After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 735557 - BMP 32-bit does not normalize if <8 bits per component
BMP 32-bit does not normalize if <8 bits per component
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Plugins
2.8.8
Other All
: Normal normal
: 2.8
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2014-08-27 23:42 UTC by Philippe Teuwen
Modified: 2014-08-29 18:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for bug 735557 to be tested (1.53 KB, patch)
2014-08-27 23:43 UTC, Philippe Teuwen
none Details | Review

Description Philippe Teuwen 2014-08-27 23:42:41 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
Comment 1 Philippe Teuwen 2014-08-27 23:43:59 UTC
Created attachment 284648 [details] [review]
Patch for bug 735557 to be tested

to be tested, see bug description
Comment 2 Philippe Teuwen 2014-08-28 07:34:48 UTC
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
Comment 3 Mukund Sivaraman 2014-08-28 14:03:48 UTC
(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.
Comment 4 Mukund Sivaraman 2014-08-28 14:28:00 UTC
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.