1 //---------------------------------------------------------------------------------
2 //
3 //  Little Color Management System
4 //  Copyright (c) 1998-2017 Marti Maria Saguer
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining
7 // a copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the Software
11 // is furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
18 // THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24 //---------------------------------------------------------------------------------
25 //
26 // Version 2.9rc3
27 //
28 
29 #ifndef _lcms2_H
30 
31 // ********** Configuration toggles ****************************************
32 
33 // Uncomment this one if you are using big endian machines
34 // #define CMS_USE_BIG_ENDIAN   1
35 
36 // Uncomment this one if your compiler/machine does NOT support the
37 // "long long" type.
38 // #define CMS_DONT_USE_INT64        1
39 
40 // Uncomment this if your compiler doesn't work with fast floor function
41 // #define CMS_DONT_USE_FAST_FLOOR 1
42 
43 // Uncomment this line if you want lcms to use the black point tag in profile,
44 // if commented, lcms will compute the black point by its own.
45 // It is safer to leave it commented out
46 // #define CMS_USE_PROFILE_BLACK_POINT_TAG    1
47 
48 // Uncomment this line if you are compiling as C++ and want a C++ API
49 // #define CMS_USE_CPP_API
50 
51 // Uncomment this line if you need strict CGATS syntax. Makes CGATS files to
52 // require "KEYWORD" on undefined identifiers, keep it commented out unless needed
53 // #define CMS_STRICT_CGATS  1
54 
55 // Uncomment to get rid of the tables for "half" float support
56 // #define CMS_NO_HALF_SUPPORT 1
57 
58 // Uncomment to get rid of pthreads/windows dependency
59 // #define CMS_NO_PTHREADS  1
60 
61 // Uncomment this for special windows mutex initialization (see lcms2_internal.h)
62 // #define CMS_RELY_ON_WINDOWS_STATIC_MUTEX_INIT
63 
64 // ********** End of configuration toggles ******************************
65 
66 // Needed for streams
67 #include <stdio.h>
68 
69 // Needed for portability (C99 per 7.1.2)
70 #include <limits.h>
71 #include <time.h>
72 #include <stddef.h>
73 
74 #ifndef CMS_USE_CPP_API
75 #   ifdef __cplusplus
76 extern "C" {
77 #   endif
78 #endif
79 
80 // Version/release
81 #define LCMS_VERSION        2090
82 
83 // I will give the chance of redefining basic types for compilers that are not fully C99 compliant
84 #ifndef CMS_BASIC_TYPES_ALREADY_DEFINED
85 
86 // Base types
87 typedef unsigned char        cmsUInt8Number;   // That is guaranteed by the C99 spec
88 typedef signed char          cmsInt8Number;    // That is guaranteed by the C99 spec
89 
90 #if CHAR_BIT != 8
91 #  error "Unable to find 8 bit type, unsupported compiler"
92 #endif
93 
94 // IEEE float storage numbers
95 typedef float                cmsFloat32Number;
96 typedef double               cmsFloat64Number;
97 
98 // 16-bit base types
99 #if (USHRT_MAX == 65535U)
100  typedef unsigned short      cmsUInt16Number;
101 #elif (UINT_MAX == 65535U)
102  typedef unsigned int        cmsUInt16Number;
103 #else
104 #  error "Unable to find 16 bits unsigned type, unsupported compiler"
105 #endif
106 
107 #if (SHRT_MAX == 32767)
108   typedef  short             cmsInt16Number;
109 #elif (INT_MAX == 32767)
110   typedef  int               cmsInt16Number;
111 #else
112 #  error "Unable to find 16 bits signed type, unsupported compiler"
113 #endif
114 
115 // 32-bit base type
116 #if (UINT_MAX == 4294967295U)
117  typedef unsigned int        cmsUInt32Number;
118 #elif (ULONG_MAX == 4294967295U)
119  typedef unsigned long       cmsUInt32Number;
120 #else
121 #  error "Unable to find 32 bit unsigned type, unsupported compiler"
122 #endif
123 
124 #if (INT_MAX == +2147483647)
125  typedef  int                cmsInt32Number;
126 #elif (LONG_MAX == +2147483647)
127  typedef  long               cmsInt32Number;
128 #else
129 #  error "Unable to find 32 bit signed type, unsupported compiler"
130 #endif
131 
132 // 64-bit base types
133 #ifndef CMS_DONT_USE_INT64
134 #  if (ULONG_MAX  == 18446744073709551615U)
135     typedef unsigned long   cmsUInt64Number;
136 #  elif (ULLONG_MAX == 18446744073709551615U)
137       typedef unsigned long long   cmsUInt64Number;
138 #  else
139 #     define CMS_DONT_USE_INT64 1
140 #  endif
141 #  if (LONG_MAX == +9223372036854775807)
142       typedef  long          cmsInt64Number;
143 #  elif (LLONG_MAX == +9223372036854775807)
144       typedef  long long     cmsInt64Number;
145 #  else
146 #     define CMS_DONT_USE_INT64 1
147 #  endif
148 #endif
149 #endif
150 
151 // In the case 64 bit numbers are not supported by the compiler
152 #ifdef CMS_DONT_USE_INT64
153     typedef cmsUInt32Number      cmsUInt64Number[2];
154     typedef cmsInt32Number       cmsInt64Number[2];
155 #endif
156 
157 // Derivative types
158 typedef cmsUInt32Number      cmsSignature;
159 typedef cmsUInt16Number      cmsU8Fixed8Number;
160 typedef cmsInt32Number       cmsS15Fixed16Number;
161 typedef cmsUInt32Number      cmsU16Fixed16Number;
162 
163 // Boolean type, which will be using the native integer
164 typedef int                  cmsBool;
165 
166 // Try to detect windows
167 #if defined (_WIN32) || defined(_WIN64) || defined(WIN32) || defined(_WIN32_)
168 #  define CMS_IS_WINDOWS_ 1
169 #endif
170 
171 #ifdef _MSC_VER
172 #  define CMS_IS_WINDOWS_ 1
173 #endif
174 
175 #ifdef __BORLANDC__
176 #  define CMS_IS_WINDOWS_ 1
177 #endif
178 
179 // Try to detect big endian platforms. This list can be endless, so primarily rely on the configure script
180 // on Unix-like systems, and allow it to be set on the compiler command line using
181 // -DCMS_USE_BIG_ENDIAN or something similar
182 #ifdef CMS_USE_BIG_ENDIAN // set at compiler command line takes overall precedence
183 
184 #  if CMS_USE_BIG_ENDIAN == 0
185 #    undef CMS_USE_BIG_ENDIAN
186 #  endif
187 
188 #else // CMS_USE_BIG_ENDIAN
189 
190 #  ifdef WORDS_BIGENDIAN // set by configure (or explicitly on compiler command line)
191 #    define CMS_USE_BIG_ENDIAN 1
192 #  else // WORDS_BIGENDIAN
193 // Fall back to platform/compiler specific tests
194 #    if defined(__sgi__) || defined(__sgi) || defined(sparc)
195 #      define CMS_USE_BIG_ENDIAN      1
196 #    endif
197 
198 #    if defined(__s390__) || defined(__s390x__)
199 #      define CMS_USE_BIG_ENDIAN   1
200 #    endif
201 
202 #    ifdef macintosh
203 #      ifdef __BIG_ENDIAN__
204 #        define CMS_USE_BIG_ENDIAN      1
205 #      endif
206 #      ifdef __LITTLE_ENDIAN__
207 #        undef CMS_USE_BIG_ENDIAN
208 #      endif
209 #    endif
210 #  endif  // WORDS_BIGENDIAN
211 
212 #  if defined(_HOST_BIG_ENDIAN) || defined(__BIG_ENDIAN__)
213 #    define CMS_USE_BIG_ENDIAN      1
214 #  endif
215 
216 #endif  // CMS_USE_BIG_ENDIAN
217 
218 
219 // Calling convention -- this is hardly platform and compiler dependent
220 #ifdef CMS_IS_WINDOWS_
221 #  if defined(CMS_DLL) || defined(CMS_DLL_BUILD)
222 #     ifdef __BORLANDC__
223 #        define CMSEXPORT       __stdcall _export
224 #        define CMSAPI
225 #     else
226 #        define CMSEXPORT      __stdcall
227 #        ifdef CMS_DLL_BUILD
228 #            define CMSAPI    __declspec(dllexport)
229 #        else
230 #           define CMSAPI     __declspec(dllimport)
231 #        endif
232 #     endif
233 #  else
234 #     define CMSEXPORT
235 #     define CMSAPI
236 #  endif
237 #else  // not Windows
238 #  ifdef HAVE_FUNC_ATTRIBUTE_VISIBILITY
239 #     define CMSEXPORT
240 #     define CMSAPI    __attribute__((visibility("default")))
241 #  else
242 #     define CMSEXPORT
243 #     define CMSAPI
244 #  endif
245 #endif  // CMS_IS_WINDOWS_
246 
247 #ifdef HasTHREADS
248 # if HasTHREADS == 1
249 #    undef CMS_NO_PTHREADS
250 # else
251 #    define CMS_NO_PTHREADS 1
252 # endif
253 #endif
254 
255 // Some common definitions
256 #define cmsMAX_PATH     256
257 
258 #ifndef FALSE
259 #       define FALSE 0
260 #endif
261 #ifndef TRUE
262 #       define TRUE  1
263 #endif
264 
265 // D50 XYZ normalized to Y=1.0
266 #define cmsD50X  0.9642
267 #define cmsD50Y  1.0
268 #define cmsD50Z  0.8249
269 
270 // V4 perceptual black
271 #define cmsPERCEPTUAL_BLACK_X  0.00336
272 #define cmsPERCEPTUAL_BLACK_Y  0.0034731
273 #define cmsPERCEPTUAL_BLACK_Z  0.00287
274 
275 // Definitions in ICC spec
276 #define cmsMagicNumber  0x61637370     // 'acsp'
277 #define lcmsSignature   0x6c636d73     // 'lcms'
278 
279 
280 // Base ICC type definitions
281 typedef enum {
282     cmsSigChromaticityType                  = 0x6368726D,  // 'chrm'
283     cmsSigColorantOrderType                 = 0x636C726F,  // 'clro'
284     cmsSigColorantTableType                 = 0x636C7274,  // 'clrt'
285     cmsSigCrdInfoType                       = 0x63726469,  // 'crdi'
286     cmsSigCurveType                         = 0x63757276,  // 'curv'
287     cmsSigDataType                          = 0x64617461,  // 'data'
288     cmsSigDictType                          = 0x64696374,  // 'dict'
289     cmsSigDateTimeType                      = 0x6474696D,  // 'dtim'
290     cmsSigDeviceSettingsType                = 0x64657673,  // 'devs'
291     cmsSigLut16Type                         = 0x6d667432,  // 'mft2'
292     cmsSigLut8Type                          = 0x6d667431,  // 'mft1'
293     cmsSigLutAtoBType                       = 0x6d414220,  // 'mAB '
294     cmsSigLutBtoAType                       = 0x6d424120,  // 'mBA '
295     cmsSigMeasurementType                   = 0x6D656173,  // 'meas'
296     cmsSigMultiLocalizedUnicodeType         = 0x6D6C7563,  // 'mluc'
297     cmsSigMultiProcessElementType           = 0x6D706574,  // 'mpet'
298     cmsSigNamedColorType                    = 0x6E636f6C,  // 'ncol' -- DEPRECATED!
299     cmsSigNamedColor2Type                   = 0x6E636C32,  // 'ncl2'
300     cmsSigParametricCurveType               = 0x70617261,  // 'para'
301     cmsSigProfileSequenceDescType           = 0x70736571,  // 'pseq'
302     cmsSigProfileSequenceIdType             = 0x70736964,  // 'psid'
303     cmsSigResponseCurveSet16Type            = 0x72637332,  // 'rcs2'
304     cmsSigS15Fixed16ArrayType               = 0x73663332,  // 'sf32'
305     cmsSigScreeningType                     = 0x7363726E,  // 'scrn'
306     cmsSigSignatureType                     = 0x73696720,  // 'sig '
307     cmsSigTextType                          = 0x74657874,  // 'text'
308     cmsSigTextDescriptionType               = 0x64657363,  // 'desc'
309     cmsSigU16Fixed16ArrayType               = 0x75663332,  // 'uf32'
310     cmsSigUcrBgType                         = 0x62666420,  // 'bfd '
311     cmsSigUInt16ArrayType                   = 0x75693136,  // 'ui16'
312     cmsSigUInt32ArrayType                   = 0x75693332,  // 'ui32'
313     cmsSigUInt64ArrayType                   = 0x75693634,  // 'ui64'
314     cmsSigUInt8ArrayType                    = 0x75693038,  // 'ui08'
315     cmsSigVcgtType                          = 0x76636774,  // 'vcgt'
316     cmsSigViewingConditionsType             = 0x76696577,  // 'view'
317     cmsSigXYZType                           = 0x58595A20   // 'XYZ '
318 
319 
320 } cmsTagTypeSignature;
321 
322 // Base ICC tag definitions
323 typedef enum {
324     cmsSigAToB0Tag                          = 0x41324230,  // 'A2B0'
325     cmsSigAToB1Tag                          = 0x41324231,  // 'A2B1'
326     cmsSigAToB2Tag                          = 0x41324232,  // 'A2B2'
327     cmsSigBlueColorantTag                   = 0x6258595A,  // 'bXYZ'
328     cmsSigBlueMatrixColumnTag               = 0x6258595A,  // 'bXYZ'
329     cmsSigBlueTRCTag                        = 0x62545243,  // 'bTRC'
330     cmsSigBToA0Tag                          = 0x42324130,  // 'B2A0'
331     cmsSigBToA1Tag                          = 0x42324131,  // 'B2A1'
332     cmsSigBToA2Tag                          = 0x42324132,  // 'B2A2'
333     cmsSigCalibrationDateTimeTag            = 0x63616C74,  // 'calt'
334     cmsSigCharTargetTag                     = 0x74617267,  // 'targ'
335     cmsSigChromaticAdaptationTag            = 0x63686164,  // 'chad'
336     cmsSigChromaticityTag                   = 0x6368726D,  // 'chrm'
337     cmsSigColorantOrderTag                  = 0x636C726F,  // 'clro'
338     cmsSigColorantTableTag                  = 0x636C7274,  // 'clrt'
339     cmsSigColorantTableOutTag               = 0x636C6F74,  // 'clot'
340     cmsSigColorimetricIntentImageStateTag   = 0x63696973,  // 'ciis'
341     cmsSigCopyrightTag                      = 0x63707274,  // 'cprt'
342     cmsSigCrdInfoTag                        = 0x63726469,  // 'crdi'
343     cmsSigDataTag                           = 0x64617461,  // 'data'
344     cmsSigDateTimeTag                       = 0x6474696D,  // 'dtim'
345     cmsSigDeviceMfgDescTag                  = 0x646D6E64,  // 'dmnd'
346     cmsSigDeviceModelDescTag                = 0x646D6464,  // 'dmdd'
347     cmsSigDeviceSettingsTag                 = 0x64657673,  // 'devs'
348     cmsSigDToB0Tag                          = 0x44324230,  // 'D2B0'
349     cmsSigDToB1Tag                          = 0x44324231,  // 'D2B1'
350     cmsSigDToB2Tag                          = 0x44324232,  // 'D2B2'
351     cmsSigDToB3Tag                          = 0x44324233,  // 'D2B3'
352     cmsSigBToD0Tag                          = 0x42324430,  // 'B2D0'
353     cmsSigBToD1Tag                          = 0x42324431,  // 'B2D1'
354     cmsSigBToD2Tag                          = 0x42324432,  // 'B2D2'
355     cmsSigBToD3Tag                          = 0x42324433,  // 'B2D3'
356     cmsSigGamutTag                          = 0x67616D74,  // 'gamt'
357     cmsSigGrayTRCTag                        = 0x6b545243,  // 'kTRC'
358     cmsSigGreenColorantTag                  = 0x6758595A,  // 'gXYZ'
359     cmsSigGreenMatrixColumnTag              = 0x6758595A,  // 'gXYZ'
360     cmsSigGreenTRCTag                       = 0x67545243,  // 'gTRC'
361     cmsSigLuminanceTag                      = 0x6C756d69,  // 'lumi'
362     cmsSigMeasurementTag                    = 0x6D656173,  // 'meas'
363     cmsSigMediaBlackPointTag                = 0x626B7074,  // 'bkpt'
364     cmsSigMediaWhitePointTag                = 0x77747074,  // 'wtpt'
365     cmsSigNamedColorTag                     = 0x6E636f6C,  // 'ncol' // Deprecated by the ICC
366     cmsSigNamedColor2Tag                    = 0x6E636C32,  // 'ncl2'
367     cmsSigOutputResponseTag                 = 0x72657370,  // 'resp'
368     cmsSigPerceptualRenderingIntentGamutTag = 0x72696730,  // 'rig0'
369     cmsSigPreview0Tag                       = 0x70726530,  // 'pre0'
370     cmsSigPreview1Tag                       = 0x70726531,  // 'pre1'
371     cmsSigPreview2Tag                       = 0x70726532,  // 'pre2'
372     cmsSigProfileDescriptionTag             = 0x64657363,  // 'desc'
373     cmsSigProfileDescriptionMLTag           = 0x6473636d,  // 'dscm'
374     cmsSigProfileSequenceDescTag            = 0x70736571,  // 'pseq'
375     cmsSigProfileSequenceIdTag              = 0x70736964,  // 'psid'
376     cmsSigPs2CRD0Tag                        = 0x70736430,  // 'psd0'
377     cmsSigPs2CRD1Tag                        = 0x70736431,  // 'psd1'
378     cmsSigPs2CRD2Tag                        = 0x70736432,  // 'psd2'
379     cmsSigPs2CRD3Tag                        = 0x70736433,  // 'psd3'
380     cmsSigPs2CSATag                         = 0x70733273,  // 'ps2s'
381     cmsSigPs2RenderingIntentTag             = 0x70733269,  // 'ps2i'
382     cmsSigRedColorantTag                    = 0x7258595A,  // 'rXYZ'
383     cmsSigRedMatrixColumnTag                = 0x7258595A,  // 'rXYZ'
384     cmsSigRedTRCTag                         = 0x72545243,  // 'rTRC'
385     cmsSigSaturationRenderingIntentGamutTag = 0x72696732,  // 'rig2'
386     cmsSigScreeningDescTag                  = 0x73637264,  // 'scrd'
387     cmsSigScreeningTag                      = 0x7363726E,  // 'scrn'
388     cmsSigTechnologyTag                     = 0x74656368,  // 'tech'
389     cmsSigUcrBgTag                          = 0x62666420,  // 'bfd '
390     cmsSigViewingCondDescTag                = 0x76756564,  // 'vued'
391     cmsSigViewingConditionsTag              = 0x76696577,  // 'view'
392     cmsSigVcgtTag                           = 0x76636774,  // 'vcgt'
393     cmsSigMetaTag                           = 0x6D657461,  // 'meta'
394     cmsSigArgyllArtsTag                     = 0x61727473   // 'arts'
395 
396 } cmsTagSignature;
397 
398 
399 // ICC Technology tag
400 typedef enum {
401     cmsSigDigitalCamera                     = 0x6463616D,  // 'dcam'
402     cmsSigFilmScanner                       = 0x6673636E,  // 'fscn'
403     cmsSigReflectiveScanner                 = 0x7273636E,  // 'rscn'
404     cmsSigInkJetPrinter                     = 0x696A6574,  // 'ijet'
405     cmsSigThermalWaxPrinter                 = 0x74776178,  // 'twax'
406     cmsSigElectrophotographicPrinter        = 0x6570686F,  // 'epho'
407     cmsSigElectrostaticPrinter              = 0x65737461,  // 'esta'
408     cmsSigDyeSublimationPrinter             = 0x64737562,  // 'dsub'
409     cmsSigPhotographicPaperPrinter          = 0x7270686F,  // 'rpho'
410     cmsSigFilmWriter                        = 0x6670726E,  // 'fprn'
411     cmsSigVideoMonitor                      = 0x7669646D,  // 'vidm'
412     cmsSigVideoCamera                       = 0x76696463,  // 'vidc'
413     cmsSigProjectionTelevision              = 0x706A7476,  // 'pjtv'
414     cmsSigCRTDisplay                        = 0x43525420,  // 'CRT '
415     cmsSigPMDisplay                         = 0x504D4420,  // 'PMD '
416     cmsSigAMDisplay                         = 0x414D4420,  // 'AMD '
417     cmsSigPhotoCD                           = 0x4B504344,  // 'KPCD'
418     cmsSigPhotoImageSetter                  = 0x696D6773,  // 'imgs'
419     cmsSigGravure                           = 0x67726176,  // 'grav'
420     cmsSigOffsetLithography                 = 0x6F666673,  // 'offs'
421     cmsSigSilkscreen                        = 0x73696C6B,  // 'silk'
422     cmsSigFlexography                       = 0x666C6578,  // 'flex'
423     cmsSigMotionPictureFilmScanner          = 0x6D706673,  // 'mpfs'
424     cmsSigMotionPictureFilmRecorder         = 0x6D706672,  // 'mpfr'
425     cmsSigDigitalMotionPictureCamera        = 0x646D7063,  // 'dmpc'
426     cmsSigDigitalCinemaProjector            = 0x64636A70   // 'dcpj'
427 
428 } cmsTechnologySignature;
429 
430 
431 // ICC Color spaces
432 typedef enum {
433     cmsSigXYZData                           = 0x58595A20,  // 'XYZ '
434     cmsSigLabData                           = 0x4C616220,  // 'Lab '
435     cmsSigLuvData                           = 0x4C757620,  // 'Luv '
436     cmsSigYCbCrData                         = 0x59436272,  // 'YCbr'
437     cmsSigYxyData                           = 0x59787920,  // 'Yxy '
438     cmsSigRgbData                           = 0x52474220,  // 'RGB '
439     cmsSigGrayData                          = 0x47524159,  // 'GRAY'
440     cmsSigHsvData                           = 0x48535620,  // 'HSV '
441     cmsSigHlsData                           = 0x484C5320,  // 'HLS '
442     cmsSigCmykData                          = 0x434D594B,  // 'CMYK'
443     cmsSigCmyData                           = 0x434D5920,  // 'CMY '
444     cmsSigMCH1Data                          = 0x4D434831,  // 'MCH1'
445     cmsSigMCH2Data                          = 0x4D434832,  // 'MCH2'
446     cmsSigMCH3Data                          = 0x4D434833,  // 'MCH3'
447     cmsSigMCH4Data                          = 0x4D434834,  // 'MCH4'
448     cmsSigMCH5Data                          = 0x4D434835,  // 'MCH5'
449     cmsSigMCH6Data                          = 0x4D434836,  // 'MCH6'
450     cmsSigMCH7Data                          = 0x4D434837,  // 'MCH7'
451     cmsSigMCH8Data                          = 0x4D434838,  // 'MCH8'
452     cmsSigMCH9Data                          = 0x4D434839,  // 'MCH9'
453     cmsSigMCHAData                          = 0x4D434841,  // 'MCHA'
454     cmsSigMCHBData                          = 0x4D434842,  // 'MCHB'
455     cmsSigMCHCData                          = 0x4D434843,  // 'MCHC'
456     cmsSigMCHDData                          = 0x4D434844,  // 'MCHD'
457     cmsSigMCHEData                          = 0x4D434845,  // 'MCHE'
458     cmsSigMCHFData                          = 0x4D434846,  // 'MCHF'
459     cmsSigNamedData                         = 0x6e6d636c,  // 'nmcl'
460     cmsSig1colorData                        = 0x31434C52,  // '1CLR'
461     cmsSig2colorData                        = 0x32434C52,  // '2CLR'
462     cmsSig3colorData                        = 0x33434C52,  // '3CLR'
463     cmsSig4colorData                        = 0x34434C52,  // '4CLR'
464     cmsSig5colorData                        = 0x35434C52,  // '5CLR'
465     cmsSig6colorData                        = 0x36434C52,  // '6CLR'
466     cmsSig7colorData                        = 0x37434C52,  // '7CLR'
467     cmsSig8colorData                        = 0x38434C52,  // '8CLR'
468     cmsSig9colorData                        = 0x39434C52,  // '9CLR'
469     cmsSig10colorData                       = 0x41434C52,  // 'ACLR'
470     cmsSig11colorData                       = 0x42434C52,  // 'BCLR'
471     cmsSig12colorData                       = 0x43434C52,  // 'CCLR'
472     cmsSig13colorData                       = 0x44434C52,  // 'DCLR'
473     cmsSig14colorData                       = 0x45434C52,  // 'ECLR'
474     cmsSig15colorData                       = 0x46434C52,  // 'FCLR'
475     cmsSigLuvKData                          = 0x4C75764B   // 'LuvK'
476 
477 } cmsColorSpaceSignature;
478 
479 // ICC Profile Class
480 typedef enum {
481     cmsSigInputClass                        = 0x73636E72,  // 'scnr'
482     cmsSigDisplayClass                      = 0x6D6E7472,  // 'mntr'
483     cmsSigOutputClass                       = 0x70727472,  // 'prtr'
484     cmsSigLinkClass                         = 0x6C696E6B,  // 'link'
485     cmsSigAbstractClass                     = 0x61627374,  // 'abst'
486     cmsSigColorSpaceClass                   = 0x73706163,  // 'spac'
487     cmsSigNamedColorClass                   = 0x6e6d636c   // 'nmcl'
488 
489 } cmsProfileClassSignature;
490 
491 // ICC Platforms
492 typedef enum {
493     cmsSigMacintosh                         = 0x4150504C,  // 'APPL'
494     cmsSigMicrosoft                         = 0x4D534654,  // 'MSFT'
495     cmsSigSolaris                           = 0x53554E57,  // 'SUNW'
496     cmsSigSGI                               = 0x53474920,  // 'SGI '
497     cmsSigTaligent                          = 0x54474E54,  // 'TGNT'
498     cmsSigUnices                            = 0x2A6E6978   // '*nix'   // From argyll -- Not official
499 
500 } cmsPlatformSignature;
501 
502 // Reference gamut
503 #define  cmsSigPerceptualReferenceMediumGamut         0x70726d67  //'prmg'
504 
505 // For cmsSigColorimetricIntentImageStateTag
506 #define  cmsSigSceneColorimetryEstimates              0x73636F65  //'scoe'
507 #define  cmsSigSceneAppearanceEstimates               0x73617065  //'sape'
508 #define  cmsSigFocalPlaneColorimetryEstimates         0x66706365  //'fpce'
509 #define  cmsSigReflectionHardcopyOriginalColorimetry  0x72686F63  //'rhoc'
510 #define  cmsSigReflectionPrintOutputColorimetry       0x72706F63  //'rpoc'
511 
512 // Multi process elements types
513 typedef enum {
514     cmsSigCurveSetElemType              = 0x63767374,  //'cvst'
515     cmsSigMatrixElemType                = 0x6D617466,  //'matf'
516     cmsSigCLutElemType                  = 0x636C7574,  //'clut'
517 
518     cmsSigBAcsElemType                  = 0x62414353,  // 'bACS'
519     cmsSigEAcsElemType                  = 0x65414353,  // 'eACS'
520 
521     // Custom from here, not in the ICC Spec
522     cmsSigXYZ2LabElemType               = 0x6C327820,  // 'l2x '
523     cmsSigLab2XYZElemType               = 0x78326C20,  // 'x2l '
524     cmsSigNamedColorElemType            = 0x6E636C20,  // 'ncl '
525     cmsSigLabV2toV4                     = 0x32203420,  // '2 4 '
526     cmsSigLabV4toV2                     = 0x34203220,  // '4 2 '
527 
528     // Identities
529     cmsSigIdentityElemType              = 0x69646E20,  // 'idn '
530 
531     // Float to floatPCS
532     cmsSigLab2FloatPCS                  = 0x64326C20,  // 'd2l '
533     cmsSigFloatPCS2Lab                  = 0x6C326420,  // 'l2d '
534     cmsSigXYZ2FloatPCS                  = 0x64327820,  // 'd2x '
535     cmsSigFloatPCS2XYZ                  = 0x78326420,  // 'x2d '
536     cmsSigClipNegativesElemType         = 0x636c7020   // 'clp '
537 
538 } cmsStageSignature;
539 
540 // Types of CurveElements
541 typedef enum {
542 
543     cmsSigFormulaCurveSeg               = 0x70617266, // 'parf'
544     cmsSigSampledCurveSeg               = 0x73616D66, // 'samf'
545     cmsSigSegmentedCurve                = 0x63757266  // 'curf'
546 
547 } cmsCurveSegSignature;
548 
549 // Used in ResponseCurveType
550 #define  cmsSigStatusA                    0x53746141 //'StaA'
551 #define  cmsSigStatusE                    0x53746145 //'StaE'
552 #define  cmsSigStatusI                    0x53746149 //'StaI'
553 #define  cmsSigStatusT                    0x53746154 //'StaT'
554 #define  cmsSigStatusM                    0x5374614D //'StaM'
555 #define  cmsSigDN                         0x444E2020 //'DN  '
556 #define  cmsSigDNP                        0x444E2050 //'DN P'
557 #define  cmsSigDNN                        0x444E4E20 //'DNN '
558 #define  cmsSigDNNP                       0x444E4E50 //'DNNP'
559 
560 // Device attributes, currently defined values correspond to the low 4 bytes
561 // of the 8 byte attribute quantity
562 #define cmsReflective     0
563 #define cmsTransparency   1
564 #define cmsGlossy         0
565 #define cmsMatte          2
566 
567 // Common structures in ICC tags
568 typedef struct {
569     cmsUInt32Number len;
570     cmsUInt32Number flag;
571     cmsUInt8Number  data[1];
572 
573 } cmsICCData;
574 
575 // ICC date time
576 typedef struct {
577     cmsUInt16Number      year;
578     cmsUInt16Number      month;
579     cmsUInt16Number      day;
580     cmsUInt16Number      hours;
581     cmsUInt16Number      minutes;
582     cmsUInt16Number      seconds;
583 
584 } cmsDateTimeNumber;
585 
586 // ICC XYZ
587 typedef struct {
588     cmsS15Fixed16Number  X;
589     cmsS15Fixed16Number  Y;
590     cmsS15Fixed16Number  Z;
591 
592 } cmsEncodedXYZNumber;
593 
594 
595 // Profile ID as computed by MD5 algorithm
596 typedef union {
597     cmsUInt8Number       ID8[16];
598     cmsUInt16Number      ID16[8];
599     cmsUInt32Number      ID32[4];
600 
601 } cmsProfileID;
602 
603 
604 // ----------------------------------------------------------------------------------------------
605 // ICC profile internal base types. Strictly, shouldn't be declared in this header, but maybe
606 // somebody want to use this info for accessing profile header directly, so here it is.
607 
608 // Profile header -- it is 32-bit aligned, so no issues are expected on alignment
609 typedef struct {
610     cmsUInt32Number              size;           // Profile size in bytes
611     cmsSignature                 cmmId;          // CMM for this profile
612     cmsUInt32Number              version;        // Format version number
613     cmsProfileClassSignature     deviceClass;    // Type of profile
614     cmsColorSpaceSignature       colorSpace;     // Color space of data
615     cmsColorSpaceSignature       pcs;            // PCS, XYZ or Lab only
616     cmsDateTimeNumber            date;           // Date profile was created
617     cmsSignature                 magic;          // Magic Number to identify an ICC profile
618     cmsPlatformSignature         platform;       // Primary Platform
619     cmsUInt32Number              flags;          // Various bit settings
620     cmsSignature                 manufacturer;   // Device manufacturer
621     cmsUInt32Number              model;          // Device model number
622     cmsUInt64Number              attributes;     // Device attributes
623     cmsUInt32Number              renderingIntent;// Rendering intent
624     cmsEncodedXYZNumber          illuminant;     // Profile illuminant
625     cmsSignature                 creator;        // Profile creator
626     cmsProfileID                 profileID;      // Profile ID using MD5
627     cmsInt8Number                reserved[28];   // Reserved for future use
628 
629 } cmsICCHeader;
630 
631 // ICC base tag
632 typedef struct {
633     cmsTagTypeSignature  sig;
634     cmsInt8Number        reserved[4];
635 
636 } cmsTagBase;
637 
638 // A tag entry in directory
639 typedef struct {
640     cmsTagSignature      sig;            // The tag signature
641     cmsUInt32Number      offset;         // Start of tag
642     cmsUInt32Number      size;           // Size in bytes
643 
644 } cmsTagEntry;
645 
646 // ----------------------------------------------------------------------------------------------
647 
648 // Little CMS specific typedefs
649 
650 typedef void* cmsHANDLE ;              // Generic handle
651 typedef void* cmsHPROFILE;             // Opaque typedefs to hide internals
652 typedef void* cmsHTRANSFORM;
653 
654 #define cmsMAXCHANNELS  16                // Maximum number of channels in ICC profiles
655 
656 // Format of pixel is defined by one cmsUInt32Number, using bit fields as follows
657 //
658 //                               2                1          0
659 //                          3 2 10987 6 5 4 3 2 1 098 7654 321
660 //                          A O TTTTT U Y F P X S EEE CCCC BBB
661 //
662 //            A: Floating point -- With this flag we can differentiate 16 bits as float and as int
663 //            O: Optimized -- previous optimization already returns the final 8-bit value
664 //            T: Pixeltype
665 //            F: Flavor  0=MinIsBlack(Chocolate) 1=MinIsWhite(Vanilla)
666 //            P: Planar? 0=Chunky, 1=Planar
667 //            X: swap 16 bps endianness?
668 //            S: Do swap? ie, BGR, KYMC
669 //            E: Extra samples
670 //            C: Channels (Samples per pixel)
671 //            B: bytes per sample
672 //            Y: Swap first - changes ABGR to BGRA and KCMY to CMYK
673 
674 #define FLOAT_SH(a)            ((a) << 22)
675 #define OPTIMIZED_SH(s)        ((s) << 21)
676 #define COLORSPACE_SH(s)       ((s) << 16)
677 #define SWAPFIRST_SH(s)        ((s) << 14)
678 #define FLAVOR_SH(s)           ((s) << 13)
679 #define PLANAR_SH(p)           ((p) << 12)
680 #define ENDIAN16_SH(e)         ((e) << 11)
681 #define DOSWAP_SH(e)           ((e) << 10)
682 #define EXTRA_SH(e)            ((e) << 7)
683 #define CHANNELS_SH(c)         ((c) << 3)
684 #define BYTES_SH(b)            (b)
685 
686 // These macros unpack format specifiers into integers
687 #define T_FLOAT(a)            (((a)>>22)&1)
688 #define T_OPTIMIZED(o)        (((o)>>21)&1)
689 #define T_COLORSPACE(s)       (((s)>>16)&31)
690 #define T_SWAPFIRST(s)        (((s)>>14)&1)
691 #define T_FLAVOR(s)           (((s)>>13)&1)
692 #define T_PLANAR(p)           (((p)>>12)&1)
693 #define T_ENDIAN16(e)         (((e)>>11)&1)
694 #define T_DOSWAP(e)           (((e)>>10)&1)
695 #define T_EXTRA(e)            (((e)>>7)&7)
696 #define T_CHANNELS(c)         (((c)>>3)&15)
697 #define T_BYTES(b)            ((b)&7)
698 
699 
700 // Pixel types
701 #define PT_ANY       0    // Don't check colorspace
702                           // 1 & 2 are reserved
703 #define PT_GRAY      3
704 #define PT_RGB       4
705 #define PT_CMY       5
706 #define PT_CMYK      6
707 #define PT_YCbCr     7
708 #define PT_YUV       8      // Lu'v'
709 #define PT_XYZ       9
710 #define PT_Lab       10
711 #define PT_YUVK      11     // Lu'v'K
712 #define PT_HSV       12
713 #define PT_HLS       13
714 #define PT_Yxy       14
715 
716 #define PT_MCH1      15
717 #define PT_MCH2      16
718 #define PT_MCH3      17
719 #define PT_MCH4      18
720 #define PT_MCH5      19
721 #define PT_MCH6      20
722 #define PT_MCH7      21
723 #define PT_MCH8      22
724 #define PT_MCH9      23
725 #define PT_MCH10     24
726 #define PT_MCH11     25
727 #define PT_MCH12     26
728 #define PT_MCH13     27
729 #define PT_MCH14     28
730 #define PT_MCH15     29
731 
732 #define PT_LabV2     30     // Identical to PT_Lab, but using the V2 old encoding
733 
734 // Some (not all!) representations
735 
736 #ifndef TYPE_RGB_8      // TYPE_RGB_8 is a very common identifier, so don't include ours
737                         // if user has it already defined.
738 
739 #define TYPE_GRAY_8            (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(1))
740 #define TYPE_GRAY_8_REV        (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(1)|FLAVOR_SH(1))
741 #define TYPE_GRAY_16           (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(2))
742 #define TYPE_GRAY_16_REV       (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(2)|FLAVOR_SH(1))
743 #define TYPE_GRAY_16_SE        (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(2)|ENDIAN16_SH(1))
744 #define TYPE_GRAYA_8           (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(1))
745 #define TYPE_GRAYA_16          (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(2))
746 #define TYPE_GRAYA_16_SE       (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(2)|ENDIAN16_SH(1))
747 #define TYPE_GRAYA_8_PLANAR    (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(1)|PLANAR_SH(1))
748 #define TYPE_GRAYA_16_PLANAR   (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(2)|PLANAR_SH(1))
749 
750 #define TYPE_RGB_8             (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(1))
751 #define TYPE_RGB_8_PLANAR      (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
752 #define TYPE_BGR_8             (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1))
753 #define TYPE_BGR_8_PLANAR      (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|PLANAR_SH(1))
754 #define TYPE_RGB_16            (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2))
755 #define TYPE_RGB_16_PLANAR     (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
756 #define TYPE_RGB_16_SE         (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
757 #define TYPE_BGR_16            (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1))
758 #define TYPE_BGR_16_PLANAR     (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|PLANAR_SH(1))
759 #define TYPE_BGR_16_SE         (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
760 
761 #define TYPE_RGBA_8            (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1))
762 #define TYPE_RGBA_8_PLANAR     (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
763 #define TYPE_RGBA_16           (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2))
764 #define TYPE_RGBA_16_PLANAR    (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
765 #define TYPE_RGBA_16_SE        (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
766 
767 #define TYPE_ARGB_8            (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|SWAPFIRST_SH(1))
768 #define TYPE_ARGB_8_PLANAR     (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|SWAPFIRST_SH(1)|PLANAR_SH(1))
769 #define TYPE_ARGB_16           (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|SWAPFIRST_SH(1))
770 
771 #define TYPE_ABGR_8            (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1))
772 #define TYPE_ABGR_8_PLANAR     (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|PLANAR_SH(1))
773 #define TYPE_ABGR_16           (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1))
774 #define TYPE_ABGR_16_PLANAR    (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|PLANAR_SH(1))
775 #define TYPE_ABGR_16_SE        (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
776 
777 #define TYPE_BGRA_8            (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1))
778 #define TYPE_BGRA_8_PLANAR     (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1)|PLANAR_SH(1))
779 #define TYPE_BGRA_16           (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|SWAPFIRST_SH(1))
780 #define TYPE_BGRA_16_SE        (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1))
781 
782 #define TYPE_CMY_8             (COLORSPACE_SH(PT_CMY)|CHANNELS_SH(3)|BYTES_SH(1))
783 #define TYPE_CMY_8_PLANAR      (COLORSPACE_SH(PT_CMY)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
784 #define TYPE_CMY_16            (COLORSPACE_SH(PT_CMY)|CHANNELS_SH(3)|BYTES_SH(2))
785 #define TYPE_CMY_16_PLANAR     (COLORSPACE_SH(PT_CMY)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
786 #define TYPE_CMY_16_SE         (COLORSPACE_SH(PT_CMY)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
787 
788 #define TYPE_CMYK_8            (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1))
789 #define TYPE_CMYKA_8           (COLORSPACE_SH(PT_CMYK)|EXTRA_SH(1)|CHANNELS_SH(4)|BYTES_SH(1))
790 #define TYPE_CMYK_8_REV        (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1)|FLAVOR_SH(1))
791 #define TYPE_YUVK_8            TYPE_CMYK_8_REV
792 #define TYPE_CMYK_8_PLANAR     (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1)|PLANAR_SH(1))
793 #define TYPE_CMYK_16           (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2))
794 #define TYPE_CMYK_16_REV       (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|FLAVOR_SH(1))
795 #define TYPE_YUVK_16           TYPE_CMYK_16_REV
796 #define TYPE_CMYK_16_PLANAR    (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|PLANAR_SH(1))
797 #define TYPE_CMYK_16_SE        (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|ENDIAN16_SH(1))
798 
799 #define TYPE_KYMC_8            (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1)|DOSWAP_SH(1))
800 #define TYPE_KYMC_16           (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|DOSWAP_SH(1))
801 #define TYPE_KYMC_16_SE        (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
802 
803 #define TYPE_KCMY_8            (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1)|SWAPFIRST_SH(1))
804 #define TYPE_KCMY_8_REV        (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1)|FLAVOR_SH(1)|SWAPFIRST_SH(1))
805 #define TYPE_KCMY_16           (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|SWAPFIRST_SH(1))
806 #define TYPE_KCMY_16_REV       (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|FLAVOR_SH(1)|SWAPFIRST_SH(1))
807 #define TYPE_KCMY_16_SE        (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|ENDIAN16_SH(1)|SWAPFIRST_SH(1))
808 
809 #define TYPE_CMYK5_8           (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(1))
810 #define TYPE_CMYK5_16          (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(2))
811 #define TYPE_CMYK5_16_SE       (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(2)|ENDIAN16_SH(1))
812 #define TYPE_KYMC5_8           (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(1)|DOSWAP_SH(1))
813 #define TYPE_KYMC5_16          (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(2)|DOSWAP_SH(1))
814 #define TYPE_KYMC5_16_SE       (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
815 #define TYPE_CMYK6_8           (COLORSPACE_SH(PT_MCH6)|CHANNELS_SH(6)|BYTES_SH(1))
816 #define TYPE_CMYK6_8_PLANAR    (COLORSPACE_SH(PT_MCH6)|CHANNELS_SH(6)|BYTES_SH(1)|PLANAR_SH(1))
817 #define TYPE_CMYK6_16          (COLORSPACE_SH(PT_MCH6)|CHANNELS_SH(6)|BYTES_SH(2))
818 #define TYPE_CMYK6_16_PLANAR   (COLORSPACE_SH(PT_MCH6)|CHANNELS_SH(6)|BYTES_SH(2)|PLANAR_SH(1))
819 #define TYPE_CMYK6_16_SE       (COLORSPACE_SH(PT_MCH6)|CHANNELS_SH(6)|BYTES_SH(2)|ENDIAN16_SH(1))
820 #define TYPE_CMYK7_8           (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(1))
821 #define TYPE_CMYK7_16          (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(2))
822 #define TYPE_CMYK7_16_SE       (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(2)|ENDIAN16_SH(1))
823 #define TYPE_KYMC7_8           (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(1)|DOSWAP_SH(1))
824 #define TYPE_KYMC7_16          (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(2)|DOSWAP_SH(1))
825 #define TYPE_KYMC7_16_SE       (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
826 #define TYPE_CMYK8_8           (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(1))
827 #define TYPE_CMYK8_16          (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(2))
828 #define TYPE_CMYK8_16_SE       (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(2)|ENDIAN16_SH(1))
829 #define TYPE_KYMC8_8           (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(1)|DOSWAP_SH(1))
830 #define TYPE_KYMC8_16          (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(2)|DOSWAP_SH(1))
831 #define TYPE_KYMC8_16_SE       (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
832 #define TYPE_CMYK9_8           (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(1))
833 #define TYPE_CMYK9_16          (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(2))
834 #define TYPE_CMYK9_16_SE       (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(2)|ENDIAN16_SH(1))
835 #define TYPE_KYMC9_8           (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(1)|DOSWAP_SH(1))
836 #define TYPE_KYMC9_16          (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(2)|DOSWAP_SH(1))
837 #define TYPE_KYMC9_16_SE       (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
838 #define TYPE_CMYK10_8          (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(1))
839 #define TYPE_CMYK10_16         (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(2))
840 #define TYPE_CMYK10_16_SE      (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(2)|ENDIAN16_SH(1))
841 #define TYPE_KYMC10_8          (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(1)|DOSWAP_SH(1))
842 #define TYPE_KYMC10_16         (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(2)|DOSWAP_SH(1))
843 #define TYPE_KYMC10_16_SE      (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
844 #define TYPE_CMYK11_8          (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(1))
845 #define TYPE_CMYK11_16         (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(2))
846 #define TYPE_CMYK11_16_SE      (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(2)|ENDIAN16_SH(1))
847 #define TYPE_KYMC11_8          (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(1)|DOSWAP_SH(1))
848 #define TYPE_KYMC11_16         (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(2)|DOSWAP_SH(1))
849 #define TYPE_KYMC11_16_SE      (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
850 #define TYPE_CMYK12_8          (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(1))
851 #define TYPE_CMYK12_16         (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(2))
852 #define TYPE_CMYK12_16_SE      (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(2)|ENDIAN16_SH(1))
853 #define TYPE_KYMC12_8          (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(1)|DOSWAP_SH(1))
854 #define TYPE_KYMC12_16         (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(2)|DOSWAP_SH(1))
855 #define TYPE_KYMC12_16_SE      (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
856 
857 // Colorimetric
858 #define TYPE_XYZ_16            (COLORSPACE_SH(PT_XYZ)|CHANNELS_SH(3)|BYTES_SH(2))
859 #define TYPE_Lab_8             (COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(1))
860 #define TYPE_LabV2_8           (COLORSPACE_SH(PT_LabV2)|CHANNELS_SH(3)|BYTES_SH(1))
861 
862 #define TYPE_ALab_8            (COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(1)|EXTRA_SH(1)|SWAPFIRST_SH(1))
863 #define TYPE_ALabV2_8          (COLORSPACE_SH(PT_LabV2)|CHANNELS_SH(3)|BYTES_SH(1)|EXTRA_SH(1)|SWAPFIRST_SH(1))
864 #define TYPE_Lab_16            (COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(2))
865 #define TYPE_LabV2_16          (COLORSPACE_SH(PT_LabV2)|CHANNELS_SH(3)|BYTES_SH(2))
866 #define TYPE_Yxy_16            (COLORSPACE_SH(PT_Yxy)|CHANNELS_SH(3)|BYTES_SH(2))
867 
868 // YCbCr
869 #define TYPE_YCbCr_8           (COLORSPACE_SH(PT_YCbCr)|CHANNELS_SH(3)|BYTES_SH(1))
870 #define TYPE_YCbCr_8_PLANAR    (COLORSPACE_SH(PT_YCbCr)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
871 #define TYPE_YCbCr_16          (COLORSPACE_SH(PT_YCbCr)|CHANNELS_SH(3)|BYTES_SH(2))
872 #define TYPE_YCbCr_16_PLANAR   (COLORSPACE_SH(PT_YCbCr)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
873 #define TYPE_YCbCr_16_SE       (COLORSPACE_SH(PT_YCbCr)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
874 
875 // YUV
876 #define TYPE_YUV_8             (COLORSPACE_SH(PT_YUV)|CHANNELS_SH(3)|BYTES_SH(1))
877 #define TYPE_YUV_8_PLANAR      (COLORSPACE_SH(PT_YUV)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
878 #define TYPE_YUV_16            (COLORSPACE_SH(PT_YUV)|CHANNELS_SH(3)|BYTES_SH(2))
879 #define TYPE_YUV_16_PLANAR     (COLORSPACE_SH(PT_YUV)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
880 #define TYPE_YUV_16_SE         (COLORSPACE_SH(PT_YUV)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
881 
882 // HLS
883 #define TYPE_HLS_8             (COLORSPACE_SH(PT_HLS)|CHANNELS_SH(3)|BYTES_SH(1))
884 #define TYPE_HLS_8_PLANAR      (COLORSPACE_SH(PT_HLS)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
885 #define TYPE_HLS_16            (COLORSPACE_SH(PT_HLS)|CHANNELS_SH(3)|BYTES_SH(2))
886 #define TYPE_HLS_16_PLANAR     (COLORSPACE_SH(PT_HLS)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
887 #define TYPE_HLS_16_SE         (COLORSPACE_SH(PT_HLS)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
888 
889 // HSV
890 #define TYPE_HSV_8             (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(1))
891 #define TYPE_HSV_8_PLANAR      (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
892 #define TYPE_HSV_16            (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(2))
893 #define TYPE_HSV_16_PLANAR     (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
894 #define TYPE_HSV_16_SE         (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
895 
896 // Named color index. Only 16 bits allowed (don't check colorspace)
897 #define TYPE_NAMED_COLOR_INDEX (CHANNELS_SH(1)|BYTES_SH(2))
898 
899 // Float formatters.
900 #define TYPE_XYZ_FLT          (FLOAT_SH(1)|COLORSPACE_SH(PT_XYZ)|CHANNELS_SH(3)|BYTES_SH(4))
901 #define TYPE_Lab_FLT          (FLOAT_SH(1)|COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(4))
902 #define TYPE_LabA_FLT         (FLOAT_SH(1)|COLORSPACE_SH(PT_Lab)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4))
903 #define TYPE_GRAY_FLT         (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(4))
904 #define TYPE_RGB_FLT          (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(4))
905 
906 #define TYPE_RGBA_FLT         (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4))
907 #define TYPE_ARGB_FLT         (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|SWAPFIRST_SH(1))
908 #define TYPE_BGR_FLT          (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1))
909 #define TYPE_BGRA_FLT         (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1)|SWAPFIRST_SH(1))
910 #define TYPE_ABGR_FLT         (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1))
911 
912 #define TYPE_CMYK_FLT         (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(4))
913 
914 // Floating point formatters.
915 // NOTE THAT 'BYTES' FIELD IS SET TO ZERO ON DLB because 8 bytes overflows the bitfield
916 #define TYPE_XYZ_DBL          (FLOAT_SH(1)|COLORSPACE_SH(PT_XYZ)|CHANNELS_SH(3)|BYTES_SH(0))
917 #define TYPE_Lab_DBL          (FLOAT_SH(1)|COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(0))
918 #define TYPE_GRAY_DBL         (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(0))
919 #define TYPE_RGB_DBL          (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(0))
920 #define TYPE_BGR_DBL          (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(0)|DOSWAP_SH(1))
921 #define TYPE_CMYK_DBL         (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(0))
922 
923 // IEEE 754-2008 "half"
924 #define TYPE_GRAY_HALF_FLT    (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(2))
925 #define TYPE_RGB_HALF_FLT     (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2))
926 #define TYPE_RGBA_HALF_FLT    (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2))
927 #define TYPE_CMYK_HALF_FLT    (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2))
928 
929 #define TYPE_RGBA_HALF_FLT    (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2))
930 #define TYPE_ARGB_HALF_FLT    (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|SWAPFIRST_SH(1))
931 #define TYPE_BGR_HALF_FLT     (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1))
932 #define TYPE_BGRA_HALF_FLT    (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|SWAPFIRST_SH(1))
933 #define TYPE_ABGR_HALF_FLT    (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1))
934 
935 #endif
936 
937 // Colorspaces
938 typedef struct {
939         cmsFloat64Number X;
940         cmsFloat64Number Y;
941         cmsFloat64Number Z;
942 
943     } cmsCIEXYZ;
944 
945 typedef struct {
946         cmsFloat64Number x;
947         cmsFloat64Number y;
948         cmsFloat64Number Y;
949 
950     } cmsCIExyY;
951 
952 typedef struct {
953         cmsFloat64Number L;
954         cmsFloat64Number a;
955         cmsFloat64Number b;
956 
957     } cmsCIELab;
958 
959 typedef struct {
960         cmsFloat64Number L;
961         cmsFloat64Number C;
962         cmsFloat64Number h;
963 
964     } cmsCIELCh;
965 
966 typedef struct {
967         cmsFloat64Number J;
968         cmsFloat64Number C;
969         cmsFloat64Number h;
970 
971     } cmsJCh;
972 
973 typedef struct {
974         cmsCIEXYZ  Red;
975         cmsCIEXYZ  Green;
976         cmsCIEXYZ  Blue;
977 
978     } cmsCIEXYZTRIPLE;
979 
980 typedef struct {
981         cmsCIExyY  Red;
982         cmsCIExyY  Green;
983         cmsCIExyY  Blue;
984 
985     } cmsCIExyYTRIPLE;
986 
987 // Illuminant types for structs below
988 #define cmsILLUMINANT_TYPE_UNKNOWN 0x0000000
989 #define cmsILLUMINANT_TYPE_D50     0x0000001
990 #define cmsILLUMINANT_TYPE_D65     0x0000002
991 #define cmsILLUMINANT_TYPE_D93     0x0000003
992 #define cmsILLUMINANT_TYPE_F2      0x0000004
993 #define cmsILLUMINANT_TYPE_D55     0x0000005
994 #define cmsILLUMINANT_TYPE_A       0x0000006
995 #define cmsILLUMINANT_TYPE_E       0x0000007
996 #define cmsILLUMINANT_TYPE_F8      0x0000008
997 
998 typedef struct {
999         cmsUInt32Number  Observer;    // 0 = unknown, 1=CIE 1931, 2=CIE 1964
1000         cmsCIEXYZ        Backing;     // Value of backing
1001         cmsUInt32Number  Geometry;    // 0=unknown, 1=45/0, 0/45 2=0d, d/0
1002         cmsFloat64Number Flare;       // 0..1.0
1003         cmsUInt32Number  IlluminantType;
1004 
1005     } cmsICCMeasurementConditions;
1006 
1007 typedef struct {
1008         cmsCIEXYZ       IlluminantXYZ;   // Not the same struct as CAM02,
1009         cmsCIEXYZ       SurroundXYZ;     // This is for storing the tag
1010         cmsUInt32Number IlluminantType;  // viewing condition
1011 
1012     } cmsICCViewingConditions;
1013 
1014 // Get LittleCMS version (for shared objects) -----------------------------------------------------------------------------
1015 
1016 CMSAPI int               CMSEXPORT cmsGetEncodedCMMversion(void);
1017 
1018 // Support of non-standard functions --------------------------------------------------------------------------------------
1019 
1020 CMSAPI int               CMSEXPORT cmsstrcasecmp(const char* s1, const char* s2);
1021 CMSAPI long int          CMSEXPORT cmsfilelength(FILE* f);
1022 
1023 
1024 // Context handling --------------------------------------------------------------------------------------------------------
1025 
1026 // Each context holds its owns globals and its own plug-ins. There is a global context with the id = 0 for lecacy compatibility
1027 // though using the global context is not recommended. Proper context handling makes lcms more thread-safe.
1028 
1029 typedef struct _cmsContext_struct* cmsContext;
1030 
1031 CMSAPI cmsContext       CMSEXPORT cmsCreateContext(void* Plugin, void* UserData);
1032 CMSAPI void             CMSEXPORT cmsDeleteContext(cmsContext ContexID);
1033 CMSAPI cmsContext       CMSEXPORT cmsDupContext(cmsContext ContextID, void* NewUserData);
1034 CMSAPI void*            CMSEXPORT cmsGetContextUserData(cmsContext ContextID);
1035 
1036 // Plug-In registering  --------------------------------------------------------------------------------------------------
1037 
1038 CMSAPI cmsBool           CMSEXPORT cmsPlugin(void* Plugin);
1039 CMSAPI cmsBool           CMSEXPORT cmsPluginTHR(cmsContext ContextID, void* Plugin);
1040 CMSAPI void              CMSEXPORT cmsUnregisterPlugins(void);
1041 CMSAPI void              CMSEXPORT cmsUnregisterPluginsTHR(cmsContext ContextID);
1042 
1043 // Error logging ----------------------------------------------------------------------------------------------------------
1044 
1045 // There is no error handling at all. When a function fails, it returns proper value.
1046 // For example, all create functions does return NULL on failure. Other may return FALSE.
1047 // It may be interesting, for the developer, to know why the function is failing.
1048 // for that reason, lcms2 does offer a logging function. This function will get
1049 // an ENGLISH string with some clues on what is going wrong. You can show this
1050 // info to the end user if you wish, or just create some sort of log on disk.
1051 // The logging function should NOT terminate the program, as this obviously can leave
1052 // unfreed resources. It is the programmer's responsibility to check each function
1053 // return code to make sure it didn't fail.
1054 
1055 #define cmsERROR_UNDEFINED                    0
1056 #define cmsERROR_FILE                         1
1057 #define cmsERROR_RANGE                        2
1058 #define cmsERROR_INTERNAL                     3
1059 #define cmsERROR_NULL                         4
1060 #define cmsERROR_READ                         5
1061 #define cmsERROR_SEEK                         6
1062 #define cmsERROR_WRITE                        7
1063 #define cmsERROR_UNKNOWN_EXTENSION            8
1064 #define cmsERROR_COLORSPACE_CHECK             9
1065 #define cmsERROR_ALREADY_DEFINED              10
1066 #define cmsERROR_BAD_SIGNATURE                11
1067 #define cmsERROR_CORRUPTION_DETECTED          12
1068 #define cmsERROR_NOT_SUITABLE                 13
1069 
1070 // Error logger is called with the ContextID when a message is raised. This gives the
1071 // chance to know which thread is responsible of the warning and any environment associated
1072 // with it. Non-multithreading applications may safely ignore this parameter.
1073 // Note that under certain special circumstances, ContextID may be NULL.
1074 typedef void  (* cmsLogErrorHandlerFunction)(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *Text);
1075 
1076 // Allows user to set any specific logger
1077 CMSAPI void              CMSEXPORT cmsSetLogErrorHandler(cmsLogErrorHandlerFunction Fn);
1078 CMSAPI void              CMSEXPORT cmsSetLogErrorHandlerTHR(cmsContext ContextID, cmsLogErrorHandlerFunction Fn);
1079 
1080 // Conversions --------------------------------------------------------------------------------------------------------------
1081 
1082 // Returns pointers to constant structs
1083 CMSAPI const cmsCIEXYZ*  CMSEXPORT cmsD50_XYZ(void);
1084 CMSAPI const cmsCIExyY*  CMSEXPORT cmsD50_xyY(void);
1085 
1086 // Colorimetric space conversions
1087 CMSAPI void              CMSEXPORT cmsXYZ2xyY(cmsCIExyY* Dest, const cmsCIEXYZ* Source);
1088 CMSAPI void              CMSEXPORT cmsxyY2XYZ(cmsCIEXYZ* Dest, const cmsCIExyY* Source);
1089 CMSAPI void              CMSEXPORT cmsXYZ2Lab(const cmsCIEXYZ* WhitePoint, cmsCIELab* Lab, const cmsCIEXYZ* xyz);
1090 CMSAPI void              CMSEXPORT cmsLab2XYZ(const cmsCIEXYZ* WhitePoint, cmsCIEXYZ* xyz, const cmsCIELab* Lab);
1091 CMSAPI void              CMSEXPORT cmsLab2LCh(cmsCIELCh*LCh, const cmsCIELab* Lab);
1092 CMSAPI void              CMSEXPORT cmsLCh2Lab(cmsCIELab* Lab, const cmsCIELCh* LCh);
1093 
1094 // Encoding /Decoding on PCS
1095 CMSAPI void              CMSEXPORT cmsLabEncoded2Float(cmsCIELab* Lab, const cmsUInt16Number wLab[3]);
1096 CMSAPI void              CMSEXPORT cmsLabEncoded2FloatV2(cmsCIELab* Lab, const cmsUInt16Number wLab[3]);
1097 CMSAPI void              CMSEXPORT cmsFloat2LabEncoded(cmsUInt16Number wLab[3], const cmsCIELab* Lab);
1098 CMSAPI void              CMSEXPORT cmsFloat2LabEncodedV2(cmsUInt16Number wLab[3], const cmsCIELab* Lab);
1099 CMSAPI void              CMSEXPORT cmsXYZEncoded2Float(cmsCIEXYZ* fxyz, const cmsUInt16Number XYZ[3]);
1100 CMSAPI void              CMSEXPORT cmsFloat2XYZEncoded(cmsUInt16Number XYZ[3], const cmsCIEXYZ* fXYZ);
1101 
1102 // DeltaE metrics
1103 CMSAPI cmsFloat64Number  CMSEXPORT cmsDeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2);
1104 CMSAPI cmsFloat64Number  CMSEXPORT cmsCIE94DeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2);
1105 CMSAPI cmsFloat64Number  CMSEXPORT cmsBFDdeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2);
1106 CMSAPI cmsFloat64Number  CMSEXPORT cmsCMCdeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2, cmsFloat64Number l, cmsFloat64Number c);
1107 CMSAPI cmsFloat64Number  CMSEXPORT cmsCIE2000DeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2, cmsFloat64Number Kl, cmsFloat64Number Kc, cmsFloat64Number Kh);
1108 
1109 // Temperature <-> Chromaticity (Black body)
1110 CMSAPI cmsBool           CMSEXPORT cmsWhitePointFromTemp(cmsCIExyY* WhitePoint, cmsFloat64Number  TempK);
1111 CMSAPI cmsBool           CMSEXPORT cmsTempFromWhitePoint(cmsFloat64Number* TempK, const cmsCIExyY* WhitePoint);
1112 
1113 // Chromatic adaptation
1114 CMSAPI cmsBool           CMSEXPORT cmsAdaptToIlluminant(cmsCIEXYZ* Result, const cmsCIEXYZ* SourceWhitePt,
1115                                                                            const cmsCIEXYZ* Illuminant,
1116                                                                            const cmsCIEXYZ* Value);
1117 
1118 // CIECAM02 ---------------------------------------------------------------------------------------------------
1119 
1120 // Viewing conditions. Please note those are CAM model viewing conditions, and not the ICC tag viewing
1121 // conditions, which I'm naming cmsICCViewingConditions to make differences evident. Unfortunately, the tag
1122 // cannot deal with surround La, Yb and D value so is basically useless to store CAM02 viewing conditions.
1123 
1124 
1125 #define AVG_SURROUND       1
1126 #define DIM_SURROUND       2
1127 #define DARK_SURROUND      3
1128 #define CUTSHEET_SURROUND  4
1129 
1130 #define D_CALCULATE        (-1)
1131 
1132 typedef struct {
1133     cmsCIEXYZ        whitePoint;
1134     cmsFloat64Number Yb;
1135     cmsFloat64Number La;
1136     cmsUInt32Number  surround;
1137     cmsFloat64Number D_value;
1138 
1139     } cmsViewingConditions;
1140 
1141 CMSAPI cmsHANDLE         CMSEXPORT cmsCIECAM02Init(cmsContext ContextID, const cmsViewingConditions* pVC);
1142 CMSAPI void              CMSEXPORT cmsCIECAM02Done(cmsHANDLE hModel);
1143 CMSAPI void              CMSEXPORT cmsCIECAM02Forward(cmsHANDLE hModel, const cmsCIEXYZ* pIn, cmsJCh* pOut);
1144 CMSAPI void              CMSEXPORT cmsCIECAM02Reverse(cmsHANDLE hModel, const cmsJCh* pIn,    cmsCIEXYZ* pOut);
1145 
1146 
1147 // Tone curves -----------------------------------------------------------------------------------------
1148 
1149 // This describes a curve segment. For a table of supported types, see the manual. User can increase the number of
1150 // available types by using a proper plug-in. Parametric segments allow 10 parameters at most
1151 
1152 typedef struct {
1153     cmsFloat32Number   x0, x1;           // Domain; for x0 < x <= x1
1154     cmsInt32Number     Type;             // Parametric type, Type == 0 means sampled segment. Negative values are reserved
1155     cmsFloat64Number   Params[10];       // Parameters if Type != 0
1156     cmsUInt32Number    nGridPoints;      // Number of grid points if Type == 0
1157     cmsFloat32Number*  SampledPoints;    // Points to an array of floats if Type == 0
1158 
1159 } cmsCurveSegment;
1160 
1161 // The internal representation is none of your business.
1162 typedef struct _cms_curve_struct cmsToneCurve;
1163 
1164 CMSAPI cmsToneCurve*     CMSEXPORT cmsBuildSegmentedToneCurve(cmsContext ContextID, cmsUInt32Number nSegments, const cmsCurveSegment Segments[]);
1165 CMSAPI cmsToneCurve*     CMSEXPORT cmsBuildParametricToneCurve(cmsContext ContextID, cmsInt32Number Type, const cmsFloat64Number Params[]);
1166 CMSAPI cmsToneCurve*     CMSEXPORT cmsBuildGamma(cmsContext ContextID, cmsFloat64Number Gamma);
1167 CMSAPI cmsToneCurve*     CMSEXPORT cmsBuildTabulatedToneCurve16(cmsContext ContextID, cmsUInt32Number nEntries, const cmsUInt16Number values[]);
1168 CMSAPI cmsToneCurve*     CMSEXPORT cmsBuildTabulatedToneCurveFloat(cmsContext ContextID, cmsUInt32Number nEntries, const cmsFloat32Number values[]);
1169 CMSAPI void              CMSEXPORT cmsFreeToneCurve(cmsToneCurve* Curve);
1170 CMSAPI void              CMSEXPORT cmsFreeToneCurveTriple(cmsToneCurve* Curve[3]);
1171 CMSAPI cmsToneCurve*     CMSEXPORT cmsDupToneCurve(const cmsToneCurve* Src);
1172 CMSAPI cmsToneCurve*     CMSEXPORT cmsReverseToneCurve(const cmsToneCurve* InGamma);
1173 CMSAPI cmsToneCurve*     CMSEXPORT cmsReverseToneCurveEx(cmsUInt32Number nResultSamples, const cmsToneCurve* InGamma);
1174 CMSAPI cmsToneCurve*     CMSEXPORT cmsJoinToneCurve(cmsContext ContextID, const cmsToneCurve* X,  const cmsToneCurve* Y, cmsUInt32Number nPoints);
1175 CMSAPI cmsBool           CMSEXPORT cmsSmoothToneCurve(cmsToneCurve* Tab, cmsFloat64Number lambda);
1176 CMSAPI cmsFloat32Number  CMSEXPORT cmsEvalToneCurveFloat(const cmsToneCurve* Curve, cmsFloat32Number v);
1177 CMSAPI cmsUInt16Number   CMSEXPORT cmsEvalToneCurve16(const cmsToneCurve* Curve, cmsUInt16Number v);
1178 CMSAPI cmsBool           CMSEXPORT cmsIsToneCurveMultisegment(const cmsToneCurve* InGamma);
1179 CMSAPI cmsBool           CMSEXPORT cmsIsToneCurveLinear(const cmsToneCurve* Curve);
1180 CMSAPI cmsBool           CMSEXPORT cmsIsToneCurveMonotonic(const cmsToneCurve* t);
1181 CMSAPI cmsBool           CMSEXPORT cmsIsToneCurveDescending(const cmsToneCurve* t);
1182 CMSAPI cmsInt32Number    CMSEXPORT cmsGetToneCurveParametricType(const cmsToneCurve* t);
1183 CMSAPI cmsFloat64Number  CMSEXPORT cmsEstimateGamma(const cmsToneCurve* t, cmsFloat64Number Precision);
1184 
1185 // Tone curve tabular estimation
1186 CMSAPI cmsUInt32Number         CMSEXPORT cmsGetToneCurveEstimatedTableEntries(const cmsToneCurve* t);
1187 CMSAPI const cmsUInt16Number*  CMSEXPORT cmsGetToneCurveEstimatedTable(const cmsToneCurve* t);
1188 
1189 
1190 // Implements pipelines of multi-processing elements -------------------------------------------------------------
1191 
1192 // Nothing to see here, move along
1193 typedef struct _cmsPipeline_struct cmsPipeline;
1194 typedef struct _cmsStage_struct cmsStage;
1195 
1196 // Those are hi-level pipelines
1197 CMSAPI cmsPipeline*      CMSEXPORT cmsPipelineAlloc(cmsContext ContextID, cmsUInt32Number InputChannels, cmsUInt32Number OutputChannels);
1198 CMSAPI void              CMSEXPORT cmsPipelineFree(cmsPipeline* lut);
1199 CMSAPI cmsPipeline*      CMSEXPORT cmsPipelineDup(const cmsPipeline* Orig);
1200 
1201 CMSAPI cmsContext        CMSEXPORT cmsGetPipelineContextID(const cmsPipeline* lut);
1202 CMSAPI cmsUInt32Number   CMSEXPORT cmsPipelineInputChannels(const cmsPipeline* lut);
1203 CMSAPI cmsUInt32Number   CMSEXPORT cmsPipelineOutputChannels(const cmsPipeline* lut);
1204 
1205 CMSAPI cmsUInt32Number   CMSEXPORT cmsPipelineStageCount(const cmsPipeline* lut);
1206 CMSAPI cmsStage*         CMSEXPORT cmsPipelineGetPtrToFirstStage(const cmsPipeline* lut);
1207 CMSAPI cmsStage*         CMSEXPORT cmsPipelineGetPtrToLastStage(const cmsPipeline* lut);
1208 
1209 CMSAPI void              CMSEXPORT cmsPipelineEval16(const cmsUInt16Number In[], cmsUInt16Number Out[], const cmsPipeline* lut);
1210 CMSAPI void              CMSEXPORT cmsPipelineEvalFloat(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsPipeline* lut);
1211 CMSAPI cmsBool           CMSEXPORT cmsPipelineEvalReverseFloat(cmsFloat32Number Target[], cmsFloat32Number Result[], cmsFloat32Number Hint[], const cmsPipeline* lut);
1212 CMSAPI cmsBool           CMSEXPORT cmsPipelineCat(cmsPipeline* l1, const cmsPipeline* l2);
1213 CMSAPI cmsBool           CMSEXPORT cmsPipelineSetSaveAs8bitsFlag(cmsPipeline* lut, cmsBool On);
1214 
1215 // Where to place/locate the stages in the pipeline chain
1216 typedef enum { cmsAT_BEGIN, cmsAT_END } cmsStageLoc;
1217 
1218 CMSAPI cmsBool           CMSEXPORT cmsPipelineInsertStage(cmsPipeline* lut, cmsStageLoc loc, cmsStage* mpe);
1219 CMSAPI void              CMSEXPORT cmsPipelineUnlinkStage(cmsPipeline* lut, cmsStageLoc loc, cmsStage** mpe);
1220 
1221 // This function is quite useful to analyze the structure of a Pipeline and retrieve the Stage elements
1222 // that conform the Pipeline. It should be called with the Pipeline, the number of expected elements and
1223 // then a list of expected types followed with a list of double pointers to Stage elements. If
1224 // the function founds a match with current pipeline, it fills the pointers and returns TRUE
1225 // if not, returns FALSE without touching anything.
1226 CMSAPI cmsBool           CMSEXPORT cmsPipelineCheckAndRetreiveStages(const cmsPipeline* Lut, cmsUInt32Number n, ...);
1227 
1228 // Matrix has double precision and CLUT has only float precision. That is because an ICC profile can encode
1229 // matrices with far more precision that CLUTS
1230 CMSAPI cmsStage*         CMSEXPORT cmsStageAllocIdentity(cmsContext ContextID, cmsUInt32Number nChannels);
1231 CMSAPI cmsStage*         CMSEXPORT cmsStageAllocToneCurves(cmsContext ContextID, cmsUInt32Number nChannels, cmsToneCurve* const Curves[]);
1232 CMSAPI cmsStage*         CMSEXPORT cmsStageAllocMatrix(cmsContext ContextID, cmsUInt32Number Rows, cmsUInt32Number Cols, const cmsFloat64Number* Matrix, const cmsFloat64Number* Offset);
1233 
1234 CMSAPI cmsStage*         CMSEXPORT cmsStageAllocCLut16bit(cmsContext ContextID, cmsUInt32Number nGridPoints, cmsUInt32Number inputChan, cmsUInt32Number outputChan, const cmsUInt16Number* Table);
1235 CMSAPI cmsStage*         CMSEXPORT cmsStageAllocCLutFloat(cmsContext ContextID, cmsUInt32Number nGridPoints, cmsUInt32Number inputChan, cmsUInt32Number outputChan, const cmsFloat32Number* Table);
1236 
1237 CMSAPI cmsStage*         CMSEXPORT cmsStageAllocCLut16bitGranular(cmsContext ContextID, const cmsUInt32Number clutPoints[], cmsUInt32Number inputChan, cmsUInt32Number outputChan, const cmsUInt16Number* Table);
1238 CMSAPI cmsStage*         CMSEXPORT cmsStageAllocCLutFloatGranular(cmsContext ContextID, const cmsUInt32Number clutPoints[], cmsUInt32Number inputChan, cmsUInt32Number outputChan, const cmsFloat32Number* Table);
1239 
1240 CMSAPI cmsStage*         CMSEXPORT cmsStageDup(cmsStage* mpe);
1241 CMSAPI void              CMSEXPORT cmsStageFree(cmsStage* mpe);
1242 CMSAPI cmsStage*         CMSEXPORT cmsStageNext(const cmsStage* mpe);
1243 
1244 CMSAPI cmsUInt32Number   CMSEXPORT cmsStageInputChannels(const cmsStage* mpe);
1245 CMSAPI cmsUInt32Number   CMSEXPORT cmsStageOutputChannels(const cmsStage* mpe);
1246 CMSAPI cmsStageSignature CMSEXPORT cmsStageType(const cmsStage* mpe);
1247 CMSAPI void*             CMSEXPORT cmsStageData(const cmsStage* mpe);
1248 
1249 // Sampling
1250 typedef cmsInt32Number (*cmsSAMPLER16)(const cmsUInt16Number In[],
1251                                        cmsUInt16Number Out[],
1252                                        void* Cargo);
1253 
1254 typedef cmsInt32Number (*cmsSAMPLERFLOAT)(const cmsFloat32Number In[],
1255                                           cmsFloat32Number Out[],
1256                                           void* Cargo);
1257 
1258 // Use this flag to prevent changes being written to destination
1259 #define SAMPLER_INSPECT     0x01000000
1260 
1261 // For CLUT only
1262 CMSAPI cmsBool           CMSEXPORT cmsStageSampleCLut16bit(cmsStage* mpe,    cmsSAMPLER16 Sampler, void* Cargo, cmsUInt32Number dwFlags);
1263 CMSAPI cmsBool           CMSEXPORT cmsStageSampleCLutFloat(cmsStage* mpe, cmsSAMPLERFLOAT Sampler, void* Cargo, cmsUInt32Number dwFlags);
1264 
1265 // Slicers
1266 CMSAPI cmsBool           CMSEXPORT cmsSliceSpace16(cmsUInt32Number nInputs, const cmsUInt32Number clutPoints[],
1267                                                    cmsSAMPLER16 Sampler, void * Cargo);
1268 
1269 CMSAPI cmsBool           CMSEXPORT cmsSliceSpaceFloat(cmsUInt32Number nInputs, const cmsUInt32Number clutPoints[],
1270                                                    cmsSAMPLERFLOAT Sampler, void * Cargo);
1271 
1272 // Multilocalized Unicode management ---------------------------------------------------------------------------------------
1273 
1274 typedef struct _cms_MLU_struct cmsMLU;
1275 
1276 #define  cmsNoLanguage "\0\0"
1277 #define  cmsNoCountry  "\0\0"
1278 
1279 CMSAPI cmsMLU*           CMSEXPORT cmsMLUalloc(cmsContext ContextID, cmsUInt32Number nItems);
1280 CMSAPI void              CMSEXPORT cmsMLUfree(cmsMLU* mlu);
1281 CMSAPI cmsMLU*           CMSEXPORT cmsMLUdup(const cmsMLU* mlu);
1282 
1283 CMSAPI cmsBool           CMSEXPORT cmsMLUsetASCII(cmsMLU* mlu,
1284                                                   const char LanguageCode[3], const char CountryCode[3],
1285                                                   const char* ASCIIString);
1286 CMSAPI cmsBool           CMSEXPORT cmsMLUsetWide(cmsMLU* mlu,
1287                                                   const char LanguageCode[3], const char CountryCode[3],
1288                                                   const wchar_t* WideString);
1289 
1290 CMSAPI cmsUInt32Number   CMSEXPORT cmsMLUgetASCII(const cmsMLU* mlu,
1291                                                   const char LanguageCode[3], const char CountryCode[3],
1292                                                   char* Buffer,    cmsUInt32Number BufferSize);
1293 
1294 CMSAPI cmsUInt32Number   CMSEXPORT cmsMLUgetWide(const cmsMLU* mlu,
1295                                                  const char LanguageCode[3], const char CountryCode[3],
1296                                                  wchar_t* Buffer, cmsUInt32Number BufferSize);
1297 
1298 CMSAPI cmsBool           CMSEXPORT cmsMLUgetTranslation(const cmsMLU* mlu,
1299                                                          const char LanguageCode[3], const char CountryCode[3],
1300                                                          char ObtainedLanguage[3], char ObtainedCountry[3]);
1301 
1302 CMSAPI cmsUInt32Number   CMSEXPORT cmsMLUtranslationsCount(const cmsMLU* mlu);
1303 
1304 CMSAPI cmsBool           CMSEXPORT cmsMLUtranslationsCodes(const cmsMLU* mlu,
1305                                                              cmsUInt32Number idx,
1306                                                              char LanguageCode[3],
1307                                                              char CountryCode[3]);
1308 
1309 // Undercolorremoval & black generation -------------------------------------------------------------------------------------
1310 
1311 typedef struct {
1312         cmsToneCurve* Ucr;
1313         cmsToneCurve* Bg;
1314         cmsMLU*       Desc;
1315 
1316 } cmsUcrBg;
1317 
1318 // Screening ----------------------------------------------------------------------------------------------------------------
1319 
1320 #define cmsPRINTER_DEFAULT_SCREENS     0x0001
1321 #define cmsFREQUENCE_UNITS_LINES_CM    0x0000
1322 #define cmsFREQUENCE_UNITS_LINES_INCH  0x0002
1323 
1324 #define cmsSPOT_UNKNOWN         0
1325 #define cmsSPOT_PRINTER_DEFAULT 1
1326 #define cmsSPOT_ROUND           2
1327 #define cmsSPOT_DIAMOND         3
1328 #define cmsSPOT_ELLIPSE         4
1329 #define cmsSPOT_LINE            5
1330 #define cmsSPOT_SQUARE          6
1331 #define cmsSPOT_CROSS           7
1332 
1333 typedef struct {
1334     cmsFloat64Number  Frequency;
1335     cmsFloat64Number  ScreenAngle;
1336     cmsUInt32Number   SpotShape;
1337 
1338 } cmsScreeningChannel;
1339 
1340 typedef struct {
1341     cmsUInt32Number Flag;
1342     cmsUInt32Number nChannels;
1343     cmsScreeningChannel Channels[cmsMAXCHANNELS];
1344 
1345 } cmsScreening;
1346 
1347 
1348 // Named color -----------------------------------------------------------------------------------------------------------------
1349 
1350 typedef struct _cms_NAMEDCOLORLIST_struct cmsNAMEDCOLORLIST;
1351 
1352 CMSAPI cmsNAMEDCOLORLIST* CMSEXPORT cmsAllocNamedColorList(cmsContext ContextID,
1353                                                            cmsUInt32Number n,
1354                                                            cmsUInt32Number ColorantCount,
1355                                                            const char* Prefix, const char* Suffix);
1356 
1357 CMSAPI void               CMSEXPORT cmsFreeNamedColorList(cmsNAMEDCOLORLIST* v);
1358 CMSAPI cmsNAMEDCOLORLIST* CMSEXPORT cmsDupNamedColorList(const cmsNAMEDCOLORLIST* v);
1359 CMSAPI cmsBool            CMSEXPORT cmsAppendNamedColor(cmsNAMEDCOLORLIST* v, const char* Name,
1360                                                             cmsUInt16Number PCS[3],
1361                                                             cmsUInt16Number Colorant[cmsMAXCHANNELS]);
1362 
1363 CMSAPI cmsUInt32Number    CMSEXPORT cmsNamedColorCount(const cmsNAMEDCOLORLIST* v);
1364 CMSAPI cmsInt32Number     CMSEXPORT cmsNamedColorIndex(const cmsNAMEDCOLORLIST* v, const char* Name);
1365 
1366 CMSAPI cmsBool            CMSEXPORT cmsNamedColorInfo(const cmsNAMEDCOLORLIST* NamedColorList, cmsUInt32Number nColor,
1367                                                       char* Name,
1368                                                       char* Prefix,
1369                                                       char* Suffix,
1370                                                       cmsUInt16Number* PCS,
1371                                                       cmsUInt16Number* Colorant);
1372 
1373 // Retrieve named color list from transform
1374 CMSAPI cmsNAMEDCOLORLIST* CMSEXPORT cmsGetNamedColorList(cmsHTRANSFORM xform);
1375 
1376 // Profile sequence -----------------------------------------------------------------------------------------------------
1377 
1378 // Profile sequence descriptor. Some fields come from profile sequence descriptor tag, others
1379 // come from Profile Sequence Identifier Tag
1380 typedef struct {
1381 
1382     cmsSignature           deviceMfg;
1383     cmsSignature           deviceModel;
1384     cmsUInt64Number        attributes;
1385     cmsTechnologySignature technology;
1386     cmsProfileID           ProfileID;
1387     cmsMLU*                Manufacturer;
1388     cmsMLU*                Model;
1389     cmsMLU*                Description;
1390 
1391 } cmsPSEQDESC;
1392 
1393 typedef struct {
1394 
1395     cmsUInt32Number n;
1396     cmsContext      ContextID;
1397     cmsPSEQDESC*    seq;
1398 
1399 } cmsSEQ;
1400 
1401 CMSAPI cmsSEQ*           CMSEXPORT cmsAllocProfileSequenceDescription(cmsContext ContextID, cmsUInt32Number n);
1402 CMSAPI cmsSEQ*           CMSEXPORT cmsDupProfileSequenceDescription(const cmsSEQ* pseq);
1403 CMSAPI void              CMSEXPORT cmsFreeProfileSequenceDescription(cmsSEQ* pseq);
1404 
1405 // Dictionaries --------------------------------------------------------------------------------------------------------
1406 
1407 typedef struct _cmsDICTentry_struct {
1408 
1409     struct _cmsDICTentry_struct* Next;
1410 
1411     cmsMLU *DisplayName;
1412     cmsMLU *DisplayValue;
1413     wchar_t* Name;
1414     wchar_t* Value;
1415 
1416 } cmsDICTentry;
1417 
1418 CMSAPI cmsHANDLE           CMSEXPORT cmsDictAlloc(cmsContext ContextID);
1419 CMSAPI void                CMSEXPORT cmsDictFree(cmsHANDLE hDict);
1420 CMSAPI cmsHANDLE           CMSEXPORT cmsDictDup(cmsHANDLE hDict);
1421 
1422 CMSAPI cmsBool             CMSEXPORT cmsDictAddEntry(cmsHANDLE hDict, const wchar_t* Name, const wchar_t* Value, const cmsMLU *DisplayName, const cmsMLU *DisplayValue);
1423 CMSAPI const cmsDICTentry* CMSEXPORT cmsDictGetEntryList(cmsHANDLE hDict);
1424 CMSAPI const cmsDICTentry* CMSEXPORT cmsDictNextEntry(const cmsDICTentry* e);
1425 
1426 // Access to Profile data ----------------------------------------------------------------------------------------------
1427 CMSAPI cmsHPROFILE       CMSEXPORT cmsCreateProfilePlaceholder(cmsContext ContextID);
1428 
1429 CMSAPI cmsContext        CMSEXPORT cmsGetProfileContextID(cmsHPROFILE hProfile);
1430 CMSAPI cmsInt32Number    CMSEXPORT cmsGetTagCount(cmsHPROFILE hProfile);
1431 CMSAPI cmsTagSignature   CMSEXPORT cmsGetTagSignature(cmsHPROFILE hProfile, cmsUInt32Number n);
1432 CMSAPI cmsBool           CMSEXPORT cmsIsTag(cmsHPROFILE hProfile, cmsTagSignature sig);
1433 
1434 // Read and write pre-formatted data
1435 CMSAPI void*             CMSEXPORT cmsReadTag(cmsHPROFILE hProfile, cmsTagSignature sig);
1436 CMSAPI cmsBool           CMSEXPORT cmsWriteTag(cmsHPROFILE hProfile, cmsTagSignature sig, const void* data);
1437 CMSAPI cmsBool           CMSEXPORT cmsLinkTag(cmsHPROFILE hProfile, cmsTagSignature sig, cmsTagSignature dest);
1438 CMSAPI cmsTagSignature   CMSEXPORT cmsTagLinkedTo(cmsHPROFILE hProfile, cmsTagSignature sig);
1439 
1440 // Read and write raw data
1441 CMSAPI cmsUInt32Number   CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature sig, void* Buffer, cmsUInt32Number BufferSize);
1442 CMSAPI cmsBool           CMSEXPORT cmsWriteRawTag(cmsHPROFILE hProfile, cmsTagSignature sig, const void* data, cmsUInt32Number Size);
1443 
1444 // Access header data
1445 #define cmsEmbeddedProfileFalse    0x00000000
1446 #define cmsEmbeddedProfileTrue     0x00000001
1447 #define cmsUseAnywhere             0x00000000
1448 #define cmsUseWithEmbeddedDataOnly 0x00000002
1449 
1450 CMSAPI cmsUInt32Number   CMSEXPORT cmsGetHeaderFlags(cmsHPROFILE hProfile);
1451 CMSAPI void              CMSEXPORT cmsGetHeaderAttributes(cmsHPROFILE hProfile, cmsUInt64Number* Flags);
1452 CMSAPI void              CMSEXPORT cmsGetHeaderProfileID(cmsHPROFILE hProfile, cmsUInt8Number* ProfileID);
1453 CMSAPI cmsBool           CMSEXPORT cmsGetHeaderCreationDateTime(cmsHPROFILE hProfile, struct tm *Dest);
1454 CMSAPI cmsUInt32Number   CMSEXPORT cmsGetHeaderRenderingIntent(cmsHPROFILE hProfile);
1455 
1456 CMSAPI void              CMSEXPORT cmsSetHeaderFlags(cmsHPROFILE hProfile, cmsUInt32Number Flags);
1457 CMSAPI cmsUInt32Number   CMSEXPORT cmsGetHeaderManufacturer(cmsHPROFILE hProfile);
1458 CMSAPI void              CMSEXPORT cmsSetHeaderManufacturer(cmsHPROFILE hProfile, cmsUInt32Number manufacturer);
1459 CMSAPI cmsUInt32Number   CMSEXPORT cmsGetHeaderCreator(cmsHPROFILE hProfile);
1460 CMSAPI cmsUInt32Number   CMSEXPORT cmsGetHeaderModel(cmsHPROFILE hProfile);
1461 CMSAPI void              CMSEXPORT cmsSetHeaderModel(cmsHPROFILE hProfile, cmsUInt32Number model);
1462 CMSAPI void              CMSEXPORT cmsSetHeaderAttributes(cmsHPROFILE hProfile, cmsUInt64Number Flags);
1463 CMSAPI void              CMSEXPORT cmsSetHeaderProfileID(cmsHPROFILE hProfile, cmsUInt8Number* ProfileID);
1464 CMSAPI void              CMSEXPORT cmsSetHeaderRenderingIntent(cmsHPROFILE hProfile, cmsUInt32Number RenderingIntent);
1465 
1466 CMSAPI cmsColorSpaceSignature
1467                          CMSEXPORT cmsGetPCS(cmsHPROFILE hProfile);
1468 CMSAPI void              CMSEXPORT cmsSetPCS(cmsHPROFILE hProfile, cmsColorSpaceSignature pcs);
1469 CMSAPI cmsColorSpaceSignature
1470                          CMSEXPORT cmsGetColorSpace(cmsHPROFILE hProfile);
1471 CMSAPI void              CMSEXPORT cmsSetColorSpace(cmsHPROFILE hProfile, cmsColorSpaceSignature sig);
1472 CMSAPI cmsProfileClassSignature
1473                          CMSEXPORT cmsGetDeviceClass(cmsHPROFILE hProfile);
1474 CMSAPI void              CMSEXPORT cmsSetDeviceClass(cmsHPROFILE hProfile, cmsProfileClassSignature sig);
1475 CMSAPI void              CMSEXPORT cmsSetProfileVersion(cmsHPROFILE hProfile, cmsFloat64Number Version);
1476 CMSAPI cmsFloat64Number  CMSEXPORT cmsGetProfileVersion(cmsHPROFILE hProfile);
1477 
1478 CMSAPI cmsUInt32Number   CMSEXPORT cmsGetEncodedICCversion(cmsHPROFILE hProfile);
1479 CMSAPI void              CMSEXPORT cmsSetEncodedICCversion(cmsHPROFILE hProfile, cmsUInt32Number Version);
1480 
1481 // How profiles may be used
1482 #define LCMS_USED_AS_INPUT      0
1483 #define LCMS_USED_AS_OUTPUT     1
1484 #define LCMS_USED_AS_PROOF      2
1485 
1486 CMSAPI cmsBool           CMSEXPORT cmsIsIntentSupported(cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number UsedDirection);
1487 CMSAPI cmsBool           CMSEXPORT cmsIsMatrixShaper(cmsHPROFILE hProfile);
1488 CMSAPI cmsBool           CMSEXPORT cmsIsCLUT(cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number UsedDirection);
1489 
1490 // Translate form/to our notation to ICC
1491 CMSAPI cmsColorSpaceSignature   CMSEXPORT _cmsICCcolorSpace(int OurNotation);
1492 CMSAPI int                      CMSEXPORT _cmsLCMScolorSpace(cmsColorSpaceSignature ProfileSpace);
1493 
1494 CMSAPI cmsUInt32Number   CMSEXPORT cmsChannelsOf(cmsColorSpaceSignature ColorSpace);
1495 
1496 // Build a suitable formatter for the colorspace of this profile. nBytes=1 means 8 bits, nBytes=2 means 16 bits.
1497 CMSAPI cmsUInt32Number   CMSEXPORT cmsFormatterForColorspaceOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes, cmsBool lIsFloat);
1498 CMSAPI cmsUInt32Number   CMSEXPORT cmsFormatterForPCSOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes, cmsBool lIsFloat);
1499 
1500 
1501 // Localized info
1502 typedef enum {
1503              cmsInfoDescription  = 0,
1504              cmsInfoManufacturer = 1,
1505              cmsInfoModel        = 2,
1506              cmsInfoCopyright    = 3
1507 } cmsInfoType;
1508 
1509 CMSAPI cmsUInt32Number   CMSEXPORT cmsGetProfileInfo(cmsHPROFILE hProfile, cmsInfoType Info,
1510                                                             const char LanguageCode[3], const char CountryCode[3],
1511                                                             wchar_t* Buffer, cmsUInt32Number BufferSize);
1512 
1513 CMSAPI cmsUInt32Number   CMSEXPORT cmsGetProfileInfoASCII(cmsHPROFILE hProfile, cmsInfoType Info,
1514                                                             const char LanguageCode[3], const char CountryCode[3],
1515                                                             char* Buffer, cmsUInt32Number BufferSize);
1516 
1517 // IO handlers ----------------------------------------------------------------------------------------------------------
1518 
1519 typedef struct _cms_io_handler cmsIOHANDLER;
1520 
1521 CMSAPI cmsIOHANDLER*     CMSEXPORT cmsOpenIOhandlerFromFile(cmsContext ContextID, const char* FileName, const char* AccessMode);
1522 CMSAPI cmsIOHANDLER*     CMSEXPORT cmsOpenIOhandlerFromStream(cmsContext ContextID, FILE* Stream);
1523 CMSAPI cmsIOHANDLER*     CMSEXPORT cmsOpenIOhandlerFromMem(cmsContext ContextID, void *Buffer, cmsUInt32Number size, const char* AccessMode);
1524 CMSAPI cmsIOHANDLER*     CMSEXPORT cmsOpenIOhandlerFromNULL(cmsContext ContextID);
1525 CMSAPI cmsIOHANDLER*     CMSEXPORT cmsGetProfileIOhandler(cmsHPROFILE hProfile);
1526 CMSAPI cmsBool           CMSEXPORT cmsCloseIOhandler(cmsIOHANDLER* io);
1527 
1528 // MD5 message digest --------------------------------------------------------------------------------------------------
1529 
1530 CMSAPI cmsBool           CMSEXPORT cmsMD5computeID(cmsHPROFILE hProfile);
1531 
1532 // Profile high level functions ------------------------------------------------------------------------------------------
1533 
1534 CMSAPI cmsHPROFILE      CMSEXPORT cmsOpenProfileFromFile(const char *ICCProfile, const char *sAccess);
1535 CMSAPI cmsHPROFILE      CMSEXPORT cmsOpenProfileFromFileTHR(cmsContext ContextID, const char *ICCProfile, const char *sAccess);
1536 CMSAPI cmsHPROFILE      CMSEXPORT cmsOpenProfileFromStream(FILE* ICCProfile, const char* sAccess);
1537 CMSAPI cmsHPROFILE      CMSEXPORT cmsOpenProfileFromStreamTHR(cmsContext ContextID, FILE* ICCProfile, const char* sAccess);
1538 CMSAPI cmsHPROFILE      CMSEXPORT cmsOpenProfileFromMem(const void * MemPtr, cmsUInt32Number dwSize);
1539 CMSAPI cmsHPROFILE      CMSEXPORT cmsOpenProfileFromMemTHR(cmsContext ContextID, const void * MemPtr, cmsUInt32Number dwSize);
1540 CMSAPI cmsHPROFILE      CMSEXPORT cmsOpenProfileFromIOhandlerTHR(cmsContext ContextID, cmsIOHANDLER* io);
1541 CMSAPI cmsHPROFILE      CMSEXPORT cmsOpenProfileFromIOhandler2THR(cmsContext ContextID, cmsIOHANDLER* io, cmsBool write);
1542 CMSAPI cmsBool          CMSEXPORT cmsCloseProfile(cmsHPROFILE hProfile);
1543 
1544 CMSAPI cmsBool          CMSEXPORT cmsSaveProfileToFile(cmsHPROFILE hProfile, const char* FileName);
1545 CMSAPI cmsBool          CMSEXPORT cmsSaveProfileToStream(cmsHPROFILE hProfile, FILE* Stream);
1546 CMSAPI cmsBool          CMSEXPORT cmsSaveProfileToMem(cmsHPROFILE hProfile, void *MemPtr, cmsUInt32Number* BytesNeeded);
1547 CMSAPI cmsUInt32Number  CMSEXPORT cmsSaveProfileToIOhandler(cmsHPROFILE hProfile, cmsIOHANDLER* io);
1548 
1549 // Predefined virtual profiles ------------------------------------------------------------------------------------------
1550 
1551 CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateRGBProfileTHR(cmsContext ContextID,
1552                                                    const cmsCIExyY* WhitePoint,
1553                                                    const cmsCIExyYTRIPLE* Primaries,
1554                                                    cmsToneCurve* const TransferFunction[3]);
1555 
1556 CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateRGBProfile(const cmsCIExyY* WhitePoint,
1557                                                    const cmsCIExyYTRIPLE* Primaries,
1558                                                    cmsToneCurve* const TransferFunction[3]);
1559 
1560 CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateGrayProfileTHR(cmsContext ContextID,
1561                                                     const cmsCIExyY* WhitePoint,
1562                                                     const cmsToneCurve* TransferFunction);
1563 
1564 CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateGrayProfile(const cmsCIExyY* WhitePoint,
1565                                                     const cmsToneCurve* TransferFunction);
1566 
1567 CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateLinearizationDeviceLinkTHR(cmsContext ContextID,
1568                                                                 cmsColorSpaceSignature ColorSpace,
1569                                                                 cmsToneCurve* const TransferFunctions[]);
1570 
1571 CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateLinearizationDeviceLink(cmsColorSpaceSignature ColorSpace,
1572                                                                 cmsToneCurve* const TransferFunctions[]);
1573 
1574 CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateInkLimitingDeviceLinkTHR(cmsContext ContextID,
1575                                                               cmsColorSpaceSignature ColorSpace, cmsFloat64Number Limit);
1576 
1577 CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateInkLimitingDeviceLink(cmsColorSpaceSignature ColorSpace, cmsFloat64Number Limit);
1578 
1579 
1580 CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateLab2ProfileTHR(cmsContext ContextID, const cmsCIExyY* WhitePoint);
1581 CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateLab2Profile(const cmsCIExyY* WhitePoint);
1582 CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateLab4ProfileTHR(cmsContext ContextID, const cmsCIExyY* WhitePoint);
1583 CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateLab4Profile(const cmsCIExyY* WhitePoint);
1584 
1585 CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateXYZProfileTHR(cmsContext ContextID);
1586 CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateXYZProfile(void);
1587 
1588 CMSAPI cmsHPROFILE      CMSEXPORT cmsCreate_sRGBProfileTHR(cmsContext ContextID);
1589 CMSAPI cmsHPROFILE      CMSEXPORT cmsCreate_sRGBProfile(void);
1590 
1591 CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateBCHSWabstractProfileTHR(cmsContext ContextID,
1592                                                              cmsUInt32Number nLUTPoints,
1593                                                              cmsFloat64Number Bright,
1594                                                              cmsFloat64Number Contrast,
1595                                                              cmsFloat64Number Hue,
1596                                                              cmsFloat64Number Saturation,
1597                                                              cmsUInt32Number TempSrc,
1598                                                              cmsUInt32Number TempDest);
1599 
1600 CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateBCHSWabstractProfile(cmsUInt32Number nLUTPoints,
1601                                                              cmsFloat64Number Bright,
1602                                                              cmsFloat64Number Contrast,
1603                                                              cmsFloat64Number Hue,
1604                                                              cmsFloat64Number Saturation,
1605                                                              cmsUInt32Number TempSrc,
1606                                                              cmsUInt32Number TempDest);
1607 
1608 CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateNULLProfileTHR(cmsContext ContextID);
1609 CMSAPI cmsHPROFILE      CMSEXPORT cmsCreateNULLProfile(void);
1610 
1611 // Converts a transform to a devicelink profile
1612 CMSAPI cmsHPROFILE      CMSEXPORT cmsTransform2DeviceLink(cmsHTRANSFORM hTransform, cmsFloat64Number Version, cmsUInt32Number dwFlags);
1613 
1614 // Intents ----------------------------------------------------------------------------------------------
1615 
1616 // ICC Intents
1617 #define INTENT_PERCEPTUAL                              0
1618 #define INTENT_RELATIVE_COLORIMETRIC                   1
1619 #define INTENT_SATURATION                              2
1620 #define INTENT_ABSOLUTE_COLORIMETRIC                   3
1621 
1622 // Non-ICC intents
1623 #define INTENT_PRESERVE_K_ONLY_PERCEPTUAL             10
1624 #define INTENT_PRESERVE_K_ONLY_RELATIVE_COLORIMETRIC  11
1625 #define INTENT_PRESERVE_K_ONLY_SATURATION             12
1626 #define INTENT_PRESERVE_K_PLANE_PERCEPTUAL            13
1627 #define INTENT_PRESERVE_K_PLANE_RELATIVE_COLORIMETRIC 14
1628 #define INTENT_PRESERVE_K_PLANE_SATURATION            15
1629 
1630 // Call with NULL as parameters to get the intent count
1631 CMSAPI cmsUInt32Number  CMSEXPORT cmsGetSupportedIntents(cmsUInt32Number nMax, cmsUInt32Number* Codes, char** Descriptions);
1632 CMSAPI cmsUInt32Number  CMSEXPORT cmsGetSupportedIntentsTHR(cmsContext ContextID, cmsUInt32Number nMax, cmsUInt32Number* Codes, char** Descriptions);
1633 
1634 // Flags
1635 
1636 #define cmsFLAGS_NOCACHE                  0x0040    // Inhibit 1-pixel cache
1637 #define cmsFLAGS_NOOPTIMIZE               0x0100    // Inhibit optimizations
1638 #define cmsFLAGS_NULLTRANSFORM            0x0200    // Don't transform anyway
1639 
1640 // Proofing flags
1641 #define cmsFLAGS_GAMUTCHECK               0x1000    // Out of Gamut alarm
1642 #define cmsFLAGS_SOFTPROOFING             0x4000    // Do softproofing
1643 
1644 // Misc
1645 #define cmsFLAGS_BLACKPOINTCOMPENSATION   0x2000
1646 #define cmsFLAGS_NOWHITEONWHITEFIXUP      0x0004    // Don't fix scum dot
1647 #define cmsFLAGS_HIGHRESPRECALC           0x0400    // Use more memory to give better accurancy
1648 #define cmsFLAGS_LOWRESPRECALC            0x0800    // Use less memory to minimize resources
1649 
1650 // For devicelink creation
1651 #define cmsFLAGS_8BITS_DEVICELINK         0x0008   // Create 8 bits devicelinks
1652 #define cmsFLAGS_GUESSDEVICECLASS         0x0020   // Guess device class (for transform2devicelink)
1653 #define cmsFLAGS_KEEP_SEQUENCE            0x0080   // Keep profile sequence for devicelink creation
1654 
1655 // Specific to a particular optimizations
1656 #define cmsFLAGS_FORCE_CLUT               0x0002    // Force CLUT optimization
1657 #define cmsFLAGS_CLUT_POST_LINEARIZATION  0x0001    // create postlinearization tables if possible
1658 #define cmsFLAGS_CLUT_PRE_LINEARIZATION   0x0010    // create prelinearization tables if possible
1659 
1660 // Specific to unbounded mode
1661 #define cmsFLAGS_NONEGATIVES              0x8000    // Prevent negative numbers in floating point transforms
1662 
1663 // Copy alpha channels when transforming
1664 #define cmsFLAGS_COPY_ALPHA               0x04000000 // Alpha channels are copied on cmsDoTransform()
1665 
1666 // Fine-tune control over number of gridpoints
1667 #define cmsFLAGS_GRIDPOINTS(n)           (((n) & 0xFF) << 16)
1668 
1669 // CRD special
1670 #define cmsFLAGS_NODEFAULTRESOURCEDEF     0x01000000
1671 
1672 // Transforms ---------------------------------------------------------------------------------------------------
1673 
1674 CMSAPI cmsHTRANSFORM    CMSEXPORT cmsCreateTransformTHR(cmsContext ContextID,
1675                                                   cmsHPROFILE Input,
1676                                                   cmsUInt32Number InputFormat,
1677                                                   cmsHPROFILE Output,
1678                                                   cmsUInt32Number OutputFormat,
1679                                                   cmsUInt32Number Intent,
1680                                                   cmsUInt32Number dwFlags);
1681 
1682 CMSAPI cmsHTRANSFORM    CMSEXPORT cmsCreateTransform(cmsHPROFILE Input,
1683                                                   cmsUInt32Number InputFormat,
1684                                                   cmsHPROFILE Output,
1685                                                   cmsUInt32Number OutputFormat,
1686                                                   cmsUInt32Number Intent,
1687                                                   cmsUInt32Number dwFlags);
1688 
1689 CMSAPI cmsHTRANSFORM    CMSEXPORT cmsCreateProofingTransformTHR(cmsContext ContextID,
1690                                                   cmsHPROFILE Input,
1691                                                   cmsUInt32Number InputFormat,
1692                                                   cmsHPROFILE Output,
1693                                                   cmsUInt32Number OutputFormat,
1694                                                   cmsHPROFILE Proofing,
1695                                                   cmsUInt32Number Intent,
1696                                                   cmsUInt32Number ProofingIntent,
1697                                                   cmsUInt32Number dwFlags);
1698 
1699 CMSAPI cmsHTRANSFORM    CMSEXPORT cmsCreateProofingTransform(cmsHPROFILE Input,
1700                                                   cmsUInt32Number InputFormat,
1701                                                   cmsHPROFILE Output,
1702                                                   cmsUInt32Number OutputFormat,
1703                                                   cmsHPROFILE Proofing,
1704                                                   cmsUInt32Number Intent,
1705                                                   cmsUInt32Number ProofingIntent,
1706                                                   cmsUInt32Number dwFlags);
1707 
1708 CMSAPI cmsHTRANSFORM    CMSEXPORT cmsCreateMultiprofileTransformTHR(cmsContext ContextID,
1709                                                   cmsHPROFILE hProfiles[],
1710                                                   cmsUInt32Number nProfiles,
1711                                                   cmsUInt32Number InputFormat,
1712                                                   cmsUInt32Number OutputFormat,
1713                                                   cmsUInt32Number Intent,
1714                                                   cmsUInt32Number dwFlags);
1715 
1716 
1717 CMSAPI cmsHTRANSFORM    CMSEXPORT cmsCreateMultiprofileTransform(cmsHPROFILE hProfiles[],
1718                                                   cmsUInt32Number nProfiles,
1719                                                   cmsUInt32Number InputFormat,
1720                                                   cmsUInt32Number OutputFormat,
1721                                                   cmsUInt32Number Intent,
1722                                                   cmsUInt32Number dwFlags);
1723 
1724 
1725 CMSAPI cmsHTRANSFORM    CMSEXPORT cmsCreateExtendedTransform(cmsContext ContextID,
1726                                                    cmsUInt32Number nProfiles, cmsHPROFILE hProfiles[],
1727                                                    cmsBool  BPC[],
1728                                                    cmsUInt32Number Intents[],
1729                                                    cmsFloat64Number AdaptationStates[],
1730                                                    cmsHPROFILE hGamutProfile,
1731                                                    cmsUInt32Number nGamutPCSposition,
1732                                                    cmsUInt32Number InputFormat,
1733                                                    cmsUInt32Number OutputFormat,
1734                                                    cmsUInt32Number dwFlags);
1735 
1736 CMSAPI void             CMSEXPORT cmsDeleteTransform(cmsHTRANSFORM hTransform);
1737 
1738 CMSAPI void             CMSEXPORT cmsDoTransform(cmsHTRANSFORM Transform,
1739                                                  const void * InputBuffer,
1740                                                  void * OutputBuffer,
1741                                                  cmsUInt32Number Size);
1742 
1743 CMSAPI void             CMSEXPORT cmsDoTransformStride(cmsHTRANSFORM Transform,   // Deprecated
1744                                                  const void * InputBuffer,
1745                                                  void * OutputBuffer,
1746                                                  cmsUInt32Number Size,
1747                                                  cmsUInt32Number Stride);
1748 
1749 CMSAPI void             CMSEXPORT cmsDoTransformLineStride(cmsHTRANSFORM  Transform,
1750                                                  const void* InputBuffer,
1751                                                  void* OutputBuffer,
1752                                                  cmsUInt32Number PixelsPerLine,
1753                                                  cmsUInt32Number LineCount,
1754                                                  cmsUInt32Number BytesPerLineIn,
1755                                                  cmsUInt32Number BytesPerLineOut,
1756                                                  cmsUInt32Number BytesPerPlaneIn,
1757                                                  cmsUInt32Number BytesPerPlaneOut);
1758 
1759 
1760 CMSAPI void             CMSEXPORT cmsSetAlarmCodes(const cmsUInt16Number NewAlarm[cmsMAXCHANNELS]);
1761 CMSAPI void             CMSEXPORT cmsGetAlarmCodes(cmsUInt16Number NewAlarm[cmsMAXCHANNELS]);
1762 
1763 
1764 CMSAPI void             CMSEXPORT cmsSetAlarmCodesTHR(cmsContext ContextID,
1765                                                           const cmsUInt16Number AlarmCodes[cmsMAXCHANNELS]);
1766 CMSAPI void             CMSEXPORT cmsGetAlarmCodesTHR(cmsContext ContextID,
1767                                                           cmsUInt16Number AlarmCodes[cmsMAXCHANNELS]);
1768 
1769 
1770 
1771 // Adaptation state for absolute colorimetric intent
1772 CMSAPI cmsFloat64Number CMSEXPORT cmsSetAdaptationState(cmsFloat64Number d);
1773 CMSAPI cmsFloat64Number CMSEXPORT cmsSetAdaptationStateTHR(cmsContext ContextID, cmsFloat64Number d);
1774 
1775 
1776 
1777 // Grab the ContextID from an open transform. Returns NULL if a NULL transform is passed
1778 CMSAPI cmsContext       CMSEXPORT cmsGetTransformContextID(cmsHTRANSFORM hTransform);
1779 
1780 // Grab the input/output formats
1781 CMSAPI cmsUInt32Number CMSEXPORT cmsGetTransformInputFormat(cmsHTRANSFORM hTransform);
1782 CMSAPI cmsUInt32Number CMSEXPORT cmsGetTransformOutputFormat(cmsHTRANSFORM hTransform);
1783 
1784 // For backwards compatibility
1785 CMSAPI cmsBool          CMSEXPORT cmsChangeBuffersFormat(cmsHTRANSFORM hTransform,
1786                                                          cmsUInt32Number InputFormat,
1787                                                          cmsUInt32Number OutputFormat);
1788 
1789 
1790 
1791 // PostScript ColorRenderingDictionary and ColorSpaceArray ----------------------------------------------------
1792 
1793 typedef enum { cmsPS_RESOURCE_CSA, cmsPS_RESOURCE_CRD } cmsPSResourceType;
1794 
1795 // lcms2 unified method to access postscript color resources
1796 CMSAPI cmsUInt32Number  CMSEXPORT cmsGetPostScriptColorResource(cmsContext ContextID,
1797                                                                 cmsPSResourceType Type,
1798                                                                 cmsHPROFILE hProfile,
1799                                                                 cmsUInt32Number Intent,
1800                                                                 cmsUInt32Number dwFlags,
1801                                                                 cmsIOHANDLER* io);
1802 
1803 CMSAPI cmsUInt32Number  CMSEXPORT cmsGetPostScriptCSA(cmsContext ContextID, cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number dwFlags, void* Buffer, cmsUInt32Number dwBufferLen);
1804 CMSAPI cmsUInt32Number  CMSEXPORT cmsGetPostScriptCRD(cmsContext ContextID, cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number dwFlags, void* Buffer, cmsUInt32Number dwBufferLen);
1805 
1806 
1807 // IT8.7 / CGATS.17-200x handling -----------------------------------------------------------------------------
1808 
1809 CMSAPI cmsHANDLE        CMSEXPORT cmsIT8Alloc(cmsContext ContextID);
1810 CMSAPI void             CMSEXPORT cmsIT8Free(cmsHANDLE hIT8);
1811 
1812 // Tables
1813 CMSAPI cmsUInt32Number  CMSEXPORT cmsIT8TableCount(cmsHANDLE hIT8);
1814 CMSAPI cmsInt32Number   CMSEXPORT cmsIT8SetTable(cmsHANDLE hIT8, cmsUInt32Number nTable);
1815 
1816 // Persistence
1817 CMSAPI cmsHANDLE        CMSEXPORT cmsIT8LoadFromFile(cmsContext ContextID, const char* cFileName);
1818 CMSAPI cmsHANDLE        CMSEXPORT cmsIT8LoadFromMem(cmsContext ContextID, const void *Ptr, cmsUInt32Number len);
1819 // CMSAPI cmsHANDLE        CMSEXPORT cmsIT8LoadFromIOhandler(cmsContext ContextID, cmsIOHANDLER* io);
1820 
1821 CMSAPI cmsBool          CMSEXPORT cmsIT8SaveToFile(cmsHANDLE hIT8, const char* cFileName);
1822 CMSAPI cmsBool          CMSEXPORT cmsIT8SaveToMem(cmsHANDLE hIT8, void *MemPtr, cmsUInt32Number* BytesNeeded);
1823 
1824 // Properties
1825 CMSAPI const char*      CMSEXPORT cmsIT8GetSheetType(cmsHANDLE hIT8);
1826 CMSAPI cmsBool          CMSEXPORT cmsIT8SetSheetType(cmsHANDLE hIT8, const char* Type);
1827 
1828 CMSAPI cmsBool          CMSEXPORT cmsIT8SetComment(cmsHANDLE hIT8, const char* cComment);
1829 
1830 CMSAPI cmsBool          CMSEXPORT cmsIT8SetPropertyStr(cmsHANDLE hIT8, const char* cProp, const char *Str);
1831 CMSAPI cmsBool          CMSEXPORT cmsIT8SetPropertyDbl(cmsHANDLE hIT8, const char* cProp, cmsFloat64Number Val);
1832 CMSAPI cmsBool          CMSEXPORT cmsIT8SetPropertyHex(cmsHANDLE hIT8, const char* cProp, cmsUInt32Number Val);
1833 CMSAPI cmsBool          CMSEXPORT cmsIT8SetPropertyMulti(cmsHANDLE hIT8, const char* Key, const char* SubKey, const char *Buffer);
1834 CMSAPI cmsBool          CMSEXPORT cmsIT8SetPropertyUncooked(cmsHANDLE hIT8, const char* Key, const char* Buffer);
1835 
1836 
1837 CMSAPI const char*      CMSEXPORT cmsIT8GetProperty(cmsHANDLE hIT8, const char* cProp);
1838 CMSAPI cmsFloat64Number CMSEXPORT cmsIT8GetPropertyDbl(cmsHANDLE hIT8, const char* cProp);
1839 CMSAPI const char*      CMSEXPORT cmsIT8GetPropertyMulti(cmsHANDLE hIT8, const char* Key, const char *SubKey);
1840 CMSAPI cmsUInt32Number  CMSEXPORT cmsIT8EnumProperties(cmsHANDLE hIT8, char ***PropertyNames);
1841 CMSAPI cmsUInt32Number  CMSEXPORT cmsIT8EnumPropertyMulti(cmsHANDLE hIT8, const char* cProp, const char ***SubpropertyNames);
1842 
1843 // Datasets
1844 CMSAPI const char*      CMSEXPORT cmsIT8GetDataRowCol(cmsHANDLE hIT8, int row, int col);
1845 CMSAPI cmsFloat64Number CMSEXPORT cmsIT8GetDataRowColDbl(cmsHANDLE hIT8, int row, int col);
1846 
1847 CMSAPI cmsBool          CMSEXPORT cmsIT8SetDataRowCol(cmsHANDLE hIT8, int row, int col,
1848                                                 const char* Val);
1849 
1850 CMSAPI cmsBool          CMSEXPORT cmsIT8SetDataRowColDbl(cmsHANDLE hIT8, int row, int col,
1851                                                 cmsFloat64Number Val);
1852 
1853 CMSAPI const char*      CMSEXPORT cmsIT8GetData(cmsHANDLE hIT8, const char* cPatch, const char* cSample);
1854 
1855 
1856 CMSAPI cmsFloat64Number CMSEXPORT cmsIT8GetDataDbl(cmsHANDLE hIT8, const char* cPatch, const char* cSample);
1857 
1858 CMSAPI cmsBool          CMSEXPORT cmsIT8SetData(cmsHANDLE hIT8, const char* cPatch,
1859                                                 const char* cSample,
1860                                                 const char *Val);
1861 
1862 CMSAPI cmsBool          CMSEXPORT cmsIT8SetDataDbl(cmsHANDLE hIT8, const char* cPatch,
1863                                                 const char* cSample,
1864                                                 cmsFloat64Number Val);
1865 
1866 CMSAPI int              CMSEXPORT cmsIT8FindDataFormat(cmsHANDLE hIT8, const char* cSample);
1867 CMSAPI cmsBool          CMSEXPORT cmsIT8SetDataFormat(cmsHANDLE hIT8, int n, const char *Sample);
1868 CMSAPI int              CMSEXPORT cmsIT8EnumDataFormat(cmsHANDLE hIT8, char ***SampleNames);
1869 
1870 CMSAPI const char*      CMSEXPORT cmsIT8GetPatchName(cmsHANDLE hIT8, int nPatch, char* buffer);
1871 CMSAPI int              CMSEXPORT cmsIT8GetPatchByName(cmsHANDLE hIT8, const char *cPatch);
1872 
1873 // The LABEL extension
1874 CMSAPI int              CMSEXPORT cmsIT8SetTableByLabel(cmsHANDLE hIT8, const char* cSet, const char* cField, const char* ExpectedType);
1875 
1876 CMSAPI cmsBool          CMSEXPORT cmsIT8SetIndexColumn(cmsHANDLE hIT8, const char* cSample);
1877 
1878 // Formatter for double
1879 CMSAPI void             CMSEXPORT cmsIT8DefineDblFormat(cmsHANDLE hIT8, const char* Formatter);
1880 
1881 // Gamut boundary description routines ------------------------------------------------------------------------------
1882 
1883 CMSAPI cmsHANDLE        CMSEXPORT cmsGBDAlloc(cmsContext ContextID);
1884 CMSAPI void             CMSEXPORT cmsGBDFree(cmsHANDLE hGBD);
1885 CMSAPI cmsBool          CMSEXPORT cmsGDBAddPoint(cmsHANDLE hGBD, const cmsCIELab* Lab);
1886 CMSAPI cmsBool          CMSEXPORT cmsGDBCompute(cmsHANDLE  hGDB, cmsUInt32Number dwFlags);
1887 CMSAPI cmsBool          CMSEXPORT cmsGDBCheckPoint(cmsHANDLE hGBD, const cmsCIELab* Lab);
1888 
1889 // Feature detection  ----------------------------------------------------------------------------------------------
1890 
1891 // Estimate the black point
1892 CMSAPI cmsBool          CMSEXPORT cmsDetectBlackPoint(cmsCIEXYZ* BlackPoint, cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number dwFlags);
1893 CMSAPI cmsBool          CMSEXPORT cmsDetectDestinationBlackPoint(cmsCIEXYZ* BlackPoint, cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number dwFlags);
1894 
1895 // Estimate total area coverage
1896 CMSAPI cmsFloat64Number CMSEXPORT cmsDetectTAC(cmsHPROFILE hProfile);
1897 
1898 
1899 // Poor man's gamut mapping
1900 CMSAPI cmsBool          CMSEXPORT cmsDesaturateLab(cmsCIELab* Lab,
1901                                                    double amax, double amin,
1902                                                    double bmax, double bmin);
1903 
1904 #ifndef CMS_USE_CPP_API
1905 #   ifdef __cplusplus
1906     }
1907 #   endif
1908 #endif
1909 
1910 #define _lcms2_H
1911 #endif
1912