GNOME Bugzilla – Bug 735557
BMP 32-bit does not normalize if <8 bits per component
Last modified: 2014-08-29 18:19:02 UTC
Hi, I've a bad rendering of some special BMP 32-bit files since v2.8.8 (and newer), while v2.8.6 is ok as well as other image viewers. There is a test image here: http://wiki.yobi.be/images/b/b3/Corkami.bmp It's a grey image, encoded as R5G6B5 (so 16-bit filters) but with 32-bit data. The problem is that apparently for 32-bit images, Gimp always assume RGB components are 8-bit but in this special image it's not the case. Red is missing 3 bits and indeed if I multiply Red channel by 8 it's restored. Same for Blue and Green must be multiplied by 4 as it's missing 2 bits. Here is a patch (copied from the 16-bit handler) to normalize components. I could not test the patch because I don't have the setup to compile Gimp from scratch. Phil
Created attachment 284648 [details] [review] Patch for bug 735557 to be tested to be tested, see bug description
In case you're wondering about the standard, see https://upload.wikimedia.org/wikipedia/commons/d/da/AllBMPformats.png 32bits BI_BITFIELDS should support [0-32].[0-32].[0-32].0.[0-32] so my file is validly constructed as 5.6.5.0.16
(In reply to comment #1) > Created an attachment (id=284648) [details] [review] > Patch for bug 735557 to be tested > > to be tested, see bug description Thank you for the patch. It was mostly correct, except that the max_values was broken perhaps due to cut-and-paste that was not edited. I've committed a fixed patch with your author name intact.
Pushed to master: * 6e73a62 file-bmp: Use masks when BI_BITFIELDS method is found * 24cf89a file-bmp: Print compression method in debug build * 1d10c4d file-bmp: Fix format specifiers * 2dac587 file-bmp: Remove unnecessary casts Cherry-picked some commits to gimp-2-8: * c7c4475 file-bmp: Use masks when BI_BITFIELDS method is found * 121b4d1 file-bmp: Print compression method in debug build * 8cb079b file-bmp: Fix format specifiers Resolving as FIXED, milestone 2.8.