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