Windows Color System and API: An Overview

Windows Color System and API:
An Overview
Outline
A Brief Overview of the Windows Color System
(WCS) in Windows codename “Longhorn”
WCS XML-based color profiles
ICM APIs: changed, unchanged, and new
Using ICM APIs to access WCS functionality
Profile/Device association and defaults
Getting color profiles
Constructing color transforms
Applying color transforms to color data
Call to Action
Goals
An understanding of the structure of the Windows Color
System (WCS)
An understanding of its relationship to Windows ICM
An understanding of how to use WCS via the ICM APIs
An understanding of how to take best advantage of
enhanced capabilities and opportunities for innovation
enabled by the Windows Color System
Knowledge of where to find more information about WCS
An understanding of how best to provide feedback
Windows Color System and ICC workflows
Seamless interoperability with ICC profile-based
workflows (ICC: International Color Consortium)
Any existing code that uses ICM2 APIs will
continue to work without any change required.
ICM Gets ICC Version 4.x Support
Addressing key recorded ICM2 bugs
Implement new functionality in current ICM2 APIs
Old applications work with new profiles
New profile format is processed by current ICM2
APIs
The Parts of the Windows Color System
The WCS XML-based color profile formats
The Color Infrastructure & Translation Engine
(CITE)
The Color Appearance Model (CAM)
Based on CIECAM02
The Baseline Device Model Set
Extensible via Device Model Plug-ins
The Baseline Gamut Map Model Set
Extensible via Gamut Map Model Plug-ins
And of course the existing ICM CMM, with ICC
version 4 profile support added
WCS Pipeline
Device A
Device B
Device Color Space
Device
Models
Device Model
Profile A
Device
Model A
Device Model
Profile B
Device
Model B
Device-Independent Color Space
CIEXYZ
Gamut
Map
Models
Color
Appearance
Model
CAMP for
Device A
Viewing
Conditions
GBD A
Gamut Map
Model C
Profile
GBD B
Gamut
Map Model
C
Color Appearance Space CIEJch
Color
Appearance
Model
CAMP for
Device B
Viewing
Conditions
WCS Profile Formats
Each Type has its own Schema
Device Model Profile (DMP), file extension “.cdmp”
Color Appearance Model Profile (CAMP), “.camp”
Gamut Map Model Profile (GMMP),
“.gmmp”
Device Model Profile Structure
ProfileName string
optional Description string
optional Author string
optional MeasurementCondition
MeasurementConditionType
– there are defaults for each ..DeviceType below
ColorSpace MeasurementSpaceType
WhitePointValue
– white point name (eg. D65), or CIEXYZ white point values
Geometry
– measurement geometry (eg. 0/45)
ApertureSize
- measurement instrument aperture (eg. 10mm)
Device Model Profile Structure
MaxColorant – maximum value allowed in any color channel
MinColorant – minimum value allowed in any color channel
A reference to the targeted baseline Device Model
- these contain model-specific measurement data
CRTDevice CRTDeviceType
LCDDevice LCDDeviceType
RGBProjectorDevice RGBProjectorDeviceType
ScannerDevice CaptureDeviceType
CameraDevice CaptureDeviceType
RGBPrinterDevice RGBPrinterDeviceType
CMYKPrinterDevice CMYKPrinterDeviceType
PlugInDevice PlugInDeviceType (only if targeting a plug-in
Device Model)
optional Extension ExtensionType
- arbitrary third-party proprietary information
DMP Schema
<xs:element name="ColorDeviceModel">
<xs:complexType>
<xs:sequence>
<xs:element name="ProfileName" type="xs:string"/>
<xs:element name="Description" type="xs:string" minOccurs="0"/>
<xs:element name="Author" type="xs:string" minOccurs="0"/>
<xs:element name="MeasurementConditions"
type="cdm:MeasurementConditionsType" minOccurs="0"/>
<xs:element name="MaxColorant" type="cdm:NonNegativeFloatType"/>
<xs:element name="MinColorant" type="cdm:NonNegativeFloatType"/>
<xs:choice>
LCDDevice
<xs:element name="CRTDevice">
RGBProjectorDevice
<xs:complexType>
<xs:sequence>
ScannerDevice
<xs:element name="MeasurementData"
CameraDevice
type="cdm:DisplayMeasurementType"/>
</xs:sequence>
RGBPrinterDevice
</xs:complexType>
CMYKPrinterDevice </xs:element>...[ rest of baseline devices]
...</xs:choice>
<xs:element name="PlugInDeviceModelModel" minOccurs="0">...
...</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
CMYKDeviceType
<xs:element name="CMYKPrinterDevice">
<xs:complexType>
<xs:sequence>
<xs:element name="MeasurementData"
type="cdm:CMYKPrinterMeasurementType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
CMYKPrinterMeasurementType
<xs:complexType
name="CMYKPrinterMeasurementType">
<xs:sequence>
<xs:element name="ColorCube">
<xs:complexType>
<xs:sequence>
<xs:element name="Sample"
type="cdm:CMYKSampleType"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="TimeStamp"
type="xs:dateTime"
use="required"/>
</xs:complexType>
Color Appearance Model Profile (CAMP) Contents
ProfileName string,
optional Description string,
optional Author string,
ViewingCondition ViewingConditionType.
-Parameters to the CIECAM02 Color Appearance Model
WhitePoint WhitePointType
Background CIEXYZ sub-element
Surround SurroundType sub-element
LuminanceOfAdaptingField float sub-element
DegreeOfAdaptation float sub-element
Gamut Map Model Profile Contents
ProfileName string,
DefaultBaselineGamutMapModel
DefaultBaselineGamutMapModelType
Optional Description string
Optional Author string
optional PlugInDevice PlugInGamutMapType
optional extension ExtensionType
ICM-WCS APIs
Three categories of ICM-WCS APIs
Existing ICM2 APIs whose parameters and
functions are completely unchanged.
Existing ICM2 APIs that now support WCS color
profiles in addition to ICC color profiles
New, WCS-specific APIs
Existing ICM2 APIs That are Unchanged
for Longhorn WCS
All Device Context-based (HDC-based) ICM APIs are unchanged.
These outside-DC ICM APIs are also unchanged:
CreateProfileFromLogColorSpace
GetCountColorProfileElements
GetColorProfileHeader
GetColorProfileElementTag
IsColorProfileTagPresent
GetColorProfileElement
SetColorProfileHeader
SetColorProfileElementSize
SetColorProfileElement
SetColorProfileElementReference
GetNamedProfileInfo
ConvertColorNameToIndex
ConvertIndexToColorName
GetPS2ColorSpaceArray
GetPS2ColorRenderingIntent
GetPS2ColorRenderingDictionary
CreateDeviceLinkProfile
Existing ICM2 APIs With Added Support
for WCS Profiles and Transforms
OpenColorProfile
CloseColorProfile
GetColorProfileFromHandle
IsColorProfileValid
CreateColorTransform
CreateMultiProfileTransform
TranslateBitmapBits
CheckBitmapBits
TranslateColors
CheckColors
Existing ICM2 Profile Management APIs
That Support WCS Profiles
InstallColorProfile
UninstallColorProfile
EnumColorProfiles
SetStandardColorSpaceProfile
GetStandardColorSpaceColorProfile
AssociateColorProfileWithDevice
DisassociateColorProfileFromDevice
New WCS-Specific ICM APIs
New APIs are all prefixed “Wcs…”
WcsOpenColorProfile
WcsTranslateColors
WcsCheckColors
WcsGetDefaultColorProfileSize
WcsGetDefaultColorProfile
WcsSetDefaultColorProfile
Using the APIs
Install/uninstall color profiles
Associate/disassociate color profiles with devices
Get/set default color profiles
Now includes mapping ICC rendering intents to
GMMPs
Now includes get/set default CAMPs
Get color profiles
Construct color transforms
Apply color transforms – translate color
Check for out of gamut colors
Color Profile Installation
These routines now work with DMPs, CAMPs,
and GMMPs, as well as ICC profiles
BOOL WINAPI InstallColorProfile(
PCTSTR pMachineName,
PCTSTR pProfileName
);
BOOL WINAPI UninstallColorProfile(
PCTSTR pMachineName,
PCTSTR pProfileName,
BOOL bDelete
);
Profile/Device Association
These routines now work with DMPs, CAMPs,
and GMMPs, as well as ICC profiles
BOOL WINAPI AssociateColorProfileWithDevice(
PCTSTR pMachineName,
PCTSTR pProfileName,
PCTSTR pDeviceName
);
BOOL WINAPI DisassociateColorProfileFromDevice(
PCTSTR pMachineName,
PCTSTR pProfileName,
PCTSTR pDeviceName
);
Get/Set System Default Profile
BOOL WINAPI SetStandardColorSpaceProfile(
PCTSTR pMachineName,
DWORD dwProfileID,
PCSTR pProfilename // DMP or ICC profile
);
BOOL WINAPI GetStandardColorSpaceProfile(
PCTSTR pMachineName,
DWORD dwProfileID,
PTSTR pProfileName, // DMP or ICC profile
PDWORD pdwSize
);
Set Default Color Profiles (New API )
BOOL WINAPI WcsSetDefaultColorProfile(
PCTSTR pDeviceName, //Null = system level default
COLORPROFILETYPE cptValue,
LPCWSTR pProfilename
);
enum {
CPT_ALL = 0,
Set/Get
CPT_WINDOWS_COLOR_SPACE,
Set/Get
CPT_sRGB,
Set/Get
CPT_ICC,
Set/Get
CPT_DMP,
Set/Get
CPT_CAMP,
Set/Get
CPT_GMMP_ABSOLUTE_COLORIMETRIC,
CPT_GMMP_RELATIVE_COLORIMETRIC,
CPT_GMMP_PERCEPTUAL,
CPT_GMMP_SATURATION,
} COLORPROFILETYPE;
all default profiles for device
System Standard color space
System sRGB profile
default ICC profile for device, OS
default DMP for device or OS
default CAMP for device or OS
Set/Get GMMP to map to Abs Col RI
Set/Get GMMP to map to Rel Col RI
Set/Get GMMP to map to Percep RI
Set/Get GMMP to map to Sat RI
Get Default Color Profiles (New APIs)
Get size of buffer required for pProfileName
BOOL WINAPI WcsGetDefaultColorProfileSize(
PCTSTR pDeviceName,
COLORPROFILETYPE cptValue,
PDWORD pdwSize
);
BOOL WINAPI WcsGetDefaultColorProfile(
PCTSTR pDeviceName,
COLORPROFILETYPE cptValue,
DWORD dwSize,
LPWSTR pProfileName
);
Get Color Profiles Via:
GetStandardColorSpaceProfile
WcsGetDefaultColorProfile
EnumColorProfiles
PrintTicket/PrintCapabilities mechanism
See DDC session PrintTicket and PrintCapabilitiesOverview of Communications Schema and API
These get you profile filenames
Then use OpenColorProfile or
WcsOpenColorProfile to obtain HPROFILEs
EnumColorProfiles
BOOL WINAPI EnumColorProfiles(
PCTSTR pMachineName,
PENUMTYPE pEnumRecord,
PBYTE pBuffer,
PDWORD pdwSize,
PDWORD pnProfiles
);
This API will support WCS profiles in addition to ICC profiles
If pEnumRecord->dwFields has ET_SIGNATURE set and pEnumRecord->
dwSignature equals “cdmp” then all matching DMPs are enumerated.
Similar functionality is implemented for dwSignature of “camp” and
dwSignature of “gmmp”. WCS DMP profiles do not require the equivalent of
ICC ‘devs’ tags and so, that legacy matching criterion is not supported when
enumerating WCS DMPs
Get an HPROFILE: OpenColorProfile
HPROFILE WINAPI OpenColorProfile(
PPROFILE pProfile,
// ICC or DMP
DWORD dwDesiredAccess,
DWORD dwShareMode,
DWORD dwCreationMode
);
This API will support WCS DMPs, both by filename and as a DMP
image in a membuffer
Default CAMP and GMMP from Registry will be used with a DMP
Get an HPROFILE: WcsOpenColorProfile (New)
HPROFILE WINAPI WcsOpenColorProfile(
PPROFILE pDMPProfile, // required – ICC or DMP
PPROFILE pCAMPProfile, // required with DMP (ignored
// with ICC)
PPROFILE pGMMPProfile, // optional (ignored with ICC)
DWORD dwDesiredAccess,
DWORD dwShareMode,
DWORD dwCreationMode
);
pGMMPProfile can be NULL. In the NULL case, the default GMMP
will be used (configured with WcsSetDefaultColorProfile).
pGMMPProfile may be set to DEFER_UNTIL_RUNTIME. In the
DEFER_UNTIL_RUNTIME case GMMP usage will be determined by
profile sequence in the color transform context
Open a Color Profile
ICC or DMP filename
DMP
CAMP
GMMP
filename filename filename
OpenColorProfile()
WcsOpenColorProfile()
Default Profiles
in Registry
HPROFILE
Construct Color Transforms
CreateColorTransform
CreateMultiProfileColorTransform
CreateColorTransform
HTRANSFORM WINAPI CreateColorTransform(
LPLOGCOLORSPACE pLogColorSpace,
HPROFILE hDestProfile,
// ICC or WCS profile
HPROFILE hTargetProfile,
// ICC or WCS profile
DWORD dwFlags
// ignored if any WCS
);
hDestProfile and hTargetProfile can be handles to ICC or
WCS profiles
If only ICC profiles are used to create a transform, then the legacy
ICM CMM will be used for processing. If any WCS profiles are
involved then the processing will occur through the WCS CITE
hTargetProfile will be NULL unless you’re creating a softproofing transform
CreateMultiProfileTransform
HTRANSFORM WINAPI CreateMultiProfileTransform(
PHPROFILE pahProfiles,
// ptr to array of HPROFILEs
DWORD nProfiles,
// number of HPROFILEs (max 10)
PDWORD padwIntent,
// ptr to array of intents
DWORD nIntents,
// number of intents (max 10)
DWORD dwFlags,
// ignored if any WCS profiles
DWORD indexPreferredCMM
// ignored if any WCS profiles
);
pahProfiles - profile array can contain a mix of ICC and WCS profile handles
If only ICC profiles are used, processing will be via the legacy ICM2 CMM
nIntents must equal 1 or nProfiles
Intents corresponding to WCS HPROFILEs will result in the use of the corresponding
default GMMB mapped to that intent.
Intents specified in the padwIntent array trump GMMBs in WCS HPROFILEs,
unless…
For WCS profiles, setting the corresponding intent to -1 will force use of GMMPs
contained in WCS HPROFILEs (constructed with WcsOpenColorProfile).
ICC DeviceLink, Abstract, and NamedColor profiles are not supported in combination
with WCS profiles.
More profile sequencing discussion on next slide
Profile Sequencing in
CreateMultiProfileTransform
Ideally only one gamut mapping is performed between a
source and destination device
Achieved by setting one or the other GMMP to NULL
when creating the HPROFILE in WcsOpenColorProfile
Gamut Boundary Descriptions (GBDs) are created from
DMP+CAMP pairs. Subsequent GMMPs use the GBD
immediately prior to them until there exists a GBD for
DMP/CAMP next in the sequence
If two adjacent GMMPs are identical, one of them will be
removed
Transform Profile Sequence ExampleIgnored
padwIntent
INTENT_PECEPTUAL
-1
INTENT_RELATIVE
_COLORIMETRIC
HPROFILE 1
HPROFILE 2
HPROFILE 3
DMP1
DMP2
DMP 3
CAMP1
CAMP2
CAMP 3
GMMP1
GMMP2
NULL
DMP1 +CAMP1
 GBD1
Default Profiles
in Registry
DMP3 +CAMP3
DMP2 +CAMP2
GMMPPercept
 GBD2
GMMP2
 GBD3
Profile Sequencing Example
Consider the profile sequence: [ DMP1, CAMP1, GMMP1,
GMMP2, GMMP3, DMP2, CAMP2, GMMP4, GMMP5,
CAMP3, DMP3 ]
GMMP1 and GMMP2 use GBD1 (from DMP1+CAMP1) as their
source and destination GBD for gamut mapping
GMMP3 uses GBD1 as its source GBD and GBD2 (from
DMP2+CAMP2) as its destination GBD for gamut mapping
Then GMMP4 uses GBD2 as source and destination
Finally GMMP5 uses GBD2 as source and GBD3 as destination
- assumes no adjacent GMMPs are identical
Most real-world transforms will involve 2 or 3 DMPs &
CAMPs, with 1 or 2 GMMPs
When ICC profiles are involved the corresponding intent
from the intent array will be used with that profile
Applying a Color Transform
For legacy 16 bit per channel (bpc) and lower
color data formats:
TranslateBitmapBits
CheckBitmapBits
TranslateColors
CheckColors
For legacy plus new WCS 16 and 32 bpc floating
point formats:
WcsTranslateColors
WcsCheckColors
Legacy Color Data Formats
COLORTYPE Enumeration
This enumeration has 64 bit
typedef enum {
COLOR_GRAY = 1, // WORD
COLOR_RGB,
// WORD
COLOR_XYZ,
// WORD
COLOR_Yxy,
// WORD
COLOR_Lab,
// WORD
COLOR_3_CHANNEL, // WORD
COLOR_CMYK,
// WORD
COLOR_5_CHANNEL, // BYTE
COLOR_6_CHANNEL, // BYTE
COLOR_7_CHANNEL, // BYTE
COLOR_8_CHANNEL, // BYTE
COLOR_NAMED
} COLORTYPE;
underlying structures.
per
per
per
per
per
per
per
per
per
per
per
channel
channel
channel
channel
channel
channel
channel
channel
channel
channel
channel
Bitmap (Raster) Color Data Formats
typedef enum
{
BM_x555RGB = 0x0000,
BM_x555XYZ = 0x0101,
BM_x555Yxy,
BM_x555Lab,
BM_x555G3CH,
BM_RGBTRIPLETS = 0x0002,
BM_BGRTRIPLETS = 0x0004,
BM_XYZTRIPLETS = 0x0201,
BM_YxyTRIPLETS,
BM_LabTRIPLETS,
BM_G3CHTRIPLETS,
BM_5CHANNEL,
BM_6CHANNEL,
BM_7CHANNEL,
BM_8CHANNEL,
BM_GRAY,
BM_xRGBQUADS = 0x0008,
BM_xBGRQUADS = 0x0010,
BM_xG3CHQUADS = 0x0304,
BM_KYMCQUADS,
BM_CMYKQUADS = 0x0020,
BM_10b_RGB = 0x0009,
BM_10b_XYZ = 0x0401,
BM_10b_Yxy,
BM_10b_Lab,
BM_10b_G3CH,
BM_NAMED_INDEX,
BM_16b_RGB = 0x000A,
BM_16b_XYZ = 0x0501,
BM_16b_Yxy,
BM_16b_Lab,
BM_16b_G3CH,
BM_16b_GRAY,
BM_565RGB = 0x0001,
BM_32b_scARGB = 0x601, // NEW
BM_16b_scARGB,
BM_32b_scRGB,
BM_16b_scRGB,
} BMFORMAT;
Only with WCS transforms
TranslateColors, CheckColors
BOOL WINAPI TranslateColors(
HTRANSFORM hColorTransform,
PCOLOR
paInputColors,
DWORD
nColors,
COLORTYPE ctInput,
PCOLOR
paOutputColors,
COLORTYPE ctOutput
);
BOOL WINAPI CheckColors(
HTRANSFORM hColorTransform,
PCOLOR paInputColors,
DWORD nColors,
COLORTYPE ctInput,
PBYTE paResult
);
// ICC or WCS transform
// Legacy color formats
// Legacy color formats
// ICC or WCS transform
// Legacy color formats
TranslateBitmapBits, CheckBitmapBits
BOOL WINAPI TranslateBitmapBits(
HTRANSFORM
hColorTransform,
PVOID
pSrcBits,
BMFORMAT
bmInput,
DWORD
dwWidth,
DWORD
dwHeight,
DWORD
dwInputStride,
PVOID
pDestBits,
BMFORMAT
bmOutput,
DWORD
dwOutputStride,
PBMCALLBACKFN pfnCallback,
ULONG
ulCallbackData
);
BOOL WINAPI CheckBitmapBits(
HTRANSFORM
hColorTransform,
PVOID
pSrcBits,
BMFORMAT
bmInput,
DWORD
dwWidth,
DWORD
dwHeight,
DWORD
dwStride,
PBYTE
paResult,
PBMCALLBACKFN pfnCallback,
LPARAM
lpCallbackData
);
// ICC or WCS transform
// Legacy bitmap formats
// Legacy bitmap formats
// ICC or WCS transform
// Legacy bitmap formats
New WCS Color Data Formats
COLORDATATYPE enum
typedef enum {
COLOR_BYTE = 1,
COLOR_WORD,
COLOR_FLOAT,
COLOR_S2DOT13FIXED,
} COLORDATATYPE;
//
//
//
//
BYTE per channel, 8 bits range 0 to 255
WORD per channel, 16 bits range 0 to 65535
FLOAT per channel, 32 bits range uses
standard IEEE 32bit floats
// WORD per channel, fixed point ranging
// from -4 to +4 using s2.13
WcsTranslateColors, WcsCheckColors
BOOL WINAPI WCSTranslateColors(
HTRANSFORM hColorTransform,
DWORD nColors,
DWORD nInputChannels,
COLORDATATYPE cdtInput,
DWORD cbInput,
PVOID pInputData,
DWORD nOutputChannels,
COLORDATATYPE cdtOutput
DWORD cbOutput,
PVOID pOutputData,
);
BOOL WINAPI WCSCheckColors(
HTRANSFORM hColorTransform,
DWORD nColors,
DWORD nInputChannels,
COLORDATATYPE cdtInput,
DWORD cbInput,
PVOID pInputData,
PBYTE pResult,
);
// WCS transforms only
// Just new color data formats
// Just new color data formats
// WCS transforms only
// Just new color data formats
Call To Action
Understand the Windows Color System
Read WCS use cases
Submit your own scenarios
Send us feedback
Review the “Metro” v.7 specification and provide feedback
to prninfo @ microsoft.com
http://www.microsoft.com/whdc/device/print/metro.mspx
Start implementation with Beta 1!
Additional Resources
MSDN Developer Community Chats
Printer Drivers -- Ask the Experts Online
http://msdn.microsoft.com/chats/windows/windows_10240
2.asp
Windows Drivers: Printer Drivers
http://msdn.microsoft.com/chats/windows/windows_10160
2.asp
Windows Drivers Printing and Networking
http://msdn.microsoft.com/chats/windows/windows_02200
2.asp
Additional Resources
WS-Devices Profile:
http://msdn.microsoft.com/webservices/understanding/specs/
default.aspx?pull=/library/en-us/dnglobspec/html/devprof.asp
Printer Working Group
http://www.pwg.org
WHDC Printing home page:
http://www.microsoft.com/whdc/device/print/default.mspx
WHDC Still Imaging / WIA home page:
http://www.microsoft.com/whdc/device/stillimage/default.mspx
WHDC Color home page:
http://www.microsoft.com/whdc/device/display/color/default.mspx
Color Use Cases
http://www.microsoft.com/whdc/device/display/color/WCS_cases.mspx
Writing Effective Use Cases, Alistair Cockburn, ISBN 0201702258
Additional Resources
E-mail
For developer print questions: prninfo @ microsoft.com
For developer scan questions: wiainfo @ microsoft.com
For developer color questions: mscolor @ microsoft.com
© 2005 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.