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 678248 - Gimp reading 32-bit BMP files with BITMAPV5HEADER: Pixbuf ignores alpha channel
Gimp reading 32-bit BMP files with BITMAPV5HEADER: Pixbuf ignores alpha channel
Status: RESOLVED FIXED
Product: gdk-pixbuf
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gdk-pixbuf-maint
gdk-pixbuf-maint
Depends on:
Blocks:
 
 
Reported: 2012-06-17 13:23 UTC by Bastian Ilsø
Modified: 2012-06-20 16:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch which fixes problems importing 32-bit RGBA V5 BMP files. (38.75 KB, patch)
2012-06-17 13:25 UTC, Bastian Ilsø
none Details | Review

Description Bastian Ilsø 2012-06-17 13:23:31 UTC
Gimp can read and write 32-bit Windows Bitmap files. 32-bit BMP files are read using GDK, but GDK doesn't appear to read the 4th channel, hence ignoring transparency. This bug report is derived from bug 676219 and below I have quoted Jigebren who discovered that the issue lied within gdk-pixbuf:

"In OneLine32(), we can see that the alpha component is simply overwritten with
0xff:
        for (i = 0; i < context->Header.width; i++) {
            *pixels++ = src[2];
            *pixels++ = src[1];
            *pixels++ = src[0];
            *pixels++ = 0xff;

            src += 4;
        }

Not to lose the alpha channel it should be:
            *pixels++ = src[2];
            *pixels++ = src[1];
            *pixels++ = src[0];
            *pixels++ = src[3];

I don't know whether or not GDK is supposed to support alpha in BMP files. But
as far as Gimp is concerned it sounds inconsistent not to be able to properly
read again a file it has written itself..."
(See also comment 10 in Bug 676219)

I have submitted a patch with Jigebren's suggested changes to this bug report.
Comment 1 Bastian Ilsø 2012-06-17 13:25:12 UTC
Created attachment 216601 [details] [review]
Patch which fixes problems importing 32-bit RGBA V5 BMP files.
Comment 2 jigebren 2012-06-19 04:56:30 UTC
After second reading of:
http://git.gnome.org/browse/gdk-pixbuf/tree/gdk-pixbuf/io-bmp.c
it appears that the alpha channel is actually supported in BMP if bV5Compression is set to BI_BITFIELDS, which seems to be the less ambiguous way to support alpha channel in BMP.

The issue still comes in fact from Gimp bmp-write.c module: Bug 678252 also prevents to save BMP using the BI_BITFIELDS format.

But a buggy ARGB BMP file exported from Gimp and then fixed in an hexadecimal editor to set the BI_BITFIELDS and add the 4 Color masks is properly loaded by Gimp / GDK (with alpha channel).

This bug report can safely be closed.