lcms2.h 105 KB

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