Using Structures in ICM 2.0

[This is preliminary documentation and subject to change.]

Most of the structures used by ICM 2.0 are very straightforward and require little explanation. They are documented in the ICM 2.0 Reference section entitled ICM 2.0 Structures.

Exceptions are the COLORMATCHSETUP structure used by the SetupColorMatching function, and the following Windows structures defined in Wingdi.h:

The following topics are discussed at greater length:

Windows Bitmap Header Structures

[This is preliminary documentation and subject to change.]

ICM 2.0 allows ICC color profiles to be linked or embedded in device-independent bitmaps (DIBs). This allows DIB colors to be characterized more accurately than was possible using ICM in Windows 95. BITMAPV5HEADER, the new bitmap header structure, is defined in Wingdi.h in the release of Windows 98. For development purposes, it is also included in the file Icm.h with this Programmer's Reference. The BITMAPV5HEADER structure is as follows:

typedef struct {
   DWORD        bV5Size;
   LONG         bV5Width;
   LONG         bV5Height;
   WORD         bV5Planes;
   WORD         bV5BitCount;
   DWORD        bV5Compression;
   DWORD        bV5SizeImage;
   LONG         bV5XPelsPerMeter;
   LONG         bV5YPelsPerMeter;
   DWORD        bV5ClrUsed;
   DWORD        bV5ClrImportant;
   DWORD        bV5RedMask;
   DWORD        bV5GreenMask;
   DWORD        bV5BlueMask;
   DWORD        bV5AlphaMask;
   DWORD        bV5CSType;
   CIEXYZTRIPLE bV5Endpoints;
   DWORD        bV5GammaRed;
   DWORD        bV5GammaGreen;
   DWORD        bV5GammaBlue;
   DWORD        bV5Intent;         // Rendering intent for bitmap
   DWORD        bV5ProfileData;    // Offset to profile data
   DWORD        bV5ProfileSize;    // Size of embedded profile data
   DWORD        bV5Reserved;       // For future use - should be zero
} BITMAPV5HEADER, FAR *LPBITMAPV5HEADER, *PBITMAPV5HEADER;
 

The member bV5CSType can have the values PROFILE_EMBEDDED or PROFILE_LINKED to specify whether a profile is embedded or linked with the DIB. The member bV5ProfileData is the offset in bytes from the beginning of the BITMAPV5HEADER structure to the start of the profile data. If the profile is embedded, profile data is the actual profile, and if it is linked, the profile data is the null-terminated file name of the profile. This cannot be a Unicode string. It must be composed exclusively of characters from the Windows character set (code page 1252).

When a DIB is loaded into memory, the profile data (if present) should follow the color table, and bV5ProfileData should give the offset of the profile data from the beginning of the BITMAPV5HEADER structure. The value of this member will be different now, as the bitmap bits do not follow the color table in memory. Applications should modify the bV5ProfileData member after loading the DIB into memory.

For packed DIBs, the profile data should follow the bitmap bits similar to the file format. The bV5ProfileData member should still give the offset of the profile data from the beginning of the BITMAPV5HEADER structure.

Applications should access the profile data only when bV5Size == sizeof(BITMAPV5HEADER) AND bV5CSType is PROFILE_EMBEDDED or PROFILE_LINKED.

If a profile is linked, the path of the profile can be any fully qualified name (including a network path) that can be opened using the Win32 CreateFile function.

Differences Between V4 and V5 Headers

In working with the new bitmap structure, it is useful to recognize differences in how BITMAPV4HEADER and BITMAPV5HEADER structures are set up:

V4 Header

  1. bV4CSType = LCS_CALIBRATED_RGB. This value implies that end points and gammas are given in the appropriate fields. Bogus values cause trouble.
  2. bV4CSType = LCS_sRGB. This value implies that the bitmap is in sRGB color space (gammas and endpoints ignored).
  3. bV4CSType = LCS_WINDOWS_COLOR_SPACE. This value implies that the bitmap is in Windows default color space.

V5 Header

  1. bV5CSType = LCS_CALIBRATED_RGB. This value implies that end points and gammas are given in the appropriate fields. Bogus values cause trouble.
  2. bV5CSType = LCS_sRGB. This value implies that the bitmap is in sRGB color space (gammas and endpoints ignored).
  3. bV5CSType = PROFILE_EMBEDDED. This value implies that bV5ProfileData points to a memory buffer that contains the profile to use (gammas and endpoints are ignored).
  4. bV5CSType = PROFILE_LINKED. This value implies that bV5ProfileData points to the file name of the profile to use (gammas and endpoints are ignored).
  5. bV5CSType = LCS_WINDOWS_COLOR_SPACE. This value implies that the bitmap is in Windows default color space.

In order to convert older bitmaps to and from the new BITMAPV5HEADER structure, a command-line conversion utility file named Bitmap.exe is included in the ICM 2.0 Programmer's Reference.

BitMap.exe: a Command-Line Utility for Converting Bitmap Headers

Bitmap.exe is a command-line utility located in the \Bin folder under the installation folder that you specified. It modifies the headers of Windows bitmaps, allowing you to convert existing bitmaps from BITMAPINFOHEADER and BITMAPV4HEADER header structures to the newer BITMAPV5HEADER structure and back again. The command-line syntax is as follows:

BITMAP [/d] [/1|4|5] [/s] [/f] filename
 

The command-line switches have the following effects.

Meaning
/d Default values are automatically entered in the converted headers.
/1 Convert the specified bitmaps to BITMAPINFOHEADER
/4 Convert the specified bitmaps to BITMAPV4HEADER
/5 Convert the specified bitmaps to BITMAPV5HEADER
/f Forces conversion, even if the bitmap already has the right header
/s Converts bitmaps in the specified folder and all subdirectories under it