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