1ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//---------------------------------------------------------------------------------
2ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//
3ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//  Little Color Management System
4ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//  Copyright (c) 1998-2014 Marti Maria Saguer
5ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//
6ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Permission is hereby granted, free of charge, to any person obtaining
7ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// a copy of this software and associated documentation files (the "Software"),
8ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// to deal in the Software without restriction, including without limitation
9ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// the rights to use, copy, modify, merge, publish, distribute, sublicense,
10ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// and/or sell copies of the Software, and to permit persons to whom the Software
11ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// is furnished to do so, subject to the following conditions:
12ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//
13ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// The above copyright notice and this permission notice shall be included in
14ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// all copies or substantial portions of the Software.
15ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//
16ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
18ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//
24ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//---------------------------------------------------------------------------------
25ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//
26ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Version 2.6
27ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//
28ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
29ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#ifndef _lcms2_H
30ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
31ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// ********** Configuration toggles ****************************************
32ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
33ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Uncomment this one if you are using big endian machines
34ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// #define CMS_USE_BIG_ENDIAN   1
35ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
36ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Uncomment this one if your compiler/machine does NOT support the
37ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// "long long" type.
38ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// #define CMS_DONT_USE_INT64        1
39ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
40ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Uncomment this if your compiler doesn't work with fast floor function
41ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// #define CMS_DONT_USE_FAST_FLOOR 1
42ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
43ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Uncomment this line if you want lcms to use the black point tag in profile,
44ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// if commented, lcms will compute the black point by its own.
45ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// It is safer to leave it commented out
46ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// #define CMS_USE_PROFILE_BLACK_POINT_TAG    1
47ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
48ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Uncomment this line if you are compiling as C++ and want a C++ API
49ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// #define CMS_USE_CPP_API
50ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
51ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Uncomment this line if you need strict CGATS syntax. Makes CGATS files to
52ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// require "KEYWORD" on undefined identifiers, keep it comented out unless needed
53ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// #define CMS_STRICT_CGATS  1
54ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
55ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Uncomment to get rid of the tables for "half" float support
56ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// #define CMS_NO_HALF_SUPPORT 1
57ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
58ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Uncomment to get rid of pthreads/windows dependency
59ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// #define CMS_NO_PTHREADS  1
60ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
61ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// ********** End of configuration toggles ******************************
62ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
63ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Needed for streams
64ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#include <stdio.h>
65ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
66ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Needed for portability (C99 per 7.1.2)
67ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#include <limits.h>
68ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#include <time.h>
69ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#include <stddef.h>
70ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
71ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#ifndef CMS_USE_CPP_API
72ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#   ifdef __cplusplus
73ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovextern "C" {
74ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#   endif
75ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
76ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
77ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Version/release
78ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define LCMS_VERSION        2060
79ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
80ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// I will give the chance of redefining basic types for compilers that are not fully C99 compliant
81ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#ifndef CMS_BASIC_TYPES_ALREADY_DEFINED
82ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
83ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Base types
84ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef unsigned char        cmsUInt8Number;   // That is guaranteed by the C99 spec
85ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef signed char          cmsInt8Number;    // That is guaranteed by the C99 spec
86ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
87ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#if CHAR_BIT != 8
88ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#  error "Unable to find 8 bit type, unsupported compiler"
89ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
90ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
91ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// IEEE float storage numbers
92ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef float                cmsFloat32Number;
93ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef double               cmsFloat64Number;
94ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
95ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// 16-bit base types
96ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#if (USHRT_MAX == 65535U)
97ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov typedef unsigned short      cmsUInt16Number;
98ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#elif (UINT_MAX == 65535U)
99ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov typedef unsigned int        cmsUInt16Number;
100ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#else
101ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#  error "Unable to find 16 bits unsigned type, unsupported compiler"
102ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
103ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
104ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#if (SHRT_MAX == 32767)
105ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov  typedef  short             cmsInt16Number;
106ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#elif (INT_MAX == 32767)
107ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov  typedef  int               cmsInt16Number;
108ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#else
109ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#  error "Unable to find 16 bits signed type, unsupported compiler"
110ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
111ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
112ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// 32-bit base type
113ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#if (UINT_MAX == 4294967295U)
114ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov typedef unsigned int        cmsUInt32Number;
115ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#elif (ULONG_MAX == 4294967295U)
116ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov typedef unsigned long       cmsUInt32Number;
117ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#else
118ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#  error "Unable to find 32 bit unsigned type, unsupported compiler"
119ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
120ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
121ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#if (INT_MAX == +2147483647)
122ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov typedef  int                cmsInt32Number;
123ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#elif (LONG_MAX == +2147483647)
124ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov typedef  long               cmsInt32Number;
125ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#else
126ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#  error "Unable to find 32 bit signed type, unsupported compiler"
127ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
128ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
129ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// 64-bit base types
130ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#ifndef CMS_DONT_USE_INT64
131ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#  if (ULONG_MAX  == 18446744073709551615U)
132ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    typedef unsigned long   cmsUInt64Number;
133ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#  elif (ULLONG_MAX == 18446744073709551615U)
134ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov      typedef unsigned long long   cmsUInt64Number;
135ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#  else
136ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#     define CMS_DONT_USE_INT64 1
137ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#  endif
138ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#  if (LONG_MAX == +9223372036854775807)
139ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov      typedef  long          cmsInt64Number;
140ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#  elif (LLONG_MAX == +9223372036854775807)
141ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov      typedef  long long     cmsInt64Number;
142ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#  else
143ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#     define CMS_DONT_USE_INT64 1
144ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#  endif
145ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
146ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
147ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
148ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// In the case 64 bit numbers are not supported by the compiler
149ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#ifdef CMS_DONT_USE_INT64
150ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    typedef cmsUInt32Number      cmsUInt64Number[2];
151ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    typedef cmsInt32Number       cmsInt64Number[2];
152ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
153ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
154ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Derivative types
155ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef cmsUInt32Number      cmsSignature;
156ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef cmsUInt16Number      cmsU8Fixed8Number;
157ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef cmsInt32Number       cmsS15Fixed16Number;
158ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef cmsUInt32Number      cmsU16Fixed16Number;
159ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
160ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Boolean type, which will be using the native integer
161ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef int                  cmsBool;
162ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
163ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Try to detect windows
164ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#if defined (_WIN32) || defined(_WIN64) || defined(WIN32) || defined(_WIN32_)
165ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#  define CMS_IS_WINDOWS_ 1
166ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
167ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
168ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#ifdef _MSC_VER
169ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#  define CMS_IS_WINDOWS_ 1
170ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
171ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
172ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#ifdef __BORLANDC__
173ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#  define CMS_IS_WINDOWS_ 1
174ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
175ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
176ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Try to detect big endian platforms. This list can be endless, so only some checks are performed over here.
177ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// you can pass this toggle to the compiler by using -DCMS_USE_BIG_ENDIAN or something similar
178ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
179ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#if defined(__sgi__) || defined(__sgi) || defined(sparc)
180ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#   define CMS_USE_BIG_ENDIAN      1
181ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
182ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
183ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#if defined(__s390__) || defined(__s390x__)
184ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#   define CMS_USE_BIG_ENDIAN   1
185ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
186ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
187ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#  ifdef TARGET_CPU_PPC
188ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#    if TARGET_CPU_PPC
189ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#      define CMS_USE_BIG_ENDIAN   1
190ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#    endif
191ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#  endif
192ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
193ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#if defined(__powerpc__) || defined(__ppc__) || defined(TARGET_CPU_PPC)
194ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#   define CMS_USE_BIG_ENDIAN   1
195ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#   if defined (__GNUC__) && defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN)
196ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#       if __BYTE_ORDER  == __LITTLE_ENDIAN
197ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//               // Don't use big endian for PowerPC little endian mode
198ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#                undef CMS_USE_BIG_ENDIAN
199ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#       endif
200ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#   endif
201ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
202ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
203ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// WORDS_BIGENDIAN takes precedence
204ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#if defined(_HOST_BIG_ENDIAN) || defined(__BIG_ENDIAN__) || defined(WORDS_BIGENDIAN)
205ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#   define CMS_USE_BIG_ENDIAN      1
206ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
207ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
208ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#ifdef macintosh
209ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov# ifdef __BIG_ENDIAN__
210ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#   define CMS_USE_BIG_ENDIAN      1
211ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov# endif
212ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov# ifdef __LITTLE_ENDIAN__
213ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#   undef CMS_USE_BIG_ENDIAN
214ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov# endif
215ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
216ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
217ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Calling convention -- this is hardly platform and compiler dependent
218ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#ifdef CMS_IS_WINDOWS_
219ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#  if defined(CMS_DLL) || defined(CMS_DLL_BUILD)
220ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#     ifdef __BORLANDC__
221ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#        define CMSEXPORT       __stdcall _export
222ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#        define CMSAPI
223ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#     else
224ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#        define CMSEXPORT      _stdcall
225ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#        ifdef CMS_DLL_BUILD
226ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#            define CMSAPI    __declspec(dllexport)
227ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#        else
228ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#           define CMSAPI     __declspec(dllimport)
229ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#       endif
230ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#     endif
231ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#  else
232ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#       define CMSEXPORT
233ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#       define CMSAPI
234ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#  endif
235ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#else
236ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov# define CMSEXPORT
237ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov# define CMSAPI
238ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
239ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
240ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#ifdef HasTHREADS
241ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov# if HasTHREADS == 1
242ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#    undef CMS_NO_PTHREADS
243ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov# else
244ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#    define CMS_NO_PTHREADS 1
245ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov# endif
246ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
247ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
248ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Some common definitions
249ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsMAX_PATH     256
250ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
251ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#ifndef FALSE
252ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#       define FALSE 0
253ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
254ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#ifndef TRUE
255ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#       define TRUE  1
256ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
257ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
258ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// D50 XYZ normalized to Y=1.0
259ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsD50X             0.9642
260ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsD50Y             1.0
261ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsD50Z             0.8249
262ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
263ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// V4 perceptual black
264ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsPERCEPTUAL_BLACK_X  0.00336
265ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsPERCEPTUAL_BLACK_Y  0.0034731
266ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsPERCEPTUAL_BLACK_Z  0.00287
267ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
268ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Definitions in ICC spec
269ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsMagicNumber      0x61637370     // 'acsp'
270ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define lcmsSignature       0x6c636d73     // 'lcms'
271ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
272ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
273ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Base ICC type definitions
274ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef enum {
275ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigChromaticityType                  = 0x6368726D,  // 'chrm'
276ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigColorantOrderType                 = 0x636C726F,  // 'clro'
277ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigColorantTableType                 = 0x636C7274,  // 'clrt'
278ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigCrdInfoType                       = 0x63726469,  // 'crdi'
279ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigCurveType                         = 0x63757276,  // 'curv'
280ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigDataType                          = 0x64617461,  // 'data'
281ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigDictType                          = 0x64696374,  // 'dict'
282ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigDateTimeType                      = 0x6474696D,  // 'dtim'
283ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigDeviceSettingsType                = 0x64657673,  // 'devs'
284ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigLut16Type                         = 0x6d667432,  // 'mft2'
285ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigLut8Type                          = 0x6d667431,  // 'mft1'
286ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigLutAtoBType                       = 0x6d414220,  // 'mAB '
287ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigLutBtoAType                       = 0x6d424120,  // 'mBA '
288ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMeasurementType                   = 0x6D656173,  // 'meas'
289ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMultiLocalizedUnicodeType         = 0x6D6C7563,  // 'mluc'
290ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMultiProcessElementType           = 0x6D706574,  // 'mpet'
291ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigNamedColorType                    = 0x6E636f6C,  // 'ncol' -- DEPRECATED!
292ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigNamedColor2Type                   = 0x6E636C32,  // 'ncl2'
293ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigParametricCurveType               = 0x70617261,  // 'para'
294ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigProfileSequenceDescType           = 0x70736571,  // 'pseq'
295ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigProfileSequenceIdType             = 0x70736964,  // 'psid'
296ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigResponseCurveSet16Type            = 0x72637332,  // 'rcs2'
297ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigS15Fixed16ArrayType               = 0x73663332,  // 'sf32'
298ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigScreeningType                     = 0x7363726E,  // 'scrn'
299ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigSignatureType                     = 0x73696720,  // 'sig '
300ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigTextType                          = 0x74657874,  // 'text'
301ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigTextDescriptionType               = 0x64657363,  // 'desc'
302ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigU16Fixed16ArrayType               = 0x75663332,  // 'uf32'
303ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigUcrBgType                         = 0x62666420,  // 'bfd '
304ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigUInt16ArrayType                   = 0x75693136,  // 'ui16'
305ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigUInt32ArrayType                   = 0x75693332,  // 'ui32'
306ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigUInt64ArrayType                   = 0x75693634,  // 'ui64'
307ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigUInt8ArrayType                    = 0x75693038,  // 'ui08'
308ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigVcgtType                          = 0x76636774,  // 'vcgt'
309ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigViewingConditionsType             = 0x76696577,  // 'view'
310ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigXYZType                           = 0x58595A20   // 'XYZ '
311ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
312ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
313ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov} cmsTagTypeSignature;
314ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
315ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Base ICC tag definitions
316ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef enum {
317ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigAToB0Tag                          = 0x41324230,  // 'A2B0'
318ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigAToB1Tag                          = 0x41324231,  // 'A2B1'
319ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigAToB2Tag                          = 0x41324232,  // 'A2B2'
320ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigBlueColorantTag                   = 0x6258595A,  // 'bXYZ'
321ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigBlueMatrixColumnTag               = 0x6258595A,  // 'bXYZ'
322ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigBlueTRCTag                        = 0x62545243,  // 'bTRC'
323ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigBToA0Tag                          = 0x42324130,  // 'B2A0'
324ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigBToA1Tag                          = 0x42324131,  // 'B2A1'
325ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigBToA2Tag                          = 0x42324132,  // 'B2A2'
326ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigCalibrationDateTimeTag            = 0x63616C74,  // 'calt'
327ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigCharTargetTag                     = 0x74617267,  // 'targ'
328ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigChromaticAdaptationTag            = 0x63686164,  // 'chad'
329ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigChromaticityTag                   = 0x6368726D,  // 'chrm'
330ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigColorantOrderTag                  = 0x636C726F,  // 'clro'
331ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigColorantTableTag                  = 0x636C7274,  // 'clrt'
332ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigColorantTableOutTag               = 0x636C6F74,  // 'clot'
333ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigColorimetricIntentImageStateTag   = 0x63696973,  // 'ciis'
334ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigCopyrightTag                      = 0x63707274,  // 'cprt'
335ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigCrdInfoTag                        = 0x63726469,  // 'crdi'
336ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigDataTag                           = 0x64617461,  // 'data'
337ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigDateTimeTag                       = 0x6474696D,  // 'dtim'
338ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigDeviceMfgDescTag                  = 0x646D6E64,  // 'dmnd'
339ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigDeviceModelDescTag                = 0x646D6464,  // 'dmdd'
340ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigDeviceSettingsTag                 = 0x64657673,  // 'devs'
341ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigDToB0Tag                          = 0x44324230,  // 'D2B0'
342ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigDToB1Tag                          = 0x44324231,  // 'D2B1'
343ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigDToB2Tag                          = 0x44324232,  // 'D2B2'
344ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigDToB3Tag                          = 0x44324233,  // 'D2B3'
345ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigBToD0Tag                          = 0x42324430,  // 'B2D0'
346ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigBToD1Tag                          = 0x42324431,  // 'B2D1'
347ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigBToD2Tag                          = 0x42324432,  // 'B2D2'
348ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigBToD3Tag                          = 0x42324433,  // 'B2D3'
349ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigGamutTag                          = 0x67616D74,  // 'gamt'
350ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigGrayTRCTag                        = 0x6b545243,  // 'kTRC'
351ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigGreenColorantTag                  = 0x6758595A,  // 'gXYZ'
352ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigGreenMatrixColumnTag              = 0x6758595A,  // 'gXYZ'
353ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigGreenTRCTag                       = 0x67545243,  // 'gTRC'
354ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigLuminanceTag                      = 0x6C756d69,  // 'lumi'
355ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMeasurementTag                    = 0x6D656173,  // 'meas'
356ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMediaBlackPointTag                = 0x626B7074,  // 'bkpt'
357ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMediaWhitePointTag                = 0x77747074,  // 'wtpt'
358ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigNamedColorTag                     = 0x6E636f6C,  // 'ncol' // Deprecated by the ICC
359ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigNamedColor2Tag                    = 0x6E636C32,  // 'ncl2'
360ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigOutputResponseTag                 = 0x72657370,  // 'resp'
361ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigPerceptualRenderingIntentGamutTag = 0x72696730,  // 'rig0'
362ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigPreview0Tag                       = 0x70726530,  // 'pre0'
363ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigPreview1Tag                       = 0x70726531,  // 'pre1'
364ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigPreview2Tag                       = 0x70726532,  // 'pre2'
365ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigProfileDescriptionTag             = 0x64657363,  // 'desc'
366ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigProfileDescriptionMLTag           = 0x6473636d,  // 'dscm'
367ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigProfileSequenceDescTag            = 0x70736571,  // 'pseq'
368ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigProfileSequenceIdTag              = 0x70736964,  // 'psid'
369ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigPs2CRD0Tag                        = 0x70736430,  // 'psd0'
370ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigPs2CRD1Tag                        = 0x70736431,  // 'psd1'
371ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigPs2CRD2Tag                        = 0x70736432,  // 'psd2'
372ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigPs2CRD3Tag                        = 0x70736433,  // 'psd3'
373ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigPs2CSATag                         = 0x70733273,  // 'ps2s'
374ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigPs2RenderingIntentTag             = 0x70733269,  // 'ps2i'
375ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigRedColorantTag                    = 0x7258595A,  // 'rXYZ'
376ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigRedMatrixColumnTag                = 0x7258595A,  // 'rXYZ'
377ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigRedTRCTag                         = 0x72545243,  // 'rTRC'
378ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigSaturationRenderingIntentGamutTag = 0x72696732,  // 'rig2'
379ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigScreeningDescTag                  = 0x73637264,  // 'scrd'
380ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigScreeningTag                      = 0x7363726E,  // 'scrn'
381ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigTechnologyTag                     = 0x74656368,  // 'tech'
382ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigUcrBgTag                          = 0x62666420,  // 'bfd '
383ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigViewingCondDescTag                = 0x76756564,  // 'vued'
384ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigViewingConditionsTag              = 0x76696577,  // 'view'
385ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigVcgtTag                           = 0x76636774,  // 'vcgt'
386ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMetaTag                           = 0x6D657461   // 'meta'
387ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
388ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov} cmsTagSignature;
389ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
390ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
391ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// ICC Technology tag
392ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef enum {
393ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigDigitalCamera                     = 0x6463616D,  // 'dcam'
394ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigFilmScanner                       = 0x6673636E,  // 'fscn'
395ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigReflectiveScanner                 = 0x7273636E,  // 'rscn'
396ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigInkJetPrinter                     = 0x696A6574,  // 'ijet'
397ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigThermalWaxPrinter                 = 0x74776178,  // 'twax'
398ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigElectrophotographicPrinter        = 0x6570686F,  // 'epho'
399ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigElectrostaticPrinter              = 0x65737461,  // 'esta'
400ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigDyeSublimationPrinter             = 0x64737562,  // 'dsub'
401ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigPhotographicPaperPrinter          = 0x7270686F,  // 'rpho'
402ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigFilmWriter                        = 0x6670726E,  // 'fprn'
403ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigVideoMonitor                      = 0x7669646D,  // 'vidm'
404ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigVideoCamera                       = 0x76696463,  // 'vidc'
405ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigProjectionTelevision              = 0x706A7476,  // 'pjtv'
406ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigCRTDisplay                        = 0x43525420,  // 'CRT '
407ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigPMDisplay                         = 0x504D4420,  // 'PMD '
408ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigAMDisplay                         = 0x414D4420,  // 'AMD '
409ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigPhotoCD                           = 0x4B504344,  // 'KPCD'
410ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigPhotoImageSetter                  = 0x696D6773,  // 'imgs'
411ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigGravure                           = 0x67726176,  // 'grav'
412ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigOffsetLithography                 = 0x6F666673,  // 'offs'
413ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigSilkscreen                        = 0x73696C6B,  // 'silk'
414ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigFlexography                       = 0x666C6578,  // 'flex'
415ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMotionPictureFilmScanner          = 0x6D706673,  // 'mpfs'
416ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMotionPictureFilmRecorder         = 0x6D706672,  // 'mpfr'
417ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigDigitalMotionPictureCamera        = 0x646D7063,  // 'dmpc'
418ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigDigitalCinemaProjector            = 0x64636A70   // 'dcpj'
419ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
420ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov} cmsTechnologySignature;
421ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
422ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
423ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// ICC Color spaces
424ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef enum {
425ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigXYZData                           = 0x58595A20,  // 'XYZ '
426ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigLabData                           = 0x4C616220,  // 'Lab '
427ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigLuvData                           = 0x4C757620,  // 'Luv '
428ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigYCbCrData                         = 0x59436272,  // 'YCbr'
429ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigYxyData                           = 0x59787920,  // 'Yxy '
430ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigRgbData                           = 0x52474220,  // 'RGB '
431ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigGrayData                          = 0x47524159,  // 'GRAY'
432ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigHsvData                           = 0x48535620,  // 'HSV '
433ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigHlsData                           = 0x484C5320,  // 'HLS '
434ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigCmykData                          = 0x434D594B,  // 'CMYK'
435ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigCmyData                           = 0x434D5920,  // 'CMY '
436ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMCH1Data                          = 0x4D434831,  // 'MCH1'
437ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMCH2Data                          = 0x4D434832,  // 'MCH2'
438ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMCH3Data                          = 0x4D434833,  // 'MCH3'
439ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMCH4Data                          = 0x4D434834,  // 'MCH4'
440ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMCH5Data                          = 0x4D434835,  // 'MCH5'
441ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMCH6Data                          = 0x4D434836,  // 'MCH6'
442ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMCH7Data                          = 0x4D434837,  // 'MCH7'
443ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMCH8Data                          = 0x4D434838,  // 'MCH8'
444ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMCH9Data                          = 0x4D434839,  // 'MCH9'
445ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMCHAData                          = 0x4D434841,  // 'MCHA'
446ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMCHBData                          = 0x4D434842,  // 'MCHB'
447ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMCHCData                          = 0x4D434843,  // 'MCHC'
448ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMCHDData                          = 0x4D434844,  // 'MCHD'
449ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMCHEData                          = 0x4D434845,  // 'MCHE'
450ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMCHFData                          = 0x4D434846,  // 'MCHF'
451ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigNamedData                         = 0x6e6d636c,  // 'nmcl'
452ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSig1colorData                        = 0x31434C52,  // '1CLR'
453ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSig2colorData                        = 0x32434C52,  // '2CLR'
454ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSig3colorData                        = 0x33434C52,  // '3CLR'
455ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSig4colorData                        = 0x34434C52,  // '4CLR'
456ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSig5colorData                        = 0x35434C52,  // '5CLR'
457ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSig6colorData                        = 0x36434C52,  // '6CLR'
458ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSig7colorData                        = 0x37434C52,  // '7CLR'
459ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSig8colorData                        = 0x38434C52,  // '8CLR'
460ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSig9colorData                        = 0x39434C52,  // '9CLR'
461ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSig10colorData                       = 0x41434C52,  // 'ACLR'
462ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSig11colorData                       = 0x42434C52,  // 'BCLR'
463ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSig12colorData                       = 0x43434C52,  // 'CCLR'
464ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSig13colorData                       = 0x44434C52,  // 'DCLR'
465ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSig14colorData                       = 0x45434C52,  // 'ECLR'
466ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSig15colorData                       = 0x46434C52,  // 'FCLR'
467ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigLuvKData                          = 0x4C75764B   // 'LuvK'
468ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
469ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov} cmsColorSpaceSignature;
470ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
471ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// ICC Profile Class
472ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef enum {
473ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigInputClass                        = 0x73636E72,  // 'scnr'
474ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigDisplayClass                      = 0x6D6E7472,  // 'mntr'
475ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigOutputClass                       = 0x70727472,  // 'prtr'
476ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigLinkClass                         = 0x6C696E6B,  // 'link'
477ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigAbstractClass                     = 0x61627374,  // 'abst'
478ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigColorSpaceClass                   = 0x73706163,  // 'spac'
479ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigNamedColorClass                   = 0x6e6d636c   // 'nmcl'
480ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
481ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov} cmsProfileClassSignature;
482ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
483ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// ICC Platforms
484ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef enum {
485ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMacintosh                         = 0x4150504C,  // 'APPL'
486ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMicrosoft                         = 0x4D534654,  // 'MSFT'
487ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigSolaris                           = 0x53554E57,  // 'SUNW'
488ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigSGI                               = 0x53474920,  // 'SGI '
489ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigTaligent                          = 0x54474E54,  // 'TGNT'
490ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigUnices                            = 0x2A6E6978   // '*nix'   // From argyll -- Not official
491ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
492ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov} cmsPlatformSignature;
493ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
494ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Reference gamut
495ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define  cmsSigPerceptualReferenceMediumGamut         0x70726d67  //'prmg'
496ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
497ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// For cmsSigColorimetricIntentImageStateTag
498ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define  cmsSigSceneColorimetryEstimates              0x73636F65  //'scoe'
499ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define  cmsSigSceneAppearanceEstimates               0x73617065  //'sape'
500ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define  cmsSigFocalPlaneColorimetryEstimates         0x66706365  //'fpce'
501ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define  cmsSigReflectionHardcopyOriginalColorimetry  0x72686F63  //'rhoc'
502ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define  cmsSigReflectionPrintOutputColorimetry       0x72706F63  //'rpoc'
503ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
504ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Multi process elements types
505ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef enum {
506ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigCurveSetElemType              = 0x63767374,  //'cvst'
507ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigMatrixElemType                = 0x6D617466,  //'matf'
508ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigCLutElemType                  = 0x636C7574,  //'clut'
509ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
510ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigBAcsElemType                  = 0x62414353,  // 'bACS'
511ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigEAcsElemType                  = 0x65414353,  // 'eACS'
512ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
513ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    // Custom from here, not in the ICC Spec
514ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigXYZ2LabElemType               = 0x6C327820,  // 'l2x '
515ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigLab2XYZElemType               = 0x78326C20,  // 'x2l '
516ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigNamedColorElemType            = 0x6E636C20,  // 'ncl '
517ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigLabV2toV4                     = 0x32203420,  // '2 4 '
518ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigLabV4toV2                     = 0x34203220,  // '4 2 '
519ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
520ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    // Identities
521ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigIdentityElemType              = 0x69646E20,  // 'idn '
522ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
523ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    // Float to floatPCS
524ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigLab2FloatPCS                  = 0x64326C20,  // 'd2l '
525ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigFloatPCS2Lab                  = 0x6C326420,  // 'l2d '
526ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigXYZ2FloatPCS                  = 0x64327820,  // 'd2x '
527ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigFloatPCS2XYZ                  = 0x78326420   // 'x2d '
528ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
529ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov} cmsStageSignature;
530ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
531ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Types of CurveElements
532ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef enum {
533ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
534ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigFormulaCurveSeg               = 0x70617266, // 'parf'
535ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigSampledCurveSeg               = 0x73616D66, // 'samf'
536ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSigSegmentedCurve                = 0x63757266  // 'curf'
537ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
538ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov} cmsCurveSegSignature;
539ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
540ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Used in ResponseCurveType
541ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define  cmsSigStatusA                    0x53746141 //'StaA'
542ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define  cmsSigStatusE                    0x53746145 //'StaE'
543ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define  cmsSigStatusI                    0x53746149 //'StaI'
544ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define  cmsSigStatusT                    0x53746154 //'StaT'
545ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define  cmsSigStatusM                    0x5374614D //'StaM'
546ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define  cmsSigDN                         0x444E2020 //'DN  '
547ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define  cmsSigDNP                        0x444E2050 //'DN P'
548ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define  cmsSigDNN                        0x444E4E20 //'DNN '
549ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define  cmsSigDNNP                       0x444E4E50 //'DNNP'
550ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
551ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Device attributes, currently defined values correspond to the low 4 bytes
552ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// of the 8 byte attribute quantity
553ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsReflective     0
554ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsTransparency   1
555ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsGlossy         0
556ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsMatte          2
557ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
558ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Common structures in ICC tags
559ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef struct {
560ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsUInt32Number len;
561ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsUInt32Number flag;
562ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsUInt8Number  data[1];
563ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
564ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov} cmsICCData;
565ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
566ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// ICC date time
567ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef struct {
568ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsUInt16Number      year;
569ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsUInt16Number      month;
570ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsUInt16Number      day;
571ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsUInt16Number      hours;
572ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsUInt16Number      minutes;
573ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsUInt16Number      seconds;
574ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
575ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov} cmsDateTimeNumber;
576ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
577ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// ICC XYZ
578ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef struct {
579ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsS15Fixed16Number  X;
580ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsS15Fixed16Number  Y;
581ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsS15Fixed16Number  Z;
582ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
583ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov} cmsEncodedXYZNumber;
584ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
585ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
586ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Profile ID as computed by MD5 algorithm
587ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef union {
588ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsUInt8Number       ID8[16];
589ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsUInt16Number      ID16[8];
590ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsUInt32Number      ID32[4];
591ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
592ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov} cmsProfileID;
593ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
594ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
595ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// ----------------------------------------------------------------------------------------------
596ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// ICC profile internal base types. Strictly, shouldn't be declared in this header, but maybe
597ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// somebody want to use this info for accessing profile header directly, so here it is.
598ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
599ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Profile header -- it is 32-bit aligned, so no issues are expected on alignment
600ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef struct {
601ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsUInt32Number              size;           // Profile size in bytes
602ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSignature                 cmmId;          // CMM for this profile
603ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsUInt32Number              version;        // Format version number
604ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsProfileClassSignature     deviceClass;    // Type of profile
605ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsColorSpaceSignature       colorSpace;     // Color space of data
606ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsColorSpaceSignature       pcs;            // PCS, XYZ or Lab only
607ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsDateTimeNumber            date;           // Date profile was created
608ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSignature                 magic;          // Magic Number to identify an ICC profile
609ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsPlatformSignature         platform;       // Primary Platform
610ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsUInt32Number              flags;          // Various bit settings
611ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSignature                 manufacturer;   // Device manufacturer
612ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsUInt32Number              model;          // Device model number
613ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsUInt64Number              attributes;     // Device attributes
614ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsUInt32Number              renderingIntent;// Rendering intent
615ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsEncodedXYZNumber          illuminant;     // Profile illuminant
616ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsSignature                 creator;        // Profile creator
617ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsProfileID                 profileID;      // Profile ID using MD5
618ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsInt8Number                reserved[28];   // Reserved for future use
619ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
620ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov} cmsICCHeader;
621ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
622ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// ICC base tag
623ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef struct {
624ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsTagTypeSignature  sig;
625ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsInt8Number        reserved[4];
626ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
627ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov} cmsTagBase;
628ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
629ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// A tag entry in directory
630ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef struct {
631ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsTagSignature      sig;            // The tag signature
632ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsUInt32Number      offset;         // Start of tag
633ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsUInt32Number      size;           // Size in bytes
634ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
635ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov} cmsTagEntry;
636ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
637ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// ----------------------------------------------------------------------------------------------
638ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
639ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Little CMS specific typedefs
640ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
641ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef void* cmsHANDLE ;              // Generic handle
642ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef void* cmsHPROFILE;             // Opaque typedefs to hide internals
643ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef void* cmsHTRANSFORM;
644ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
645ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsMAXCHANNELS  16                // Maximum number of channels in ICC profiles
646ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
647ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Format of pixel is defined by one cmsUInt32Number, using bit fields as follows
648ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//
649ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//                               2                1          0
650ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//                          3 2 10987 6 5 4 3 2 1 098 7654 321
651ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//                          A O TTTTT U Y F P X S EEE CCCC BBB
652ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//
653ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//            A: Floating point -- With this flag we can differentiate 16 bits as float and as int
654ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//            O: Optimized -- previous optimization already returns the final 8-bit value
655ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//            T: Pixeltype
656ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//            F: Flavor  0=MinIsBlack(Chocolate) 1=MinIsWhite(Vanilla)
657ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//            P: Planar? 0=Chunky, 1=Planar
658ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//            X: swap 16 bps endianess?
659ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//            S: Do swap? ie, BGR, KYMC
660ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//            E: Extra samples
661ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//            C: Channels (Samples per pixel)
662ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//            B: bytes per sample
663ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov//            Y: Swap first - changes ABGR to BGRA and KCMY to CMYK
664ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
665ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define FLOAT_SH(a)            ((a) << 22)
666ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define OPTIMIZED_SH(s)        ((s) << 21)
667ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define COLORSPACE_SH(s)       ((s) << 16)
668ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define SWAPFIRST_SH(s)        ((s) << 14)
669ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define FLAVOR_SH(s)           ((s) << 13)
670ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PLANAR_SH(p)           ((p) << 12)
671ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define ENDIAN16_SH(e)         ((e) << 11)
672ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define DOSWAP_SH(e)           ((e) << 10)
673ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define EXTRA_SH(e)            ((e) << 7)
674ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define CHANNELS_SH(c)         ((c) << 3)
675ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define BYTES_SH(b)            (b)
676ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
677ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// These macros unpack format specifiers into integers
678ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define T_FLOAT(a)            (((a)>>22)&1)
679ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define T_OPTIMIZED(o)        (((o)>>21)&1)
680ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define T_COLORSPACE(s)       (((s)>>16)&31)
681ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define T_SWAPFIRST(s)        (((s)>>14)&1)
682ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define T_FLAVOR(s)           (((s)>>13)&1)
683ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define T_PLANAR(p)           (((p)>>12)&1)
684ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define T_ENDIAN16(e)         (((e)>>11)&1)
685ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define T_DOSWAP(e)           (((e)>>10)&1)
686ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define T_EXTRA(e)            (((e)>>7)&7)
687ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define T_CHANNELS(c)         (((c)>>3)&15)
688ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define T_BYTES(b)            ((b)&7)
689ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
690ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
691ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Pixel types
692ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_ANY       0    // Don't check colorspace
693ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov                          // 1 & 2 are reserved
694ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_GRAY      3
695ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_RGB       4
696ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_CMY       5
697ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_CMYK      6
698ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_YCbCr     7
699ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_YUV       8      // Lu'v'
700ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_XYZ       9
701ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_Lab       10
702ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_YUVK      11     // Lu'v'K
703ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_HSV       12
704ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_HLS       13
705ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_Yxy       14
706ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
707ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_MCH1      15
708ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_MCH2      16
709ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_MCH3      17
710ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_MCH4      18
711ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_MCH5      19
712ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_MCH6      20
713ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_MCH7      21
714ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_MCH8      22
715ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_MCH9      23
716ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_MCH10     24
717ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_MCH11     25
718ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_MCH12     26
719ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_MCH13     27
720ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_MCH14     28
721ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_MCH15     29
722ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
723ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define PT_LabV2     30     // Identical to PT_Lab, but using the V2 old encoding
724ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
725ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Some (not all!) representations
726ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
727ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#ifndef TYPE_RGB_8      // TYPE_RGB_8 is a very common identifier, so don't include ours
728ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov                        // if user has it already defined.
729ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
730ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_GRAY_8            (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(1))
731ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_GRAY_8_REV        (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(1)|FLAVOR_SH(1))
732ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_GRAY_16           (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(2))
733ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_GRAY_16_REV       (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(2)|FLAVOR_SH(1))
734ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_GRAY_16_SE        (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(2)|ENDIAN16_SH(1))
735ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_GRAYA_8           (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(1))
736ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_GRAYA_16          (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(2))
737ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_GRAYA_16_SE       (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(2)|ENDIAN16_SH(1))
738ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_GRAYA_8_PLANAR    (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(1)|PLANAR_SH(1))
739ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_GRAYA_16_PLANAR   (COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(2)|PLANAR_SH(1))
740ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
741ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_RGB_8             (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(1))
742ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_RGB_8_PLANAR      (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
743ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_BGR_8             (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1))
744ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_BGR_8_PLANAR      (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|PLANAR_SH(1))
745ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_RGB_16            (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2))
746ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_RGB_16_PLANAR     (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
747ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_RGB_16_SE         (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
748ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_BGR_16            (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1))
749ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_BGR_16_PLANAR     (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|PLANAR_SH(1))
750ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_BGR_16_SE         (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
751ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
752ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_RGBA_8            (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1))
753ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_RGBA_8_PLANAR     (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
754ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_RGBA_16           (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2))
755ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_RGBA_16_PLANAR    (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
756ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_RGBA_16_SE        (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
757ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
758ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_ARGB_8            (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|SWAPFIRST_SH(1))
759ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_ARGB_8_PLANAR     (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|SWAPFIRST_SH(1)|PLANAR_SH(1))
760ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_ARGB_16           (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|SWAPFIRST_SH(1))
761ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
762ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_ABGR_8            (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1))
763ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_ABGR_8_PLANAR     (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|PLANAR_SH(1))
764ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_ABGR_16           (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1))
765ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_ABGR_16_PLANAR    (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|PLANAR_SH(1))
766ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_ABGR_16_SE        (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
767ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
768ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_BGRA_8            (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1))
769ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#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))
770ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_BGRA_16           (COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1)|SWAPFIRST_SH(1))
771ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#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))
772ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
773ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMY_8             (COLORSPACE_SH(PT_CMY)|CHANNELS_SH(3)|BYTES_SH(1))
774ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMY_8_PLANAR      (COLORSPACE_SH(PT_CMY)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
775ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMY_16            (COLORSPACE_SH(PT_CMY)|CHANNELS_SH(3)|BYTES_SH(2))
776ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMY_16_PLANAR     (COLORSPACE_SH(PT_CMY)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
777ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMY_16_SE         (COLORSPACE_SH(PT_CMY)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
778ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
779ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK_8            (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1))
780ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYKA_8           (COLORSPACE_SH(PT_CMYK)|EXTRA_SH(1)|CHANNELS_SH(4)|BYTES_SH(1))
781ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK_8_REV        (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1)|FLAVOR_SH(1))
782ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_YUVK_8            TYPE_CMYK_8_REV
783ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK_8_PLANAR     (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1)|PLANAR_SH(1))
784ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK_16           (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2))
785ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK_16_REV       (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|FLAVOR_SH(1))
786ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_YUVK_16           TYPE_CMYK_16_REV
787ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK_16_PLANAR    (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|PLANAR_SH(1))
788ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK_16_SE        (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|ENDIAN16_SH(1))
789ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
790ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC_8            (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1)|DOSWAP_SH(1))
791ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC_16           (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|DOSWAP_SH(1))
792ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC_16_SE        (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
793ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
794ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KCMY_8            (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1)|SWAPFIRST_SH(1))
795ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KCMY_8_REV        (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(1)|FLAVOR_SH(1)|SWAPFIRST_SH(1))
796ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KCMY_16           (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|SWAPFIRST_SH(1))
797ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KCMY_16_REV       (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|FLAVOR_SH(1)|SWAPFIRST_SH(1))
798ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KCMY_16_SE        (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2)|ENDIAN16_SH(1)|SWAPFIRST_SH(1))
799ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
800ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK5_8           (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(1))
801ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK5_16          (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(2))
802ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK5_16_SE       (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(2)|ENDIAN16_SH(1))
803ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC5_8           (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(1)|DOSWAP_SH(1))
804ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC5_16          (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(2)|DOSWAP_SH(1))
805ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC5_16_SE       (COLORSPACE_SH(PT_MCH5)|CHANNELS_SH(5)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
806ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK6_8           (COLORSPACE_SH(PT_MCH6)|CHANNELS_SH(6)|BYTES_SH(1))
807ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK6_8_PLANAR    (COLORSPACE_SH(PT_MCH6)|CHANNELS_SH(6)|BYTES_SH(1)|PLANAR_SH(1))
808ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK6_16          (COLORSPACE_SH(PT_MCH6)|CHANNELS_SH(6)|BYTES_SH(2))
809ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK6_16_PLANAR   (COLORSPACE_SH(PT_MCH6)|CHANNELS_SH(6)|BYTES_SH(2)|PLANAR_SH(1))
810ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK6_16_SE       (COLORSPACE_SH(PT_MCH6)|CHANNELS_SH(6)|BYTES_SH(2)|ENDIAN16_SH(1))
811ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK7_8           (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(1))
812ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK7_16          (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(2))
813ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK7_16_SE       (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(2)|ENDIAN16_SH(1))
814ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC7_8           (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(1)|DOSWAP_SH(1))
815ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC7_16          (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(2)|DOSWAP_SH(1))
816ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC7_16_SE       (COLORSPACE_SH(PT_MCH7)|CHANNELS_SH(7)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
817ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK8_8           (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(1))
818ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK8_16          (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(2))
819ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK8_16_SE       (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(2)|ENDIAN16_SH(1))
820ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC8_8           (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(1)|DOSWAP_SH(1))
821ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC8_16          (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(2)|DOSWAP_SH(1))
822ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC8_16_SE       (COLORSPACE_SH(PT_MCH8)|CHANNELS_SH(8)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
823ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK9_8           (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(1))
824ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK9_16          (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(2))
825ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK9_16_SE       (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(2)|ENDIAN16_SH(1))
826ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC9_8           (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(1)|DOSWAP_SH(1))
827ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC9_16          (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(2)|DOSWAP_SH(1))
828ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC9_16_SE       (COLORSPACE_SH(PT_MCH9)|CHANNELS_SH(9)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
829ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK10_8          (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(1))
830ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK10_16         (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(2))
831ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK10_16_SE      (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(2)|ENDIAN16_SH(1))
832ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC10_8          (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(1)|DOSWAP_SH(1))
833ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC10_16         (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(2)|DOSWAP_SH(1))
834ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC10_16_SE      (COLORSPACE_SH(PT_MCH10)|CHANNELS_SH(10)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
835ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK11_8          (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(1))
836ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK11_16         (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(2))
837ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK11_16_SE      (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(2)|ENDIAN16_SH(1))
838ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC11_8          (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(1)|DOSWAP_SH(1))
839ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC11_16         (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(2)|DOSWAP_SH(1))
840ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC11_16_SE      (COLORSPACE_SH(PT_MCH11)|CHANNELS_SH(11)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
841ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK12_8          (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(1))
842ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK12_16         (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(2))
843ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK12_16_SE      (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(2)|ENDIAN16_SH(1))
844ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC12_8          (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(1)|DOSWAP_SH(1))
845ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC12_16         (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(2)|DOSWAP_SH(1))
846ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_KYMC12_16_SE      (COLORSPACE_SH(PT_MCH12)|CHANNELS_SH(12)|BYTES_SH(2)|DOSWAP_SH(1)|ENDIAN16_SH(1))
847ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
848ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Colorimetric
849ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_XYZ_16            (COLORSPACE_SH(PT_XYZ)|CHANNELS_SH(3)|BYTES_SH(2))
850ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_Lab_8             (COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(1))
851ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_LabV2_8           (COLORSPACE_SH(PT_LabV2)|CHANNELS_SH(3)|BYTES_SH(1))
852ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
853ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_ALab_8            (COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(1)|EXTRA_SH(1)|SWAPFIRST_SH(1))
854ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_ALabV2_8          (COLORSPACE_SH(PT_LabV2)|CHANNELS_SH(3)|BYTES_SH(1)|EXTRA_SH(1)|SWAPFIRST_SH(1))
855ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_Lab_16            (COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(2))
856ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_LabV2_16          (COLORSPACE_SH(PT_LabV2)|CHANNELS_SH(3)|BYTES_SH(2))
857ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_Yxy_16            (COLORSPACE_SH(PT_Yxy)|CHANNELS_SH(3)|BYTES_SH(2))
858ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
859ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// YCbCr
860ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_YCbCr_8           (COLORSPACE_SH(PT_YCbCr)|CHANNELS_SH(3)|BYTES_SH(1))
861ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_YCbCr_8_PLANAR    (COLORSPACE_SH(PT_YCbCr)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
862ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_YCbCr_16          (COLORSPACE_SH(PT_YCbCr)|CHANNELS_SH(3)|BYTES_SH(2))
863ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_YCbCr_16_PLANAR   (COLORSPACE_SH(PT_YCbCr)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
864ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_YCbCr_16_SE       (COLORSPACE_SH(PT_YCbCr)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
865ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
866ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// YUV
867ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_YUV_8             (COLORSPACE_SH(PT_YUV)|CHANNELS_SH(3)|BYTES_SH(1))
868ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_YUV_8_PLANAR      (COLORSPACE_SH(PT_YUV)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
869ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_YUV_16            (COLORSPACE_SH(PT_YUV)|CHANNELS_SH(3)|BYTES_SH(2))
870ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_YUV_16_PLANAR     (COLORSPACE_SH(PT_YUV)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
871ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_YUV_16_SE         (COLORSPACE_SH(PT_YUV)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
872ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
873ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// HLS
874ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_HLS_8             (COLORSPACE_SH(PT_HLS)|CHANNELS_SH(3)|BYTES_SH(1))
875ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_HLS_8_PLANAR      (COLORSPACE_SH(PT_HLS)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
876ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_HLS_16            (COLORSPACE_SH(PT_HLS)|CHANNELS_SH(3)|BYTES_SH(2))
877ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_HLS_16_PLANAR     (COLORSPACE_SH(PT_HLS)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
878ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_HLS_16_SE         (COLORSPACE_SH(PT_HLS)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
879ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
880ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// HSV
881ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_HSV_8             (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(1))
882ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_HSV_8_PLANAR      (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(1)|PLANAR_SH(1))
883ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_HSV_16            (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(2))
884ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_HSV_16_PLANAR     (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(2)|PLANAR_SH(1))
885ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_HSV_16_SE         (COLORSPACE_SH(PT_HSV)|CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1))
886ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
887ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Named color index. Only 16 bits allowed (don't check colorspace)
888ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_NAMED_COLOR_INDEX (CHANNELS_SH(1)|BYTES_SH(2))
889ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
890ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Float formatters.
891ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_XYZ_FLT          (FLOAT_SH(1)|COLORSPACE_SH(PT_XYZ)|CHANNELS_SH(3)|BYTES_SH(4))
892ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_Lab_FLT          (FLOAT_SH(1)|COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(4))
893ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_LabA_FLT         (FLOAT_SH(1)|COLORSPACE_SH(PT_Lab)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4))
894ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_GRAY_FLT         (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(4))
895ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_RGB_FLT          (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(4))
896ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
897ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_RGBA_FLT         (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4))
898ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_ARGB_FLT         (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(4)|SWAPFIRST_SH(1))
899ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_BGR_FLT          (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1))
900ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#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))
901ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_ABGR_FLT         (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(4)|DOSWAP_SH(1))
902ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
903ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK_FLT         (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(4))
904ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
905ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Floating point formatters.
906ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// NOTE THAT 'BYTES' FIELD IS SET TO ZERO ON DLB because 8 bytes overflows the bitfield
907ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_XYZ_DBL          (FLOAT_SH(1)|COLORSPACE_SH(PT_XYZ)|CHANNELS_SH(3)|BYTES_SH(0))
908ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_Lab_DBL          (FLOAT_SH(1)|COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(0))
909ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_GRAY_DBL         (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(0))
910ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_RGB_DBL          (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(0))
911ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_BGR_DBL          (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(0)|DOSWAP_SH(1))
912ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK_DBL         (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(0))
913ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
914ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// IEEE 754-2008 "half"
915ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_GRAY_HALF_FLT    (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(2))
916ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_RGB_HALF_FLT     (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2))
917ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_RGBA_HALF_FLT    (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2))
918ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_CMYK_HALF_FLT    (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(2))
919ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
920ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_RGBA_HALF_FLT    (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2))
921ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_ARGB_HALF_FLT    (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|EXTRA_SH(1)|CHANNELS_SH(3)|BYTES_SH(2)|SWAPFIRST_SH(1))
922ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_BGR_HALF_FLT     (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1))
923ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#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))
924ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define TYPE_ABGR_HALF_FLT    (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1))
925ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
926ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#endif
927ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
928ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Colorspaces
929ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef struct {
930ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsFloat64Number X;
931ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsFloat64Number Y;
932ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsFloat64Number Z;
933ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
934ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    } cmsCIEXYZ;
935ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
936ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef struct {
937ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsFloat64Number x;
938ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsFloat64Number y;
939ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsFloat64Number Y;
940ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
941ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    } cmsCIExyY;
942ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
943ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef struct {
944ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsFloat64Number L;
945ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsFloat64Number a;
946ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsFloat64Number b;
947ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
948ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    } cmsCIELab;
949ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
950ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef struct {
951ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsFloat64Number L;
952ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsFloat64Number C;
953ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsFloat64Number h;
954ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
955ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    } cmsCIELCh;
956ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
957ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef struct {
958ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsFloat64Number J;
959ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsFloat64Number C;
960ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsFloat64Number h;
961ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
962ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    } cmsJCh;
963ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
964ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef struct {
965ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsCIEXYZ  Red;
966ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsCIEXYZ  Green;
967ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsCIEXYZ  Blue;
968ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
969ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    } cmsCIEXYZTRIPLE;
970ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
971ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef struct {
972ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsCIExyY  Red;
973ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsCIExyY  Green;
974ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsCIExyY  Blue;
975ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
976ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    } cmsCIExyYTRIPLE;
977ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
978ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Illuminant types for structs below
979ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsILLUMINANT_TYPE_UNKNOWN 0x0000000
980ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsILLUMINANT_TYPE_D50     0x0000001
981ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsILLUMINANT_TYPE_D65     0x0000002
982ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsILLUMINANT_TYPE_D93     0x0000003
983ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsILLUMINANT_TYPE_F2      0x0000004
984ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsILLUMINANT_TYPE_D55     0x0000005
985ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsILLUMINANT_TYPE_A       0x0000006
986ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsILLUMINANT_TYPE_E       0x0000007
987ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsILLUMINANT_TYPE_F8      0x0000008
988ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
989ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef struct {
990ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsUInt32Number  Observer;    // 0 = unknown, 1=CIE 1931, 2=CIE 1964
991ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsCIEXYZ        Backing;     // Value of backing
992ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsUInt32Number  Geometry;    // 0=unknown, 1=45/0, 0/45 2=0d, d/0
993ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsFloat64Number Flare;       // 0..1.0
994ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsUInt32Number  IlluminantType;
995ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
996ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    } cmsICCMeasurementConditions;
997ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
998ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef struct {
999ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsCIEXYZ       IlluminantXYZ;   // Not the same struct as CAM02,
1000ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsCIEXYZ       SurroundXYZ;     // This is for storing the tag
1001ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov        cmsUInt32Number IlluminantType;  // viewing condition
1002ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1003ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    } cmsICCViewingConditions;
1004ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1005ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Support of non-standard functions --------------------------------------------------------------------------------------
1006ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1007ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI int               CMSEXPORT cmsstrcasecmp(const char* s1, const char* s2);
1008ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI long int          CMSEXPORT cmsfilelength(FILE* f);
1009ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1010ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1011ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Context handling --------------------------------------------------------------------------------------------------------
1012ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1013ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Each context holds its owns globals and its own plug-ins. There is a global context with the id = 0 for lecacy compatibility
1014ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// though using the global context is not recomended. Proper context handling makes lcms more thread-safe.
1015ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1016ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef struct _cmsContext_struct* cmsContext;
1017ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1018ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI cmsContext       CMSEXPORT cmsCreateContext(void* Plugin, void* UserData);
1019ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI void             CMSEXPORT cmsDeleteContext(cmsContext ContexID);
1020ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI cmsContext       CMSEXPORT cmsDupContext(cmsContext ContextID, void* NewUserData);
1021ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI void*            CMSEXPORT cmsGetContextUserData(cmsContext ContextID);
1022ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1023ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Plug-In registering  --------------------------------------------------------------------------------------------------
1024ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1025ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI cmsBool           CMSEXPORT cmsPlugin(void* Plugin);
1026ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI cmsBool           CMSEXPORT cmsPluginTHR(cmsContext ContextID, void* Plugin);
1027ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI void              CMSEXPORT cmsUnregisterPlugins(void);
1028ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI void              CMSEXPORT cmsUnregisterPluginsTHR(cmsContext ContextID);
1029ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1030ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Error logging ----------------------------------------------------------------------------------------------------------
1031ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1032ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// There is no error handling at all. When a function fails, it returns proper value.
1033ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// For example, all create functions does return NULL on failure. Other may return FALSE.
1034ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// It may be interesting, for the developer, to know why the function is failing.
1035ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// for that reason, lcms2 does offer a logging function. This function will get
1036ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// an ENGLISH string with some clues on what is going wrong. You can show this
1037ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// info to the end user if you wish, or just create some sort of log on disk.
1038ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// The logging function should NOT terminate the program, as this obviously can leave
1039ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// unfreed resources. It is the programmer's responsibility to check each function
1040ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// return code to make sure it didn't fail.
1041ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1042ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsERROR_UNDEFINED                    0
1043ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsERROR_FILE                         1
1044ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsERROR_RANGE                        2
1045ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsERROR_INTERNAL                     3
1046ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsERROR_NULL                         4
1047ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsERROR_READ                         5
1048ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsERROR_SEEK                         6
1049ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsERROR_WRITE                        7
1050ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsERROR_UNKNOWN_EXTENSION            8
1051ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsERROR_COLORSPACE_CHECK             9
1052ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsERROR_ALREADY_DEFINED              10
1053ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsERROR_BAD_SIGNATURE                11
1054ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsERROR_CORRUPTION_DETECTED          12
1055ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define cmsERROR_NOT_SUITABLE                 13
1056ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1057ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Error logger is called with the ContextID when a message is raised. This gives the
1058ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// chance to know which thread is responsible of the warning and any environment associated
1059ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// with it. Non-multithreading applications may safely ignore this parameter.
1060ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Note that under certain special circumstances, ContextID may be NULL.
1061ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef void  (* cmsLogErrorHandlerFunction)(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *Text);
1062ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1063ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Allows user to set any specific logger
1064ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI void              CMSEXPORT cmsSetLogErrorHandler(cmsLogErrorHandlerFunction Fn);
1065ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI void              CMSEXPORT cmsSetLogErrorHandlerTHR(cmsContext ContextID, cmsLogErrorHandlerFunction Fn);
1066ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1067ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Conversions --------------------------------------------------------------------------------------------------------------
1068ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1069ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Returns pointers to constant structs
1070ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI const cmsCIEXYZ*  CMSEXPORT cmsD50_XYZ(void);
1071ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI const cmsCIExyY*  CMSEXPORT cmsD50_xyY(void);
1072ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1073ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Colorimetric space conversions
1074ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI void              CMSEXPORT cmsXYZ2xyY(cmsCIExyY* Dest, const cmsCIEXYZ* Source);
1075ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI void              CMSEXPORT cmsxyY2XYZ(cmsCIEXYZ* Dest, const cmsCIExyY* Source);
1076ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI void              CMSEXPORT cmsXYZ2Lab(const cmsCIEXYZ* WhitePoint, cmsCIELab* Lab, const cmsCIEXYZ* xyz);
1077ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI void              CMSEXPORT cmsLab2XYZ(const cmsCIEXYZ* WhitePoint, cmsCIEXYZ* xyz, const cmsCIELab* Lab);
1078ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI void              CMSEXPORT cmsLab2LCh(cmsCIELCh*LCh, const cmsCIELab* Lab);
1079ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI void              CMSEXPORT cmsLCh2Lab(cmsCIELab* Lab, const cmsCIELCh* LCh);
1080ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1081ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Encoding /Decoding on PCS
1082ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI void              CMSEXPORT cmsLabEncoded2Float(cmsCIELab* Lab, const cmsUInt16Number wLab[3]);
1083ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI void              CMSEXPORT cmsLabEncoded2FloatV2(cmsCIELab* Lab, const cmsUInt16Number wLab[3]);
1084ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI void              CMSEXPORT cmsFloat2LabEncoded(cmsUInt16Number wLab[3], const cmsCIELab* Lab);
1085ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI void              CMSEXPORT cmsFloat2LabEncodedV2(cmsUInt16Number wLab[3], const cmsCIELab* Lab);
1086ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI void              CMSEXPORT cmsXYZEncoded2Float(cmsCIEXYZ* fxyz, const cmsUInt16Number XYZ[3]);
1087ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI void              CMSEXPORT cmsFloat2XYZEncoded(cmsUInt16Number XYZ[3], const cmsCIEXYZ* fXYZ);
1088ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1089ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// DeltaE metrics
1090ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI cmsFloat64Number  CMSEXPORT cmsDeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2);
1091ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI cmsFloat64Number  CMSEXPORT cmsCIE94DeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2);
1092ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI cmsFloat64Number  CMSEXPORT cmsBFDdeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2);
1093ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI cmsFloat64Number  CMSEXPORT cmsCMCdeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2, cmsFloat64Number l, cmsFloat64Number c);
1094ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI cmsFloat64Number  CMSEXPORT cmsCIE2000DeltaE(const cmsCIELab* Lab1, const cmsCIELab* Lab2, cmsFloat64Number Kl, cmsFloat64Number Kc, cmsFloat64Number Kh);
1095ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1096ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Temperature <-> Chromaticity (Black body)
1097ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI cmsBool           CMSEXPORT cmsWhitePointFromTemp(cmsCIExyY* WhitePoint, cmsFloat64Number  TempK);
1098ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI cmsBool           CMSEXPORT cmsTempFromWhitePoint(cmsFloat64Number* TempK, const cmsCIExyY* WhitePoint);
1099ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1100ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Chromatic adaptation
1101ee451cb395940862dad63c85adfe8f2fd55e864cSvet GanovCMSAPI cmsBool           CMSEXPORT cmsAdaptToIlluminant(cmsCIEXYZ* Result, const cmsCIEXYZ* SourceWhitePt,
1102ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov                                                                           const cmsCIEXYZ* Illuminant,
1103ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov                                                                           const cmsCIEXYZ* Value);
1104ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1105ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// CIECAM02 ---------------------------------------------------------------------------------------------------
1106ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1107ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// Viewing conditions. Please note those are CAM model viewing conditions, and not the ICC tag viewing
1108ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// conditions, which I'm naming cmsICCViewingConditions to make differences evident. Unfortunately, the tag
1109ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov// cannot deal with surround La, Yb and D value so is basically useless to store CAM02 viewing conditions.
1110ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1111ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1112ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define AVG_SURROUND       1
1113ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define DIM_SURROUND       2
1114ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define DARK_SURROUND      3
1115ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define CUTSHEET_SURROUND  4
1116ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1117ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov#define D_CALCULATE        (-1)
1118ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov
1119ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganovtypedef struct {
1120ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsCIEXYZ        whitePoint;
1121ee451cb395940862dad63c85adfe8f2fd55e864cSvet Ganov    cmsFloat64Number Yb;
1122