' ########################################################################################
' Microsoft Windows
' File: Icm.inc
' Contents: Public header file for Image Color Management
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_Icm_PBI)
#DEFINE PBX_Icm_PBI
%EQUATE `ICM_INC = 1
#INCLUDE ONCE "Core/Windows.inc"
'//
'// Support for named color profiles
'//
'typedef char COLOR_NAME[32];
' // Size = 76 bytes
TYPE NAMED_PROFILE_INFO DWORD
 dwFlags AS DWORD
 dwCount AS DWORD
 dwCountDevCoordinates AS DWORD
 szPrefix AS ASCIIZ * 32 ' COLOR_NAME
 szSuffix AS ASCIIZ * 32 ' COLOR_NAME
END TYPE
'//
'// Color spaces
'//
'// The following color spaces are supported.
'// Gray, RGB, CMYK, XYZ, Yxy, Lab, generic 3 channel color spaces where
'// the profiles defines how to interpret the 3 channels, named color spaces
'// which can either be indices into the space or have color names, and
'// multichannel spaces with 1 byte per channel upto MAX_COLOR_CHANNELS.
'//
%EQUATE `MAX_COLOR_CHANNELS = 8 ' // maximum number of HiFi color channels
' // Size = 2 bytes
TYPE GRAYCOLOR WORD
 gray AS WORD ' WORD
END TYPE
' // Size = 6 bytes
TYPE RGBCOLOR WORD
 red AS WORD ' WORD
 green AS WORD ' WORD
 blue AS WORD ' WORD
END TYPE
' // Size = 8 bytes
TYPE CMYKCOLOR WORD
 cyan AS WORD ' WORD
 magenta AS WORD ' WORD
 yellow AS WORD ' WORD
 black AS WORD ' WORD
END TYPE
' // Size = 6 bytes
TYPE XYZCOLOR WORD
 X AS WORD ' WORD
 Y AS WORD ' WORD
 Z AS WORD ' WORD
END TYPE
' // Size = 6 bytes
TYPE YxyCOLOR WORD
 YCap AS WORD ' WORD
 x AS WORD ' WORD
 ySmall AS WORD ' WORD
END TYPE
' // Size = 6 bytes
TYPE LabCOLOR WORD
 L AS WORD ' WORD
 a AS WORD ' WORD
 b AS WORD ' WORD
END TYPE
' // Size = 6 bytes
TYPE GENERIC3CHANNEL WORD
 ch1 AS WORD ' WORD
 ch2 AS WORD ' WORD
 ch3 AS WORD ' WORD
END TYPE
' // Size = 4 bytes
TYPE NAMEDCOLOR DWORD
 dwIndex AS DWORD
END TYPE
' // Size = 8 bytes
TYPE HiFiCOLOR BYTE
 channel(%MAX_COLOR_CHANNELS - 1) AS BYTE
END TYPE
'typedef union tagCOLOR {
' 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;
' struct { // alignment padding.
' DWORD reserved1;
' VOID *reserved2;
' };
'} COLOR;
' // Size = 8 bytes
UNION tagCOLOR
 gray AS GRAYCOLOR
 rgb AS RGBCOLOR
 cmyk AS CMYKCOLOR
 XYZ AS XYZCOLOR
 Yxy AS YxyCOLOR
 Lab AS LabCOLOR
 gen3ch AS GENERIC3CHANNEL
 named AS NAMEDCOLOR
 hifi AS HiFiCOLOR
 ' // alignment padding.
 reserved1 AS DWORD
 reserved2 AS DWORD PTR ' VOID *
END UNION
' COLORTYPE enum
%EQUATE `COLOR_GRAY = 1
%EQUATE `COLOR_RGB = 2
%EQUATE `COLOR_XYZ = 3
%EQUATE `COLOR_Yxy = 4
%EQUATE `COLOR_Lab = 4
%EQUATE `COLOR_3_CHANNEL = 6 ' // WORD per channel
%EQUATE `COLOR_CMYK = 7
%EQUATE `COLOR_5_CHANNEL = 8 ' // BYTE per channel
%EQUATE `COLOR_6_CHANNEL = 9 ' // - do -
%EQUATE `COLOR_7_CHANNEL = 10 ' // - do -
%EQUATE `COLOR_8_CHANNEL = 11 ' // - do -
%EQUATE `COLOR_NAMED = 12
'//
'// Rendering Intents
'//
'// + INTENT_PERCEPTUAL = LCS_GM_IMAGES for LOGCOLORSPACE
'// = DMICM_CONTRAST for DEVMODE
'// = "Pictures" for SetupColorMathing/Printer UI
'//
'// + INTENT_RELATIVE_COLORIMETRIC = LCS_GM_GRAPHICS for LOGCOLORSPACE
'// = DMICM_COLORIMETRIC for DEVMODE
'// = "Proof" for SetupColorMatching/Printer UI
'//
'// + INTENT_SATURATION = LCS_GM_BUSINESS for LOGCOLORSPACE
'// = DMICM_SATURATE for DEVMODE
'// = "Graphics" for SetupColorMatching/Printer UI
'//
'// + INTENT_ABSOLUTE_COLORIMETRIC = LCS_GM_ABS_COLORIMETRIC for LOGCOLORSPACE
'// = DMICM_ABS_COLORIMETRIC for DEVMODE
'// = "Match" for SetupColorMatching/Printer UI
'//
%EQUATE `INTENT_PERCEPTUAL = 0
%EQUATE `INTENT_RELATIVE_COLORIMETRIC = 1
%EQUATE `INTENT_SATURATION = 2
%EQUATE `INTENT_ABSOLUTE_COLORIMETRIC = 3
'#if NTDDI_VERSION >= NTDDI_VISTA
' enum COLORPROFILETYPE
%EQUATE `CPT_ICC = 0
%EQUATE `CPT_DMP = 1
%EQUATE `CPT_CAMP = 2
%EQUATE `CPT_GMMP = 3
' enum COLORPROFILESUBTYPE
'// intent
%EQUATE `CPST_PERCEPTUAL = %INTENT_PERCEPTUAL
%EQUATE `CPST_RELATIVE_COLORIMETRIC = %INTENT_RELATIVE_COLORIMETRIC
%EQUATE `CPST_SATURATION = %INTENT_SATURATION
%EQUATE `CPST_ABSOLUTE_COLORIMETRIC = %INTENT_ABSOLUTE_COLORIMETRIC
'// working space
%EQUATE `CPST_NONE = 0
%EQUATE `CPST_RGB_WORKING_SPACE = 1
%EQUATE `CPST_CUSTOM_WORKING_SPACE = 2
'//
'// Device color data type
'//
' enum COLORDATATYPE
%EQUATE `COLOR_BYTE = 1 ' // BYTE per channel. data range [0, 255]
%EQUATE `COLOR_WORD = 2 ' // WORD per channel. data range [0, 65535]
%EQUATE `COLOR_FLOAT = 3 ' // FLOAT per channel. IEEE 32-bit floating point
%EQUATE `COLOR_S2DOT13FIXED = 4 ' // WORD per channel. data range [-4, +4] using s2.13
'//#if NTDDI_VERSION >= NTDDI_WIN7
%EQUATE `COLOR_10b_R10G10B10A2 = 5 ' // Packed WORD per channel. data range [0, 1]
%EQUATE `COLOR_10b_R10G10B10A2_XR = 6 ' // Packed extended range WORD per channel. data range [-1, 3]
 ' // using 4.0 scale and -1.0 bias.
%EQUATE `COLOR_FLOAT16 = 7 ' // FLOAT16 per channel.
'//#endif //NTDDI_VERSION >= NTDDI_WIN7
'#endif // NTDDI_VERSION >= NTDDI_VISTA
'//
'// Bitmap formats supported
'//
' BMFORMAT enum
' //
' // 16bpp - 5 bits per channel. The most significant bit is ignored.
' //
%EQUATE `BM_x555RGB = &H0000
%EQUATE `BM_x555XYZ = &H0101
%EQUATE `BM_x555Yxy = &H0102
%EQUATE `BM_x555Lab = &H0103
%EQUATE `BM_x555G3CH = &H0104
' //
' // Packed 8 bits per channel => 8bpp for GRAY and
' // 24bpp for the 3 channel colors, more for hifi channels
' //
%EQUATE `BM_RGBTRIPLETS = &H0002
%EQUATE `BM_BGRTRIPLETS = &H0004
%EQUATE `BM_XYZTRIPLETS = &H0201
%EQUATE `BM_YxyTRIPLETS = &H0202
%EQUATE `BM_LabTRIPLETS = &H0203
%EQUATE `BM_G3CHTRIPLETS = &H0204
%EQUATE `BM_5CHANNEL = &H0205
%EQUATE `BM_6CHANNEL = &H0206
%EQUATE `BM_7CHANNEL = &H0207
%EQUATE `BM_8CHANNEL = &H0208
%EQUATE `BM_GRAY = &H0209
' //
' // 32bpp - 8 bits per channel. The most significant byte is ignored
' // for the 3 channel colors.
' //
%EQUATE `BM_xRGBQUADS = &H0008
%EQUATE `BM_xBGRQUADS = &H0010
%EQUATE `BM_xG3CHQUADS = &H0304
%EQUATE `BM_KYMCQUADS = &H0305
%EQUATE `BM_CMYKQUADS = &H0020
' //
' // 32bpp - 10 bits per channel. The 2 most significant bits are ignored.
' //
%EQUATE `BM_10b_RGB = &H0009
%EQUATE `BM_10b_XYZ = &H0401
%EQUATE `BM_10b_Yxy = &H0402
%EQUATE `BM_10b_Lab = &H0403
%EQUATE `BM_10b_G3CH = &H0404
' //
' // 32bpp - named color indices (1-based)
' //
%EQUATE `BM_NAMED_INDEX = &H0405
' //
' // Packed 16 bits per channel => 16bpp for GRAY and
' // 48bpp for the 3 channel colors.
' //
%EQUATE `BM_16b_RGB = &H000A
%EQUATE `BM_16b_XYZ = &H0501
%EQUATE `BM_16b_Yxy = &H0502
%EQUATE `BM_16b_Lab = &H0503
%EQUATE `BM_16b_G3CH = &H0504
%EQUATE `BM_16b_GRAY = &H0505
' //
' // 16 bpp - 5 bits for Red & Blue, 6 bits for Green
' //
%EQUATE `BM_565RGB = &H0001
'//#if NTDDI_VERSION >= NTDDI_VISTA
' //
' // scRGB - 32 bits per channel floating point
' // 16 bits per channel floating point
' //
%EQUATE `BM_32b_scRGB = &H0601
%EQUATE `BM_32b_scARGB = &H0602
%EQUATE `BM_S2DOT13FIXED_scRGB = &H0603
%EQUATE `BM_S2DOT13FIXED_scARGB = &H0604
'//#endif // NTDDI_VERSION >= NTDDI_VISTA
'//#if NTDDI_VERSION >= NTDDI_WIN7
%EQUATE `BM_R10G10B10A2 = &H0701
%EQUATE `BM_R10G10B10A2_XR = &H0702
%EQUATE `BM_R16G16B16A16_FLOAT = &H0703
'//#endif // NTDDI_VERSION >= NTDDI_WIN7
'//
'// Callback function definition
'//
'typedef BOOL (WINAPI *PBMCALLBACKFN)(ULONG, ULONG, LPARAM);
'//
'// ICC profile header
'//
' // Size = 128 bytes
TYPE PROFILEHEADER DWORD
 phSize AS DWORD ' DWORD // profile size in bytes
 phCMMType AS DWORD ' DWORD // CMM for this profile
 phVersion AS DWORD ' DWORD // profile format version number
 phClass AS DWORD ' DWORD // type of profile
 phDataColorSpace AS DWORD ' DWORD // color space of data
 phConnectionSpace AS DWORD ' DWORD // PCS
 phDateTime(2) AS DWORD ' DWORD[3] // date profile was created
 phSignature AS DWORD ' DWORD // magic number
 phPlatform AS DWORD ' DWORD // primary platform
 phProfileFlags AS DWORD ' DWORD // various bit settings
 phManufacturer AS DWORD ' DWORD // device manufacturer
 phModel AS DWORD ' DWORD // device model number
 phAttributes(1) AS DWORD ' DWORD[2] // device attributes
 phRenderingIntent AS DWORD ' DWORD // rendering intent
 phIlluminant AS CIEXYZ ' CIEXYZ // profile illuminant
 phCreator AS DWORD ' DWORD // profile creator
 phReserved(43) AS BYTE ' BYTE[44] // reserved for future use
END TYPE
'//
'// Profile class values
'//
$CLASS_MONITOR = "mntr"
$CLASS_PRINTER = "prtr"
$CLASS_SCANNER = "scnr"
$CLASS_LINK = "link"
$CLASS_ABSTRACT = "abst"
$CLASS_COLORSPACE = "spac"
$CLASS_NAMED = "nmcl"
'#if NTDDI_VERSION >= NTDDI_VISTA
$CLASS_CAMP = "camp"
$CLASS_GMMP = "gmmp"
'#endif // NTDDI_VERSION >= NTDDI_VISTA
'//
'// Color space values
'//
$SPACE_XYZ = "XYZ "
$SPACE_Lab = "Lab "
$SPACE_Luv = "Luv "
$SPACE_YCbCr = "YCbr"
$SPACE_Yxy = "Yxy "
$SPACE_RGB = "RGB "
$SPACE_GRAY = "GRAY"
$SPACE_HSV = "HSV "
$SPACE_HLS = "HLS "
$SPACE_CMYK = "CMYK"
$SPACE_CMY = "CMY "
$SPACE_2_CHANNEL = "2CLR"
$SPACE_3_CHANNEL = "3CLR"
$SPACE_4_CHANNEL = "4CLR"
$SPACE_5_CHANNEL = "5CLR"
$SPACE_6_CHANNEL = "6CLR"
$SPACE_7_CHANNEL = "7CLR"
$SPACE_8_CHANNEL = "8CLR"
'//
'// Profile flag bitfield values
'//
%EQUATE `FLAG_EMBEDDEDPROFILE = &H00000001
%EQUATE `FLAG_DEPENDENTONDATA = &H00000002
'//
'// Profile flag bits for vendor extensions (bytes 44..45 of the ICC profile header).
'//
'#if NTDDI_VERSION >= NTDDI_VISTA
'//
'// Enable support for chromatic adaptation.
'//
%EQUATE `FLAG_ENABLE_CHROMATIC_ADAPTATION = &H02000000
'#endif // NTDDI_VERSION >= NTDDI_VISTA
'//
'// Profile attributes bitfield values
'//
%EQUATE `ATTRIB_TRANSPARENCY = &H00000001
%EQUATE `ATTRIB_MATTE = &H00000002
'//
'// Profile data structure
'//
' // Size = 12 bytes
TYPE tagPROFILE DWORD
 dwType AS DWORD ' DWORD // profile type
 pProfileData AS DWORD ' PVOID // filename or buffer containing profile
 cbDataSize AS DWORD ' DWORD // size of profile data
END TYPE
'//
'// Profile types to be used in the PROFILE structure
'//
%EQUATE `PROFILE_FILENAME = 1 ' // profile data is NULL terminated filename
%EQUATE `PROFILE_MEMBUFFER = 2 ' // profile data is a buffer containing the profile
'//
'// Desired access mode for opening profiles
'//
%EQUATE `PROFILE_READ = 1 ' // opened for read access
%EQUATE `PROFILE_READWRITE = 2 ' // opened for read and write access
'//
'// Handles returned to applications
'//
'typedef HANDLE HPROFILE; // handle to profile object
'typedef HPROFILE *PHPROFILE;
'typedef HANDLE HTRANSFORM; // handle to color transform object
'//
'// CMM selection for CreateMultiProfileTransform and SelectCMM.
'//
%EQUATE `INDEX_DONT_CARE = 0
%EQUATE `CMM_FROM_PROFILE = %INDEX_DONT_CARE ' // Use CMM specified in profile.
$CMM_WINDOWS_DEFAULT = "Win " ' // Use Windows default CMM always.
'//
'// Tags found in ICC profiles
'//
'typedef DWORD TAGTYPE;
'typedef TAGTYPE *PTAGTYPE, *LPTAGTYPE;
'//
'// Profile enumeration data structure
'//
%EQUATE `ENUM_TYPE_VERSION = &H0300
' // Size = 88 bytes
TYPE ENUMTYPEA DWORD
 dwSize AS DWORD ' DWORD // structure size
 dwVersion AS DWORD ' DWORD // structure version
 dwFields AS DWORD ' DWORD // bit fields
 pDeviceName AS ASCIIZ PTR ' PCSTR // device friendly name
 dwMediaType AS DWORD ' DWORD // media type
 dwDitheringMode AS DWORD ' DWORD // dithering mode
 dwResolution(1) AS DWORD ' DWORD[2] // x and y resolutions
 dwCMMType AS DWORD ' DWORD // cmm ID
 dwClass AS DWORD ' DWORD // profile class
 dwDataColorSpace AS DWORD ' DWORD // color space of data
 dwConnectionSpace AS DWORD ' DWORD // pcs
 dwSignature AS DWORD ' DWORD // magic number
 dwPlatform AS DWORD ' DWORD // primary platform
 dwProfileFlags AS DWORD ' DWORD // various bit settings in profile
 dwManufacturer AS DWORD ' DWORD // manufacturer ID
 dwModel AS DWORD ' DWORD // model ID
 dwAttributes(1) AS DWORD ' DWORD[2] // device attributes
 dwRenderingIntent AS DWORD ' DWORD // rendering intent
 dwCreator AS DWORD ' DWORD // profile creator
 dwDeviceClass AS DWORD ' DWORD // device class
END TYPE
' // Size = 88 bytes
TYPE ENUMTYPEW DWORD
 dwSize AS DWORD ' DWORD // structure size
 dwVersion AS DWORD ' DWORD // structure version
 dwFields AS DWORD ' DWORD // bit fields
 pDeviceName AS WSTRINGZ PTR ' PCWSTR // device friendly name
 dwMediaType AS DWORD ' DWORD // media type
 dwDitheringMode AS DWORD ' DWORD[2] // dithering mode
 dwResolution(1) AS DWORD ' DWORD // x and y resolutions
 dwCMMType AS DWORD ' DWORD // cmm ID
 dwClass AS DWORD ' DWORD // profile class
 dwDataColorSpace AS DWORD ' DWORD // color space of data
 dwConnectionSpace AS DWORD ' DWORD // pcs
 dwSignature AS DWORD ' DWORD // magic number
 dwPlatform AS DWORD ' DWORD // primary platform
 dwProfileFlags AS DWORD ' DWORD // various bit settings in profile
 dwManufacturer AS DWORD ' DWORD // manufacturer ID
 dwModel AS DWORD ' DWORD // model ID
 dwAttributes(1) AS DWORD ' DWORD[2] // device attributes
 dwRenderingIntent AS DWORD ' DWORD // rendering intent
 dwCreator AS DWORD ' DWORD // profile creator
 dwDeviceClass AS DWORD ' DWORD // device class
END TYPE
MACRO ENUMTYPE = ENUMTYPEA
'//
'// Bitfields for enumeration record above
'//
%EQUATE `ET_DEVICENAME = &H00000001
%EQUATE `ET_MEDIATYPE = &H00000002
%EQUATE `ET_DITHERMODE = &H00000004
%EQUATE `ET_RESOLUTION = &H00000008
%EQUATE `ET_CMMTYPE = &H00000010
%EQUATE `ET_CLASS = &H00000020
%EQUATE `ET_DATACOLORSPACE = &H00000040
%EQUATE `ET_CONNECTIONSPACE = &H00000080
%EQUATE `ET_SIGNATURE = &H00000100
%EQUATE `ET_PLATFORM = &H00000200
%EQUATE `ET_PROFILEFLAGS = &H00000400
%EQUATE `ET_MANUFACTURER = &H00000800
%EQUATE `ET_MODEL = &H00001000
%EQUATE `ET_ATTRIBUTES = &H00002000
%EQUATE `ET_RENDERINGINTENT = &H00004000
%EQUATE `ET_CREATOR = &H00008000
%EQUATE `ET_DEVICECLASS = &H00010000
'#if NTDDI_VERSION >= NTDDI_VISTA
'//
'// WCS profile management scope - system-wide and current-user
'//
' enum WCS_PROFILE_MANAGEMENT_SCOPE
%EQUATE `WCS_PROFILE_MANAGEMENT_SCOPE_SYSTEM_WIDE = 0
%EQUATE `WCS_PROFILE_MANAGEMENT_SCOPE_CURRENT_USER = 1
'#endif // NTDDI_VERSION >= NTDDI_VISTA
'//
'// Flags for creating color transforms
'//
%EQUATE `PROOF_MODE = &H00000001
%EQUATE `NORMAL_MODE = &H00000002
%EQUATE `BEST_MODE = &H00000003
%EQUATE `ENABLE_GAMUT_CHECKING = &H00010000
%EQUATE `USE_RELATIVE_COLORIMETRIC = &H00020000
%EQUATE `FAST_TRANSLATE = &H00040000
'#if NTDDI_VERSION >= NTDDI_VISTA
%EQUATE `PRESERVEBLACK = &H00100000
%EQUATE `WCS_ALWAYS = &H00200000
%EQUATE `SEQUENTIAL_TRANSFORM = &H80800000
'#endif // NTDDI_VERSION >= NTDDI_VISTA
%EQUATE `RESERVED = &H80000000
'//
'// Paremeter for GetPS2ColorSpaceArray
'//
%EQUATE `CSA_A = 1
%EQUATE `CSA_ABC = 2
%EQUATE `CSA_DEF = 3
%EQUATE `CSA_DEFG = 4
%EQUATE `CSA_GRAY = 5
%EQUATE `CSA_RGB = 6
%EQUATE `CSA_CMYK = 7
%EQUATE `CSA_Lab = 8
'//
'// Parameter for CMGetInfo()
'//
%EQUATE `CMM_WIN_VERSION = 0
%EQUATE `CMM_IDENT = 1
%EQUATE `CMM_DRIVER_VERSION = 2
%EQUATE `CMM_DLL_VERSION = 3
%EQUATE `CMM_VERSION = 4
%EQUATE `CMM_DESCRIPTION = 5
%EQUATE `CMM_LOGOICON = 6
'//
'// Parameter for CMTranslateRGBs()
'//
%EQUATE `CMS_FORWARD = 0
%EQUATE `CMS_BACKWARD = 1
'//
'// Constants for SetupColorMatching()
'//
%EQUATE `COLOR_MATCH_VERSION = &H0200
'//
'// Constants for flags
'//
%EQUATE `CMS_DISABLEICM = 1 ' // Disable color matching
%EQUATE `CMS_ENABLEPROOFING = 2 ' // Enable proofing
%EQUATE `CMS_SETRENDERINTENT = 4 ' // Use passed in value
%EQUATE `CMS_SETPROOFINTENT = 8
%EQUATE `CMS_SETMONITORPROFILE = &H10 ' // Use passed in profile name initially
%EQUATE `CMS_SETPRINTERPROFILE = &H20
%EQUATE `CMS_SETTARGETPROFILE = &H40
%EQUATE `CMS_USEHOOK = &H80 ' // Use hook procedure in lpfnHook
%EQUATE `CMS_USEAPPLYCALLBACK = &H100 ' // Use callback procedure when applied
%EQUATE `CMS_USEDESCRIPTION = &H200 ' // Use profile description in UI
 ' // (default is filename)
%EQUATE `CMS_DISABLEINTENT = &H400 ' // Disable intent selection (render & proofing) always
%EQUATE `CMS_DISABLERENDERINTENT = &H800 ' // Disable rendering intent selection while in proofing mode
 ' // Only proofing intent selection is enabled.
'//
'// Used to denote too-small buffers (output only)
'//
%EQUATE `CMS_MONITOROVERFLOW = &H80000000
%EQUATE `CMS_PRINTEROVERFLOW = &H40000000
%EQUATE `CMS_TARGETOVERFLOW = &H20000000
'//
'// Structures (both ANSI and Unicode)
'//
'struct _tagCOLORMATCHSETUPW;
'struct _tagCOLORMATCHSETUPA;
'typedef BOOL (WINAPI *PCMSCALLBACKW)(struct _tagCOLORMATCHSETUPW *,LPARAM);
'typedef BOOL (WINAPI *PCMSCALLBACKA)(struct _tagCOLORMATCHSETUPA *,LPARAM);
' // Size = 76 bytes
TYPE COLORMATCHSETUPW DWORD
 dwSize AS DWORD ' DWORD // Size of structure in bytes
 dwVersion AS DWORD ' DWORD // Set to COLOR_MATCH_VERSION
 dwFlags AS DWORD ' DWORD // See constants listed previously
 hwndOwner AS DWORD ' HWND // Window handle of owner
 pSourceName AS WSTRINGZ PTR ' PCWSTR // Name of Image Source, defaults to "sRGB Color Space"
 pDisplayName AS WSTRINGZ PTR ' PCWSTR // If null, defaults to first enumerated monitor
 pPrinterName AS WSTRINGZ PTR ' PCWSTR // If null, defaults to default printer.
 dwRenderIntent AS DWORD ' DWORD // Rendering Intent
 dwProofingIntent AS DWORD ' DWORD // Rendering Intent for Proofing
 pMonitorProfile AS WSTRINGZ PTR ' PWSTR // Monitor profile name
 ccMonitorProfile AS DWORD ' DWORD // Size of above in characters
 pPrinterProfile AS WSTRINGZ PTR ' PWSTR // Printer profile name
 ccPrinterProfile AS DWORD ' DWORD // Size of above in characters
 pTargetProfile AS WSTRINGZ PTR ' PWSTR // Target profile name
 ccTargetProfile AS DWORD ' DWORD // Size of above in characters
 lpfnHook AS DWORD ' DLGPROC // Hook Procedure address
 lParam AS DWORD ' LPARAM // Given to hook procedure at WM_INITDIALOG
 lpfnApplyCallback AS DWORD ' PCMSCALLBACKW // Callback Procedure address when apply is pushed
 lParamApplyCallback AS DWORD ' LPARAM // Given to callback Procedure for apply
END TYPE
' // Size = 76 bytes
TYPE COLORMATCHSETUPA DWORD
 dwSize AS DWORD ' DWORD // Size of structure in bytes
 dwVersion AS DWORD ' DWORD // Set to COLOR_MATCH_VERSION
 dwFlags AS DWORD ' DWORD // See constants listed previously
 hwndOwner AS DWORD ' HWND // Window handle of owner
 pSourceName AS ASCIIZ PTR ' PCSTR // Name of Image Source, defaults to "sRGB Color Space"
 pDisplayName AS ASCIIZ PTR ' PCSTR // If null, defaults to first enumerated monitor
 pPrinterName AS ASCIIZ PTR ' PCSTR // If null, defaults to default printer.
 dwRenderIntent AS DWORD ' DWORD // Rendering Intent
 dwProofingIntent AS DWORD ' DWORD // Rendering Intent for Proofing
 pMonitorProfile AS ASCIIZ PTR ' PSTR // Monitor profile name
 ccMonitorProfile AS DWORD ' DWORD // Size of above in characters
 pPrinterProfile AS ASCIIZ PTR ' PSTR // Printer profile name
 ccPrinterProfile AS DWORD ' DWORD // Size of above in characters
 pTargetProfile AS ASCIIZ PTR ' PSTR // Target profile name
 ccTargetProfile AS DWORD ' DWORD // Size of above in characters
 lpfnHook AS DWORD ' DLGPROC // Hook Procedure address
 lParam AS DWORD ' LPARAM // Given to hook procedure at WM_INITDIALOG
 lpfnApplyCallback AS DWORD ' PCMSCALLBACKW // Callback Procedure address when apply is pushed
 lParamApplyCallback AS DWORD ' LPARAM // Given to callback Procedure for apply
END TYPE
MACRO COLORMATCHSETUP = COLORMATCHSETUPA
'//
'// Windows API definitions
'//
DECLARE FUNCTION OpenColorProfileA LIB "mscms.dll" ALIAS "OpenColorProfileA" ( BYREF pProfile AS tagPROFILE , BYVAL dwDesiredAccess AS QUAD , BYVAL dwShareMode AS QUAD , BYVAL dwCreationMode AS QUAD ) AS QUAD ' HPROFILE
DECLARE FUNCTION OpenColorProfileW LIB "mscms.dll" ALIAS "OpenColorProfileW" ( BYREF pProfile AS tagPROFILE , BYVAL dwDesiredAccess AS QUAD , BYVAL dwShareMode AS QUAD , BYVAL dwCreationMode AS QUAD ) AS QUAD ' HPROFILE
#IF %DEF(%UNICODE)
 MACRO OpenColorProfile = OpenColorProfileW
#ELSE
 MACRO OpenColorProfile = OpenColorProfileA
#ENDIF
DECLARE FUNCTION CloseColorProfile LIB "mscms.dll" ALIAS "CloseColorProfile" ( BYVAL hProfile AS QUAD ) AS LONG
DECLARE FUNCTION GetColorProfileFromHandle LIB "mscms.dll" ALIAS "GetColorProfileFromHandle" ( BYVAL hProfile AS QUAD
 , BYVAL pBuffer AS BYTE PTR
 , BYREF pcbSize AS DWORD
 ) AS LONG
DECLARE FUNCTION IsColorProfileValid LIB "mscms.dll" ALIAS "IsColorProfileValid" ( BYVAL hProfile AS DWORD
 , BYREF pbValid AS LONG
 ) AS LONG
DECLARE FUNCTION CreateProfileFromLogColorSpaceA LIB "mscms.dll" ALIAS "CreateProfileFromLogColorSpaceA" ( BYREF pLogColorSpace AS LOGCOLORSPACEA
 , BYREF pBuffer AS DWORD
 ) AS LONG
DECLARE FUNCTION CreateProfileFromLogColorSpaceW LIB "mscms.dll" ALIAS "CreateProfileFromLogColorSpaceW" ( BYREF pLogColorSpace AS LOGCOLORSPACEW
 , BYREF pBuffer AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO CreateProfileFromLogColorSpace = CreateProfileFromLogColorSpaceW
#ELSE
 MACRO CreateProfileFromLogColorSpace = CreateProfileFromLogColorSpaceA
#ENDIF
DECLARE FUNCTION GetCountColorProfileElements LIB "mscms.dll" ALIAS "GetCountColorProfileElements" ( BYVAL hProfile AS QUAD , BYREF pnCount AS QUAD ) AS LONG
DECLARE FUNCTION GetColorProfileHeader LIB "mscms.dll" ALIAS "GetColorProfileHeader" ( BYVAL hProfile AS QUAD
 , BYREF pHeader AS PROFILEHEADER
 ) AS LONG
DECLARE FUNCTION GetColorProfileElementTag LIB "mscms.dll" ALIAS "GetColorProfileElementTag" ( BYVAL hProfile AS DWORD
 , BYVAL dwIndex AS DWORD
 , BYREF pTag AS DWORD
 ) AS LONG
DECLARE FUNCTION IsColorProfileTagPresent LIB "mscms.dll" ALIAS "IsColorProfileTagPresent" ( BYVAL hProfile AS DWORD
 , BYVAL tag AS DWORD
 , BYREF pbPresent AS LONG
 ) AS LONG
DECLARE FUNCTION GetColorProfileElement LIB "mscms.dll" ALIAS "GetColorProfileElement" ( BYVAL hProfile AS DWORD
 , BYVAL tag AS DWORD
 , BYVAL dwOffset AS DWORD
 , BYREF pcbSize AS DWORD
 , BYVAL pBuffer AS DWORD
 , BYREF pbReference AS LONG
 ) AS LONG
DECLARE FUNCTION SetColorProfileHeader LIB "mscms.dll" ALIAS "SetColorProfileHeader" ( BYVAL hProfile AS DWORD
 , BYREF pHeader AS PROFILEHEADER
 ) AS LONG
DECLARE FUNCTION SetColorProfileElementSize LIB "mscms.dll" ALIAS "SetColorProfileElementSize" ( BYVAL hProfile AS DWORD
 , BYVAL tag AS DWORD
 , BYVAL cbSize AS DWORD
 ) AS LONG
DECLARE FUNCTION SetColorProfileElement LIB "mscms.dll" ALIAS "SetColorProfileElement" ( BYVAL hProfile AS DWORD
 , BYVAL tag AS DWORD
 , BYVAL dwOffset AS DWORD
 , BYREF pcbSize AS DWORD
 , BYVAL pBuffer AS DWORD
 ) AS LONG
DECLARE FUNCTION SetColorProfileElementReference LIB "mscms.dll" ALIAS "SetColorProfileElementReference" ( BYVAL hProfile AS DWORD
 , BYVAL newTag AS DWORD
 , BYVAL refTag AS DWORD
 ) AS LONG
DECLARE FUNCTION GetPS2ColorSpaceArray LIB "mscms.dll" ALIAS "GetPS2ColorSpaceArray" ( BYVAL hProfile AS DWORD
 , BYVAL dwIntent AS DWORD
 , BYVAL dwCSAType AS DWORD
 , BYVAL pBuffer AS BYTE PTR
 , BYREF pcbSize AS DWORD
 , BYREF pbBinary AS LONG
 ) AS LONG
DECLARE FUNCTION GetPS2ColorRenderingIntent LIB "mscms.dll" ALIAS "GetPS2ColorRenderingIntent" ( BYVAL hProfile AS DWORD
 , BYVAL dwIntent AS DWORD
 , BYVAL pBuffer AS BYTE PTR
 , BYREF pcbSize AS DWORD
 ) AS LONG
DECLARE FUNCTION GetPS2ColorRenderingDictionary LIB "mscms.dll" ALIAS "GetPS2ColorRenderingDictionary" ( BYVAL hProfile AS DWORD
 , BYVAL dwIntent AS DWORD
 , BYVAL pBuffer AS BYTE PTR
 , BYREF pcbSize AS DWORD
 , BYREF pbBinary AS LONG
 ) AS LONG
DECLARE FUNCTION GetNamedProfileInfo LIB "mscms.dll" ALIAS "GetNamedProfileInfo" ( BYVAL hProfile AS DWORD
 , BYREF pNamedProfileInfo AS NAMED_PROFILE_INFO
 ) AS LONG
DECLARE FUNCTION ConvertColorNameToIndex LIB "mscms.dll" ALIAS "ConvertColorNameToIndex" ( BYVAL hProfile AS DWORD
 , BYREF paColorName AS ANY
 , BYREF paIndex AS DWORD
 , BYVAL dwCount AS DWORD
 ) AS LONG
DECLARE FUNCTION ConvertIndexToColorName LIB "mscms.dll" ALIAS "ConvertIndexToColorName" ( BYVAL hProfile AS DWORD
 , BYREF paIndex AS DWORD
 , BYREF paColorName AS ANY
 , BYVAL dwCount AS DWORD
 ) AS LONG
DECLARE FUNCTION CreateDeviceLinkProfile LIB "mscms.dll" ALIAS "CreateDeviceLinkProfile" ( BYREF pahProfiles AS DWORD
 , BYVAL nProfiles AS DWORD
 , BYREF padwIntent AS DWORD
 , BYVAL nIntents AS DWORD
 , BYVAL dwFlags AS DWORD
 , BYREF pProfileData AS DWORD
 , BYVAL indexPreferredCMM AS DWORD
 ) AS LONG
DECLARE FUNCTION CreateColorTransformA LIB "mscms.dll" ALIAS "CreateColorTransformA" ( BYREF pahProfiles AS DWORD
 , BYREF pLogColorSpace AS LOGCOLORSPACEA
 , BYVAL hDestProfile AS DWORD
 , BYVAL hTargetProfile AS DWORD
 , BYVAL dwFlags AS DWORD
 ) AS DWORD ' HTRANSFORM
DECLARE FUNCTION CreateColorTransformW LIB "mscms.dll" ALIAS "CreateColorTransformW" ( BYREF pahProfiles AS QUAD , BYREF pLogColorSpace AS LOGCOLORSPACEW , BYVAL hDestProfile AS QUAD , BYVAL hTargetProfile AS QUAD , BYVAL dwFlags AS QUAD ) AS QUAD ' HTRANSFORM
#IF %DEF(%UNICODE)
 MACRO CreateColorTransform = CreateColorTransformW
#ELSE
 MACRO CreateColorTransform = CreateColorTransformA
#ENDIF
DECLARE FUNCTION CreateMultiProfileTransform LIB "mscms.dll" ALIAS "CreateMultiProfileTransform" ( BYREF pahProfiles AS QUAD , BYVAL nProfiles AS QUAD , BYREF padwIntent AS QUAD , BYVAL nIntents AS QUAD , BYVAL dwFlags AS QUAD , BYVAL indexPreferredCMM AS QUAD ) AS QUAD ' HTRANSFORM
DECLARE FUNCTION DeleteColorTransform LIB "mscms.dll" ALIAS "DeleteColorTransform" ( BYVAL hColorTransform AS QUAD ) AS LONG ' HTRANSFORM hColorTransform
DECLARE FUNCTION TranslateBitmapBits LIB "mscms.dll" ALIAS "TranslateBitmapBits" ( BYVAL hColorTransform AS QUAD
 , BYREF pSrcBits AS ANY
 , BYVAL bmInput AS LONG
 , BYVAL dwWidth AS DWORD
 , BYVAL dwHeight AS DWORD
 , BYVAL dwInputStride AS DWORD
 , BYREF pDestBits AS ANY
 , BYVAL bmOutput AS LONG
 , BYVAL dwOutputStride AS DWORD
 , BYVAL pfnCallback AS DWORD
 , BYVAL ulCallbackData AS DWORD
 ) AS LONG
DECLARE FUNCTION CheckBitmapBits LIB "mscms.dll" ALIAS "CheckBitmapBits" ( BYVAL hColorTransform AS DWORD
 , BYREF pSrcBits AS ANY
 , BYVAL bmInput AS LONG
 , BYVAL dwWidth AS DWORD
 , BYVAL dwHeight AS DWORD
 , BYVAL dwStride AS DWORD
 , BYREF paResult AS BYTE
 , BYVAL pfnCallback AS DWORD
 , BYVAL lpCallbackData AS DWORD
 ) AS LONG
DECLARE FUNCTION TranslateColors LIB "mscms.dll" ALIAS "TranslateColors" ( BYVAL hColorTransform AS DWORD
 , BYREF paInputColors AS tagCOLOR
 , BYVAL nColors AS DWORD
 , BYVAL ctInput AS LONG
 , BYREF paOutputColors AS tagCOLOR
 , BYVAL ctOutput AS LONG
 ) AS LONG
DECLARE FUNCTION CheckColors LIB "mscms.dll" ALIAS "CheckColors" ( BYVAL hColorTransform AS DWORD
 , BYREF paInputColors AS tagCOLOR
 , BYVAL nColors AS DWORD
 , BYVAL ctInput AS LONG
 , BYREF paResult AS BYTE
 ) AS LONG
DECLARE FUNCTION GetCMMInfo LIB "mscms.dll" ALIAS "GetCMMInfo" ( BYVAL hColorTransform AS DWORD
 , BYVAL dwInfo AS DWORD
 ) AS DWORD
DECLARE FUNCTION RegisterCMMA LIB "mscms.dll" ALIAS "RegisterCMMA" ( BYREF pMachineName AS ASCIIZ
 , BYVAL cmmID AS DWORD
 , BYREF pCMMdll AS ASCIIZ
 ) AS LONG
DECLARE FUNCTION RegisterCMMW LIB "mscms.dll" ALIAS "RegisterCMMW" ( BYREF pMachineName AS WSTRINGZ
 , BYVAL cmmID AS DWORD
 , BYREF pCMMdll AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO RegisterCMM = RegisterCMMW
#ELSE
 MACRO RegisterCMM = RegisterCMMA
#ENDIF
DECLARE FUNCTION UnregisterCMMA LIB "mscms.dll" ALIAS "UnregisterCMMA" ( BYREF pMachineName AS ASCIIZ , BYVAL cmmID AS QUAD ) AS LONG
DECLARE FUNCTION UnregisterCMMW LIB "mscms.dll" ALIAS "UnregisterCMMW" ( BYREF pMachineName AS WSTRINGZ
 , BYVAL cmmID AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO UnregisterCMM = UnregisterCMMW
#ELSE
 MACRO UnregisterCMM = UnregisterCMMA
#ENDIF
DECLARE FUNCTION SelectCMM LIB "mscms.dll" ALIAS "SelectCMM" ( BYVAL cmmID AS QUAD ) AS LONG
DECLARE FUNCTION GetColorDirectoryA LIB "mscms.dll" ALIAS "GetColorDirectoryA" ( BYREF pMachineName AS ASCIIZ
 , BYREF pBuffer AS ASCIIZ
 , BYREF pdwSize AS DWORD
 ) AS LONG
DECLARE FUNCTION GetColorDirectoryW LIB "mscms.dll" ALIAS "GetColorDirectoryW" ( BYREF pMachineName AS WSTRINGZ
 , BYVAL pBuffer AS DWORD
 , BYREF pdwSize AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO GetColorDirectory = GetColorDirectoryW
#ELSE
 MACRO GetColorDirectory = GetColorDirectoryA
#ENDIF
DECLARE FUNCTION InstallColorProfileA LIB "mscms.dll" ALIAS "InstallColorProfileA" ( BYREF pMachineName AS ASCIIZ , BYREF pProfileName AS ASCIIZ ) AS LONG
DECLARE FUNCTION InstallColorProfileW LIB "mscms.dll" ALIAS "InstallColorProfileW" ( BYREF pMachineName AS WSTRINGZ
 , BYREF pProfileName AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO InstallColorProfile = InstallColorProfileW
#ELSE
 MACRO InstallColorProfile = InstallColorProfileA
#ENDIF
DECLARE FUNCTION UninstallColorProfileA LIB "mscms.dll" ALIAS "UninstallColorProfileA" ( BYREF pMachineName AS ASCIIZ , BYREF pProfileName AS ASCIIZ , BYVAL bDelete AS LONG ) AS LONG
DECLARE FUNCTION UninstallColorProfileW LIB "mscms.dll" ALIAS "UninstallColorProfileW" ( BYREF pMachineName AS WSTRINGZ
 , BYREF pProfileName AS WSTRINGZ
 , BYVAL bDelete AS LONG
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO UninstallColorProfile = UninstallColorProfileW
#ELSE
 MACRO UninstallColorProfile = UninstallColorProfileA
#ENDIF
DECLARE FUNCTION EnumColorProfilesA LIB "mscms.dll" ALIAS "EnumColorProfilesA" ( BYREF pMachineName AS ASCIIZ , BYREF pEnumRecord AS ENUMTYPEA , BYVAL pBuffer AS BYTE PTR , BYREF pdwSize AS QUAD , BYREF pnProfiles AS QUAD ) AS LONG
DECLARE FUNCTION EnumColorProfilesW LIB "mscms.dll" ALIAS "EnumColorProfilesW" ( BYREF pMachineName AS WSTRINGZ
 , BYREF pEnumRecord AS ENUMTYPEW
 , BYVAL pBuffer AS BYTE PTR
 , BYREF pdwSize AS DWORD
 , BYREF pnProfiles AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO EnumColorProfiles = EnumColorProfilesW
#ELSE
 MACRO EnumColorProfiles = EnumColorProfilesA
#ENDIF
DECLARE FUNCTION SetStandardColorSpaceProfileA LIB "mscms.dll" ALIAS "SetStandardColorSpaceProfileA" ( BYREF pMachineName AS ASCIIZ , BYVAL dwProfileID AS QUAD , BYREF pProfilename AS ASCIIZ ) AS LONG
DECLARE FUNCTION SetStandardColorSpaceProfileW LIB "mscms.dll" ALIAS "SetStandardColorSpaceProfileW" ( BYREF pMachineName AS WSTRINGZ
 , BYVAL dwProfileID AS DWORD
 , BYREF pProfilename AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SetStandardColorSpaceProfile = SetStandardColorSpaceProfileW
#ELSE
 MACRO SetStandardColorSpaceProfile = SetStandardColorSpaceProfileA
#ENDIF
DECLARE FUNCTION GetStandardColorSpaceProfileA LIB "mscms.dll" ALIAS "GetStandardColorSpaceProfileA" ( BYREF pMachineName AS ASCIIZ , BYVAL dwSCS AS QUAD , BYREF pBuffer AS ASCIIZ , BYREF pcbSize AS QUAD ) AS LONG
DECLARE FUNCTION GetStandardColorSpaceProfileW LIB "mscms.dll" ALIAS "GetStandardColorSpaceProfileW" ( BYREF pMachineName AS WSTRINGZ
 , BYVAL dwSCS AS DWORD
 , BYVAL pBuffer AS DWORD
 , BYREF pcbSize AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO GetStandardColorSpaceProfile = GetStandardColorSpaceProfileW
#ELSE
 MACRO GetStandardColorSpaceProfile = GetStandardColorSpaceProfileA
#ENDIF
DECLARE FUNCTION AssociateColorProfileWithDeviceA LIB "mscms.dll" ALIAS "AssociateColorProfileWithDeviceA" ( BYREF pMachineName AS ASCIIZ , BYREF pProfileName AS ASCIIZ , BYREF pDeviceName AS ASCIIZ ) AS LONG
DECLARE FUNCTION AssociateColorProfileWithDeviceW LIB "mscms.dll" ALIAS "AssociateColorProfileWithDeviceW" ( BYREF pMachineName AS WSTRINGZ
 , BYREF pProfileName AS WSTRINGZ
 , BYREF pDeviceName AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO AssociateColorProfileWithDevice = AssociateColorProfileWithDeviceW
#ELSE
 MACRO AssociateColorProfileWithDevice = AssociateColorProfileWithDeviceA
#ENDIF
DECLARE FUNCTION DisassociateColorProfileFromDeviceA LIB "mscms.dll" ALIAS "DisassociateColorProfileFromDeviceA" ( BYREF pMachineName AS ASCIIZ , BYREF pProfileName AS ASCIIZ , BYREF pDeviceName AS ASCIIZ ) AS LONG
DECLARE FUNCTION DisassociateColorProfileFromDeviceW LIB "mscms.dll" ALIAS "DisassociateColorProfileFromDeviceW" ( BYREF pMachineName AS WSTRINGZ
 , BYREF pProfileName AS WSTRINGZ
 , BYREF pDeviceName AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO DisassociateColorProfileFromDevice = DisassociateColorProfileFromDeviceW
#ELSE
 MACRO DisassociateColorProfileFromDevice = DisassociateColorProfileFromDeviceA
#ENDIF
'//
'// The APIs SetupColorMatchingA and SetupColorMatchingW are
'// deprecated as of Windows Vista. The implementations in icmui.dll
'// now SetLastError to ERROR_NOT_SUPPORTED, and return FALSE.
'//
DECLARE FUNCTION SetupColorMatchingW LIB "icmui.dll" ALIAS "SetupColorMatchingW" ( BYREF pcms AS COLORMATCHSETUPW ) AS LONG
DECLARE FUNCTION SetupColorMatchingA LIB "icmui.dll" ALIAS "SetupColorMatchingA" ( BYREF pcms AS COLORMATCHSETUPA
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SetupColorMatching = SetupColorMatchingW
#ELSE
 MACRO SetupColorMatching = SetupColorMatchingA
#ENDIF
'#if NTDDI_VERSION >= NTDDI_VISTA
DECLARE FUNCTION WcsAssociateColorProfileWithDevice LIB "mscms.dll" ALIAS "WcsAssociateColorProfileWithDevice" ( BYVAL scope AS LONG , BYREF pProfileName AS WSTRINGZ , BYREF pDeviceName AS WSTRINGZ ) AS LONG
DECLARE FUNCTION WcsDisassociateColorProfileFromDevice LIB "mscms.dll" ALIAS "WcsDisassociateColorProfileFromDevice" ( BYVAL scope AS LONG
 , BYREF pProfileName AS WSTRINGZ
 , BYREF pDeviceName AS WSTRINGZ
 ) AS LONG
DECLARE FUNCTION WcsEnumColorProfilesSize LIB "mscms.dll" ALIAS "WcsEnumColorProfilesSize" ( BYVAL scope AS LONG
 , BYREF pEnumRecord AS ENUMTYPEW
 , BYREF pdwSize AS DWORD
 ) AS LONG
DECLARE FUNCTION WcsEnumColorProfiles LIB "mscms.dll" ALIAS "WcsEnumColorProfiles" ( BYVAL scope AS LONG
 , BYREF pEnumRecord AS ENUMTYPEW
 , BYVAL pBuffer AS DWORD
 , BYVAL dwSize AS DWORD
 , BYREF pnProfiles AS DWORD
 ) AS LONG
DECLARE FUNCTION WcsGetDefaultColorProfileSize LIB "mscms.dll" ALIAS "WcsGetDefaultColorProfileSize" ( BYVAL scope AS LONG
 , BYREF pDeviceName AS WSTRINGZ
 , BYVAL cptColorProfileType AS LONG
 , BYVAL cpstColorProfileSubType AS LONG
 , BYVAL dwProfileID AS DWORD
 , BYREF pcbProfileName AS DWORD
 ) AS LONG
DECLARE FUNCTION WcsGetDefaultColorProfile LIB "mscms.dll" ALIAS "WcsGetDefaultColorProfile" ( BYVAL scope AS LONG
 , BYREF pDeviceName AS WSTRINGZ
 , BYVAL cptColorProfileType AS LONG
 , BYVAL cpstColorProfileSubType AS LONG
 , BYVAL dwProfileID AS DWORD
 , BYVAL cbProfileName AS DWORD
 , BYREF pProfileName AS WSTRINGZ
 ) AS LONG
DECLARE FUNCTION WcsSetDefaultColorProfile LIB "mscms.dll" ALIAS "WcsSetDefaultColorProfile" ( BYVAL scope AS LONG
 , BYREF pDeviceName AS WSTRINGZ
 , BYVAL cptColorProfileType AS LONG
 , BYVAL cpstColorProfileSubType AS LONG
 , BYVAL dwProfileID AS DWORD
 , BYREF pProfileName AS WSTRINGZ
 ) AS LONG
DECLARE FUNCTION WcsSetDefaultRenderingIntent LIB "mscms.dll" ALIAS "WcsSetDefaultRenderingIntent" ( BYVAL scope AS LONG
 , BYVAL dwRenderingIntent AS DWORD
 ) AS LONG
DECLARE FUNCTION WcsGetDefaultRenderingIntent LIB "mscms.dll" ALIAS "WcsGetDefaultRenderingIntent" ( BYVAL scope AS LONG
 , BYREF pdwRenderingIntent AS DWORD
 ) AS LONG
DECLARE FUNCTION WcsGetUsePerUserProfiles LIB "mscms.dll" ALIAS "WcsGetUsePerUserProfiles" ( BYREF pDeviceName AS WSTRINGZ
 , BYVAL dwDeviceClass AS DWORD
 , BYREF pUsePerUserProfiles AS LONG
 ) AS LONG
DECLARE FUNCTION WcsSetUsePerUserProfiles LIB "mscms.dll" ALIAS "WcsSetUsePerUserProfiles" ( BYREF pDeviceName AS WSTRINGZ
 , BYVAL dwDeviceClass AS DWORD
 , BYVAL usePerUserProfiles AS LONG
 ) AS LONG
DECLARE FUNCTION WcsTranslateColors LIB "mscms.dll" ALIAS "WcsTranslateColors" ( BYVAL hColorTransform AS DWORD
 , BYVAL nColors AS DWORD
 , BYVAL nInputChannels AS DWORD
 , BYVAL cdtInput AS LONG
 , BYVAL cbInput AS DWORD
 , BYREF pInputData AS ANY
 , BYVAL nOutputChannels AS DWORD
 , BYVAL cdtOutput AS LONG
 , BYVAL cbOutput AS DWORD
 , BYREF pOutputData AS ANY
 ) AS LONG
DECLARE FUNCTION WcsCheckColors LIB "mscms.dll" ALIAS "WcsCheckColors" ( BYVAL hColorTransform AS DWORD
 , BYVAL nColors AS DWORD
 , BYVAL nInputChannels AS DWORD
 , BYVAL cdtInput AS LONG
 , BYVAL cbInput AS DWORD
 , BYREF pInputData AS ANY
 , BYREF paResult AS BYTE
 ) AS LONG
'#endif // NTDDI_VERSION >= NTDDI_VISTA
'//
'// Transform returned by CMM
'//
'typedef HANDLE HCMTRANSFORM;
'//
'// Pointer to ICC color profile data.
'//
'typedef PVOID LPDEVCHARACTER;
'//
'// CMM API definition
'//
DECLARE FUNCTION CMCheckColors LIB "icm32.dll" ALIAS "CMCheckColors" ( BYVAL hcmTransform AS QUAD , BYREF lpaInputColors AS tagCOLOR , BYVAL nColors AS QUAD , BYVAL ctInput AS LONG , BYREF lpaResult AS BYTE ) AS LONG
DECLARE FUNCTION CMCheckRGBs LIB "icm32.dll" ALIAS "CMCheckRGBs" ( BYVAL hcmTransform AS QUAD
 , BYREF lpSrcBits AS ANY
 , BYVAL bmInput AS LONG
 , BYVAL dwWidth AS DWORD
 , BYVAL dwHeight AS DWORD
 , BYVAL dwStride AS DWORD
 , BYREF lpaResult AS BYTE
 , BYVAL pfnCallback AS DWORD
 , BYVAL ulCallbackData AS DWORD
 ) AS LONG
DECLARE FUNCTION CMConvertColorNameToIndex LIB "icm32.dll" ALIAS "CMConvertColorNameToIndex" ( BYVAL hProfile AS DWORD
 , BYREF paColorName AS ANY
 , BYREF paIndex AS DWORD
 , BYVAL dwCount AS DWORD
 ) AS LONG
DECLARE FUNCTION CMConvertIndexToColorName LIB "icm32.dll" ALIAS "CMConvertIndexToColorName" ( BYVAL hProfile AS DWORD
 , BYREF paIndex AS DWORD
 , BYREF paColorName AS ANY
 , BYVAL dwCount AS DWORD
 ) AS LONG
DECLARE FUNCTION CMCreateDeviceLinkProfile LIB "icm32.dll" ALIAS "CMCreateDeviceLinkProfile" ( BYREF pahProfiles AS DWORD
 , BYVAL nProfiles AS DWORD
 , BYREF padwIntents AS DWORD
 , BYVAL nIntents AS DWORD
 , BYVAL dwFlags AS DWORD
 , BYREF lpProfileData AS DWORD
 ) AS LONG
DECLARE FUNCTION CMCreateMultiProfileTransform LIB "icm32.dll" ALIAS "CMCreateMultiProfileTransform" ( BYREF pahProfiles AS DWORD
 , BYVAL nProfiles AS DWORD
 , BYREF padwIntents AS DWORD
 , BYVAL nIntents AS DWORD
 , BYVAL dwFlags AS DWORD
 ) AS LONG
' // See CMCreateProfile below
DECLARE FUNCTION CMCreateProfileW LIB "icm32.dll" ALIAS "CMCreateProfileW" ( BYREF lpColorSpace AS LOGCOLORSPACEW , BYREF lpProfileData AS QUAD ) AS LONG
'//
'// The CMM APIs CMCreateTransform, CMCreateTransformW, and CMCreateTransformExt are
'// deprecated as of Windows Vista, and CMM implementors are no longer required to
'// implement them. The implementations in the default CMM (icm32.dll) in Windows Vista
'// now SetLastError to ERROR_NOT_SUPPORTED, and return an invalid transform handle
'// (a value < 256).
'//
DECLARE FUNCTION CMCreateTransformA LIB "icm32.dll" ALIAS "CMCreateTransform" ( BYREF lpColorSpace AS LOGCOLORSPACEA , BYREF lpDevCharacter AS ANY , BYREF lpTargetDevCharacter AS ANY ) AS QUAD ' HCMTRANSFORM
DECLARE FUNCTION CMCreateTransformW LIB "icm32.dll" ALIAS "CMCreateTransformW" ( BYREF lpColorSpace AS LOGCOLORSPACEW , BYREF lpDevCharacter AS ANY , BYREF lpTargetDevCharacter AS ANY ) AS QUAD ' HCMTRANSFORM
#IF %DEF(%UNICODE)
 MACRO CMCreateTransform = CMCreateTransformW
#ELSE
 MACRO CMCreateTransform = CMCreateTransformA
#ENDIF
' // See CMCreateTransformExtW below
DECLARE FUNCTION CMCreateTransformExtA LIB "icm32.dll" ALIAS "CMCreateTransformExt" ( BYREF lpColorSpace AS LOGCOLORSPACEA , BYREF lpDevCharacter AS ANY , BYREF lpTargetDevCharacter AS ANY , BYVAL dwFlags AS QUAD ) AS QUAD ' HCMTRANSFORM
'//
'// The CMM APIs CMCheckColorsInGamut, CMCreateProfile, CMTranslateRGB and CMTranslateRGBs are
'// deprecated as of Windows 7, and CMM implementors are no longer required to
'// implement them. The implementations in the default CMM (icm32.dll) in Windows 7
'// now SetLastError to ERROR_NOT_SUPPORTED, and return FALSE.
'//
DECLARE FUNCTION CMCheckColorsInGamut LIB "icm32.dll" ALIAS "CMCheckColorsInGamut" ( BYVAL hcmTransform AS QUAD , BYREF lpaRGBTriple AS RGBTRIPLE , BYREF lpaResult AS BYTE , BYVAL nCount AS QUAD ) AS LONG
DECLARE FUNCTION CMCreateProfileA LIB "icm32.dll" ALIAS "CMCreateProfile" ( BYREF lpColorSpace AS LOGCOLORSPACEA
 , BYREF lpProfileData AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO CMCreateProfile = CMCreateProfileW
#ELSE
 MACRO CMCreateProfile = CMCreateProfileA
#ENDIF
DECLARE FUNCTION CMTranslateRGB LIB "icm32.dll" ALIAS "CMTranslateRGB" ( BYVAL hcmTransform AS QUAD , BYVAL ColorRef AS QUAD , BYREF lpColorRef AS QUAD , BYVAL dwFlags AS QUAD ) AS LONG
DECLARE FUNCTION CMTranslateRGBs LIB "icm32.dll" ALIAS "CMTranslateRGBs" ( BYVAL hcmTransform AS QUAD
 , BYREF lpSrcBits AS ANY
 , BYVAL bmInput AS LONG
 , BYVAL dwWidth AS DWORD
 , BYVAL dwHeight AS DWORD
 , BYVAL dwStride AS DWORD
 , BYREF lpDestBits AS ANY
 , BYVAL bmOutput AS LONG
 , BYVAL dwTranslateDirection AS DWORD
 ) AS LONG
DECLARE FUNCTION CMCreateTransformExtW LIB "icm32.dll" ALIAS "CMCreateTransformExtW" ( BYREF lpColorSpace AS LOGCOLORSPACEW
 , BYREF lpDevCharacter AS ANY
 , BYREF lpTargetDevCharacter AS ANY
 , BYVAL dwFlags AS DWORD
 ) AS DWORD ' HCMTRANSFORM
#IF %DEF(%UNICODE)
 MACRO CMCreateTransformExt = CMCreateTransformExtW
#ELSE
 MACRO CMCreateTransformExt = CMCreateTransformExtA
#ENDIF
DECLARE FUNCTION CMDeleteTransform LIB "icm32.dll" ALIAS "CMDeleteTransform" ( BYVAL hcmTransform AS QUAD ) AS LONG
DECLARE FUNCTION CMGetInfo LIB "icm32.dll" ALIAS "CMGetInfo" ( BYVAL dwInfo AS QUAD
 ) AS LONG
DECLARE FUNCTION CMGetNamedProfileInfo LIB "icm32.dll" ALIAS "CMGetNamedProfileInfo" ( BYVAL hProfile AS DWORD
 , BYREF pNamedProfileInfo AS NAMED_PROFILE_INFO
 ) AS LONG
' This function is optional for all CMMs.
DECLARE FUNCTION CMGetPS2ColorRenderingDictionary LIB "icm32.dll" ALIAS "CMGetPS2ColorRenderingDictionary" ( BYVAL hProfile AS QUAD , BYVAL dwIntent AS QUAD , BYVAL lpBuffer AS BYTE PTR , BYREF lpcbSize AS QUAD , BYREF lpbBinary AS LONG ) AS LONG
' This function is optional for all CMMs.
DECLARE FUNCTION CMGetPS2ColorRenderingIntent LIB "icm32.dll" ALIAS "CMGetPS2ColorRenderingIntent" ( BYVAL hProfile AS QUAD , BYVAL dwIntent AS QUAD , BYVAL lpBuffer AS BYTE PTR , BYREF lpcbSize AS QUAD ) AS LONG
' This function is optional for all CMMs.
DECLARE FUNCTION CMGetPS2ColorSpaceArray LIB "icm32.dll" ALIAS "CMGetPS2ColorSpaceArray" ( BYVAL hProfile AS QUAD , BYVAL dwIntent AS QUAD , BYVAL dwCSAType AS QUAD , BYVAL lpBuffer AS BYTE PTR , BYREF lpcbSize AS QUAD , BYREF lpbBinary AS LONG ) AS LONG
DECLARE FUNCTION CMIsProfileValid LIB "icm32.dll" ALIAS "CMIsProfileValid" ( BYVAL hProfile AS QUAD
 , BYREF lpbValid AS LONG
 ) AS LONG
DECLARE FUNCTION CMTranslateColors LIB "icm32.dll" ALIAS "CMTranslateColors" ( BYVAL hcmTransform AS DWORD
 , BYREF lpaInputColors AS tagCOLOR
 , BYVAL nColors AS DWORD
 , BYVAL ctInput AS LONG
 , BYREF lpaOutputColors AS tagCOLOR
 , BYVAL ctOutput AS LONG
 ) AS LONG
DECLARE FUNCTION CMTranslateRGBsExt LIB "icm32.dll" ALIAS "CMTranslateRGBsExt" ( BYVAL hcmTransform AS DWORD
 , BYREF lpSrcBits AS ANY
 , BYVAL bmInput AS LONG
 , BYVAL dwWidth AS DWORD
 , BYVAL dwHeight AS DWORD
 , BYVAL dwInputStride AS DWORD
 , BYREF lpDestBits AS ANY
 , BYVAL bmOutput AS LONG
 , BYVAL dwOutputStride AS DWORD
 , BYVAL lpfnCallback AS DWORD
 , BYVAL ulCallbackData AS DWORD
 ) AS LONG
'#if NTDDI_VERSION >= NTDDI_VISTA
'//
'// Windows Color System APIs
'//
'//
'// Passed in as a bit-flag for dwFlags, this instructs WcsOpenColorProfile
'// to ignore any embedded Wcs information in the WcsProfiles tag if the input
'// profile is an ICC one.
'//
%EQUATE `DONT_USE_EMBEDDED_WCS_PROFILES = &H00000001
DECLARE FUNCTION WcsOpenColorProfileA LIB "mscms.dll" ALIAS "WcsOpenColorProfileA" ( BYREF pCDMPProfile AS tagPROFILE , BYREF pCAMPProfile AS tagPROFILE , BYREF pGMMPProfile AS tagPROFILE , BYVAL dwDesireAccess AS QUAD , BYVAL dwShareMode AS QUAD , BYVAL dwCreationMode AS QUAD , BYVAL dwFlags AS QUAD ) AS QUAD ' HPROFILE
DECLARE FUNCTION WcsOpenColorProfileW LIB "mscms.dll" ALIAS "WcsOpenColorProfileW" ( BYREF pCDMPProfile AS tagPROFILE , BYREF pCAMPProfile AS tagPROFILE , BYREF pGMMPProfile AS tagPROFILE , BYVAL dwDesireAccess AS QUAD , BYVAL dwShareMode AS QUAD , BYVAL dwCreationMode AS QUAD , BYVAL dwFlags AS QUAD ) AS QUAD ' HPROFILE
#IF %DEF(%UNICODE)
 MACRO WcsOpenColorProfile = WcsOpenColorProfileW
#ELSE
 MACRO WcsOpenColorProfile = WcsOpenColorProfileA
#ENDIF
'//
'// Flags for WcsCreateIccProfile.
'//
'// By default, the original WCS profiles used for the conversion are embedded
'// in the output ICC profile in a WcsProfilesTag, resulting in an ICC profile
'// which is compatible with ICC software, yet still has the original WCS
'// profile data available to code which is designed to parse it.
'//
'// This flag is set to produce an ICC profile without any of the original
'// WCS profile data embedded. The WcsProfilesTag will not be present in the
'// output profile. This will result in a smaller output profile, however the
'// original WCS profile data will not be available to code that would be able
'// to parse it instead of the ICC data.
'//
'//
'// These flags should be ORed in with one of the four ICC INTENT_ flags
'// Thus, they must use different bits from the INTENT_ flags. Currrently, the INTENT_ flags
'// use the values 0-3, or the low order two bits. Hence we use the third lowest bit.
'//
%EQUATE `WCS_DEFAULT = &H00000000
%EQUATE `WCS_ICCONLY = &H00010000
DECLARE FUNCTION WcsCreateIccProfile LIB "mscms.dll" ALIAS "WcsCreateIccProfile" ( BYVAL hWcsProfile AS QUAD , BYVAL dwOptions AS QUAD ) AS QUAD ' HPROFILE
'//
'// ICC TAGTYPE for the embedded Wcs information.
'//
$WCS_EMBEDDED_TAG_SIGNATURE = "MS00"
$WCS_EMBEDDED_TAG_TYPE_SIGNATURE = "MS10"
'#endif // NTDDI_VERSION >= NTDDI_VISTA
'#if NTDDI_VERSION >= NTDDI_WIN7
DECLARE FUNCTION WcsGetCalibrationManagementState LIB "mscms.dll" ALIAS "WcsGetCalibrationManagementState" ( BYREF pbIsEnabled AS LONG ) AS LONG
DECLARE FUNCTION WcsSetCalibrationManagementState LIB "mscms.dll" ALIAS "WcsSetCalibrationManagementState" ( BYVAL bIsEnabled AS LONG
 ) AS LONG
'#endif // NTDDI_VERSION >= NTDDI_WIN7
#ENDIF
