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 678250 - Reading 32-bit RGBX BMP Files: Transparency Turns into Cyan
Reading 32-bit RGBX BMP Files: Transparency Turns into Cyan
Status: RESOLVED DUPLICATE of bug 678252
Product: GIMP
Classification: Other
Component: Plugins
git master
Other Linux
: Normal normal
: ---
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2012-06-17 14:09 UTC by Bastian Ilsø
Modified: 2012-06-21 00:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
XCF File with Original image and image after BMP Export/Import (891.75 KB, application/x-gzip)
2012-06-17 14:10 UTC, Bastian Ilsø
Details
Results of proposed changes in comment 2. (394.59 KB, application/zip)
2012-06-19 15:38 UTC, Bastian Ilsø
Details

Description Bastian Ilsø 2012-06-17 14:09:04 UTC
When reading a 32-bit RGBX Windows Bitmap file the pixels with the RGBA values 0,0,0,0 turn into 0,255,255,255. Color Space information does not affect the results. See also the attachment to this bug report.

This bug can be reproduced the following way:
- Export an image containing an alpha channel as 32-bit RGBX Windows Bitmap (BMP) - Import the bitmap file again into GIMP.
Comment 1 Bastian Ilsø 2012-06-17 14:10:16 UTC
Created attachment 216604 [details]
XCF File with Original image and image after BMP Export/Import
Comment 2 jigebren 2012-06-18 03:15:25 UTC
I've found a few mistakes in file:
http://git.gnome.org/browse/gimp/tree/plug-ins/file-bmp/bmp-write.c

Inside write_image(), the code:

                case RGBX_8888:
                  buf[0] = 0;
                  buf[3] = *temp++;
                  buf[2] = *temp++;
                  buf[1] = *temp++;

should be replaced by:

                case RGBX_8888:
                  buf[2] = *temp++;
                  buf[1] = *temp++;
                  buf[0] = *temp++;
                  buf[3] = 0;

And inside WriteBMP(), the code:

      switch (BMPSaveData.rgb_format)
        {
        default:
        case RGB_888:
        case RGBX_8888:
          Mask[0] = 0xff000000;
          Mask[1] = 0x00ff0000;
          Mask[2] = 0x0000ff00;
          Mask[3] = 0x00000000;
          break;

        case RGBA_8888:
          Mask[0] = 0xff000000;
          Mask[1] = 0x00ff0000;
          Mask[2] = 0x0000ff00;
          Mask[3] = 0x000000ff;
          break;

should be replaced by:

      switch (BMPSaveData.rgb_format)
        {
        default:
        case RGB_888:
        case RGBX_8888:
          Mask[0] = 0x0000ff00;
          Mask[1] = 0x00ff0000;
          Mask[2] = 0xff000000;
          Mask[3] = 0x00000000;
          break;

        case RGBA_8888:
          Mask[0] = 0x0000ff00;
          Mask[1] = 0x00ff0000;
          Mask[2] = 0xff000000;
          Mask[3] = 0x000000ff;
          break;

Sorry, I'm on Windows so I can't easily compile and try, etc.
Comment 3 Bastian Ilsø 2012-06-19 15:36:54 UTC
I have attached a zip file below showing the results of your changes. The first change you suggest results in "RGBX changes1.bmp". The first change combined with the second change you suggest results in "RGBX changes2.bmp". Applying the second change only to bmp-write.c results in "RGBX changes3.bmp". And of course, there is "RGBX nochange.bmp" which is the bmp exported from a non-modified bmp-write.c.
Comment 4 Bastian Ilsø 2012-06-19 15:38:04 UTC
Created attachment 216758 [details]
Results of proposed changes in comment 2.
Comment 5 Bastian Ilsø 2012-06-20 09:48:04 UTC
The patch I just uploaded in Bug 678252 should solve this issue. I am marking this bug report as a duplicate.

*** This bug has been marked as a duplicate of bug 678252 ***
Comment 6 jigebren 2012-06-21 00:43:04 UTC
Just for info, there was a mistake (wrong endianness) in the fix I suggested above (comment 2). The code inside WriteBMP() should be:

switch (BMPSaveData.rgb_format)
        {
        default:
        case RGB_888:
        case RGBX_8888:
          Mask[0] = 0x00ff0000;
          Mask[1] = 0x0000ff00;
          Mask[2] = 0x000000ff;
          Mask[3] = 0x00000000;
          break;

        case RGBA_8888:
          Mask[0] = 0x00ff0000;
          Mask[1] = 0x0000ff00;
          Mask[2] = 0x000000ff;
          Mask[3] = 0xff000000;
          break;

The patch kindly generated by Bastian and attached to bug 678252, comment 6 was created using this fixed modification.