| Summary: | 32-bit BMPs with alpha channel saved with GIMP 2.8 not handled correctly | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Wei Mingzhi <weimingzhi> |
| Component: | video | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | minor | ||
| Priority: | P2 | CC: | icculus, soryy708 |
| Version: | HG 2.1 | ||
| Hardware: | x86_64 | ||
| OS: | Windows 8 | ||
I ran into this a few weeks ago and put a hack into SDL, but this is a clear explanation of what would need to change to make a proper fix. Stealing this bug. --ryan. (In reply to Ryan C. Gordon from comment #1) > I ran into this a few weeks ago and put a hack into SDL, but this is a clear > explanation of what would need to change to make a proper fix. > > Stealing this bug. > > --ryan. So what we do is look for a 40-byte BITMAPINFOHEADER (and if the reported size of this header is more than 40 bytes, we throw away the difference by seeking over it). Gimp's extra field we're ignoring is because they write out a BITMAPV5INFOHEADER. v2 added the RGB masks, v3 added alpha. I'm cleaning this up a little in SDL now. --ryan. Ok, my totally incorrect hack is gone, and this is fixed properly in https://hg.libsdl.org/SDL/rev/08f3b56969b1 ...let me know if this gives you further grief. --ryan. cool :) thanks. |
From GIMP source code: gimp-2.8.14/plug-ins/file-bmp/bmp.h: extern struct Bitmap_File_Head_Struct { gchar zzMagic[2]; /* 00 "BM" */ gulong bfSize; /* 02 */ gushort zzHotX; /* 06 */ gushort zzHotY; /* 08 */ gulong bfOffs; /* 0A */ gulong biSize; /* 0E */ } Bitmap_File_Head; extern struct Bitmap_Head_Struct { glong biWidth; /* 12 */ glong biHeight; /* 16 */ gushort biPlanes; /* 1A */ gushort biBitCnt; /* 1C */ gulong biCompr; /* 1E */ gulong biSizeIm; /* 22 */ gulong biXPels; /* 26 */ gulong biYPels; /* 2A */ gulong biClrUsed; /* 2E */ gulong biClrImp; /* 32 */ guint32 masks[4]; /* 36 */ } Bitmap_Head; However currently SDL2 does not use the "masks" field in Bitmap_Head_Struct struct (which contains the masks for R/G/B/A channels). Not sure if what the GIMP is doing is standard behavior though (cannot find documentation about this one, and M$ does not use the "masks" field), also I can manually hack the BMP file by putting the masks to where SDL2 uses to make it work with SDL2 so this should be considered as a minor issue.