The two newest DIB headers say what the
stored colours mean. BITMAPV4HEADER names a colour space or describes one
with primaries and gamma, and BITMAPV5HEADER adds a rendering intent and an
ICC colour profile. Older headers carry no colour information, and readers treat their
colours as sRGB.
00000046 42 47 52 73
LCS_sRGB as stored: the value 0x73524742, little-endianColour space type
The field bV4CSType (or bV5CSType) at offset 56 of the header
says which colour space applies. Its values are four letters read as a little-endian
number, so sRGB appears in the file as BGRs.
| Value | Name | Meaning |
|---|---|---|
| 0x00000000 (0) | LCS_CALIBRATED_RGB | Use the endpoints and gamma in the header. |
| 0x73524742 ('sRGB') | LCS_sRGB | The colours are sRGB. |
| 0x57696E20 ('Win') | LCS_WINDOWS_COLOR_SPACE | The system’s default colour space, sRGB in practice. |
| 0x4C494E4B ('LINK') | PROFILE_LINKED | V5 only: a profile in another file, named in the profile data. |
| 0x4D424544 ('MBED') | PROFILE_EMBEDDED | V5 only: an ICC profile stored in this file. |
Endpoints and gamma
These fields are used only when the type is LCS_CALIBRATED_RGB; otherwise
they are ignored and usually zero. Offsets are from the start of the header.
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 60 | 36 | CIEXYZTRIPLE | bV4Endpoints | The CIE XYZ coordinates of the red, green and blue primaries, in that order. Each is three 2.30 fixed point numbers: 2 integer bits and 30 fraction bits. |
| 96 | 4 | u32 | bV4GammaRed | The red tone response, as unsigned 16.16 fixed point. |
| 100 | 4 | u32 | bV4GammaGreen | The green tone response. |
| 104 | 4 | u32 | bV4GammaBlue | The blue tone response. |
In 16.16 fixed point the top 16 bits are the whole number and the bottom 16 the
fraction, so a gamma of 2.2 is stored as 0x00023333.
Rendering intent
bV5Intent, at offset 108 of a V5 header, says how colours outside the
output device’s range should be handled.
| Value | Name | ICC intent |
|---|---|---|
| 0x01 (1) | LCS_GM_BUSINESS | Saturation |
| 0x02 (2) | LCS_GM_GRAPHICS | Relative colorimetric |
| 0x04 (4) | LCS_GM_IMAGES | Perceptual |
| 0x08 (8) | LCS_GM_ABS_COLORIMETRIC | Absolute colorimetric |
ICC profile
When the type is PROFILE_EMBEDDED or PROFILE_LINKED, two V5
fields locate the profile data:
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
| 112 | 4 | u32 | bV5ProfileData | The offset of the profile data, measured from the start of the V5 header, not the start of the file. |
| 116 | 4 | u32 | bV5ProfileSize | The size of the profile data in bytes. |
In a file the header starts at offset 14, so the profile is at
14 + bV5ProfileData. An embedded profile is a complete ICC profile. A linked
profile is a file name, ended by a zero byte, in the Windows-1252 character set. Readers
find the profile only through this offset, so it can sit anywhere after the header.