BMP "CSType" field

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
Jason S
Posts: 86
Joined: 2010-12-14T19:42:12-07:00
Authentication code: 8675308

BMP "CSType" field

Post by Jason S » 2012-04-30T16:48:33-07:00

If I run "convert logo: test.bmp", IM writes a version 5 BMP file, and sets the "bV5CSType" (color space type) field to 1. My question is, what does the 1 mean? The IM source code in bmp.c has this:

Code: Select all

 (void) WriteBlobLSBLong(image,0x00000001U);  /* CSType==Calib. RGB */
But my Windows SDK tells me that "Calib. RGB" is 0, not 1:

Code: Select all

#define LCS_CALIBRATED_RGB      0x00000000L
  This value indicates that endpoints and gamma values are given in the appropriate fields.
#define LCS_sRGB                'sRGB'   // = 0x73524742
  This value implies that the bitmap is in sRGB color space.
...
And 1 is not one of the options listed in the current documentation. So, maybe it's just an error, and was supposed to be 0.

But it may not be as simple as that. A web search suggests that older documentation gave a different set of options:

Code: Select all

LCS_CALIBRATED_RGB   0
  The DIB uses the normalized sRGB colour space defined by ICM
LCS_DEVICE_RGB       1
  The DIB uses the device dependent RGB colour space defined by a display device.
  This is the definition used by the older BITMAPINFOHEADER.
LCS_DEVICE_CMYK      2
  The DIB uses the device dependent CMYK colour space defined by a printer.
So, I guess 1 could be a reasonable thing to use if the colorspace is unknown, even if it is no longer documented. (But the comment should be changed, at least.)

Aside: I observe that this older definition of LCS_CALIBRATED_RGB is different from, and incompatible with, the current definition.

Post Reply