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