Invalid BMP Format with Alpha channel
verpies Nov 15, 2010 5:25 PMThis post is directed to Adobe technical personnel and requires the knowledge of internal bitmap format structures.
CLAIM: Photoshop CS4 creates invalid file format when saving an image as a Bitmap
(BMP) with Alpha Channels, in the advanced format A8 R8 G8 B8.
According to Microsoft documentation of the Bitmap (BMP) format, available at:
http://msdn.microsoft.com/en-us/library/dd183376%28VS.85%29.aspx
" If the biCompression member of the BITMAPINFOHEADER is BI_RGB, <...snip...> Each DWORD in the bitmap array represents the relative intensities of blue, green, and red, respectively, for a pixel. The high byte in each DWORD is not used..."
Yet, Photoshop CS4 saves Bitmaps with Alpha Channels in the advanced format A8 R8 G8 B8 in violation of this documentation.
Specifically, Photoshop CS4 writes:
1) BITMAPINFOHEADER of the size 0x28 bytes which is equal to sizeof(BITMAPINFOHEADER)
2) biCompression member of the BITMAPINFOHEADER is set to BI_RGB
3) The high byte in each DWORD of the pixel array is USED and contains the Alpha Channel values
4) There is no indication in the Bitmap headers of the presence of Alpha Channel data described in pt.3 above.
Proposed Solution:
1) Use BITMAPV4HEADER in lieu of BITMAPINFOHEADER because it contains a mandatory Alpha Channel bitmask.
a) Alternatively use the proprietary Adobe header of the size 0x38 bytes, that Photoshop seems to be using in the wild.
2) Indicate the presence of the Alpha Channel by setting the bV4AlphaMask member of the BITMAPV4HEADER to an appropriate non-zero bitmask.
a) Optionally indicate the presence of a valid bV4AlphaMask by setting the bV4V4Compression member, to BI_ALPHABITFIELDS
b) Optionally set the bV4RedMask and bV4GreenMask and bV4BlueMask members to appropriate bitmasks
and indicate this fact by setting the bV4V4Compression member to BI_BITFIELDS or to BI_ALPHABITFIELDS
NOTE: The Microsoft documentation, available at:
http://msdn.microsoft.com/en-us/library/dd183380%28VS.85%29.aspx
...states that:
"bV4AlphaMask - Color mask that specifies the alpha component of each pixel" irrespective of the value of bV4V4Compression member of the BITMAPV4HEADER.
The same is not true about the bV4RedMask and bV4GreenMask and bV4BlueMask members of the BITMAPV4HEADER, because these members are valid only when bV4V4Compression member is set to BI_BITFIELDS (or to BI_ALPHABITFIELDS in the wild).
Also, BITMAPV5HEADER can be used instead of BITMAPV4HEADER if advanced color profile needs to be embedded, but at the expense of increased file size.





Save
Save
Save
Save
Save
Save
Save
Save