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