lcms2.h 103 KB

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