You are on page 1of 45

Microsoft Color Match

Specification

Document Version: 0.991


Revision Date: Aug 28, 1996
Author: Srinivasan Chandrasekar, Microsoft Corp.

Microsoft Confidential 1
1. Introduction____________________________________________________________________
2. Color Matching outside the DC using Microsoft Color Match___________________________
3. Profile Management using Microsoft Color Match____________________________________
3.1. Adding color profiles to the system_____________________________________________________
4. Color matching inside the DC using Microsoft Color Match_____________________________
4.1. DIB enhancements__________________________________________________________________
4.2. sRGB color space support____________________________________________________________
5. Data Structures for applications using Microsoft Color Match___________________________
6. Microsoft Color Match Application Programming Interfaces____________________________
6.1. Color Matching outside the DC________________________________________________________
6.2. Profile element accessing_____________________________________________________________
6.3. Profile management_________________________________________________________________
7. Color Matching Modules_________________________________________________________
8. CMM Structures and Definitions___________________________________________________
9. CMM function interface__________________________________________________________
10. INF file format for installing profiles______________________________________________

Microsoft Confidential 2
1 Introduction
Image Color Matching (ICM), the first implementation of color matching technology in a Microsoft operating
system, was released in Windows 95 with the initial goals of providing simple and easy to use application program
interfaces (API’s) and a simple user experience. ICM has achieved these goals and provided a platform for a range of
testing and evaluation both within Microsoft and in the industry at large. Feedback from ISV’s, IHV’s, and internal
sources has been reviewed to generate an enhanced set of requirements for color matching. These requirements have
been used to create Microsoft Color Match, the new color management system from Microsoft.
Microsoft Color Match is a superset of ICM and provides a rich set of Windows APIs for applications to handle tasks
like profile management, profile searching and accessing, color matching and gamut checking easily. Using these,
applications can work in several color spaces and are not limited to the RGB space that existing Windows APIs
understand. The profile management functionality allows applications to install, remove and associate profiles with
devices, search and retrieve profiles satisfying certain criteria, and read, write and modify profile tags.
Microsoft Color Match has the following components:
1. Color matching using the Windows Device Context (DC) (formerly called ICM). Microsoft has enhanced the
original ICM implementation to provide better color matching support using the DC.
2. Functionality to perform color matching and profile management outside of the DC.
3. An enhanced Color Matching Module (CMM).
This document presents the functionality provided by Microsoft Color Match, and is intended as a preview for ISVs
and OEMs that wish to support Microsoft Color Match in their products. It should be noted that the system is under
development and this document is subject to change.

2 Color Matching outside the DC using Microsoft Color Match


Using Windows 95 ICM, all color matching had to be done using a Device Context (DC). This imposed artificial
limitations on the capabilities exposed to applications based on the DC model. Microsoft Color Match provides
functionality for applications to work completely outside the DC and create and manage color transforms directly.
Using these new APIs, applications can create multi-profile transforms, transforms using device link profiles etc., and
use these transforms directly to perform their color matching and gamut checking functions.
The following is a list of color matching APIs provided by Microsoft Color Match to perform color matching outside
the DC:
CreateColorTransform Creates a color transform
CreateMultiProfileTransform Uses multiple profiles or device-link profiles to create a transform
DeleteColorTransform Deletes a color transform
TranslateColors Converts an array of colors from source to destination color space
CheckColors Checks if an array of colors falls within the output gamut
TranslateBitmapBits Converts the colors of a bitmap from source to destination color
space
CheckBitmapBits Checks if the colors in a bitmap fall within the output gamut
GetCMMInfo Retrieves information about CMM that created the given transform
RegisterCMM Registers a CMM that can be used by the system
UnRegisterCMM Removes the CMM registration, so it cannot be used by the system
SelectCMM Specifies the application preferred CMM to use. It should be
registered with the system.

Microsoft Color Match supports the following color spaces in the above APIs.
· RGB
· CMYK
· XYZ
· Yxy
· Lab
· Named color space
· HiFi color space up to 8 color channels

Microsoft Confidential 3
· Arbitrary 3 channel color spaces like Luv, Ycc etc.
Support for all these color spaces is based on the availability of the correct profile. For example, to translate a color
from a named color space to CMYK values, you need to create a transform using two profiles - an input named color
profile, and an output CMYK profile, and use this transform for color matching the named colors.
Note that while Microsoft Color Match understands XYZ, Yxy and Lab color spaces (i.e. it can translate from any of
these color spaces to another internally when combining profiles), it does not understand other device independent
color spaces like Luv, and requires ICC profiles to translate colors between these color spaces.
Microsoft Color Match supports the following bitmap formats in the above color spaces:
Bitmap Format Color spaces supported
1 bpp Gray
16 bpp (5 bits per channel - msb ignored) RGB, XYZ, Yxy, Lab, Generic 3 color
Packed 8 bits per channel Gray (8 bpp)
RGB, XYZ, Yxy, Lab, Generic 3 color (24 bpp)
32 bpp (8 bits per channel) RGB, XYZ, Yxy, Lab, Generic 3 color (MSB ignored)
CMYK
32 bpp (10 bits per channel) RGB, XYZ, Yxy, Lab, Generic 3 color
Packed 16 bits per channel Gray (16 bpp)
RGB, XYZ, Yxy, Lab, Generic 3 color (48 bpp)

3 Profile Management using Microsoft Color Match


Every device instance can have a set of profiles associated with it. Profile management involves associating profiles
with device instances. The best way to think of this is to imagine several bins or buckets, each having some profiles
in it. Each device instance points to a bucket, and all profiles in that bucket are available for that device to use.
Multiple devices could point to the same bucket. This usually happens if you have multiple instances of the same
device model, and want to share profiles among them. Ex. you have two HP 1200C PS printers and want to use the
same set of profiles for both of them. It is also possible in this scheme to have these two printers point to different
buckets, thereby not share profiles - this allows you to calibrate each printer separately and use a different set of
profiles with each printer.
The figure below shows a specific configuration where the user shares the same set of profiles between two Canon
BJC 600e’s, but uses different sets of profiles for two HP 1200C PS printers.

Devices :
HP 1200C PS (Copy 1) HP 1200C PS (Copy 2) Canon BJC 600e Canon BJC 600e
(1) (2)

Profile buckets:

HP 1200C PS-generic HP 1200C PS (Copy 2) Canon BJC 600e-generic

The following is a list of profile management APIs supported by Microsoft Color Match:
AddColorProfiles Adds color profiles to the system for a device instance
RemoveColorProfiles Removes color profiles from a device instance
CreateNewColorProfileSet Sets up the system so that profiles for this device are not shared
EnumColorProfiles Enumerates all color profiles associated with a device instance
GetSystemColorProfile Retrieves the system profile for given predefined color space
SearchColorProfiles Searches for profiles satisfying search criteria.

NOTE: Applications are strongly discouraged from using the old ICM API UpdateICMRegKey. It is retained in
Microsoft Color Match for backward compatibility, and will become obsolete in future.

Microsoft Confidential 4
Besides providing the capability to manage profiles, Microsoft Color Match also provides rich APIs to manipulate the
data in color profiles. The following is a list of profile manipulation APIs provided:
OpenColorProfile Opens a profile and returns a handle to it
CloseColorProfile Closes the profile
CreateDeviceLinkProfile Creates an ICC device-link profile
IsColorProfileValid Checks if a given profile is a valid ICC profile
IsColorProfileTagPresent Checks if a given tag is present in the profile
GetCountColorProfileElements Returns number of tagged elements in the profile
GetColorProfileElement Retrieves element data from a profile element
GetColorProfileElementTag Retrieves the tag name from a profile element
GetColorProfileHeader Retrieves the header from a profile
SetColorProfileElementSize Sets the size of a profile element
SetColorProfileElement Sets the element data for a profile element
SetColorProfileElementReference Creates a new tag that refers to the data of an existing tag
SetColorProfileHeader Sets the header in a profile
GetPS2ColorSpaceArray Retrieves the PostScript color space array from a profile
GetPS2ColorRenderingIntent Retrieves the PostScript color rendering intents from a profile
GetPS2ColorRenderingDictionary Retrieves the PostScript color rendering dictionary from a profile

3.1 Adding color profiles to the system


A color profile can be added to the system in two ways:
1. By a printer installation program while installing a new printer. The INF file that lists the printer also lists the
color profiles to be installed with the printer. The printer installation program reads this INF file and installs
the profiles.
2. By an end user who buys profiles from a third part vendor. The vendor needs to supply an INF file that maps
<manufacturer> and <model> tags in the profile to Windows device model names. See Section 10 “INF file
format for installing profiles” for the syntax of these INF files. The system profile installer reads this INF file.

4 Color matching inside the DC using Microsoft Color Match


Microsoft Color Match is completely compatible with Windows 95 ICM, and supports all the Windows APIs provided
by ICM. Please refer to the Windows SDK or MSDN for more information on these APIs. This section introduces the
enhancements made to color matching using the DC in Microsoft Color Match.

4.1 DIB enhancements


Microsoft Color Match 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. The new
bitmap header structure is given below.
typedef struct BITMAPV5HEADER {
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;

Microsoft Confidential 5
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, *PBITMAPV5HEADER;
The field bV5CSType can have the following values - ‘MBED’ or ‘LINK’ to specify whether a profile is embedded or
linked with the DIB. The field 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 filename of the profile.
The disk format of the DIB on file is as shown below.

BITMAP FILE HEADER

BITMAPV5HEADER
bV5ProfileData

Color Table

BITMAP DATA

PROFILE DATA

Applications should use the first DWORD (bV5Size) in the bitmap header structure to decide if it is a
BITMAPCOREHEADER, BITMAPINFOHEADER, BITMAPV4HEADER or a BITMAPV5HEADER.
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. NOTE that the
value of this field will be different now as the bitmap bits do not follow the color table in memory. Applications
should modify the bV5ProfileData field after loading the DIB into memory.
For packed DIBs, the profile data should follow the bitmap bits similar to the file format. The bV5ProfileData should
still give the offset of the profile data from the beginning of the BITMAPV5HEADER structure.
NOTE: Applications should access the profile data only when bV5Size == sizeof(BITMAPV5HEADER) AND
bV5CSType is ‘MBED’ or ‘LINK’.
NOTE: If a profile is linked, the path name to the profile can be any fully qualified name (including a network path
name) that can be opened using the Win32 API CreateFile().

4.2 sRGB color space support


When we transfer an image from one system to another, we necessarily have to embed a profile with the image in
order to characterize the colors in the image. This increases the size of the image by about 30-100MB depending on
the size of the profile. There are several situations where it is not appropriate to add this extra overhead in order to
perform accurate color matching. An example is when an image is being transmitted over the Internet or other low
bandwidth networks.

Microsoft Confidential 6
Microsoft Color Match alleviates the above problem by providing native support for a predefined color space called
the sRGB color space. Microsoft and Hewlett-Packard have defined a variation of the RGB-709 color space to be the
sRGB color space. Images defined in sRGB color space need not have profiles attached to them in order to be color
matched using Microsoft Color Match. They however need to be identified to be in this color space. Different file
formats will use/add a flag to specify that the image is in sRGB color space. In the Windows DIB format, the
bV5CSType field of the DIB header should be set to LCS_sRGB to specify that the DIB colors are in this color space.
There are two ways an application can display an image defined in sRGB color space.
· It can use color matching outside the DC described earlier to create a transform using CreateColorTransform(),
where the lcsCSType field of the LogColorSpace structure is set to LCS_sRGB, and the destination profile
represents the display device’s color space, color match the image using this transform, and image it on the
display device.
OR
· It can use color matching inside the DC to create a DC on the display device, turn on color matching using
SetICMMode(), and BitBlt() the DIB into the DC. Windows will understand that the image is in sRGB color
space by looking at the bV5CSType field in the DIB header and perform color matching appropriately.

5 Data Structures for applications using Microsoft Color Match


struct GRAYCOLOR {
WORD gray;
};

struct RGBCOLOR {
WORD red; // 0 -> 0xFFFF
WORD green; // 0 -> 0xFFFF
WORD blue; // 0 -> 0xFFFF
};

struct CMYKCOLOR {
WORD cyan; // 0 -> 0xFFFF
WORD magenta; // 0 -> 0xFFFF
WORD yellow; // 0 -> 0xFFFF
WORD black; // 0 -> 0xFFFF
};

struct XYZCOLOR {
WORD X; // 0 -> 1.99997 encoded as 0 -> 0xFFFF
WORD Y; // 0 -> 1.99997 encoded as 0 -> 0xFFFF
WORD Z; // 0 -> 1.99997 encoded as 0 -> 0xFFFF
};

struct YxyCOLOR {
WORD Y;
WORD x;
WORD y;
};

struct LabCOLOR {
WORD L; // 0 -> 100 encoded as 0 -> 0xFF00
WORD a; // -128 -> +127.996 encoded as 0 -> 0xFFFF
WORD b; // -128 -> +127.996 encoded as 0 -> 0xFFFF
};

struct GENERIC3CHANNEL {

Microsoft Confidential 7
WORD ch1;
WORD ch2;
WORD ch3;
};

/*
* Named colors can be referred to by an index or by the color name. Usually
* the index value is used. If the index value is 0xffffffff, it is ignored
* and the color name is used.
* The color name is organized as follows:
* NULL terminated color name prefix followed by
* NULL terminated color root name followed by
* NULL terminated color name suffix.
* This definition of color name makes it consistent with the ICC specification
* of how color names are referenced inside ICC profiles.
*/
struct NAMEDCOLOR {
DWORD dwIndex; // Set to 0xffffffff to ignore index and use only pName
PSTR pName; // Pointer to color name
};

#define MAX_COLOR_CHANNELS 8

struct HiFiCOLOR {
BYTE channel[MAX_COLOR_CHANNELS]; // 0 -> 0xFF
};

/*
* Microsoft Color Match Color Data Structure
*/
typedef union {
struct GRAYCOLOR gray;
struct RGBCOLOR rgb;
struct CMYKCOLOR cmyk;
struct XYZCOLOR XYZ;
struct YxyCOLOR Yxy;
struct LabCOLOR Lab;
struct GENERIC3CHANNEL gen3ch;
struct NAMEDCOLOR named;
struct HiFiCOLOR hifi;
} COLOR, *PCOLOR;

/*
* Color Type definitions defines what color space COLOR is defined in
*/
typedef enum {
COLOR_GRAY = 1,
COLOR_RGB,
COLOR_XYZ,
COLOR_Yxy,
COLOR_Lab,
COLOR_3_CHANNEL, // WORD per channel
COLOR_CMYK,
COLOR_5_CHANNEL, // BYTE per channel
COLOR_6_CHANNEL, // - do -
COLOR_7_CHANNEL, // - do -

Microsoft Confidential 8
COLOR_8_CHANNEL, // - do -
COLOR_PANTONE, // Other named colors can be added
} COLORTYPE;
typedef COLORTYPE *PCOLORTYPE;

/*
* Color types supported in bitmaps. The funny numbering is for compatibility.
*/
typedef enum {
/*
* 1 bpp
*/
BM_1GRAY = 0x0005,

/*
* 16bpp - 5 bits per channel. The most significant bit is ignored.
*/
BM_x555RGB = 0x0000,
BM_x555XYZ = 0x0101,
BM_x555Yxy,
BM_x555Lab,
BM_x555G3CH,

/*
* Packed 8 bits per channel => 8bpp for GRAY and
* 24bpp for the 3 channel colors
*/
BM_RGBTRIPLETS = 0x0002,
BM_BGRTRIPLETS = 0x0004,
BM_XYZTRIPLETS = 0x0201,
BM_YxyTRIPLETS,
BM_LabTRIPLETS,
BM_G3CHTRIPLETS,
BM_8GRAY,

/*
* 32bpp - 8 bits per channel. The most significant byte is ignored
* for the 3 channel colors.
*/
BM_xRGBQUADS = 0x0008,
BM_xBGRQUADS = 0x0010,
BM_xXYZQUADS = 0x0301,
BM_xYxyQUADS,
BM_xLabQUADS,
BM_xG3CHQUADS,
BM_CMYKQUADS = 0x0020,

/*
* 32bpp - 10 bits per channel. The 2 most significant bits are ignored.
*/
BM_10b_RGB = 0x0009,
BM_10b_XYZ = 0x0401,
BM_10b_Yxy,
BM_10b_Lab,
BM_10b_G3CH,

Microsoft Confidential 9
/*
* Packed 16 bits per channel => 16bpp for GRAY and
* 48bpp for the 3 channel colors.
*/
BM_16b_RGB = 0x000A,
BM_16b_XYZ = 0x0501,
BM_16b_Yxy,
BM_16b_Lab,
BM_16b_G3CH,
BM_16b_GRAY,
/*
* 16 bpp - 5 bits for Red & Blue, 6 bits for Green
*/
BM_565RGB = 0x0001,
} BMFORMAT;
typedef BMFORMAT *PBMFORMAT;

/*
* Profile data structure used by applications
*/
typedef struct tagPROFILE {
DWORD dwType; // profile type
PVOID pProfileData; // filename or buffer containing profile
DWORD cbDataSize; // size of profile data
} PROFILE;
typedef PROFILE *PPROFILE;

/*
* Profile types to be used in the PROFILE structure
*/
#define PROFILE_FILENAME 1 // profile data is NULL terminated filename
#define PROFILE_MEMBUFFER 2 // profile data is a buffer containing
// the profile

/*
* Handles returned to applications
*/
typedef HANDLE HPROFILE; // handle to profile object
typedef HPROFILE *PHPROFILE;
typedef HANDLE HTRANSFORM; // handle to color transform object

/*
* Device types for profile management APIs
*/
typedef enum {
DEV_INPUT,
DEV_DISPLAY,
DEV_OUTPUT,
} DEVTYPE;

/*
* Tags found in ICC profiles
*/
typedef DWORD TAGTYPE;

Microsoft Confidential 10
typedef TAGTYPE *PTAGTYPE;

typedef struct tagTAGDATA {


TAGTYPE tagType;
DWORD dwOffset;
DWORD cbSize;
} TAGDATA;
typedef TAGDATA *PTAGDATA;

/*
* ICC profile header
*/
typedef struct tagPROFILEHEADER {
DWORD phSize; // profile size in bytes
DWORD phCMMType; // CMM for this profile
DWORD phVersion; // profile format version number
DWORD phClass; // type of profile
DWORD phDataColorSpace; // color space of data
DWORD phConnectionSpace; // PCS
DWORD phDateTime[3]; // date profile was created
DWORD phSignature; // magic number
DWORD phPlatform; // primary platform
DWORD phProfileFlags; // various bit settings
DWORD phManufacturer; // device manufacturer
DWORD phModel; // device model number
DWORD phAttributes[2]; // device attributes
DWORD phRenderingIntent; // rendering intent
CIEXYZ phIlluminant; // profile illuminant
DWORD phCreator; // profile creator
BYTE phReserved[44]; // reserved for future use
} PROFILEHEADER;
typedef PROFILEHEADER *PPROFILEHEADER;

/*
* Profile class values
*/
#define CLASS_MONITOR 'mntr'
#define CLASS_PRINTER 'prtr'
#define CLASS_SCANNER 'scnr'
#define CLASS_LINK 'link'
#define CLASS_ABSTRACT 'abst'
#define CLASS_COLORSPACE 'spac'
#define CLASS_NAMED 'nmcl'

/*
* Color space values
*/
#define SPACE_XYZ 'XYZ '
#define SPACE_Lab 'Lab '
#define SPACE_Luv 'Luv '
#define SPACE_YCbCr 'YCbr'
#define SPACE_Yxy 'Yxy '
#define SPACE_RGB 'RGB '
#define SPACE_GRAY 'GRAY'
#define SPACE_HSV 'HSV '

Microsoft Confidential 11
#define SPACE_HLS 'HLS '
#define SPACE_CMYK 'CMYK'
#define SPACE_CMY 'CMY '

/*
* Profile flag bitfield values
*/
#define FLAG_EMBEDDEDPROFILE 0x00000001
#define FLAG_DEPENDENTONDATA 0x00000002

/*
* Profile attributes bitfield values
*/
#define ATTRIB_TRANSPARENCY 0x00000001
#define ATTRIB_MATTE 0x00000002

/*
* Rendering intents
*/
#define PERCEPTUAL 0
#define RELATIVE_COLORIMETRIC 1
#define SATURATION 2
#define ABSOLUTE_COLORIMETRIC 3

/*
* Profile search data structure
*/
typedef struct tagSEARCHTYPE {
DWORD stSize; // Size of structure
DWORD stFields; // Bit fields
DWORD stCMMType;
DWORD stClass;
DWORD stDataColorSpace;
DWORD stProfileConnectionSpace;
DWORD stSignature;
DWORD stPlatform;
DWORD stProfileFlags;
DWORD stDeviceManufacturer;
DWORD stDeviceModel;
DWORD stDeviceAttributes[2];
DWORD stRenderingIntent;
DWORD stProfileCreator;
} SEARCHTYPE, *PSEARCHTYPE;

/*
* Bitfields for search record above
*/
#define ST_CMMTYPE 0x00000001
#define ST_CLASS 0x00000002
#define ST_DATACOLORSPACE 0x00000004
#define ST_CONNECTIONSPACE 0x00000008
#define ST_SIGNATURE 0x00000010
#define ST_PLATFORM 0x00000020
#define ST_PROFILEFLAGS 0x00000040
#define ST_MANUFACTURER 0x00000080
#define ST_MODEL 0x00000100

Microsoft Confidential 12
#define ST_ATTRIBUTES 0x00000200
#define ST_RENDERINGINTENT 0x00000400
#define ST_CREATOR 0x00000800

typedef DWORD (WINAPI *PPROFILECALLBACK)(PPROFILE, PVOID);

Microsoft Confidential 13
6 Microsoft Color Match Application Programming Interfaces

6.1 Color Matching outside the DC

HTRANSFORM WINAPI CreateColorTransform(


LPLOGCOLORSPACE pLogColorSpace,
HPROFILE hDestProfile,
HPROFILE hTargetProfile
);

The CreateColorTransform function creates a color transform that applications can use to perform color matching.

Parameter Description
pLogColorSpace Pointer to the input LogColorSpace
hDestProfile Handle to profile of destination device
hTargetProfile Handle to profile of target device

Returns
If the function is successful, the return value is a handle that identifies the color transform. Otherwise it returns
NULL. To get extended error information, call GetLastError.

Comments
If the target profile is NULL, the transform goes from the source logical color space to the destination profile. If the
target profile is given, the transform goes from the source logical color space to the target profile and then to the
destination profile. This allows previewing output meant for the target device on the destination device.

Microsoft Confidential 14
HTRANSFORM WINAPI CreateMultiProfileTransform(
PHPROFILE pahProfiles,
DWORD nProfiles,
DWORD indexPreferredCMM
);

The CreateMultiProfileTransform function accepts an array of profiles or a single device link profile and creates a
color transform that applications can use to perform color matching.

Parameter Description
pahProfiles Pointer to an array of handles to the profiles to be used
nProfiles Number of profiles in the array
indexPreferredCMM Zero based index of the profile that specifies the CMM to use

Returns
If the function is successful, the return value is a handle that identifies the color transform. Otherwise it returns
NULL. To get extended error information, call GetLastError.

Comments
If a device link profile is being used, nProfiles should be 1, otherwise the function will fail.

BOOL WINAPI DeleteColorTransform(


HTRANSFORM hColorTransform
);

The DeleteColorTransform function deletes the given color transform.

Parameter Description
hColorTransform Identifies the color transform to delete

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero. To get extended error information, call
GetLastError.

Microsoft Confidential 15
BOOL WINAPI TranslateColors(
HTRANSFORM hColorTransform,
PCOLOR paInputColors,
DWORD nColors,
COLORTYPE ctInput,
PCOLOR paOutputColors,
COLORTYPE ctOutput
);

The TranslateColors function translates an array of colors from the source colorspace to the destination colorspace
as defined by a color transform.

Parameter Description
hColorTransform Identifies the color transform to use
paInputColors Pointer to an array of COLOR structures to translate
nColors Number of elements in the array
ctInput Specifies the input color type
paOutputColors Pointer to array of COLOR structures that receive the translated colors.
Number of elements in this array should also be nColors.
CtOutput Specifies the output color type

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero. To get extended error information, call
GetLastError.

Comments
If the input and the output color types are not compatible with the color transform, this function fails.

Microsoft Confidential 16
BOOL WINAPI CheckColors(
HTRANSFORM hColorTransform,
PCOLOR paInputColors,
DWORD nColors,
COLORTYPE ctInput,
PBYTE paResult
);

The CheckColors function determines if the colors in the array lie within the output gamut of the given transform.

Parameter Description
hColorTransform Identifies the color transform to use
paInputColors Pointer to an array of COLOR structures
nColors Number of elements in the array
ctInput Input color type
paResult Pointer to an array of bytes that hold the result. Number of elements in this
array should also be nColors.

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero. To get extended error information, call
GetLastError.
The paResult array holds the results, each byte corresponds to a COLOR element and gets a value between 0 and
255. The value 0 denotes that the color is in gamut; a non-zero value implies that it is out of gamut, with the number
“n+1” being at least as far out of gamut as the number “n”.

Comments
If the input color type is not compatible with the color transform, this function fails.

Microsoft Confidential 17
BOOL WINAPI TranslateBitmapBits(
HTRANSFORM hColorTransform,
PVOID pSrcBits,
BMFORMAT bmInput,
DWORD dwWidth,
DWORD dwHeight,
DWORD dwStride,
PVOID pDestBits,
BMFORMAT bmOutput
);

The TranslateBitmapBits function takes a bitmap in one of the defined formats and translates the colors in the
bitmap producing another bitmap in the requested format.

Parameter Description
hColorTransform Identifies the color transform to use
pSrcBits Pointer to bitmap to translate
bmInput Input bitmap format
dwWidth Number of pixels per scanline of input data
dwHeight Number of scanlines of input data
dwStride Number of bytes from beginning of one scanline to beginning of next
pDestBits Pointer to buffer to receive translated data
bmOutput Output bitmap format

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero. To get extended error information, call
GetLastError.

Comments
Scanlines might be padded to be DWORD aligned, and dwStride is used to calculate beginning of next scanline. If
dwStride is 0, the API automatically calculates the beginning of next scanline by assuming DWORD alignment.
The scanlines in the destination buffer will be DWORD aligned. The caller of this function shoulld make sure that
the destination buffer is large enough.
If the input and output formats are not compatible with the color transform, this function fails.

Microsoft Confidential 18
BOOL WINAPI CheckBitmapBits(
HTRANSFORM hColorTransform,
PVOID pSrcBits,
BMFORMAT bmInput,
DWORD dwWidth,
DWORD dwHeight,
DWORD dwStride,
PBYTE paResult
);

The CheckBitmapBits function checks if the pixels in the bitmap lie within the output gamut of the given transform.

Parameter Description
hColorTransform Identifies the color transform to use
pSrcBits Pointer to bitmap to check against gamut
bmInput Input bitmap format
dwWidth Number of pixels per scanline of input data
dwHeight Number of scanlines of input data
dwStride Number of bytes from beginning one scanline to next
paResult Pointer to an array of bytes that hold the result.

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero. To get extended error information, call
GetLastError.
The paResult array holds the results, each byte corresponds to a pixel and gets a value between 0 and 255. The value
0 denotes that the color is in gamut; a non-zero value implies that it is out of gamut, with the number “n+1” being at
least as far out of gamut as the number “n”.

Comments
Scanlines might be padded to be DWORD aligned, and dwStride is used to calculate beginning of next scanline. If
dwStride is 0, the API automatically calculates the beginning of next scanline by assuming DWORD alignment.
If the input format is not compatible with the color transform, this function fails.

DWORD WINAPI GetCMMInfo(


HTRANSFORM hColorTransform,
DWORD dwInfo
);

The GetCMMInfo function retrieves various information about the CMM that created the given transform.

Parameter Description
hColorTransform Identifies the CMM to query
dwInfo Information to be retrieved
Value Meaning
CMM_WIN_VERSION Version of Windows support
CMM_DLL_VERSION Version of CMM
CMM_IDENT CMM signature registered with ICC

Returns
For CMM_WIN_VERSION, it returns the Windows version it was written for.
For CMM_DLL_VERSION, it returns the version number of the CMM DLL.
For CMM_IDENT, it returns the CMM signature registered with the International Color Consortium.
If the function fails it returns zero.

Microsoft Confidential 19
BOOL WINAPI RegisterCMM(
DWORD cmmID,
PCTSTR pCMMdll
);

The RegisterCMM function associates an ID with a CMM DLL, so that Windows can use the ID in profiles to find
the CMM to use when creating a transform.

Parameter Description
cmmID ID to associate with the CMM
pCMMdll Fully qualified path name of the CMM DLL

Returns
If the function is successful, it returns a nonzero value. Otherwise it returns zero. To get extended error information,
call GetLastError.

BOOL WINAPI UnRegisterCMM(


DWORD cmmID
);

The UnRegisterCMM function dissociates the ID with any CMM DLL. Later if the source profile for creating a
transform specifies this ID, the CMM DLL will not be located and the Windows default CMM will be used.

Parameter Description
cmmID ID of CMM to unregister

Returns
If the function is successful, it returns a nonzero value. Otherwise it returns zero. To get extended error information,
call GetLastError.

BOOL WINAPI SelectCMM(


DWORD dwCMMType
);

The SelectCMM function allows an application to select the preferred CMM to use.

Parameter Description
dwCMMType ICC signature of CMM to use

Returns
If the function is successful, it returns a nonzero value. Otherwise it returns zero. To get extended error information,
call GetLastError.

Comments
For this function to succeed, this CMM must be registered with the system.

Microsoft Confidential 20
6.2 Profile element accessing

HPROFILE WINAPI OpenColorProfile(


PPROFILE pProfile,
DWORD dwDesiredAccess,
DWORD dwShareMode,
DWORD dwCreationMode
);

The OpenColorProfile function takes a profile structure and returns a handle to the profile that can be used in other
profile management functions.

Parameter Description
pProfile Pointer to structure specifying the profile
dwDesiredAccess Specifies how the profile will be access. This parameter must be one of the
following values:
Value Meaning
PROFILE_READ Opens the profile for read access
PROFILE_READWRITE Opens the profile for both read and write
access
dwShareMode Specifies how the profile should be shared This parameter must be some
combination of the following values:
Value Meaning
0 Prevents the profile from being shared.
FILE_SHARE_READ Other open operations can be performed on the
profile for read access.
FILE_SHARE_WRITE Other open operations can be performed on the
profile for write access.
dwCreationMode Specifies which actions to take on the profile while opening it. This
parameter must be one of the following values:
Value Meaning
CREATE_NEW Creates a new profile. Fails if the profile
already exists.
CREATE_ALWAYS Creates a new profile. Overwrites the profile if
it exists.
OPEN_EXISTING Opens the profile. Fails if it does not exist
OPEN_ALWAYS Opens the profile if it exists. If it does not
exist, creates the profile.
TRUNCATE_EXISTING Opens the profile, and truncates it to zero
bytes. Fails if the profile doesn’t exist.

Returns
If the function is successful, it returns a handle to the profile. Otherwise it returns zero. To get extended error
information, call GetLastError.

Comments
If the profile data is not a file name, dwShareMode and dwCreationMode are ignored.

Microsoft Confidential 21
BOOL WINAPI CloseColorProfile(
HPROFILE hProfile
);

The CloseColorProfile function closes the given profile.

Parameter Description
hProfile Handle to the profile

Returns
If the function is successful, it returns nonzero. Otherwise it returns zero. To get extended error information, call
GetLastError.

BOOL WINAPI IsColorProfileValid(


HPROFILE hProfile
);

The IsColorProfileValid function allows the user to find out if a given profile is a valid ICC profile that can be used
for color matching.

Parameter Description
hProfile Handle to the profile

Returns
If it is a valid ICC profile that can be used for color matching, the return value is TRUE. Otherwise it is FALSE.

BOOL WINAPI IsColorProfileTagPresent(


HPROFILE hProfile,
TAGTYPE tag
);

The IsColorProfileTagPresent function reports if a given tag is present in a profile.

Parameter Description
hProfile Handle to the profile
tag ICC tag to check

Returns
If the tag is present in the profile, the return value is TRUE. Otherwise it is FALSE.

DWORD WINAPI GetCountColorProfileElements(


HPROFILE hProfile
);

The GetCountColorProfileElements function returns the number of tagged elements in a profile.

Parameter Description
hProfile Handle to the profile

Returns
If the function is successful, it returns the number of tagged elements in the profile. Otherwise it returns zero.

Microsoft Confidential 22
BOOL WINAPI GetColorProfileElementTag(
HPROFILE hProfile,
DWORD dwindex,
PTAGTYPE pTag
);

The GetColorProfileElementTag function retrieves the tag name for the dwIndex’th element in the profile’s tag
table, where dwIndex is a one-based index into the table.

Parameter Description
hProfile Handle to the profile
dwIndex one-based index of tag to retrieve
pTag Pointer to buffer that receives the tag name.

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero. To get extended error information, call
GetLastError.

Comments
GetColorProfileElementTag can be used to enumerate all tags in a profile after getting the number of tags in the
profile using GetCountColorProfileElements.

BOOL WINAPI GetColorProfileElement(


HPROFILE hProfile,
TAGTYPE tag,
DWORD dwOffset,
PDWORD pcbSize,
PVOID pBuffer,
PBOOL pbReference
);

The GetColorProfileElement function copies a tagged profile element data from a profile to a buffer.

Parameter Description
hProfile Handle to the profile
tag Identifies the element to copy
dwOffset Beginning from the first byte of the element data, the offset from which to
copy
pcbSize Pointer to variable specifying number of bytes to copy. (The buffer must be
at least as large as this value). On return it has the actual number of bytes
copied.
pBuffer Pointer to buffer to receive the element data
pbReference Boolean that is set to TRUE if more than one tag in the profile refers to the
same data this tag refers to. It is set to FALSE otherwise.

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero. To get extended error information, call
GetLastError.

Comments
If pBuffer is NULL, the size of the entire element data in bytes in copied into pcbSize, and dwOffset is ignored.

Microsoft Confidential 23
BOOL WINAPI GetColorProfileHeader(
HPROFILE hProfile,
PPROFILEHEADER pHeader
);

The GetColorProfileHeader function retrieves the header of a color profile.

Parameter Description
hProfile Handle to the profile
pHeader Pointer to buffer to receive the header

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero. To get extended error information, call
GetLastError.

BOOL WINAPI SetColorProfileElementSize(


HPROFILE hProfile,
TAGTYPE tag,
DWORD cbSize
);
The SetColorProfileElementSize function sets the size of a tagged element.

Parameter Description
hProfile Handle to the profile
tag Identifies the tag
cbSize Size to be set to

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero. To get extended error information, call
GetLastError.

Comments
To create a new tagged element in a profile, use SetColorProfileElementSize to set the size, then use
SetColorProfileElement to set the element value.
If this tag already exists in the profile, this function changes the size of the element, truncating it or adding zeroes at
the end as the case may be.
If this tag already exists, and is a reference to another tag, this function creates a new data area for this tag that is not
shared.
If cbSize is zero, it deletes the element. If it is a reference, only the tag table entry is deleted not the data.
The profile should be opened for read/write access for this function to succeed.

Microsoft Confidential 24
BOOL WINAPI SetColorProfileElement(
HPROFILE hProfile,
TAGTYPE tag,
DWORD dwOffset,
PDWORD pcbSize,
PVOID pBuffer
);

The function SetColorProfileElement sets the element data for a tagged profile element.

Parameter Description
hProfile Handle to the profile
tag Identifies the tag
dwOffset Beginning from the first byte of the element data in the profile, the offset
from which to write from.
PcbSize Pointer to number of bytes of data to write. On return it has the number of
bytes actually written.
Pbuffer Pointer to buffer containing element data

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero. To get extended error information, call
GetLastError.

Comments
This function fails if dwOffset exceeds the size of the tagged element. If dwOffset + *pcbSize is greater than the size
of the element, this function only writes as many bytes as are within the current size of the element.
Any existing data is overwritten when this function succeeds.
The profile should be opened for read/write access for this function to succeed.

BOOL WINAPI SetColorProfileElementReference(


HPROFILE hProfile,
TAGTYPE newTag,
TAGTYPE refTag
);

The function SetColorProfileElementReference creates a new tag which references the same data as an existing
tag.

Parameter Description
hProfile Handle to the profile
newTag Identifies the tag to create
refTag Identifies the tag whose data is to be referenced by the new tag

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero. To get extended error information, call
GetLastError.

Comments
If newTag exists or refTag doesn’t exist, this function fails.
The profile should be opened for read/write access for this function to succeed.

Microsoft Confidential 25
BOOL WINAPI SetColorProfileHeader(
HPROFILE hProfile,
PPROFILEHEADER pHeader
);

The SetColorProfileHeader function sets the header data in a profile.

Parameter Description
hProfile Handle to the profile
pHeader Pointer to profile header data to write

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero. To get extended error information, call
GetLastError.

Comments
The profile should be opened for read/write access for this function to succeed.

BOOL WINAPI CreateDeviceLinkProfile(


PHPROFILE pahProfiles,
DWORD nProfiles,
PCTSTR pProfileFilename,
DWORD indexPreferredCMM
);

The CreateDeviceLinkProfile function creates a device link profile from a set of profiles.

Parameter Description
pahProfiles Pointer to an array of handles of the profiles to be used
nProfiles Number of profiles in the array
pProfileFilename NULL terminated full path name of device-link profile to create
indexPreferredCMM Index of the profile that specifies the CMM to use

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero. To get extended error information, call
GetLastError.

Comments
The first and the last profiles in the array must be device profiles. The other profiles can be color space or abstract
profiles.
Each profile’s output color space must be the next profile’s input color space.

Microsoft Confidential 26
BOOL WINAPI GetPS2ColorSpaceArray(
HPROFILE hProfile,
PVOID pBuffer,
PDWORD pcbSize,
PBOOL pbBinary
);

The GetPS2ColorSpaceArray function retrieves the PostScript Level 2 color space array from a profile. This can be
used as the operand for the PostScript Level2 “setcolorspace” operator.

Parameter Description
hProfile Handle to the profile
pBuffer Pointer to buffer to receive the color space array
pcbSize Pointer to size of buffer. On return it has the number of bytes copied
pbBinary If TRUE, data returned could be binary, else it should be ASCII85 encoded.
On return, it denotes if the data returned is actually binary or ascii.

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero. To get extended error information, call
GetLastError.

Comments
If pBuffer is NULL, the size of the buffer required is returned in pcbSize.

Microsoft Confidential 27
BOOL WINAPI GetPS2ColorRenderingIntent(
HPROFILE hProfile,
PVOID pBuffer,
PDWORD pcbSize,
PBOOL pbBinary
);

The GetPS2ColorRenderingIntent function retrieves the PostScript Level 2 color rendering intent from a profile.
This can be used as the operand for the PostScript Level2 “findcolorrendering” operator.

Parameter Description
hProfile Handle to the profile
pBuffer Pointer to buffer that receives the color rendering intent
pcbSize Pointer to size of buffer. On return it has the number of bytes copied.
pbBinary If TRUE, data returned could be binary, else it should be ASCII85 encoded.
On return, it denotes if the data returned is actually binary or ascii.

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero. To get extended error information, call
GetLastError.

Comments
If pBuffer is NULL, the size of the buffer required is returned in pcbSize.

BOOL WINAPI GetPS2ColorRenderingDictionary(


HPROFILE hProfile,
DWORD dwIntent,
PVOID pBuffer,
PDWORD pcbSize,
PBOOL pbBinary
);

The GetPS2ColorRenderingDictionary function retrieves the PostScript Level 2 color rendering dictionary for the
given rendering intent from a profile. This can be used as the operand for the PostScript Level2 “setcolorrendering”
operator.

Parameter Description
hProfile Handle to the profile
dwIntent Rendering intent
pBuffer Pointer to buffer that receives the color rendering dictionary
pcbSize Pointer to size of buffer. On return it has the number of bytes copied.
PbBinary If TRUE, data returned could be binary, else it should be ASCII85 encoded.
On return, it denotes if the data returned is actually binary or ascii.

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero. To get extended error information, call
GetLastError.

Comments
If pBuffer is NULL, the size of the buffer required is returned in pcbSize.

Microsoft Confidential 28
6.3 Profile management

BOOL WINAPI AddColorProfiles(


PCTSTR pDevicename,
DEVTYPE devType,
PCTSTR* papProfilenames,
DWORD nCount
);

The AddColorProfiles function installs the given set of profiles for use by the device instance identified by
pDevicename in the system. The profiles are copied to the COLOR directory.

Parameter Description
pDevicename Identifies the instance of the device.
devType Device type
Value Description
DEV_INPUT Input device
DEV_DISPLAY Display device
DEV_OUTPUT Output device
PapProfilenames Pointer to array of pointers to profile file names
nCount Number of elements in the array

Returns
If the function is successful, it returns a nonzero value. Otherwise it returns zero. To get extended error information,
call GetLastError.

BOOL WINAPI RemoveColorProfiles(


PCTSTR pDevicename,
DEVTYPE devType,
PCTSTR* papProfilenames,
DWORD nCount
);

The RemoveColorProfiles function removes the given set of profiles from being used by the device instance
identified by pDevicename. The files are left on the system.

Parameter Description
pDevicename Identifies the instance of the device.
devType Device type
Value Description
DEV_INPUT Input device
DEV_DISPLAY Display device
DEV_OUTPUT Output device
pProfileName Pointer to array of pointers to profile file names
nCount Number of elements in the array

Returns
If the function is successful, it returns a nonzero value. Otherwise it returns zero. To get extended error information,
call GetLastError.

Microsoft Confidential 29
BOOL WINAPI CreateNewColorProfileSet(
PCTSTR pDevicename,
DEVTYPE devType
);

The function CreateNewColorProfileSet sets up the device to use its own set of profiles, so that subsequent calls to
AddColorProfiles adds profiles exclusively for this device. After this function is called, the device has no profiles
associated with it. Profiles need to be added using AddColorProfiles.

Parameter Description
pDevicename Identifies the instance of the device
devType Device type
Value Description
DEV_INPUT Input device
DEV_DISPLAY Display device
DEV_OUTPUT Output device

Returns
If the function is successful, it returns a nonzero value. Otherwise it returns zero. To get extended error information,
call GetLastError.

ULONG WINAPI EnumColorProfiles(


PCTSTR pDevicename,
DEVTYPE devType
PPROFILECALLBACK pCallbackFunc,
PVOID pClientData
);

The EnumColorProfiles function enumerates all the profiles associated with a device. The callback function is a user
supplied function that is called once for each profile.

Parameter Description
pDevicename Identifies the instance of the device
devType Device type
Value Description
DEV_INPUT Input device
DEV_DISPLAY Display device
DEV_OUTPUT Output device
pCallbackFunc Pointer to a user supplied callback function. For more information see the
SearchColorProfiles function.
PClientData Pointer to user supplied data

Returns
This function returns the last value returned by the callback function.

Comments
EnumColorProfiles calls the callback function once for each profile associated with the device. It continues to call
the callback until there are no more profiles, or the callback function returns zero.
See the SearchColorProfiles function for more on the format of the callback function.

Microsoft Confidential 30
ULONG WINAPI SearchColorProfiles(
PSEARCHTYPE pSearchType,
PPROFILECALLBACK pCallbackFunc,
PVOID pClientData
);

The SearchColorProfiles function searches through the profiles installed in the system and enumerates all the
profiles satisfying the search criteria specified by the application. The callback function is a user supplied function
that is called once for each profile that satisfies the criteria defined by the SEARCHTYPE record.

Parameter Description
pSearchType Pointer to the structure specifying the search criteria
pCallbackFunc Pointer to a user supplied callback function. For more information see the
Comments section below.
pClientData Pointer to user supplied data

Returns
This function returns the last value returned by the callback function.

Comments
SearchColorProfiles calls the callback function once for each profile that satisfies the search criteria. It continues to
call the callback until there are no more profiles, or the callback function returns zero.
The callback function has the following form.
ULONG WINAPI CallbackFunction(
PCTSTR pFilename,
PVOID pClientData
);

Parameter Description
pFilename Pointer to NULL terminated file name of profile
pClientData Pointer to user supplied data

Returns
The return value must be nonzero to continue enumeration; to stop enumeration, it must be zero.

BOOL WINAPI GetSystemColorProfile(


DWORD dwProfileID,
PTSTR pProfilename,
PDWORD pcbSize
);

The GetSystemColorProfile function retrieves the system color profile representing the color space given. Currently
only sRGB color space is supported and the profile for this color space will ship with Microsoft Color Match.

Parameter Description
dwProfileID ID of predefined color space that profile represents
pProfilename Buffer that gets name of profile on return
pcbSize On input it has size of buffer. If function fails because
buffer is too small, it has size required on return.

Returns
If the function is successful, it returns a nonzero value. Otherwise it returns zero. To get extended error information,
call GetLastError.

Microsoft Confidential 31
7 Color Matching Modules
All the color matching work takes place inside the Color Matching Module. Microsoft Color Match ships with a
default CMM that provides this support. However it is possible, using the provide APIs, to register additional CMMs
in the system. When multiple CMMs are present, the following algorithm is used to chooses the correct CMM to
use:
1. The application specified CMM is used.
2. If this cannot be located, the CMM specified by the profile belonging to the output device is used.
3. If this CMM also cannot be located, the Windows default CMM is used.
Once it is loaded and a transform is created using it, the same CMM is used for all operations on that transform.
For a Windows DLL to be a CMM capable of being used by Microsoft Color Match, it should export the following
entry points:
CMGetInfo Returns information about the CMM
CMCreateTransform Creates a color transform (ANSI)
CMCreateTransformW Creates a color transform (Unicode)
CMCreateMultiProfileTransform Uses an array of profiles or a device link profile to create a transform
CMDeleteTransform Deletes a color transform
CMCreateProfile * Creates an ICC profile from a logical color space structure (ANSI)
CMCreateProfileW * Creates an ICC profile from a logical color space structure (Unicode)
CMCreateDeviceLinkProfile * Creates an ICC device link profile (ANSI)
CMCreateDeviceLinkProfileW * Creates an ICC device link profile (Unicode)
CMTranslateColors Translates an array of colors from source to destination color space
CMCheckColors Checks if an array of colors falls within the output gamut
CMTranslateRGBs Translates the colors of a bitmap from source to destination color space
CMCheckRGBs Checks if the colors of a bitmap fall within the output gamut
CMGetPS2ColorSpaceArray * Gets the PostScript color space array from a profile
CMGetPS2ColorRenderingIntent * Gets the PostScript color rendering intents from a profile
CMGetPS2ColorRenderingDictionary Gets the PostScript color rendering dictionary from a profile
*
CMIsProfileValid * Checks if a profile is a valid ICC profile
CMTranslateRGB + Translates an RGB color value from source to destination color space
CMCheckColorsInGamut + Checks if an array of RGB triplets falls within the output gamut
The functions marked with an asterisk (*) are optional and need not be exported by all CMMs. If any of these
optional functions need to be called and the CMM in use doesn’t provide them, the Windows default CMM is used
for that function.
The functions marked with a plus (+) are required for backward compatibility with Windows 95 ICM. For
information on these functions, please refer to the MSDN documentation.
The functions to create a transform, a profile and a device link profile have ANSI and Unicode versions. The ANSI
versions do not end with an ‘A’ to ensure compatibility with Windows 95. The Unicode versions are needed on
Windows NT.
The above CMM specification is a superset of the ICM CMM specification. Therefore any CMM conforming to this
specification will continue to work with ICM on Windows 95. For this reason, CMM vendors are strongly
encouraged to write CMMs to the above Microsoft Color Match specification.

8 CMM Structures and Definitions


/*
* These are used by CMGetInfo()
*/
#define CMM_WIN_VERSION 0
#define CMM_IDENT 1
#define CMM_DRIVER_LEVEL 2
#define CMM_DLL_VERSION 3
#define CMM_VERSION 4

Microsoft Confidential 32
#define CMS_LEVEL_1 1

9 CMM function interface


This section defines the interface that CMMs should provide to work with Microsoft Color Match. Some of the entry
points are required and some are optional. If the optional entry points are not provided, the Windows default CMM is
used to provide the extra functionality.
Only the functions required or are optional for use with Microsoft Color Match are described here. Please refer to the
Windows 95 SDK for a description of CMTranslateRGB and CMCheckColorsInGamut which are required for
Windows 95 compatibility.

DWORD WINAPI CMGetInfo( // Required


DWORD dwInfo
);

The CMGetInfo function retrieves various information about the CMM.

Parameter Description
dwInfo Information to be retrieved
Value Meaning
CMM_VERSION Version of Windows supported
CMM_WIN_VERSION Backward compatibility with Windows 95
CMM_DLL_VERSION Version of CMM DLL
CMM_IDENT ICC registered ID for the CMM DLL.
CMM_DRIVER_LEVEL Backward compatibility with Windows 95

Returns
For CMM_VERSION, CMGetInfo returns 0x00050000.
For CMM_WIN_VERSION, CMGetInfo returns 0x00040000 for compatibility with Windows 95 ICM.
For CMM_DLL_VERSION, it returns the version number of the CMM DLL.
For CMM_IDENT, CMGetInfo retrieves the CMM ID registered with the International Color Consortium.
For CMM_DRIVER_LEVEL, CMGetInfo returns CMS_LEVEL_1 for compatibility with Windows 95 ICM.
If the function fails it returns zero.

Comments
CMMs that do not wish to run on Windows 95 should return 0x0050000 for CMM_WIN_VERSION.

Microsoft Confidential 33
HCMTRANSFORM WINAPI CMCreateTransform( // Required
LPCOLORSPACE lpColorSpace,
LPDEVCHARACTER lpDevCharcacter,
LPDEVCHARACTER lpTargetDevCharacter
);

The CMCreateTransform function creates a color transform that maps from an input LogColorSpace to an optional
target to an output device

Parameter Description
lpColorSpace Pointer to input color space. If lcsFilename is non-zero, it is a pointer to the
memory mapped profile.
LpDevCharacter Pointer to memory mapped device profile
lpTargetDevCharacter Pointer to memory mapped target profile

Returns
If the function is successful, it returns a color transform in the range 256 to 65535. Otherwise it returns an error code
(return value < 255).

Comments
If there is an error, and the return value is less than 255, the CMM should set the last error (SetLastError) to a valid
error value defined in winerror.h.
Only the low WORD of the transform is retained, so valid transforms must be in the range 256 to 65535.
For 16-bit device drivers that are Microsoft Color Match aware, LPDEVCHARACTER is a pointer to the profile file
name.
The forward transform must be precomputed at this time. Future calls to CMTranslatexxx() using the forward
transform should not fail due to inability to construct the mapping.
The Unicode version of this function is defined as
HCMTRANSFORM WINAPI CMCreateTransformW( // Required
LPCOLORSPACEW lpColorSpace,
LPDEVCHARACTER lpDevCharcacter,
LPDEVCHARACTER lpTargetDevCharacter
);

Microsoft Confidential 34
HCMTRANSFORM WINAPI CMCreateMultiProfileTransform( // Required
LPHPROFILE lpahProfiles,
DWORD nProfiles
);

The CMCreateMultiProfileTransform function accepts an array of profiles or a single device link profile and
creates a color transform. This transform is a mapping from the color space specified by the first profile to that of the
second profile and so on until the last one.

Parameter Description
lpahProfiles Pointer to an array of profile handles
nProfiles Number of profiles in the array

Returns
If the function is successful, it returns a color transform. Otherwise it returns an error code (return value < 255).

Comments
If there is an error, and the return value is less than 255, the CMM should set the last error (SetLastError) to a valid
error value defined in winerror.h.
16-bit device drivers that are Microsoft Color Match aware do not have to support this function as it is only used for
color matching outside the DC.
The forward transform must be precomputed at this time. Future calls to CMTranslatexxx() using the forward
transform should not fail due to inability to construct the mapping.

BOOL WINAPI CMDeleteTransform( // Required


HCMTRANSFORM hcmTransform
);

The CMDeleteTransform function deletes the given color transform, and frees any memory associated with it.

Parameter Description
hcmTransform Identifies the color transform

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero.

Comments
If there is an error, and the return value is less than 255, the CMM should set the last error (SetLastError) to a valid
error value defined in winerror.h.

Microsoft Confidential 35
BOOL WINAPI CMCreateProfile( // Optional
LPCOLORSPACE lpColorSpace,
LPCTSTR lpProfileFilename
);

The CMCreateProfile function creates a display color profile from a LogColorSpace structure.

Parameter Description
lpColorSpace Pointer to color space. lcsFilename field will be NULL.
lpProfileFilename NULL terminated full path name of profile to create

Returns
If the function is successful, it returns nonzero. Otherwise it returns zero.

Comments
If there is an error, and the return value is less than 255, the CMM should set the last error (SetLastError) to a valid
error value defined in winerror.h.
If a CMM does not support this function, GDI uses the Windows default CMM to create the profile.
The CMM should set all header fields to sensible defaults. This profile should be usable as the input profile in a
transform. Profiles created using this function are temporary, and will be discarded by the system after use.
The Unicode version of this function is defined as
BOOL WINAPI CMCreateProfileW( // Optional
LPCOLORSPACEW lpColorSpace,
LPCWSTR lpProfileFilename
);

Microsoft Confidential 36
BOOL WINAPI CMCreateDeviceLinkProfile( // Optional
LPHPROFILE lpahProfiles,
DWORD nProfiles,
LPCTSTR lpProfileFilename
);

The CMCreateDeviceLinkProfile function creates a device link profile as specified by the “ICC Profile Format
Specification.”

Parameter Description
lpahProfiles Pointer to an array of profile handles
nProfiles Number of profiles in the array
lpProfileFilename NULL terminated full path name of device-link profile to create

Returns
If the function is successful, it returns nonzero. Otherwise it returns zero.

Comments
If there is an error, and the return value is less than 255, the CMM should set the last error (SetLastError) to a valid
error value defined in winerror.h.
If a CMM does not support this function, GDI uses the Windows default CMM to create a device link profile.
The Unicode version of this function is defined as
BOOL WINAPI CMCreateDeviceLinkProfileW( // Optional
LPHPROFILE lpahProfiles,
DWORD nProfiles,
LPCWSTR lpProfileFilename
);

Microsoft Confidential 37
BOOL WINAPI CMTranslateColors( // Required
HCMTRANSFORM hcmTransform,
LPCOLOR lpaInputColors,
DWORD nColors,
COLORTYPE ctInput,
LPCOLOR lpaOutputColors,
COLORTYPE ctOutput
);

The CMTranslateColors function translates an array of colors from the source colorspace to the destination
colorspace as defined by the color transform.

Parameter Description
hcmTransform Identifies the color transform to use
lpaInputColors Pointer to an array of COLOR structures to translate
nColors Number of elements in the array
ctInput Specifies the input color type
lpaOutputColors Pointer to an array of COLOR structures that receive the translated colors
ctOutput Specifies the output color type

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero.

Comments
If there is an error, and the return value is less than 255, the CMM should set the last error (SetLastError) to a valid
error value defined in winerror.h.
If the input and the output color types are not compatible with the color transform, this function fails.

Microsoft Confidential 38
BOOL WINAPI CMCheckColors( // Required
HCMTRANSFORM hcmTransform,
LPCOLOR lpaInputColors,
DWORD nColors,
COLORTYPE ctInput,
LPBYTE lpaResult
);

The CMCheckColors function determines if the given colors lie within the output gamut of the given transform.

Parameter Description
hcmTransform Identifies the color transform to use
lpaInputColors Pointer to an array of COLOR structures
nColors Number of elements in the array
ctInput Input color type
lpaResult Pointer to an array of bytes that hold the result

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero.
The lpaResult array holds the results, each byte corresponds to a COLOR element and has a value between 0 and
255. The value 0 denotes that the color is in gamut; a non-zero value implies that it is out of gamut, with the number
“n+1” being at least as far out of gamut as the number “n”. These values are usually generated from the gamutTag in
the ICC profile.

Comments
If there is an error, and the return value is less than 255, the CMM should set the last error (SetLastError) to a valid
error value defined in winerror.h.
If the input color type is not compatible with the color transform, this function fails.

Microsoft Confidential 39
BOOL WINAPI CMTranslateRGBs( // Required
HCMTRANSFORM hcmTransform,
LPVOID lpSrcBits,
BMFORMAT bmInput,
DWORD dwWidth,
DWORD dwHeight,
DWORD dwStride,
LPVOID lpDestBits,
BMFORMAT bmOutput,
DWORD dwTranslateDirection
);

The CMTranslateRGBs function takes a bitmap in one of the defined formats and translates the colors in the bitmap
producing another bitmap in the requested format.

Parameter Description
hcmTransform Identifies the color transform to use
lpSrcBits Pointer to bitmap to translate
bmInput Input bitmap format
dwWidth Number of pixels per scanline of input data
dwHeight Number of scanlines of input data
dwStride Number of bytes from beginning of one scanline to beginning of next
lpDestBits Pointer to buffer to receive translated data
bmOutput Output bitmap format
dwTranslateDirection Describes direction of transform
Value Meaning
CMS_FORWARD Use forward transform
CMS_BACKWARD Use reverse transform

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero.

Comments
If there is an error, and the return value is less than 255, the CMM should set the last error (SetLastError) to a valid
error value defined in winerror.h.
Scanlines might be padded to be DWORD aligned, and dwStride must be used to calculate beginning of next
scanline. If dwStride is 0, the CMM should automatically calculate the beginning of next scanline by assuming
DWORD alignment.
When writing into the destination buffer, the CMM should make sure that scanlines are padded to be DWORD
aligned.
If the input and output formats are not compatible with the color transform, this function fails.
If both input and output bitmap formats are 3 channel, 4 bytes per pixel like BM_xRGBQUADS, the 4 th bytes should
be preserved and copied to the output buffer.

Microsoft Confidential 40
BOOL WINAPI CMCheckRGBs( // Required
HCMTRANSFORM hcmTransform,
LPVOID lpSrcBits,
BMFORMAT bmInput,
DWORD dwWidth,
DWORD dwHeight,
DWORD dwStride,
LPBYTE lpaResult
);

The CMCheckRGBs function checks if the pixels in the bitmap lie within the output gamut of the given transform.

Parameter Description
hcmTransform Handle to color transform
lpSrcBits Pointer to bitmap to check against gamut
bmInput Input bitmap format
dwWidth Number of pixels per scanline of input data
dwHeight Number of scanlines of input data
dwStride Number of bytes from beginning of one scanline to beginning of next
lpaResult Pointer to an array of bytes that hold the result

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero.
The lpaResult array holds the results, each byte corresponds to a pixel and has a value between 0 and 255. The value
0 denotes that the color is in gamut; a non-zero value implies that it is out of gamut, with the number “n+1” being at
least as far out of gamut as the number “n”. These values are usually generated from the gamutTag in the ICC profile.

Comments
If there is an error, and the return value is less than 255, the CMM should set the last error (SetLastError) to a valid
error value defined in winerror.h.
Scanlines might be padded for alignment, and dwStride must be used to calculate beginning of next scanline. If
dwStride is 0, the CMM should automatically calculate the beginning of next scanline by assuming DWORD
alignment.
If the input format is not compatible with the color transform, this function fails.

Microsoft Confidential 41
BOOL WINAPI CMGetPS2ColorSpaceArray( // Optional
LPDEVCHARACTER lpDevCharacter,
LPVOID lpBuffer,
LPDWORD lpcbSize,
LPBOOL lpbBinary
);

The CMGetPS2ColorSpaceArray function retrieves the PostScript Level 2 color space array from a profile. If this
tag is not present in the profile, the CMM creates it. This can be used as the operand for the PostScript Level2
“setcolorspace” operator.

Parameter Description
lpDevCharacter Pointer to memory mapped profile
lpBuffer Pointer to buffer to receive the color space array
lpcbSize Pointer to size of buffer. On return it has the number of bytes copied
lpbBinary If TRUE, data returned could be binary, else it should be ASCII85 encoded.
On return, it denotes if the data returned is actually binary or ascii.

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero.

Comments
If there is an error, and the return value is less than 255, the CMM should set the last error (SetLastError) to a valid
error value defined in winerror.h.
For 16-bit device drivers that are Microsoft Color Match aware, lpDevCharacter is a pointer to a NULL terminated
profile file name.
If a CMM does not support this function, GDI uses the Windows default CMM to create the color space array.
If lpBuffer is NULL, it returns the size of the buffer required in lpcbSize.

Microsoft Confidential 42
BOOL WINAPI CMGetPS2ColorRenderingIntent( // Optional
LPDEVCHARACTER lpDevCharacter,
LPVOID lpBuffer,
LPDWORD lpcbSize,
LPBOOL lpbBinary
);

The CMGetPS2ColorRenderingIntent function retrieves the PostScript Level 2 color rendering intent from the
profile. If this tag is not present in the profile, the CMM creates it. This can be used as the operand for the PostScript
Level2 “findcolorrendering” operator.

Parameter Description
lpDevCharacter Pointer to memory mapped profile
lpBuffer Pointer to buffer that receives the color rendering intent
lpcbSize Pointer to size of buffer. On return it has the number of bytes copied.
lpbBinary If TRUE, data returned could be binary, else it should be ASCII85 encoded.
On return, it denotes if the data returned is actually binary or ascii.

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero.

Comments
If there is an error, and the return value is less than 255, the CMM should set the last error (SetLastError) to a valid
error value defined in winerror.h.
For 16-bit device drivers that are Microsoft Color Match aware, lpDevCharacter is a pointer to a NULL terminated
profile file name.
If a CMM does not support this function, GDI uses the Windows default CMM to get the color rendering intents.
If lpBuffer is NULL, it returns the size of the buffer required in lpcbSize.

Microsoft Confidential 43
BOOL WINAPI CMGetPS2ColorRenderingDictionary( // Optional
LPDEVCHARACTER lpDevCharacter,
DWORD dwIntent,
LPVOID lpBuffer,
LPDWORD lpcbSize,
LPBOOL lpbBinary
);

The CMGetPS2ColorRenderingDictionary function retrieves the PostScript Level 2 color rendering dictionary for
the given rendering intent from the profile. If this tag is not present in the profile, the CMM creates it. This can be
used as the operand for the PostScript Level2 “setcolorrendering” operator.

Parameter Description
lpDevCharacter Pointer to memory mapped profile
dwIntent Rendering intent
lpBuffer Pointer to buffer that receives the color rendering dictionary
lpcbSize Pointer to size of buffer. On return it has the number of bytes copied.
lpbBinary If TRUE, data returned could be binary, else it should be ASCII85 encoded.
On return, it denotes if the data returned is actually binary or ascii.

Returns
If the function is successful, the return value is nonzero. Otherwise it is zero.

Comments
If there is an error, and the return value is less than 255, the CMM should set the last error (SetLastError) to a valid
error value defined in winerror.h.
For 16-bit device drivers that are Microsoft Color Match aware, lpDevCharacter is a pointer to a NULL terminated
profile file name.
If a CMM does not support this function, GDI uses the Windows default CMM to create the color space array.
If lpBuffer is NULL, it returns the size of the buffer required in lpcbSize.

BOOL WINAPI CMIsProfileValid( // Optional


LPDEVCHARACTER lpDevCharacter
);

The CMIsProfileValid function reports if the given profile is a valid ICC profile that can be used for color matching.

Parameter Description
lpDevCharacter Pointer to memory mapped profile

Returns
If it is a valid ICC profile that can be used for color matching, the return value is nonzero. Otherwise it is zero.

Comments
If a CMM does not support this function, GDI uses the Windows default CMM to validate the profile.

Microsoft Confidential 44
10 INF file format for installing profiles
TO BE DONE

Microsoft Confidential 45

You might also like