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