summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarti Maria <info@littlecms.com>2013-05-13 14:07:26 +0200
committerMarti Maria <info@littlecms.com>2013-05-13 14:07:26 +0200
commita558ac5483b7205a1ef74d9e5dde7b64516b3bfd (patch)
treee49296a81e4b0d120f97233a34f1e0531cf5a60a
parent861a932020b8da50328b44ad26e1f41fb1cc3191 (diff)
downloadlcms2-a558ac5483b7205a1ef74d9e5dde7b64516b3bfd.tar.gz
Remove ^M
-rw-r--r--[-rwxr-xr-x]autogen.sh0
-rw-r--r--[-rwxr-xr-x]config.guess0
-rw-r--r--[-rwxr-xr-x]config.sub0
-rw-r--r--[-rwxr-xr-x]configure0
-rw-r--r--[-rwxr-xr-x]depcomp0
-rw-r--r--[-rwxr-xr-x]install-sh0
-rw-r--r--[-rwxr-xr-x]ltmain.sh0
-rw-r--r--[-rwxr-xr-x]missing0
-rw-r--r--src/cmsgmt.c1180
-rw-r--r--[-rwxr-xr-x]src/cmshalf.c0
-rw-r--r--src/cmsintrp.c2988
-rw-r--r--src/lcms2.def650
-rw-r--r--utils/common/vprf.c666
-rw-r--r--[-rwxr-xr-x]utils/delphi/delphidemo.dpr26
-rw-r--r--[-rwxr-xr-x]utils/delphi/delphidemo.dproj228
-rw-r--r--[-rwxr-xr-x]utils/delphi/demo1.pas644
-rw-r--r--[-rwxr-xr-x]utils/delphi/lcms2dll.pas4222
-rw-r--r--utils/jpgicc/jpgicc.c2536
-rw-r--r--[-rwxr-xr-x]utils/matlab/icctrans.c16
-rw-r--r--[-rwxr-xr-x]utils/matlab/lcms_rsp0
-rw-r--r--[-rwxr-xr-x]utils/samples/vericc.c0
21 files changed, 6578 insertions, 6578 deletions
diff --git a/autogen.sh b/autogen.sh
index 5c62310..5c62310 100755..100644
--- a/autogen.sh
+++ b/autogen.sh
diff --git a/config.guess b/config.guess
index dc84c68..dc84c68 100755..100644
--- a/config.guess
+++ b/config.guess
diff --git a/config.sub b/config.sub
index 2a55a50..2a55a50 100755..100644
--- a/config.sub
+++ b/config.sub
diff --git a/configure b/configure
index f2c2e59..f2c2e59 100755..100644
--- a/configure
+++ b/configure
diff --git a/depcomp b/depcomp
index 11e2d3b..11e2d3b 100755..100644
--- a/depcomp
+++ b/depcomp
diff --git a/install-sh b/install-sh
index 6781b98..6781b98 100755..100644
--- a/install-sh
+++ b/install-sh
diff --git a/ltmain.sh b/ltmain.sh
index fcebbcb..fcebbcb 100755..100644
--- a/ltmain.sh
+++ b/ltmain.sh
diff --git a/missing b/missing
index 64b5f90..64b5f90 100755..100644
--- a/missing
+++ b/missing
diff --git a/src/cmsgmt.c b/src/cmsgmt.c
index ea977d0..2966f0c 100644
--- a/src/cmsgmt.c
+++ b/src/cmsgmt.c
@@ -1,590 +1,590 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2012 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-
-// Auxiliar: append a Lab identity after the given sequence of profiles
-// and return the transform. Lab profile is closed, rest of profiles are kept open.
-cmsHTRANSFORM _cmsChain2Lab(cmsContext ContextID,
- cmsUInt32Number nProfiles,
- cmsUInt32Number InputFormat,
- cmsUInt32Number OutputFormat,
- const cmsUInt32Number Intents[],
- const cmsHPROFILE hProfiles[],
- const cmsBool BPC[],
- const cmsFloat64Number AdaptationStates[],
- cmsUInt32Number dwFlags)
-{
- cmsHTRANSFORM xform;
- cmsHPROFILE hLab;
- cmsHPROFILE ProfileList[256];
- cmsBool BPCList[256];
- cmsFloat64Number AdaptationList[256];
- cmsUInt32Number IntentList[256];
- cmsUInt32Number i;
-
- // This is a rather big number and there is no need of dynamic memory
- // since we are adding a profile, 254 + 1 = 255 and this is the limit
- if (nProfiles > 254) return NULL;
-
- // The output space
- hLab = cmsCreateLab4ProfileTHR(ContextID, NULL);
- if (hLab == NULL) return NULL;
-
- // Create a copy of parameters
- for (i=0; i < nProfiles; i++) {
-
- ProfileList[i] = hProfiles[i];
- BPCList[i] = BPC[i];
- AdaptationList[i] = AdaptationStates[i];
- IntentList[i] = Intents[i];
- }
-
- // Place Lab identity at chain's end.
- ProfileList[nProfiles] = hLab;
- BPCList[nProfiles] = 0;
- AdaptationList[nProfiles] = 1.0;
- IntentList[nProfiles] = INTENT_RELATIVE_COLORIMETRIC;
-
- // Create the transform
- xform = cmsCreateExtendedTransform(ContextID, nProfiles + 1, ProfileList,
- BPCList,
- IntentList,
- AdaptationList,
- NULL, 0,
- InputFormat,
- OutputFormat,
- dwFlags);
-
- cmsCloseProfile(hLab);
-
- return xform;
-}
-
-
-// Compute K -> L* relationship. Flags may include black point compensation. In this case,
-// the relationship is assumed from the profile with BPC to a black point zero.
-static
-cmsToneCurve* ComputeKToLstar(cmsContext ContextID,
- cmsUInt32Number nPoints,
- cmsUInt32Number nProfiles,
- const cmsUInt32Number Intents[],
- const cmsHPROFILE hProfiles[],
- const cmsBool BPC[],
- const cmsFloat64Number AdaptationStates[],
- cmsUInt32Number dwFlags)
-{
- cmsToneCurve* out = NULL;
- cmsUInt32Number i;
- cmsHTRANSFORM xform;
- cmsCIELab Lab;
- cmsFloat32Number cmyk[4];
- cmsFloat32Number* SampledPoints;
-
- xform = _cmsChain2Lab(ContextID, nProfiles, TYPE_CMYK_FLT, TYPE_Lab_DBL, Intents, hProfiles, BPC, AdaptationStates, dwFlags);
- if (xform == NULL) return NULL;
-
- SampledPoints = (cmsFloat32Number*) _cmsCalloc(ContextID, nPoints, sizeof(cmsFloat32Number));
- if (SampledPoints == NULL) goto Error;
-
- for (i=0; i < nPoints; i++) {
-
- cmyk[0] = 0;
- cmyk[1] = 0;
- cmyk[2] = 0;
- cmyk[3] = (cmsFloat32Number) ((i * 100.0) / (nPoints-1));
-
- cmsDoTransform(xform, cmyk, &Lab, 1);
- SampledPoints[i]= (cmsFloat32Number) (1.0 - Lab.L / 100.0); // Negate K for easier operation
- }
-
- out = cmsBuildTabulatedToneCurveFloat(ContextID, nPoints, SampledPoints);
-
-Error:
-
- cmsDeleteTransform(xform);
- if (SampledPoints) _cmsFree(ContextID, SampledPoints);
-
- return out;
-}
-
-
-// Compute Black tone curve on a CMYK -> CMYK transform. This is done by
-// using the proof direction on both profiles to find K->L* relationship
-// then joining both curves. dwFlags may include black point compensation.
-cmsToneCurve* _cmsBuildKToneCurve(cmsContext ContextID,
- cmsUInt32Number nPoints,
- cmsUInt32Number nProfiles,
- const cmsUInt32Number Intents[],
- const cmsHPROFILE hProfiles[],
- const cmsBool BPC[],
- const cmsFloat64Number AdaptationStates[],
- cmsUInt32Number dwFlags)
-{
- cmsToneCurve *in, *out, *KTone;
-
- // Make sure CMYK -> CMYK
- if (cmsGetColorSpace(hProfiles[0]) != cmsSigCmykData ||
- cmsGetColorSpace(hProfiles[nProfiles-1])!= cmsSigCmykData) return NULL;
-
-
- // Make sure last is an output profile
- if (cmsGetDeviceClass(hProfiles[nProfiles - 1]) != cmsSigOutputClass) return NULL;
-
- // Create individual curves. BPC works also as each K to L* is
- // computed as a BPC to zero black point in case of L*
- in = ComputeKToLstar(ContextID, nPoints, nProfiles - 1, Intents, hProfiles, BPC, AdaptationStates, dwFlags);
- if (in == NULL) return NULL;
-
- out = ComputeKToLstar(ContextID, nPoints, 1,
- Intents + (nProfiles - 1),
- hProfiles + (nProfiles - 1),
- BPC + (nProfiles - 1),
- AdaptationStates + (nProfiles - 1),
- dwFlags);
- if (out == NULL) {
- cmsFreeToneCurve(in);
- return NULL;
- }
-
- // Build the relationship. This effectively limits the maximum accuracy to 16 bits, but
- // since this is used on black-preserving LUTs, we are not loosing accuracy in any case
- KTone = cmsJoinToneCurve(ContextID, in, out, nPoints);
-
- // Get rid of components
- cmsFreeToneCurve(in); cmsFreeToneCurve(out);
-
- // Something went wrong...
- if (KTone == NULL) return NULL;
-
- // Make sure it is monotonic
- if (!cmsIsToneCurveMonotonic(KTone)) {
- cmsFreeToneCurve(KTone);
- return NULL;
- }
-
- return KTone;
-}
-
-
-// Gamut LUT Creation -----------------------------------------------------------------------------------------
-
-// Used by gamut & softproofing
-
-typedef struct {
-
- cmsHTRANSFORM hInput; // From whatever input color space. 16 bits to DBL
- cmsHTRANSFORM hForward, hReverse; // Transforms going from Lab to colorant and back
- cmsFloat64Number Thereshold; // The thereshold after which is considered out of gamut
-
- } GAMUTCHAIN;
-
-// This sampler does compute gamut boundaries by comparing original
-// values with a transform going back and forth. Values above ERR_THERESHOLD
-// of maximum are considered out of gamut.
-
-#define ERR_THERESHOLD 5
-
-
-static
-int GamutSampler(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
-{
- GAMUTCHAIN* t = (GAMUTCHAIN* ) Cargo;
- cmsCIELab LabIn1, LabOut1;
- cmsCIELab LabIn2, LabOut2;
- cmsUInt16Number Proof[cmsMAXCHANNELS], Proof2[cmsMAXCHANNELS];
- cmsFloat64Number dE1, dE2, ErrorRatio;
-
- // Assume in-gamut by default.
- ErrorRatio = 1.0;
-
- // Convert input to Lab
- cmsDoTransform(t -> hInput, In, &LabIn1, 1);
-
- // converts from PCS to colorant. This always
- // does return in-gamut values,
- cmsDoTransform(t -> hForward, &LabIn1, Proof, 1);
-
- // Now, do the inverse, from colorant to PCS.
- cmsDoTransform(t -> hReverse, Proof, &LabOut1, 1);
-
- memmove(&LabIn2, &LabOut1, sizeof(cmsCIELab));
-
- // Try again, but this time taking Check as input
- cmsDoTransform(t -> hForward, &LabOut1, Proof2, 1);
- cmsDoTransform(t -> hReverse, Proof2, &LabOut2, 1);
-
- // Take difference of direct value
- dE1 = cmsDeltaE(&LabIn1, &LabOut1);
-
- // Take difference of converted value
- dE2 = cmsDeltaE(&LabIn2, &LabOut2);
-
-
- // if dE1 is small and dE2 is small, value is likely to be in gamut
- if (dE1 < t->Thereshold && dE2 < t->Thereshold)
- Out[0] = 0;
- else {
-
- // if dE1 is small and dE2 is big, undefined. Assume in gamut
- if (dE1 < t->Thereshold && dE2 > t->Thereshold)
- Out[0] = 0;
- else
- // dE1 is big and dE2 is small, clearly out of gamut
- if (dE1 > t->Thereshold && dE2 < t->Thereshold)
- Out[0] = (cmsUInt16Number) _cmsQuickFloor((dE1 - t->Thereshold) + .5);
- else {
-
- // dE1 is big and dE2 is also big, could be due to perceptual mapping
- // so take error ratio
- if (dE2 == 0.0)
- ErrorRatio = dE1;
- else
- ErrorRatio = dE1 / dE2;
-
- if (ErrorRatio > t->Thereshold)
- Out[0] = (cmsUInt16Number) _cmsQuickFloor((ErrorRatio - t->Thereshold) + .5);
- else
- Out[0] = 0;
- }
- }
-
-
- return TRUE;
-}
-
-// Does compute a gamut LUT going back and forth across pcs -> relativ. colorimetric intent -> pcs
-// the dE obtained is then annotated on the LUT. Values truely out of gamut are clipped to dE = 0xFFFE
-// and values changed are supposed to be handled by any gamut remapping, so, are out of gamut as well.
-//
-// **WARNING: This algorithm does assume that gamut remapping algorithms does NOT move in-gamut colors,
-// of course, many perceptual and saturation intents does not work in such way, but relativ. ones should.
-
-cmsPipeline* _cmsCreateGamutCheckPipeline(cmsContext ContextID,
- cmsHPROFILE hProfiles[],
- cmsBool BPC[],
- cmsUInt32Number Intents[],
- cmsFloat64Number AdaptationStates[],
- cmsUInt32Number nGamutPCSposition,
- cmsHPROFILE hGamut)
-{
- cmsHPROFILE hLab;
- cmsPipeline* Gamut;
- cmsStage* CLUT;
- cmsUInt32Number dwFormat;
- GAMUTCHAIN Chain;
- int nChannels, nGridpoints;
- cmsColorSpaceSignature ColorSpace;
- cmsUInt32Number i;
- cmsHPROFILE ProfileList[256];
- cmsBool BPCList[256];
- cmsFloat64Number AdaptationList[256];
- cmsUInt32Number IntentList[256];
-
- memset(&Chain, 0, sizeof(GAMUTCHAIN));
-
-
- if (nGamutPCSposition <= 0 || nGamutPCSposition > 255) {
- cmsSignalError(ContextID, cmsERROR_RANGE, "Wrong position of PCS. 1..255 expected, %d found.", nGamutPCSposition);
- return NULL;
- }
-
- hLab = cmsCreateLab4ProfileTHR(ContextID, NULL);
- if (hLab == NULL) return NULL;
-
-
- // The figure of merit. On matrix-shaper profiles, should be almost zero as
- // the conversion is pretty exact. On LUT based profiles, different resolutions
- // of input and output CLUT may result in differences.
-
- if (cmsIsMatrixShaper(hGamut)) {
-
- Chain.Thereshold = 1.0;
- }
- else {
- Chain.Thereshold = ERR_THERESHOLD;
- }
-
-
- // Create a copy of parameters
- for (i=0; i < nGamutPCSposition; i++) {
- ProfileList[i] = hProfiles[i];
- BPCList[i] = BPC[i];
- AdaptationList[i] = AdaptationStates[i];
- IntentList[i] = Intents[i];
- }
-
- // Fill Lab identity
- ProfileList[nGamutPCSposition] = hLab;
- BPCList[nGamutPCSposition] = 0;
- AdaptationList[nGamutPCSposition] = 1.0;
- IntentList[nGamutPCSposition] = INTENT_RELATIVE_COLORIMETRIC;
-
-
- ColorSpace = cmsGetColorSpace(hGamut);
-
- nChannels = cmsChannelsOf(ColorSpace);
- nGridpoints = _cmsReasonableGridpointsByColorspace(ColorSpace, cmsFLAGS_HIGHRESPRECALC);
- dwFormat = (CHANNELS_SH(nChannels)|BYTES_SH(2));
-
- // 16 bits to Lab double
- Chain.hInput = cmsCreateExtendedTransform(ContextID,
- nGamutPCSposition + 1,
- ProfileList,
- BPCList,
- IntentList,
- AdaptationList,
- NULL, 0,
- dwFormat, TYPE_Lab_DBL,
- cmsFLAGS_NOCACHE);
-
-
- // Does create the forward step. Lab double to device
- dwFormat = (CHANNELS_SH(nChannels)|BYTES_SH(2));
- Chain.hForward = cmsCreateTransformTHR(ContextID,
- hLab, TYPE_Lab_DBL,
- hGamut, dwFormat,
- INTENT_RELATIVE_COLORIMETRIC,
- cmsFLAGS_NOCACHE);
-
- // Does create the backwards step
- Chain.hReverse = cmsCreateTransformTHR(ContextID, hGamut, dwFormat,
- hLab, TYPE_Lab_DBL,
- INTENT_RELATIVE_COLORIMETRIC,
- cmsFLAGS_NOCACHE);
-
-
- // All ok?
- if (Chain.hInput && Chain.hForward && Chain.hReverse) {
-
- // Go on, try to compute gamut LUT from PCS. This consist on a single channel containing
- // dE when doing a transform back and forth on the colorimetric intent.
-
- Gamut = cmsPipelineAlloc(ContextID, 3, 1);
- if (Gamut != NULL) {
-
- CLUT = cmsStageAllocCLut16bit(ContextID, nGridpoints, nChannels, 1, NULL);
- if (!cmsPipelineInsertStage(Gamut, cmsAT_BEGIN, CLUT)) {
- cmsPipelineFree(Gamut);
- Gamut = NULL;
- }
- else {
- cmsStageSampleCLut16bit(CLUT, GamutSampler, (void*) &Chain, 0);
- }
- }
- }
- else
- Gamut = NULL; // Didn't work...
-
- // Free all needed stuff.
- if (Chain.hInput) cmsDeleteTransform(Chain.hInput);
- if (Chain.hForward) cmsDeleteTransform(Chain.hForward);
- if (Chain.hReverse) cmsDeleteTransform(Chain.hReverse);
- if (hLab) cmsCloseProfile(hLab);
-
- // And return computed hull
- return Gamut;
-}
-
-// Total Area Coverage estimation ----------------------------------------------------------------
-
-typedef struct {
- cmsUInt32Number nOutputChans;
- cmsHTRANSFORM hRoundTrip;
- cmsFloat32Number MaxTAC;
- cmsFloat32Number MaxInput[cmsMAXCHANNELS];
-
-} cmsTACestimator;
-
-
-// This callback just accounts the maximum ink dropped in the given node. It does not populate any
-// memory, as the destination table is NULL. Its only purpose it to know the global maximum.
-static
-int EstimateTAC(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void * Cargo)
-{
- cmsTACestimator* bp = (cmsTACestimator*) Cargo;
- cmsFloat32Number RoundTrip[cmsMAXCHANNELS];
- cmsUInt32Number i;
- cmsFloat32Number Sum;
-
-
- // Evaluate the xform
- cmsDoTransform(bp->hRoundTrip, In, RoundTrip, 1);
-
- // All all amounts of ink
- for (Sum=0, i=0; i < bp ->nOutputChans; i++)
- Sum += RoundTrip[i];
-
- // If above maximum, keep track of input values
- if (Sum > bp ->MaxTAC) {
-
- bp ->MaxTAC = Sum;
-
- for (i=0; i < bp ->nOutputChans; i++) {
- bp ->MaxInput[i] = In[i];
- }
- }
-
- return TRUE;
-
- cmsUNUSED_PARAMETER(Out);
-}
-
-
-// Detect Total area coverage of the profile
-cmsFloat64Number CMSEXPORT cmsDetectTAC(cmsHPROFILE hProfile)
-{
- cmsTACestimator bp;
- cmsUInt32Number dwFormatter;
- cmsUInt32Number GridPoints[MAX_INPUT_DIMENSIONS];
- cmsHPROFILE hLab;
- cmsContext ContextID = cmsGetProfileContextID(hProfile);
-
- // TAC only works on output profiles
- if (cmsGetDeviceClass(hProfile) != cmsSigOutputClass) {
- return 0;
- }
-
- // Create a fake formatter for result
- dwFormatter = cmsFormatterForColorspaceOfProfile(hProfile, 4, TRUE);
-
- bp.nOutputChans = T_CHANNELS(dwFormatter);
- bp.MaxTAC = 0; // Initial TAC is 0
-
- // for safety
- if (bp.nOutputChans >= cmsMAXCHANNELS) return 0;
-
- hLab = cmsCreateLab4ProfileTHR(ContextID, NULL);
- if (hLab == NULL) return 0;
- // Setup a roundtrip on perceptual intent in output profile for TAC estimation
- bp.hRoundTrip = cmsCreateTransformTHR(ContextID, hLab, TYPE_Lab_16,
- hProfile, dwFormatter, INTENT_PERCEPTUAL, cmsFLAGS_NOOPTIMIZE|cmsFLAGS_NOCACHE);
-
- cmsCloseProfile(hLab);
- if (bp.hRoundTrip == NULL) return 0;
-
- // For L* we only need black and white. For C* we need many points
- GridPoints[0] = 6;
- GridPoints[1] = 74;
- GridPoints[2] = 74;
-
-
- if (!cmsSliceSpace16(3, GridPoints, EstimateTAC, &bp)) {
- bp.MaxTAC = 0;
- }
-
- cmsDeleteTransform(bp.hRoundTrip);
-
- // Results in %
- return bp.MaxTAC;
-}
-
-
-// Carefully, clamp on CIELab space.
-
-cmsBool CMSEXPORT cmsDesaturateLab(cmsCIELab* Lab,
- double amax, double amin,
- double bmax, double bmin)
-{
-
- // Whole Luma surface to zero
-
- if (Lab -> L < 0) {
-
- Lab-> L = Lab->a = Lab-> b = 0.0;
- return FALSE;
- }
-
- // Clamp white, DISCARD HIGHLIGHTS. This is done
- // in such way because icc spec doesn't allow the
- // use of L>100 as a highlight means.
-
- if (Lab->L > 100)
- Lab -> L = 100;
-
- // Check out gamut prism, on a, b faces
-
- if (Lab -> a < amin || Lab->a > amax||
- Lab -> b < bmin || Lab->b > bmax) {
-
- cmsCIELCh LCh;
- double h, slope;
-
- // Falls outside a, b limits. Transports to LCh space,
- // and then do the clipping
-
-
- if (Lab -> a == 0.0) { // Is hue exactly 90?
-
- // atan will not work, so clamp here
- Lab -> b = Lab->b < 0 ? bmin : bmax;
- return TRUE;
- }
-
- cmsLab2LCh(&LCh, Lab);
-
- slope = Lab -> b / Lab -> a;
- h = LCh.h;
-
- // There are 4 zones
-
- if ((h >= 0. && h < 45.) ||
- (h >= 315 && h <= 360.)) {
-
- // clip by amax
- Lab -> a = amax;
- Lab -> b = amax * slope;
- }
- else
- if (h >= 45. && h < 135.)
- {
- // clip by bmax
- Lab -> b = bmax;
- Lab -> a = bmax / slope;
- }
- else
- if (h >= 135. && h < 225.) {
- // clip by amin
- Lab -> a = amin;
- Lab -> b = amin * slope;
-
- }
- else
- if (h >= 225. && h < 315.) {
- // clip by bmin
- Lab -> b = bmin;
- Lab -> a = bmin / slope;
- }
- else {
- cmsSignalError(0, cmsERROR_RANGE, "Invalid angle");
- return FALSE;
- }
-
- }
-
- return TRUE;
-}
+//---------------------------------------------------------------------------------
+//
+// Little Color Management System
+// Copyright (c) 1998-2012 Marti Maria Saguer
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the Software
+// is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//---------------------------------------------------------------------------------
+//
+
+#include "lcms2_internal.h"
+
+
+// Auxiliar: append a Lab identity after the given sequence of profiles
+// and return the transform. Lab profile is closed, rest of profiles are kept open.
+cmsHTRANSFORM _cmsChain2Lab(cmsContext ContextID,
+ cmsUInt32Number nProfiles,
+ cmsUInt32Number InputFormat,
+ cmsUInt32Number OutputFormat,
+ const cmsUInt32Number Intents[],
+ const cmsHPROFILE hProfiles[],
+ const cmsBool BPC[],
+ const cmsFloat64Number AdaptationStates[],
+ cmsUInt32Number dwFlags)
+{
+ cmsHTRANSFORM xform;
+ cmsHPROFILE hLab;
+ cmsHPROFILE ProfileList[256];
+ cmsBool BPCList[256];
+ cmsFloat64Number AdaptationList[256];
+ cmsUInt32Number IntentList[256];
+ cmsUInt32Number i;
+
+ // This is a rather big number and there is no need of dynamic memory
+ // since we are adding a profile, 254 + 1 = 255 and this is the limit
+ if (nProfiles > 254) return NULL;
+
+ // The output space
+ hLab = cmsCreateLab4ProfileTHR(ContextID, NULL);
+ if (hLab == NULL) return NULL;
+
+ // Create a copy of parameters
+ for (i=0; i < nProfiles; i++) {
+
+ ProfileList[i] = hProfiles[i];
+ BPCList[i] = BPC[i];
+ AdaptationList[i] = AdaptationStates[i];
+ IntentList[i] = Intents[i];
+ }
+
+ // Place Lab identity at chain's end.
+ ProfileList[nProfiles] = hLab;
+ BPCList[nProfiles] = 0;
+ AdaptationList[nProfiles] = 1.0;
+ IntentList[nProfiles] = INTENT_RELATIVE_COLORIMETRIC;
+
+ // Create the transform
+ xform = cmsCreateExtendedTransform(ContextID, nProfiles + 1, ProfileList,
+ BPCList,
+ IntentList,
+ AdaptationList,
+ NULL, 0,
+ InputFormat,
+ OutputFormat,
+ dwFlags);
+
+ cmsCloseProfile(hLab);
+
+ return xform;
+}
+
+
+// Compute K -> L* relationship. Flags may include black point compensation. In this case,
+// the relationship is assumed from the profile with BPC to a black point zero.
+static
+cmsToneCurve* ComputeKToLstar(cmsContext ContextID,
+ cmsUInt32Number nPoints,
+ cmsUInt32Number nProfiles,
+ const cmsUInt32Number Intents[],
+ const cmsHPROFILE hProfiles[],
+ const cmsBool BPC[],
+ const cmsFloat64Number AdaptationStates[],
+ cmsUInt32Number dwFlags)
+{
+ cmsToneCurve* out = NULL;
+ cmsUInt32Number i;
+ cmsHTRANSFORM xform;
+ cmsCIELab Lab;
+ cmsFloat32Number cmyk[4];
+ cmsFloat32Number* SampledPoints;
+
+ xform = _cmsChain2Lab(ContextID, nProfiles, TYPE_CMYK_FLT, TYPE_Lab_DBL, Intents, hProfiles, BPC, AdaptationStates, dwFlags);
+ if (xform == NULL) return NULL;
+
+ SampledPoints = (cmsFloat32Number*) _cmsCalloc(ContextID, nPoints, sizeof(cmsFloat32Number));
+ if (SampledPoints == NULL) goto Error;
+
+ for (i=0; i < nPoints; i++) {
+
+ cmyk[0] = 0;
+ cmyk[1] = 0;
+ cmyk[2] = 0;
+ cmyk[3] = (cmsFloat32Number) ((i * 100.0) / (nPoints-1));
+
+ cmsDoTransform(xform, cmyk, &Lab, 1);
+ SampledPoints[i]= (cmsFloat32Number) (1.0 - Lab.L / 100.0); // Negate K for easier operation
+ }
+
+ out = cmsBuildTabulatedToneCurveFloat(ContextID, nPoints, SampledPoints);
+
+Error:
+
+ cmsDeleteTransform(xform);
+ if (SampledPoints) _cmsFree(ContextID, SampledPoints);
+
+ return out;
+}
+
+
+// Compute Black tone curve on a CMYK -> CMYK transform. This is done by
+// using the proof direction on both profiles to find K->L* relationship
+// then joining both curves. dwFlags may include black point compensation.
+cmsToneCurve* _cmsBuildKToneCurve(cmsContext ContextID,
+ cmsUInt32Number nPoints,
+ cmsUInt32Number nProfiles,
+ const cmsUInt32Number Intents[],
+ const cmsHPROFILE hProfiles[],
+ const cmsBool BPC[],
+ const cmsFloat64Number AdaptationStates[],
+ cmsUInt32Number dwFlags)
+{
+ cmsToneCurve *in, *out, *KTone;
+
+ // Make sure CMYK -> CMYK
+ if (cmsGetColorSpace(hProfiles[0]) != cmsSigCmykData ||
+ cmsGetColorSpace(hProfiles[nProfiles-1])!= cmsSigCmykData) return NULL;
+
+
+ // Make sure last is an output profile
+ if (cmsGetDeviceClass(hProfiles[nProfiles - 1]) != cmsSigOutputClass) return NULL;
+
+ // Create individual curves. BPC works also as each K to L* is
+ // computed as a BPC to zero black point in case of L*
+ in = ComputeKToLstar(ContextID, nPoints, nProfiles - 1, Intents, hProfiles, BPC, AdaptationStates, dwFlags);
+ if (in == NULL) return NULL;
+
+ out = ComputeKToLstar(ContextID, nPoints, 1,
+ Intents + (nProfiles - 1),
+ hProfiles + (nProfiles - 1),
+ BPC + (nProfiles - 1),
+ AdaptationStates + (nProfiles - 1),
+ dwFlags);
+ if (out == NULL) {
+ cmsFreeToneCurve(in);
+ return NULL;
+ }
+
+ // Build the relationship. This effectively limits the maximum accuracy to 16 bits, but
+ // since this is used on black-preserving LUTs, we are not loosing accuracy in any case
+ KTone = cmsJoinToneCurve(ContextID, in, out, nPoints);
+
+ // Get rid of components
+ cmsFreeToneCurve(in); cmsFreeToneCurve(out);
+
+ // Something went wrong...
+ if (KTone == NULL) return NULL;
+
+ // Make sure it is monotonic
+ if (!cmsIsToneCurveMonotonic(KTone)) {
+ cmsFreeToneCurve(KTone);
+ return NULL;
+ }
+
+ return KTone;
+}
+
+
+// Gamut LUT Creation -----------------------------------------------------------------------------------------
+
+// Used by gamut & softproofing
+
+typedef struct {
+
+ cmsHTRANSFORM hInput; // From whatever input color space. 16 bits to DBL
+ cmsHTRANSFORM hForward, hReverse; // Transforms going from Lab to colorant and back
+ cmsFloat64Number Thereshold; // The thereshold after which is considered out of gamut
+
+ } GAMUTCHAIN;
+
+// This sampler does compute gamut boundaries by comparing original
+// values with a transform going back and forth. Values above ERR_THERESHOLD
+// of maximum are considered out of gamut.
+
+#define ERR_THERESHOLD 5
+
+
+static
+int GamutSampler(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
+{
+ GAMUTCHAIN* t = (GAMUTCHAIN* ) Cargo;
+ cmsCIELab LabIn1, LabOut1;
+ cmsCIELab LabIn2, LabOut2;
+ cmsUInt16Number Proof[cmsMAXCHANNELS], Proof2[cmsMAXCHANNELS];
+ cmsFloat64Number dE1, dE2, ErrorRatio;
+
+ // Assume in-gamut by default.
+ ErrorRatio = 1.0;
+
+ // Convert input to Lab
+ cmsDoTransform(t -> hInput, In, &LabIn1, 1);
+
+ // converts from PCS to colorant. This always
+ // does return in-gamut values,
+ cmsDoTransform(t -> hForward, &LabIn1, Proof, 1);
+
+ // Now, do the inverse, from colorant to PCS.
+ cmsDoTransform(t -> hReverse, Proof, &LabOut1, 1);
+
+ memmove(&LabIn2, &LabOut1, sizeof(cmsCIELab));
+
+ // Try again, but this time taking Check as input
+ cmsDoTransform(t -> hForward, &LabOut1, Proof2, 1);
+ cmsDoTransform(t -> hReverse, Proof2, &LabOut2, 1);
+
+ // Take difference of direct value
+ dE1 = cmsDeltaE(&LabIn1, &LabOut1);
+
+ // Take difference of converted value
+ dE2 = cmsDeltaE(&LabIn2, &LabOut2);
+
+
+ // if dE1 is small and dE2 is small, value is likely to be in gamut
+ if (dE1 < t->Thereshold && dE2 < t->Thereshold)
+ Out[0] = 0;
+ else {
+
+ // if dE1 is small and dE2 is big, undefined. Assume in gamut
+ if (dE1 < t->Thereshold && dE2 > t->Thereshold)
+ Out[0] = 0;
+ else
+ // dE1 is big and dE2 is small, clearly out of gamut
+ if (dE1 > t->Thereshold && dE2 < t->Thereshold)
+ Out[0] = (cmsUInt16Number) _cmsQuickFloor((dE1 - t->Thereshold) + .5);
+ else {
+
+ // dE1 is big and dE2 is also big, could be due to perceptual mapping
+ // so take error ratio
+ if (dE2 == 0.0)
+ ErrorRatio = dE1;
+ else
+ ErrorRatio = dE1 / dE2;
+
+ if (ErrorRatio > t->Thereshold)
+ Out[0] = (cmsUInt16Number) _cmsQuickFloor((ErrorRatio - t->Thereshold) + .5);
+ else
+ Out[0] = 0;
+ }
+ }
+
+
+ return TRUE;
+}
+
+// Does compute a gamut LUT going back and forth across pcs -> relativ. colorimetric intent -> pcs
+// the dE obtained is then annotated on the LUT. Values truely out of gamut are clipped to dE = 0xFFFE
+// and values changed are supposed to be handled by any gamut remapping, so, are out of gamut as well.
+//
+// **WARNING: This algorithm does assume that gamut remapping algorithms does NOT move in-gamut colors,
+// of course, many perceptual and saturation intents does not work in such way, but relativ. ones should.
+
+cmsPipeline* _cmsCreateGamutCheckPipeline(cmsContext ContextID,
+ cmsHPROFILE hProfiles[],
+ cmsBool BPC[],
+ cmsUInt32Number Intents[],
+ cmsFloat64Number AdaptationStates[],
+ cmsUInt32Number nGamutPCSposition,
+ cmsHPROFILE hGamut)
+{
+ cmsHPROFILE hLab;
+ cmsPipeline* Gamut;
+ cmsStage* CLUT;
+ cmsUInt32Number dwFormat;
+ GAMUTCHAIN Chain;
+ int nChannels, nGridpoints;
+ cmsColorSpaceSignature ColorSpace;
+ cmsUInt32Number i;
+ cmsHPROFILE ProfileList[256];
+ cmsBool BPCList[256];
+ cmsFloat64Number AdaptationList[256];
+ cmsUInt32Number IntentList[256];
+
+ memset(&Chain, 0, sizeof(GAMUTCHAIN));
+
+
+ if (nGamutPCSposition <= 0 || nGamutPCSposition > 255) {
+ cmsSignalError(ContextID, cmsERROR_RANGE, "Wrong position of PCS. 1..255 expected, %d found.", nGamutPCSposition);
+ return NULL;
+ }
+
+ hLab = cmsCreateLab4ProfileTHR(ContextID, NULL);
+ if (hLab == NULL) return NULL;
+
+
+ // The figure of merit. On matrix-shaper profiles, should be almost zero as
+ // the conversion is pretty exact. On LUT based profiles, different resolutions
+ // of input and output CLUT may result in differences.
+
+ if (cmsIsMatrixShaper(hGamut)) {
+
+ Chain.Thereshold = 1.0;
+ }
+ else {
+ Chain.Thereshold = ERR_THERESHOLD;
+ }
+
+
+ // Create a copy of parameters
+ for (i=0; i < nGamutPCSposition; i++) {
+ ProfileList[i] = hProfiles[i];
+ BPCList[i] = BPC[i];
+ AdaptationList[i] = AdaptationStates[i];
+ IntentList[i] = Intents[i];
+ }
+
+ // Fill Lab identity
+ ProfileList[nGamutPCSposition] = hLab;
+ BPCList[nGamutPCSposition] = 0;
+ AdaptationList[nGamutPCSposition] = 1.0;
+ IntentList[nGamutPCSposition] = INTENT_RELATIVE_COLORIMETRIC;
+
+
+ ColorSpace = cmsGetColorSpace(hGamut);
+
+ nChannels = cmsChannelsOf(ColorSpace);
+ nGridpoints = _cmsReasonableGridpointsByColorspace(ColorSpace, cmsFLAGS_HIGHRESPRECALC);
+ dwFormat = (CHANNELS_SH(nChannels)|BYTES_SH(2));
+
+ // 16 bits to Lab double
+ Chain.hInput = cmsCreateExtendedTransform(ContextID,
+ nGamutPCSposition + 1,
+ ProfileList,
+ BPCList,
+ IntentList,
+ AdaptationList,
+ NULL, 0,
+ dwFormat, TYPE_Lab_DBL,
+ cmsFLAGS_NOCACHE);
+
+
+ // Does create the forward step. Lab double to device
+ dwFormat = (CHANNELS_SH(nChannels)|BYTES_SH(2));
+ Chain.hForward = cmsCreateTransformTHR(ContextID,
+ hLab, TYPE_Lab_DBL,
+ hGamut, dwFormat,
+ INTENT_RELATIVE_COLORIMETRIC,
+ cmsFLAGS_NOCACHE);
+
+ // Does create the backwards step
+ Chain.hReverse = cmsCreateTransformTHR(ContextID, hGamut, dwFormat,
+ hLab, TYPE_Lab_DBL,
+ INTENT_RELATIVE_COLORIMETRIC,
+ cmsFLAGS_NOCACHE);
+
+
+ // All ok?
+ if (Chain.hInput && Chain.hForward && Chain.hReverse) {
+
+ // Go on, try to compute gamut LUT from PCS. This consist on a single channel containing
+ // dE when doing a transform back and forth on the colorimetric intent.
+
+ Gamut = cmsPipelineAlloc(ContextID, 3, 1);
+ if (Gamut != NULL) {
+
+ CLUT = cmsStageAllocCLut16bit(ContextID, nGridpoints, nChannels, 1, NULL);
+ if (!cmsPipelineInsertStage(Gamut, cmsAT_BEGIN, CLUT)) {
+ cmsPipelineFree(Gamut);
+ Gamut = NULL;
+ }
+ else {
+ cmsStageSampleCLut16bit(CLUT, GamutSampler, (void*) &Chain, 0);
+ }
+ }
+ }
+ else
+ Gamut = NULL; // Didn't work...
+
+ // Free all needed stuff.
+ if (Chain.hInput) cmsDeleteTransform(Chain.hInput);
+ if (Chain.hForward) cmsDeleteTransform(Chain.hForward);
+ if (Chain.hReverse) cmsDeleteTransform(Chain.hReverse);
+ if (hLab) cmsCloseProfile(hLab);
+
+ // And return computed hull
+ return Gamut;
+}
+
+// Total Area Coverage estimation ----------------------------------------------------------------
+
+typedef struct {
+ cmsUInt32Number nOutputChans;
+ cmsHTRANSFORM hRoundTrip;
+ cmsFloat32Number MaxTAC;
+ cmsFloat32Number MaxInput[cmsMAXCHANNELS];
+
+} cmsTACestimator;
+
+
+// This callback just accounts the maximum ink dropped in the given node. It does not populate any
+// memory, as the destination table is NULL. Its only purpose it to know the global maximum.
+static
+int EstimateTAC(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void * Cargo)
+{
+ cmsTACestimator* bp = (cmsTACestimator*) Cargo;
+ cmsFloat32Number RoundTrip[cmsMAXCHANNELS];
+ cmsUInt32Number i;
+ cmsFloat32Number Sum;
+
+
+ // Evaluate the xform
+ cmsDoTransform(bp->hRoundTrip, In, RoundTrip, 1);
+
+ // All all amounts of ink
+ for (Sum=0, i=0; i < bp ->nOutputChans; i++)
+ Sum += RoundTrip[i];
+
+ // If above maximum, keep track of input values
+ if (Sum > bp ->MaxTAC) {
+
+ bp ->MaxTAC = Sum;
+
+ for (i=0; i < bp ->nOutputChans; i++) {
+ bp ->MaxInput[i] = In[i];
+ }
+ }
+
+ return TRUE;
+
+ cmsUNUSED_PARAMETER(Out);
+}
+
+
+// Detect Total area coverage of the profile
+cmsFloat64Number CMSEXPORT cmsDetectTAC(cmsHPROFILE hProfile)
+{
+ cmsTACestimator bp;
+ cmsUInt32Number dwFormatter;
+ cmsUInt32Number GridPoints[MAX_INPUT_DIMENSIONS];
+ cmsHPROFILE hLab;
+ cmsContext ContextID = cmsGetProfileContextID(hProfile);
+
+ // TAC only works on output profiles
+ if (cmsGetDeviceClass(hProfile) != cmsSigOutputClass) {
+ return 0;
+ }
+
+ // Create a fake formatter for result
+ dwFormatter = cmsFormatterForColorspaceOfProfile(hProfile, 4, TRUE);
+
+ bp.nOutputChans = T_CHANNELS(dwFormatter);
+ bp.MaxTAC = 0; // Initial TAC is 0
+
+ // for safety
+ if (bp.nOutputChans >= cmsMAXCHANNELS) return 0;
+
+ hLab = cmsCreateLab4ProfileTHR(ContextID, NULL);
+ if (hLab == NULL) return 0;
+ // Setup a roundtrip on perceptual intent in output profile for TAC estimation
+ bp.hRoundTrip = cmsCreateTransformTHR(ContextID, hLab, TYPE_Lab_16,
+ hProfile, dwFormatter, INTENT_PERCEPTUAL, cmsFLAGS_NOOPTIMIZE|cmsFLAGS_NOCACHE);
+
+ cmsCloseProfile(hLab);
+ if (bp.hRoundTrip == NULL) return 0;
+
+ // For L* we only need black and white. For C* we need many points
+ GridPoints[0] = 6;
+ GridPoints[1] = 74;
+ GridPoints[2] = 74;
+
+
+ if (!cmsSliceSpace16(3, GridPoints, EstimateTAC, &bp)) {
+ bp.MaxTAC = 0;
+ }
+
+ cmsDeleteTransform(bp.hRoundTrip);
+
+ // Results in %
+ return bp.MaxTAC;
+}
+
+
+// Carefully, clamp on CIELab space.
+
+cmsBool CMSEXPORT cmsDesaturateLab(cmsCIELab* Lab,
+ double amax, double amin,
+ double bmax, double bmin)
+{
+
+ // Whole Luma surface to zero
+
+ if (Lab -> L < 0) {
+
+ Lab-> L = Lab->a = Lab-> b = 0.0;
+ return FALSE;
+ }
+
+ // Clamp white, DISCARD HIGHLIGHTS. This is done
+ // in such way because icc spec doesn't allow the
+ // use of L>100 as a highlight means.
+
+ if (Lab->L > 100)
+ Lab -> L = 100;
+
+ // Check out gamut prism, on a, b faces
+
+ if (Lab -> a < amin || Lab->a > amax||
+ Lab -> b < bmin || Lab->b > bmax) {
+
+ cmsCIELCh LCh;
+ double h, slope;
+
+ // Falls outside a, b limits. Transports to LCh space,
+ // and then do the clipping
+
+
+ if (Lab -> a == 0.0) { // Is hue exactly 90?
+
+ // atan will not work, so clamp here
+ Lab -> b = Lab->b < 0 ? bmin : bmax;
+ return TRUE;
+ }
+
+ cmsLab2LCh(&LCh, Lab);
+
+ slope = Lab -> b / Lab -> a;
+ h = LCh.h;
+
+ // There are 4 zones
+
+ if ((h >= 0. && h < 45.) ||
+ (h >= 315 && h <= 360.)) {
+
+ // clip by amax
+ Lab -> a = amax;
+ Lab -> b = amax * slope;
+ }
+ else
+ if (h >= 45. && h < 135.)
+ {
+ // clip by bmax
+ Lab -> b = bmax;
+ Lab -> a = bmax / slope;
+ }
+ else
+ if (h >= 135. && h < 225.) {
+ // clip by amin
+ Lab -> a = amin;
+ Lab -> b = amin * slope;
+
+ }
+ else
+ if (h >= 225. && h < 315.) {
+ // clip by bmin
+ Lab -> b = bmin;
+ Lab -> a = bmin / slope;
+ }
+ else {
+ cmsSignalError(0, cmsERROR_RANGE, "Invalid angle");
+ return FALSE;
+ }
+
+ }
+
+ return TRUE;
+}
diff --git a/src/cmshalf.c b/src/cmshalf.c
index 204dee9..204dee9 100755..100644
--- a/src/cmshalf.c
+++ b/src/cmshalf.c
diff --git a/src/cmsintrp.c b/src/cmsintrp.c
index 9072050..3e81805 100644
--- a/src/cmsintrp.c
+++ b/src/cmsintrp.c
@@ -1,1494 +1,1494 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2012 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "lcms2_internal.h"
-
-// This module incorporates several interpolation routines, for 1 to 8 channels on input and
-// up to 65535 channels on output. The user may change those by using the interpolation plug-in
-
-// Interpolation routines by default
-static cmsInterpFunction DefaultInterpolatorsFactory(cmsUInt32Number nInputChannels, cmsUInt32Number nOutputChannels, cmsUInt32Number dwFlags);
-
-// This is the default factory
-static cmsInterpFnFactory Interpolators = DefaultInterpolatorsFactory;
-
-
-// Main plug-in entry
-cmsBool _cmsRegisterInterpPlugin(cmsPluginBase* Data)
-{
- cmsPluginInterpolation* Plugin = (cmsPluginInterpolation*) Data;
-
- if (Data == NULL) {
-
- Interpolators = DefaultInterpolatorsFactory;
- return TRUE;
- }
-
- // Set replacement functions
- Interpolators = Plugin ->InterpolatorsFactory;
- return TRUE;
-}
-
-
-// Set the interpolation method
-
-cmsBool _cmsSetInterpolationRoutine(cmsInterpParams* p)
-{
- // Invoke factory, possibly in the Plug-in
- p ->Interpolation = Interpolators(p -> nInputs, p ->nOutputs, p ->dwFlags);
-
- // If unsupported by the plug-in, go for the LittleCMS default.
- // If happens only if an extern plug-in is being used
- if (p ->Interpolation.Lerp16 == NULL)
- p ->Interpolation = DefaultInterpolatorsFactory(p ->nInputs, p ->nOutputs, p ->dwFlags);
-
- // Check for valid interpolator (we just check one member of the union)
- if (p ->Interpolation.Lerp16 == NULL) {
- return FALSE;
- }
- return TRUE;
-}
-
-
-// This function precalculates as many parameters as possible to speed up the interpolation.
-cmsInterpParams* _cmsComputeInterpParamsEx(cmsContext ContextID,
- const cmsUInt32Number nSamples[],
- int InputChan, int OutputChan,
- const void *Table,
- cmsUInt32Number dwFlags)
-{
- cmsInterpParams* p;
- int i;
-
- // Check for maximum inputs
- if (InputChan > MAX_INPUT_DIMENSIONS) {
- cmsSignalError(ContextID, cmsERROR_RANGE, "Too many input channels (%d channels, max=%d)", InputChan, MAX_INPUT_DIMENSIONS);
- return NULL;
- }
-
- // Creates an empty object
- p = (cmsInterpParams*) _cmsMallocZero(ContextID, sizeof(cmsInterpParams));
- if (p == NULL) return NULL;
-
- // Keep original parameters
- p -> dwFlags = dwFlags;
- p -> nInputs = InputChan;
- p -> nOutputs = OutputChan;
- p ->Table = Table;
- p ->ContextID = ContextID;
-
- // Fill samples per input direction and domain (which is number of nodes minus one)
- for (i=0; i < InputChan; i++) {
-
- p -> nSamples[i] = nSamples[i];
- p -> Domain[i] = nSamples[i] - 1;
- }
-
- // Compute factors to apply to each component to index the grid array
- p -> opta[0] = p -> nOutputs;
- for (i=1; i < InputChan; i++)
- p ->opta[i] = p ->opta[i-1] * nSamples[InputChan-i];
-
-
- if (!_cmsSetInterpolationRoutine(p)) {
- cmsSignalError(ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported interpolation (%d->%d channels)", InputChan, OutputChan);
- _cmsFree(ContextID, p);
- return NULL;
- }
-
- // All seems ok
- return p;
-}
-
-
-// This one is a wrapper on the anterior, but assuming all directions have same number of nodes
-cmsInterpParams* _cmsComputeInterpParams(cmsContext ContextID, int nSamples, int InputChan, int OutputChan, const void* Table, cmsUInt32Number dwFlags)
-{
- int i;
- cmsUInt32Number Samples[MAX_INPUT_DIMENSIONS];
-
- // Fill the auxiliar array
- for (i=0; i < MAX_INPUT_DIMENSIONS; i++)
- Samples[i] = nSamples;
-
- // Call the extended function
- return _cmsComputeInterpParamsEx(ContextID, Samples, InputChan, OutputChan, Table, dwFlags);
-}
-
-
-// Free all associated memory
-void _cmsFreeInterpParams(cmsInterpParams* p)
-{
- if (p != NULL) _cmsFree(p ->ContextID, p);
-}
-
-
-// Inline fixed point interpolation
-cmsINLINE cmsUInt16Number LinearInterp(cmsS15Fixed16Number a, cmsS15Fixed16Number l, cmsS15Fixed16Number h)
-{
- cmsUInt32Number dif = (cmsUInt32Number) (h - l) * a + 0x8000;
- dif = (dif >> 16) + l;
- return (cmsUInt16Number) (dif);
-}
-
-
-// Linear interpolation (Fixed-point optimized)
-static
-void LinLerp1D(register const cmsUInt16Number Value[],
- register cmsUInt16Number Output[],
- register const cmsInterpParams* p)
-{
- cmsUInt16Number y1, y0;
- int cell0, rest;
- int val3;
- const cmsUInt16Number* LutTable = (cmsUInt16Number*) p ->Table;
-
- // if last value...
- if (Value[0] == 0xffff) {
-
- Output[0] = LutTable[p -> Domain[0]];
- return;
- }
-
- val3 = p -> Domain[0] * Value[0];
- val3 = _cmsToFixedDomain(val3); // To fixed 15.16
-
- cell0 = FIXED_TO_INT(val3); // Cell is 16 MSB bits
- rest = FIXED_REST_TO_INT(val3); // Rest is 16 LSB bits
-
- y0 = LutTable[cell0];
- y1 = LutTable[cell0+1];
-
-
- Output[0] = LinearInterp(rest, y0, y1);
-}
-
-
-// Floating-point version of 1D interpolation
-static
-void LinLerp1Dfloat(const cmsFloat32Number Value[],
- cmsFloat32Number Output[],
- const cmsInterpParams* p)
-{
- cmsFloat32Number y1, y0;
- cmsFloat32Number val2, rest;
- int cell0, cell1;
- const cmsFloat32Number* LutTable = (cmsFloat32Number*) p ->Table;
-
- // if last value...
- if (Value[0] == 1.0) {
- Output[0] = LutTable[p -> Domain[0]];
- return;
- }
-
- val2 = p -> Domain[0] * Value[0];
-
- cell0 = (int) floor(val2);
- cell1 = (int) ceil(val2);
-
- // Rest is 16 LSB bits
- rest = val2 - cell0;
-
- y0 = LutTable[cell0] ;
- y1 = LutTable[cell1] ;
-
- Output[0] = y0 + (y1 - y0) * rest;
-}
-
-
-
-// Eval gray LUT having only one input channel
-static
-void Eval1Input(register const cmsUInt16Number Input[],
- register cmsUInt16Number Output[],
- register const cmsInterpParams* p16)
-{
- cmsS15Fixed16Number fk;
- cmsS15Fixed16Number k0, k1, rk, K0, K1;
- int v;
- cmsUInt32Number OutChan;
- const cmsUInt16Number* LutTable = (cmsUInt16Number*) p16 -> Table;
-
- v = Input[0] * p16 -> Domain[0];
- fk = _cmsToFixedDomain(v);
-
- k0 = FIXED_TO_INT(fk);
- rk = (cmsUInt16Number) FIXED_REST_TO_INT(fk);
-
- k1 = k0 + (Input[0] != 0xFFFFU ? 1 : 0);
-
- K0 = p16 -> opta[0] * k0;
- K1 = p16 -> opta[0] * k1;
-
- for (OutChan=0; OutChan < p16->nOutputs; OutChan++) {
-
- Output[OutChan] = LinearInterp(rk, LutTable[K0+OutChan], LutTable[K1+OutChan]);
- }
-}
-
-
-
-// Eval gray LUT having only one input channel
-static
-void Eval1InputFloat(const cmsFloat32Number Value[],
- cmsFloat32Number Output[],
- const cmsInterpParams* p)
-{
- cmsFloat32Number y1, y0;
- cmsFloat32Number val2, rest;
- int cell0, cell1;
- cmsUInt32Number OutChan;
- const cmsFloat32Number* LutTable = (cmsFloat32Number*) p ->Table;
-
- // if last value...
- if (Value[0] == 1.0) {
- Output[0] = LutTable[p -> Domain[0]];
- return;
- }
-
- val2 = p -> Domain[0] * Value[0];
-
- cell0 = (int) floor(val2);
- cell1 = (int) ceil(val2);
-
- // Rest is 16 LSB bits
- rest = val2 - cell0;
-
- cell0 *= p -> opta[0];
- cell1 *= p -> opta[0];
-
- for (OutChan=0; OutChan < p->nOutputs; OutChan++) {
-
- y0 = LutTable[cell0 + OutChan] ;
- y1 = LutTable[cell1 + OutChan] ;
-
- Output[OutChan] = y0 + (y1 - y0) * rest;
- }
-}
-
-// Bilinear interpolation (16 bits) - cmsFloat32Number version
-static
-void BilinearInterpFloat(const cmsFloat32Number Input[],
- cmsFloat32Number Output[],
- const cmsInterpParams* p)
-
-{
-# define LERP(a,l,h) (cmsFloat32Number) ((l)+(((h)-(l))*(a)))
-# define DENS(i,j) (LutTable[(i)+(j)+OutChan])
-
- const cmsFloat32Number* LutTable = (cmsFloat32Number*) p ->Table;
- cmsFloat32Number px, py;
- int x0, y0,
- X0, Y0, X1, Y1;
- int TotalOut, OutChan;
- cmsFloat32Number fx, fy,
- d00, d01, d10, d11,
- dx0, dx1,
- dxy;
-
- TotalOut = p -> nOutputs;
- px = Input[0] * p->Domain[0];
- py = Input[1] * p->Domain[1];
-
- x0 = (int) _cmsQuickFloor(px); fx = px - (cmsFloat32Number) x0;
- y0 = (int) _cmsQuickFloor(py); fy = py - (cmsFloat32Number) y0;
-
- X0 = p -> opta[1] * x0;
- X1 = X0 + (Input[0] >= 1.0 ? 0 : p->opta[1]);
-
- Y0 = p -> opta[0] * y0;
- Y1 = Y0 + (Input[1] >= 1.0 ? 0 : p->opta[0]);
-
- for (OutChan = 0; OutChan < TotalOut; OutChan++) {
-
- d00 = DENS(X0, Y0);
- d01 = DENS(X0, Y1);
- d10 = DENS(X1, Y0);
- d11 = DENS(X1, Y1);
-
- dx0 = LERP(fx, d00, d10);
- dx1 = LERP(fx, d01, d11);
-
- dxy = LERP(fy, dx0, dx1);
-
- Output[OutChan] = dxy;
- }
-
-
-# undef LERP
-# undef DENS
-}
-
-// Bilinear interpolation (16 bits) - optimized version
-static
-void BilinearInterp16(register const cmsUInt16Number Input[],
- register cmsUInt16Number Output[],
- register const cmsInterpParams* p)
-
-{
-#define DENS(i,j) (LutTable[(i)+(j)+OutChan])
-#define LERP(a,l,h) (cmsUInt16Number) (l + ROUND_FIXED_TO_INT(((h-l)*a)))
-
- const cmsUInt16Number* LutTable = (cmsUInt16Number*) p ->Table;
- int OutChan, TotalOut;
- cmsS15Fixed16Number fx, fy;
- register int rx, ry;
- int x0, y0;
- register int X0, X1, Y0, Y1;
- int d00, d01, d10, d11,
- dx0, dx1,
- dxy;
-
- TotalOut = p -> nOutputs;
-
- fx = _cmsToFixedDomain((int) Input[0] * p -> Domain[0]);
- x0 = FIXED_TO_INT(fx);
- rx = FIXED_REST_TO_INT(fx); // Rest in 0..1.0 domain
-
-
- fy = _cmsToFixedDomain((int) Input[1] * p -> Domain[1]);
- y0 = FIXED_TO_INT(fy);
- ry = FIXED_REST_TO_INT(fy);
-
-
- X0 = p -> opta[1] * x0;
- X1 = X0 + (Input[0] == 0xFFFFU ? 0 : p->opta[1]);
-
- Y0 = p -> opta[0] * y0;
- Y1 = Y0 + (Input[1] == 0xFFFFU ? 0 : p->opta[0]);
-
- for (OutChan = 0; OutChan < TotalOut; OutChan++) {
-
- d00 = DENS(X0, Y0);
- d01 = DENS(X0, Y1);
- d10 = DENS(X1, Y0);
- d11 = DENS(X1, Y1);
-
- dx0 = LERP(rx, d00, d10);
- dx1 = LERP(rx, d01, d11);
-
- dxy = LERP(ry, dx0, dx1);
-
- Output[OutChan] = (cmsUInt16Number) dxy;
- }
-
-
-# undef LERP
-# undef DENS
-}
-
-
-// Trilinear interpolation (16 bits) - cmsFloat32Number version
-static
-void TrilinearInterpFloat(const cmsFloat32Number Input[],
- cmsFloat32Number Output[],
- const cmsInterpParams* p)
-
-{
-# define LERP(a,l,h) (cmsFloat32Number) ((l)+(((h)-(l))*(a)))
-# define DENS(i,j,k) (LutTable[(i)+(j)+(k)+OutChan])
-
- const cmsFloat32Number* LutTable = (cmsFloat32Number*) p ->Table;
- cmsFloat32Number px, py, pz;
- int x0, y0, z0,
- X0, Y0, Z0, X1, Y1, Z1;
- int TotalOut, OutChan;
- cmsFloat32Number fx, fy, fz,
- d000, d001, d010, d011,
- d100, d101, d110, d111,
- dx00, dx01, dx10, dx11,
- dxy0, dxy1, dxyz;
-
- TotalOut = p -> nOutputs;
-
- // We need some clipping here
- px = Input[0];
- py = Input[1];
- pz = Input[2];
-
- if (px < 0) px = 0;
- if (px > 1) px = 1;
- if (py < 0) py = 0;
- if (py > 1) py = 1;
- if (pz < 0) pz = 0;
- if (pz > 1) pz = 1;
-
- px *= p->Domain[0];
- py *= p->Domain[1];
- pz *= p->Domain[2];
-
- x0 = (int) _cmsQuickFloor(px); fx = px - (cmsFloat32Number) x0;
- y0 = (int) _cmsQuickFloor(py); fy = py - (cmsFloat32Number) y0;
- z0 = (int) _cmsQuickFloor(pz); fz = pz - (cmsFloat32Number) z0;
-
- X0 = p -> opta[2] * x0;
- X1 = X0 + (Input[0] >= 1.0 ? 0 : p->opta[2]);
-
- Y0 = p -> opta[1] * y0;
- Y1 = Y0 + (Input[1] >= 1.0 ? 0 : p->opta[1]);
-
- Z0 = p -> opta[0] * z0;
- Z1 = Z0 + (Input[2] >= 1.0 ? 0 : p->opta[0]);
-
- for (OutChan = 0; OutChan < TotalOut; OutChan++) {
-
- d000 = DENS(X0, Y0, Z0);
- d001 = DENS(X0, Y0, Z1);
- d010 = DENS(X0, Y1, Z0);
- d011 = DENS(X0, Y1, Z1);
-
- d100 = DENS(X1, Y0, Z0);
- d101 = DENS(X1, Y0, Z1);
- d110 = DENS(X1, Y1, Z0);
- d111 = DENS(X1, Y1, Z1);
-
-
- dx00 = LERP(fx, d000, d100);
- dx01 = LERP(fx, d001, d101);
- dx10 = LERP(fx, d010, d110);
- dx11 = LERP(fx, d011, d111);
-
- dxy0 = LERP(fy, dx00, dx10);
- dxy1 = LERP(fy, dx01, dx11);
-
- dxyz = LERP(fz, dxy0, dxy1);
-
- Output[OutChan] = dxyz;
- }
-
-
-# undef LERP
-# undef DENS
-}
-
-// Trilinear interpolation (16 bits) - optimized version
-static
-void TrilinearInterp16(register const cmsUInt16Number Input[],
- register cmsUInt16Number Output[],
- register const cmsInterpParams* p)
-
-{
-#define DENS(i,j,k) (LutTable[(i)+(j)+(k)+OutChan])
-#define LERP(a,l,h) (cmsUInt16Number) (l + ROUND_FIXED_TO_INT(((h-l)*a)))
-
- const cmsUInt16Number* LutTable = (cmsUInt16Number*) p ->Table;
- int OutChan, TotalOut;
- cmsS15Fixed16Number fx, fy, fz;
- register int rx, ry, rz;
- int x0, y0, z0;
- register int X0, X1, Y0, Y1, Z0, Z1;
- int d000, d001, d010, d011,
- d100, d101, d110, d111,
- dx00, dx01, dx10, dx11,
- dxy0, dxy1, dxyz;
-
- TotalOut = p -> nOutputs;
-
- fx = _cmsToFixedDomain((int) Input[0] * p -> Domain[0]);
- x0 = FIXED_TO_INT(fx);
- rx = FIXED_REST_TO_INT(fx); // Rest in 0..1.0 domain
-
-
- fy = _cmsToFixedDomain((int) Input[1] * p -> Domain[1]);
- y0 = FIXED_TO_INT(fy);
- ry = FIXED_REST_TO_INT(fy);
-
- fz = _cmsToFixedDomain((int) Input[2] * p -> Domain[2]);
- z0 = FIXED_TO_INT(fz);
- rz = FIXED_REST_TO_INT(fz);
-
-
- X0 = p -> opta[2] * x0;
- X1 = X0 + (Input[0] == 0xFFFFU ? 0 : p->opta[2]);
-
- Y0 = p -> opta[1] * y0;
- Y1 = Y0 + (Input[1] == 0xFFFFU ? 0 : p->opta[1]);
-
- Z0 = p -> opta[0] * z0;
- Z1 = Z0 + (Input[2] == 0xFFFFU ? 0 : p->opta[0]);
-
- for (OutChan = 0; OutChan < TotalOut; OutChan++) {
-
- d000 = DENS(X0, Y0, Z0);
- d001 = DENS(X0, Y0, Z1);
- d010 = DENS(X0, Y1, Z0);
- d011 = DENS(X0, Y1, Z1);
-
- d100 = DENS(X1, Y0, Z0);
- d101 = DENS(X1, Y0, Z1);
- d110 = DENS(X1, Y1, Z0);
- d111 = DENS(X1, Y1, Z1);
-
-
- dx00 = LERP(rx, d000, d100);
- dx01 = LERP(rx, d001, d101);
- dx10 = LERP(rx, d010, d110);
- dx11 = LERP(rx, d011, d111);
-
- dxy0 = LERP(ry, dx00, dx10);
- dxy1 = LERP(ry, dx01, dx11);
-
- dxyz = LERP(rz, dxy0, dxy1);
-
- Output[OutChan] = (cmsUInt16Number) dxyz;
- }
-
-
-# undef LERP
-# undef DENS
-}
-
-
-// Tetrahedral interpolation, using Sakamoto algorithm.
-#define DENS(i,j,k) (LutTable[(i)+(j)+(k)+OutChan])
-static
-void TetrahedralInterpFloat(const cmsFloat32Number Input[],
- cmsFloat32Number Output[],
- const cmsInterpParams* p)
-{
- const cmsFloat32Number* LutTable = (cmsFloat32Number*) p -> Table;
- cmsFloat32Number px, py, pz;
- int x0, y0, z0,
- X0, Y0, Z0, X1, Y1, Z1;
- cmsFloat32Number rx, ry, rz;
- cmsFloat32Number c0, c1=0, c2=0, c3=0;
- int OutChan, TotalOut;
-
- TotalOut = p -> nOutputs;
-
- // We need some clipping here
- px = Input[0];
- py = Input[1];
- pz = Input[2];
-
- if (px < 0) px = 0;
- if (px > 1) px = 1;
- if (py < 0) py = 0;
- if (py > 1) py = 1;
- if (pz < 0) pz = 0;
- if (pz > 1) pz = 1;
-
- px *= p->Domain[0];
- py *= p->Domain[1];
- pz *= p->Domain[2];
-
- x0 = (int) _cmsQuickFloor(px); rx = (px - (cmsFloat32Number) x0);
- y0 = (int) _cmsQuickFloor(py); ry = (py - (cmsFloat32Number) y0);
- z0 = (int) _cmsQuickFloor(pz); rz = (pz - (cmsFloat32Number) z0);
-
-
- X0 = p -> opta[2] * x0;
- X1 = X0 + (Input[0] >= 1.0 ? 0 : p->opta[2]);
-
- Y0 = p -> opta[1] * y0;
- Y1 = Y0 + (Input[1] >= 1.0 ? 0 : p->opta[1]);
-
- Z0 = p -> opta[0] * z0;
- Z1 = Z0 + (Input[2] >= 1.0 ? 0 : p->opta[0]);
-
- for (OutChan=0; OutChan < TotalOut; OutChan++) {
-
- // These are the 6 Tetrahedral
-
- c0 = DENS(X0, Y0, Z0);
-
- if (rx >= ry && ry >= rz) {
-
- c1 = DENS(X1, Y0, Z0) - c0;
- c2 = DENS(X1, Y1, Z0) - DENS(X1, Y0, Z0);
- c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0);
-
- }
- else
- if (rx >= rz && rz >= ry) {
-
- c1 = DENS(X1, Y0, Z0) - c0;
- c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1);
- c3 = DENS(X1, Y0, Z1) - DENS(X1, Y0, Z0);
-
- }
- else
- if (rz >= rx && rx >= ry) {
-
- c1 = DENS(X1, Y0, Z1) - DENS(X0, Y0, Z1);
- c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1);
- c3 = DENS(X0, Y0, Z1) - c0;
-
- }
- else
- if (ry >= rx && rx >= rz) {
-
- c1 = DENS(X1, Y1, Z0) - DENS(X0, Y1, Z0);
- c2 = DENS(X0, Y1, Z0) - c0;
- c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0);
-
- }
- else
- if (ry >= rz && rz >= rx) {
-
- c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1);
- c2 = DENS(X0, Y1, Z0) - c0;
- c3 = DENS(X0, Y1, Z1) - DENS(X0, Y1, Z0);
-
- }
- else
- if (rz >= ry && ry >= rx) {
-
- c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1);
- c2 = DENS(X0, Y1, Z1) - DENS(X0, Y0, Z1);
- c3 = DENS(X0, Y0, Z1) - c0;
-
- }
- else {
- c1 = c2 = c3 = 0;
- }
-
- Output[OutChan] = c0 + c1 * rx + c2 * ry + c3 * rz;
- }
-
-}
-
-#undef DENS
-
-
-
-
-static
-void TetrahedralInterp16(register const cmsUInt16Number Input[],
- register cmsUInt16Number Output[],
- register const cmsInterpParams* p)
-{
- const cmsUInt16Number* LutTable = (cmsUInt16Number*) p -> Table;
- cmsS15Fixed16Number fx, fy, fz;
- cmsS15Fixed16Number rx, ry, rz;
- int x0, y0, z0;
- cmsS15Fixed16Number c0, c1, c2, c3, Rest;
- cmsS15Fixed16Number X0, X1, Y0, Y1, Z0, Z1;
- cmsUInt32Number TotalOut = p -> nOutputs;
-
- fx = _cmsToFixedDomain((int) Input[0] * p -> Domain[0]);
- fy = _cmsToFixedDomain((int) Input[1] * p -> Domain[1]);
- fz = _cmsToFixedDomain((int) Input[2] * p -> Domain[2]);
-
- x0 = FIXED_TO_INT(fx);
- y0 = FIXED_TO_INT(fy);
- z0 = FIXED_TO_INT(fz);
-
- rx = FIXED_REST_TO_INT(fx);
- ry = FIXED_REST_TO_INT(fy);
- rz = FIXED_REST_TO_INT(fz);
-
- X0 = p -> opta[2] * x0;
- X1 = (Input[0] == 0xFFFFU ? 0 : p->opta[2]);
-
- Y0 = p -> opta[1] * y0;
- Y1 = (Input[1] == 0xFFFFU ? 0 : p->opta[1]);
-
- Z0 = p -> opta[0] * z0;
- Z1 = (Input[2] == 0xFFFFU ? 0 : p->opta[0]);
-
- LutTable = &LutTable[X0+Y0+Z0];
-
- // Output should be computed as x = ROUND_FIXED_TO_INT(_cmsToFixedDomain(Rest))
- // which expands as: x = (Rest + ((Rest+0x7fff)/0xFFFF) + 0x8000)>>16
- // This can be replaced by: t = Rest+0x8001, x = (t + (t>>16))>>16
- // at the cost of being off by one at 7fff and 17ffe.
-
- if (rx >= ry) {
- if (ry >= rz) {
- Y1 += X1;
- Z1 += Y1;
- for (; TotalOut; TotalOut--) {
- c1 = LutTable[X1];
- c2 = LutTable[Y1];
- c3 = LutTable[Z1];
- c0 = *LutTable++;
- c3 -= c2;
- c2 -= c1;
- c1 -= c0;
- Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
- *Output++ = (cmsUInt16Number) c0 + ((Rest + (Rest>>16))>>16);
- }
- } else if (rz >= rx) {
- X1 += Z1;
- Y1 += X1;
- for (; TotalOut; TotalOut--) {
- c1 = LutTable[X1];
- c2 = LutTable[Y1];
- c3 = LutTable[Z1];
- c0 = *LutTable++;
- c2 -= c1;
- c1 -= c3;
- c3 -= c0;
- Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
- *Output++ = (cmsUInt16Number) c0 + ((Rest + (Rest>>16))>>16);
- }
- } else {
- Z1 += X1;
- Y1 += Z1;
- for (; TotalOut; TotalOut--) {
- c1 = LutTable[X1];
- c2 = LutTable[Y1];
- c3 = LutTable[Z1];
- c0 = *LutTable++;
- c2 -= c3;
- c3 -= c1;
- c1 -= c0;
- Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
- *Output++ = (cmsUInt16Number) c0 + ((Rest + (Rest>>16))>>16);
- }
- }
- } else {
- if (rx >= rz) {
- X1 += Y1;
- Z1 += X1;
- for (; TotalOut; TotalOut--) {
- c1 = LutTable[X1];
- c2 = LutTable[Y1];
- c3 = LutTable[Z1];
- c0 = *LutTable++;
- c3 -= c1;
- c1 -= c2;
- c2 -= c0;
- Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
- *Output++ = (cmsUInt16Number) c0 + ((Rest + (Rest>>16))>>16);
- }
- } else if (ry >= rz) {
- Z1 += Y1;
- X1 += Z1;
- for (; TotalOut; TotalOut--) {
- c1 = LutTable[X1];
- c2 = LutTable[Y1];
- c3 = LutTable[Z1];
- c0 = *LutTable++;
- c1 -= c3;
- c3 -= c2;
- c2 -= c0;
- Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
- *Output++ = (cmsUInt16Number) c0 + ((Rest + (Rest>>16))>>16);
- }
- } else {
- Y1 += Z1;
- X1 += Y1;
- for (; TotalOut; TotalOut--) {
- c1 = LutTable[X1];
- c2 = LutTable[Y1];
- c3 = LutTable[Z1];
- c0 = *LutTable++;
- c1 -= c2;
- c2 -= c3;
- c3 -= c0;
- Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
- *Output++ = (cmsUInt16Number) c0 + ((Rest + (Rest>>16))>>16);
- }
- }
- }
-}
-
-
-#define DENS(i,j,k) (LutTable[(i)+(j)+(k)+OutChan])
-static
-void Eval4Inputs(register const cmsUInt16Number Input[],
- register cmsUInt16Number Output[],
- register const cmsInterpParams* p16)
-{
- const cmsUInt16Number* LutTable;
- cmsS15Fixed16Number fk;
- cmsS15Fixed16Number k0, rk;
- int K0, K1;
- cmsS15Fixed16Number fx, fy, fz;
- cmsS15Fixed16Number rx, ry, rz;
- int x0, y0, z0;
- cmsS15Fixed16Number X0, X1, Y0, Y1, Z0, Z1;
- cmsUInt32Number i;
- cmsS15Fixed16Number c0, c1, c2, c3, Rest;
- cmsUInt32Number OutChan;
- cmsUInt16Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
-
-
- fk = _cmsToFixedDomain((int) Input[0] * p16 -> Domain[0]);
- fx = _cmsToFixedDomain((int) Input[1] * p16 -> Domain[1]);
- fy = _cmsToFixedDomain((int) Input[2] * p16 -> Domain[2]);
- fz = _cmsToFixedDomain((int) Input[3] * p16 -> Domain[3]);
-
- k0 = FIXED_TO_INT(fk);
- x0 = FIXED_TO_INT(fx);
- y0 = FIXED_TO_INT(fy);
- z0 = FIXED_TO_INT(fz);
-
- rk = FIXED_REST_TO_INT(fk);
- rx = FIXED_REST_TO_INT(fx);
- ry = FIXED_REST_TO_INT(fy);
- rz = FIXED_REST_TO_INT(fz);
-
- K0 = p16 -> opta[3] * k0;
- K1 = K0 + (Input[0] == 0xFFFFU ? 0 : p16->opta[3]);
-
- X0 = p16 -> opta[2] * x0;
- X1 = X0 + (Input[1] == 0xFFFFU ? 0 : p16->opta[2]);
-
- Y0 = p16 -> opta[1] * y0;
- Y1 = Y0 + (Input[2] == 0xFFFFU ? 0 : p16->opta[1]);
-
- Z0 = p16 -> opta[0] * z0;
- Z1 = Z0 + (Input[3] == 0xFFFFU ? 0 : p16->opta[0]);
-
- LutTable = (cmsUInt16Number*) p16 -> Table;
- LutTable += K0;
-
- for (OutChan=0; OutChan < p16 -> nOutputs; OutChan++) {
-
- c0 = DENS(X0, Y0, Z0);
-
- if (rx >= ry && ry >= rz) {
-
- c1 = DENS(X1, Y0, Z0) - c0;
- c2 = DENS(X1, Y1, Z0) - DENS(X1, Y0, Z0);
- c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0);
-
- }
- else
- if (rx >= rz && rz >= ry) {
-
- c1 = DENS(X1, Y0, Z0) - c0;
- c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1);
- c3 = DENS(X1, Y0, Z1) - DENS(X1, Y0, Z0);
-
- }
- else
- if (rz >= rx && rx >= ry) {
-
- c1 = DENS(X1, Y0, Z1) - DENS(X0, Y0, Z1);
- c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1);
- c3 = DENS(X0, Y0, Z1) - c0;
-
- }
- else
- if (ry >= rx && rx >= rz) {
-
- c1 = DENS(X1, Y1, Z0) - DENS(X0, Y1, Z0);
- c2 = DENS(X0, Y1, Z0) - c0;
- c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0);
-
- }
- else
- if (ry >= rz && rz >= rx) {
-
- c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1);
- c2 = DENS(X0, Y1, Z0) - c0;
- c3 = DENS(X0, Y1, Z1) - DENS(X0, Y1, Z0);
-
- }
- else
- if (rz >= ry && ry >= rx) {
-
- c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1);
- c2 = DENS(X0, Y1, Z1) - DENS(X0, Y0, Z1);
- c3 = DENS(X0, Y0, Z1) - c0;
-
- }
- else {
- c1 = c2 = c3 = 0;
- }
-
- Rest = c1 * rx + c2 * ry + c3 * rz;
-
- Tmp1[OutChan] = (cmsUInt16Number) c0 + ROUND_FIXED_TO_INT(_cmsToFixedDomain(Rest));
- }
-
-
- LutTable = (cmsUInt16Number*) p16 -> Table;
- LutTable += K1;
-
- for (OutChan=0; OutChan < p16 -> nOutputs; OutChan++) {
-
- c0 = DENS(X0, Y0, Z0);
-
- if (rx >= ry && ry >= rz) {
-
- c1 = DENS(X1, Y0, Z0) - c0;
- c2 = DENS(X1, Y1, Z0) - DENS(X1, Y0, Z0);
- c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0);
-
- }
- else
- if (rx >= rz && rz >= ry) {
-
- c1 = DENS(X1, Y0, Z0) - c0;
- c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1);
- c3 = DENS(X1, Y0, Z1) - DENS(X1, Y0, Z0);
-
- }
- else
- if (rz >= rx && rx >= ry) {
-
- c1 = DENS(X1, Y0, Z1) - DENS(X0, Y0, Z1);
- c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1);
- c3 = DENS(X0, Y0, Z1) - c0;
-
- }
- else
- if (ry >= rx && rx >= rz) {
-
- c1 = DENS(X1, Y1, Z0) - DENS(X0, Y1, Z0);
- c2 = DENS(X0, Y1, Z0) - c0;
- c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0);
-
- }
- else
- if (ry >= rz && rz >= rx) {
-
- c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1);
- c2 = DENS(X0, Y1, Z0) - c0;
- c3 = DENS(X0, Y1, Z1) - DENS(X0, Y1, Z0);
-
- }
- else
- if (rz >= ry && ry >= rx) {
-
- c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1);
- c2 = DENS(X0, Y1, Z1) - DENS(X0, Y0, Z1);
- c3 = DENS(X0, Y0, Z1) - c0;
-
- }
- else {
- c1 = c2 = c3 = 0;
- }
-
- Rest = c1 * rx + c2 * ry + c3 * rz;
-
- Tmp2[OutChan] = (cmsUInt16Number) c0 + ROUND_FIXED_TO_INT(_cmsToFixedDomain(Rest));
- }
-
-
-
- for (i=0; i < p16 -> nOutputs; i++) {
- Output[i] = LinearInterp(rk, Tmp1[i], Tmp2[i]);
- }
-}
-#undef DENS
-
-
-// For more that 3 inputs (i.e., CMYK)
-// evaluate two 3-dimensional interpolations and then linearly interpolate between them.
-
-
-static
-void Eval4InputsFloat(const cmsFloat32Number Input[],
- cmsFloat32Number Output[],
- const cmsInterpParams* p)
-{
- const cmsFloat32Number* LutTable = (cmsFloat32Number*) p -> Table;
- cmsFloat32Number rest;
- cmsFloat32Number pk;
- int k0, K0, K1;
- const cmsFloat32Number* T;
- cmsUInt32Number i;
- cmsFloat32Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
- cmsInterpParams p1;
-
-
- pk = Input[0] * p->Domain[0];
- k0 = _cmsQuickFloor(pk);
- rest = pk - (cmsFloat32Number) k0;
-
- K0 = p -> opta[3] * k0;
- K1 = K0 + (Input[0] >= 1.0 ? 0 : p->opta[3]);
-
- p1 = *p;
- memmove(&p1.Domain[0], &p ->Domain[1], 3*sizeof(cmsUInt32Number));
-
- T = LutTable + K0;
- p1.Table = T;
-
- TetrahedralInterpFloat(Input + 1, Tmp1, &p1);
-
- T = LutTable + K1;
- p1.Table = T;
- TetrahedralInterpFloat(Input + 1, Tmp2, &p1);
-
- for (i=0; i < p -> nOutputs; i++)
- {
- cmsFloat32Number y0 = Tmp1[i];
- cmsFloat32Number y1 = Tmp2[i];
-
- Output[i] = y0 + (y1 - y0) * rest;
- }
-}
-
-
-static
-void Eval5Inputs(register const cmsUInt16Number Input[],
- register cmsUInt16Number Output[],
-
- register const cmsInterpParams* p16)
-{
- const cmsUInt16Number* LutTable = (cmsUInt16Number*) p16 -> Table;
- cmsS15Fixed16Number fk;
- cmsS15Fixed16Number k0, rk;
- int K0, K1;
- const cmsUInt16Number* T;
- cmsUInt32Number i;
- cmsUInt16Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
- cmsInterpParams p1;
-
-
- fk = _cmsToFixedDomain((cmsS15Fixed16Number) Input[0] * p16 -> Domain[0]);
- k0 = FIXED_TO_INT(fk);
- rk = FIXED_REST_TO_INT(fk);
-
- K0 = p16 -> opta[4] * k0;
- K1 = p16 -> opta[4] * (k0 + (Input[0] != 0xFFFFU ? 1 : 0));
-
- p1 = *p16;
- memmove(&p1.Domain[0], &p16 ->Domain[1], 4*sizeof(cmsUInt32Number));
-
- T = LutTable + K0;
- p1.Table = T;
-
- Eval4Inputs(Input + 1, Tmp1, &p1);
-
- T = LutTable + K1;
- p1.Table = T;
-
- Eval4Inputs(Input + 1, Tmp2, &p1);
-
- for (i=0; i < p16 -> nOutputs; i++) {
-
- Output[i] = LinearInterp(rk, Tmp1[i], Tmp2[i]);
- }
-
-}
-
-
-static
-void Eval5InputsFloat(const cmsFloat32Number Input[],
- cmsFloat32Number Output[],
- const cmsInterpParams* p)
-{
- const cmsFloat32Number* LutTable = (cmsFloat32Number*) p -> Table;
- cmsFloat32Number rest;
- cmsFloat32Number pk;
- int k0, K0, K1;
- const cmsFloat32Number* T;
- cmsUInt32Number i;
- cmsFloat32Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
- cmsInterpParams p1;
-
- pk = Input[0] * p->Domain[0];
- k0 = _cmsQuickFloor(pk);
- rest = pk - (cmsFloat32Number) k0;
-
- K0 = p -> opta[4] * k0;
- K1 = K0 + (Input[0] >= 1.0 ? 0 : p->opta[4]);
-
- p1 = *p;
- memmove(&p1.Domain[0], &p ->Domain[1], 4*sizeof(cmsUInt32Number));
-
- T = LutTable + K0;
- p1.Table = T;
-
- Eval4InputsFloat(Input + 1, Tmp1, &p1);
-
- T = LutTable + K1;
- p1.Table = T;
-
- Eval4InputsFloat(Input + 1, Tmp2, &p1);
-
- for (i=0; i < p -> nOutputs; i++) {
-
- cmsFloat32Number y0 = Tmp1[i];
- cmsFloat32Number y1 = Tmp2[i];
-
- Output[i] = y0 + (y1 - y0) * rest;
- }
-}
-
-
-
-static
-void Eval6Inputs(register const cmsUInt16Number Input[],
- register cmsUInt16Number Output[],
- register const cmsInterpParams* p16)
-{
- const cmsUInt16Number* LutTable = (cmsUInt16Number*) p16 -> Table;
- cmsS15Fixed16Number fk;
- cmsS15Fixed16Number k0, rk;
- int K0, K1;
- const cmsUInt16Number* T;
- cmsUInt32Number i;
- cmsUInt16Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
- cmsInterpParams p1;
-
- fk = _cmsToFixedDomain((cmsS15Fixed16Number) Input[0] * p16 -> Domain[0]);
- k0 = FIXED_TO_INT(fk);
- rk = FIXED_REST_TO_INT(fk);
-
- K0 = p16 -> opta[5] * k0;
- K1 = p16 -> opta[5] * (k0 + (Input[0] != 0xFFFFU ? 1 : 0));
-
- p1 = *p16;
- memmove(&p1.Domain[0], &p16 ->Domain[1], 5*sizeof(cmsUInt32Number));
-
- T = LutTable + K0;
- p1.Table = T;
-
- Eval5Inputs(Input + 1, Tmp1, &p1);
-
- T = LutTable + K1;
- p1.Table = T;
-
- Eval5Inputs(Input + 1, Tmp2, &p1);
-
- for (i=0; i < p16 -> nOutputs; i++) {
-
- Output[i] = LinearInterp(rk, Tmp1[i], Tmp2[i]);
- }
-
-}
-
-
-static
-void Eval6InputsFloat(const cmsFloat32Number Input[],
- cmsFloat32Number Output[],
- const cmsInterpParams* p)
-{
- const cmsFloat32Number* LutTable = (cmsFloat32Number*) p -> Table;
- cmsFloat32Number rest;
- cmsFloat32Number pk;
- int k0, K0, K1;
- const cmsFloat32Number* T;
- cmsUInt32Number i;
- cmsFloat32Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
- cmsInterpParams p1;
-
- pk = Input[0] * p->Domain[0];
- k0 = _cmsQuickFloor(pk);
- rest = pk - (cmsFloat32Number) k0;
-
- K0 = p -> opta[5] * k0;
- K1 = K0 + (Input[0] >= 1.0 ? 0 : p->opta[5]);
-
- p1 = *p;
- memmove(&p1.Domain[0], &p ->Domain[1], 5*sizeof(cmsUInt32Number));
-
- T = LutTable + K0;
- p1.Table = T;
-
- Eval5InputsFloat(Input + 1, Tmp1, &p1);
-
- T = LutTable + K1;
- p1.Table = T;
-
- Eval5InputsFloat(Input + 1, Tmp2, &p1);
-
- for (i=0; i < p -> nOutputs; i++) {
-
- cmsFloat32Number y0 = Tmp1[i];
- cmsFloat32Number y1 = Tmp2[i];
-
- Output[i] = y0 + (y1 - y0) * rest;
- }
-}
-
-
-static
-void Eval7Inputs(register const cmsUInt16Number Input[],
- register cmsUInt16Number Output[],
- register const cmsInterpParams* p16)
-{
- const cmsUInt16Number* LutTable = (cmsUInt16Number*) p16 -> Table;
- cmsS15Fixed16Number fk;
- cmsS15Fixed16Number k0, rk;
- int K0, K1;
- const cmsUInt16Number* T;
- cmsUInt32Number i;
- cmsUInt16Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
- cmsInterpParams p1;
-
-
- fk = _cmsToFixedDomain((cmsS15Fixed16Number) Input[0] * p16 -> Domain[0]);
- k0 = FIXED_TO_INT(fk);
- rk = FIXED_REST_TO_INT(fk);
-
- K0 = p16 -> opta[6] * k0;
- K1 = p16 -> opta[6] * (k0 + (Input[0] != 0xFFFFU ? 1 : 0));
-
- p1 = *p16;
- memmove(&p1.Domain[0], &p16 ->Domain[1], 6*sizeof(cmsUInt32Number));
-
- T = LutTable + K0;
- p1.Table = T;
-
- Eval6Inputs(Input + 1, Tmp1, &p1);
-
- T = LutTable + K1;
- p1.Table = T;
-
- Eval6Inputs(Input + 1, Tmp2, &p1);
-
- for (i=0; i < p16 -> nOutputs; i++) {
- Output[i] = LinearInterp(rk, Tmp1[i], Tmp2[i]);
- }
-}
-
-
-static
-void Eval7InputsFloat(const cmsFloat32Number Input[],
- cmsFloat32Number Output[],
- const cmsInterpParams* p)
-{
- const cmsFloat32Number* LutTable = (cmsFloat32Number*) p -> Table;
- cmsFloat32Number rest;
- cmsFloat32Number pk;
- int k0, K0, K1;
- const cmsFloat32Number* T;
- cmsUInt32Number i;
- cmsFloat32Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
- cmsInterpParams p1;
-
- pk = Input[0] * p->Domain[0];
- k0 = _cmsQuickFloor(pk);
- rest = pk - (cmsFloat32Number) k0;
-
- K0 = p -> opta[6] * k0;
- K1 = K0 + (Input[0] >= 1.0 ? 0 : p->opta[6]);
-
- p1 = *p;
- memmove(&p1.Domain[0], &p ->Domain[1], 6*sizeof(cmsUInt32Number));
-
- T = LutTable + K0;
- p1.Table = T;
-
- Eval6InputsFloat(Input + 1, Tmp1, &p1);
-
- T = LutTable + K1;
- p1.Table = T;
-
- Eval6InputsFloat(Input + 1, Tmp2, &p1);
-
-
- for (i=0; i < p -> nOutputs; i++) {
-
- cmsFloat32Number y0 = Tmp1[i];
- cmsFloat32Number y1 = Tmp2[i];
-
- Output[i] = y0 + (y1 - y0) * rest;
-
- }
-}
-
-static
-void Eval8Inputs(register const cmsUInt16Number Input[],
- register cmsUInt16Number Output[],
- register const cmsInterpParams* p16)
-{
- const cmsUInt16Number* LutTable = (cmsUInt16Number*) p16 -> Table;
- cmsS15Fixed16Number fk;
- cmsS15Fixed16Number k0, rk;
- int K0, K1;
- const cmsUInt16Number* T;
- cmsUInt32Number i;
- cmsUInt16Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
- cmsInterpParams p1;
-
- fk = _cmsToFixedDomain((cmsS15Fixed16Number) Input[0] * p16 -> Domain[0]);
- k0 = FIXED_TO_INT(fk);
- rk = FIXED_REST_TO_INT(fk);
-
- K0 = p16 -> opta[7] * k0;
- K1 = p16 -> opta[7] * (k0 + (Input[0] != 0xFFFFU ? 1 : 0));
-
- p1 = *p16;
- memmove(&p1.Domain[0], &p16 ->Domain[1], 7*sizeof(cmsUInt32Number));
-
- T = LutTable + K0;
- p1.Table = T;
-
- Eval7Inputs(Input + 1, Tmp1, &p1);
-
- T = LutTable + K1;
- p1.Table = T;
- Eval7Inputs(Input + 1, Tmp2, &p1);
-
- for (i=0; i < p16 -> nOutputs; i++) {
- Output[i] = LinearInterp(rk, Tmp1[i], Tmp2[i]);
- }
-}
-
-
-
-static
-void Eval8InputsFloat(const cmsFloat32Number Input[],
- cmsFloat32Number Output[],
- const cmsInterpParams* p)
-{
- const cmsFloat32Number* LutTable = (cmsFloat32Number*) p -> Table;
- cmsFloat32Number rest;
- cmsFloat32Number pk;
- int k0, K0, K1;
- const cmsFloat32Number* T;
- cmsUInt32Number i;
- cmsFloat32Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
- cmsInterpParams p1;
-
- pk = Input[0] * p->Domain[0];
- k0 = _cmsQuickFloor(pk);
- rest = pk - (cmsFloat32Number) k0;
-
- K0 = p -> opta[7] * k0;
- K1 = K0 + (Input[0] >= 1.0 ? 0 : p->opta[7]);
-
- p1 = *p;
- memmove(&p1.Domain[0], &p ->Domain[1], 7*sizeof(cmsUInt32Number));
-
- T = LutTable + K0;
- p1.Table = T;
-
- Eval7InputsFloat(Input + 1, Tmp1, &p1);
-
- T = LutTable + K1;
- p1.Table = T;
-
- Eval7InputsFloat(Input + 1, Tmp2, &p1);
-
-
- for (i=0; i < p -> nOutputs; i++) {
-
- cmsFloat32Number y0 = Tmp1[i];
- cmsFloat32Number y1 = Tmp2[i];
-
- Output[i] = y0 + (y1 - y0) * rest;
- }
-}
-
-// The default factory
-static
-cmsInterpFunction DefaultInterpolatorsFactory(cmsUInt32Number nInputChannels, cmsUInt32Number nOutputChannels, cmsUInt32Number dwFlags)
-{
-
- cmsInterpFunction Interpolation;
- cmsBool IsFloat = (dwFlags & CMS_LERP_FLAGS_FLOAT);
- cmsBool IsTrilinear = (dwFlags & CMS_LERP_FLAGS_TRILINEAR);
-
- memset(&Interpolation, 0, sizeof(Interpolation));
-
- // Safety check
- if (nInputChannels >= 4 && nOutputChannels >= MAX_STAGE_CHANNELS)
- return Interpolation;
-
- switch (nInputChannels) {
-
- case 1: // Gray LUT / linear
-
- if (nOutputChannels == 1) {
-
- if (IsFloat)
- Interpolation.LerpFloat = LinLerp1Dfloat;
- else
- Interpolation.Lerp16 = LinLerp1D;
-
- }
- else {
-
- if (IsFloat)
- Interpolation.LerpFloat = Eval1InputFloat;
- else
- Interpolation.Lerp16 = Eval1Input;
- }
- break;
-
- case 2: // Duotone
- if (IsFloat)
- Interpolation.LerpFloat = BilinearInterpFloat;
- else
- Interpolation.Lerp16 = BilinearInterp16;
- break;
-
- case 3: // RGB et al
-
- if (IsTrilinear) {
-
- if (IsFloat)
- Interpolation.LerpFloat = TrilinearInterpFloat;
- else
- Interpolation.Lerp16 = TrilinearInterp16;
- }
- else {
-
- if (IsFloat)
- Interpolation.LerpFloat = TetrahedralInterpFloat;
- else {
-
- Interpolation.Lerp16 = TetrahedralInterp16;
- }
- }
- break;
-
- case 4: // CMYK lut
-
- if (IsFloat)
- Interpolation.LerpFloat = Eval4InputsFloat;
- else
- Interpolation.Lerp16 = Eval4Inputs;
- break;
-
- case 5: // 5 Inks
- if (IsFloat)
- Interpolation.LerpFloat = Eval5InputsFloat;
- else
- Interpolation.Lerp16 = Eval5Inputs;
- break;
-
- case 6: // 6 Inks
- if (IsFloat)
- Interpolation.LerpFloat = Eval6InputsFloat;
- else
- Interpolation.Lerp16 = Eval6Inputs;
- break;
-
- case 7: // 7 inks
- if (IsFloat)
- Interpolation.LerpFloat = Eval7InputsFloat;
- else
- Interpolation.Lerp16 = Eval7Inputs;
- break;
-
- case 8: // 8 inks
- if (IsFloat)
- Interpolation.LerpFloat = Eval8InputsFloat;
- else
- Interpolation.Lerp16 = Eval8Inputs;
- break;
-
- break;
-
- default:
- Interpolation.Lerp16 = NULL;
- }
-
- return Interpolation;
-}
+//---------------------------------------------------------------------------------
+//
+// Little Color Management System
+// Copyright (c) 1998-2012 Marti Maria Saguer
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the Software
+// is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//---------------------------------------------------------------------------------
+//
+
+#include "lcms2_internal.h"
+
+// This module incorporates several interpolation routines, for 1 to 8 channels on input and
+// up to 65535 channels on output. The user may change those by using the interpolation plug-in
+
+// Interpolation routines by default
+static cmsInterpFunction DefaultInterpolatorsFactory(cmsUInt32Number nInputChannels, cmsUInt32Number nOutputChannels, cmsUInt32Number dwFlags);
+
+// This is the default factory
+static cmsInterpFnFactory Interpolators = DefaultInterpolatorsFactory;
+
+
+// Main plug-in entry
+cmsBool _cmsRegisterInterpPlugin(cmsPluginBase* Data)
+{
+ cmsPluginInterpolation* Plugin = (cmsPluginInterpolation*) Data;
+
+ if (Data == NULL) {
+
+ Interpolators = DefaultInterpolatorsFactory;
+ return TRUE;
+ }
+
+ // Set replacement functions
+ Interpolators = Plugin ->InterpolatorsFactory;
+ return TRUE;
+}
+
+
+// Set the interpolation method
+
+cmsBool _cmsSetInterpolationRoutine(cmsInterpParams* p)
+{
+ // Invoke factory, possibly in the Plug-in
+ p ->Interpolation = Interpolators(p -> nInputs, p ->nOutputs, p ->dwFlags);
+
+ // If unsupported by the plug-in, go for the LittleCMS default.
+ // If happens only if an extern plug-in is being used
+ if (p ->Interpolation.Lerp16 == NULL)
+ p ->Interpolation = DefaultInterpolatorsFactory(p ->nInputs, p ->nOutputs, p ->dwFlags);
+
+ // Check for valid interpolator (we just check one member of the union)
+ if (p ->Interpolation.Lerp16 == NULL) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+// This function precalculates as many parameters as possible to speed up the interpolation.
+cmsInterpParams* _cmsComputeInterpParamsEx(cmsContext ContextID,
+ const cmsUInt32Number nSamples[],
+ int InputChan, int OutputChan,
+ const void *Table,
+ cmsUInt32Number dwFlags)
+{
+ cmsInterpParams* p;
+ int i;
+
+ // Check for maximum inputs
+ if (InputChan > MAX_INPUT_DIMENSIONS) {
+ cmsSignalError(ContextID, cmsERROR_RANGE, "Too many input channels (%d channels, max=%d)", InputChan, MAX_INPUT_DIMENSIONS);
+ return NULL;
+ }
+
+ // Creates an empty object
+ p = (cmsInterpParams*) _cmsMallocZero(ContextID, sizeof(cmsInterpParams));
+ if (p == NULL) return NULL;
+
+ // Keep original parameters
+ p -> dwFlags = dwFlags;
+ p -> nInputs = InputChan;
+ p -> nOutputs = OutputChan;
+ p ->Table = Table;
+ p ->ContextID = ContextID;
+
+ // Fill samples per input direction and domain (which is number of nodes minus one)
+ for (i=0; i < InputChan; i++) {
+
+ p -> nSamples[i] = nSamples[i];
+ p -> Domain[i] = nSamples[i] - 1;
+ }
+
+ // Compute factors to apply to each component to index the grid array
+ p -> opta[0] = p -> nOutputs;
+ for (i=1; i < InputChan; i++)
+ p ->opta[i] = p ->opta[i-1] * nSamples[InputChan-i];
+
+
+ if (!_cmsSetInterpolationRoutine(p)) {
+ cmsSignalError(ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported interpolation (%d->%d channels)", InputChan, OutputChan);
+ _cmsFree(ContextID, p);
+ return NULL;
+ }
+
+ // All seems ok
+ return p;
+}
+
+
+// This one is a wrapper on the anterior, but assuming all directions have same number of nodes
+cmsInterpParams* _cmsComputeInterpParams(cmsContext ContextID, int nSamples, int InputChan, int OutputChan, const void* Table, cmsUInt32Number dwFlags)
+{
+ int i;
+ cmsUInt32Number Samples[MAX_INPUT_DIMENSIONS];
+
+ // Fill the auxiliar array
+ for (i=0; i < MAX_INPUT_DIMENSIONS; i++)
+ Samples[i] = nSamples;
+
+ // Call the extended function
+ return _cmsComputeInterpParamsEx(ContextID, Samples, InputChan, OutputChan, Table, dwFlags);
+}
+
+
+// Free all associated memory
+void _cmsFreeInterpParams(cmsInterpParams* p)
+{
+ if (p != NULL) _cmsFree(p ->ContextID, p);
+}
+
+
+// Inline fixed point interpolation
+cmsINLINE cmsUInt16Number LinearInterp(cmsS15Fixed16Number a, cmsS15Fixed16Number l, cmsS15Fixed16Number h)
+{
+ cmsUInt32Number dif = (cmsUInt32Number) (h - l) * a + 0x8000;
+ dif = (dif >> 16) + l;
+ return (cmsUInt16Number) (dif);
+}
+
+
+// Linear interpolation (Fixed-point optimized)
+static
+void LinLerp1D(register const cmsUInt16Number Value[],
+ register cmsUInt16Number Output[],
+ register const cmsInterpParams* p)
+{
+ cmsUInt16Number y1, y0;
+ int cell0, rest;
+ int val3;
+ const cmsUInt16Number* LutTable = (cmsUInt16Number*) p ->Table;
+
+ // if last value...
+ if (Value[0] == 0xffff) {
+
+ Output[0] = LutTable[p -> Domain[0]];
+ return;
+ }
+
+ val3 = p -> Domain[0] * Value[0];
+ val3 = _cmsToFixedDomain(val3); // To fixed 15.16
+
+ cell0 = FIXED_TO_INT(val3); // Cell is 16 MSB bits
+ rest = FIXED_REST_TO_INT(val3); // Rest is 16 LSB bits
+
+ y0 = LutTable[cell0];
+ y1 = LutTable[cell0+1];
+
+
+ Output[0] = LinearInterp(rest, y0, y1);
+}
+
+
+// Floating-point version of 1D interpolation
+static
+void LinLerp1Dfloat(const cmsFloat32Number Value[],
+ cmsFloat32Number Output[],
+ const cmsInterpParams* p)
+{
+ cmsFloat32Number y1, y0;
+ cmsFloat32Number val2, rest;
+ int cell0, cell1;
+ const cmsFloat32Number* LutTable = (cmsFloat32Number*) p ->Table;
+
+ // if last value...
+ if (Value[0] == 1.0) {
+ Output[0] = LutTable[p -> Domain[0]];
+ return;
+ }
+
+ val2 = p -> Domain[0] * Value[0];
+
+ cell0 = (int) floor(val2);
+ cell1 = (int) ceil(val2);
+
+ // Rest is 16 LSB bits
+ rest = val2 - cell0;
+
+ y0 = LutTable[cell0] ;
+ y1 = LutTable[cell1] ;
+
+ Output[0] = y0 + (y1 - y0) * rest;
+}
+
+
+
+// Eval gray LUT having only one input channel
+static
+void Eval1Input(register const cmsUInt16Number Input[],
+ register cmsUInt16Number Output[],
+ register const cmsInterpParams* p16)
+{
+ cmsS15Fixed16Number fk;
+ cmsS15Fixed16Number k0, k1, rk, K0, K1;
+ int v;
+ cmsUInt32Number OutChan;
+ const cmsUInt16Number* LutTable = (cmsUInt16Number*) p16 -> Table;
+
+ v = Input[0] * p16 -> Domain[0];
+ fk = _cmsToFixedDomain(v);
+
+ k0 = FIXED_TO_INT(fk);
+ rk = (cmsUInt16Number) FIXED_REST_TO_INT(fk);
+
+ k1 = k0 + (Input[0] != 0xFFFFU ? 1 : 0);
+
+ K0 = p16 -> opta[0] * k0;
+ K1 = p16 -> opta[0] * k1;
+
+ for (OutChan=0; OutChan < p16->nOutputs; OutChan++) {
+
+ Output[OutChan] = LinearInterp(rk, LutTable[K0+OutChan], LutTable[K1+OutChan]);
+ }
+}
+
+
+
+// Eval gray LUT having only one input channel
+static
+void Eval1InputFloat(const cmsFloat32Number Value[],
+ cmsFloat32Number Output[],
+ const cmsInterpParams* p)
+{
+ cmsFloat32Number y1, y0;
+ cmsFloat32Number val2, rest;
+ int cell0, cell1;
+ cmsUInt32Number OutChan;
+ const cmsFloat32Number* LutTable = (cmsFloat32Number*) p ->Table;
+
+ // if last value...
+ if (Value[0] == 1.0) {
+ Output[0] = LutTable[p -> Domain[0]];
+ return;
+ }
+
+ val2 = p -> Domain[0] * Value[0];
+
+ cell0 = (int) floor(val2);
+ cell1 = (int) ceil(val2);
+
+ // Rest is 16 LSB bits
+ rest = val2 - cell0;
+
+ cell0 *= p -> opta[0];
+ cell1 *= p -> opta[0];
+
+ for (OutChan=0; OutChan < p->nOutputs; OutChan++) {
+
+ y0 = LutTable[cell0 + OutChan] ;
+ y1 = LutTable[cell1 + OutChan] ;
+
+ Output[OutChan] = y0 + (y1 - y0) * rest;
+ }
+}
+
+// Bilinear interpolation (16 bits) - cmsFloat32Number version
+static
+void BilinearInterpFloat(const cmsFloat32Number Input[],
+ cmsFloat32Number Output[],
+ const cmsInterpParams* p)
+
+{
+# define LERP(a,l,h) (cmsFloat32Number) ((l)+(((h)-(l))*(a)))
+# define DENS(i,j) (LutTable[(i)+(j)+OutChan])
+
+ const cmsFloat32Number* LutTable = (cmsFloat32Number*) p ->Table;
+ cmsFloat32Number px, py;
+ int x0, y0,
+ X0, Y0, X1, Y1;
+ int TotalOut, OutChan;
+ cmsFloat32Number fx, fy,
+ d00, d01, d10, d11,
+ dx0, dx1,
+ dxy;
+
+ TotalOut = p -> nOutputs;
+ px = Input[0] * p->Domain[0];
+ py = Input[1] * p->Domain[1];
+
+ x0 = (int) _cmsQuickFloor(px); fx = px - (cmsFloat32Number) x0;
+ y0 = (int) _cmsQuickFloor(py); fy = py - (cmsFloat32Number) y0;
+
+ X0 = p -> opta[1] * x0;
+ X1 = X0 + (Input[0] >= 1.0 ? 0 : p->opta[1]);
+
+ Y0 = p -> opta[0] * y0;
+ Y1 = Y0 + (Input[1] >= 1.0 ? 0 : p->opta[0]);
+
+ for (OutChan = 0; OutChan < TotalOut; OutChan++) {
+
+ d00 = DENS(X0, Y0);
+ d01 = DENS(X0, Y1);
+ d10 = DENS(X1, Y0);
+ d11 = DENS(X1, Y1);
+
+ dx0 = LERP(fx, d00, d10);
+ dx1 = LERP(fx, d01, d11);
+
+ dxy = LERP(fy, dx0, dx1);
+
+ Output[OutChan] = dxy;
+ }
+
+
+# undef LERP
+# undef DENS
+}
+
+// Bilinear interpolation (16 bits) - optimized version
+static
+void BilinearInterp16(register const cmsUInt16Number Input[],
+ register cmsUInt16Number Output[],
+ register const cmsInterpParams* p)
+
+{
+#define DENS(i,j) (LutTable[(i)+(j)+OutChan])
+#define LERP(a,l,h) (cmsUInt16Number) (l + ROUND_FIXED_TO_INT(((h-l)*a)))
+
+ const cmsUInt16Number* LutTable = (cmsUInt16Number*) p ->Table;
+ int OutChan, TotalOut;
+ cmsS15Fixed16Number fx, fy;
+ register int rx, ry;
+ int x0, y0;
+ register int X0, X1, Y0, Y1;
+ int d00, d01, d10, d11,
+ dx0, dx1,
+ dxy;
+
+ TotalOut = p -> nOutputs;
+
+ fx = _cmsToFixedDomain((int) Input[0] * p -> Domain[0]);
+ x0 = FIXED_TO_INT(fx);
+ rx = FIXED_REST_TO_INT(fx); // Rest in 0..1.0 domain
+
+
+ fy = _cmsToFixedDomain((int) Input[1] * p -> Domain[1]);
+ y0 = FIXED_TO_INT(fy);
+ ry = FIXED_REST_TO_INT(fy);
+
+
+ X0 = p -> opta[1] * x0;
+ X1 = X0 + (Input[0] == 0xFFFFU ? 0 : p->opta[1]);
+
+ Y0 = p -> opta[0] * y0;
+ Y1 = Y0 + (Input[1] == 0xFFFFU ? 0 : p->opta[0]);
+
+ for (OutChan = 0; OutChan < TotalOut; OutChan++) {
+
+ d00 = DENS(X0, Y0);
+ d01 = DENS(X0, Y1);
+ d10 = DENS(X1, Y0);
+ d11 = DENS(X1, Y1);
+
+ dx0 = LERP(rx, d00, d10);
+ dx1 = LERP(rx, d01, d11);
+
+ dxy = LERP(ry, dx0, dx1);
+
+ Output[OutChan] = (cmsUInt16Number) dxy;
+ }
+
+
+# undef LERP
+# undef DENS
+}
+
+
+// Trilinear interpolation (16 bits) - cmsFloat32Number version
+static
+void TrilinearInterpFloat(const cmsFloat32Number Input[],
+ cmsFloat32Number Output[],
+ const cmsInterpParams* p)
+
+{
+# define LERP(a,l,h) (cmsFloat32Number) ((l)+(((h)-(l))*(a)))
+# define DENS(i,j,k) (LutTable[(i)+(j)+(k)+OutChan])
+
+ const cmsFloat32Number* LutTable = (cmsFloat32Number*) p ->Table;
+ cmsFloat32Number px, py, pz;
+ int x0, y0, z0,
+ X0, Y0, Z0, X1, Y1, Z1;
+ int TotalOut, OutChan;
+ cmsFloat32Number fx, fy, fz,
+ d000, d001, d010, d011,
+ d100, d101, d110, d111,
+ dx00, dx01, dx10, dx11,
+ dxy0, dxy1, dxyz;
+
+ TotalOut = p -> nOutputs;
+
+ // We need some clipping here
+ px = Input[0];
+ py = Input[1];
+ pz = Input[2];
+
+ if (px < 0) px = 0;
+ if (px > 1) px = 1;
+ if (py < 0) py = 0;
+ if (py > 1) py = 1;
+ if (pz < 0) pz = 0;
+ if (pz > 1) pz = 1;
+
+ px *= p->Domain[0];
+ py *= p->Domain[1];
+ pz *= p->Domain[2];
+
+ x0 = (int) _cmsQuickFloor(px); fx = px - (cmsFloat32Number) x0;
+ y0 = (int) _cmsQuickFloor(py); fy = py - (cmsFloat32Number) y0;
+ z0 = (int) _cmsQuickFloor(pz); fz = pz - (cmsFloat32Number) z0;
+
+ X0 = p -> opta[2] * x0;
+ X1 = X0 + (Input[0] >= 1.0 ? 0 : p->opta[2]);
+
+ Y0 = p -> opta[1] * y0;
+ Y1 = Y0 + (Input[1] >= 1.0 ? 0 : p->opta[1]);
+
+ Z0 = p -> opta[0] * z0;
+ Z1 = Z0 + (Input[2] >= 1.0 ? 0 : p->opta[0]);
+
+ for (OutChan = 0; OutChan < TotalOut; OutChan++) {
+
+ d000 = DENS(X0, Y0, Z0);
+ d001 = DENS(X0, Y0, Z1);
+ d010 = DENS(X0, Y1, Z0);
+ d011 = DENS(X0, Y1, Z1);
+
+ d100 = DENS(X1, Y0, Z0);
+ d101 = DENS(X1, Y0, Z1);
+ d110 = DENS(X1, Y1, Z0);
+ d111 = DENS(X1, Y1, Z1);
+
+
+ dx00 = LERP(fx, d000, d100);
+ dx01 = LERP(fx, d001, d101);
+ dx10 = LERP(fx, d010, d110);
+ dx11 = LERP(fx, d011, d111);
+
+ dxy0 = LERP(fy, dx00, dx10);
+ dxy1 = LERP(fy, dx01, dx11);
+
+ dxyz = LERP(fz, dxy0, dxy1);
+
+ Output[OutChan] = dxyz;
+ }
+
+
+# undef LERP
+# undef DENS
+}
+
+// Trilinear interpolation (16 bits) - optimized version
+static
+void TrilinearInterp16(register const cmsUInt16Number Input[],
+ register cmsUInt16Number Output[],
+ register const cmsInterpParams* p)
+
+{
+#define DENS(i,j,k) (LutTable[(i)+(j)+(k)+OutChan])
+#define LERP(a,l,h) (cmsUInt16Number) (l + ROUND_FIXED_TO_INT(((h-l)*a)))
+
+ const cmsUInt16Number* LutTable = (cmsUInt16Number*) p ->Table;
+ int OutChan, TotalOut;
+ cmsS15Fixed16Number fx, fy, fz;
+ register int rx, ry, rz;
+ int x0, y0, z0;
+ register int X0, X1, Y0, Y1, Z0, Z1;
+ int d000, d001, d010, d011,
+ d100, d101, d110, d111,
+ dx00, dx01, dx10, dx11,
+ dxy0, dxy1, dxyz;
+
+ TotalOut = p -> nOutputs;
+
+ fx = _cmsToFixedDomain((int) Input[0] * p -> Domain[0]);
+ x0 = FIXED_TO_INT(fx);
+ rx = FIXED_REST_TO_INT(fx); // Rest in 0..1.0 domain
+
+
+ fy = _cmsToFixedDomain((int) Input[1] * p -> Domain[1]);
+ y0 = FIXED_TO_INT(fy);
+ ry = FIXED_REST_TO_INT(fy);
+
+ fz = _cmsToFixedDomain((int) Input[2] * p -> Domain[2]);
+ z0 = FIXED_TO_INT(fz);
+ rz = FIXED_REST_TO_INT(fz);
+
+
+ X0 = p -> opta[2] * x0;
+ X1 = X0 + (Input[0] == 0xFFFFU ? 0 : p->opta[2]);
+
+ Y0 = p -> opta[1] * y0;
+ Y1 = Y0 + (Input[1] == 0xFFFFU ? 0 : p->opta[1]);
+
+ Z0 = p -> opta[0] * z0;
+ Z1 = Z0 + (Input[2] == 0xFFFFU ? 0 : p->opta[0]);
+
+ for (OutChan = 0; OutChan < TotalOut; OutChan++) {
+
+ d000 = DENS(X0, Y0, Z0);
+ d001 = DENS(X0, Y0, Z1);
+ d010 = DENS(X0, Y1, Z0);
+ d011 = DENS(X0, Y1, Z1);
+
+ d100 = DENS(X1, Y0, Z0);
+ d101 = DENS(X1, Y0, Z1);
+ d110 = DENS(X1, Y1, Z0);
+ d111 = DENS(X1, Y1, Z1);
+
+
+ dx00 = LERP(rx, d000, d100);
+ dx01 = LERP(rx, d001, d101);
+ dx10 = LERP(rx, d010, d110);
+ dx11 = LERP(rx, d011, d111);
+
+ dxy0 = LERP(ry, dx00, dx10);
+ dxy1 = LERP(ry, dx01, dx11);
+
+ dxyz = LERP(rz, dxy0, dxy1);
+
+ Output[OutChan] = (cmsUInt16Number) dxyz;
+ }
+
+
+# undef LERP
+# undef DENS
+}
+
+
+// Tetrahedral interpolation, using Sakamoto algorithm.
+#define DENS(i,j,k) (LutTable[(i)+(j)+(k)+OutChan])
+static
+void TetrahedralInterpFloat(const cmsFloat32Number Input[],
+ cmsFloat32Number Output[],
+ const cmsInterpParams* p)
+{
+ const cmsFloat32Number* LutTable = (cmsFloat32Number*) p -> Table;
+ cmsFloat32Number px, py, pz;
+ int x0, y0, z0,
+ X0, Y0, Z0, X1, Y1, Z1;
+ cmsFloat32Number rx, ry, rz;
+ cmsFloat32Number c0, c1=0, c2=0, c3=0;
+ int OutChan, TotalOut;
+
+ TotalOut = p -> nOutputs;
+
+ // We need some clipping here
+ px = Input[0];
+ py = Input[1];
+ pz = Input[2];
+
+ if (px < 0) px = 0;
+ if (px > 1) px = 1;
+ if (py < 0) py = 0;
+ if (py > 1) py = 1;
+ if (pz < 0) pz = 0;
+ if (pz > 1) pz = 1;
+
+ px *= p->Domain[0];
+ py *= p->Domain[1];
+ pz *= p->Domain[2];
+
+ x0 = (int) _cmsQuickFloor(px); rx = (px - (cmsFloat32Number) x0);
+ y0 = (int) _cmsQuickFloor(py); ry = (py - (cmsFloat32Number) y0);
+ z0 = (int) _cmsQuickFloor(pz); rz = (pz - (cmsFloat32Number) z0);
+
+
+ X0 = p -> opta[2] * x0;
+ X1 = X0 + (Input[0] >= 1.0 ? 0 : p->opta[2]);
+
+ Y0 = p -> opta[1] * y0;
+ Y1 = Y0 + (Input[1] >= 1.0 ? 0 : p->opta[1]);
+
+ Z0 = p -> opta[0] * z0;
+ Z1 = Z0 + (Input[2] >= 1.0 ? 0 : p->opta[0]);
+
+ for (OutChan=0; OutChan < TotalOut; OutChan++) {
+
+ // These are the 6 Tetrahedral
+
+ c0 = DENS(X0, Y0, Z0);
+
+ if (rx >= ry && ry >= rz) {
+
+ c1 = DENS(X1, Y0, Z0) - c0;
+ c2 = DENS(X1, Y1, Z0) - DENS(X1, Y0, Z0);
+ c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0);
+
+ }
+ else
+ if (rx >= rz && rz >= ry) {
+
+ c1 = DENS(X1, Y0, Z0) - c0;
+ c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1);
+ c3 = DENS(X1, Y0, Z1) - DENS(X1, Y0, Z0);
+
+ }
+ else
+ if (rz >= rx && rx >= ry) {
+
+ c1 = DENS(X1, Y0, Z1) - DENS(X0, Y0, Z1);
+ c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1);
+ c3 = DENS(X0, Y0, Z1) - c0;
+
+ }
+ else
+ if (ry >= rx && rx >= rz) {
+
+ c1 = DENS(X1, Y1, Z0) - DENS(X0, Y1, Z0);
+ c2 = DENS(X0, Y1, Z0) - c0;
+ c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0);
+
+ }
+ else
+ if (ry >= rz && rz >= rx) {
+
+ c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1);
+ c2 = DENS(X0, Y1, Z0) - c0;
+ c3 = DENS(X0, Y1, Z1) - DENS(X0, Y1, Z0);
+
+ }
+ else
+ if (rz >= ry && ry >= rx) {
+
+ c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1);
+ c2 = DENS(X0, Y1, Z1) - DENS(X0, Y0, Z1);
+ c3 = DENS(X0, Y0, Z1) - c0;
+
+ }
+ else {
+ c1 = c2 = c3 = 0;
+ }
+
+ Output[OutChan] = c0 + c1 * rx + c2 * ry + c3 * rz;
+ }
+
+}
+
+#undef DENS
+
+
+
+
+static
+void TetrahedralInterp16(register const cmsUInt16Number Input[],
+ register cmsUInt16Number Output[],
+ register const cmsInterpParams* p)
+{
+ const cmsUInt16Number* LutTable = (cmsUInt16Number*) p -> Table;
+ cmsS15Fixed16Number fx, fy, fz;
+ cmsS15Fixed16Number rx, ry, rz;
+ int x0, y0, z0;
+ cmsS15Fixed16Number c0, c1, c2, c3, Rest;
+ cmsS15Fixed16Number X0, X1, Y0, Y1, Z0, Z1;
+ cmsUInt32Number TotalOut = p -> nOutputs;
+
+ fx = _cmsToFixedDomain((int) Input[0] * p -> Domain[0]);
+ fy = _cmsToFixedDomain((int) Input[1] * p -> Domain[1]);
+ fz = _cmsToFixedDomain((int) Input[2] * p -> Domain[2]);
+
+ x0 = FIXED_TO_INT(fx);
+ y0 = FIXED_TO_INT(fy);
+ z0 = FIXED_TO_INT(fz);
+
+ rx = FIXED_REST_TO_INT(fx);
+ ry = FIXED_REST_TO_INT(fy);
+ rz = FIXED_REST_TO_INT(fz);
+
+ X0 = p -> opta[2] * x0;
+ X1 = (Input[0] == 0xFFFFU ? 0 : p->opta[2]);
+
+ Y0 = p -> opta[1] * y0;
+ Y1 = (Input[1] == 0xFFFFU ? 0 : p->opta[1]);
+
+ Z0 = p -> opta[0] * z0;
+ Z1 = (Input[2] == 0xFFFFU ? 0 : p->opta[0]);
+
+ LutTable = &LutTable[X0+Y0+Z0];
+
+ // Output should be computed as x = ROUND_FIXED_TO_INT(_cmsToFixedDomain(Rest))
+ // which expands as: x = (Rest + ((Rest+0x7fff)/0xFFFF) + 0x8000)>>16
+ // This can be replaced by: t = Rest+0x8001, x = (t + (t>>16))>>16
+ // at the cost of being off by one at 7fff and 17ffe.
+
+ if (rx >= ry) {
+ if (ry >= rz) {
+ Y1 += X1;
+ Z1 += Y1;
+ for (; TotalOut; TotalOut--) {
+ c1 = LutTable[X1];
+ c2 = LutTable[Y1];
+ c3 = LutTable[Z1];
+ c0 = *LutTable++;
+ c3 -= c2;
+ c2 -= c1;
+ c1 -= c0;
+ Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
+ *Output++ = (cmsUInt16Number) c0 + ((Rest + (Rest>>16))>>16);
+ }
+ } else if (rz >= rx) {
+ X1 += Z1;
+ Y1 += X1;
+ for (; TotalOut; TotalOut--) {
+ c1 = LutTable[X1];
+ c2 = LutTable[Y1];
+ c3 = LutTable[Z1];
+ c0 = *LutTable++;
+ c2 -= c1;
+ c1 -= c3;
+ c3 -= c0;
+ Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
+ *Output++ = (cmsUInt16Number) c0 + ((Rest + (Rest>>16))>>16);
+ }
+ } else {
+ Z1 += X1;
+ Y1 += Z1;
+ for (; TotalOut; TotalOut--) {
+ c1 = LutTable[X1];
+ c2 = LutTable[Y1];
+ c3 = LutTable[Z1];
+ c0 = *LutTable++;
+ c2 -= c3;
+ c3 -= c1;
+ c1 -= c0;
+ Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
+ *Output++ = (cmsUInt16Number) c0 + ((Rest + (Rest>>16))>>16);
+ }
+ }
+ } else {
+ if (rx >= rz) {
+ X1 += Y1;
+ Z1 += X1;
+ for (; TotalOut; TotalOut--) {
+ c1 = LutTable[X1];
+ c2 = LutTable[Y1];
+ c3 = LutTable[Z1];
+ c0 = *LutTable++;
+ c3 -= c1;
+ c1 -= c2;
+ c2 -= c0;
+ Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
+ *Output++ = (cmsUInt16Number) c0 + ((Rest + (Rest>>16))>>16);
+ }
+ } else if (ry >= rz) {
+ Z1 += Y1;
+ X1 += Z1;
+ for (; TotalOut; TotalOut--) {
+ c1 = LutTable[X1];
+ c2 = LutTable[Y1];
+ c3 = LutTable[Z1];
+ c0 = *LutTable++;
+ c1 -= c3;
+ c3 -= c2;
+ c2 -= c0;
+ Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
+ *Output++ = (cmsUInt16Number) c0 + ((Rest + (Rest>>16))>>16);
+ }
+ } else {
+ Y1 += Z1;
+ X1 += Y1;
+ for (; TotalOut; TotalOut--) {
+ c1 = LutTable[X1];
+ c2 = LutTable[Y1];
+ c3 = LutTable[Z1];
+ c0 = *LutTable++;
+ c1 -= c2;
+ c2 -= c3;
+ c3 -= c0;
+ Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
+ *Output++ = (cmsUInt16Number) c0 + ((Rest + (Rest>>16))>>16);
+ }
+ }
+ }
+}
+
+
+#define DENS(i,j,k) (LutTable[(i)+(j)+(k)+OutChan])
+static
+void Eval4Inputs(register const cmsUInt16Number Input[],
+ register cmsUInt16Number Output[],
+ register const cmsInterpParams* p16)
+{
+ const cmsUInt16Number* LutTable;
+ cmsS15Fixed16Number fk;
+ cmsS15Fixed16Number k0, rk;
+ int K0, K1;
+ cmsS15Fixed16Number fx, fy, fz;
+ cmsS15Fixed16Number rx, ry, rz;
+ int x0, y0, z0;
+ cmsS15Fixed16Number X0, X1, Y0, Y1, Z0, Z1;
+ cmsUInt32Number i;
+ cmsS15Fixed16Number c0, c1, c2, c3, Rest;
+ cmsUInt32Number OutChan;
+ cmsUInt16Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
+
+
+ fk = _cmsToFixedDomain((int) Input[0] * p16 -> Domain[0]);
+ fx = _cmsToFixedDomain((int) Input[1] * p16 -> Domain[1]);
+ fy = _cmsToFixedDomain((int) Input[2] * p16 -> Domain[2]);
+ fz = _cmsToFixedDomain((int) Input[3] * p16 -> Domain[3]);
+
+ k0 = FIXED_TO_INT(fk);
+ x0 = FIXED_TO_INT(fx);
+ y0 = FIXED_TO_INT(fy);
+ z0 = FIXED_TO_INT(fz);
+
+ rk = FIXED_REST_TO_INT(fk);
+ rx = FIXED_REST_TO_INT(fx);
+ ry = FIXED_REST_TO_INT(fy);
+ rz = FIXED_REST_TO_INT(fz);
+
+ K0 = p16 -> opta[3] * k0;
+ K1 = K0 + (Input[0] == 0xFFFFU ? 0 : p16->opta[3]);
+
+ X0 = p16 -> opta[2] * x0;
+ X1 = X0 + (Input[1] == 0xFFFFU ? 0 : p16->opta[2]);
+
+ Y0 = p16 -> opta[1] * y0;
+ Y1 = Y0 + (Input[2] == 0xFFFFU ? 0 : p16->opta[1]);
+
+ Z0 = p16 -> opta[0] * z0;
+ Z1 = Z0 + (Input[3] == 0xFFFFU ? 0 : p16->opta[0]);
+
+ LutTable = (cmsUInt16Number*) p16 -> Table;
+ LutTable += K0;
+
+ for (OutChan=0; OutChan < p16 -> nOutputs; OutChan++) {
+
+ c0 = DENS(X0, Y0, Z0);
+
+ if (rx >= ry && ry >= rz) {
+
+ c1 = DENS(X1, Y0, Z0) - c0;
+ c2 = DENS(X1, Y1, Z0) - DENS(X1, Y0, Z0);
+ c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0);
+
+ }
+ else
+ if (rx >= rz && rz >= ry) {
+
+ c1 = DENS(X1, Y0, Z0) - c0;
+ c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1);
+ c3 = DENS(X1, Y0, Z1) - DENS(X1, Y0, Z0);
+
+ }
+ else
+ if (rz >= rx && rx >= ry) {
+
+ c1 = DENS(X1, Y0, Z1) - DENS(X0, Y0, Z1);
+ c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1);
+ c3 = DENS(X0, Y0, Z1) - c0;
+
+ }
+ else
+ if (ry >= rx && rx >= rz) {
+
+ c1 = DENS(X1, Y1, Z0) - DENS(X0, Y1, Z0);
+ c2 = DENS(X0, Y1, Z0) - c0;
+ c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0);
+
+ }
+ else
+ if (ry >= rz && rz >= rx) {
+
+ c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1);
+ c2 = DENS(X0, Y1, Z0) - c0;
+ c3 = DENS(X0, Y1, Z1) - DENS(X0, Y1, Z0);
+
+ }
+ else
+ if (rz >= ry && ry >= rx) {
+
+ c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1);
+ c2 = DENS(X0, Y1, Z1) - DENS(X0, Y0, Z1);
+ c3 = DENS(X0, Y0, Z1) - c0;
+
+ }
+ else {
+ c1 = c2 = c3 = 0;
+ }
+
+ Rest = c1 * rx + c2 * ry + c3 * rz;
+
+ Tmp1[OutChan] = (cmsUInt16Number) c0 + ROUND_FIXED_TO_INT(_cmsToFixedDomain(Rest));
+ }
+
+
+ LutTable = (cmsUInt16Number*) p16 -> Table;
+ LutTable += K1;
+
+ for (OutChan=0; OutChan < p16 -> nOutputs; OutChan++) {
+
+ c0 = DENS(X0, Y0, Z0);
+
+ if (rx >= ry && ry >= rz) {
+
+ c1 = DENS(X1, Y0, Z0) - c0;
+ c2 = DENS(X1, Y1, Z0) - DENS(X1, Y0, Z0);
+ c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0);
+
+ }
+ else
+ if (rx >= rz && rz >= ry) {
+
+ c1 = DENS(X1, Y0, Z0) - c0;
+ c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1);
+ c3 = DENS(X1, Y0, Z1) - DENS(X1, Y0, Z0);
+
+ }
+ else
+ if (rz >= rx && rx >= ry) {
+
+ c1 = DENS(X1, Y0, Z1) - DENS(X0, Y0, Z1);
+ c2 = DENS(X1, Y1, Z1) - DENS(X1, Y0, Z1);
+ c3 = DENS(X0, Y0, Z1) - c0;
+
+ }
+ else
+ if (ry >= rx && rx >= rz) {
+
+ c1 = DENS(X1, Y1, Z0) - DENS(X0, Y1, Z0);
+ c2 = DENS(X0, Y1, Z0) - c0;
+ c3 = DENS(X1, Y1, Z1) - DENS(X1, Y1, Z0);
+
+ }
+ else
+ if (ry >= rz && rz >= rx) {
+
+ c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1);
+ c2 = DENS(X0, Y1, Z0) - c0;
+ c3 = DENS(X0, Y1, Z1) - DENS(X0, Y1, Z0);
+
+ }
+ else
+ if (rz >= ry && ry >= rx) {
+
+ c1 = DENS(X1, Y1, Z1) - DENS(X0, Y1, Z1);
+ c2 = DENS(X0, Y1, Z1) - DENS(X0, Y0, Z1);
+ c3 = DENS(X0, Y0, Z1) - c0;
+
+ }
+ else {
+ c1 = c2 = c3 = 0;
+ }
+
+ Rest = c1 * rx + c2 * ry + c3 * rz;
+
+ Tmp2[OutChan] = (cmsUInt16Number) c0 + ROUND_FIXED_TO_INT(_cmsToFixedDomain(Rest));
+ }
+
+
+
+ for (i=0; i < p16 -> nOutputs; i++) {
+ Output[i] = LinearInterp(rk, Tmp1[i], Tmp2[i]);
+ }
+}
+#undef DENS
+
+
+// For more that 3 inputs (i.e., CMYK)
+// evaluate two 3-dimensional interpolations and then linearly interpolate between them.
+
+
+static
+void Eval4InputsFloat(const cmsFloat32Number Input[],
+ cmsFloat32Number Output[],
+ const cmsInterpParams* p)
+{
+ const cmsFloat32Number* LutTable = (cmsFloat32Number*) p -> Table;
+ cmsFloat32Number rest;
+ cmsFloat32Number pk;
+ int k0, K0, K1;
+ const cmsFloat32Number* T;
+ cmsUInt32Number i;
+ cmsFloat32Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
+ cmsInterpParams p1;
+
+
+ pk = Input[0] * p->Domain[0];
+ k0 = _cmsQuickFloor(pk);
+ rest = pk - (cmsFloat32Number) k0;
+
+ K0 = p -> opta[3] * k0;
+ K1 = K0 + (Input[0] >= 1.0 ? 0 : p->opta[3]);
+
+ p1 = *p;
+ memmove(&p1.Domain[0], &p ->Domain[1], 3*sizeof(cmsUInt32Number));
+
+ T = LutTable + K0;
+ p1.Table = T;
+
+ TetrahedralInterpFloat(Input + 1, Tmp1, &p1);
+
+ T = LutTable + K1;
+ p1.Table = T;
+ TetrahedralInterpFloat(Input + 1, Tmp2, &p1);
+
+ for (i=0; i < p -> nOutputs; i++)
+ {
+ cmsFloat32Number y0 = Tmp1[i];
+ cmsFloat32Number y1 = Tmp2[i];
+
+ Output[i] = y0 + (y1 - y0) * rest;
+ }
+}
+
+
+static
+void Eval5Inputs(register const cmsUInt16Number Input[],
+ register cmsUInt16Number Output[],
+
+ register const cmsInterpParams* p16)
+{
+ const cmsUInt16Number* LutTable = (cmsUInt16Number*) p16 -> Table;
+ cmsS15Fixed16Number fk;
+ cmsS15Fixed16Number k0, rk;
+ int K0, K1;
+ const cmsUInt16Number* T;
+ cmsUInt32Number i;
+ cmsUInt16Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
+ cmsInterpParams p1;
+
+
+ fk = _cmsToFixedDomain((cmsS15Fixed16Number) Input[0] * p16 -> Domain[0]);
+ k0 = FIXED_TO_INT(fk);
+ rk = FIXED_REST_TO_INT(fk);
+
+ K0 = p16 -> opta[4] * k0;
+ K1 = p16 -> opta[4] * (k0 + (Input[0] != 0xFFFFU ? 1 : 0));
+
+ p1 = *p16;
+ memmove(&p1.Domain[0], &p16 ->Domain[1], 4*sizeof(cmsUInt32Number));
+
+ T = LutTable + K0;
+ p1.Table = T;
+
+ Eval4Inputs(Input + 1, Tmp1, &p1);
+
+ T = LutTable + K1;
+ p1.Table = T;
+
+ Eval4Inputs(Input + 1, Tmp2, &p1);
+
+ for (i=0; i < p16 -> nOutputs; i++) {
+
+ Output[i] = LinearInterp(rk, Tmp1[i], Tmp2[i]);
+ }
+
+}
+
+
+static
+void Eval5InputsFloat(const cmsFloat32Number Input[],
+ cmsFloat32Number Output[],
+ const cmsInterpParams* p)
+{
+ const cmsFloat32Number* LutTable = (cmsFloat32Number*) p -> Table;
+ cmsFloat32Number rest;
+ cmsFloat32Number pk;
+ int k0, K0, K1;
+ const cmsFloat32Number* T;
+ cmsUInt32Number i;
+ cmsFloat32Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
+ cmsInterpParams p1;
+
+ pk = Input[0] * p->Domain[0];
+ k0 = _cmsQuickFloor(pk);
+ rest = pk - (cmsFloat32Number) k0;
+
+ K0 = p -> opta[4] * k0;
+ K1 = K0 + (Input[0] >= 1.0 ? 0 : p->opta[4]);
+
+ p1 = *p;
+ memmove(&p1.Domain[0], &p ->Domain[1], 4*sizeof(cmsUInt32Number));
+
+ T = LutTable + K0;
+ p1.Table = T;
+
+ Eval4InputsFloat(Input + 1, Tmp1, &p1);
+
+ T = LutTable + K1;
+ p1.Table = T;
+
+ Eval4InputsFloat(Input + 1, Tmp2, &p1);
+
+ for (i=0; i < p -> nOutputs; i++) {
+
+ cmsFloat32Number y0 = Tmp1[i];
+ cmsFloat32Number y1 = Tmp2[i];
+
+ Output[i] = y0 + (y1 - y0) * rest;
+ }
+}
+
+
+
+static
+void Eval6Inputs(register const cmsUInt16Number Input[],
+ register cmsUInt16Number Output[],
+ register const cmsInterpParams* p16)
+{
+ const cmsUInt16Number* LutTable = (cmsUInt16Number*) p16 -> Table;
+ cmsS15Fixed16Number fk;
+ cmsS15Fixed16Number k0, rk;
+ int K0, K1;
+ const cmsUInt16Number* T;
+ cmsUInt32Number i;
+ cmsUInt16Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
+ cmsInterpParams p1;
+
+ fk = _cmsToFixedDomain((cmsS15Fixed16Number) Input[0] * p16 -> Domain[0]);
+ k0 = FIXED_TO_INT(fk);
+ rk = FIXED_REST_TO_INT(fk);
+
+ K0 = p16 -> opta[5] * k0;
+ K1 = p16 -> opta[5] * (k0 + (Input[0] != 0xFFFFU ? 1 : 0));
+
+ p1 = *p16;
+ memmove(&p1.Domain[0], &p16 ->Domain[1], 5*sizeof(cmsUInt32Number));
+
+ T = LutTable + K0;
+ p1.Table = T;
+
+ Eval5Inputs(Input + 1, Tmp1, &p1);
+
+ T = LutTable + K1;
+ p1.Table = T;
+
+ Eval5Inputs(Input + 1, Tmp2, &p1);
+
+ for (i=0; i < p16 -> nOutputs; i++) {
+
+ Output[i] = LinearInterp(rk, Tmp1[i], Tmp2[i]);
+ }
+
+}
+
+
+static
+void Eval6InputsFloat(const cmsFloat32Number Input[],
+ cmsFloat32Number Output[],
+ const cmsInterpParams* p)
+{
+ const cmsFloat32Number* LutTable = (cmsFloat32Number*) p -> Table;
+ cmsFloat32Number rest;
+ cmsFloat32Number pk;
+ int k0, K0, K1;
+ const cmsFloat32Number* T;
+ cmsUInt32Number i;
+ cmsFloat32Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
+ cmsInterpParams p1;
+
+ pk = Input[0] * p->Domain[0];
+ k0 = _cmsQuickFloor(pk);
+ rest = pk - (cmsFloat32Number) k0;
+
+ K0 = p -> opta[5] * k0;
+ K1 = K0 + (Input[0] >= 1.0 ? 0 : p->opta[5]);
+
+ p1 = *p;
+ memmove(&p1.Domain[0], &p ->Domain[1], 5*sizeof(cmsUInt32Number));
+
+ T = LutTable + K0;
+ p1.Table = T;
+
+ Eval5InputsFloat(Input + 1, Tmp1, &p1);
+
+ T = LutTable + K1;
+ p1.Table = T;
+
+ Eval5InputsFloat(Input + 1, Tmp2, &p1);
+
+ for (i=0; i < p -> nOutputs; i++) {
+
+ cmsFloat32Number y0 = Tmp1[i];
+ cmsFloat32Number y1 = Tmp2[i];
+
+ Output[i] = y0 + (y1 - y0) * rest;
+ }
+}
+
+
+static
+void Eval7Inputs(register const cmsUInt16Number Input[],
+ register cmsUInt16Number Output[],
+ register const cmsInterpParams* p16)
+{
+ const cmsUInt16Number* LutTable = (cmsUInt16Number*) p16 -> Table;
+ cmsS15Fixed16Number fk;
+ cmsS15Fixed16Number k0, rk;
+ int K0, K1;
+ const cmsUInt16Number* T;
+ cmsUInt32Number i;
+ cmsUInt16Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
+ cmsInterpParams p1;
+
+
+ fk = _cmsToFixedDomain((cmsS15Fixed16Number) Input[0] * p16 -> Domain[0]);
+ k0 = FIXED_TO_INT(fk);
+ rk = FIXED_REST_TO_INT(fk);
+
+ K0 = p16 -> opta[6] * k0;
+ K1 = p16 -> opta[6] * (k0 + (Input[0] != 0xFFFFU ? 1 : 0));
+
+ p1 = *p16;
+ memmove(&p1.Domain[0], &p16 ->Domain[1], 6*sizeof(cmsUInt32Number));
+
+ T = LutTable + K0;
+ p1.Table = T;
+
+ Eval6Inputs(Input + 1, Tmp1, &p1);
+
+ T = LutTable + K1;
+ p1.Table = T;
+
+ Eval6Inputs(Input + 1, Tmp2, &p1);
+
+ for (i=0; i < p16 -> nOutputs; i++) {
+ Output[i] = LinearInterp(rk, Tmp1[i], Tmp2[i]);
+ }
+}
+
+
+static
+void Eval7InputsFloat(const cmsFloat32Number Input[],
+ cmsFloat32Number Output[],
+ const cmsInterpParams* p)
+{
+ const cmsFloat32Number* LutTable = (cmsFloat32Number*) p -> Table;
+ cmsFloat32Number rest;
+ cmsFloat32Number pk;
+ int k0, K0, K1;
+ const cmsFloat32Number* T;
+ cmsUInt32Number i;
+ cmsFloat32Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
+ cmsInterpParams p1;
+
+ pk = Input[0] * p->Domain[0];
+ k0 = _cmsQuickFloor(pk);
+ rest = pk - (cmsFloat32Number) k0;
+
+ K0 = p -> opta[6] * k0;
+ K1 = K0 + (Input[0] >= 1.0 ? 0 : p->opta[6]);
+
+ p1 = *p;
+ memmove(&p1.Domain[0], &p ->Domain[1], 6*sizeof(cmsUInt32Number));
+
+ T = LutTable + K0;
+ p1.Table = T;
+
+ Eval6InputsFloat(Input + 1, Tmp1, &p1);
+
+ T = LutTable + K1;
+ p1.Table = T;
+
+ Eval6InputsFloat(Input + 1, Tmp2, &p1);
+
+
+ for (i=0; i < p -> nOutputs; i++) {
+
+ cmsFloat32Number y0 = Tmp1[i];
+ cmsFloat32Number y1 = Tmp2[i];
+
+ Output[i] = y0 + (y1 - y0) * rest;
+
+ }
+}
+
+static
+void Eval8Inputs(register const cmsUInt16Number Input[],
+ register cmsUInt16Number Output[],
+ register const cmsInterpParams* p16)
+{
+ const cmsUInt16Number* LutTable = (cmsUInt16Number*) p16 -> Table;
+ cmsS15Fixed16Number fk;
+ cmsS15Fixed16Number k0, rk;
+ int K0, K1;
+ const cmsUInt16Number* T;
+ cmsUInt32Number i;
+ cmsUInt16Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
+ cmsInterpParams p1;
+
+ fk = _cmsToFixedDomain((cmsS15Fixed16Number) Input[0] * p16 -> Domain[0]);
+ k0 = FIXED_TO_INT(fk);
+ rk = FIXED_REST_TO_INT(fk);
+
+ K0 = p16 -> opta[7] * k0;
+ K1 = p16 -> opta[7] * (k0 + (Input[0] != 0xFFFFU ? 1 : 0));
+
+ p1 = *p16;
+ memmove(&p1.Domain[0], &p16 ->Domain[1], 7*sizeof(cmsUInt32Number));
+
+ T = LutTable + K0;
+ p1.Table = T;
+
+ Eval7Inputs(Input + 1, Tmp1, &p1);
+
+ T = LutTable + K1;
+ p1.Table = T;
+ Eval7Inputs(Input + 1, Tmp2, &p1);
+
+ for (i=0; i < p16 -> nOutputs; i++) {
+ Output[i] = LinearInterp(rk, Tmp1[i], Tmp2[i]);
+ }
+}
+
+
+
+static
+void Eval8InputsFloat(const cmsFloat32Number Input[],
+ cmsFloat32Number Output[],
+ const cmsInterpParams* p)
+{
+ const cmsFloat32Number* LutTable = (cmsFloat32Number*) p -> Table;
+ cmsFloat32Number rest;
+ cmsFloat32Number pk;
+ int k0, K0, K1;
+ const cmsFloat32Number* T;
+ cmsUInt32Number i;
+ cmsFloat32Number Tmp1[MAX_STAGE_CHANNELS], Tmp2[MAX_STAGE_CHANNELS];
+ cmsInterpParams p1;
+
+ pk = Input[0] * p->Domain[0];
+ k0 = _cmsQuickFloor(pk);
+ rest = pk - (cmsFloat32Number) k0;
+
+ K0 = p -> opta[7] * k0;
+ K1 = K0 + (Input[0] >= 1.0 ? 0 : p->opta[7]);
+
+ p1 = *p;
+ memmove(&p1.Domain[0], &p ->Domain[1], 7*sizeof(cmsUInt32Number));
+
+ T = LutTable + K0;
+ p1.Table = T;
+
+ Eval7InputsFloat(Input + 1, Tmp1, &p1);
+
+ T = LutTable + K1;
+ p1.Table = T;
+
+ Eval7InputsFloat(Input + 1, Tmp2, &p1);
+
+
+ for (i=0; i < p -> nOutputs; i++) {
+
+ cmsFloat32Number y0 = Tmp1[i];
+ cmsFloat32Number y1 = Tmp2[i];
+
+ Output[i] = y0 + (y1 - y0) * rest;
+ }
+}
+
+// The default factory
+static
+cmsInterpFunction DefaultInterpolatorsFactory(cmsUInt32Number nInputChannels, cmsUInt32Number nOutputChannels, cmsUInt32Number dwFlags)
+{
+
+ cmsInterpFunction Interpolation;
+ cmsBool IsFloat = (dwFlags & CMS_LERP_FLAGS_FLOAT);
+ cmsBool IsTrilinear = (dwFlags & CMS_LERP_FLAGS_TRILINEAR);
+
+ memset(&Interpolation, 0, sizeof(Interpolation));
+
+ // Safety check
+ if (nInputChannels >= 4 && nOutputChannels >= MAX_STAGE_CHANNELS)
+ return Interpolation;
+
+ switch (nInputChannels) {
+
+ case 1: // Gray LUT / linear
+
+ if (nOutputChannels == 1) {
+
+ if (IsFloat)
+ Interpolation.LerpFloat = LinLerp1Dfloat;
+ else
+ Interpolation.Lerp16 = LinLerp1D;
+
+ }
+ else {
+
+ if (IsFloat)
+ Interpolation.LerpFloat = Eval1InputFloat;
+ else
+ Interpolation.Lerp16 = Eval1Input;
+ }
+ break;
+
+ case 2: // Duotone
+ if (IsFloat)
+ Interpolation.LerpFloat = BilinearInterpFloat;
+ else
+ Interpolation.Lerp16 = BilinearInterp16;
+ break;
+
+ case 3: // RGB et al
+
+ if (IsTrilinear) {
+
+ if (IsFloat)
+ Interpolation.LerpFloat = TrilinearInterpFloat;
+ else
+ Interpolation.Lerp16 = TrilinearInterp16;
+ }
+ else {
+
+ if (IsFloat)
+ Interpolation.LerpFloat = TetrahedralInterpFloat;
+ else {
+
+ Interpolation.Lerp16 = TetrahedralInterp16;
+ }
+ }
+ break;
+
+ case 4: // CMYK lut
+
+ if (IsFloat)
+ Interpolation.LerpFloat = Eval4InputsFloat;
+ else
+ Interpolation.Lerp16 = Eval4Inputs;
+ break;
+
+ case 5: // 5 Inks
+ if (IsFloat)
+ Interpolation.LerpFloat = Eval5InputsFloat;
+ else
+ Interpolation.Lerp16 = Eval5Inputs;
+ break;
+
+ case 6: // 6 Inks
+ if (IsFloat)
+ Interpolation.LerpFloat = Eval6InputsFloat;
+ else
+ Interpolation.Lerp16 = Eval6Inputs;
+ break;
+
+ case 7: // 7 inks
+ if (IsFloat)
+ Interpolation.LerpFloat = Eval7InputsFloat;
+ else
+ Interpolation.Lerp16 = Eval7Inputs;
+ break;
+
+ case 8: // 8 inks
+ if (IsFloat)
+ Interpolation.LerpFloat = Eval8InputsFloat;
+ else
+ Interpolation.Lerp16 = Eval8Inputs;
+ break;
+
+ break;
+
+ default:
+ Interpolation.Lerp16 = NULL;
+ }
+
+ return Interpolation;
+}
diff --git a/src/lcms2.def b/src/lcms2.def
index d6a5de7..def9680 100644
--- a/src/lcms2.def
+++ b/src/lcms2.def
@@ -1,325 +1,325 @@
-LIBRARY LCMS2.DLL
-
-EXPORTS
-
-_cms15Fixed16toDouble = _cms15Fixed16toDouble
-_cms8Fixed8toDouble = _cms8Fixed8toDouble
-cmsAdaptToIlluminant = cmsAdaptToIlluminant
-_cmsAdjustEndianess16 = _cmsAdjustEndianess16
-_cmsAdjustEndianess32 = _cmsAdjustEndianess32
-_cmsAdjustEndianess64 = _cmsAdjustEndianess64
-cmsAllocNamedColorList = cmsAllocNamedColorList
-cmsAllocProfileSequenceDescription = cmsAllocProfileSequenceDescription
-cmsAppendNamedColor = cmsAppendNamedColor
-cmsBFDdeltaE = cmsBFDdeltaE
-cmsBuildGamma = cmsBuildGamma
-cmsBuildParametricToneCurve = cmsBuildParametricToneCurve
-cmsBuildSegmentedToneCurve = cmsBuildSegmentedToneCurve
-cmsBuildTabulatedToneCurve16 = cmsBuildTabulatedToneCurve16
-cmsBuildTabulatedToneCurveFloat = cmsBuildTabulatedToneCurveFloat
-_cmsCalloc = _cmsCalloc
-cmsChannelsOf = cmsChannelsOf
-cmsCIE2000DeltaE = cmsCIE2000DeltaE
-cmsCIE94DeltaE = cmsCIE94DeltaE
-cmsCIECAM02Done = cmsCIECAM02Done
-cmsCIECAM02Forward = cmsCIECAM02Forward
-cmsCIECAM02Init = cmsCIECAM02Init
-cmsCIECAM02Reverse = cmsCIECAM02Reverse
-cmsCloseIOhandler = cmsCloseIOhandler
-cmsCloseProfile = cmsCloseProfile
-cmsCMCdeltaE = cmsCMCdeltaE
-cmsCreate_sRGBProfile = cmsCreate_sRGBProfile
-cmsCreate_sRGBProfileTHR = cmsCreate_sRGBProfileTHR
-cmsCreateBCHSWabstractProfile = cmsCreateBCHSWabstractProfile
-cmsCreateBCHSWabstractProfileTHR = cmsCreateBCHSWabstractProfileTHR
-cmsCreateExtendedTransform = cmsCreateExtendedTransform
-cmsCreateGrayProfile = cmsCreateGrayProfile
-cmsCreateGrayProfileTHR = cmsCreateGrayProfileTHR
-cmsCreateInkLimitingDeviceLink = cmsCreateInkLimitingDeviceLink
-cmsCreateInkLimitingDeviceLinkTHR = cmsCreateInkLimitingDeviceLinkTHR
-cmsCreateLab2Profile = cmsCreateLab2Profile
-cmsCreateLab2ProfileTHR = cmsCreateLab2ProfileTHR
-cmsCreateLab4Profile = cmsCreateLab4Profile
-cmsCreateLab4ProfileTHR = cmsCreateLab4ProfileTHR
-cmsCreateLinearizationDeviceLink = cmsCreateLinearizationDeviceLink
-cmsCreateLinearizationDeviceLinkTHR = cmsCreateLinearizationDeviceLinkTHR
-cmsCreateMultiprofileTransform = cmsCreateMultiprofileTransform
-cmsCreateMultiprofileTransformTHR = cmsCreateMultiprofileTransformTHR
-cmsCreateNULLProfile = cmsCreateNULLProfile
-cmsCreateNULLProfileTHR = cmsCreateNULLProfileTHR
-cmsCreateProfilePlaceholder = cmsCreateProfilePlaceholder
-cmsCreateProofingTransform = cmsCreateProofingTransform
-cmsCreateProofingTransformTHR = cmsCreateProofingTransformTHR
-cmsCreateRGBProfile = cmsCreateRGBProfile
-cmsCreateRGBProfileTHR = cmsCreateRGBProfileTHR
-cmsCreateTransform = cmsCreateTransform
-cmsCreateTransformTHR = cmsCreateTransformTHR
-cmsCreateXYZProfile = cmsCreateXYZProfile
-cmsCreateXYZProfileTHR = cmsCreateXYZProfileTHR
-cmsD50_xyY = cmsD50_xyY
-cmsD50_XYZ = cmsD50_XYZ
-_cmsDecodeDateTimeNumber = _cmsDecodeDateTimeNumber
-_cmsDefaultICCintents = _cmsDefaultICCintents
-cmsDeleteTransform = cmsDeleteTransform
-cmsDeltaE = cmsDeltaE
-cmsDetectBlackPoint = cmsDetectBlackPoint
-cmsDetectDestinationBlackPoint = cmsDetectDestinationBlackPoint
-cmsDetectTAC = cmsDetectTAC
-cmsDesaturateLab = cmsDesaturateLab
-cmsDoTransform = cmsDoTransform
-cmsDoTransformStride = cmsDoTransformStride
-_cmsDoubleTo15Fixed16 = _cmsDoubleTo15Fixed16
-_cmsDoubleTo8Fixed8 = _cmsDoubleTo8Fixed8
-_cmsDupMem = _cmsDupMem
-cmsDupNamedColorList = cmsDupNamedColorList
-cmsDupProfileSequenceDescription = cmsDupProfileSequenceDescription
-cmsDupToneCurve = cmsDupToneCurve
-_cmsEncodeDateTimeNumber = _cmsEncodeDateTimeNumber
-cmsEstimateGamma = cmsEstimateGamma
-cmsGetToneCurveEstimatedTableEntries = cmsGetToneCurveEstimatedTableEntries
-cmsGetToneCurveEstimatedTable = cmsGetToneCurveEstimatedTable
-cmsEvalToneCurve16 = cmsEvalToneCurve16
-cmsEvalToneCurveFloat = cmsEvalToneCurveFloat
-cmsfilelength = cmsfilelength
-cmsFloat2LabEncoded = cmsFloat2LabEncoded
-cmsFloat2LabEncodedV2 = cmsFloat2LabEncodedV2
-cmsFloat2XYZEncoded = cmsFloat2XYZEncoded
-cmsFormatterForColorspaceOfProfile = cmsFormatterForColorspaceOfProfile
-cmsFormatterForPCSOfProfile = cmsFormatterForPCSOfProfile
-_cmsFree = _cmsFree
-cmsFreeNamedColorList = cmsFreeNamedColorList
-cmsFreeProfileSequenceDescription = cmsFreeProfileSequenceDescription
-cmsFreeToneCurve = cmsFreeToneCurve
-cmsFreeToneCurveTriple = cmsFreeToneCurveTriple
-cmsGBDAlloc = cmsGBDAlloc
-cmsGBDFree = cmsGBDFree
-cmsGDBAddPoint = cmsGDBAddPoint
-cmsGDBCheckPoint = cmsGDBCheckPoint
-cmsGDBCompute = cmsGDBCompute
-cmsGetAlarmCodes = cmsGetAlarmCodes
-cmsGetColorSpace = cmsGetColorSpace
-cmsGetDeviceClass = cmsGetDeviceClass
-cmsGetEncodedICCversion = cmsGetEncodedICCversion
-cmsGetHeaderAttributes = cmsGetHeaderAttributes
-cmsGetHeaderCreationDateTime = cmsGetHeaderCreationDateTime
-cmsGetHeaderFlags = cmsGetHeaderFlags
-cmsGetHeaderManufacturer = cmsGetHeaderManufacturer
-cmsGetHeaderModel = cmsGetHeaderModel
-cmsGetHeaderProfileID = cmsGetHeaderProfileID
-cmsGetHeaderRenderingIntent = cmsGetHeaderRenderingIntent
-cmsGetNamedColorList = cmsGetNamedColorList
-cmsGetPCS = cmsGetPCS
-cmsGetPostScriptColorResource = cmsGetPostScriptColorResource
-cmsGetPostScriptCRD = cmsGetPostScriptCRD
-cmsGetPostScriptCSA = cmsGetPostScriptCSA
-cmsGetProfileInfo = cmsGetProfileInfo
-cmsGetProfileInfoASCII = cmsGetProfileInfoASCII
-cmsGetProfileContextID = cmsGetProfileContextID
-cmsGetProfileVersion = cmsGetProfileVersion
-cmsGetSupportedIntents = cmsGetSupportedIntents
-cmsGetTagCount = cmsGetTagCount
-cmsGetTagSignature = cmsGetTagSignature
-cmsGetTransformContextID = cmsGetTransformContextID
-_cmsICCcolorSpace = _cmsICCcolorSpace
-_cmsIOPrintf = _cmsIOPrintf
-cmsIsCLUT = cmsIsCLUT
-cmsIsIntentSupported = cmsIsIntentSupported
-cmsIsMatrixShaper = cmsIsMatrixShaper
-cmsIsTag = cmsIsTag
-cmsIsToneCurveDescending = cmsIsToneCurveDescending
-cmsIsToneCurveLinear = cmsIsToneCurveLinear
-cmsIsToneCurveMonotonic = cmsIsToneCurveMonotonic
-cmsIsToneCurveMultisegment = cmsIsToneCurveMultisegment
-cmsGetToneCurveParametricType = cmsGetToneCurveParametricType
-cmsIT8Alloc = cmsIT8Alloc
-cmsIT8DefineDblFormat = cmsIT8DefineDblFormat
-cmsIT8EnumDataFormat = cmsIT8EnumDataFormat
-cmsIT8EnumProperties = cmsIT8EnumProperties
-cmsIT8EnumPropertyMulti = cmsIT8EnumPropertyMulti
-cmsIT8Free = cmsIT8Free
-cmsIT8GetData = cmsIT8GetData
-cmsIT8GetDataDbl = cmsIT8GetDataDbl
-cmsIT8FindDataFormat = cmsIT8FindDataFormat
-cmsIT8GetDataRowCol = cmsIT8GetDataRowCol
-cmsIT8GetDataRowColDbl = cmsIT8GetDataRowColDbl
-cmsIT8GetPatchName = cmsIT8GetPatchName
-cmsIT8GetPatchByName = cmsIT8GetPatchByName
-cmsIT8GetProperty = cmsIT8GetProperty
-cmsIT8GetPropertyDbl = cmsIT8GetPropertyDbl
-cmsIT8GetPropertyMulti = cmsIT8GetPropertyMulti
-cmsIT8GetSheetType = cmsIT8GetSheetType
-cmsIT8LoadFromFile = cmsIT8LoadFromFile
-cmsIT8LoadFromMem = cmsIT8LoadFromMem
-cmsIT8SaveToFile = cmsIT8SaveToFile
-cmsIT8SaveToMem = cmsIT8SaveToMem
-cmsIT8SetComment = cmsIT8SetComment
-cmsIT8SetData = cmsIT8SetData
-cmsIT8SetDataDbl = cmsIT8SetDataDbl
-cmsIT8SetDataFormat = cmsIT8SetDataFormat
-cmsIT8SetDataRowCol = cmsIT8SetDataRowCol
-cmsIT8SetDataRowColDbl = cmsIT8SetDataRowColDbl
-cmsIT8SetPropertyDbl = cmsIT8SetPropertyDbl
-cmsIT8SetPropertyHex = cmsIT8SetPropertyHex
-cmsIT8SetPropertyStr = cmsIT8SetPropertyStr
-cmsIT8SetPropertyMulti = cmsIT8SetPropertyMulti
-cmsIT8SetPropertyUncooked = cmsIT8SetPropertyUncooked
-cmsIT8SetSheetType = cmsIT8SetSheetType
-cmsIT8SetTable = cmsIT8SetTable
-cmsIT8SetTableByLabel = cmsIT8SetTableByLabel
-cmsIT8SetIndexColumn = cmsIT8SetIndexColumn
-cmsIT8TableCount = cmsIT8TableCount
-cmsJoinToneCurve = cmsJoinToneCurve
-cmsLab2LCh = cmsLab2LCh
-cmsLab2XYZ = cmsLab2XYZ
-cmsLabEncoded2Float = cmsLabEncoded2Float
-cmsLabEncoded2FloatV2 = cmsLabEncoded2FloatV2
-cmsLCh2Lab = cmsLCh2Lab
-_cmsLCMScolorSpace = _cmsLCMScolorSpace
-cmsLinkTag = cmsLinkTag
-cmsTagLinkedTo = cmsTagLinkedTo
-cmsPipelineAlloc = cmsPipelineAlloc
-cmsPipelineCat = cmsPipelineCat
-cmsPipelineCheckAndRetreiveStages = cmsPipelineCheckAndRetreiveStages
-cmsPipelineDup = cmsPipelineDup
-cmsPipelineStageCount = cmsPipelineStageCount
-cmsPipelineEval16 = cmsPipelineEval16
-cmsPipelineEvalFloat = cmsPipelineEvalFloat
-cmsPipelineEvalReverseFloat = cmsPipelineEvalReverseFloat
-cmsPipelineFree = cmsPipelineFree
-cmsPipelineGetPtrToFirstStage = cmsPipelineGetPtrToFirstStage
-cmsPipelineGetPtrToLastStage = cmsPipelineGetPtrToLastStage
-cmsPipelineInputChannels = cmsPipelineInputChannels
-cmsPipelineInsertStage = cmsPipelineInsertStage
-cmsPipelineOutputChannels = cmsPipelineOutputChannels
-cmsPipelineSetSaveAs8bitsFlag = cmsPipelineSetSaveAs8bitsFlag
-_cmsPipelineSetOptimizationParameters = _cmsPipelineSetOptimizationParameters
-cmsPipelineUnlinkStage = cmsPipelineUnlinkStage
-_cmsMalloc = _cmsMalloc
-_cmsMallocZero = _cmsMallocZero
-_cmsMAT3eval = _cmsMAT3eval
-_cmsMAT3identity = _cmsMAT3identity
-_cmsMAT3inverse = _cmsMAT3inverse
-_cmsMAT3isIdentity = _cmsMAT3isIdentity
-_cmsMAT3per = _cmsMAT3per
-_cmsMAT3solve = _cmsMAT3solve
-cmsMD5computeID = cmsMD5computeID
-cmsMLUalloc = cmsMLUalloc
-cmsMLUdup = cmsMLUdup
-cmsMLUfree = cmsMLUfree
-cmsMLUgetASCII = cmsMLUgetASCII
-cmsMLUgetTranslation = cmsMLUgetTranslation
-cmsMLUgetWide = cmsMLUgetWide
-cmsMLUsetASCII = cmsMLUsetASCII
-cmsMLUsetWide = cmsMLUsetWide
-cmsStageAllocCLut16bit = cmsStageAllocCLut16bit
-cmsStageAllocCLut16bitGranular = cmsStageAllocCLut16bitGranular
-cmsStageAllocCLutFloat = cmsStageAllocCLutFloat
-cmsStageAllocCLutFloatGranular = cmsStageAllocCLutFloatGranular
-cmsStageAllocToneCurves = cmsStageAllocToneCurves
-cmsStageAllocIdentity = cmsStageAllocIdentity
-cmsStageAllocMatrix = cmsStageAllocMatrix
-_cmsStageAllocPlaceholder = _cmsStageAllocPlaceholder
-cmsStageDup = cmsStageDup
-cmsStageFree = cmsStageFree
-cmsStageNext = cmsStageNext
-cmsStageInputChannels = cmsStageInputChannels
-cmsStageOutputChannels = cmsStageOutputChannels
-cmsStageSampleCLut16bit = cmsStageSampleCLut16bit
-cmsStageSampleCLutFloat = cmsStageSampleCLutFloat
-cmsStageType = cmsStageType
-cmsStageData = cmsStageData
-cmsNamedColorCount = cmsNamedColorCount
-cmsNamedColorIndex = cmsNamedColorIndex
-cmsNamedColorInfo = cmsNamedColorInfo
-cmsOpenIOhandlerFromFile = cmsOpenIOhandlerFromFile
-cmsOpenIOhandlerFromMem = cmsOpenIOhandlerFromMem
-cmsOpenIOhandlerFromNULL = cmsOpenIOhandlerFromNULL
-cmsOpenIOhandlerFromStream = cmsOpenIOhandlerFromStream
-cmsOpenProfileFromFile = cmsOpenProfileFromFile
-cmsOpenProfileFromFileTHR = cmsOpenProfileFromFileTHR
-cmsOpenProfileFromIOhandlerTHR = cmsOpenProfileFromIOhandlerTHR
-cmsOpenProfileFromMem = cmsOpenProfileFromMem
-cmsOpenProfileFromMemTHR = cmsOpenProfileFromMemTHR
-cmsOpenProfileFromStream = cmsOpenProfileFromStream
-cmsOpenProfileFromStreamTHR = cmsOpenProfileFromStreamTHR
-cmsPlugin = cmsPlugin
-_cmsRead15Fixed16Number = _cmsRead15Fixed16Number
-_cmsReadAlignment = _cmsReadAlignment
-_cmsReadFloat32Number = _cmsReadFloat32Number
-cmsReadRawTag = cmsReadRawTag
-cmsReadTag = cmsReadTag
-_cmsReadTypeBase = _cmsReadTypeBase
-_cmsReadUInt16Array = _cmsReadUInt16Array
-_cmsReadUInt16Number = _cmsReadUInt16Number
-_cmsReadUInt32Number = _cmsReadUInt32Number
-_cmsReadUInt64Number = _cmsReadUInt64Number
-_cmsReadUInt8Number = _cmsReadUInt8Number
-_cmsReadXYZNumber = _cmsReadXYZNumber
-_cmsRealloc = _cmsRealloc
-cmsReverseToneCurve = cmsReverseToneCurve
-cmsReverseToneCurveEx = cmsReverseToneCurveEx
-cmsSaveProfileToFile = cmsSaveProfileToFile
-cmsSaveProfileToIOhandler = cmsSaveProfileToIOhandler
-cmsSaveProfileToMem = cmsSaveProfileToMem
-cmsSaveProfileToStream = cmsSaveProfileToStream
-cmsSetAdaptationState = cmsSetAdaptationState
-cmsSetAlarmCodes = cmsSetAlarmCodes
-cmsSetColorSpace = cmsSetColorSpace
-cmsSetDeviceClass = cmsSetDeviceClass
-cmsSetEncodedICCversion = cmsSetEncodedICCversion
-cmsSetHeaderAttributes = cmsSetHeaderAttributes
-cmsSetHeaderFlags = cmsSetHeaderFlags
-cmsSetHeaderManufacturer = cmsSetHeaderManufacturer
-cmsSetHeaderModel = cmsSetHeaderModel
-cmsSetHeaderProfileID = cmsSetHeaderProfileID
-cmsSetHeaderRenderingIntent = cmsSetHeaderRenderingIntent
-cmsSetLogErrorHandler = cmsSetLogErrorHandler
-cmsSetPCS = cmsSetPCS
-cmsSetProfileVersion = cmsSetProfileVersion
-cmsSignalError = cmsSignalError
-cmsSmoothToneCurve = cmsSmoothToneCurve
-cmsstrcasecmp = cmsstrcasecmp
-cmsTempFromWhitePoint = cmsTempFromWhitePoint
-cmsTransform2DeviceLink = cmsTransform2DeviceLink
-cmsUnregisterPlugins = cmsUnregisterPlugins
-_cmsVEC3cross = _cmsVEC3cross
-_cmsVEC3distance = _cmsVEC3distance
-_cmsVEC3dot = _cmsVEC3dot
-_cmsVEC3init = _cmsVEC3init
-_cmsVEC3length = _cmsVEC3length
-_cmsVEC3minus = _cmsVEC3minus
-cmsWhitePointFromTemp = cmsWhitePointFromTemp
-_cmsWrite15Fixed16Number = _cmsWrite15Fixed16Number
-_cmsWriteAlignment = _cmsWriteAlignment
-_cmsWriteFloat32Number = _cmsWriteFloat32Number
-cmsWriteRawTag = cmsWriteRawTag
-cmsWriteTag = cmsWriteTag
-_cmsWriteTypeBase = _cmsWriteTypeBase
-_cmsWriteUInt16Array = _cmsWriteUInt16Array
-_cmsWriteUInt16Number = _cmsWriteUInt16Number
-_cmsWriteUInt32Number = _cmsWriteUInt32Number
-_cmsWriteUInt64Number = _cmsWriteUInt64Number
-_cmsWriteUInt8Number = _cmsWriteUInt8Number
-_cmsWriteXYZNumber = _cmsWriteXYZNumber
-cmsxyY2XYZ = cmsxyY2XYZ
-cmsXYZ2Lab = cmsXYZ2Lab
-cmsXYZ2xyY = cmsXYZ2xyY
-cmsXYZEncoded2Float = cmsXYZEncoded2Float
-cmsSliceSpace16 = cmsSliceSpace16
-cmsSliceSpaceFloat = cmsSliceSpaceFloat
-cmsChangeBuffersFormat = cmsChangeBuffersFormat
-cmsDictAlloc = cmsDictAlloc
-cmsDictFree = cmsDictFree
-cmsDictDup = cmsDictDup
-cmsDictAddEntry = cmsDictAddEntry
-cmsDictGetEntryList = cmsDictGetEntryList
-cmsDictNextEntry = cmsDictNextEntry
-_cmsGetTransformUserData = _cmsGetTransformUserData
-_cmsSetTransformUserData = _cmsSetTransformUserData
-_cmsGetTransformFormatters16 = _cmsGetTransformFormatters16
-_cmsGetTransformFormattersFloat = _cmsGetTransformFormattersFloat
-cmsGetHeaderCreator = cmsGetHeaderCreator
-cmsPluginTHR = cmsPluginTHR
-cmsGetPipelineContextID = cmsGetPipelineContextID
-cmsGetTransformInputFormat = cmsGetTransformInputFormat
-cmsGetTransformOutputFormat = cmsGetTransformOutputFormat
+LIBRARY LCMS2.DLL
+
+EXPORTS
+
+_cms15Fixed16toDouble = _cms15Fixed16toDouble
+_cms8Fixed8toDouble = _cms8Fixed8toDouble
+cmsAdaptToIlluminant = cmsAdaptToIlluminant
+_cmsAdjustEndianess16 = _cmsAdjustEndianess16
+_cmsAdjustEndianess32 = _cmsAdjustEndianess32
+_cmsAdjustEndianess64 = _cmsAdjustEndianess64
+cmsAllocNamedColorList = cmsAllocNamedColorList
+cmsAllocProfileSequenceDescription = cmsAllocProfileSequenceDescription
+cmsAppendNamedColor = cmsAppendNamedColor
+cmsBFDdeltaE = cmsBFDdeltaE
+cmsBuildGamma = cmsBuildGamma
+cmsBuildParametricToneCurve = cmsBuildParametricToneCurve
+cmsBuildSegmentedToneCurve = cmsBuildSegmentedToneCurve
+cmsBuildTabulatedToneCurve16 = cmsBuildTabulatedToneCurve16
+cmsBuildTabulatedToneCurveFloat = cmsBuildTabulatedToneCurveFloat
+_cmsCalloc = _cmsCalloc
+cmsChannelsOf = cmsChannelsOf
+cmsCIE2000DeltaE = cmsCIE2000DeltaE
+cmsCIE94DeltaE = cmsCIE94DeltaE
+cmsCIECAM02Done = cmsCIECAM02Done
+cmsCIECAM02Forward = cmsCIECAM02Forward
+cmsCIECAM02Init = cmsCIECAM02Init
+cmsCIECAM02Reverse = cmsCIECAM02Reverse
+cmsCloseIOhandler = cmsCloseIOhandler
+cmsCloseProfile = cmsCloseProfile
+cmsCMCdeltaE = cmsCMCdeltaE
+cmsCreate_sRGBProfile = cmsCreate_sRGBProfile
+cmsCreate_sRGBProfileTHR = cmsCreate_sRGBProfileTHR
+cmsCreateBCHSWabstractProfile = cmsCreateBCHSWabstractProfile
+cmsCreateBCHSWabstractProfileTHR = cmsCreateBCHSWabstractProfileTHR
+cmsCreateExtendedTransform = cmsCreateExtendedTransform
+cmsCreateGrayProfile = cmsCreateGrayProfile
+cmsCreateGrayProfileTHR = cmsCreateGrayProfileTHR
+cmsCreateInkLimitingDeviceLink = cmsCreateInkLimitingDeviceLink
+cmsCreateInkLimitingDeviceLinkTHR = cmsCreateInkLimitingDeviceLinkTHR
+cmsCreateLab2Profile = cmsCreateLab2Profile
+cmsCreateLab2ProfileTHR = cmsCreateLab2ProfileTHR
+cmsCreateLab4Profile = cmsCreateLab4Profile
+cmsCreateLab4ProfileTHR = cmsCreateLab4ProfileTHR
+cmsCreateLinearizationDeviceLink = cmsCreateLinearizationDeviceLink
+cmsCreateLinearizationDeviceLinkTHR = cmsCreateLinearizationDeviceLinkTHR
+cmsCreateMultiprofileTransform = cmsCreateMultiprofileTransform
+cmsCreateMultiprofileTransformTHR = cmsCreateMultiprofileTransformTHR
+cmsCreateNULLProfile = cmsCreateNULLProfile
+cmsCreateNULLProfileTHR = cmsCreateNULLProfileTHR
+cmsCreateProfilePlaceholder = cmsCreateProfilePlaceholder
+cmsCreateProofingTransform = cmsCreateProofingTransform
+cmsCreateProofingTransformTHR = cmsCreateProofingTransformTHR
+cmsCreateRGBProfile = cmsCreateRGBProfile
+cmsCreateRGBProfileTHR = cmsCreateRGBProfileTHR
+cmsCreateTransform = cmsCreateTransform
+cmsCreateTransformTHR = cmsCreateTransformTHR
+cmsCreateXYZProfile = cmsCreateXYZProfile
+cmsCreateXYZProfileTHR = cmsCreateXYZProfileTHR
+cmsD50_xyY = cmsD50_xyY
+cmsD50_XYZ = cmsD50_XYZ
+_cmsDecodeDateTimeNumber = _cmsDecodeDateTimeNumber
+_cmsDefaultICCintents = _cmsDefaultICCintents
+cmsDeleteTransform = cmsDeleteTransform
+cmsDeltaE = cmsDeltaE
+cmsDetectBlackPoint = cmsDetectBlackPoint
+cmsDetectDestinationBlackPoint = cmsDetectDestinationBlackPoint
+cmsDetectTAC = cmsDetectTAC
+cmsDesaturateLab = cmsDesaturateLab
+cmsDoTransform = cmsDoTransform
+cmsDoTransformStride = cmsDoTransformStride
+_cmsDoubleTo15Fixed16 = _cmsDoubleTo15Fixed16
+_cmsDoubleTo8Fixed8 = _cmsDoubleTo8Fixed8
+_cmsDupMem = _cmsDupMem
+cmsDupNamedColorList = cmsDupNamedColorList
+cmsDupProfileSequenceDescription = cmsDupProfileSequenceDescription
+cmsDupToneCurve = cmsDupToneCurve
+_cmsEncodeDateTimeNumber = _cmsEncodeDateTimeNumber
+cmsEstimateGamma = cmsEstimateGamma
+cmsGetToneCurveEstimatedTableEntries = cmsGetToneCurveEstimatedTableEntries
+cmsGetToneCurveEstimatedTable = cmsGetToneCurveEstimatedTable
+cmsEvalToneCurve16 = cmsEvalToneCurve16
+cmsEvalToneCurveFloat = cmsEvalToneCurveFloat
+cmsfilelength = cmsfilelength
+cmsFloat2LabEncoded = cmsFloat2LabEncoded
+cmsFloat2LabEncodedV2 = cmsFloat2LabEncodedV2
+cmsFloat2XYZEncoded = cmsFloat2XYZEncoded
+cmsFormatterForColorspaceOfProfile = cmsFormatterForColorspaceOfProfile
+cmsFormatterForPCSOfProfile = cmsFormatterForPCSOfProfile
+_cmsFree = _cmsFree
+cmsFreeNamedColorList = cmsFreeNamedColorList
+cmsFreeProfileSequenceDescription = cmsFreeProfileSequenceDescription
+cmsFreeToneCurve = cmsFreeToneCurve
+cmsFreeToneCurveTriple = cmsFreeToneCurveTriple
+cmsGBDAlloc = cmsGBDAlloc
+cmsGBDFree = cmsGBDFree
+cmsGDBAddPoint = cmsGDBAddPoint
+cmsGDBCheckPoint = cmsGDBCheckPoint
+cmsGDBCompute = cmsGDBCompute
+cmsGetAlarmCodes = cmsGetAlarmCodes
+cmsGetColorSpace = cmsGetColorSpace
+cmsGetDeviceClass = cmsGetDeviceClass
+cmsGetEncodedICCversion = cmsGetEncodedICCversion
+cmsGetHeaderAttributes = cmsGetHeaderAttributes
+cmsGetHeaderCreationDateTime = cmsGetHeaderCreationDateTime
+cmsGetHeaderFlags = cmsGetHeaderFlags
+cmsGetHeaderManufacturer = cmsGetHeaderManufacturer
+cmsGetHeaderModel = cmsGetHeaderModel
+cmsGetHeaderProfileID = cmsGetHeaderProfileID
+cmsGetHeaderRenderingIntent = cmsGetHeaderRenderingIntent
+cmsGetNamedColorList = cmsGetNamedColorList
+cmsGetPCS = cmsGetPCS
+cmsGetPostScriptColorResource = cmsGetPostScriptColorResource
+cmsGetPostScriptCRD = cmsGetPostScriptCRD
+cmsGetPostScriptCSA = cmsGetPostScriptCSA
+cmsGetProfileInfo = cmsGetProfileInfo
+cmsGetProfileInfoASCII = cmsGetProfileInfoASCII
+cmsGetProfileContextID = cmsGetProfileContextID
+cmsGetProfileVersion = cmsGetProfileVersion
+cmsGetSupportedIntents = cmsGetSupportedIntents
+cmsGetTagCount = cmsGetTagCount
+cmsGetTagSignature = cmsGetTagSignature
+cmsGetTransformContextID = cmsGetTransformContextID
+_cmsICCcolorSpace = _cmsICCcolorSpace
+_cmsIOPrintf = _cmsIOPrintf
+cmsIsCLUT = cmsIsCLUT
+cmsIsIntentSupported = cmsIsIntentSupported
+cmsIsMatrixShaper = cmsIsMatrixShaper
+cmsIsTag = cmsIsTag
+cmsIsToneCurveDescending = cmsIsToneCurveDescending
+cmsIsToneCurveLinear = cmsIsToneCurveLinear
+cmsIsToneCurveMonotonic = cmsIsToneCurveMonotonic
+cmsIsToneCurveMultisegment = cmsIsToneCurveMultisegment
+cmsGetToneCurveParametricType = cmsGetToneCurveParametricType
+cmsIT8Alloc = cmsIT8Alloc
+cmsIT8DefineDblFormat = cmsIT8DefineDblFormat
+cmsIT8EnumDataFormat = cmsIT8EnumDataFormat
+cmsIT8EnumProperties = cmsIT8EnumProperties
+cmsIT8EnumPropertyMulti = cmsIT8EnumPropertyMulti
+cmsIT8Free = cmsIT8Free
+cmsIT8GetData = cmsIT8GetData
+cmsIT8GetDataDbl = cmsIT8GetDataDbl
+cmsIT8FindDataFormat = cmsIT8FindDataFormat
+cmsIT8GetDataRowCol = cmsIT8GetDataRowCol
+cmsIT8GetDataRowColDbl = cmsIT8GetDataRowColDbl
+cmsIT8GetPatchName = cmsIT8GetPatchName
+cmsIT8GetPatchByName = cmsIT8GetPatchByName
+cmsIT8GetProperty = cmsIT8GetProperty
+cmsIT8GetPropertyDbl = cmsIT8GetPropertyDbl
+cmsIT8GetPropertyMulti = cmsIT8GetPropertyMulti
+cmsIT8GetSheetType = cmsIT8GetSheetType
+cmsIT8LoadFromFile = cmsIT8LoadFromFile
+cmsIT8LoadFromMem = cmsIT8LoadFromMem
+cmsIT8SaveToFile = cmsIT8SaveToFile
+cmsIT8SaveToMem = cmsIT8SaveToMem
+cmsIT8SetComment = cmsIT8SetComment
+cmsIT8SetData = cmsIT8SetData
+cmsIT8SetDataDbl = cmsIT8SetDataDbl
+cmsIT8SetDataFormat = cmsIT8SetDataFormat
+cmsIT8SetDataRowCol = cmsIT8SetDataRowCol
+cmsIT8SetDataRowColDbl = cmsIT8SetDataRowColDbl
+cmsIT8SetPropertyDbl = cmsIT8SetPropertyDbl
+cmsIT8SetPropertyHex = cmsIT8SetPropertyHex
+cmsIT8SetPropertyStr = cmsIT8SetPropertyStr
+cmsIT8SetPropertyMulti = cmsIT8SetPropertyMulti
+cmsIT8SetPropertyUncooked = cmsIT8SetPropertyUncooked
+cmsIT8SetSheetType = cmsIT8SetSheetType
+cmsIT8SetTable = cmsIT8SetTable
+cmsIT8SetTableByLabel = cmsIT8SetTableByLabel
+cmsIT8SetIndexColumn = cmsIT8SetIndexColumn
+cmsIT8TableCount = cmsIT8TableCount
+cmsJoinToneCurve = cmsJoinToneCurve
+cmsLab2LCh = cmsLab2LCh
+cmsLab2XYZ = cmsLab2XYZ
+cmsLabEncoded2Float = cmsLabEncoded2Float
+cmsLabEncoded2FloatV2 = cmsLabEncoded2FloatV2
+cmsLCh2Lab = cmsLCh2Lab
+_cmsLCMScolorSpace = _cmsLCMScolorSpace
+cmsLinkTag = cmsLinkTag
+cmsTagLinkedTo = cmsTagLinkedTo
+cmsPipelineAlloc = cmsPipelineAlloc
+cmsPipelineCat = cmsPipelineCat
+cmsPipelineCheckAndRetreiveStages = cmsPipelineCheckAndRetreiveStages
+cmsPipelineDup = cmsPipelineDup
+cmsPipelineStageCount = cmsPipelineStageCount
+cmsPipelineEval16 = cmsPipelineEval16
+cmsPipelineEvalFloat = cmsPipelineEvalFloat
+cmsPipelineEvalReverseFloat = cmsPipelineEvalReverseFloat
+cmsPipelineFree = cmsPipelineFree
+cmsPipelineGetPtrToFirstStage = cmsPipelineGetPtrToFirstStage
+cmsPipelineGetPtrToLastStage = cmsPipelineGetPtrToLastStage
+cmsPipelineInputChannels = cmsPipelineInputChannels
+cmsPipelineInsertStage = cmsPipelineInsertStage
+cmsPipelineOutputChannels = cmsPipelineOutputChannels
+cmsPipelineSetSaveAs8bitsFlag = cmsPipelineSetSaveAs8bitsFlag
+_cmsPipelineSetOptimizationParameters = _cmsPipelineSetOptimizationParameters
+cmsPipelineUnlinkStage = cmsPipelineUnlinkStage
+_cmsMalloc = _cmsMalloc
+_cmsMallocZero = _cmsMallocZero
+_cmsMAT3eval = _cmsMAT3eval
+_cmsMAT3identity = _cmsMAT3identity
+_cmsMAT3inverse = _cmsMAT3inverse
+_cmsMAT3isIdentity = _cmsMAT3isIdentity
+_cmsMAT3per = _cmsMAT3per
+_cmsMAT3solve = _cmsMAT3solve
+cmsMD5computeID = cmsMD5computeID
+cmsMLUalloc = cmsMLUalloc
+cmsMLUdup = cmsMLUdup
+cmsMLUfree = cmsMLUfree
+cmsMLUgetASCII = cmsMLUgetASCII
+cmsMLUgetTranslation = cmsMLUgetTranslation
+cmsMLUgetWide = cmsMLUgetWide
+cmsMLUsetASCII = cmsMLUsetASCII
+cmsMLUsetWide = cmsMLUsetWide
+cmsStageAllocCLut16bit = cmsStageAllocCLut16bit
+cmsStageAllocCLut16bitGranular = cmsStageAllocCLut16bitGranular
+cmsStageAllocCLutFloat = cmsStageAllocCLutFloat
+cmsStageAllocCLutFloatGranular = cmsStageAllocCLutFloatGranular
+cmsStageAllocToneCurves = cmsStageAllocToneCurves
+cmsStageAllocIdentity = cmsStageAllocIdentity
+cmsStageAllocMatrix = cmsStageAllocMatrix
+_cmsStageAllocPlaceholder = _cmsStageAllocPlaceholder
+cmsStageDup = cmsStageDup
+cmsStageFree = cmsStageFree
+cmsStageNext = cmsStageNext
+cmsStageInputChannels = cmsStageInputChannels
+cmsStageOutputChannels = cmsStageOutputChannels
+cmsStageSampleCLut16bit = cmsStageSampleCLut16bit
+cmsStageSampleCLutFloat = cmsStageSampleCLutFloat
+cmsStageType = cmsStageType
+cmsStageData = cmsStageData
+cmsNamedColorCount = cmsNamedColorCount
+cmsNamedColorIndex = cmsNamedColorIndex
+cmsNamedColorInfo = cmsNamedColorInfo
+cmsOpenIOhandlerFromFile = cmsOpenIOhandlerFromFile
+cmsOpenIOhandlerFromMem = cmsOpenIOhandlerFromMem
+cmsOpenIOhandlerFromNULL = cmsOpenIOhandlerFromNULL
+cmsOpenIOhandlerFromStream = cmsOpenIOhandlerFromStream
+cmsOpenProfileFromFile = cmsOpenProfileFromFile
+cmsOpenProfileFromFileTHR = cmsOpenProfileFromFileTHR
+cmsOpenProfileFromIOhandlerTHR = cmsOpenProfileFromIOhandlerTHR
+cmsOpenProfileFromMem = cmsOpenProfileFromMem
+cmsOpenProfileFromMemTHR = cmsOpenProfileFromMemTHR
+cmsOpenProfileFromStream = cmsOpenProfileFromStream
+cmsOpenProfileFromStreamTHR = cmsOpenProfileFromStreamTHR
+cmsPlugin = cmsPlugin
+_cmsRead15Fixed16Number = _cmsRead15Fixed16Number
+_cmsReadAlignment = _cmsReadAlignment
+_cmsReadFloat32Number = _cmsReadFloat32Number
+cmsReadRawTag = cmsReadRawTag
+cmsReadTag = cmsReadTag
+_cmsReadTypeBase = _cmsReadTypeBase
+_cmsReadUInt16Array = _cmsReadUInt16Array
+_cmsReadUInt16Number = _cmsReadUInt16Number
+_cmsReadUInt32Number = _cmsReadUInt32Number
+_cmsReadUInt64Number = _cmsReadUInt64Number
+_cmsReadUInt8Number = _cmsReadUInt8Number
+_cmsReadXYZNumber = _cmsReadXYZNumber
+_cmsRealloc = _cmsRealloc
+cmsReverseToneCurve = cmsReverseToneCurve
+cmsReverseToneCurveEx = cmsReverseToneCurveEx
+cmsSaveProfileToFile = cmsSaveProfileToFile
+cmsSaveProfileToIOhandler = cmsSaveProfileToIOhandler
+cmsSaveProfileToMem = cmsSaveProfileToMem
+cmsSaveProfileToStream = cmsSaveProfileToStream
+cmsSetAdaptationState = cmsSetAdaptationState
+cmsSetAlarmCodes = cmsSetAlarmCodes
+cmsSetColorSpace = cmsSetColorSpace
+cmsSetDeviceClass = cmsSetDeviceClass
+cmsSetEncodedICCversion = cmsSetEncodedICCversion
+cmsSetHeaderAttributes = cmsSetHeaderAttributes
+cmsSetHeaderFlags = cmsSetHeaderFlags
+cmsSetHeaderManufacturer = cmsSetHeaderManufacturer
+cmsSetHeaderModel = cmsSetHeaderModel
+cmsSetHeaderProfileID = cmsSetHeaderProfileID
+cmsSetHeaderRenderingIntent = cmsSetHeaderRenderingIntent
+cmsSetLogErrorHandler = cmsSetLogErrorHandler
+cmsSetPCS = cmsSetPCS
+cmsSetProfileVersion = cmsSetProfileVersion
+cmsSignalError = cmsSignalError
+cmsSmoothToneCurve = cmsSmoothToneCurve
+cmsstrcasecmp = cmsstrcasecmp
+cmsTempFromWhitePoint = cmsTempFromWhitePoint
+cmsTransform2DeviceLink = cmsTransform2DeviceLink
+cmsUnregisterPlugins = cmsUnregisterPlugins
+_cmsVEC3cross = _cmsVEC3cross
+_cmsVEC3distance = _cmsVEC3distance
+_cmsVEC3dot = _cmsVEC3dot
+_cmsVEC3init = _cmsVEC3init
+_cmsVEC3length = _cmsVEC3length
+_cmsVEC3minus = _cmsVEC3minus
+cmsWhitePointFromTemp = cmsWhitePointFromTemp
+_cmsWrite15Fixed16Number = _cmsWrite15Fixed16Number
+_cmsWriteAlignment = _cmsWriteAlignment
+_cmsWriteFloat32Number = _cmsWriteFloat32Number
+cmsWriteRawTag = cmsWriteRawTag
+cmsWriteTag = cmsWriteTag
+_cmsWriteTypeBase = _cmsWriteTypeBase
+_cmsWriteUInt16Array = _cmsWriteUInt16Array
+_cmsWriteUInt16Number = _cmsWriteUInt16Number
+_cmsWriteUInt32Number = _cmsWriteUInt32Number
+_cmsWriteUInt64Number = _cmsWriteUInt64Number
+_cmsWriteUInt8Number = _cmsWriteUInt8Number
+_cmsWriteXYZNumber = _cmsWriteXYZNumber
+cmsxyY2XYZ = cmsxyY2XYZ
+cmsXYZ2Lab = cmsXYZ2Lab
+cmsXYZ2xyY = cmsXYZ2xyY
+cmsXYZEncoded2Float = cmsXYZEncoded2Float
+cmsSliceSpace16 = cmsSliceSpace16
+cmsSliceSpaceFloat = cmsSliceSpaceFloat
+cmsChangeBuffersFormat = cmsChangeBuffersFormat
+cmsDictAlloc = cmsDictAlloc
+cmsDictFree = cmsDictFree
+cmsDictDup = cmsDictDup
+cmsDictAddEntry = cmsDictAddEntry
+cmsDictGetEntryList = cmsDictGetEntryList
+cmsDictNextEntry = cmsDictNextEntry
+_cmsGetTransformUserData = _cmsGetTransformUserData
+_cmsSetTransformUserData = _cmsSetTransformUserData
+_cmsGetTransformFormatters16 = _cmsGetTransformFormatters16
+_cmsGetTransformFormattersFloat = _cmsGetTransformFormattersFloat
+cmsGetHeaderCreator = cmsGetHeaderCreator
+cmsPluginTHR = cmsPluginTHR
+cmsGetPipelineContextID = cmsGetPipelineContextID
+cmsGetTransformInputFormat = cmsGetTransformInputFormat
+cmsGetTransformOutputFormat = cmsGetTransformOutputFormat
diff --git a/utils/common/vprf.c b/utils/common/vprf.c
index f6873ba..cec81b8 100644
--- a/utils/common/vprf.c
+++ b/utils/common/vprf.c
@@ -1,333 +1,333 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2010 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-
-#include "utils.h"
-
-
-int Verbose = 0;
-
-static char ProgramName[256] = "";
-
-void FatalError(const char *frm, ...)
-{
- va_list args;
-
- va_start(args, frm);
- fprintf(stderr, "[%s fatal error]: ", ProgramName);
- vfprintf(stderr, frm, args);
- fprintf(stderr, "\n");
- va_end(args);
-
- exit(1);
-}
-
-// Show errors to the end user (unless quiet option)
-static
-void MyErrorLogHandler(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *Text)
-{
- if (Verbose >= 0)
- fprintf(stderr, "[%s]: %s\n", ProgramName, Text);
-
- UTILS_UNUSED_PARAMETER(ErrorCode);
- UTILS_UNUSED_PARAMETER(ContextID);
-}
-
-
-void InitUtils(const char* PName)
-{
- strncpy(ProgramName, PName, sizeof(ProgramName));
- ProgramName[sizeof(ProgramName)-1] = 0;
-
- cmsSetLogErrorHandler(MyErrorLogHandler);
-}
-
-
-// Virtual profiles are handled here.
-cmsHPROFILE OpenStockProfile(cmsContext ContextID, const char* File)
-{
- if (!File)
- return cmsCreate_sRGBProfileTHR(ContextID);
-
- if (cmsstrcasecmp(File, "*Lab2") == 0)
- return cmsCreateLab2ProfileTHR(ContextID, NULL);
-
- if (cmsstrcasecmp(File, "*Lab4") == 0)
- return cmsCreateLab4ProfileTHR(ContextID, NULL);
-
- if (cmsstrcasecmp(File, "*Lab") == 0)
- return cmsCreateLab4ProfileTHR(ContextID, NULL);
-
- if (cmsstrcasecmp(File, "*LabD65") == 0) {
-
- cmsCIExyY D65xyY;
-
- cmsWhitePointFromTemp( &D65xyY, 6504);
- return cmsCreateLab4ProfileTHR(ContextID, &D65xyY);
- }
-
- if (cmsstrcasecmp(File, "*XYZ") == 0)
- return cmsCreateXYZProfileTHR(ContextID);
-
- if (cmsstrcasecmp(File, "*Gray22") == 0) {
-
- cmsToneCurve* Curve = cmsBuildGamma(ContextID, 2.2);
- cmsHPROFILE hProfile = cmsCreateGrayProfileTHR(ContextID, cmsD50_xyY(), Curve);
- cmsFreeToneCurve(Curve);
- return hProfile;
- }
-
- if (cmsstrcasecmp(File, "*Gray30") == 0) {
-
- cmsToneCurve* Curve = cmsBuildGamma(ContextID, 3.0);
- cmsHPROFILE hProfile = cmsCreateGrayProfileTHR(ContextID, cmsD50_xyY(), Curve);
- cmsFreeToneCurve(Curve);
- return hProfile;
- }
-
- if (cmsstrcasecmp(File, "*srgb") == 0)
- return cmsCreate_sRGBProfileTHR(ContextID);
-
- if (cmsstrcasecmp(File, "*null") == 0)
- return cmsCreateNULLProfileTHR(ContextID);
-
-
- if (cmsstrcasecmp(File, "*Lin2222") == 0) {
-
- cmsToneCurve* Gamma = cmsBuildGamma(0, 2.2);
- cmsToneCurve* Gamma4[4];
- cmsHPROFILE hProfile;
-
- Gamma4[0] = Gamma4[1] = Gamma4[2] = Gamma4[3] = Gamma;
- hProfile = cmsCreateLinearizationDeviceLink(cmsSigCmykData, Gamma4);
- cmsFreeToneCurve(Gamma);
- return hProfile;
- }
-
-
- return cmsOpenProfileFromFileTHR(ContextID, File, "r");
-}
-
-// Help on available built-ins
-void PrintBuiltins(void)
-{
- fprintf(stderr, "\nBuilt-in profiles:\n\n");
- fprintf(stderr, "\t*Lab2 -- D50-based v2 CIEL*a*b\n"
- "\t*Lab4 -- D50-based v4 CIEL*a*b\n"
- "\t*Lab -- D50-based v4 CIEL*a*b\n"
- "\t*XYZ -- CIE XYZ (PCS)\n"
- "\t*sRGB -- sRGB color space\n"
- "\t*Gray22 - Monochrome of Gamma 2.2\n"
- "\t*Gray30 - Monochrome of Gamma 3.0\n"
- "\t*null - Monochrome black for all input\n"
- "\t*Lin2222- CMYK linearization of gamma 2.2 on each channel\n");
-}
-
-
-// Auxiliar for printing information on profile
-static
-void PrintInfo(cmsHPROFILE h, cmsInfoType Info)
-{
- char* text;
- int len;
-
- len = cmsGetProfileInfoASCII(h, Info, "en", "US", NULL, 0);
- if (len == 0) return;
-
- text = malloc(len * sizeof(char));
- if (text == NULL) return;
-
- cmsGetProfileInfoASCII(h, Info, "en", "US", text, len);
-
- if (strlen(text) > 0)
- printf("%s\n", text);
-
- free(text);
-}
-
-
-
-// Displays the colorant table
-static
-void PrintColorantTable(cmsHPROFILE hInput, cmsTagSignature Sig, const char* Title)
-{
- cmsNAMEDCOLORLIST* list;
- int i, n;
-
- if (cmsIsTag(hInput, Sig)) {
-
- printf("%s:\n", Title);
-
- list = cmsReadTag(hInput, Sig);
- if (list == NULL) {
- printf("(Unavailable)\n");
- return;
- }
-
- n = cmsNamedColorCount(list);
- for (i=0; i < n; i++) {
-
- char Name[cmsMAX_PATH];
-
- cmsNamedColorInfo(list, i, Name, NULL, NULL, NULL, NULL);
- printf("\t%s\n", Name);
- }
-
- printf("\n");
- }
-
-}
-
-
-void PrintProfileInformation(cmsHPROFILE hInput)
-{
- PrintInfo(hInput, cmsInfoDescription);
- PrintInfo(hInput, cmsInfoManufacturer);
- PrintInfo(hInput, cmsInfoModel);
- PrintInfo(hInput, cmsInfoCopyright);
-
- if (Verbose > 2) {
-
- PrintColorantTable(hInput, cmsSigColorantTableTag, "Input colorant table");
- PrintColorantTable(hInput, cmsSigColorantTableOutTag, "Input colorant out table");
- }
-
- printf("\n");
-}
-
-// -----------------------------------------------------------------------------
-
-
-void PrintRenderingIntents(void)
-{
- cmsUInt32Number Codes[200];
- char* Descriptions[200];
- cmsUInt32Number n, i;
-
- fprintf(stderr, "%ct<n> rendering intent:\n\n", SW);
-
- n = cmsGetSupportedIntents(200, Codes, Descriptions);
-
- for (i=0; i < n; i++) {
- fprintf(stderr, "\t%u - %s\n", Codes[i], Descriptions[i]);
- }
- fprintf(stderr, "\n");
-}
-
-
-
-// ------------------------------------------------------------------------------
-
-cmsBool SaveMemoryBlock(const cmsUInt8Number* Buffer, cmsUInt32Number dwLen, const char* Filename)
-{
- FILE* out = fopen(Filename, "wb");
- if (out == NULL) {
- FatalError("Cannot create '%s'", Filename);
- return FALSE;
- }
-
- if (fwrite(Buffer, 1, dwLen, out) != dwLen) {
- FatalError("Cannot write %ld bytes to %s", dwLen, Filename);
- return FALSE;
- }
-
- if (fclose(out) != 0) {
- FatalError("Error flushing file '%s'", Filename);
- return FALSE;
- }
-
- return TRUE;
-}
-
-// ------------------------------------------------------------------------------
-
-// Return a pixel type on depending on the number of channels
-int PixelTypeFromChanCount(int ColorChannels)
-{
- switch (ColorChannels) {
-
- case 1: return PT_GRAY;
- case 2: return PT_MCH2;
- case 3: return PT_MCH3;
- case 4: return PT_CMYK;
- case 5: return PT_MCH5;
- case 6: return PT_MCH6;
- case 7: return PT_MCH7;
- case 8: return PT_MCH8;
- case 9: return PT_MCH9;
- case 10: return PT_MCH10;
- case 11: return PT_MCH11;
- case 12: return PT_MCH12;
- case 13: return PT_MCH13;
- case 14: return PT_MCH14;
- case 15: return PT_MCH15;
-
- default:
-
- FatalError("What a weird separation of %d channels?!?!", ColorChannels);
- return -1;
- }
-}
-
-
-// ------------------------------------------------------------------------------
-
-// Return number of channels of pixel type
-int ChanCountFromPixelType(int ColorChannels)
-{
- switch (ColorChannels) {
-
- case PT_GRAY: return 1;
-
- case PT_RGB:
- case PT_CMY:
- case PT_Lab:
- case PT_YUV:
- case PT_YCbCr: return 3;
-
- case PT_CMYK: return 4 ;
- case PT_MCH2: return 2 ;
- case PT_MCH3: return 3 ;
- case PT_MCH4: return 4 ;
- case PT_MCH5: return 5 ;
- case PT_MCH6: return 6 ;
- case PT_MCH7: return 7 ;
- case PT_MCH8: return 8 ;
- case PT_MCH9: return 9 ;
- case PT_MCH10: return 10;
- case PT_MCH11: return 11;
- case PT_MCH12: return 12;
- case PT_MCH13: return 12;
- case PT_MCH14: return 14;
- case PT_MCH15: return 15;
-
- default:
-
- FatalError("Unsupported color space of %d channels", ColorChannels);
- return -1;
- }
-}
-
-
+//---------------------------------------------------------------------------------
+//
+// Little Color Management System
+// Copyright (c) 1998-2010 Marti Maria Saguer
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the Software
+// is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//---------------------------------------------------------------------------------
+//
+
+#include "utils.h"
+
+
+int Verbose = 0;
+
+static char ProgramName[256] = "";
+
+void FatalError(const char *frm, ...)
+{
+ va_list args;
+
+ va_start(args, frm);
+ fprintf(stderr, "[%s fatal error]: ", ProgramName);
+ vfprintf(stderr, frm, args);
+ fprintf(stderr, "\n");
+ va_end(args);
+
+ exit(1);
+}
+
+// Show errors to the end user (unless quiet option)
+static
+void MyErrorLogHandler(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *Text)
+{
+ if (Verbose >= 0)
+ fprintf(stderr, "[%s]: %s\n", ProgramName, Text);
+
+ UTILS_UNUSED_PARAMETER(ErrorCode);
+ UTILS_UNUSED_PARAMETER(ContextID);
+}
+
+
+void InitUtils(const char* PName)
+{
+ strncpy(ProgramName, PName, sizeof(ProgramName));
+ ProgramName[sizeof(ProgramName)-1] = 0;
+
+ cmsSetLogErrorHandler(MyErrorLogHandler);
+}
+
+
+// Virtual profiles are handled here.
+cmsHPROFILE OpenStockProfile(cmsContext ContextID, const char* File)
+{
+ if (!File)
+ return cmsCreate_sRGBProfileTHR(ContextID);
+
+ if (cmsstrcasecmp(File, "*Lab2") == 0)
+ return cmsCreateLab2ProfileTHR(ContextID, NULL);
+
+ if (cmsstrcasecmp(File, "*Lab4") == 0)
+ return cmsCreateLab4ProfileTHR(ContextID, NULL);
+
+ if (cmsstrcasecmp(File, "*Lab") == 0)
+ return cmsCreateLab4ProfileTHR(ContextID, NULL);
+
+ if (cmsstrcasecmp(File, "*LabD65") == 0) {
+
+ cmsCIExyY D65xyY;
+
+ cmsWhitePointFromTemp( &D65xyY, 6504);
+ return cmsCreateLab4ProfileTHR(ContextID, &D65xyY);
+ }
+
+ if (cmsstrcasecmp(File, "*XYZ") == 0)
+ return cmsCreateXYZProfileTHR(ContextID);
+
+ if (cmsstrcasecmp(File, "*Gray22") == 0) {
+
+ cmsToneCurve* Curve = cmsBuildGamma(ContextID, 2.2);
+ cmsHPROFILE hProfile = cmsCreateGrayProfileTHR(ContextID, cmsD50_xyY(), Curve);
+ cmsFreeToneCurve(Curve);
+ return hProfile;
+ }
+
+ if (cmsstrcasecmp(File, "*Gray30") == 0) {
+
+ cmsToneCurve* Curve = cmsBuildGamma(ContextID, 3.0);
+ cmsHPROFILE hProfile = cmsCreateGrayProfileTHR(ContextID, cmsD50_xyY(), Curve);
+ cmsFreeToneCurve(Curve);
+ return hProfile;
+ }
+
+ if (cmsstrcasecmp(File, "*srgb") == 0)
+ return cmsCreate_sRGBProfileTHR(ContextID);
+
+ if (cmsstrcasecmp(File, "*null") == 0)
+ return cmsCreateNULLProfileTHR(ContextID);
+
+
+ if (cmsstrcasecmp(File, "*Lin2222") == 0) {
+
+ cmsToneCurve* Gamma = cmsBuildGamma(0, 2.2);
+ cmsToneCurve* Gamma4[4];
+ cmsHPROFILE hProfile;
+
+ Gamma4[0] = Gamma4[1] = Gamma4[2] = Gamma4[3] = Gamma;
+ hProfile = cmsCreateLinearizationDeviceLink(cmsSigCmykData, Gamma4);
+ cmsFreeToneCurve(Gamma);
+ return hProfile;
+ }
+
+
+ return cmsOpenProfileFromFileTHR(ContextID, File, "r");
+}
+
+// Help on available built-ins
+void PrintBuiltins(void)
+{
+ fprintf(stderr, "\nBuilt-in profiles:\n\n");
+ fprintf(stderr, "\t*Lab2 -- D50-based v2 CIEL*a*b\n"
+ "\t*Lab4 -- D50-based v4 CIEL*a*b\n"
+ "\t*Lab -- D50-based v4 CIEL*a*b\n"
+ "\t*XYZ -- CIE XYZ (PCS)\n"
+ "\t*sRGB -- sRGB color space\n"
+ "\t*Gray22 - Monochrome of Gamma 2.2\n"
+ "\t*Gray30 - Monochrome of Gamma 3.0\n"
+ "\t*null - Monochrome black for all input\n"
+ "\t*Lin2222- CMYK linearization of gamma 2.2 on each channel\n");
+}
+
+
+// Auxiliar for printing information on profile
+static
+void PrintInfo(cmsHPROFILE h, cmsInfoType Info)
+{
+ char* text;
+ int len;
+
+ len = cmsGetProfileInfoASCII(h, Info, "en", "US", NULL, 0);
+ if (len == 0) return;
+
+ text = malloc(len * sizeof(char));
+ if (text == NULL) return;
+
+ cmsGetProfileInfoASCII(h, Info, "en", "US", text, len);
+
+ if (strlen(text) > 0)
+ printf("%s\n", text);
+
+ free(text);
+}
+
+
+
+// Displays the colorant table
+static
+void PrintColorantTable(cmsHPROFILE hInput, cmsTagSignature Sig, const char* Title)
+{
+ cmsNAMEDCOLORLIST* list;
+ int i, n;
+
+ if (cmsIsTag(hInput, Sig)) {
+
+ printf("%s:\n", Title);
+
+ list = cmsReadTag(hInput, Sig);
+ if (list == NULL) {
+ printf("(Unavailable)\n");
+ return;
+ }
+
+ n = cmsNamedColorCount(list);
+ for (i=0; i < n; i++) {
+
+ char Name[cmsMAX_PATH];
+
+ cmsNamedColorInfo(list, i, Name, NULL, NULL, NULL, NULL);
+ printf("\t%s\n", Name);
+ }
+
+ printf("\n");
+ }
+
+}
+
+
+void PrintProfileInformation(cmsHPROFILE hInput)
+{
+ PrintInfo(hInput, cmsInfoDescription);
+ PrintInfo(hInput, cmsInfoManufacturer);
+ PrintInfo(hInput, cmsInfoModel);
+ PrintInfo(hInput, cmsInfoCopyright);
+
+ if (Verbose > 2) {
+
+ PrintColorantTable(hInput, cmsSigColorantTableTag, "Input colorant table");
+ PrintColorantTable(hInput, cmsSigColorantTableOutTag, "Input colorant out table");
+ }
+
+ printf("\n");
+}
+
+// -----------------------------------------------------------------------------
+
+
+void PrintRenderingIntents(void)
+{
+ cmsUInt32Number Codes[200];
+ char* Descriptions[200];
+ cmsUInt32Number n, i;
+
+ fprintf(stderr, "%ct<n> rendering intent:\n\n", SW);
+
+ n = cmsGetSupportedIntents(200, Codes, Descriptions);
+
+ for (i=0; i < n; i++) {
+ fprintf(stderr, "\t%u - %s\n", Codes[i], Descriptions[i]);
+ }
+ fprintf(stderr, "\n");
+}
+
+
+
+// ------------------------------------------------------------------------------
+
+cmsBool SaveMemoryBlock(const cmsUInt8Number* Buffer, cmsUInt32Number dwLen, const char* Filename)
+{
+ FILE* out = fopen(Filename, "wb");
+ if (out == NULL) {
+ FatalError("Cannot create '%s'", Filename);
+ return FALSE;
+ }
+
+ if (fwrite(Buffer, 1, dwLen, out) != dwLen) {
+ FatalError("Cannot write %ld bytes to %s", dwLen, Filename);
+ return FALSE;
+ }
+
+ if (fclose(out) != 0) {
+ FatalError("Error flushing file '%s'", Filename);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+// ------------------------------------------------------------------------------
+
+// Return a pixel type on depending on the number of channels
+int PixelTypeFromChanCount(int ColorChannels)
+{
+ switch (ColorChannels) {
+
+ case 1: return PT_GRAY;
+ case 2: return PT_MCH2;
+ case 3: return PT_MCH3;
+ case 4: return PT_CMYK;
+ case 5: return PT_MCH5;
+ case 6: return PT_MCH6;
+ case 7: return PT_MCH7;
+ case 8: return PT_MCH8;
+ case 9: return PT_MCH9;
+ case 10: return PT_MCH10;
+ case 11: return PT_MCH11;
+ case 12: return PT_MCH12;
+ case 13: return PT_MCH13;
+ case 14: return PT_MCH14;
+ case 15: return PT_MCH15;
+
+ default:
+
+ FatalError("What a weird separation of %d channels?!?!", ColorChannels);
+ return -1;
+ }
+}
+
+
+// ------------------------------------------------------------------------------
+
+// Return number of channels of pixel type
+int ChanCountFromPixelType(int ColorChannels)
+{
+ switch (ColorChannels) {
+
+ case PT_GRAY: return 1;
+
+ case PT_RGB:
+ case PT_CMY:
+ case PT_Lab:
+ case PT_YUV:
+ case PT_YCbCr: return 3;
+
+ case PT_CMYK: return 4 ;
+ case PT_MCH2: return 2 ;
+ case PT_MCH3: return 3 ;
+ case PT_MCH4: return 4 ;
+ case PT_MCH5: return 5 ;
+ case PT_MCH6: return 6 ;
+ case PT_MCH7: return 7 ;
+ case PT_MCH8: return 8 ;
+ case PT_MCH9: return 9 ;
+ case PT_MCH10: return 10;
+ case PT_MCH11: return 11;
+ case PT_MCH12: return 12;
+ case PT_MCH13: return 12;
+ case PT_MCH14: return 14;
+ case PT_MCH15: return 15;
+
+ default:
+
+ FatalError("Unsupported color space of %d channels", ColorChannels);
+ return -1;
+ }
+}
+
+
diff --git a/utils/delphi/delphidemo.dpr b/utils/delphi/delphidemo.dpr
index a78d56c..9180c04 100755..100644
--- a/utils/delphi/delphidemo.dpr
+++ b/utils/delphi/delphidemo.dpr
@@ -1,13 +1,13 @@
-program delphidemo;
-
-uses
- Forms,
- demo1 in 'demo1.pas' {Form1};
-
-{$R *.RES}
-
-begin
- Application.Initialize;
- Application.CreateForm(TForm1, Form1);
- Application.Run;
-end.
+program delphidemo;
+
+uses
+ Forms,
+ demo1 in 'demo1.pas' {Form1};
+
+{$R *.RES}
+
+begin
+ Application.Initialize;
+ Application.CreateForm(TForm1, Form1);
+ Application.Run;
+end.
diff --git a/utils/delphi/delphidemo.dproj b/utils/delphi/delphidemo.dproj
index 61fc4f2..25b97d8 100755..100644
--- a/utils/delphi/delphidemo.dproj
+++ b/utils/delphi/delphidemo.dproj
@@ -1,114 +1,114 @@
- <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <ProjectGuid>{E3F889E8-CB8A-49AE-8173-4DDA022466BE}</ProjectGuid>
- <MainSource>delphidemo.dpr</MainSource>
- <Config Condition="'$(Config)'==''">Debug</Config>
- <DCC_DCCCompiler>DCC32</DCC_DCCCompiler>
- <ProjectVersion>12.0</ProjectVersion>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
- <Base>true</Base>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_1)'!=''">
- <Cfg_1>true</Cfg_1>
- <CfgParent>Base</CfgParent>
- <Base>true</Base>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_2)'!=''">
- <Cfg_2>true</Cfg_2>
- <CfgParent>Base</CfgParent>
- <Base>true</Base>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Base)'!=''">
- <DCC_UsePackage>vcl;rtl;vclx;vclimg;vclactnband;dbrtl;vcldb;vcldbx;bdertl;vcltouch;xmlrtl;dsnap;dsnapcon;TeeUI;TeeDB;Tee;vclib;ibxpress;adortl;IndyCore;IndySystem;IndyProtocols;inet;intrawebdb_100_140;Intraweb_100_140;VclSmp;vclie;websnap;webdsnap;inetdb;inetdbbde;inetdbxpress;soaprtl;vclribbon;dbexpress;DbxCommonDriver;DataSnapIndy10ServerTransport;DataSnapProviderClient;DbxClientDriver;DataSnapServer;DBXInterBaseDriver;DBXMySQLDriver;dbxcds;DBXFirebirdDriver;DBXSybaseASEDriver;DBXSybaseASADriver;DBXOracleDriver;DBXMSSQLDriver;DBXInformixDriver;DBXDb2Driver;Rave77VCL</DCC_UsePackage>
- <DCC_ImageBase>00400000</DCC_ImageBase>
- <DCC_SymbolReferenceInfo>1</DCC_SymbolReferenceInfo>
- <DCC_DependencyCheckOutputName>delphidemo.exe</DCC_DependencyCheckOutputName>
- <DCC_UnitAlias>WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;WinTypes=Windows;WinProcs=Windows;$(DCC_UnitAlias)</DCC_UnitAlias>
- <DCC_Platform>x86</DCC_Platform>
- <DCC_N>true</DCC_N>
- <DCC_S>false</DCC_S>
- <DCC_K>false</DCC_K>
- <DCC_E>false</DCC_E>
- <DCC_F>false</DCC_F>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Cfg_1)'!=''">
- <DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
- <DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
- <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
- <DCC_DebugInformation>false</DCC_DebugInformation>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Cfg_2)'!=''">
- <DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
- </PropertyGroup>
- <ItemGroup>
- <DelphiCompile Include="delphidemo.dpr">
- <MainSource>MainSource</MainSource>
- </DelphiCompile>
- <DCCReference Include="demo1.pas">
- <Form>Form1</Form>
- </DCCReference>
- <BuildConfiguration Include="Base">
- <Key>Base</Key>
- </BuildConfiguration>
- <BuildConfiguration Include="Debug">
- <Key>Cfg_2</Key>
- <CfgParent>Base</CfgParent>
- </BuildConfiguration>
- <BuildConfiguration Include="Release">
- <Key>Cfg_1</Key>
- <CfgParent>Base</CfgParent>
- </BuildConfiguration>
- </ItemGroup>
- <Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/>
- <ProjectExtensions>
- <Borland.Personality>Delphi.Personality.12</Borland.Personality>
- <Borland.ProjectType>VCLApplication</Borland.ProjectType>
- <BorlandProject>
- <Delphi.Personality>
- <Source>
- <Source Name="MainSource">delphidemo.dpr</Source>
- </Source>
- <Parameters>
- <Parameters Name="UseLauncher">False</Parameters>
- <Parameters Name="DebugCWD">d:\lcms-1.13\delphi</Parameters>
- <Parameters Name="LoadAllSymbols">True</Parameters>
- <Parameters Name="LoadUnspecifiedSymbols">False</Parameters>
- </Parameters>
- <VersionInfo>
- <VersionInfo Name="IncludeVerInfo">False</VersionInfo>
- <VersionInfo Name="AutoIncBuild">False</VersionInfo>
- <VersionInfo Name="MajorVer">1</VersionInfo>
- <VersionInfo Name="MinorVer">0</VersionInfo>
- <VersionInfo Name="Release">0</VersionInfo>
- <VersionInfo Name="Build">0</VersionInfo>
- <VersionInfo Name="Debug">False</VersionInfo>
- <VersionInfo Name="PreRelease">False</VersionInfo>
- <VersionInfo Name="Special">False</VersionInfo>
- <VersionInfo Name="Private">False</VersionInfo>
- <VersionInfo Name="DLL">False</VersionInfo>
- <VersionInfo Name="Locale">3082</VersionInfo>
- <VersionInfo Name="CodePage">1252</VersionInfo>
- </VersionInfo>
- <VersionInfoKeys>
- <VersionInfoKeys Name="CompanyName"/>
- <VersionInfoKeys Name="FileDescription"/>
- <VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
- <VersionInfoKeys Name="InternalName"/>
- <VersionInfoKeys Name="LegalCopyright"/>
- <VersionInfoKeys Name="LegalTrademarks"/>
- <VersionInfoKeys Name="OriginalFilename"/>
- <VersionInfoKeys Name="ProductName"/>
- <VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
- <VersionInfoKeys Name="Comments"/>
- </VersionInfoKeys>
- <Excluded_Packages>
- <Excluded_Packages Name="$(BDS)\bin\dcloffice2k140.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
- <Excluded_Packages Name="$(BDS)\bin\dclofficexp140.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
- </Excluded_Packages>
- </Delphi.Personality>
- <ModelSupport>False</ModelSupport>
- </BorlandProject>
- <ProjectFileVersion>12</ProjectFileVersion>
- </ProjectExtensions>
- </Project>
+ <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <ProjectGuid>{E3F889E8-CB8A-49AE-8173-4DDA022466BE}</ProjectGuid>
+ <MainSource>delphidemo.dpr</MainSource>
+ <Config Condition="'$(Config)'==''">Debug</Config>
+ <DCC_DCCCompiler>DCC32</DCC_DCCCompiler>
+ <ProjectVersion>12.0</ProjectVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
+ <Base>true</Base>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_1)'!=''">
+ <Cfg_1>true</Cfg_1>
+ <CfgParent>Base</CfgParent>
+ <Base>true</Base>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_2)'!=''">
+ <Cfg_2>true</Cfg_2>
+ <CfgParent>Base</CfgParent>
+ <Base>true</Base>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Base)'!=''">
+ <DCC_UsePackage>vcl;rtl;vclx;vclimg;vclactnband;dbrtl;vcldb;vcldbx;bdertl;vcltouch;xmlrtl;dsnap;dsnapcon;TeeUI;TeeDB;Tee;vclib;ibxpress;adortl;IndyCore;IndySystem;IndyProtocols;inet;intrawebdb_100_140;Intraweb_100_140;VclSmp;vclie;websnap;webdsnap;inetdb;inetdbbde;inetdbxpress;soaprtl;vclribbon;dbexpress;DbxCommonDriver;DataSnapIndy10ServerTransport;DataSnapProviderClient;DbxClientDriver;DataSnapServer;DBXInterBaseDriver;DBXMySQLDriver;dbxcds;DBXFirebirdDriver;DBXSybaseASEDriver;DBXSybaseASADriver;DBXOracleDriver;DBXMSSQLDriver;DBXInformixDriver;DBXDb2Driver;Rave77VCL</DCC_UsePackage>
+ <DCC_ImageBase>00400000</DCC_ImageBase>
+ <DCC_SymbolReferenceInfo>1</DCC_SymbolReferenceInfo>
+ <DCC_DependencyCheckOutputName>delphidemo.exe</DCC_DependencyCheckOutputName>
+ <DCC_UnitAlias>WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;WinTypes=Windows;WinProcs=Windows;$(DCC_UnitAlias)</DCC_UnitAlias>
+ <DCC_Platform>x86</DCC_Platform>
+ <DCC_N>true</DCC_N>
+ <DCC_S>false</DCC_S>
+ <DCC_K>false</DCC_K>
+ <DCC_E>false</DCC_E>
+ <DCC_F>false</DCC_F>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Cfg_1)'!=''">
+ <DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
+ <DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
+ <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
+ <DCC_DebugInformation>false</DCC_DebugInformation>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Cfg_2)'!=''">
+ <DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
+ </PropertyGroup>
+ <ItemGroup>
+ <DelphiCompile Include="delphidemo.dpr">
+ <MainSource>MainSource</MainSource>
+ </DelphiCompile>
+ <DCCReference Include="demo1.pas">
+ <Form>Form1</Form>
+ </DCCReference>
+ <BuildConfiguration Include="Base">
+ <Key>Base</Key>
+ </BuildConfiguration>
+ <BuildConfiguration Include="Debug">
+ <Key>Cfg_2</Key>
+ <CfgParent>Base</CfgParent>
+ </BuildConfiguration>
+ <BuildConfiguration Include="Release">
+ <Key>Cfg_1</Key>
+ <CfgParent>Base</CfgParent>
+ </BuildConfiguration>
+ </ItemGroup>
+ <Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/>
+ <ProjectExtensions>
+ <Borland.Personality>Delphi.Personality.12</Borland.Personality>
+ <Borland.ProjectType>VCLApplication</Borland.ProjectType>
+ <BorlandProject>
+ <Delphi.Personality>
+ <Source>
+ <Source Name="MainSource">delphidemo.dpr</Source>
+ </Source>
+ <Parameters>
+ <Parameters Name="UseLauncher">False</Parameters>
+ <Parameters Name="DebugCWD">d:\lcms-1.13\delphi</Parameters>
+ <Parameters Name="LoadAllSymbols">True</Parameters>
+ <Parameters Name="LoadUnspecifiedSymbols">False</Parameters>
+ </Parameters>
+ <VersionInfo>
+ <VersionInfo Name="IncludeVerInfo">False</VersionInfo>
+ <VersionInfo Name="AutoIncBuild">False</VersionInfo>
+ <VersionInfo Name="MajorVer">1</VersionInfo>
+ <VersionInfo Name="MinorVer">0</VersionInfo>
+ <VersionInfo Name="Release">0</VersionInfo>
+ <VersionInfo Name="Build">0</VersionInfo>
+ <VersionInfo Name="Debug">False</VersionInfo>
+ <VersionInfo Name="PreRelease">False</VersionInfo>
+ <VersionInfo Name="Special">False</VersionInfo>
+ <VersionInfo Name="Private">False</VersionInfo>
+ <VersionInfo Name="DLL">False</VersionInfo>
+ <VersionInfo Name="Locale">3082</VersionInfo>
+ <VersionInfo Name="CodePage">1252</VersionInfo>
+ </VersionInfo>
+ <VersionInfoKeys>
+ <VersionInfoKeys Name="CompanyName"/>
+ <VersionInfoKeys Name="FileDescription"/>
+ <VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
+ <VersionInfoKeys Name="InternalName"/>
+ <VersionInfoKeys Name="LegalCopyright"/>
+ <VersionInfoKeys Name="LegalTrademarks"/>
+ <VersionInfoKeys Name="OriginalFilename"/>
+ <VersionInfoKeys Name="ProductName"/>
+ <VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
+ <VersionInfoKeys Name="Comments"/>
+ </VersionInfoKeys>
+ <Excluded_Packages>
+ <Excluded_Packages Name="$(BDS)\bin\dcloffice2k140.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
+ <Excluded_Packages Name="$(BDS)\bin\dclofficexp140.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
+ </Excluded_Packages>
+ </Delphi.Personality>
+ <ModelSupport>False</ModelSupport>
+ </BorlandProject>
+ <ProjectFileVersion>12</ProjectFileVersion>
+ </ProjectExtensions>
+ </Project>
diff --git a/utils/delphi/demo1.pas b/utils/delphi/demo1.pas
index 750f29b..8b69c98 100755..100644
--- a/utils/delphi/demo1.pas
+++ b/utils/delphi/demo1.pas
@@ -1,322 +1,322 @@
-unit demo1;
-
-interface
-
-uses
- Windows, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- ExtCtrls, StdCtrls, ExtDlgs, lcms2dll, ComCtrls;
-
-type
- TForm1 = class(TForm)
-
- Image1: TImage;
- Image2: TImage;
- Panel1: TPanel;
- Splitter1: TSplitter;
- Button2: TButton;
- ComboBoxInput: TComboBox;
- ComboBoxOutput: TComboBox;
- Label1: TLabel;
- Label2: TLabel;
- WBCompensation: TCheckBox;
- NoTransform: TCheckBox;
- RadioGroup1: TRadioGroup;
- OpenPictureDialog1: TOpenPictureDialog;
- Button1: TButton;
- ProgressBar1: TProgressBar;
- ComboBoxIntent: TComboBox;
- Label3: TLabel;
- Button3: TButton;
- Button4: TButton;
- OpenDialog1: TOpenDialog;
- Label4: TLabel;
- ScrollBar1: TScrollBar;
-
- procedure Button2Click(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure Button4Click(Sender: TObject);
- procedure ComboBoxIntentChange(Sender: TObject);
- procedure ScrollBar1Change(Sender: TObject);
- private
- { Private declarations }
- function ComputeFlags: DWORD;
-
- public
- constructor Create(Owner: TComponent); Override;
- { Public declarations }
- end;
-
-var
- Form1: TForm1;
-
-implementation
-
-{$R *.DFM}
-
-CONST
- IS_INPUT = $1;
- IS_DISPLAY = $2;
- IS_COLORSPACE = $4;
- IS_OUTPUT = $8;
- IS_ABSTRACT = $10;
-
-VAR
- IntentCodes: array [0 .. 20] of cmsUInt32Number;
-
-FUNCTION InSignatures(Signature: cmsProfileClassSignature; dwFlags: DWORD): Boolean;
-BEGIN
-
- if (((dwFlags AND IS_DISPLAY) <> 0) AND (Signature = cmsSigDisplayClass)) then
- InSignatures := TRUE
- else if (((dwFlags AND IS_OUTPUT) <> 0) AND (Signature = cmsSigOutputClass))
- then
- InSignatures := TRUE
- else if (((dwFlags AND IS_INPUT) <> 0) AND (Signature = cmsSigInputClass))
- then
- InSignatures := TRUE
- else if (((dwFlags AND IS_COLORSPACE) <> 0) AND
- (Signature = cmsSigColorSpaceClass)) then
- InSignatures := TRUE
- else if (((dwFlags AND IS_ABSTRACT) <> 0) AND
- (Signature = cmsSigAbstractClass)) then
- InSignatures := TRUE
- else
- InSignatures := FALSE
-END;
-
-PROCEDURE FillCombo(var Combo: TComboBox; Signatures: DWORD);
-var
- Files, Descriptions: TStringList;
- Found: Integer;
- SearchRec: TSearchRec;
- Path, Profile: String;
- Dir: ARRAY [0 .. 1024] OF Char;
- hProfile: cmsHPROFILE;
- Descrip: array [0 .. 256] of Char;
-begin
- Files := TStringList.Create;
- Descriptions := TStringList.Create;
- GetSystemDirectory(Dir, 1023);
- Path := String(Dir) + '\SPOOL\DRIVERS\COLOR\';
- Found := FindFirst(Path + '*.ic?', faAnyFile, SearchRec);
- while Found = 0 do
- begin
- Profile := Path + SearchRec.Name;
- hProfile := cmsOpenProfileFromFile(PAnsiChar(AnsiString(Profile)), 'r');
- if (hProfile <> NIL) THEN
- begin
-
- if ((cmsGetColorSpace(hProfile) = cmsSigRgbData) AND InSignatures
- (cmsGetDeviceClass(hProfile), Signatures)) then
- begin
- cmsGetProfileInfo(hProfile, cmsInfoDescription, 'EN', 'us', Descrip,
- 256);
- Descriptions.Add(Descrip);
- Files.Add(Profile);
- end;
- cmsCloseProfile(hProfile);
- end;
-
- Found := FindNext(SearchRec);
-
- end;
- FindClose(SearchRec);
- Combo.Items := Descriptions;
- Combo.Tag := Integer(Files);
-end;
-
-// A rather simple Logger... note the "cdecl" convention
-PROCEDURE ErrorLogger(ContextID: cmsContext; ErrorCode: cmsUInt32Number;
- Text: PAnsiChar); Cdecl;
-begin
- MessageBox(0, PWideChar(WideString(Text)), 'Something is going wrong...',
- MB_OK OR MB_ICONWARNING or MB_TASKMODAL);
-end;
-
-constructor TForm1.Create(Owner: TComponent);
-var
- IntentNames: array [0 .. 20] of PAnsiChar;
- i, n: Integer;
-begin
- inherited Create(Owner);
-
- // Set the logger
- cmsSetLogErrorHandler(ErrorLogger);
-
- ScrollBar1.Min := 0;
- ScrollBar1.Max := 100;
-
- FillCombo(ComboBoxInput, IS_INPUT OR IS_COLORSPACE OR IS_DISPLAY);
- FillCombo(ComboBoxOutput, $FFFF );
-
-
- // Get the supported intents
- n := cmsGetSupportedIntents(20, @IntentCodes, @IntentNames);
-
-
- ComboBoxIntent.Items.BeginUpdate;
- ComboBoxIntent.Items.Clear;
- for i:= 0 TO n - 1 DO
- ComboBoxIntent.Items.Add(String(IntentNames[i]));
-
- ComboBoxIntent.ItemIndex := 0;
- ComboBoxIntent.Items.EndUpdate;
-end;
-
-
-
-procedure TForm1.ScrollBar1Change(Sender: TObject);
-var d: Integer;
- s: String;
-begin
- d := ScrollBar1.Position;
- Str(d, s);
- Label4.Caption := 'Adaptation state '+s + '% (Abs. col only)';
-end;
-
-procedure TForm1.Button2Click(Sender: TObject);
-begin
- if OpenPictureDialog1.Execute then
- begin
- Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
- Image1.Picture.Bitmap.PixelFormat := pf24bit;
-
- Image2.Picture.LoadFromFile(OpenPictureDialog1.FileName);
- Image2.Picture.Bitmap.PixelFormat := pf24bit;
-
- end
-end;
-
-function SelectedFile(var Combo: TComboBox): string;
-var
- List: TStringList;
- n: Integer;
-begin
-
- List := TStringList(Combo.Tag);
- n := Combo.ItemIndex;
- if (n >= 0) then
- SelectedFile := List.Strings[n]
- else
- SelectedFile := Combo.Text;
-end;
-
-procedure TForm1.ComboBoxIntentChange(Sender: TObject);
-begin
- ScrollBar1.Enabled := (ComboBoxIntent.itemIndex = 3);
-end;
-
-function TForm1.ComputeFlags: DWORD;
-var
- dwFlags: DWORD;
-begin
- dwFlags := 0;
- if (WBCompensation.Checked) then
- begin
- dwFlags := dwFlags OR cmsFLAGS_BLACKPOINTCOMPENSATION
- end;
-
- if (NoTransform.Checked) then
- begin
- dwFlags := dwFlags OR cmsFLAGS_NULLTRANSFORM
- end;
-
- case RadioGroup1.ItemIndex of
- 0:
- dwFlags := dwFlags OR cmsFLAGS_NOOPTIMIZE;
- 1:
- dwFlags := dwFlags OR cmsFLAGS_HIGHRESPRECALC;
- 3:
- dwFlags := dwFlags OR cmsFLAGS_LOWRESPRECALC;
- end;
-
- ComputeFlags := dwFlags
-end;
-
-procedure TForm1.Button1Click(Sender: TObject);
-var
- Source, Dest: String;
- hSrc, hDest: cmsHPROFILE;
- xform: cmsHTRANSFORM;
- i, PicW, PicH: Integer;
- Intent: Integer;
- dwFlags: DWORD;
-begin
-
- Source := SelectedFile(ComboBoxInput);
- Dest := SelectedFile(ComboBoxOutput);
-
- dwFlags := ComputeFlags;
-
- Intent := IntentCodes[ComboBoxIntent.ItemIndex];
-
- cmsSetAdaptationState( ScrollBar1.Position / 100.0 );
-
- if (Source <> '') AND (Dest <> '') then
- begin
- hSrc := cmsOpenProfileFromFile(PAnsiChar(AnsiString(Source)), 'r');
- hDest := cmsOpenProfileFromFile(PAnsiChar(AnsiString(Dest)), 'r');
-
- if (hSrc <> Nil) and (hDest <> Nil) then
- begin
- xform := cmsCreateTransform(hSrc, TYPE_BGR_8, hDest, TYPE_BGR_8, Intent,
- dwFlags);
- end
- else
- begin
- xform := nil;
- end;
-
- if hSrc <> nil then
- begin
- cmsCloseProfile(hSrc);
- end;
-
- if hDest <> Nil then
- begin
- cmsCloseProfile(hDest);
- end;
-
- if (xform <> nil) then
- begin
-
- PicW := Image2.Picture.width;
- PicH := Image2.Picture.height;
- ProgressBar1.Min := 0;
- ProgressBar1.Max := PicH;
- ProgressBar1.Step := 1;
-
- for i := 0 TO (PicH - 1) do
- begin
- if ((i MOD 100) = 0) then
- ProgressBar1.Position := i;
-
- cmsDoTransform(xform, Image1.Picture.Bitmap.Scanline[i],
- Image2.Picture.Bitmap.Scanline[i], PicW);
-
- end;
- ProgressBar1.Position := PicH;
-
- cmsDeleteTransform(xform);
-
- end;
-
- Image2.Repaint;
- ProgressBar1.Position := 0;
- end
-end;
-
-procedure TForm1.Button3Click(Sender: TObject);
-begin
- if OpenDialog1.Execute then
- ComboBoxInput.Text := OpenDialog1.FileName;
-end;
-
-procedure TForm1.Button4Click(Sender: TObject);
-begin
- if OpenDialog1.Execute then
- ComboBoxOutput.Text := OpenDialog1.FileName;
-end;
-
-end.
+unit demo1;
+
+interface
+
+uses
+ Windows, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
+ ExtCtrls, StdCtrls, ExtDlgs, lcms2dll, ComCtrls;
+
+type
+ TForm1 = class(TForm)
+
+ Image1: TImage;
+ Image2: TImage;
+ Panel1: TPanel;
+ Splitter1: TSplitter;
+ Button2: TButton;
+ ComboBoxInput: TComboBox;
+ ComboBoxOutput: TComboBox;
+ Label1: TLabel;
+ Label2: TLabel;
+ WBCompensation: TCheckBox;
+ NoTransform: TCheckBox;
+ RadioGroup1: TRadioGroup;
+ OpenPictureDialog1: TOpenPictureDialog;
+ Button1: TButton;
+ ProgressBar1: TProgressBar;
+ ComboBoxIntent: TComboBox;
+ Label3: TLabel;
+ Button3: TButton;
+ Button4: TButton;
+ OpenDialog1: TOpenDialog;
+ Label4: TLabel;
+ ScrollBar1: TScrollBar;
+
+ procedure Button2Click(Sender: TObject);
+ procedure Button1Click(Sender: TObject);
+ procedure Button3Click(Sender: TObject);
+ procedure Button4Click(Sender: TObject);
+ procedure ComboBoxIntentChange(Sender: TObject);
+ procedure ScrollBar1Change(Sender: TObject);
+ private
+ { Private declarations }
+ function ComputeFlags: DWORD;
+
+ public
+ constructor Create(Owner: TComponent); Override;
+ { Public declarations }
+ end;
+
+var
+ Form1: TForm1;
+
+implementation
+
+{$R *.DFM}
+
+CONST
+ IS_INPUT = $1;
+ IS_DISPLAY = $2;
+ IS_COLORSPACE = $4;
+ IS_OUTPUT = $8;
+ IS_ABSTRACT = $10;
+
+VAR
+ IntentCodes: array [0 .. 20] of cmsUInt32Number;
+
+FUNCTION InSignatures(Signature: cmsProfileClassSignature; dwFlags: DWORD): Boolean;
+BEGIN
+
+ if (((dwFlags AND IS_DISPLAY) <> 0) AND (Signature = cmsSigDisplayClass)) then
+ InSignatures := TRUE
+ else if (((dwFlags AND IS_OUTPUT) <> 0) AND (Signature = cmsSigOutputClass))
+ then
+ InSignatures := TRUE
+ else if (((dwFlags AND IS_INPUT) <> 0) AND (Signature = cmsSigInputClass))
+ then
+ InSignatures := TRUE
+ else if (((dwFlags AND IS_COLORSPACE) <> 0) AND
+ (Signature = cmsSigColorSpaceClass)) then
+ InSignatures := TRUE
+ else if (((dwFlags AND IS_ABSTRACT) <> 0) AND
+ (Signature = cmsSigAbstractClass)) then
+ InSignatures := TRUE
+ else
+ InSignatures := FALSE
+END;
+
+PROCEDURE FillCombo(var Combo: TComboBox; Signatures: DWORD);
+var
+ Files, Descriptions: TStringList;
+ Found: Integer;
+ SearchRec: TSearchRec;
+ Path, Profile: String;
+ Dir: ARRAY [0 .. 1024] OF Char;
+ hProfile: cmsHPROFILE;
+ Descrip: array [0 .. 256] of Char;
+begin
+ Files := TStringList.Create;
+ Descriptions := TStringList.Create;
+ GetSystemDirectory(Dir, 1023);
+ Path := String(Dir) + '\SPOOL\DRIVERS\COLOR\';
+ Found := FindFirst(Path + '*.ic?', faAnyFile, SearchRec);
+ while Found = 0 do
+ begin
+ Profile := Path + SearchRec.Name;
+ hProfile := cmsOpenProfileFromFile(PAnsiChar(AnsiString(Profile)), 'r');
+ if (hProfile <> NIL) THEN
+ begin
+
+ if ((cmsGetColorSpace(hProfile) = cmsSigRgbData) AND InSignatures
+ (cmsGetDeviceClass(hProfile), Signatures)) then
+ begin
+ cmsGetProfileInfo(hProfile, cmsInfoDescription, 'EN', 'us', Descrip,
+ 256);
+ Descriptions.Add(Descrip);
+ Files.Add(Profile);
+ end;
+ cmsCloseProfile(hProfile);
+ end;
+
+ Found := FindNext(SearchRec);
+
+ end;
+ FindClose(SearchRec);
+ Combo.Items := Descriptions;
+ Combo.Tag := Integer(Files);
+end;
+
+// A rather simple Logger... note the "cdecl" convention
+PROCEDURE ErrorLogger(ContextID: cmsContext; ErrorCode: cmsUInt32Number;
+ Text: PAnsiChar); Cdecl;
+begin
+ MessageBox(0, PWideChar(WideString(Text)), 'Something is going wrong...',
+ MB_OK OR MB_ICONWARNING or MB_TASKMODAL);
+end;
+
+constructor TForm1.Create(Owner: TComponent);
+var
+ IntentNames: array [0 .. 20] of PAnsiChar;
+ i, n: Integer;
+begin
+ inherited Create(Owner);
+
+ // Set the logger
+ cmsSetLogErrorHandler(ErrorLogger);
+
+ ScrollBar1.Min := 0;
+ ScrollBar1.Max := 100;
+
+ FillCombo(ComboBoxInput, IS_INPUT OR IS_COLORSPACE OR IS_DISPLAY);
+ FillCombo(ComboBoxOutput, $FFFF );
+
+
+ // Get the supported intents
+ n := cmsGetSupportedIntents(20, @IntentCodes, @IntentNames);
+
+
+ ComboBoxIntent.Items.BeginUpdate;
+ ComboBoxIntent.Items.Clear;
+ for i:= 0 TO n - 1 DO
+ ComboBoxIntent.Items.Add(String(IntentNames[i]));
+
+ ComboBoxIntent.ItemIndex := 0;
+ ComboBoxIntent.Items.EndUpdate;
+end;
+
+
+
+procedure TForm1.ScrollBar1Change(Sender: TObject);
+var d: Integer;
+ s: String;
+begin
+ d := ScrollBar1.Position;
+ Str(d, s);
+ Label4.Caption := 'Adaptation state '+s + '% (Abs. col only)';
+end;
+
+procedure TForm1.Button2Click(Sender: TObject);
+begin
+ if OpenPictureDialog1.Execute then
+ begin
+ Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
+ Image1.Picture.Bitmap.PixelFormat := pf24bit;
+
+ Image2.Picture.LoadFromFile(OpenPictureDialog1.FileName);
+ Image2.Picture.Bitmap.PixelFormat := pf24bit;
+
+ end
+end;
+
+function SelectedFile(var Combo: TComboBox): string;
+var
+ List: TStringList;
+ n: Integer;
+begin
+
+ List := TStringList(Combo.Tag);
+ n := Combo.ItemIndex;
+ if (n >= 0) then
+ SelectedFile := List.Strings[n]
+ else
+ SelectedFile := Combo.Text;
+end;
+
+procedure TForm1.ComboBoxIntentChange(Sender: TObject);
+begin
+ ScrollBar1.Enabled := (ComboBoxIntent.itemIndex = 3);
+end;
+
+function TForm1.ComputeFlags: DWORD;
+var
+ dwFlags: DWORD;
+begin
+ dwFlags := 0;
+ if (WBCompensation.Checked) then
+ begin
+ dwFlags := dwFlags OR cmsFLAGS_BLACKPOINTCOMPENSATION
+ end;
+
+ if (NoTransform.Checked) then
+ begin
+ dwFlags := dwFlags OR cmsFLAGS_NULLTRANSFORM
+ end;
+
+ case RadioGroup1.ItemIndex of
+ 0:
+ dwFlags := dwFlags OR cmsFLAGS_NOOPTIMIZE;
+ 1:
+ dwFlags := dwFlags OR cmsFLAGS_HIGHRESPRECALC;
+ 3:
+ dwFlags := dwFlags OR cmsFLAGS_LOWRESPRECALC;
+ end;
+
+ ComputeFlags := dwFlags
+end;
+
+procedure TForm1.Button1Click(Sender: TObject);
+var
+ Source, Dest: String;
+ hSrc, hDest: cmsHPROFILE;
+ xform: cmsHTRANSFORM;
+ i, PicW, PicH: Integer;
+ Intent: Integer;
+ dwFlags: DWORD;
+begin
+
+ Source := SelectedFile(ComboBoxInput);
+ Dest := SelectedFile(ComboBoxOutput);
+
+ dwFlags := ComputeFlags;
+
+ Intent := IntentCodes[ComboBoxIntent.ItemIndex];
+
+ cmsSetAdaptationState( ScrollBar1.Position / 100.0 );
+
+ if (Source <> '') AND (Dest <> '') then
+ begin
+ hSrc := cmsOpenProfileFromFile(PAnsiChar(AnsiString(Source)), 'r');
+ hDest := cmsOpenProfileFromFile(PAnsiChar(AnsiString(Dest)), 'r');
+
+ if (hSrc <> Nil) and (hDest <> Nil) then
+ begin
+ xform := cmsCreateTransform(hSrc, TYPE_BGR_8, hDest, TYPE_BGR_8, Intent,
+ dwFlags);
+ end
+ else
+ begin
+ xform := nil;
+ end;
+
+ if hSrc <> nil then
+ begin
+ cmsCloseProfile(hSrc);
+ end;
+
+ if hDest <> Nil then
+ begin
+ cmsCloseProfile(hDest);
+ end;
+
+ if (xform <> nil) then
+ begin
+
+ PicW := Image2.Picture.width;
+ PicH := Image2.Picture.height;
+ ProgressBar1.Min := 0;
+ ProgressBar1.Max := PicH;
+ ProgressBar1.Step := 1;
+
+ for i := 0 TO (PicH - 1) do
+ begin
+ if ((i MOD 100) = 0) then
+ ProgressBar1.Position := i;
+
+ cmsDoTransform(xform, Image1.Picture.Bitmap.Scanline[i],
+ Image2.Picture.Bitmap.Scanline[i], PicW);
+
+ end;
+ ProgressBar1.Position := PicH;
+
+ cmsDeleteTransform(xform);
+
+ end;
+
+ Image2.Repaint;
+ ProgressBar1.Position := 0;
+ end
+end;
+
+procedure TForm1.Button3Click(Sender: TObject);
+begin
+ if OpenDialog1.Execute then
+ ComboBoxInput.Text := OpenDialog1.FileName;
+end;
+
+procedure TForm1.Button4Click(Sender: TObject);
+begin
+ if OpenDialog1.Execute then
+ ComboBoxOutput.Text := OpenDialog1.FileName;
+end;
+
+end.
diff --git a/utils/delphi/lcms2dll.pas b/utils/delphi/lcms2dll.pas
index 19e3f87..1c2d674 100755..100644
--- a/utils/delphi/lcms2dll.pas
+++ b/utils/delphi/lcms2dll.pas
@@ -1,2111 +1,2111 @@
-//
-// Little cms DELPHI wrapper
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2010 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//---------------------------------------------------------------------------------
-//
-// Version 2.1
-//
-
-UNIT lcms2dll;
-
-INTERFACE
-
-USES Windows;
-
- TYPE
-
- Uint8 = Byte;
- Int8 = Shortint;
- UInt16 = Word;
- Int16 = Smallint;
- UInt32 = LongWord;
- Int32 = Longint;
-
- TYPE
- cmsUInt8Number = Uint8;
- cmsInt8Number = Int8;
- cmsUInt16Number = UInt16;
- cmsInt16Number = Int16;
-
- cmsUInt32Number = UInt32;
- cmsInt32Number = Int32;
- cmsInt64Number = Int64;
- cmsUInt64Number = UInt64;
-
- cmsFloat32Number = Single;
- cmsFloat64Number = Double;
-
- LPcmsUInt8Number = ^cmsUInt8Number;
- LPcmsInt8Number = ^cmsInt8Number;
- LPcmsUInt16Number = ^cmsUInt16Number;
- LPcmsInt16Number = ^cmsInt16Number;
-
- LPcmsUInt32Number = ^cmsUInt32Number;
- LPcmsInt32Number = ^cmsInt32Number;
- LPcmsInt64Number = ^cmsInt64Number;
- LPcmsUInt64Number = ^cmsUInt64Number;
-
- LPcmsFloat32Number = ^cmsFloat32Number;
- LPcmsFloat64Number = ^cmsFloat64Number;
-
-
- // Derivative types
- cmsSignature = cmsUInt32Number;
- cmsU8Fixed8Number = cmsUInt16Number;
- cmsS15Fixed16Number = cmsInt32Number;
- cmsU16Fixed16Number = cmsUInt32Number;
-
- // Boolean type, which will be using the native integer
- cmsBool = Boolean;
-
- CONST
-
- // Some common definitions
- cmsMAX_PATH = 256;
-
- // D50 XYZ normalized to Y=1.0
- cmsD50X = 0.9642;
- cmsD50Y = 1.0;
- cmsD50Z = 0.8249;
-
- // V4 perceptual black
- cmsPERCEPTUAL_BLACK_X = 0.00336;
- cmsPERCEPTUAL_BLACK_Y = 0.0034731;
- cmsPERCEPTUAL_BLACK_Z = 0.00287;
-
- // Definitions in ICC spec
- cmsMagicNumber = $61637370; // 'acsp'
- lcmsSignature = $6c636d73; // 'lcms'
-
-
-TYPE
-
-// Base ICC type definitions
-cmsTagTypeSignature = (
- cmsSigChromaticityType = $6368726D, // 'chrm'
- cmsSigColorantOrderType = $636C726F, // 'clro'
- cmsSigColorantTableType = $636C7274, // 'clrt'
- cmsSigCrdInfoType = $63726469, // 'crdi'
- cmsSigCurveType = $63757276, // 'curv'
- cmsSigDataType = $64617461, // 'data'
- cmsSigDictType = $64696374, // 'dict'
- cmsSigDateTimeType = $6474696D, // 'dtim'
- cmsSigDeviceSettingsType = $64657673, // 'devs'
- cmsSigLut16Type = $6d667432, // 'mft2'
- cmsSigLut8Type = $6d667431, // 'mft1'
- cmsSigLutAtoBType = $6d414220, // 'mAB '
- cmsSigLutBtoAType = $6d424120, // 'mBA '
- cmsSigMeasurementType = $6D656173, // 'meas'
- cmsSigMultiLocalizedUnicodeType = $6D6C7563, // 'mluc'
- cmsSigMultiProcessElementType = $6D706574, // 'mpet'
- cmsSigNamedColorType = $6E636f6C, // 'ncol' -- DEPRECATED!
- cmsSigNamedColor2Type = $6E636C32, // 'ncl2'
- cmsSigParametricCurveType = $70617261, // 'para'
- cmsSigProfileSequenceDescType = $70736571, // 'pseq'
- cmsSigProfileSequenceIdType = $70736964, // 'psid'
- cmsSigResponseCurveSet16Type = $72637332, // 'rcs2'
- cmsSigS15Fixed16ArrayType = $73663332, // 'sf32'
- cmsSigScreeningType = $7363726E, // 'scrn'
- cmsSigSignatureType = $73696720, // 'sig '
- cmsSigTextType = $74657874, // 'text'
- cmsSigTextDescriptionType = $64657363, // 'desc'
- cmsSigU16Fixed16ArrayType = $75663332, // 'uf32'
- cmsSigUcrBgType = $62666420, // 'bfd '
- cmsSigUInt16ArrayType = $75693136, // 'ui16'
- cmsSigUInt32ArrayType = $75693332, // 'ui32'
- cmsSigUInt64ArrayType = $75693634, // 'ui64'
- cmsSigUInt8ArrayType = $75693038, // 'ui08'
- cmsSigViewingConditionsType = $76696577, // 'view'
- cmsSigXYZType = $58595A20, // 'XYZ '
- cmsSigVcgtType = $76636774 // 'vcgt'
- );
-
-// Base ICC tag definitions
-cmsTagSignature = (
- cmsSigAToB0Tag = $41324230, // 'A2B0'
- cmsSigAToB1Tag = $41324231, // 'A2B1'
- cmsSigAToB2Tag = $41324232, // 'A2B2'
- cmsSigBlueColorantTag = $6258595A, // 'bXYZ'
- cmsSigBlueMatrixColumnTag = $6258595A, // 'bXYZ'
- cmsSigBlueTRCTag = $62545243, // 'bTRC'
- cmsSigBToA0Tag = $42324130, // 'B2A0'
- cmsSigBToA1Tag = $42324131, // 'B2A1'
- cmsSigBToA2Tag = $42324132, // 'B2A2'
- cmsSigCalibrationDateTimeTag = $63616C74, // 'calt'
- cmsSigCharTargetTag = $74617267, // 'targ'
- cmsSigChromaticAdaptationTag = $63686164, // 'chad'
- cmsSigChromaticityTag = $6368726D, // 'chrm'
- cmsSigColorantOrderTag = $636C726F, // 'clro'
- cmsSigColorantTableTag = $636C7274, // 'clrt'
- cmsSigColorantTableOutTag = $636C6F74, // 'clot'
- cmsSigColorimetricIntentImageStateTag = $63696973, // 'ciis'
- cmsSigCopyrightTag = $63707274, // 'cprt'
- cmsSigCrdInfoTag = $63726469, // 'crdi'
- cmsSigDataTag = $64617461, // 'data'
- cmsSigDateTimeTag = $6474696D, // 'dtim'
- cmsSigDeviceMfgDescTag = $646D6E64, // 'dmnd'
- cmsSigDeviceModelDescTag = $646D6464, // 'dmdd'
- cmsSigDeviceSettingsTag = $64657673, // 'devs'
- cmsSigDToB0Tag = $44324230, // 'D2B0'
- cmsSigDToB1Tag = $44324231, // 'D2B1'
- cmsSigDToB2Tag = $44324232, // 'D2B2'
- cmsSigDToB3Tag = $44324233, // 'D2B3'
- cmsSigBToD0Tag = $42324430, // 'B2D0'
- cmsSigBToD1Tag = $42324431, // 'B2D1'
- cmsSigBToD2Tag = $42324432, // 'B2D2'
- cmsSigBToD3Tag = $42324433, // 'B2D3'
- cmsSigGamutTag = $67616D74, // 'gamt'
- cmsSigGrayTRCTag = $6b545243, // 'kTRC'
- cmsSigGreenColorantTag = $6758595A, // 'gXYZ'
- cmsSigGreenMatrixColumnTag = $6758595A, // 'gXYZ'
- cmsSigGreenTRCTag = $67545243, // 'gTRC'
- cmsSigLuminanceTag = $6C756d69, // 'lumi'
- cmsSigMeasurementTag = $6D656173, // 'meas'
- cmsSigMediaBlackPointTag = $626B7074, // 'bkpt'
- cmsSigMediaWhitePointTag = $77747074, // 'wtpt'
- cmsSigNamedColorTag = $6E636f6C, // 'ncol' // Deprecated by the ICC
- cmsSigNamedColor2Tag = $6E636C32, // 'ncl2'
- cmsSigOutputResponseTag = $72657370, // 'resp'
- cmsSigPerceptualRenderingIntentGamutTag = $72696730, // 'rig0'
- cmsSigPreview0Tag = $70726530, // 'pre0'
- cmsSigPreview1Tag = $70726531, // 'pre1'
- cmsSigPreview2Tag = $70726532, // 'pre2'
- cmsSigProfileDescriptionTag = $64657363, // 'desc'
- cmsSigProfileSequenceDescTag = $70736571, // 'pseq'
- cmsSigProfileSequenceIdTag = $70736964, // 'psid'
- cmsSigPs2CRD0Tag = $70736430, // 'psd0'
- cmsSigPs2CRD1Tag = $70736431, // 'psd1'
- cmsSigPs2CRD2Tag = $70736432, // 'psd2'
- cmsSigPs2CRD3Tag = $70736433, // 'psd3'
- cmsSigPs2CSATag = $70733273, // 'ps2s'
- cmsSigPs2RenderingIntentTag = $70733269, // 'ps2i'
- cmsSigRedColorantTag = $7258595A, // 'rXYZ'
- cmsSigRedMatrixColumnTag = $7258595A, // 'rXYZ'
- cmsSigRedTRCTag = $72545243, // 'rTRC'
- cmsSigSaturationRenderingIntentGamutTag = $72696732, // 'rig2'
- cmsSigScreeningDescTag = $73637264, // 'scrd'
- cmsSigScreeningTag = $7363726E, // 'scrn'
- cmsSigTechnologyTag = $74656368, // 'tech'
- cmsSigUcrBgTag = $62666420, // 'bfd '
- cmsSigViewingCondDescTag = $76756564, // 'vued'
- cmsSigViewingConditionsTag = $76696577, // 'view'
- cmsSigVcgtTag = $76636774, // 'vcgt'
- cmsSigMetaTag = $6D657461 // 'meta'
-);
-
-// ICC Technology tag
-cmsTechnologySignature = (
- cmsSigDigitalCamera = $6463616D, // 'dcam'
- cmsSigFilmScanner = $6673636E, // 'fscn'
- cmsSigReflectiveScanner = $7273636E, // 'rscn'
- cmsSigInkJetPrinter = $696A6574, // 'ijet'
- cmsSigThermalWaxPrinter = $74776178, // 'twax'
- cmsSigElectrophotographicPrinter = $6570686F, // 'epho'
- cmsSigElectrostaticPrinter = $65737461, // 'esta'
- cmsSigDyeSublimationPrinter = $64737562, // 'dsub'
- cmsSigPhotographicPaperPrinter = $7270686F, // 'rpho'
- cmsSigFilmWriter = $6670726E, // 'fprn'
- cmsSigVideoMonitor = $7669646D, // 'vidm'
- cmsSigVideoCamera = $76696463, // 'vidc'
- cmsSigProjectionTelevision = $706A7476, // 'pjtv'
- cmsSigCRTDisplay = $43525420, // 'CRT '
- cmsSigPMDisplay = $504D4420, // 'PMD '
- cmsSigAMDisplay = $414D4420, // 'AMD '
- cmsSigPhotoCD = $4B504344, // 'KPCD'
- cmsSigPhotoImageSetter = $696D6773, // 'imgs'
- cmsSigGravure = $67726176, // 'grav'
- cmsSigOffsetLithography = $6F666673, // 'offs'
- cmsSigSilkscreen = $73696C6B, // 'silk'
- cmsSigFlexography = $666C6578, // 'flex'
- cmsSigMotionPictureFilmScanner = $6D706673, // 'mpfs'
- cmsSigMotionPictureFilmRecorder = $6D706672, // 'mpfr'
- cmsSigDigitalMotionPictureCamera = $646D7063, // 'dmpc'
- cmsSigDigitalCinemaProjector = $64636A70 // 'dcpj'
-);
-
-
-// ICC Color spaces
-cmsColorSpaceSignature = (
- cmsSigXYZData = $58595A20, // 'XYZ '
- cmsSigLabData = $4C616220, // 'Lab '
- cmsSigLuvData = $4C757620, // 'Luv '
- cmsSigYCbCrData = $59436272, // 'YCbr'
- cmsSigYxyData = $59787920, // 'Yxy '
- cmsSigRgbData = $52474220, // 'RGB '
- cmsSigGrayData = $47524159, // 'GRAY'
- cmsSigHsvData = $48535620, // 'HSV '
- cmsSigHlsData = $484C5320, // 'HLS '
- cmsSigCmykData = $434D594B, // 'CMYK'
- cmsSigCmyData = $434D5920, // 'CMY '
- cmsSigMCH1Data = $4D434831, // 'MCH1'
- cmsSigMCH2Data = $4D434832, // 'MCH2'
- cmsSigMCH3Data = $4D434833, // 'MCH3'
- cmsSigMCH4Data = $4D434834, // 'MCH4'
- cmsSigMCH5Data = $4D434835, // 'MCH5'
- cmsSigMCH6Data = $4D434836, // 'MCH6'
- cmsSigMCH7Data = $4D434837, // 'MCH7'
- cmsSigMCH8Data = $4D434838, // 'MCH8'
- cmsSigMCH9Data = $4D434839, // 'MCH9'
- cmsSigMCHAData = $4D43483A, // 'MCHA'
- cmsSigMCHBData = $4D43483B, // 'MCHB'
- cmsSigMCHCData = $4D43483C, // 'MCHC'
- cmsSigMCHDData = $4D43483D, // 'MCHD'
- cmsSigMCHEData = $4D43483E, // 'MCHE'
- cmsSigMCHFData = $4D43483F, // 'MCHF'
- cmsSigNamedData = $6e6d636c, // 'nmcl'
- cmsSig1colorData = $31434C52, // '1CLR'
- cmsSig2colorData = $32434C52, // '2CLR'
- cmsSig3colorData = $33434C52, // '3CLR'
- cmsSig4colorData = $34434C52, // '4CLR'
- cmsSig5colorData = $35434C52, // '5CLR'
- cmsSig6colorData = $36434C52, // '6CLR'
- cmsSig7colorData = $37434C52, // '7CLR'
- cmsSig8colorData = $38434C52, // '8CLR'
- cmsSig9colorData = $39434C52, // '9CLR'
- cmsSig10colorData = $41434C52, // 'ACLR'
- cmsSig11colorData = $42434C52, // 'BCLR'
- cmsSig12colorData = $43434C52, // 'CCLR'
- cmsSig13colorData = $44434C52, // 'DCLR'
- cmsSig14colorData = $45434C52, // 'ECLR'
- cmsSig15colorData = $46434C52, // 'FCLR'
- cmsSigLuvKData = $4C75764B // 'LuvK'
-);
-
-// ICC Profile Class
-cmsProfileClassSignature = (
- cmsSigInputClass = $73636E72, // 'scnr'
- cmsSigDisplayClass = $6D6E7472, // 'mntr'
- cmsSigOutputClass = $70727472, // 'prtr'
- cmsSigLinkClass = $6C696E6B, // 'link'
- cmsSigAbstractClass = $61627374, // 'abst'
- cmsSigColorSpaceClass = $73706163, // 'spac'
- cmsSigNamedColorClass = $6e6d636c // 'nmcl'
-);
-
-
-// ICC Platforms
-cmsPlatformSignature = (
- cmsSigMacintosh = $4150504C, // 'APPL'
- cmsSigMicrosoft = $4D534654, // 'MSFT'
- cmsSigSolaris = $53554E57, // 'SUNW'
- cmsSigSGI = $53474920, // 'SGI '
- cmsSigTaligent = $54474E54, // 'TGNT'
- cmsSigUnices = $2A6E6978 // '*nix' // From argyll -- Not official
-);
-
-CONST
-
- // Reference gamut
- cmsSigPerceptualReferenceMediumGamut = $70726d67; //'prmg'
-
- // For cmsSigColorimetricIntentImageStateTag
- cmsSigSceneColorimetryEstimates = $73636F65; //'scoe'
- cmsSigSceneAppearanceEstimates = $73617065; //'sape'
- cmsSigFocalPlaneColorimetryEstimates = $66706365; //'fpce'
- cmsSigReflectionHardcopyOriginalColorimetry = $72686F63; //'rhoc'
- cmsSigReflectionPrintOutputColorimetry = $72706F63; //'rpoc'
-
-TYPE
-
-// Multi process elements types
-cmsStageSignature = (
- cmsSigCurveSetElemType = $63767374, //'cvst'
- cmsSigMatrixElemType = $6D617466, //'matf'
- cmsSigCLutElemType = $636C7574, //'clut'
-
- cmsSigBAcsElemType = $62414353, // 'bACS'
- cmsSigEAcsElemType = $65414353, // 'eACS'
-
- // Custom from here, not in the ICC Spec
- cmsSigXYZ2LabElemType = $6C327820, // 'l2x '
- cmsSigLab2XYZElemType = $78326C20, // 'x2l '
- cmsSigNamedColorElemType = $6E636C20, // 'ncl '
- cmsSigLabV2toV4 = $32203420, // '2 4 '
- cmsSigLabV4toV2 = $34203220, // '4 2 '
-
- // Identities
- cmsSigIdentityElemType = $69646E20 // 'idn '
-);
-
-// Types of CurveElements
-cmsCurveSegSignature = (
-
- cmsSigFormulaCurveSeg = $70617266, // 'parf'
- cmsSigSampledCurveSeg = $73616D66, // 'samf'
- cmsSigSegmentedCurve = $63757266 // 'curf'
-);
-
-CONST
-
- // Used in ResponseCurveType
- cmsSigStatusA = $53746141; //'StaA'
- cmsSigStatusE = $53746145; //'StaE'
- cmsSigStatusI = $53746149; //'StaI'
- cmsSigStatusT = $53746154; //'StaT'
- cmsSigStatusM = $5374614D; //'StaM'
- cmsSigDN = $444E2020; //'DN '
- cmsSigDNP = $444E2050; //'DN P'
- cmsSigDNN = $444E4E20; //'DNN '
- cmsSigDNNP = $444E4E50; //'DNNP'
-
- // Device attributes, currently defined values correspond to the low 4 bytes
- // of the 8 byte attribute quantity
- cmsReflective = 0;
- cmsTransparency = 1;
- cmsGlossy = 0;
- cmsMatte = 2;
-
-TYPE
-
-// Common structures in ICC tags
-cmsICCData = PACKED RECORD
- len : cmsUInt32Number;
- flag : cmsUInt32Number;
- data : Array [0..1] of cmsUInt8Number;
- END;
-
-// ICC date time
-cmsDateTimeNumber = PACKED RECORD
- year: cmsUInt16Number;
- month: cmsUInt16Number;
- day: cmsUInt16Number;
- hours: cmsUInt16Number;
- minutes: cmsUInt16Number;
- seconds: cmsUInt16Number;
-END;
-
-// ICC XYZ
-
-cmsEncodedXYZNumber = PACKED RECORD
- X: cmsS15Fixed16Number;
- Y: cmsS15Fixed16Number;
- Z: cmsS15Fixed16Number;
-END;
-
-
-// Profile ID as computed by MD5 algorithm
-cmsProfileID = PACKED RECORD
- CASE Integer OF
- 1: (ID8: Array[0..15] OF cmsUInt8Number);
- 2: (ID16: Array[0..7] OF cmsUInt16Number);
- 3: (ID32: Array[0..3] OF cmsUInt32Number);
-END;
-
-
-
-// ----------------------------------------------------------------------------------------------
-// ICC profile internal base types. Strictly, shouldn't be declared in this unit, but maybe
-// somebody want to use this info for accessing profile header directly, so here it is.
-
-// Profile header -- it is 32-bit aligned, so no issues are expected on alignment
-cmsICCHeader = PACKED RECORD
- size: cmsUInt32Number; // Profile size in bytes
- cmmId: cmsSignature; // CMM for this profile
- version: cmsUInt32Number; // Format version number
- deviceClass: cmsProfileClassSignature; // Type of profile
- colorSpace: cmsColorSpaceSignature; // Color space of data
- pcs: cmsColorSpaceSignature; // PCS, XYZ or Lab only
- date: cmsDateTimeNumber; // Date profile was created
- magic: cmsSignature; // Magic Number to identify an ICC profile
- platform: cmsPlatformSignature; // Primary Platform
- flags: cmsUInt32Number; // Various bit settings
- manufacturer: cmsSignature; // Device manufacturer
- model: cmsUInt32Number; // Device model number
- attributes: cmsUInt64Number; // Device attributes
- renderingIntent:cmsUInt32Number; // Rendering intent
- illuminant: cmsEncodedXYZNumber; // Profile illuminant
- creator: cmsSignature; // Profile creator
- profileID: cmsProfileID; // Profile ID using MD5
- reserved: array [0..27] of cmsInt8Number; // Reserved for future use
-END;
-
-// ICC base tag
-cmsTagBase = PACKED RECORD
- sig: cmsTagTypeSignature;
- reserved: array[0..3] of cmsInt8Number;
-END;
-
-// A tag entry in directory
-cmsTagEntry = PACKED RECORD
- sig: cmsTagSignature; // The tag signature
- offset: cmsUInt32Number; // Start of tag
- size: cmsUInt32Number; // Size in bytes
-END;
-
-
-cmsContext = Pointer; // Context identifier for multithreaded environments
-cmsHANDLE = Pointer; // Generic handle
-cmsHPROFILE = Pointer; // Opaque typedefs to hide internals
-cmsHTRANSFORM = Pointer;
-
-
-CONST
-
- cmsMAXCHANNELS = 16; // Maximum number of channels in ICC profiles
-
-// Format of pixel is defined by one cmsUInt32Number, using bit fields as follows
-//
-// A O TTTTT U Y F P X S EEE CCCC BBB
-//
-// A: Floating point -- With this flag we can differentiate 16 bits as float and as int
-// O: Optimized -- previous optimization already returns the final 8-bit value
-// T: Pixeltype
-// F: Flavor 0=MinIsBlack(Chocolate) 1=MinIsWhite(Vanilla)
-// P: Planar? 0=Chunky, 1=Planar
-// X: swap 16 bps endianess?
-// S: Do swap? ie, BGR, KYMC
-// E: Extra samples
-// C: Channels (Samples per pixel)
-// B: bytes per sample
-// Y: Swap first - changes ABGR to BGRA and KCMY to CMYK
-
- FUNCTION FLOAT_SH(a: cmsUInt32Number): cmsUInt32Number;
- FUNCTION OPTIMIZED_SH(s: cmsUInt32Number): cmsUInt32Number;
- FUNCTION COLORSPACE_SH(s: cmsUInt32Number):cmsUInt32Number;
- FUNCTION SWAPFIRST_SH(s: cmsUInt32Number):cmsUInt32Number;
- FUNCTION FLAVOR_SH(s: cmsUInt32Number):cmsUInt32Number;
- FUNCTION PLANAR_SH(p: cmsUInt32Number):cmsUInt32Number;
- FUNCTION ENDIAN16_SH(e: cmsUInt32Number):cmsUInt32Number;
- FUNCTION DOSWAP_SH(e: cmsUInt32Number):cmsUInt32Number;
- FUNCTION EXTRA_SH(e: cmsUInt32Number):cmsUInt32Number;
- FUNCTION CHANNELS_SH(c: cmsUInt32Number):cmsUInt32Number;
- FUNCTION BYTES_SH(b: cmsUInt32Number):cmsUInt32Number;
-
-
- FUNCTION T_FLOAT(a: cmsUInt32Number): cmsUInt32Number;
- FUNCTION T_OPTIMIZED(o: cmsUInt32Number): cmsUInt32Number;
- FUNCTION T_COLORSPACE(s: cmsUInt32Number): cmsUInt32Number;
- FUNCTION T_SWAPFIRST(s: cmsUInt32Number): cmsUInt32Number;
- FUNCTION T_FLAVOR(s: cmsUInt32Number): cmsUInt32Number;
- FUNCTION T_PLANAR(p: cmsUInt32Number): cmsUInt32Number;
- FUNCTION T_ENDIAN16(e: cmsUInt32Number): cmsUInt32Number;
- FUNCTION T_DOSWAP(e: cmsUInt32Number): cmsUInt32Number;
- FUNCTION T_EXTRA(e: cmsUInt32Number): cmsUInt32Number;
- FUNCTION T_CHANNELS(c: cmsUInt32Number): cmsUInt32Number;
- FUNCTION T_BYTES(b: cmsUInt32Number): cmsUInt32Number;
-
-CONST
-
-
-// Pixel types
-
- PT_ANY = 0; // Don't check colorspace
- // 1 & 2 are reserved
- PT_GRAY = 3;
- PT_RGB = 4;
- PT_CMY = 5;
- PT_CMYK = 6;
- PT_YCbCr = 7;
- PT_YUV = 8; // Lu'v'
- PT_XYZ = 9;
- PT_Lab = 10;
- PT_YUVK = 11; // Lu'v'K
- PT_HSV = 12;
- PT_HLS = 13;
- PT_Yxy = 14;
-
- PT_MCH1 = 15;
- PT_MCH2 = 16;
- PT_MCH3 = 17;
- PT_MCH4 = 18;
- PT_MCH5 = 19;
- PT_MCH6 = 20;
- PT_MCH7 = 21;
- PT_MCH8 = 22;
- PT_MCH9 = 23;
- PT_MCH10 = 24;
- PT_MCH11 = 25;
- PT_MCH12 = 26;
- PT_MCH13 = 27;
- PT_MCH14 = 28;
- PT_MCH15 = 29;
-
- PT_LabV2 = 30; // Identical to PT_Lab, but using the V2 old encoding
-
-
- // Format descriptors
- TYPE_GRAY_8 = $030009;
- TYPE_GRAY_8_REV = $032009;
- TYPE_GRAY_16 = $03000a;
- TYPE_GRAY_16_REV = $03200a;
- TYPE_GRAY_16_SE = $03080a;
- TYPE_GRAYA_8 = $030089;
- TYPE_GRAYA_16 = $03008a;
- TYPE_GRAYA_16_SE = $03088a;
- TYPE_GRAYA_8_PLANAR = $031089;
- TYPE_GRAYA_16_PLANAR = $03108a;
- TYPE_RGB_8 = $040019;
- TYPE_RGB_8_PLANAR = $041019;
- TYPE_BGR_8 = $040419;
- TYPE_BGR_8_PLANAR = $041419;
- TYPE_RGB_16 = $04001a;
- TYPE_RGB_16_PLANAR = $04101a;
- TYPE_RGB_16_SE = $04081a;
- TYPE_BGR_16 = $04041a;
- TYPE_BGR_16_PLANAR = $04141a;
- TYPE_BGR_16_SE = $040c1a;
- TYPE_RGBA_8 = $040099;
- TYPE_RGBA_8_PLANAR = $041099;
- TYPE_RGBA_16 = $04009a;
- TYPE_RGBA_16_PLANAR = $04109a;
- TYPE_RGBA_16_SE = $04089a;
- TYPE_ARGB_8 = $044099;
- TYPE_ARGB_16 = $04409a;
- TYPE_ABGR_8 = $040499;
- TYPE_ABGR_16 = $04049a;
- TYPE_ABGR_16_PLANAR = $04149a;
- TYPE_ABGR_16_SE = $040c9a;
- TYPE_BGRA_8 = $044499;
- TYPE_BGRA_16 = $04449a;
- TYPE_BGRA_16_SE = $04489a;
- TYPE_CMY_8 = $050019;
- TYPE_CMY_8_PLANAR = $051019;
- TYPE_CMY_16 = $05001a;
- TYPE_CMY_16_PLANAR = $05101a;
- TYPE_CMY_16_SE = $05081a;
- TYPE_CMYK_8 = $060021;
- TYPE_CMYKA_8 = $0600a1;
- TYPE_CMYK_8_REV = $062021;
- TYPE_YUVK_8 = $062021;
- TYPE_CMYK_8_PLANAR = $061021;
- TYPE_CMYK_16 = $060022;
- TYPE_CMYK_16_REV = $062022;
- TYPE_YUVK_16 = $062022;
- TYPE_CMYK_16_PLANAR = $061022;
- TYPE_CMYK_16_SE = $060822;
- TYPE_KYMC_8 = $060421;
- TYPE_KYMC_16 = $060422;
- TYPE_KYMC_16_SE = $060c22;
- TYPE_KCMY_8 = $064021;
- TYPE_KCMY_8_REV = $066021;
- TYPE_KCMY_16 = $064022;
- TYPE_KCMY_16_REV = $066022;
- TYPE_KCMY_16_SE = $064822;
- TYPE_CMYK5_8 = $130029;
- TYPE_CMYK5_16 = $13002a;
- TYPE_CMYK5_16_SE = $13082a;
- TYPE_KYMC5_8 = $130429;
- TYPE_KYMC5_16 = $13042a;
- TYPE_KYMC5_16_SE = $130c2a;
- TYPE_CMYK6_8 = $140031;
- TYPE_CMYK6_8_PLANAR = $141031;
- TYPE_CMYK6_16 = $140032;
- TYPE_CMYK6_16_PLANAR = $141032;
- TYPE_CMYK6_16_SE = $140832;
- TYPE_CMYK7_8 = $150039;
- TYPE_CMYK7_16 = $15003a;
- TYPE_CMYK7_16_SE = $15083a;
- TYPE_KYMC7_8 = $150439;
- TYPE_KYMC7_16 = $15043a;
- TYPE_KYMC7_16_SE = $150c3a;
- TYPE_CMYK8_8 = $160041;
- TYPE_CMYK8_16 = $160042;
- TYPE_CMYK8_16_SE = $160842;
- TYPE_KYMC8_8 = $160441;
- TYPE_KYMC8_16 = $160442;
- TYPE_KYMC8_16_SE = $160c42;
- TYPE_CMYK9_8 = $170049;
- TYPE_CMYK9_16 = $17004a;
- TYPE_CMYK9_16_SE = $17084a;
- TYPE_KYMC9_8 = $170449;
- TYPE_KYMC9_16 = $17044a;
- TYPE_KYMC9_16_SE = $170c4a;
- TYPE_CMYK10_8 = $180051;
- TYPE_CMYK10_16 = $180052;
- TYPE_CMYK10_16_SE = $180852;
- TYPE_KYMC10_8 = $180451;
- TYPE_KYMC10_16 = $180452;
- TYPE_KYMC10_16_SE = $180c52;
- TYPE_CMYK11_8 = $190059;
- TYPE_CMYK11_16 = $19005a;
- TYPE_CMYK11_16_SE = $19085a;
- TYPE_KYMC11_8 = $190459;
- TYPE_KYMC11_16 = $19045a;
- TYPE_KYMC11_16_SE = $190c5a;
- TYPE_CMYK12_8 = $1a0061;
- TYPE_CMYK12_16 = $1a0062;
- TYPE_CMYK12_16_SE = $1a0862;
- TYPE_KYMC12_8 = $1a0461;
- TYPE_KYMC12_16 = $1a0462;
- TYPE_KYMC12_16_SE = $1a0c62;
- TYPE_XYZ_16 = $09001a;
- TYPE_Lab_8 = $0a0019;
- TYPE_ALab_8 = $0a0499;
- TYPE_Lab_16 = $0a001a;
- TYPE_Yxy_16 = $0e001a;
- TYPE_YCbCr_8 = $070019;
- TYPE_YCbCr_8_PLANAR = $071019;
- TYPE_YCbCr_16 = $07001a;
- TYPE_YCbCr_16_PLANAR = $07101a;
- TYPE_YCbCr_16_SE = $07081a;
- TYPE_YUV_8 = $080019;
- TYPE_YUV_8_PLANAR = $081019;
- TYPE_YUV_16 = $08001a;
- TYPE_YUV_16_PLANAR = $08101a;
- TYPE_YUV_16_SE = $08081a;
- TYPE_HLS_8 = $0d0019;
- TYPE_HLS_8_PLANAR = $0d1019;
- TYPE_HLS_16 = $0d001a;
- TYPE_HLS_16_PLANAR = $0d101a;
- TYPE_HLS_16_SE = $0d081a;
- TYPE_HSV_8 = $0c0019;
- TYPE_HSV_8_PLANAR = $0c1019;
- TYPE_HSV_16 = $0c001a;
- TYPE_HSV_16_PLANAR = $0c101a;
- TYPE_HSV_16_SE = $0c081a;
-
- TYPE_NAMED_COLOR_INDEX = $000A;
-
- TYPE_XYZ_FLT = $49001c;
- TYPE_Lab_FLT = $4a001c;
- TYPE_GRAY_FLT = $43000c;
- TYPE_RGB_FLT = $44001c;
- TYPE_CMYK_FLT = $460024;
- TYPE_XYZA_FLT = $49009c;
- TYPE_LabA_FLT = $4a009c;
- TYPE_RGBA_FLT = $44009c;
- TYPE_XYZ_DBL = $490018;
- TYPE_Lab_DBL = $4a0018;
- TYPE_GRAY_DBL = $430008;
- TYPE_RGB_DBL = $440018;
- TYPE_CMYK_DBL = $460020;
- TYPE_LabV2_8 = $1e0019;
- TYPE_ALabV2_8 = $1e0499;
- TYPE_LabV2_16 = $1e001a;
-
-
-TYPE
-
-
- // Colorimetric spaces
-
- cmsCIEXYZ = PACKED RECORD
- X, Y, Z : cmsFloat64Number;
- END;
- LPcmsCIEXYZ = ^cmsCIEXYZ;
-
- cmsCIExyY = PACKED RECORD
- x, y, YY : cmsFloat64Number
- END;
- LPcmsCIExyY = ^cmsCIEXYY;
-
- cmsCIELab = PACKED RECORD
- L, a, b: cmsFloat64Number
- END;
- LPcmsCIELab = ^cmsCIELab;
-
- cmsCIELCh = PACKED RECORD
- L, C, h : cmsFloat64Number
- END;
- LPcmsCIELCh = ^cmsCIELCh;
-
- cmsJCh = PACKED RECORD
- J, C, h : cmsFloat64Number
- END;
- LPcmsJCh = ^cmsJCH;
-
-
- cmsCIEXYZTRIPLE = PACKED RECORD
- Red, Green, Blue : cmsCIEXYZ
- END;
- LPcmsCIEXYZTRIPLE = ^cmsCIEXYZTRIPLE;
-
-
- cmsCIExyYTRIPLE = PACKED RECORD
- Red, Green, Blue : cmsCIExyY
- END;
- LPcmsCIExyYTRIPLE = ^cmsCIExyYTRIPLE;
-
-
-CONST
-
- // Illuminant types for structs below
- cmsILLUMINANT_TYPE_UNKNOWN = $0000000;
- cmsILLUMINANT_TYPE_D50 = $0000001;
- cmsILLUMINANT_TYPE_D65 = $0000002;
- cmsILLUMINANT_TYPE_D93 = $0000003;
- cmsILLUMINANT_TYPE_F2 = $0000004;
- cmsILLUMINANT_TYPE_D55 = $0000005;
- cmsILLUMINANT_TYPE_A = $0000006;
- cmsILLUMINANT_TYPE_E = $0000007;
- cmsILLUMINANT_TYPE_F8 = $0000008;
-
-TYPE
-
- cmsICCMeasurementConditions = PACKED RECORD
-
- Observer: cmsUInt32Number; // 0 = unknown, 1=CIE 1931, 2=CIE 1964
- Backing: cmsCIEXYZ; // Value of backing
- Geometry: cmsUInt32Number; // 0=unknown, 1=45/0, 0/45 2=0d, d/0
- Flare: cmsFloat64Number; // 0..1.0
- IlluminantType: cmsUInt32Number;
-
- END;
-
- cmsICCViewingConditions = PACKED RECORD
- IlluminantXYZ: cmsCIEXYZ; // Not the same struct as CAM02,
- SurroundXYZ: cmsCIEXYZ; // This is for storing the tag
- IlluminantType: cmsUInt32Number; // viewing condition
- END;
-
-
-// Plug-In registering ---------------------------------------------------------------------------------------------------
-
-FUNCTION cmsPlugin(Plugin: Pointer): cmsBool; StdCall;
-PROCEDURE cmsUnregisterPlugins; StdCall;
-
-// Error logging ----------------------------------------------------------------------------------------------------------
-
-// There is no error handling at all. When a function fails, it returns proper value.
-// For example, all create functions does return NULL on failure. Other may return FALSE.
-// It may be interesting, for the developer, to know why the function is failing.
-// for that reason, lcms2 does offer a logging function. This function will get
-// an ENGLISH string with some clues on what is going wrong. You can show this
-// info to the end user if you wish, or just create some sort of log on disk.
-// The logging function should NOT terminate the program, as this obviously can leave
-// unfreed resources. It is the programmer's responsibility to check each function
-// return code to make sure it didn't fail.
-
-CONST
-
- cmsERROR_UNDEFINED = 0;
- cmsERROR_FILE = 1;
- cmsERROR_RANGE = 2;
- cmsERROR_INTERNAL = 3;
- cmsERROR_NULL = 4;
- cmsERROR_READ = 5;
- cmsERROR_SEEK = 6;
- cmsERROR_WRITE = 7;
- cmsERROR_UNKNOWN_EXTENSION = 8;
- cmsERROR_COLORSPACE_CHECK = 9;
- cmsERROR_ALREADY_DEFINED = 10;
- cmsERROR_BAD_SIGNATURE = 11;
- cmsERROR_CORRUPTION_DETECTED = 12;
- cmsERROR_NOT_SUITABLE = 13;
-
-// Error logger is called with the ContextID when a message is raised. This gives the
-// chance to know which thread is responsible of the warning and any environment associated
-// with it. Non-multithreading applications may safely ignore this parameter.
-// Note that under certain special circumstances, ContextID may be NULL.
-
-TYPE
-
- cmsLogErrorHandlerFunction = PROCEDURE( ContextID: cmsContext; ErrorCode: cmsUInt32Number; Text: PAnsiChar); CDecl;
-
- // Allows user to set any specific logger
- PROCEDURE cmsSetLogErrorHandler(Fn: cmsLogErrorHandlerFunction); StdCall;
-
-
-// Conversions --------------------------------------------------------------------------------------------------------------
-
-
-// Returns pointers to constant structs
-FUNCTION cmsD50_XYZ: LPcmsCIEXYZ; StdCall;
-FUNCTION cmsD50_xyY: LPcmsCIExyY; StdCall;
-
-// Colorimetric space conversions
-PROCEDURE cmsXYZ2xyY(Dest: LPcmsCIExyY; Source: LPcmsCIEXYZ); StdCall;
-PROCEDURE cmsxyY2XYZ(Dest: LPcmsCIEXYZ; Source: LPcmsCIExyY); StdCall;
-PROCEDURE cmsLab2XYZ(WhitePoint: LPcmsCIEXYZ; xyz: LPcmsCIEXYZ; Lab: LPcmsCIELab); StdCall;
-PROCEDURE cmsXYZ2Lab(WhitePoint: LPcmsCIEXYZ; Lab: LPcmsCIELab; xyz: LPcmsCIEXYZ); StdCall;
-PROCEDURE cmsLab2LCh(LCh: LPcmsCIELCh; Lab: LPcmsCIELab); StdCall;
-PROCEDURE cmsLCh2Lab(Lab: LPcmsCIELab; LCh: LPcmsCIELCh); StdCall;
-
-// Encoding /Decoding on PCS
-PROCEDURE cmsLabEncoded2Float(Lab: LPcmsCIELab; wLab: Pointer); StdCall;
-PROCEDURE cmsLabEncoded2FloatV2(Lab: LPcmsCIELab; wLab: Pointer); StdCall;
-PROCEDURE cmsFloat2LabEncoded(wLab: Pointer; Lab: LPcmsCIELab); StdCall;
-PROCEDURE cmsFloat2LabEncodedV2(wLab: Pointer; Lab: LPcmsCIELab); StdCall;
-PROCEDURE cmsXYZEncoded2Float(fxyz : LPcmsCIEXYZ; XYZ: Pointer); StdCall;
-PROCEDURE cmsFloat2XYZEncoded(XYZ: Pointer; fXYZ: LPcmsCIEXYZ); StdCall;
-
-
-// DeltaE metrics
-FUNCTION cmsDeltaE(Lab1, Lab2: LPcmsCIELab): Double; StdCall;
-FUNCTION cmsCIE94DeltaE(Lab1, Lab2: LPcmsCIELab): Double; StdCall;
-FUNCTION cmsBFDdeltaE(Lab1, Lab2: LPcmsCIELab): Double; StdCall;
-FUNCTION cmsCMCdeltaE(Lab1, Lab2: LPcmsCIELab): Double; StdCall;
-FUNCTION cmsCIE2000DeltaE(Lab1, Lab2: LPcmsCIELab; Kl, Kc, Kh: Double): Double; StdCall;
-
-
-// Temperature <-> Chromaticity (Black body)
-FUNCTION cmsWhitePointFromTemp(var WhitePoint: cmsCIExyY; TempK: cmsFloat64Number) : cmsBool; StdCall;
-FUNCTION cmsTempFromWhitePoint(var TeampK: cmsFloat64Number; var WhitePoint: cmsCIExyY) : cmsBool; StdCall;
-
-
-// Chromatic adaptation
-FUNCTION cmsAdaptToIlluminant(Result: LPcmsCIEXYZ; SourceWhitePt: LPcmsCIEXYZ;
- Illuminant: LPcmsCIEXYZ; Value: LPcmsCIEXYZ): cmsBool; StdCall;
-
-
-// CIECAM02 ---------------------------------------------------------------------------------------------------
-
-// Viewing conditions. Please note those are CAM model viewing conditions, and not the ICC tag viewing
-// conditions, which I'm naming cmsICCViewingConditions to make differences evident. Unfortunately, the tag
-// cannot deal with surround La, Yb and D value so is basically useless to store CAM02 viewing conditions.
-
- CONST
-
- AVG_SURROUND = 1;
- DIM_SURROUND = 2;
- DARK_SURROUND = 3;
- CUTSHEET_SURROUND = 4;
-
- D_CALCULATE = -1;
-
- TYPE
-
- cmsViewingConditions = PACKED RECORD
-
- WhitePoint: cmsCIEXYZ;
- Yb : cmsFloat64Number;
- La : cmsFloat64Number;
- surround : Integer;
- D_value : cmsFloat64Number
- END;
-
-
- LPcmsViewingConditions = ^cmsViewingConditions;
-
-FUNCTION cmsCIECAM02Init(pVC : LPcmsViewingConditions ) : Pointer; StdCall;
-PROCEDURE cmsCIECAM02Done(hModel : Pointer); StdCall;
-PROCEDURE cmsCIECAM02Forward(hModel: Pointer; pIn: LPcmsCIEXYZ; pOut: LPcmsJCh ); StdCall;
-PROCEDURE cmsCIECAM02Reverse(hModel: Pointer; pIn: LPcmsJCh; pOut: LPcmsCIEXYZ ); StdCall;
-
-// Tone curves -----------------------------------------------------------------------------------------
-
-// This describes a curve segment. For a table of supported types, see the manual. User can increase the number of
-// available types by using a proper plug-in. Parametric segments allow 10 parameters at most
-
-TYPE
-cmsCurveSegment = PACKED RECORD
- x0, x1: cmsFloat32Number; // Domain; for x0 < x <= x1
- PType: cmsInt32Number; // Parametric type, Type == 0 means sampled segment. Negative values are reserved
- Params: array [0..9] of cmsFloat64Number; // Parameters if Type != 0
- nGridPoints: cmsUInt32Number; // Number of grid points if Type == 0
- SampledPoints: LPcmsFloat32Number; // Points to an array of floats if Type == 0
-END;
-
-LPcmsToneCurve = Pointer;
-LPcmsCurveSegmentArray = ^cmsCurveSegmentArray;
-cmsCurveSegmentArray = array[0..0] of cmsCurveSegment;
-
-LPcmsFloat64NumberArray = ^cmsFloat64NumberArray;
-cmsFloat64NumberArray = array[0..0] of cmsFloat64Number;
-
-LPcmsUInt16NumberArray = ^cmsUInt16NumberArray;
-cmsUInt16NumberArray = array[0..0] of cmsUInt16Number;
-
-LPcmsFloat32NumberArray = ^cmsFloat32NumberArray;
-cmsFloat32NumberArray = array[0..0] of cmsFloat32Number;
-
-LPLPcmsToneCurveArray = ^LPcmsToneCurveArray;
-LPcmsToneCurveArray = array[0..0] of LPcmsToneCurve;
-
-LPcmsUInt32NumberArray = ^cmsUInt32NumberArray;
-cmsUInt32NumberArray = array[0..0] of cmsUInt32Number;
-
-FUNCTION cmsBuildSegmentedToneCurve(ContextID: cmsContext; nSegments: cmsInt32Number; Segments: LPcmsCurveSegmentArray): LPcmsToneCurve; StdCall;
-FUNCTION cmsBuildParametricToneCurve(ContextID: cmsContext; CType: cmsInt32Number; Params: LPcmsFloat64NumberArray): LPcmsToneCurve; StdCall;
-FUNCTION cmsBuildGamma(ContextID: cmsContext; Gamma: cmsFloat64Number): LPcmsToneCurve; StdCall;
-FUNCTION cmsBuildTabulatedToneCurve16(ContextID: cmsContext; nEntries: cmsInt32Number; values: LPcmsUInt16NumberArray): LPcmsToneCurve; StdCall;
-FUNCTION cmsBuildTabulatedToneCurveFloat(ContextID: cmsContext; nEntries: cmsUInt32Number; values: LPcmsFloat32NumberArray): LPcmsToneCurve; StdCall;
-PROCEDURE cmsFreeToneCurve(Curve: LPcmsToneCurve); StdCall;
-PROCEDURE cmsFreeToneCurveTriple(Curve: LPLPcmsToneCurveArray); StdCall;
-FUNCTION cmsDupToneCurve(Src: LPcmsToneCurve): LPcmsToneCurve; StdCall;
-FUNCTION cmsReverseToneCurve(InGamma: LPcmsToneCurve): LPcmsToneCurve; StdCall;
-FUNCTION cmsReverseToneCurveEx(nResultSamples: cmsInt32Number; InGamma: LPcmsToneCurve): LPcmsToneCurve; StdCall;
-FUNCTION cmsJoinToneCurve(ContextID: cmsContext; X, Y: LPcmsToneCurve; nPoints: cmsUInt32Number ): LPcmsToneCurve; StdCall;
-FUNCTION cmsSmoothToneCurve(Tab: LPcmsToneCurve; lambda: cmsFloat64Number): cmsBool; StdCall;
-FUNCTION cmsEvalToneCurveFloat(Curve: LPcmsToneCurve; v: cmsFloat32Number):cmsFloat32Number; StdCall;
-FUNCTION cmsEvalToneCurve16(Curve: LPcmsToneCurve; v:cmsUInt16Number):cmsUInt16Number; StdCall;
-FUNCTION cmsIsToneCurveMultisegment(InGamma: LPcmsToneCurve):cmsBool; StdCall;
-FUNCTION cmsIsToneCurveLinear(Curve: LPcmsToneCurve):cmsBool; StdCall;
-FUNCTION cmsIsToneCurveMonotonic(t: LPcmsToneCurve):cmsBool; StdCall;
-FUNCTION cmsIsToneCurveDescending(t: LPcmsToneCurve):cmsBool; StdCall;
-FUNCTION cmsGetToneCurveParametricType(t: LPcmsToneCurve):cmsInt32Number; StdCall;
-FUNCTION cmsEstimateGamma(t: LPcmsToneCurve; Precision:cmsFloat64Number):cmsFloat64Number; StdCall;
-
-
-// Implements pipelines of multi-processing elements -------------------------------------------------------------
-
-TYPE
- LPcmsPipeline = Pointer;
- LPcmsStage = Pointer;
- LPLPcmsStage = ^LPcmsStage;
-
-// Those are hi-level pipelines
-FUNCTION cmsPipelineAlloc(ContextID: cmsContext; InputChannels, OutputChannels: cmsUInt32Number): LPcmsPipeline; StdCall;
-PROCEDURE cmsPipelineFree(lut: LPcmsPipeline); StdCall;
-FUNCTION cmsPipelineDup(Orig: LPcmsPipeline): LPcmsPipeline; StdCall;
-FUNCTION cmsPipelineInputChannels(lut: LPcmsPipeline): cmsUInt32Number; StdCall;
-FUNCTION cmsPipelineOutputChannels(lut: LPcmsPipeline): cmsUInt32Number; StdCall;
-
-FUNCTION cmsPipelineStageCount(lut: LPcmsPipeline): cmsUInt32Number; StdCall;
-FUNCTION cmsPipelineGetPtrToFirstStage(lut: LPcmsPipeline): LPcmsStage; StdCall;
-FUNCTION cmsPipelineGetPtrToLastStage(lut: LPcmsPipeline): LPcmsStage; StdCall;
-
-PROCEDURE cmsPipelineEval16(Inv, Outv: LPcmsUInt16NumberArray; lut: LPcmsPipeline); StdCall;
-PROCEDURE cmsPipelineEvalFloat(Inv, Outv: LPcmsFloat32NumberArray; lut: LPcmsPipeline); StdCall;
-
-FUNCTION cmsPipelineEvalReverseFloat(Target, Result, Hint: LPcmsFloat32NumberArray; lut: LPcmsPipeline): cmsBool; StdCall;
-FUNCTION cmsPipelineCat(l1, l2: LPcmsPipeline): cmsBool; StdCall;
-FUNCTION cmsPipelineSetSaveAs8bitsFlag(lut: LPcmsPipeline; On: cmsBool): cmsBool; StdCall;
-
-// Where to place/locate the stages in the pipeline chain
-TYPE
- cmsStageLoc = (cmsAT_BEGIN = 0, cmsAT_END = 1 );
-
-PROCEDURE cmsPipelineInsertStage(lut: LPcmsPipeline; loc: cmsStageLoc; mpe: LPcmsStage); StdCall;
-PROCEDURE cmsPipelineUnlinkStage(lut: LPcmsPipeline; loc: cmsStageLoc; mpe: LPLPcmsStage); StdCall;
-
-// This function is quite useful to analyze the structure of a Pipeline and retrieve the Stage elements
-// that conform the Pipeline. It should be called with the Pipeline, the number of expected elements and
-// then a list of expected types followed with a list of double pointers to Stage elements. If
-// the function founds a match with current pipeline, it fills the pointers and returns TRUE
-// if not, returns FALSE without touching anything.
-// FUNCTION cmsPipelineCheckAndRetreiveStages(const cmsPipeline* Lut, n: cmsUInt32Number, ...): cmsBool; StdCall;
-
-// Matrix has double precision and CLUT has only float precision. That is because an ICC profile can encode
-// matrices with far more precision that CLUTS
-FUNCTION cmsStageAllocIdentity(ContextID: cmsContext; nChannels: cmsUInt32Number): LPcmsStage; StdCall;
-FUNCTION cmsStageAllocToneCurves(ContextID: cmsContext; nChannels: cmsUInt32Number; Curves: LPLPcmsToneCurveArray): LPcmsStage; StdCall;
-FUNCTION cmsStageAllocMatrix(ContextID: cmsContext; Rows, Cols: cmsUInt32Number; Matrix, Offset: LPcmsFloat64NumberArray): LPcmsStage; StdCall;
-
-FUNCTION cmsStageAllocCLut16bit(ContextID: cmsContext; nGridPoints: cmsUInt32Number; inputChan, outputChan: cmsUInt32Number; Table: LPcmsUInt16NumberArray): LPcmsStage; StdCall;
-FUNCTION cmsStageAllocCLutFloat(ContextID: cmsContext; nGridPoints: cmsUInt32Number; inputChan, outputChan: cmsUInt32Number; Table: LPcmsFloat32NumberArray): LPcmsStage; StdCall;
-
-FUNCTION cmsStageAllocCLut16bitGranular(ContextID: cmsContext; nGridPoints: LPcmsUInt32NumberArray; inputChan, outputChan: cmsUInt32Number; Table: LPcmsUInt16NumberArray): LPcmsStage; StdCall;
-FUNCTION cmsStageAllocCLutFloatGranular(ContextID: cmsContext; nGridPoints: LPcmsUInt32NumberArray; inputChan, outputChan: cmsUInt32Number; Table: LPcmsFloat32NumberArray): LPcmsStage; StdCall;
-
-
-FUNCTION cmsStageDup(mpe: LPcmsStage): LPcmsStage; StdCall;
-PROCEDURE cmsStageFree(mpe: LPcmsStage); StdCall;
-FUNCTION cmsStageNext(mpe: LPcmsStage): LPcmsStage; StdCall;
-
-FUNCTION cmsStageInputChannels(mpe: LPcmsStage): cmsUInt32Number; StdCall;
-FUNCTION cmsStageOutputChannels(mpe: LPcmsStage): cmsUInt32Number; StdCall;
-FUNCTION cmsStageType(mpe: LPcmsStage): cmsStageSignature; StdCall;
-FUNCTION cmsStageData(mpe: LPcmsStage): Pointer; StdCall;
-
-// Sampling
-
-Type
- cmsSAMPLER16 = FUNCTION (Inp, Outp: LPcmsUInt16NumberArray; Cargo: Pointer): cmsInt32Number; CDecl;
- cmsSAMPLERFLOAT = FUNCTION (Inp, Outp: LPcmsFloat32NumberArray; Cargo: Pointer): cmsInt32Number; CDecl;
-
-// Use this flag to prevent changes being written to destination
-
-Const
-
-SAMPLER_INSPECT = $01000000;
-
-
-// For CLUT only
-FUNCTION cmsStageSampleCLut16bit(mpe: LPcmsStage; Sampler: cmsSAMPLER16; Cargo: Pointer; dwFlags: cmsUInt32Number): cmsBool; StdCall;
-FUNCTION cmsStageSampleCLutFloat(mpe: LPcmsStage; Sampler: cmsSAMPLERFLOAT; Cargo: Pointer; dwFlags: cmsUInt32Number): cmsBool; StdCall;
-
-
-// Slicers
-FUNCTION cmsSliceSpace16(nInputs: cmsUInt32Number; clutPoints: LPcmsUInt32NumberArray;
- Sampler: cmsSAMPLER16; Cargo: Pointer): cmsBool; StdCall;
-
-FUNCTION cmsSliceSpaceFloat(nInputs: cmsUInt32Number; clutPoints: LPcmsUInt32NumberArray;
- Sampler: cmsSAMPLERFLOAT; Cargo: Pointer): cmsBool; StdCall;
-
-// Multilocalized Unicode management ---------------------------------------------------------------------------------------
-
-Type
- LPcmsMLU = Pointer;
-
-Const
-
-cmsNoLanguage = #0#0#0;
-cmsNoCountry = #0#0#0;
-
-
-FUNCTION cmsMLUalloc(ContextID: cmsContext; nItems: cmsUInt32Number): LPcmsMLU; StdCall;
-PROCEDURE cmsMLUfree(mlu: LPcmsMLU); StdCall;
-FUNCTION cmsMLUdup(mlu: LPcmsMLU): LPcmsMLU; StdCall;
-
-FUNCTION cmsMLUsetASCII(mlu: LPcmsMLU; LanguageCode, CountryCode, ASCIIString: PAnsiChar): cmsBool; StdCall;
-FUNCTION cmsMLUsetWide(mlu: LPcmsMLU; LanguageCode, CountryCode: PAnsiChar; WideString: PWChar): cmsBool; StdCall;
-
-FUNCTION cmsMLUgetASCII(mlu: LPcmsMLU; LanguageCode, CountryCode: PAnsiChar; Buffer: PAnsiChar; BufferSize: cmsUInt32Number): cmsUInt32Number; StdCall;
-
-FUNCTION cmsMLUgetWide(mlu: LPcmsMLU; LanguageCode, CountryCode: PAnsiChar; Buffer: PWChar; BufferSize: cmsUInt32Number): cmsUInt32Number; StdCall;
-
-FUNCTION cmsMLUgetTranslation(mlu: LPcmsMLU; LanguageCode, CountryCode, ObtainedLanguage, ObtainedCountry: PAnsiChar): cmsBool; StdCall;
-
-// Undercolorremoval & black generation -------------------------------------------------------------------------------------
-
-Type
-
-cmsUcrBg = PACKED RECORD
- Ucr, Bg: LPcmsToneCurve;
- Desc: LPcmsMLU;
- END;
-
-
-// Screening ----------------------------------------------------------------------------------------------------------------
-
-Const
-
- cmsPRINTER_DEFAULT_SCREENS = $0001;
- cmsFREQUENCE_UNITS_LINES_CM = $0000;
- cmsFREQUENCE_UNITS_LINES_INCH = $0002;
-
- cmsSPOT_UNKNOWN = 0;
- cmsSPOT_PRINTER_DEFAULT = 1;
- cmsSPOT_ROUND = 2;
- cmsSPOT_DIAMOND = 3;
- cmsSPOT_ELLIPSE = 4;
- cmsSPOT_LINE = 5;
- cmsSPOT_SQUARE = 6;
- cmsSPOT_CROSS = 7;
-
-
-Type
-
-cmsScreeningChannel = PACKED RECORD
-
- Frequency,
- ScreenAngle: cmsFloat64Number;
- SpotShape: cmsUInt32Number;
-
-END;
-
-cmsScreening = PACKED RECORD
-
- Flag,
- nChannels : cmsUInt32Number;
- Channels: Array [0..cmsMAXCHANNELS-1] OF cmsScreeningChannel;
-END;
-
-
-// Named color -----------------------------------------------------------------------------------------------------------------
-
-
-LPcmsNAMEDCOLORLIST = Pointer;
-
-FUNCTION cmsAllocNamedColorList(ContextID: cmsContext; n, ColorantCount :cmsUInt32Number;
- Prefix, Suffix: PAnsiChar): LPcmsNAMEDCOLORLIST; StdCall;
-
-PROCEDURE cmsFreeNamedColorList(v: LPcmsNAMEDCOLORLIST); StdCall;
-FUNCTION cmsDupNamedColorList(v: LPcmsNAMEDCOLORLIST): LPcmsNAMEDCOLORLIST; StdCall;
-FUNCTION cmsAppendNamedColor(v: LPcmsNAMEDCOLORLIST; Name: PAnsiChar;
- PCS, Colorant : LPcmsUInt16NumberArray): cmsBool; StdCall;
-
-FUNCTION cmsNamedColorCount(v: LPcmsNAMEDCOLORLIST): cmsUInt32Number; StdCall;
-FUNCTION cmsNamedColorIndex(v: LPcmsNAMEDCOLORLIST; Name: PAnsiChar): cmsInt32Number; StdCall;
-
-FUNCTION cmsNamedColorInfo(v: LPcmsNAMEDCOLORLIST; nColor : cmsUInt32Number;
- Name,Prefix, Suffix : PAnsiChar;
- PCS, Colorant : LPcmsUInt16NumberArray): cmsBool; StdCall;
-
-// Retrieve named color list from transform
-FUNCTION cmsGetNamedColorList(xform: cmsHTRANSFORM ): LPcmsNAMEDCOLORLIST; StdCall;
-
-// Profile sequence -----------------------------------------------------------------------------------------------------
-
-Type
-
-// Profile sequence descriptor. Some fields come from profile sequence descriptor tag, others
-// come from Profile Sequence Identifier Tag
-
-cmsPSEQDESC = PACKED RECORD
- deviceMfg, deviceModel: cmsSignature;
-
- attributes: cmsUInt64Number;
- technology: cmsTechnologySignature;
- ProfileID: cmsProfileID;
- Manufacturer,
- Model,
- Description : LPcmsMLU;
- END;
-
- LPcmsSEQDESC = ^cmsPSEQDESC;
-
-cmsSEQ = PACKED RECORD
-
- n: cmsUInt32Number;
- ContextID: cmsContext;
- seq: LPcmsSEQDESC;
-END;
-
-LPcmsSEQ = ^cmsSEQ;
-
-FUNCTION cmsAllocProfileSequenceDescription(ContextID: cmsContext; n: cmsUInt32Number):LPcmsSEQ; StdCall;
-FUNCTION cmsDupProfileSequenceDescription(pseq: LPcmsSEQ):LPcmsSEQ; StdCall;
-PROCEDURE cmsFreeProfileSequenceDescription(pseq: LPcmsSEQ); StdCall;
-
-// Dictionaries --------------------------------------------------------------------------------------------------------
-
-TYPE
-
- LPcmsDICTentry = ^cmsDICTentry;
-
-cmsDICTentry = PACKED RECORD
-
- Next: LPcmsDICTentry;
-
- DisplayName, DisplayValue: LPcmsMLU;
- Name, Value : PWChar;
-END;
-
-FUNCTION cmsDictAlloc(ContextID: cmsContext): cmsHANDLE; StdCall;
-PROCEDURE cmsDictFree(hDict: cmsHANDLE); StdCall;
-FUNCTION cmsDictDup(hDict: cmsHANDLE): cmsHANDLE; StdCall;
-
-FUNCTION cmsDictAddEntry(hDict: cmsHANDLE; Name, Value: PWChar; DisplayName, DisplayValue : LPcmsMLU): cmsBool; StdCall;
-FUNCTION cmsDictGetEntryList(hDict: cmsHANDLE): LPcmsDICTentry; StdCall;
-FUNCTION cmsDictNextEntry(e : LPcmsDICTentry): LPcmsDICTentry; StdCall;
-
-// Access to Profile data ----------------------------------------------------------------------------------------------
-FUNCTION cmsCreateProfilePlaceholder(ContextID: cmsContext): cmsHPROFILE; StdCall;
-
-FUNCTION cmsGetProfileContextID(hProfile: cmsHPROFILE):cmsContext; StdCall;
-FUNCTION cmsGetTagCount(hProfile: cmsHPROFILE): cmsInt32Number; StdCall;
-FUNCTION cmsGetTagSignature(hProfile: cmsHPROFILE; n: cmsUInt32Number): cmsTagSignature; StdCall;
-FUNCTION cmsIsTag(hProfile: cmsHPROFILE; sig: cmsTagSignature ): cmsBool; StdCall;
-
-// Read and write pre-formatted data
-FUNCTION cmsReadTag(hProfile: cmsHPROFILE; sig: cmsTagSignature ): Pointer; StdCall;
-FUNCTION cmsWriteTag(hProfile: cmsHPROFILE; sig: cmsTagSignature; data: Pointer): cmsBool; StdCall;
-FUNCTION cmsLinkTag(hProfile: cmsHPROFILE; sig: cmsTagSignature; dest: cmsTagSignature): cmsBool; StdCall;
-FUNCTION cmsTagLinkedTo(hProfile: cmsHPROFILE; sig: cmsTagSignature):cmsTagSignature; StdCall;
-
-// Read and write raw data
-FUNCTION cmsReadRawTag(hProfile: cmsHPROFILE; sig: cmsTagSignature; Buffer: Pointer; BufferSize: cmsUInt32Number): cmsInt32Number; StdCall;
-FUNCTION cmsWriteRawTag(hProfile: cmsHPROFILE; sig: cmsTagSignature; data: Pointer; Size: cmsUInt32Number): cmsBool; StdCall;
-
-// Access header data
-Const
-
- cmsEmbeddedProfileFalse = $00000000;
- cmsEmbeddedProfileTrue = $00000001;
- cmsUseAnywhere = $00000000;
- cmsUseWithEmbeddedDataOnly = $00000002;
-
-FUNCTION cmsGetHeaderFlags(hProfile: cmsHPROFILE): cmsUInt32Number; StdCall;
-PROCEDURE cmsGetHeaderAttributes(hProfile: cmsHPROFILE; Flags: LPcmsUInt64Number); StdCall;
-PROCEDURE cmsGetHeaderProfileID(hProfile: cmsHPROFILE; ProfileID: LPcmsUInt8Number); StdCall;
-
-// TODO:
-// FUNCTION cmsGetHeaderCreationDateTime(hProfile: cmsHPROFILE; struct tm *Dest): cmsBool; StdCall;
-
-FUNCTION cmsGetHeaderRenderingIntent(hProfile: cmsHPROFILE): cmsUInt32Number; StdCall;
-PROCEDURE cmsSetHeaderFlags(hProfile: cmsHPROFILE; Flags: cmsUInt32Number); StdCall;
-FUNCTION cmsGetHeaderManufacturer(hProfile: cmsHPROFILE): cmsUInt32Number; StdCall;
-PROCEDURE cmsSetHeaderManufacturer(hProfile: cmsHPROFILE; manufacturer: cmsUInt32Number ); StdCall;
-FUNCTION cmsGetHeaderModel(hProfile: cmsHPROFILE): cmsUInt32Number; StdCall;
-PROCEDURE cmsSetHeaderModel(hProfile: cmsHPROFILE; model: cmsUInt32Number ); StdCall;
-PROCEDURE cmsSetHeaderAttributes(hProfile: cmsHPROFILE; Flags: cmsUInt64Number); StdCall;
-PROCEDURE cmsSetHeaderProfileID(hProfile: cmsHPROFILE; ProfileID: LPcmsUInt8Number); StdCall;
-PROCEDURE cmsSetHeaderRenderingIntent(hProfile: cmsHPROFILE; RenderingIntent: cmsUInt32Number ); StdCall;
-
-FUNCTION cmsGetPCS(hProfile: cmsHPROFILE):cmsColorSpaceSignature; StdCall;
-PROCEDURE cmsSetPCS(hProfile: cmsHPROFILE; pcs: cmsColorSpaceSignature); StdCall;
-FUNCTION cmsGetColorSpace(hProfile: cmsHPROFILE): cmsColorSpaceSignature; StdCall;
-PROCEDURE cmsSetColorSpace(hProfile: cmsHPROFILE; sig: cmsColorSpaceSignature); StdCall;
-FUNCTION cmsGetDeviceClass(hProfile: cmsHPROFILE): cmsProfileClassSignature; StdCall;
-PROCEDURE cmsSetDeviceClass(hProfile: cmsHPROFILE; sig: cmsProfileClassSignature); StdCall;
-PROCEDURE cmsSetProfileVersion(hProfile: cmsHPROFILE; Version: cmsFloat64Number); StdCall;
-FUNCTION cmsGetProfileVersion(hProfile: cmsHPROFILE): cmsFloat64Number; StdCall;
-
-FUNCTION cmsGetEncodedICCversion(hProfile: cmsHPROFILE): cmsUInt32Number; StdCall;
-PROCEDURE cmsSetEncodedICCversion(hProfile: cmsHPROFILE; Version: cmsUInt32Number); StdCall;
-
-
-Const
-
- // How profiles may be used
- LCMS_USED_AS_INPUT = 0;
- LCMS_USED_AS_OUTPUT = 1;
- LCMS_USED_AS_PROOF = 2;
-
-FUNCTION cmsIsIntentSupported(hProfile: cmsHPROFILE; Intent: cmsUInt32Number; UsedDirection: cmsUInt32Number): cmsBool; StdCall;
-FUNCTION cmsIsMatrixShaper(hProfile: cmsHPROFILE): cmsBool; StdCall;
-FUNCTION cmsIsCLUT(hProfile: cmsHPROFILE; Intent: cmsUInt32Number; UsedDirection: cmsUInt32Number): cmsBool; StdCall;
-
-// Translate form/to our notation to ICC
-FUNCTION _cmsICCcolorSpace(OurNotation: Integer): cmsColorSpaceSignature; StdCall;
-FUNCTION _cmsLCMScolorSpace(ProfileSpace: cmsColorSpaceSignature): Integer; StdCall;
-
-FUNCTION cmsChannelsOf( ColorSpace: cmsColorSpaceSignature): cmsUInt32Number; StdCall;
-
-// Build a suitable formatter for the colorspace of this profile
-FUNCTION cmsFormatterForColorspaceOfProfile(hProfile: cmsHPROFILE; nBytes: cmsUInt32Number; lIsFloat: cmsBool): cmsUInt32Number; StdCall;
-FUNCTION cmsFormatterForPCSOfProfile(hProfile: cmsHPROFILE; nBytes: cmsUInt32Number; lIsFloat: cmsBool): cmsUInt32Number; StdCall;
-
-Type
-
-// Localized info
-cmsInfoType = (
- cmsInfoDescription = 0,
- cmsInfoManufacturer = 1,
- cmsInfoModel = 2,
- cmsInfoCopyright = 3
-);
-
-FUNCTION cmsGetProfileInfo(hProfile: cmsHPROFILE; Info: cmsInfoType; LanguageCode, CountryCode: PAnsiChar;
- Buffer: PWChar; BufferSize: cmsUInt32Number): cmsUInt32Number; StdCall;
-
-FUNCTION cmsGetProfileInfoASCII(hProfile: cmsHPROFILE; Info: cmsInfoType; LanguageCode, CountryCode: PAnsiChar;
- Buffer: PAnsiChar; BufferSize: cmsUInt32Number): cmsUInt32Number; StdCall;
-
-// IO handlers ----------------------------------------------------------------------------------------------------------
-
-Type
-
-LPcmsIOHANDLER = Pointer;
-
-FUNCTION cmsOpenIOhandlerFromFile(ContextID: cmsContext; FileName, AccessMode: PAnsiChar): LPcmsIOHANDLER; StdCall;
-// FUNCTION cmsOpenIOhandlerFromStream(ContextID: cmsContext; FILE* Stream): LPcmsIOHANDLER; StdCall;
-FUNCTION cmsOpenIOhandlerFromMem(ContextID: cmsContext; Buffer: Pointer; size: cmsUInt32Number; AccessMode: PAnsiChar): LPcmsIOHANDLER; StdCall;
-FUNCTION cmsOpenIOhandlerFromNULL(ContextID: cmsContext): LPcmsIOHANDLER; StdCall;
-FUNCTION cmsCloseIOhandler(io: LPcmsIOHANDLER): cmsBool; StdCall;
-
-// MD5 message digest --------------------------------------------------------------------------------------------------
-
-FUNCTION cmsMD5computeID(hProfile: cmsHPROFILE): cmsBool; StdCall;
-
-// Profile high level funtions ------------------------------------------------------------------------------------------
-
-FUNCTION cmsOpenProfileFromFile(ICCProfile : PAnsiChar; sAccess: PAnsiChar): cmsHPROFILE; StdCall;
-FUNCTION cmsOpenProfileFromFileTHR(ContextID: cmsContext; ICCProfile, sAccess: PAnsiChar): cmsHPROFILE; StdCall;
-// FUNCTION CMSEXPORT cmsOpenProfileFromStream(FILE* ICCProfile, const char* sAccess): cmsHPROFILE; StdCall;
-// FUNCTION CMSEXPORT cmsOpenProfileFromStreamTHR(ContextID: cmsContext; FILE* ICCProfile, const char* sAccess): cmsHPROFILE; StdCall;
-FUNCTION cmsOpenProfileFromMem(MemPtr: Pointer; dwSize: cmsUInt32Number): cmsHPROFILE; StdCall;
-FUNCTION cmsOpenProfileFromMemTHR(ContextID: cmsContext; MemPtr: Pointer; dwSize: cmsUInt32Number): cmsHPROFILE; StdCall;
-FUNCTION cmsOpenProfileFromIOhandlerTHR(ContextID: cmsContext; io: LPcmsIOHANDLER): cmsHPROFILE; StdCall;
-FUNCTION cmsCloseProfile(hProfile: cmsHPROFILE): cmsBool; StdCall;
-
-FUNCTION cmsSaveProfileToFile(hProfile: cmsHPROFILE; FileName: PAnsiChar): cmsBool; StdCall;
-// FUNCTION CMSEXPORT cmsSaveProfileToStream(hProfile: cmsHPROFILE, FILE* Stream): cmsBool; StdCall;
-FUNCTION cmsSaveProfileToMem(hProfile: cmsHPROFILE; MemPtr: Pointer; BytesNeeded: LPcmsUInt32Number): cmsBool; StdCall;
-FUNCTION cmsSaveProfileToIOhandler(hProfile: cmsHPROFILE; io: LPcmsIOHANDLER):cmsUInt32Number; StdCall;
-
-// Predefined virtual profiles ------------------------------------------------------------------------------------------
-
-FUNCTION cmsCreateRGBProfileTHR(ContextID: cmsContext;
- WhitePoint: LPcmsCIExyY;
- Primaries: LPcmsCIExyYTRIPLE;
- TransferFunction: LPLPcmsToneCurveArray): cmsHPROFILE; StdCall;
-
-FUNCTION cmsCreateRGBProfile(WhitePoint: LPcmsCIExyY;
- Primaries: LPcmsCIExyYTRIPLE;
- TransferFunction: LPLPcmsToneCurveArray): cmsHPROFILE; StdCall;
-
-FUNCTION cmsCreateGrayProfileTHR(ContextID: cmsContext;
- WhitePoint: LPcmsCIExyY;
- TransferFunction: LPcmsToneCurve): cmsHPROFILE; StdCall;
-
-FUNCTION cmsCreateGrayProfile(WhitePoint: LPcmsCIExyY;
- TransferFunction: LPcmsToneCurve): cmsHPROFILE; StdCall;
-
-FUNCTION cmsCreateLinearizationDeviceLinkTHR(ContextID: cmsContext;
- ColorSpace: cmsColorSpaceSignature;
- TransferFunctions: LPLPcmsToneCurveArray): cmsHPROFILE; StdCall;
-
-FUNCTION cmsCreateLinearizationDeviceLink(ColorSpace: cmsColorSpaceSignature;
- TransferFunctions: LPLPcmsToneCurveArray): cmsHPROFILE; StdCall;
-
-FUNCTION cmsCreateInkLimitingDeviceLinkTHR(ContextID: cmsContext;
- ColorSpace: cmsColorSpaceSignature; Limit: cmsFloat64Number): cmsHPROFILE; StdCall;
-
-FUNCTION cmsCreateInkLimitingDeviceLink(ColorSpace: cmsColorSpaceSignature; Limit: cmsFloat64Number): cmsHPROFILE; StdCall;
-
-
-FUNCTION cmsCreateLab2ProfileTHR(ContextID: cmsContext; WhitePoint: LPcmsCIExyY): cmsHPROFILE; StdCall;
-FUNCTION cmsCreateLab2Profile(WhitePoint: LPcmsCIExyY): cmsHPROFILE; StdCall;
-FUNCTION cmsCreateLab4ProfileTHR(ContextID: cmsContext; WhitePoint: LPcmsCIExyY): cmsHPROFILE; StdCall;
-FUNCTION cmsCreateLab4Profile(WhitePoint: LPcmsCIExyY): cmsHPROFILE; StdCall;
-
-FUNCTION cmsCreateXYZProfileTHR(ContextID: cmsContext): cmsHPROFILE; StdCall;
-FUNCTION cmsCreateXYZProfile: cmsHPROFILE; StdCall;
-
-FUNCTION cmsCreate_sRGBProfileTHR(ContextID: cmsContext): cmsHPROFILE; StdCall;
-FUNCTION cmsCreate_sRGBProfile: cmsHPROFILE; StdCall;
-
-FUNCTION cmsCreateBCHSWabstractProfileTHR(ContextID: cmsContext;
- nLUTPoints: Integer;
- Bright,
- Contrast,
- Hue,
- Saturation: cmsFloat64Number;
- TempSrc,
- TempDest: Integer): cmsHPROFILE; StdCall;
-
-FUNCTION cmsCreateBCHSWabstractProfile( nLUTPoints: Integer;
- Bright,
- Contrast,
- Hue,
- Saturation: cmsFloat64Number;
- TempSrc,
- TempDest: Integer): cmsHPROFILE; StdCall;
-
-FUNCTION cmsCreateNULLProfileTHR(ContextID: cmsContext): cmsHPROFILE; StdCall;
-FUNCTION cmsCreateNULLProfile: cmsHPROFILE; StdCall;
-
-// Converts a transform to a devicelink profile
-FUNCTION cmsTransform2DeviceLink(hTransform: cmsHTRANSFORM; Version: cmsFloat64Number; dwFlags: cmsUInt32Number): cmsHPROFILE; StdCall;
-
-// Intents ----------------------------------------------------------------------------------------------
-
-Const
-
-// ICC Intents
-INTENT_PERCEPTUAL = 0;
-INTENT_RELATIVE_COLORIMETRIC = 1;
-INTENT_SATURATION = 2;
-INTENT_ABSOLUTE_COLORIMETRIC = 3;
-
-// Non-ICC intents
-INTENT_PRESERVE_K_ONLY_PERCEPTUAL = 10;
-INTENT_PRESERVE_K_ONLY_RELATIVE_COLORIMETRIC = 11;
-INTENT_PRESERVE_K_ONLY_SATURATION = 12;
-INTENT_PRESERVE_K_PLANE_PERCEPTUAL = 13;
-INTENT_PRESERVE_K_PLANE_RELATIVE_COLORIMETRIC = 14;
-INTENT_PRESERVE_K_PLANE_SATURATION = 15;
-
-Type
-LPPAnsiChar = ^PAnsiChar;
-
-// Call with NULL as parameters to get the intent count
-FUNCTION cmsGetSupportedIntents(nMax: cmsUInt32Number; Codes: LPcmsUInt32Number; Descriptions: LPPAnsiChar): cmsUInt32Number; StdCall;
-
-Const
-
-// Flags
-
-cmsFLAGS_NOCACHE = $0040; // Inhibit 1-pixel cache
-cmsFLAGS_NOOPTIMIZE = $0100; // Inhibit optimizations
-cmsFLAGS_NULLTRANSFORM = $0200; // Don't transform anyway
-
-// Proofing flags
-cmsFLAGS_GAMUTCHECK = $1000; // Out of Gamut alarm
-cmsFLAGS_SOFTPROOFING = $4000; // Do softproofing
-
-// Misc
-cmsFLAGS_BLACKPOINTCOMPENSATION = $2000;
-cmsFLAGS_NOWHITEONWHITEFIXUP = $0004; // Don't fix scum dot
-cmsFLAGS_HIGHRESPRECALC = $0400; // Use more memory to give better accurancy
-cmsFLAGS_LOWRESPRECALC = $0800; // Use less memory to minimize resouces
-
-// For devicelink creation
-cmsFLAGS_8BITS_DEVICELINK = $0008; // Create 8 bits devicelinks
-cmsFLAGS_GUESSDEVICECLASS = $0020; // Guess device class (for transform2devicelink)
-cmsFLAGS_KEEP_SEQUENCE = $0080; // Keep profile sequence for devicelink creation
-
-// Specific to a particular optimizations
-cmsFLAGS_FORCE_CLUT = $0002; // Force CLUT optimization
-cmsFLAGS_CLUT_POST_LINEARIZATION = $0001; // create postlinearization tables if possible
-cmsFLAGS_CLUT_PRE_LINEARIZATION = $0010; // create prelinearization tables if possible
-
-// CRD special
-cmsFLAGS_NODEFAULTRESOURCEDEF = $01000000;
-
-// Fine-tune control over number of gridpoints
-FUNCTION cmsFLAGS_GRIDPOINTS(n: Integer): Integer;
-
-
-// Transforms ---------------------------------------------------------------------------------------------------
-
-type
- LPcmsHPROFILEArray = ^cmsHPROFILEArray;
- cmsHPROFILEArray = array[0..0] of cmsHPROFILE;
-
- LPcmsBoolArray = ^cmsBoolArray;
- cmsBoolArray = array[0..0] of cmsBool;
-
-FUNCTION cmsCreateTransformTHR(ContextID: cmsContext;
- Input: cmsHPROFILE;
- InputFormat: cmsUInt32Number;
- Output: cmsHPROFILE;
- OutputFormat: cmsUInt32Number;
- Intent: cmsUInt32Number;
- dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall;
-
-FUNCTION cmsCreateTransform(Input: cmsHPROFILE;
- InputFormat: cmsUInt32Number;
- Output: cmsHPROFILE;
- OutputFormat: cmsUInt32Number;
- Intent: cmsUInt32Number;
- dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall;
-
-FUNCTION cmsCreateProofingTransformTHR(ContextID: cmsContext;
- Input: cmsHPROFILE;
- InputFormat: cmsUInt32Number;
- Output: cmsHPROFILE;
- OutputFormat: cmsUInt32Number;
- Proofing: cmsHPROFILE;
- Intent: cmsUInt32Number;
- ProofingIntent: cmsUInt32Number;
- dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall;
-
-FUNCTION cmsCreateProofingTransform(Input: cmsHPROFILE;
- InputFormat: cmsUInt32Number;
- Output: cmsHPROFILE;
- OutputFormat: cmsUInt32Number;
- Proofing: cmsHPROFILE;
- Intent: cmsUInt32Number;
- ProofingIntent: cmsUInt32Number;
- dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall;
-
-FUNCTION cmsCreateMultiprofileTransformTHR(ContextID: cmsContext;
- hProfiles: LPcmsHPROFILEArray;
- nProfiles: cmsUInt32Number;
- InputFormat: cmsUInt32Number;
- OutputFormat: cmsUInt32Number;
- Intent: cmsUInt32Number;
- dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall;
-
-
-FUNCTION cmsCreateMultiprofileTransform( hProfiles: LPcmsHPROFILEArray;
- nProfiles: cmsUInt32Number;
- InputFormat: cmsUInt32Number;
- OutputFormat: cmsUInt32Number;
- Intent: cmsUInt32Number;
- dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall;
-
-
-FUNCTION cmsCreateExtendedTransform(ContextID: cmsContext;
- nProfiles: cmsUInt32Number;
- hProfiles: LPcmsHPROFILEArray;
- BPC: LPcmsBoolArray;
- Intents: LPcmsUInt32NumberArray;
- AdaptationStates: LPcmsFloat64NumberArray;
- hGamutProfile: cmsHPROFILE;
- nGamutPCSposition: cmsUInt32Number;
- InputFormat,
- OutputFormat: cmsUInt32Number;
- dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall;
-
-PROCEDURE cmsDeleteTransform(hTransform: cmsHTRANSFORM); StdCall;
-
-PROCEDURE cmsDoTransform(Transform: cmsHTRANSFORM; InputBuffer, OutputBuffer: Pointer; size: cmsUInt32Number); StdCall;
-
-PROCEDURE cmsSetAlarmCodes( NewAlarm: LPcmsUInt16NumberArray); StdCall;
-PROCEDURE cmsGetAlarmCodes(NewAlarm: LPcmsUInt16NumberArray); StdCall;
-
-// Adaptation state for absolute colorimetric intent
-FUNCTION cmsSetAdaptationState(d: cmsFloat64Number):cmsFloat64Number; StdCall;
-
-// Grab the ContextID from an open transform. Returns NULL if a NULL transform is passed
-FUNCTION cmsGetTransformContextID(hTransform: cmsHTRANSFORM):cmsContext; StdCall;
-
-// For backwards compatibility
-FUNCTION cmsChangeBuffersFormat(hTransform: cmsHTRANSFORM; InputFormat, OutputFormat: cmsUInt32Number): cmsBool; StdCall;
-
-
-
-// PostScript ColorRenderingDictionary and ColorSpaceArray ----------------------------------------------------
-
-Type
-
-cmsPSResourceType = (cmsPS_RESOURCE_CSA, cmsPS_RESOURCE_CRD ) ;
-
-// lcms2 unified method to access postscript color resources
-FUNCTION cmsGetPostScriptColorResource(ContextID: cmsContext; RType: cmsPSResourceType;
- hProfile: cmsHPROFILE;
- Intent: cmsUInt32Number;
- dwFlags: cmsUInt32Number;
- io: LPcmsIOHANDLER): cmsUInt32Number; StdCall;
-
-FUNCTION cmsGetPostScriptCSA(ContextID: cmsContext; hProfile: cmsHPROFILE; Intent: cmsUInt32Number; dwFlags: cmsUInt32Number; Buffer: Pointer; dwBufferLen: cmsUInt32Number ): cmsUInt32Number; StdCall;
-FUNCTION cmsGetPostScriptCRD(ContextID: cmsContext; hProfile: cmsHPROFILE; Intent: cmsUInt32Number; dwFlags: cmsUInt32Number; Buffer: Pointer; dwBufferLen: cmsUInt32Number): cmsUInt32Number; StdCall;
-
-
-// IT8.7 / CGATS.17-20$ handling -----------------------------------------------------------------------------
-
-
-// CGATS.13 parser
-
-FUNCTION cmsIT8Alloc: cmsHANDLE; StdCall;
-PROCEDURE cmsIT8Free(hIT8: cmsHANDLE); StdCall;
-
-// Tables
-
-FUNCTION cmsIT8TableCount(hIT8: cmsHANDLE): Integer; StdCall;
-FUNCTION cmsIT8SetTable(hIT8: cmsHANDLE; nTable: Integer): Integer; StdCall;
-
-// Persistence
-FUNCTION cmsIT8LoadFromFile(cFileName: PAnsiChar): cmsHANDLE; StdCall;
-FUNCTION cmsIT8LoadFromMem(Ptr: Pointer; size :DWord): cmsHANDLE; StdCall;
-
-FUNCTION cmsIT8SaveToFile(hIT8: cmsHANDLE; cFileName: PAnsiChar): cmsBool; StdCall;
-FUNCTION cmsIT8SaveToMem(hIT8: cmsHANDLE; MemPtr: Pointer; BytesNeeded: LPcmsUInt32Number): cmsBool; StdCall;
-// Properties
-
-FUNCTION cmsIT8GetSheetType(hIT8: cmsHANDLE): PAnsiChar; StdCall;
-FUNCTION cmsIT8SetSheetType(hIT8: cmsHANDLE; TheType: PAnsiChar): cmsBool; StdCall;
-
-FUNCTION cmsIT8SetComment(hIT8: cmsHANDLE; cComment: PAnsiChar): cmsBool; StdCall;
-
-FUNCTION cmsIT8SetPropertyStr(hIT8: cmsHANDLE; cProp, Str: PAnsiChar): cmsBool; StdCall;
-FUNCTION cmsIT8SetPropertyDbl(hIT8: cmsHANDLE; cProp: PAnsiChar; Val: Double): cmsBool; StdCall;
-FUNCTION cmsIT8SetPropertyHex(hIT8: cmsHANDLE; cProp: PAnsiChar; Val: Integer): cmsBool; StdCall;
-FUNCTION cmsIT8SetPropertyUncooked(hIT8: cmsHANDLE; Key, Buffer: PAnsiChar): cmsBool; StdCall;
-
-
-FUNCTION cmsIT8GetProperty(hIT8: cmsHANDLE; cProp: PAnsiChar): PAnsiChar; StdCall;
-FUNCTION cmsIT8GetPropertyDbl(hIT8: cmsHANDLE; cProp: PAnsiChar): Double; StdCall;
-FUNCTION cmsIT8EnumProperties(hIT8: cmsHANDLE; var PropertyNames: LPPAnsiChar): Integer; StdCall;
-
-// Datasets
-
-FUNCTION cmsIT8GetDataRowCol(hIT8: cmsHANDLE; row, col: Integer): PAnsiChar; StdCall;
-FUNCTION cmsIT8GetDataRowColDbl(hIT8: cmsHANDLE; row, col: Integer): Double; StdCall;
-
-FUNCTION cmsIT8SetDataRowCol(hIT8: cmsHANDLE; row, col: Integer; Val: PAnsiChar): cmsBool; StdCall;
-FUNCTION cmsIT8SetDataRowColDbl(hIT8: cmsHANDLE; row, col: Integer; Val: Double): cmsBool; StdCall;
-
-FUNCTION cmsIT8GetData(hIT8: cmsHANDLE; cPatch, cSample: PAnsiChar): PAnsiChar; StdCall;
-
-FUNCTION cmsIT8GetDataDbl(hIT8: cmsHANDLE;cPatch, cSample: PAnsiChar): Double; StdCall;
-
-FUNCTION cmsIT8SetData(hIT8: cmsHANDLE; cPatch, cSample, Val: PAnsiChar): cmsBool; StdCall;
-
-FUNCTION cmsIT8SetDataDbl(hIT8: cmsHANDLE; cPatch, cSample: PAnsiChar; Val: Double): cmsBool; StdCall;
-
-FUNCTION cmsIT8SetDataFormat(hIT8: cmsHANDLE; n: Integer; Sample: PAnsiChar): cmsBool; StdCall;
-FUNCTION cmsIT8EnumDataFormat(hIT8: cmsHANDLE; var SampleNames: LPPAnsiChar): Integer; StdCall;
-FUNCTION cmsIT8GetPatchName(hIT8: cmsHANDLE; nPatch: Integer; Buffer: PAnsiChar): PAnsiChar; StdCall;
-
-// The LABEL extension
-FUNCTION cmsIT8SetTableByLabel(hIT8: cmsHANDLE; cSet, cField, ExpectedType: PAnsiChar): Integer; StdCall;
-
-FUNCTION cmsIT8FindDataFormat(hIT8: cmsHANDLE; cSample: PAnsiChar): Integer; StdCall;
-
-// Formatter for double
-PROCEDURE cmsIT8DefineDblFormat(hIT8: cmsHANDLE; Formatter: PAnsiChar); StdCall;
-
-// Gamut boundary description routines ------------------------------------------------------------------------------
-
-FUNCTION cmsGBDAlloc(ContextID: cmsContext):cmsHANDLE; StdCall;
-PROCEDURE cmsGBDFree(hGBD: cmsHANDLE); StdCall;
-FUNCTION cmsGDBAddPoint(hGBD: cmsHANDLE; Lab: LPcmsCIELab): cmsBool; StdCall;
-FUNCTION cmsGDBCompute(hGDB: cmsHANDLE; dwFlags: cmsUInt32Number): cmsBool; StdCall;
-FUNCTION cmsGDBCheckPoint(hGBD: cmsHANDLE; Lab: LPcmsCIELab): cmsBool; StdCall;
-
-// Feature detection ----------------------------------------------------------------------------------------------
-
-// Estimate the black point
-FUNCTION cmsDetectBlackPoint( BlackPoint: LPcmsCIEXYZ; hProfile: cmsHPROFILE; Intent: cmsUInt32Number; dwFlags: cmsUInt32Number): cmsBool; StdCall;
-FUNCTION cmsDetectDestinationBlackPoint( BlackPoint: LPcmsCIEXYZ; hProfile: cmsHPROFILE; Intent: cmsUInt32Number; dwFlags: cmsUInt32Number): cmsBool; StdCall;
-
-
-// Estimate total area coverage
-FUNCTION cmsDetectTAC(hProfile: cmsHPROFILE): cmsFloat64Number; StdCall;
-
-
-// Poor man's gamut mapping
-FUNCTION cmsDesaturateLab(Lab: LPcmsCIELab; amax, amin, bmax, bmin: cmsFloat64Number): cmsBool; StdCall;
-
-
-IMPLEMENTATION
-
-
-
- FUNCTION FLOAT_SH(a: cmsUInt32Number): cmsUInt32Number; begin FLOAT_SH := ((a) shl 22) end;
- FUNCTION OPTIMIZED_SH(s: cmsUInt32Number): cmsUInt32Number; begin OPTIMIZED_SH := ((s) shl 21) end;
- FUNCTION COLORSPACE_SH(s: cmsUInt32Number):cmsUInt32Number; begin COLORSPACE_SH := ((s) shl 16) end;
- FUNCTION SWAPFIRST_SH(s: cmsUInt32Number):cmsUInt32Number; begin SWAPFIRST_SH := ((s) shl 14) end;
- FUNCTION FLAVOR_SH(s: cmsUInt32Number):cmsUInt32Number; begin FLAVOR_SH := ((s) shl 13) end;
- FUNCTION PLANAR_SH(p: cmsUInt32Number):cmsUInt32Number; begin PLANAR_SH := ((p) shl 12) end;
- FUNCTION ENDIAN16_SH(e: cmsUInt32Number):cmsUInt32Number; begin ENDIAN16_SH := ((e) shl 11) end;
- FUNCTION DOSWAP_SH(e: cmsUInt32Number):cmsUInt32Number; begin DOSWAP_SH := ((e) shl 10) end;
- FUNCTION EXTRA_SH(e: cmsUInt32Number):cmsUInt32Number; begin EXTRA_SH := ((e) shl 7) end;
- FUNCTION CHANNELS_SH(c: cmsUInt32Number):cmsUInt32Number; begin CHANNELS_SH := ((c) shl 3) end;
- FUNCTION BYTES_SH(b: cmsUInt32Number):cmsUInt32Number; begin BYTES_SH := (b) end;
-
-
- FUNCTION T_FLOAT(a: cmsUInt32Number): cmsUInt32Number; begin T_FLOAT := (((a) shr 22) and 1) end;
- FUNCTION T_OPTIMIZED(o: cmsUInt32Number): cmsUInt32Number; begin T_OPTIMIZED := (((o) shr 21) and 1) end;
- FUNCTION T_COLORSPACE(s: cmsUInt32Number): cmsUInt32Number; begin T_COLORSPACE := (((s) shr 16) and 31) end;
- FUNCTION T_SWAPFIRST(s: cmsUInt32Number): cmsUInt32Number; begin T_SWAPFIRST := (((s) shr 14) and 1) end;
- FUNCTION T_FLAVOR(s: cmsUInt32Number): cmsUInt32Number; begin T_FLAVOR := (((s) shr 13) and 1) end;
- FUNCTION T_PLANAR(p: cmsUInt32Number): cmsUInt32Number; begin T_PLANAR := (((p) shr 12) and 1) end;
- FUNCTION T_ENDIAN16(e: cmsUInt32Number): cmsUInt32Number; begin T_ENDIAN16 := (((e) shr 11) and 1) end;
- FUNCTION T_DOSWAP(e: cmsUInt32Number): cmsUInt32Number; begin T_DOSWAP := (((e) shr 10) and 1) end;
- FUNCTION T_EXTRA(e: cmsUInt32Number): cmsUInt32Number; begin T_EXTRA := (((e) shr 7) and 7) end;
- FUNCTION T_CHANNELS(c: cmsUInt32Number): cmsUInt32Number; begin T_CHANNELS := (((c) shr 3) and 15) end;
- FUNCTION T_BYTES(b: cmsUInt32Number): cmsUInt32Number; begin T_BYTES := ((b) and 7) end;
-
-
-
-//
-
-
-FUNCTION cmsPlugin(Plugin: Pointer): cmsBool; StdCall; external 'lcms2.dll';
-PROCEDURE cmsUnregisterPlugins; StdCall; external 'lcms2.dll';
-PROCEDURE cmsSetLogErrorHandler(Fn: cmsLogErrorHandlerFunction); StdCall; external 'lcms2.dll';
-FUNCTION cmsD50_XYZ: LPcmsCIEXYZ; StdCall; external 'lcms2.dll';
-FUNCTION cmsD50_xyY: LPcmsCIExyY; StdCall; external 'lcms2.dll';
-PROCEDURE cmsXYZ2xyY(Dest: LPcmsCIExyY; Source: LPcmsCIEXYZ); StdCall; external 'lcms2.dll';
-PROCEDURE cmsxyY2XYZ(Dest: LPcmsCIEXYZ; Source: LPcmsCIExyY); StdCall; external 'lcms2.dll';
-PROCEDURE cmsLab2XYZ(WhitePoint: LPcmsCIEXYZ; xyz: LPcmsCIEXYZ; Lab: LPcmsCIELab); StdCall; external 'lcms2.dll';
-PROCEDURE cmsXYZ2Lab(WhitePoint: LPcmsCIEXYZ; Lab: LPcmsCIELab; xyz: LPcmsCIEXYZ); StdCall; external 'lcms2.dll';
-PROCEDURE cmsLab2LCh(LCh: LPcmsCIELCh; Lab: LPcmsCIELab); StdCall; external 'lcms2.dll';
-PROCEDURE cmsLCh2Lab(Lab: LPcmsCIELab; LCh: LPcmsCIELCh); StdCall; external 'lcms2.dll';
-PROCEDURE cmsLabEncoded2Float(Lab: LPcmsCIELab; wLab: Pointer); StdCall; external 'lcms2.dll';
-PROCEDURE cmsLabEncoded2FloatV2(Lab: LPcmsCIELab; wLab: Pointer); StdCall; external 'lcms2.dll';
-PROCEDURE cmsFloat2LabEncoded(wLab: Pointer; Lab: LPcmsCIELab); StdCall; external 'lcms2.dll';
-PROCEDURE cmsFloat2LabEncodedV2(wLab: Pointer; Lab: LPcmsCIELab); StdCall; external 'lcms2.dll';
-PROCEDURE cmsXYZEncoded2Float(fxyz : LPcmsCIEXYZ; XYZ: Pointer); StdCall; external 'lcms2.dll';
-PROCEDURE cmsFloat2XYZEncoded(XYZ: Pointer; fXYZ: LPcmsCIEXYZ); StdCall; external 'lcms2.dll';
-FUNCTION cmsDeltaE(Lab1, Lab2: LPcmsCIELab): Double; StdCall; external 'lcms2.dll';
-FUNCTION cmsCIE94DeltaE(Lab1, Lab2: LPcmsCIELab): Double; StdCall; external 'lcms2.dll';
-FUNCTION cmsBFDdeltaE(Lab1, Lab2: LPcmsCIELab): Double; StdCall; external 'lcms2.dll';
-FUNCTION cmsCMCdeltaE(Lab1, Lab2: LPcmsCIELab): Double; StdCall; external 'lcms2.dll';
-FUNCTION cmsCIE2000DeltaE(Lab1, Lab2: LPcmsCIELab; Kl, Kc, Kh: Double): Double; StdCall; external 'lcms2.dll';
-FUNCTION cmsWhitePointFromTemp(var WhitePoint: cmsCIExyY; TempK: cmsFloat64Number) : cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsTempFromWhitePoint(var TeampK: cmsFloat64Number; var WhitePoint: cmsCIExyY) : cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsAdaptToIlluminant(Result: LPcmsCIEXYZ; SourceWhitePt: LPcmsCIEXYZ;
- Illuminant: LPcmsCIEXYZ; Value: LPcmsCIEXYZ): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsCIECAM02Init(pVC : LPcmsViewingConditions ) : Pointer; StdCall; external 'lcms2.dll';
-PROCEDURE cmsCIECAM02Done(hModel : Pointer); StdCall; external 'lcms2.dll';
-PROCEDURE cmsCIECAM02Forward(hModel: Pointer; pIn: LPcmsCIEXYZ; pOut: LPcmsJCh ); StdCall; external 'lcms2.dll';
-PROCEDURE cmsCIECAM02Reverse(hModel: Pointer; pIn: LPcmsJCh; pOut: LPcmsCIEXYZ ); StdCall; external 'lcms2.dll';
-FUNCTION cmsBuildSegmentedToneCurve(ContextID: cmsContext; nSegments: cmsInt32Number; Segments: LPcmsCurveSegmentArray): LPcmsToneCurve; StdCall; external 'lcms2.dll';
-FUNCTION cmsBuildParametricToneCurve(ContextID: cmsContext; CType: cmsInt32Number; Params: LPcmsFloat64NumberArray): LPcmsToneCurve; StdCall; external 'lcms2.dll';
-FUNCTION cmsBuildGamma(ContextID: cmsContext; Gamma: cmsFloat64Number): LPcmsToneCurve; StdCall; external 'lcms2.dll';
-FUNCTION cmsBuildTabulatedToneCurve16(ContextID: cmsContext; nEntries: cmsInt32Number; values: LPcmsUInt16NumberArray): LPcmsToneCurve; StdCall; external 'lcms2.dll';
-FUNCTION cmsBuildTabulatedToneCurveFloat(ContextID: cmsContext; nEntries: cmsUInt32Number; values: LPcmsFloat32NumberArray): LPcmsToneCurve; StdCall; external 'lcms2.dll';
-PROCEDURE cmsFreeToneCurve(Curve: LPcmsToneCurve); StdCall; external 'lcms2.dll';
-PROCEDURE cmsFreeToneCurveTriple(Curve: LPLPcmsToneCurveArray); StdCall; external 'lcms2.dll';
-FUNCTION cmsDupToneCurve(Src: LPcmsToneCurve): LPcmsToneCurve; StdCall; external 'lcms2.dll';
-FUNCTION cmsReverseToneCurve(InGamma: LPcmsToneCurve): LPcmsToneCurve; StdCall; external 'lcms2.dll';
-FUNCTION cmsReverseToneCurveEx(nResultSamples: cmsInt32Number; InGamma: LPcmsToneCurve): LPcmsToneCurve; StdCall; external 'lcms2.dll';
-FUNCTION cmsJoinToneCurve(ContextID: cmsContext; X, Y: LPcmsToneCurve; nPoints: cmsUInt32Number ): LPcmsToneCurve; StdCall; external 'lcms2.dll';
-FUNCTION cmsSmoothToneCurve(Tab: LPcmsToneCurve; lambda: cmsFloat64Number): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsEvalToneCurveFloat(Curve: LPcmsToneCurve; v: cmsFloat32Number):cmsFloat32Number; StdCall; external 'lcms2.dll';
-FUNCTION cmsEvalToneCurve16(Curve: LPcmsToneCurve; v:cmsUInt16Number):cmsUInt16Number; StdCall; external 'lcms2.dll';
-FUNCTION cmsIsToneCurveMultisegment(InGamma: LPcmsToneCurve):cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsIsToneCurveLinear(Curve: LPcmsToneCurve):cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsIsToneCurveMonotonic(t: LPcmsToneCurve):cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsIsToneCurveDescending(t: LPcmsToneCurve):cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsGetToneCurveParametricType(t: LPcmsToneCurve):cmsInt32Number; StdCall; external 'lcms2.dll';
-FUNCTION cmsEstimateGamma(t: LPcmsToneCurve; Precision:cmsFloat64Number):cmsFloat64Number; StdCall; external 'lcms2.dll';
-FUNCTION cmsPipelineAlloc(ContextID: cmsContext; InputChannels, OutputChannels: cmsUInt32Number): LPcmsPipeline; StdCall; external 'lcms2.dll';
-PROCEDURE cmsPipelineFree(lut: LPcmsPipeline); StdCall; external 'lcms2.dll';
-FUNCTION cmsPipelineDup(Orig: LPcmsPipeline): LPcmsPipeline; StdCall; external 'lcms2.dll';
-FUNCTION cmsPipelineInputChannels(lut: LPcmsPipeline): cmsUInt32Number; StdCall; external 'lcms2.dll';
-FUNCTION cmsPipelineOutputChannels(lut: LPcmsPipeline): cmsUInt32Number; StdCall; external 'lcms2.dll';
-FUNCTION cmsPipelineStageCount(lut: LPcmsPipeline): cmsUInt32Number; StdCall; external 'lcms2.dll';
-FUNCTION cmsPipelineGetPtrToFirstStage(lut: LPcmsPipeline): LPcmsStage; StdCall; external 'lcms2.dll';
-FUNCTION cmsPipelineGetPtrToLastStage(lut: LPcmsPipeline): LPcmsStage; StdCall; external 'lcms2.dll';
-
-PROCEDURE cmsPipelineEval16(Inv, Outv: LPcmsUInt16NumberArray; lut: LPcmsPipeline); StdCall; external 'lcms2.dll';
-PROCEDURE cmsPipelineEvalFloat(Inv, Outv: LPcmsFloat32NumberArray; lut: LPcmsPipeline); StdCall; external 'lcms2.dll';
-
-FUNCTION cmsPipelineEvalReverseFloat(Target, Result, Hint: LPcmsFloat32NumberArray; lut: LPcmsPipeline): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsPipelineCat(l1, l2: LPcmsPipeline): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsPipelineSetSaveAs8bitsFlag(lut: LPcmsPipeline; On: cmsBool): cmsBool; StdCall; external 'lcms2.dll';
-PROCEDURE cmsPipelineInsertStage(lut: LPcmsPipeline; loc: cmsStageLoc; mpe: LPcmsStage); StdCall; external 'lcms2.dll';
-PROCEDURE cmsPipelineUnlinkStage(lut: LPcmsPipeline; loc: cmsStageLoc; mpe: LPLPcmsStage); StdCall; external 'lcms2.dll';
-FUNCTION cmsStageAllocIdentity(ContextID: cmsContext; nChannels: cmsUInt32Number): LPcmsStage; StdCall; external 'lcms2.dll';
-FUNCTION cmsStageAllocToneCurves(ContextID: cmsContext; nChannels: cmsUInt32Number; Curves: LPLPcmsToneCurveArray): LPcmsStage; StdCall; external 'lcms2.dll';
-FUNCTION cmsStageAllocMatrix(ContextID: cmsContext; Rows, Cols: cmsUInt32Number; Matrix, Offset: LPcmsFloat64NumberArray): LPcmsStage; StdCall; external 'lcms2.dll';
-FUNCTION cmsStageAllocCLut16bit(ContextID: cmsContext; nGridPoints: cmsUInt32Number; inputChan, outputChan: cmsUInt32Number; Table: LPcmsUInt16NumberArray): LPcmsStage; StdCall; external 'lcms2.dll';
-FUNCTION cmsStageAllocCLutFloat(ContextID: cmsContext; nGridPoints: cmsUInt32Number; inputChan, outputChan: cmsUInt32Number; Table: LPcmsFloat32NumberArray): LPcmsStage; StdCall; external 'lcms2.dll';
-FUNCTION cmsStageAllocCLut16bitGranular(ContextID: cmsContext; nGridPoints: LPcmsUInt32NumberArray; inputChan, outputChan: cmsUInt32Number; Table: LPcmsUInt16NumberArray): LPcmsStage; StdCall; external 'lcms2.dll';
-FUNCTION cmsStageAllocCLutFloatGranular(ContextID: cmsContext; nGridPoints: LPcmsUInt32NumberArray; inputChan, outputChan: cmsUInt32Number; Table: LPcmsFloat32NumberArray): LPcmsStage; StdCall; external 'lcms2.dll';
-FUNCTION cmsStageDup(mpe: LPcmsStage): LPcmsStage; StdCall; external 'lcms2.dll';
-PROCEDURE cmsStageFree(mpe: LPcmsStage); StdCall; external 'lcms2.dll';
-FUNCTION cmsStageNext(mpe: LPcmsStage): LPcmsStage; StdCall; external 'lcms2.dll';
-FUNCTION cmsStageInputChannels(mpe: LPcmsStage): cmsUInt32Number; StdCall; external 'lcms2.dll';
-FUNCTION cmsStageOutputChannels(mpe: LPcmsStage): cmsUInt32Number; StdCall; external 'lcms2.dll';
-FUNCTION cmsStageType(mpe: LPcmsStage): cmsStageSignature; StdCall; external 'lcms2.dll';
-FUNCTION cmsStageData(mpe: LPcmsStage): Pointer; StdCall; external 'lcms2.dll';
-FUNCTION cmsStageSampleCLut16bit(mpe: LPcmsStage; Sampler: cmsSAMPLER16; Cargo: Pointer; dwFlags: cmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsStageSampleCLutFloat(mpe: LPcmsStage; Sampler: cmsSAMPLERFLOAT; Cargo: Pointer; dwFlags: cmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsSliceSpace16(nInputs: cmsUInt32Number; clutPoints: LPcmsUInt32NumberArray;
- Sampler: cmsSAMPLER16; Cargo: Pointer): cmsBool; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsSliceSpaceFloat(nInputs: cmsUInt32Number; clutPoints: LPcmsUInt32NumberArray;
- Sampler: cmsSAMPLERFLOAT; Cargo: Pointer): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsMLUalloc(ContextID: cmsContext; nItems: cmsUInt32Number): LPcmsMLU; StdCall; external 'lcms2.dll';
-PROCEDURE cmsMLUfree(mlu: LPcmsMLU); StdCall; external 'lcms2.dll';
-FUNCTION cmsMLUdup(mlu: LPcmsMLU): LPcmsMLU; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsMLUsetASCII(mlu: LPcmsMLU; LanguageCode, CountryCode, ASCIIString: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsMLUsetWide(mlu: LPcmsMLU; LanguageCode, CountryCode: PAnsiChar; WideString: PWChar): cmsBool; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsMLUgetASCII(mlu: LPcmsMLU; LanguageCode, CountryCode: PAnsiChar; Buffer: PAnsiChar; BufferSize: cmsUInt32Number): cmsUInt32Number; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsMLUgetWide(mlu: LPcmsMLU; LanguageCode, CountryCode: PAnsiChar; Buffer: PWChar; BufferSize: cmsUInt32Number): cmsUInt32Number; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsMLUgetTranslation(mlu: LPcmsMLU; LanguageCode, CountryCode, ObtainedLanguage, ObtainedCountry: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsAllocNamedColorList(ContextID: cmsContext; n, ColorantCount :cmsUInt32Number;
- Prefix, Suffix: PAnsiChar): LPcmsNAMEDCOLORLIST; StdCall; external 'lcms2.dll';
-
-PROCEDURE cmsFreeNamedColorList(v: LPcmsNAMEDCOLORLIST); StdCall; external 'lcms2.dll';
-FUNCTION cmsDupNamedColorList(v: LPcmsNAMEDCOLORLIST): LPcmsNAMEDCOLORLIST; StdCall; external 'lcms2.dll';
-FUNCTION cmsAppendNamedColor(v: LPcmsNAMEDCOLORLIST; Name: PAnsiChar;
- PCS, Colorant : LPcmsUInt16NumberArray): cmsBool; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsNamedColorCount(v: LPcmsNAMEDCOLORLIST): cmsUInt32Number; StdCall; external 'lcms2.dll';
-FUNCTION cmsNamedColorIndex(v: LPcmsNAMEDCOLORLIST; Name: PAnsiChar): cmsInt32Number; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsNamedColorInfo(v: LPcmsNAMEDCOLORLIST; nColor : cmsUInt32Number;
- Name,Prefix, Suffix : PAnsiChar;
- PCS, Colorant : LPcmsUInt16NumberArray): cmsBool; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsGetNamedColorList(xform: cmsHTRANSFORM ): LPcmsNAMEDCOLORLIST; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsAllocProfileSequenceDescription(ContextID: cmsContext; n: cmsUInt32Number):LPcmsSEQ; StdCall; external 'lcms2.dll';
-FUNCTION cmsDupProfileSequenceDescription(pseq: LPcmsSEQ):LPcmsSEQ; StdCall; external 'lcms2.dll';
-PROCEDURE cmsFreeProfileSequenceDescription(pseq: LPcmsSEQ); StdCall; external 'lcms2.dll';
-
-FUNCTION cmsDictAlloc(ContextID: cmsContext): cmsHANDLE; StdCall; external 'lcms2.dll';
-PROCEDURE cmsDictFree(hDict: cmsHANDLE); StdCall; external 'lcms2.dll';
-FUNCTION cmsDictDup(hDict: cmsHANDLE): cmsHANDLE; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsDictAddEntry(hDict: cmsHANDLE; Name, Value: PWChar; DisplayName, DisplayValue : LPcmsMLU): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsDictGetEntryList(hDict: cmsHANDLE): LPcmsDICTentry; StdCall; external 'lcms2.dll';
-FUNCTION cmsDictNextEntry(e : LPcmsDICTentry): LPcmsDICTentry; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsCreateProfilePlaceholder(ContextID: cmsContext): cmsHPROFILE; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsGetProfileContextID(hProfile: cmsHPROFILE):cmsContext; StdCall; external 'lcms2.dll';
-FUNCTION cmsGetTagCount(hProfile: cmsHPROFILE): cmsInt32Number; StdCall; external 'lcms2.dll';
-FUNCTION cmsGetTagSignature(hProfile: cmsHPROFILE; n: cmsUInt32Number): cmsTagSignature; StdCall; external 'lcms2.dll';
-FUNCTION cmsIsTag(hProfile: cmsHPROFILE; sig: cmsTagSignature ): cmsBool; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsReadTag(hProfile: cmsHPROFILE; sig: cmsTagSignature ): Pointer; StdCall; external 'lcms2.dll';
-FUNCTION cmsWriteTag(hProfile: cmsHPROFILE; sig: cmsTagSignature; data: Pointer): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsLinkTag(hProfile: cmsHPROFILE; sig: cmsTagSignature; dest: cmsTagSignature): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsTagLinkedTo(hProfile: cmsHPROFILE; sig: cmsTagSignature):cmsTagSignature; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsReadRawTag(hProfile: cmsHPROFILE; sig: cmsTagSignature; Buffer: Pointer; BufferSize: cmsUInt32Number): cmsInt32Number; StdCall; external 'lcms2.dll';
-FUNCTION cmsWriteRawTag(hProfile: cmsHPROFILE; sig: cmsTagSignature; data: Pointer; Size: cmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsGetHeaderFlags(hProfile: cmsHPROFILE): cmsUInt32Number; StdCall; external 'lcms2.dll';
-PROCEDURE cmsGetHeaderAttributes(hProfile: cmsHPROFILE; Flags: LPcmsUInt64Number); StdCall; external 'lcms2.dll';
-PROCEDURE cmsGetHeaderProfileID(hProfile: cmsHPROFILE; ProfileID: LPcmsUInt8Number); StdCall; external 'lcms2.dll';
-
-FUNCTION cmsGetHeaderRenderingIntent(hProfile: cmsHPROFILE): cmsUInt32Number; StdCall; external 'lcms2.dll';
-PROCEDURE cmsSetHeaderFlags(hProfile: cmsHPROFILE; Flags: cmsUInt32Number); StdCall; external 'lcms2.dll';
-FUNCTION cmsGetHeaderManufacturer(hProfile: cmsHPROFILE): cmsUInt32Number; StdCall; external 'lcms2.dll';
-PROCEDURE cmsSetHeaderManufacturer(hProfile: cmsHPROFILE; manufacturer: cmsUInt32Number ); StdCall; external 'lcms2.dll';
-FUNCTION cmsGetHeaderModel(hProfile: cmsHPROFILE): cmsUInt32Number; StdCall; external 'lcms2.dll';
-PROCEDURE cmsSetHeaderModel(hProfile: cmsHPROFILE; model: cmsUInt32Number ); StdCall; external 'lcms2.dll';
-PROCEDURE cmsSetHeaderAttributes(hProfile: cmsHPROFILE; Flags: cmsUInt64Number); StdCall; external 'lcms2.dll';
-PROCEDURE cmsSetHeaderProfileID(hProfile: cmsHPROFILE; ProfileID: LPcmsUInt8Number); StdCall; external 'lcms2.dll';
-PROCEDURE cmsSetHeaderRenderingIntent(hProfile: cmsHPROFILE; RenderingIntent: cmsUInt32Number ); StdCall; external 'lcms2.dll';
-
-FUNCTION cmsGetPCS(hProfile: cmsHPROFILE):cmsColorSpaceSignature; StdCall; external 'lcms2.dll';
-PROCEDURE cmsSetPCS(hProfile: cmsHPROFILE; pcs: cmsColorSpaceSignature); StdCall; external 'lcms2.dll';
-FUNCTION cmsGetColorSpace(hProfile: cmsHPROFILE): cmsColorSpaceSignature; StdCall; external 'lcms2.dll';
-PROCEDURE cmsSetColorSpace(hProfile: cmsHPROFILE; sig: cmsColorSpaceSignature); StdCall; external 'lcms2.dll';
-FUNCTION cmsGetDeviceClass(hProfile: cmsHPROFILE): cmsProfileClassSignature; StdCall; external 'lcms2.dll';
-PROCEDURE cmsSetDeviceClass(hProfile: cmsHPROFILE; sig: cmsProfileClassSignature); StdCall; external 'lcms2.dll';
-PROCEDURE cmsSetProfileVersion(hProfile: cmsHPROFILE; Version: cmsFloat64Number); StdCall; external 'lcms2.dll';
-FUNCTION cmsGetProfileVersion(hProfile: cmsHPROFILE): cmsFloat64Number; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsGetEncodedICCversion(hProfile: cmsHPROFILE): cmsUInt32Number; StdCall; external 'lcms2.dll';
-PROCEDURE cmsSetEncodedICCversion(hProfile: cmsHPROFILE; Version: cmsUInt32Number); StdCall; external 'lcms2.dll';
-
-
-FUNCTION cmsIsIntentSupported(hProfile: cmsHPROFILE; Intent: cmsUInt32Number; UsedDirection: cmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsIsMatrixShaper(hProfile: cmsHPROFILE): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsIsCLUT(hProfile: cmsHPROFILE; Intent: cmsUInt32Number; UsedDirection: cmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION _cmsICCcolorSpace(OurNotation: Integer): cmsColorSpaceSignature; StdCall; external 'lcms2.dll';
-FUNCTION _cmsLCMScolorSpace(ProfileSpace: cmsColorSpaceSignature): Integer; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsChannelsOf( ColorSpace: cmsColorSpaceSignature): cmsUInt32Number; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsFormatterForColorspaceOfProfile(hProfile: cmsHPROFILE; nBytes: cmsUInt32Number; lIsFloat: cmsBool): cmsUInt32Number; StdCall; external 'lcms2.dll';
-FUNCTION cmsFormatterForPCSOfProfile(hProfile: cmsHPROFILE; nBytes: cmsUInt32Number; lIsFloat: cmsBool): cmsUInt32Number; StdCall; external 'lcms2.dll';
-
-
-FUNCTION cmsGetProfileInfo(hProfile: cmsHPROFILE; Info: cmsInfoType; LanguageCode, CountryCode: PAnsiChar;
- Buffer: PWChar; BufferSize: cmsUInt32Number): cmsUInt32Number; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsGetProfileInfoASCII(hProfile: cmsHPROFILE; Info: cmsInfoType; LanguageCode, CountryCode: PAnsiChar;
- Buffer: PAnsiChar; BufferSize: cmsUInt32Number): cmsUInt32Number; StdCall; external 'lcms2.dll';
-
-
-FUNCTION cmsOpenIOhandlerFromFile(ContextID: cmsContext; FileName, AccessMode: PAnsiChar): LPcmsIOHANDLER; StdCall; external 'lcms2.dll';
-// FUNCTION cmsOpenIOhandlerFromStream(ContextID: cmsContext; FILE* Stream): LPcmsIOHANDLER; StdCall; external 'lcms2.dll';
-FUNCTION cmsOpenIOhandlerFromMem(ContextID: cmsContext; Buffer: Pointer; size: cmsUInt32Number; AccessMode: PAnsiChar): LPcmsIOHANDLER; StdCall; external 'lcms2.dll';
-FUNCTION cmsOpenIOhandlerFromNULL(ContextID: cmsContext): LPcmsIOHANDLER; StdCall; external 'lcms2.dll';
-FUNCTION cmsCloseIOhandler(io: LPcmsIOHANDLER): cmsBool; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsMD5computeID(hProfile: cmsHPROFILE): cmsBool; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsOpenProfileFromFile(ICCProfile : PAnsiChar; sAccess: PAnsiChar): cmsHPROFILE; StdCall; external 'lcms2.dll';
-FUNCTION cmsOpenProfileFromFileTHR(ContextID: cmsContext; ICCProfile, sAccess: PAnsiChar): cmsHPROFILE; StdCall; external 'lcms2.dll';
-// FUNCTION CMSEXPORT cmsOpenProfileFromStream(FILE* ICCProfile, const char* sAccess): cmsHPROFILE; StdCall; external 'lcms2.dll';
-// FUNCTION CMSEXPORT cmsOpenProfileFromStreamTHR(ContextID: cmsContext; FILE* ICCProfile, const char* sAccess): cmsHPROFILE; StdCall; external 'lcms2.dll';
-FUNCTION cmsOpenProfileFromMem(MemPtr: Pointer; dwSize: cmsUInt32Number): cmsHPROFILE; StdCall; external 'lcms2.dll';
-FUNCTION cmsOpenProfileFromMemTHR(ContextID: cmsContext; MemPtr: Pointer; dwSize: cmsUInt32Number): cmsHPROFILE; StdCall; external 'lcms2.dll';
-FUNCTION cmsOpenProfileFromIOhandlerTHR(ContextID: cmsContext; io: LPcmsIOHANDLER): cmsHPROFILE; StdCall; external 'lcms2.dll';
-FUNCTION cmsCloseProfile(hProfile: cmsHPROFILE): cmsBool; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsSaveProfileToFile(hProfile: cmsHPROFILE; FileName: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
-// FUNCTION CMSEXPORT cmsSaveProfileToStream(hProfile: cmsHPROFILE, FILE* Stream): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsSaveProfileToMem(hProfile: cmsHPROFILE; MemPtr: Pointer; BytesNeeded: LPcmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsSaveProfileToIOhandler(hProfile: cmsHPROFILE; io: LPcmsIOHANDLER):cmsUInt32Number; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsCreateRGBProfileTHR(ContextID: cmsContext;
- WhitePoint: LPcmsCIExyY;
- Primaries: LPcmsCIExyYTRIPLE;
- TransferFunction: LPLPcmsToneCurveArray): cmsHPROFILE; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsCreateRGBProfile(WhitePoint: LPcmsCIExyY;
- Primaries: LPcmsCIExyYTRIPLE;
- TransferFunction: LPLPcmsToneCurveArray): cmsHPROFILE; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsCreateGrayProfileTHR(ContextID: cmsContext;
- WhitePoint: LPcmsCIExyY;
- TransferFunction: LPcmsToneCurve): cmsHPROFILE; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsCreateGrayProfile(WhitePoint: LPcmsCIExyY;
- TransferFunction: LPcmsToneCurve): cmsHPROFILE; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsCreateLinearizationDeviceLinkTHR(ContextID: cmsContext;
- ColorSpace: cmsColorSpaceSignature;
- TransferFunctions: LPLPcmsToneCurveArray): cmsHPROFILE; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsCreateLinearizationDeviceLink(ColorSpace: cmsColorSpaceSignature;
- TransferFunctions: LPLPcmsToneCurveArray): cmsHPROFILE; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsCreateInkLimitingDeviceLinkTHR(ContextID: cmsContext;
- ColorSpace: cmsColorSpaceSignature; Limit: cmsFloat64Number): cmsHPROFILE; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsCreateInkLimitingDeviceLink(ColorSpace: cmsColorSpaceSignature; Limit: cmsFloat64Number): cmsHPROFILE; StdCall; external 'lcms2.dll';
-
-
-FUNCTION cmsCreateLab2ProfileTHR(ContextID: cmsContext; WhitePoint: LPcmsCIExyY): cmsHPROFILE; StdCall; external 'lcms2.dll';
-FUNCTION cmsCreateLab2Profile(WhitePoint: LPcmsCIExyY): cmsHPROFILE; StdCall; external 'lcms2.dll';
-FUNCTION cmsCreateLab4ProfileTHR(ContextID: cmsContext; WhitePoint: LPcmsCIExyY): cmsHPROFILE; StdCall; external 'lcms2.dll';
-FUNCTION cmsCreateLab4Profile(WhitePoint: LPcmsCIExyY): cmsHPROFILE; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsCreateXYZProfileTHR(ContextID: cmsContext): cmsHPROFILE; StdCall; external 'lcms2.dll';
-FUNCTION cmsCreateXYZProfile: cmsHPROFILE; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsCreate_sRGBProfileTHR(ContextID: cmsContext): cmsHPROFILE; StdCall; external 'lcms2.dll';
-FUNCTION cmsCreate_sRGBProfile: cmsHPROFILE; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsCreateBCHSWabstractProfileTHR(ContextID: cmsContext;
- nLUTPoints: Integer;
- Bright,
- Contrast,
- Hue,
- Saturation: cmsFloat64Number;
- TempSrc,
- TempDest: Integer): cmsHPROFILE; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsCreateBCHSWabstractProfile( nLUTPoints: Integer;
- Bright,
- Contrast,
- Hue,
- Saturation: cmsFloat64Number;
- TempSrc,
- TempDest: Integer): cmsHPROFILE; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsCreateNULLProfileTHR(ContextID: cmsContext): cmsHPROFILE; StdCall; external 'lcms2.dll';
-FUNCTION cmsCreateNULLProfile: cmsHPROFILE; StdCall; external 'lcms2.dll';
-
-// Converts a transform to a devicelink profile
-FUNCTION cmsTransform2DeviceLink(hTransform: cmsHTRANSFORM; Version: cmsFloat64Number; dwFlags: cmsUInt32Number): cmsHPROFILE; StdCall; external 'lcms2.dll';
-
-// Call with NULL as parameters to get the intent count
-FUNCTION cmsGetSupportedIntents(nMax: cmsUInt32Number; Codes: LPcmsUInt32Number; Descriptions: LPPAnsiChar): cmsUInt32Number; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsFLAGS_GRIDPOINTS(n: Integer): Integer; begin cmsFLAGS_GRIDPOINTS := (((n) and $FF) shl 16) end;
-
-
-FUNCTION cmsCreateTransformTHR(ContextID: cmsContext;
- Input: cmsHPROFILE;
- InputFormat: cmsUInt32Number;
- Output: cmsHPROFILE;
- OutputFormat: cmsUInt32Number;
- Intent: cmsUInt32Number;
- dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsCreateTransform(Input: cmsHPROFILE;
- InputFormat: cmsUInt32Number;
- Output: cmsHPROFILE;
- OutputFormat: cmsUInt32Number;
- Intent: cmsUInt32Number;
- dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsCreateProofingTransformTHR(ContextID: cmsContext;
- Input: cmsHPROFILE;
- InputFormat: cmsUInt32Number;
- Output: cmsHPROFILE;
- OutputFormat: cmsUInt32Number;
- Proofing: cmsHPROFILE;
- Intent: cmsUInt32Number;
- ProofingIntent: cmsUInt32Number;
- dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsCreateProofingTransform(Input: cmsHPROFILE;
- InputFormat: cmsUInt32Number;
- Output: cmsHPROFILE;
- OutputFormat: cmsUInt32Number;
- Proofing: cmsHPROFILE;
- Intent: cmsUInt32Number;
- ProofingIntent: cmsUInt32Number;
- dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsCreateMultiprofileTransformTHR(ContextID: cmsContext;
- hProfiles: LPcmsHPROFILEArray;
- nProfiles: cmsUInt32Number;
- InputFormat: cmsUInt32Number;
- OutputFormat: cmsUInt32Number;
- Intent: cmsUInt32Number;
- dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall; external 'lcms2.dll';
-
-
-FUNCTION cmsCreateMultiprofileTransform( hProfiles: LPcmsHPROFILEArray;
- nProfiles: cmsUInt32Number;
- InputFormat: cmsUInt32Number;
- OutputFormat: cmsUInt32Number;
- Intent: cmsUInt32Number;
- dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall; external 'lcms2.dll';
-
-
-FUNCTION cmsCreateExtendedTransform(ContextID: cmsContext;
- nProfiles: cmsUInt32Number;
- hProfiles: LPcmsHPROFILEArray;
- BPC: LPcmsBoolArray;
- Intents: LPcmsUInt32NumberArray;
- AdaptationStates: LPcmsFloat64NumberArray;
- hGamutProfile: cmsHPROFILE;
- nGamutPCSposition: cmsUInt32Number;
- InputFormat,
- OutputFormat: cmsUInt32Number;
- dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall; external 'lcms2.dll';
-
-PROCEDURE cmsDeleteTransform(hTransform: cmsHTRANSFORM); StdCall; external 'lcms2.dll';
-
-PROCEDURE cmsDoTransform(Transform: cmsHTRANSFORM; InputBuffer, OutputBuffer: Pointer; size: cmsUInt32Number); StdCall; external 'lcms2.dll';
-
-PROCEDURE cmsSetAlarmCodes( NewAlarm: LPcmsUInt16NumberArray); StdCall; external 'lcms2.dll';
-PROCEDURE cmsGetAlarmCodes(NewAlarm: LPcmsUInt16NumberArray); StdCall; external 'lcms2.dll';
-
-// Adaptation state for absolute colorimetric intent
-FUNCTION cmsSetAdaptationState(d: cmsFloat64Number):cmsFloat64Number; StdCall; external 'lcms2.dll';
-
-// Grab the ContextID from an open transform. Returns NULL if a NULL transform is passed
-FUNCTION cmsGetTransformContextID(hTransform: cmsHTRANSFORM):cmsContext; StdCall; external 'lcms2.dll';
-
-// For backwards compatibility
-FUNCTION cmsChangeBuffersFormat(hTransform: cmsHTRANSFORM; InputFormat, OutputFormat: cmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
-
-
-// lcms2 unified method to access postscript color resources
-FUNCTION cmsGetPostScriptColorResource(ContextID: cmsContext; RType: cmsPSResourceType;
- hProfile: cmsHPROFILE;
- Intent: cmsUInt32Number;
- dwFlags: cmsUInt32Number;
- io: LPcmsIOHANDLER): cmsUInt32Number; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsGetPostScriptCSA(ContextID: cmsContext; hProfile: cmsHPROFILE; Intent: cmsUInt32Number; dwFlags: cmsUInt32Number; Buffer: Pointer; dwBufferLen: cmsUInt32Number ): cmsUInt32Number; StdCall; external 'lcms2.dll';
-FUNCTION cmsGetPostScriptCRD(ContextID: cmsContext; hProfile: cmsHPROFILE; Intent: cmsUInt32Number; dwFlags: cmsUInt32Number; Buffer: Pointer; dwBufferLen: cmsUInt32Number): cmsUInt32Number; StdCall; external 'lcms2.dll';
-
-
-// CGATS.13 parser
-
-FUNCTION cmsIT8Alloc: cmsHANDLE; StdCall; external 'lcms2.dll';
-PROCEDURE cmsIT8Free(hIT8: cmsHANDLE); StdCall; external 'lcms2.dll';
-
-// Tables
-
-FUNCTION cmsIT8TableCount(hIT8: cmsHANDLE): Integer; StdCall; external 'lcms2.dll';
-FUNCTION cmsIT8SetTable(hIT8: cmsHANDLE; nTable: Integer): Integer; StdCall; external 'lcms2.dll';
-
-// Persistence
-FUNCTION cmsIT8LoadFromFile(cFileName: PAnsiChar): cmsHANDLE; StdCall; external 'lcms2.dll';
-FUNCTION cmsIT8LoadFromMem(Ptr: Pointer; size :DWord): cmsHANDLE; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsIT8SaveToFile(hIT8: cmsHANDLE; cFileName: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsIT8SaveToMem(hIT8: cmsHANDLE; MemPtr: Pointer; BytesNeeded: LPcmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
-// Properties
-
-FUNCTION cmsIT8GetSheetType(hIT8: cmsHANDLE): PAnsiChar; StdCall; external 'lcms2.dll';
-FUNCTION cmsIT8SetSheetType(hIT8: cmsHANDLE; TheType: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsIT8SetComment(hIT8: cmsHANDLE; cComment: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsIT8SetPropertyStr(hIT8: cmsHANDLE; cProp, Str: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsIT8SetPropertyDbl(hIT8: cmsHANDLE; cProp: PAnsiChar; Val: Double): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsIT8SetPropertyHex(hIT8: cmsHANDLE; cProp: PAnsiChar; Val: Integer): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsIT8SetPropertyUncooked(hIT8: cmsHANDLE; Key, Buffer: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
-
-
-FUNCTION cmsIT8GetProperty(hIT8: cmsHANDLE; cProp: PAnsiChar): PAnsiChar; StdCall; external 'lcms2.dll';
-FUNCTION cmsIT8GetPropertyDbl(hIT8: cmsHANDLE; cProp: PAnsiChar): Double; StdCall; external 'lcms2.dll';
-FUNCTION cmsIT8EnumProperties(hIT8: cmsHANDLE; var PropertyNames: LPPAnsiChar): Integer; StdCall; external 'lcms2.dll';
-
-// Datasets
-
-FUNCTION cmsIT8GetDataRowCol(hIT8: cmsHANDLE; row, col: Integer): PAnsiChar; StdCall; external 'lcms2.dll';
-FUNCTION cmsIT8GetDataRowColDbl(hIT8: cmsHANDLE; row, col: Integer): Double; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsIT8SetDataRowCol(hIT8: cmsHANDLE; row, col: Integer; Val: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsIT8SetDataRowColDbl(hIT8: cmsHANDLE; row, col: Integer; Val: Double): cmsBool; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsIT8GetData(hIT8: cmsHANDLE; cPatch, cSample: PAnsiChar): PAnsiChar; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsIT8GetDataDbl(hIT8: cmsHANDLE;cPatch, cSample: PAnsiChar): Double; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsIT8SetData(hIT8: cmsHANDLE; cPatch, cSample, Val: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsIT8SetDataDbl(hIT8: cmsHANDLE; cPatch, cSample: PAnsiChar; Val: Double): cmsBool; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsIT8SetDataFormat(hIT8: cmsHANDLE; n: Integer; Sample: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsIT8EnumDataFormat(hIT8: cmsHANDLE; var SampleNames: LPPAnsiChar): Integer; StdCall; external 'lcms2.dll';
-FUNCTION cmsIT8GetPatchName(hIT8: cmsHANDLE; nPatch: Integer; Buffer: PAnsiChar): PAnsiChar; StdCall; external 'lcms2.dll';
-
-// The LABEL extension
-
-FUNCTION cmsIT8SetTableByLabel(hIT8: cmsHANDLE; cSet, cField, ExpectedType: PAnsiChar): Integer; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsIT8FindDataFormat(hIT8: cmsHANDLE; cSample: PAnsiChar): Integer; StdCall; external 'lcms2.dll';
-
-// Formatter for double
-PROCEDURE cmsIT8DefineDblFormat(hIT8: cmsHANDLE; Formatter: PAnsiChar); StdCall; external 'lcms2.dll';
-
-FUNCTION cmsGBDAlloc(ContextID: cmsContext):cmsHANDLE; StdCall; external 'lcms2.dll';
-PROCEDURE cmsGBDFree(hGBD: cmsHANDLE); StdCall; external 'lcms2.dll';
-FUNCTION cmsGDBAddPoint(hGBD: cmsHANDLE; Lab: LPcmsCIELab): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsGDBCompute(hGDB: cmsHANDLE; dwFlags: cmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsGDBCheckPoint(hGBD: cmsHANDLE; Lab: LPcmsCIELab): cmsBool; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsDetectBlackPoint( BlackPoint: LPcmsCIEXYZ; hProfile: cmsHPROFILE; Intent: cmsUInt32Number; dwFlags: cmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
-FUNCTION cmsDetectDestinationBlackPoint( BlackPoint: LPcmsCIEXYZ; hProfile: cmsHPROFILE; Intent: cmsUInt32Number; dwFlags: cmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsDetectTAC(hProfile: cmsHPROFILE): cmsFloat64Number; StdCall; external 'lcms2.dll';
-
-FUNCTION cmsDesaturateLab(Lab: LPcmsCIELab; amax, amin, bmax, bmin: cmsFloat64Number): cmsBool; StdCall; external 'lcms2.dll';
-
-END.
+//
+// Little cms DELPHI wrapper
+//---------------------------------------------------------------------------------
+//
+// Little Color Management System
+// Copyright (c) 1998-2010 Marti Maria Saguer
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the Software
+// is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//---------------------------------------------------------------------------------
+//
+// Version 2.1
+//
+
+UNIT lcms2dll;
+
+INTERFACE
+
+USES Windows;
+
+ TYPE
+
+ Uint8 = Byte;
+ Int8 = Shortint;
+ UInt16 = Word;
+ Int16 = Smallint;
+ UInt32 = LongWord;
+ Int32 = Longint;
+
+ TYPE
+ cmsUInt8Number = Uint8;
+ cmsInt8Number = Int8;
+ cmsUInt16Number = UInt16;
+ cmsInt16Number = Int16;
+
+ cmsUInt32Number = UInt32;
+ cmsInt32Number = Int32;
+ cmsInt64Number = Int64;
+ cmsUInt64Number = UInt64;
+
+ cmsFloat32Number = Single;
+ cmsFloat64Number = Double;
+
+ LPcmsUInt8Number = ^cmsUInt8Number;
+ LPcmsInt8Number = ^cmsInt8Number;
+ LPcmsUInt16Number = ^cmsUInt16Number;
+ LPcmsInt16Number = ^cmsInt16Number;
+
+ LPcmsUInt32Number = ^cmsUInt32Number;
+ LPcmsInt32Number = ^cmsInt32Number;
+ LPcmsInt64Number = ^cmsInt64Number;
+ LPcmsUInt64Number = ^cmsUInt64Number;
+
+ LPcmsFloat32Number = ^cmsFloat32Number;
+ LPcmsFloat64Number = ^cmsFloat64Number;
+
+
+ // Derivative types
+ cmsSignature = cmsUInt32Number;
+ cmsU8Fixed8Number = cmsUInt16Number;
+ cmsS15Fixed16Number = cmsInt32Number;
+ cmsU16Fixed16Number = cmsUInt32Number;
+
+ // Boolean type, which will be using the native integer
+ cmsBool = Boolean;
+
+ CONST
+
+ // Some common definitions
+ cmsMAX_PATH = 256;
+
+ // D50 XYZ normalized to Y=1.0
+ cmsD50X = 0.9642;
+ cmsD50Y = 1.0;
+ cmsD50Z = 0.8249;
+
+ // V4 perceptual black
+ cmsPERCEPTUAL_BLACK_X = 0.00336;
+ cmsPERCEPTUAL_BLACK_Y = 0.0034731;
+ cmsPERCEPTUAL_BLACK_Z = 0.00287;
+
+ // Definitions in ICC spec
+ cmsMagicNumber = $61637370; // 'acsp'
+ lcmsSignature = $6c636d73; // 'lcms'
+
+
+TYPE
+
+// Base ICC type definitions
+cmsTagTypeSignature = (
+ cmsSigChromaticityType = $6368726D, // 'chrm'
+ cmsSigColorantOrderType = $636C726F, // 'clro'
+ cmsSigColorantTableType = $636C7274, // 'clrt'
+ cmsSigCrdInfoType = $63726469, // 'crdi'
+ cmsSigCurveType = $63757276, // 'curv'
+ cmsSigDataType = $64617461, // 'data'
+ cmsSigDictType = $64696374, // 'dict'
+ cmsSigDateTimeType = $6474696D, // 'dtim'
+ cmsSigDeviceSettingsType = $64657673, // 'devs'
+ cmsSigLut16Type = $6d667432, // 'mft2'
+ cmsSigLut8Type = $6d667431, // 'mft1'
+ cmsSigLutAtoBType = $6d414220, // 'mAB '
+ cmsSigLutBtoAType = $6d424120, // 'mBA '
+ cmsSigMeasurementType = $6D656173, // 'meas'
+ cmsSigMultiLocalizedUnicodeType = $6D6C7563, // 'mluc'
+ cmsSigMultiProcessElementType = $6D706574, // 'mpet'
+ cmsSigNamedColorType = $6E636f6C, // 'ncol' -- DEPRECATED!
+ cmsSigNamedColor2Type = $6E636C32, // 'ncl2'
+ cmsSigParametricCurveType = $70617261, // 'para'
+ cmsSigProfileSequenceDescType = $70736571, // 'pseq'
+ cmsSigProfileSequenceIdType = $70736964, // 'psid'
+ cmsSigResponseCurveSet16Type = $72637332, // 'rcs2'
+ cmsSigS15Fixed16ArrayType = $73663332, // 'sf32'
+ cmsSigScreeningType = $7363726E, // 'scrn'
+ cmsSigSignatureType = $73696720, // 'sig '
+ cmsSigTextType = $74657874, // 'text'
+ cmsSigTextDescriptionType = $64657363, // 'desc'
+ cmsSigU16Fixed16ArrayType = $75663332, // 'uf32'
+ cmsSigUcrBgType = $62666420, // 'bfd '
+ cmsSigUInt16ArrayType = $75693136, // 'ui16'
+ cmsSigUInt32ArrayType = $75693332, // 'ui32'
+ cmsSigUInt64ArrayType = $75693634, // 'ui64'
+ cmsSigUInt8ArrayType = $75693038, // 'ui08'
+ cmsSigViewingConditionsType = $76696577, // 'view'
+ cmsSigXYZType = $58595A20, // 'XYZ '
+ cmsSigVcgtType = $76636774 // 'vcgt'
+ );
+
+// Base ICC tag definitions
+cmsTagSignature = (
+ cmsSigAToB0Tag = $41324230, // 'A2B0'
+ cmsSigAToB1Tag = $41324231, // 'A2B1'
+ cmsSigAToB2Tag = $41324232, // 'A2B2'
+ cmsSigBlueColorantTag = $6258595A, // 'bXYZ'
+ cmsSigBlueMatrixColumnTag = $6258595A, // 'bXYZ'
+ cmsSigBlueTRCTag = $62545243, // 'bTRC'
+ cmsSigBToA0Tag = $42324130, // 'B2A0'
+ cmsSigBToA1Tag = $42324131, // 'B2A1'
+ cmsSigBToA2Tag = $42324132, // 'B2A2'
+ cmsSigCalibrationDateTimeTag = $63616C74, // 'calt'
+ cmsSigCharTargetTag = $74617267, // 'targ'
+ cmsSigChromaticAdaptationTag = $63686164, // 'chad'
+ cmsSigChromaticityTag = $6368726D, // 'chrm'
+ cmsSigColorantOrderTag = $636C726F, // 'clro'
+ cmsSigColorantTableTag = $636C7274, // 'clrt'
+ cmsSigColorantTableOutTag = $636C6F74, // 'clot'
+ cmsSigColorimetricIntentImageStateTag = $63696973, // 'ciis'
+ cmsSigCopyrightTag = $63707274, // 'cprt'
+ cmsSigCrdInfoTag = $63726469, // 'crdi'
+ cmsSigDataTag = $64617461, // 'data'
+ cmsSigDateTimeTag = $6474696D, // 'dtim'
+ cmsSigDeviceMfgDescTag = $646D6E64, // 'dmnd'
+ cmsSigDeviceModelDescTag = $646D6464, // 'dmdd'
+ cmsSigDeviceSettingsTag = $64657673, // 'devs'
+ cmsSigDToB0Tag = $44324230, // 'D2B0'
+ cmsSigDToB1Tag = $44324231, // 'D2B1'
+ cmsSigDToB2Tag = $44324232, // 'D2B2'
+ cmsSigDToB3Tag = $44324233, // 'D2B3'
+ cmsSigBToD0Tag = $42324430, // 'B2D0'
+ cmsSigBToD1Tag = $42324431, // 'B2D1'
+ cmsSigBToD2Tag = $42324432, // 'B2D2'
+ cmsSigBToD3Tag = $42324433, // 'B2D3'
+ cmsSigGamutTag = $67616D74, // 'gamt'
+ cmsSigGrayTRCTag = $6b545243, // 'kTRC'
+ cmsSigGreenColorantTag = $6758595A, // 'gXYZ'
+ cmsSigGreenMatrixColumnTag = $6758595A, // 'gXYZ'
+ cmsSigGreenTRCTag = $67545243, // 'gTRC'
+ cmsSigLuminanceTag = $6C756d69, // 'lumi'
+ cmsSigMeasurementTag = $6D656173, // 'meas'
+ cmsSigMediaBlackPointTag = $626B7074, // 'bkpt'
+ cmsSigMediaWhitePointTag = $77747074, // 'wtpt'
+ cmsSigNamedColorTag = $6E636f6C, // 'ncol' // Deprecated by the ICC
+ cmsSigNamedColor2Tag = $6E636C32, // 'ncl2'
+ cmsSigOutputResponseTag = $72657370, // 'resp'
+ cmsSigPerceptualRenderingIntentGamutTag = $72696730, // 'rig0'
+ cmsSigPreview0Tag = $70726530, // 'pre0'
+ cmsSigPreview1Tag = $70726531, // 'pre1'
+ cmsSigPreview2Tag = $70726532, // 'pre2'
+ cmsSigProfileDescriptionTag = $64657363, // 'desc'
+ cmsSigProfileSequenceDescTag = $70736571, // 'pseq'
+ cmsSigProfileSequenceIdTag = $70736964, // 'psid'
+ cmsSigPs2CRD0Tag = $70736430, // 'psd0'
+ cmsSigPs2CRD1Tag = $70736431, // 'psd1'
+ cmsSigPs2CRD2Tag = $70736432, // 'psd2'
+ cmsSigPs2CRD3Tag = $70736433, // 'psd3'
+ cmsSigPs2CSATag = $70733273, // 'ps2s'
+ cmsSigPs2RenderingIntentTag = $70733269, // 'ps2i'
+ cmsSigRedColorantTag = $7258595A, // 'rXYZ'
+ cmsSigRedMatrixColumnTag = $7258595A, // 'rXYZ'
+ cmsSigRedTRCTag = $72545243, // 'rTRC'
+ cmsSigSaturationRenderingIntentGamutTag = $72696732, // 'rig2'
+ cmsSigScreeningDescTag = $73637264, // 'scrd'
+ cmsSigScreeningTag = $7363726E, // 'scrn'
+ cmsSigTechnologyTag = $74656368, // 'tech'
+ cmsSigUcrBgTag = $62666420, // 'bfd '
+ cmsSigViewingCondDescTag = $76756564, // 'vued'
+ cmsSigViewingConditionsTag = $76696577, // 'view'
+ cmsSigVcgtTag = $76636774, // 'vcgt'
+ cmsSigMetaTag = $6D657461 // 'meta'
+);
+
+// ICC Technology tag
+cmsTechnologySignature = (
+ cmsSigDigitalCamera = $6463616D, // 'dcam'
+ cmsSigFilmScanner = $6673636E, // 'fscn'
+ cmsSigReflectiveScanner = $7273636E, // 'rscn'
+ cmsSigInkJetPrinter = $696A6574, // 'ijet'
+ cmsSigThermalWaxPrinter = $74776178, // 'twax'
+ cmsSigElectrophotographicPrinter = $6570686F, // 'epho'
+ cmsSigElectrostaticPrinter = $65737461, // 'esta'
+ cmsSigDyeSublimationPrinter = $64737562, // 'dsub'
+ cmsSigPhotographicPaperPrinter = $7270686F, // 'rpho'
+ cmsSigFilmWriter = $6670726E, // 'fprn'
+ cmsSigVideoMonitor = $7669646D, // 'vidm'
+ cmsSigVideoCamera = $76696463, // 'vidc'
+ cmsSigProjectionTelevision = $706A7476, // 'pjtv'
+ cmsSigCRTDisplay = $43525420, // 'CRT '
+ cmsSigPMDisplay = $504D4420, // 'PMD '
+ cmsSigAMDisplay = $414D4420, // 'AMD '
+ cmsSigPhotoCD = $4B504344, // 'KPCD'
+ cmsSigPhotoImageSetter = $696D6773, // 'imgs'
+ cmsSigGravure = $67726176, // 'grav'
+ cmsSigOffsetLithography = $6F666673, // 'offs'
+ cmsSigSilkscreen = $73696C6B, // 'silk'
+ cmsSigFlexography = $666C6578, // 'flex'
+ cmsSigMotionPictureFilmScanner = $6D706673, // 'mpfs'
+ cmsSigMotionPictureFilmRecorder = $6D706672, // 'mpfr'
+ cmsSigDigitalMotionPictureCamera = $646D7063, // 'dmpc'
+ cmsSigDigitalCinemaProjector = $64636A70 // 'dcpj'
+);
+
+
+// ICC Color spaces
+cmsColorSpaceSignature = (
+ cmsSigXYZData = $58595A20, // 'XYZ '
+ cmsSigLabData = $4C616220, // 'Lab '
+ cmsSigLuvData = $4C757620, // 'Luv '
+ cmsSigYCbCrData = $59436272, // 'YCbr'
+ cmsSigYxyData = $59787920, // 'Yxy '
+ cmsSigRgbData = $52474220, // 'RGB '
+ cmsSigGrayData = $47524159, // 'GRAY'
+ cmsSigHsvData = $48535620, // 'HSV '
+ cmsSigHlsData = $484C5320, // 'HLS '
+ cmsSigCmykData = $434D594B, // 'CMYK'
+ cmsSigCmyData = $434D5920, // 'CMY '
+ cmsSigMCH1Data = $4D434831, // 'MCH1'
+ cmsSigMCH2Data = $4D434832, // 'MCH2'
+ cmsSigMCH3Data = $4D434833, // 'MCH3'
+ cmsSigMCH4Data = $4D434834, // 'MCH4'
+ cmsSigMCH5Data = $4D434835, // 'MCH5'
+ cmsSigMCH6Data = $4D434836, // 'MCH6'
+ cmsSigMCH7Data = $4D434837, // 'MCH7'
+ cmsSigMCH8Data = $4D434838, // 'MCH8'
+ cmsSigMCH9Data = $4D434839, // 'MCH9'
+ cmsSigMCHAData = $4D43483A, // 'MCHA'
+ cmsSigMCHBData = $4D43483B, // 'MCHB'
+ cmsSigMCHCData = $4D43483C, // 'MCHC'
+ cmsSigMCHDData = $4D43483D, // 'MCHD'
+ cmsSigMCHEData = $4D43483E, // 'MCHE'
+ cmsSigMCHFData = $4D43483F, // 'MCHF'
+ cmsSigNamedData = $6e6d636c, // 'nmcl'
+ cmsSig1colorData = $31434C52, // '1CLR'
+ cmsSig2colorData = $32434C52, // '2CLR'
+ cmsSig3colorData = $33434C52, // '3CLR'
+ cmsSig4colorData = $34434C52, // '4CLR'
+ cmsSig5colorData = $35434C52, // '5CLR'
+ cmsSig6colorData = $36434C52, // '6CLR'
+ cmsSig7colorData = $37434C52, // '7CLR'
+ cmsSig8colorData = $38434C52, // '8CLR'
+ cmsSig9colorData = $39434C52, // '9CLR'
+ cmsSig10colorData = $41434C52, // 'ACLR'
+ cmsSig11colorData = $42434C52, // 'BCLR'
+ cmsSig12colorData = $43434C52, // 'CCLR'
+ cmsSig13colorData = $44434C52, // 'DCLR'
+ cmsSig14colorData = $45434C52, // 'ECLR'
+ cmsSig15colorData = $46434C52, // 'FCLR'
+ cmsSigLuvKData = $4C75764B // 'LuvK'
+);
+
+// ICC Profile Class
+cmsProfileClassSignature = (
+ cmsSigInputClass = $73636E72, // 'scnr'
+ cmsSigDisplayClass = $6D6E7472, // 'mntr'
+ cmsSigOutputClass = $70727472, // 'prtr'
+ cmsSigLinkClass = $6C696E6B, // 'link'
+ cmsSigAbstractClass = $61627374, // 'abst'
+ cmsSigColorSpaceClass = $73706163, // 'spac'
+ cmsSigNamedColorClass = $6e6d636c // 'nmcl'
+);
+
+
+// ICC Platforms
+cmsPlatformSignature = (
+ cmsSigMacintosh = $4150504C, // 'APPL'
+ cmsSigMicrosoft = $4D534654, // 'MSFT'
+ cmsSigSolaris = $53554E57, // 'SUNW'
+ cmsSigSGI = $53474920, // 'SGI '
+ cmsSigTaligent = $54474E54, // 'TGNT'
+ cmsSigUnices = $2A6E6978 // '*nix' // From argyll -- Not official
+);
+
+CONST
+
+ // Reference gamut
+ cmsSigPerceptualReferenceMediumGamut = $70726d67; //'prmg'
+
+ // For cmsSigColorimetricIntentImageStateTag
+ cmsSigSceneColorimetryEstimates = $73636F65; //'scoe'
+ cmsSigSceneAppearanceEstimates = $73617065; //'sape'
+ cmsSigFocalPlaneColorimetryEstimates = $66706365; //'fpce'
+ cmsSigReflectionHardcopyOriginalColorimetry = $72686F63; //'rhoc'
+ cmsSigReflectionPrintOutputColorimetry = $72706F63; //'rpoc'
+
+TYPE
+
+// Multi process elements types
+cmsStageSignature = (
+ cmsSigCurveSetElemType = $63767374, //'cvst'
+ cmsSigMatrixElemType = $6D617466, //'matf'
+ cmsSigCLutElemType = $636C7574, //'clut'
+
+ cmsSigBAcsElemType = $62414353, // 'bACS'
+ cmsSigEAcsElemType = $65414353, // 'eACS'
+
+ // Custom from here, not in the ICC Spec
+ cmsSigXYZ2LabElemType = $6C327820, // 'l2x '
+ cmsSigLab2XYZElemType = $78326C20, // 'x2l '
+ cmsSigNamedColorElemType = $6E636C20, // 'ncl '
+ cmsSigLabV2toV4 = $32203420, // '2 4 '
+ cmsSigLabV4toV2 = $34203220, // '4 2 '
+
+ // Identities
+ cmsSigIdentityElemType = $69646E20 // 'idn '
+);
+
+// Types of CurveElements
+cmsCurveSegSignature = (
+
+ cmsSigFormulaCurveSeg = $70617266, // 'parf'
+ cmsSigSampledCurveSeg = $73616D66, // 'samf'
+ cmsSigSegmentedCurve = $63757266 // 'curf'
+);
+
+CONST
+
+ // Used in ResponseCurveType
+ cmsSigStatusA = $53746141; //'StaA'
+ cmsSigStatusE = $53746145; //'StaE'
+ cmsSigStatusI = $53746149; //'StaI'
+ cmsSigStatusT = $53746154; //'StaT'
+ cmsSigStatusM = $5374614D; //'StaM'
+ cmsSigDN = $444E2020; //'DN '
+ cmsSigDNP = $444E2050; //'DN P'
+ cmsSigDNN = $444E4E20; //'DNN '
+ cmsSigDNNP = $444E4E50; //'DNNP'
+
+ // Device attributes, currently defined values correspond to the low 4 bytes
+ // of the 8 byte attribute quantity
+ cmsReflective = 0;
+ cmsTransparency = 1;
+ cmsGlossy = 0;
+ cmsMatte = 2;
+
+TYPE
+
+// Common structures in ICC tags
+cmsICCData = PACKED RECORD
+ len : cmsUInt32Number;
+ flag : cmsUInt32Number;
+ data : Array [0..1] of cmsUInt8Number;
+ END;
+
+// ICC date time
+cmsDateTimeNumber = PACKED RECORD
+ year: cmsUInt16Number;
+ month: cmsUInt16Number;
+ day: cmsUInt16Number;
+ hours: cmsUInt16Number;
+ minutes: cmsUInt16Number;
+ seconds: cmsUInt16Number;
+END;
+
+// ICC XYZ
+
+cmsEncodedXYZNumber = PACKED RECORD
+ X: cmsS15Fixed16Number;
+ Y: cmsS15Fixed16Number;
+ Z: cmsS15Fixed16Number;
+END;
+
+
+// Profile ID as computed by MD5 algorithm
+cmsProfileID = PACKED RECORD
+ CASE Integer OF
+ 1: (ID8: Array[0..15] OF cmsUInt8Number);
+ 2: (ID16: Array[0..7] OF cmsUInt16Number);
+ 3: (ID32: Array[0..3] OF cmsUInt32Number);
+END;
+
+
+
+// ----------------------------------------------------------------------------------------------
+// ICC profile internal base types. Strictly, shouldn't be declared in this unit, but maybe
+// somebody want to use this info for accessing profile header directly, so here it is.
+
+// Profile header -- it is 32-bit aligned, so no issues are expected on alignment
+cmsICCHeader = PACKED RECORD
+ size: cmsUInt32Number; // Profile size in bytes
+ cmmId: cmsSignature; // CMM for this profile
+ version: cmsUInt32Number; // Format version number
+ deviceClass: cmsProfileClassSignature; // Type of profile
+ colorSpace: cmsColorSpaceSignature; // Color space of data
+ pcs: cmsColorSpaceSignature; // PCS, XYZ or Lab only
+ date: cmsDateTimeNumber; // Date profile was created
+ magic: cmsSignature; // Magic Number to identify an ICC profile
+ platform: cmsPlatformSignature; // Primary Platform
+ flags: cmsUInt32Number; // Various bit settings
+ manufacturer: cmsSignature; // Device manufacturer
+ model: cmsUInt32Number; // Device model number
+ attributes: cmsUInt64Number; // Device attributes
+ renderingIntent:cmsUInt32Number; // Rendering intent
+ illuminant: cmsEncodedXYZNumber; // Profile illuminant
+ creator: cmsSignature; // Profile creator
+ profileID: cmsProfileID; // Profile ID using MD5
+ reserved: array [0..27] of cmsInt8Number; // Reserved for future use
+END;
+
+// ICC base tag
+cmsTagBase = PACKED RECORD
+ sig: cmsTagTypeSignature;
+ reserved: array[0..3] of cmsInt8Number;
+END;
+
+// A tag entry in directory
+cmsTagEntry = PACKED RECORD
+ sig: cmsTagSignature; // The tag signature
+ offset: cmsUInt32Number; // Start of tag
+ size: cmsUInt32Number; // Size in bytes
+END;
+
+
+cmsContext = Pointer; // Context identifier for multithreaded environments
+cmsHANDLE = Pointer; // Generic handle
+cmsHPROFILE = Pointer; // Opaque typedefs to hide internals
+cmsHTRANSFORM = Pointer;
+
+
+CONST
+
+ cmsMAXCHANNELS = 16; // Maximum number of channels in ICC profiles
+
+// Format of pixel is defined by one cmsUInt32Number, using bit fields as follows
+//
+// A O TTTTT U Y F P X S EEE CCCC BBB
+//
+// A: Floating point -- With this flag we can differentiate 16 bits as float and as int
+// O: Optimized -- previous optimization already returns the final 8-bit value
+// T: Pixeltype
+// F: Flavor 0=MinIsBlack(Chocolate) 1=MinIsWhite(Vanilla)
+// P: Planar? 0=Chunky, 1=Planar
+// X: swap 16 bps endianess?
+// S: Do swap? ie, BGR, KYMC
+// E: Extra samples
+// C: Channels (Samples per pixel)
+// B: bytes per sample
+// Y: Swap first - changes ABGR to BGRA and KCMY to CMYK
+
+ FUNCTION FLOAT_SH(a: cmsUInt32Number): cmsUInt32Number;
+ FUNCTION OPTIMIZED_SH(s: cmsUInt32Number): cmsUInt32Number;
+ FUNCTION COLORSPACE_SH(s: cmsUInt32Number):cmsUInt32Number;
+ FUNCTION SWAPFIRST_SH(s: cmsUInt32Number):cmsUInt32Number;
+ FUNCTION FLAVOR_SH(s: cmsUInt32Number):cmsUInt32Number;
+ FUNCTION PLANAR_SH(p: cmsUInt32Number):cmsUInt32Number;
+ FUNCTION ENDIAN16_SH(e: cmsUInt32Number):cmsUInt32Number;
+ FUNCTION DOSWAP_SH(e: cmsUInt32Number):cmsUInt32Number;
+ FUNCTION EXTRA_SH(e: cmsUInt32Number):cmsUInt32Number;
+ FUNCTION CHANNELS_SH(c: cmsUInt32Number):cmsUInt32Number;
+ FUNCTION BYTES_SH(b: cmsUInt32Number):cmsUInt32Number;
+
+
+ FUNCTION T_FLOAT(a: cmsUInt32Number): cmsUInt32Number;
+ FUNCTION T_OPTIMIZED(o: cmsUInt32Number): cmsUInt32Number;
+ FUNCTION T_COLORSPACE(s: cmsUInt32Number): cmsUInt32Number;
+ FUNCTION T_SWAPFIRST(s: cmsUInt32Number): cmsUInt32Number;
+ FUNCTION T_FLAVOR(s: cmsUInt32Number): cmsUInt32Number;
+ FUNCTION T_PLANAR(p: cmsUInt32Number): cmsUInt32Number;
+ FUNCTION T_ENDIAN16(e: cmsUInt32Number): cmsUInt32Number;
+ FUNCTION T_DOSWAP(e: cmsUInt32Number): cmsUInt32Number;
+ FUNCTION T_EXTRA(e: cmsUInt32Number): cmsUInt32Number;
+ FUNCTION T_CHANNELS(c: cmsUInt32Number): cmsUInt32Number;
+ FUNCTION T_BYTES(b: cmsUInt32Number): cmsUInt32Number;
+
+CONST
+
+
+// Pixel types
+
+ PT_ANY = 0; // Don't check colorspace
+ // 1 & 2 are reserved
+ PT_GRAY = 3;
+ PT_RGB = 4;
+ PT_CMY = 5;
+ PT_CMYK = 6;
+ PT_YCbCr = 7;
+ PT_YUV = 8; // Lu'v'
+ PT_XYZ = 9;
+ PT_Lab = 10;
+ PT_YUVK = 11; // Lu'v'K
+ PT_HSV = 12;
+ PT_HLS = 13;
+ PT_Yxy = 14;
+
+ PT_MCH1 = 15;
+ PT_MCH2 = 16;
+ PT_MCH3 = 17;
+ PT_MCH4 = 18;
+ PT_MCH5 = 19;
+ PT_MCH6 = 20;
+ PT_MCH7 = 21;
+ PT_MCH8 = 22;
+ PT_MCH9 = 23;
+ PT_MCH10 = 24;
+ PT_MCH11 = 25;
+ PT_MCH12 = 26;
+ PT_MCH13 = 27;
+ PT_MCH14 = 28;
+ PT_MCH15 = 29;
+
+ PT_LabV2 = 30; // Identical to PT_Lab, but using the V2 old encoding
+
+
+ // Format descriptors
+ TYPE_GRAY_8 = $030009;
+ TYPE_GRAY_8_REV = $032009;
+ TYPE_GRAY_16 = $03000a;
+ TYPE_GRAY_16_REV = $03200a;
+ TYPE_GRAY_16_SE = $03080a;
+ TYPE_GRAYA_8 = $030089;
+ TYPE_GRAYA_16 = $03008a;
+ TYPE_GRAYA_16_SE = $03088a;
+ TYPE_GRAYA_8_PLANAR = $031089;
+ TYPE_GRAYA_16_PLANAR = $03108a;
+ TYPE_RGB_8 = $040019;
+ TYPE_RGB_8_PLANAR = $041019;
+ TYPE_BGR_8 = $040419;
+ TYPE_BGR_8_PLANAR = $041419;
+ TYPE_RGB_16 = $04001a;
+ TYPE_RGB_16_PLANAR = $04101a;
+ TYPE_RGB_16_SE = $04081a;
+ TYPE_BGR_16 = $04041a;
+ TYPE_BGR_16_PLANAR = $04141a;
+ TYPE_BGR_16_SE = $040c1a;
+ TYPE_RGBA_8 = $040099;
+ TYPE_RGBA_8_PLANAR = $041099;
+ TYPE_RGBA_16 = $04009a;
+ TYPE_RGBA_16_PLANAR = $04109a;
+ TYPE_RGBA_16_SE = $04089a;
+ TYPE_ARGB_8 = $044099;
+ TYPE_ARGB_16 = $04409a;
+ TYPE_ABGR_8 = $040499;
+ TYPE_ABGR_16 = $04049a;
+ TYPE_ABGR_16_PLANAR = $04149a;
+ TYPE_ABGR_16_SE = $040c9a;
+ TYPE_BGRA_8 = $044499;
+ TYPE_BGRA_16 = $04449a;
+ TYPE_BGRA_16_SE = $04489a;
+ TYPE_CMY_8 = $050019;
+ TYPE_CMY_8_PLANAR = $051019;
+ TYPE_CMY_16 = $05001a;
+ TYPE_CMY_16_PLANAR = $05101a;
+ TYPE_CMY_16_SE = $05081a;
+ TYPE_CMYK_8 = $060021;
+ TYPE_CMYKA_8 = $0600a1;
+ TYPE_CMYK_8_REV = $062021;
+ TYPE_YUVK_8 = $062021;
+ TYPE_CMYK_8_PLANAR = $061021;
+ TYPE_CMYK_16 = $060022;
+ TYPE_CMYK_16_REV = $062022;
+ TYPE_YUVK_16 = $062022;
+ TYPE_CMYK_16_PLANAR = $061022;
+ TYPE_CMYK_16_SE = $060822;
+ TYPE_KYMC_8 = $060421;
+ TYPE_KYMC_16 = $060422;
+ TYPE_KYMC_16_SE = $060c22;
+ TYPE_KCMY_8 = $064021;
+ TYPE_KCMY_8_REV = $066021;
+ TYPE_KCMY_16 = $064022;
+ TYPE_KCMY_16_REV = $066022;
+ TYPE_KCMY_16_SE = $064822;
+ TYPE_CMYK5_8 = $130029;
+ TYPE_CMYK5_16 = $13002a;
+ TYPE_CMYK5_16_SE = $13082a;
+ TYPE_KYMC5_8 = $130429;
+ TYPE_KYMC5_16 = $13042a;
+ TYPE_KYMC5_16_SE = $130c2a;
+ TYPE_CMYK6_8 = $140031;
+ TYPE_CMYK6_8_PLANAR = $141031;
+ TYPE_CMYK6_16 = $140032;
+ TYPE_CMYK6_16_PLANAR = $141032;
+ TYPE_CMYK6_16_SE = $140832;
+ TYPE_CMYK7_8 = $150039;
+ TYPE_CMYK7_16 = $15003a;
+ TYPE_CMYK7_16_SE = $15083a;
+ TYPE_KYMC7_8 = $150439;
+ TYPE_KYMC7_16 = $15043a;
+ TYPE_KYMC7_16_SE = $150c3a;
+ TYPE_CMYK8_8 = $160041;
+ TYPE_CMYK8_16 = $160042;
+ TYPE_CMYK8_16_SE = $160842;
+ TYPE_KYMC8_8 = $160441;
+ TYPE_KYMC8_16 = $160442;
+ TYPE_KYMC8_16_SE = $160c42;
+ TYPE_CMYK9_8 = $170049;
+ TYPE_CMYK9_16 = $17004a;
+ TYPE_CMYK9_16_SE = $17084a;
+ TYPE_KYMC9_8 = $170449;
+ TYPE_KYMC9_16 = $17044a;
+ TYPE_KYMC9_16_SE = $170c4a;
+ TYPE_CMYK10_8 = $180051;
+ TYPE_CMYK10_16 = $180052;
+ TYPE_CMYK10_16_SE = $180852;
+ TYPE_KYMC10_8 = $180451;
+ TYPE_KYMC10_16 = $180452;
+ TYPE_KYMC10_16_SE = $180c52;
+ TYPE_CMYK11_8 = $190059;
+ TYPE_CMYK11_16 = $19005a;
+ TYPE_CMYK11_16_SE = $19085a;
+ TYPE_KYMC11_8 = $190459;
+ TYPE_KYMC11_16 = $19045a;
+ TYPE_KYMC11_16_SE = $190c5a;
+ TYPE_CMYK12_8 = $1a0061;
+ TYPE_CMYK12_16 = $1a0062;
+ TYPE_CMYK12_16_SE = $1a0862;
+ TYPE_KYMC12_8 = $1a0461;
+ TYPE_KYMC12_16 = $1a0462;
+ TYPE_KYMC12_16_SE = $1a0c62;
+ TYPE_XYZ_16 = $09001a;
+ TYPE_Lab_8 = $0a0019;
+ TYPE_ALab_8 = $0a0499;
+ TYPE_Lab_16 = $0a001a;
+ TYPE_Yxy_16 = $0e001a;
+ TYPE_YCbCr_8 = $070019;
+ TYPE_YCbCr_8_PLANAR = $071019;
+ TYPE_YCbCr_16 = $07001a;
+ TYPE_YCbCr_16_PLANAR = $07101a;
+ TYPE_YCbCr_16_SE = $07081a;
+ TYPE_YUV_8 = $080019;
+ TYPE_YUV_8_PLANAR = $081019;
+ TYPE_YUV_16 = $08001a;
+ TYPE_YUV_16_PLANAR = $08101a;
+ TYPE_YUV_16_SE = $08081a;
+ TYPE_HLS_8 = $0d0019;
+ TYPE_HLS_8_PLANAR = $0d1019;
+ TYPE_HLS_16 = $0d001a;
+ TYPE_HLS_16_PLANAR = $0d101a;
+ TYPE_HLS_16_SE = $0d081a;
+ TYPE_HSV_8 = $0c0019;
+ TYPE_HSV_8_PLANAR = $0c1019;
+ TYPE_HSV_16 = $0c001a;
+ TYPE_HSV_16_PLANAR = $0c101a;
+ TYPE_HSV_16_SE = $0c081a;
+
+ TYPE_NAMED_COLOR_INDEX = $000A;
+
+ TYPE_XYZ_FLT = $49001c;
+ TYPE_Lab_FLT = $4a001c;
+ TYPE_GRAY_FLT = $43000c;
+ TYPE_RGB_FLT = $44001c;
+ TYPE_CMYK_FLT = $460024;
+ TYPE_XYZA_FLT = $49009c;
+ TYPE_LabA_FLT = $4a009c;
+ TYPE_RGBA_FLT = $44009c;
+ TYPE_XYZ_DBL = $490018;
+ TYPE_Lab_DBL = $4a0018;
+ TYPE_GRAY_DBL = $430008;
+ TYPE_RGB_DBL = $440018;
+ TYPE_CMYK_DBL = $460020;
+ TYPE_LabV2_8 = $1e0019;
+ TYPE_ALabV2_8 = $1e0499;
+ TYPE_LabV2_16 = $1e001a;
+
+
+TYPE
+
+
+ // Colorimetric spaces
+
+ cmsCIEXYZ = PACKED RECORD
+ X, Y, Z : cmsFloat64Number;
+ END;
+ LPcmsCIEXYZ = ^cmsCIEXYZ;
+
+ cmsCIExyY = PACKED RECORD
+ x, y, YY : cmsFloat64Number
+ END;
+ LPcmsCIExyY = ^cmsCIEXYY;
+
+ cmsCIELab = PACKED RECORD
+ L, a, b: cmsFloat64Number
+ END;
+ LPcmsCIELab = ^cmsCIELab;
+
+ cmsCIELCh = PACKED RECORD
+ L, C, h : cmsFloat64Number
+ END;
+ LPcmsCIELCh = ^cmsCIELCh;
+
+ cmsJCh = PACKED RECORD
+ J, C, h : cmsFloat64Number
+ END;
+ LPcmsJCh = ^cmsJCH;
+
+
+ cmsCIEXYZTRIPLE = PACKED RECORD
+ Red, Green, Blue : cmsCIEXYZ
+ END;
+ LPcmsCIEXYZTRIPLE = ^cmsCIEXYZTRIPLE;
+
+
+ cmsCIExyYTRIPLE = PACKED RECORD
+ Red, Green, Blue : cmsCIExyY
+ END;
+ LPcmsCIExyYTRIPLE = ^cmsCIExyYTRIPLE;
+
+
+CONST
+
+ // Illuminant types for structs below
+ cmsILLUMINANT_TYPE_UNKNOWN = $0000000;
+ cmsILLUMINANT_TYPE_D50 = $0000001;
+ cmsILLUMINANT_TYPE_D65 = $0000002;
+ cmsILLUMINANT_TYPE_D93 = $0000003;
+ cmsILLUMINANT_TYPE_F2 = $0000004;
+ cmsILLUMINANT_TYPE_D55 = $0000005;
+ cmsILLUMINANT_TYPE_A = $0000006;
+ cmsILLUMINANT_TYPE_E = $0000007;
+ cmsILLUMINANT_TYPE_F8 = $0000008;
+
+TYPE
+
+ cmsICCMeasurementConditions = PACKED RECORD
+
+ Observer: cmsUInt32Number; // 0 = unknown, 1=CIE 1931, 2=CIE 1964
+ Backing: cmsCIEXYZ; // Value of backing
+ Geometry: cmsUInt32Number; // 0=unknown, 1=45/0, 0/45 2=0d, d/0
+ Flare: cmsFloat64Number; // 0..1.0
+ IlluminantType: cmsUInt32Number;
+
+ END;
+
+ cmsICCViewingConditions = PACKED RECORD
+ IlluminantXYZ: cmsCIEXYZ; // Not the same struct as CAM02,
+ SurroundXYZ: cmsCIEXYZ; // This is for storing the tag
+ IlluminantType: cmsUInt32Number; // viewing condition
+ END;
+
+
+// Plug-In registering ---------------------------------------------------------------------------------------------------
+
+FUNCTION cmsPlugin(Plugin: Pointer): cmsBool; StdCall;
+PROCEDURE cmsUnregisterPlugins; StdCall;
+
+// Error logging ----------------------------------------------------------------------------------------------------------
+
+// There is no error handling at all. When a function fails, it returns proper value.
+// For example, all create functions does return NULL on failure. Other may return FALSE.
+// It may be interesting, for the developer, to know why the function is failing.
+// for that reason, lcms2 does offer a logging function. This function will get
+// an ENGLISH string with some clues on what is going wrong. You can show this
+// info to the end user if you wish, or just create some sort of log on disk.
+// The logging function should NOT terminate the program, as this obviously can leave
+// unfreed resources. It is the programmer's responsibility to check each function
+// return code to make sure it didn't fail.
+
+CONST
+
+ cmsERROR_UNDEFINED = 0;
+ cmsERROR_FILE = 1;
+ cmsERROR_RANGE = 2;
+ cmsERROR_INTERNAL = 3;
+ cmsERROR_NULL = 4;
+ cmsERROR_READ = 5;
+ cmsERROR_SEEK = 6;
+ cmsERROR_WRITE = 7;
+ cmsERROR_UNKNOWN_EXTENSION = 8;
+ cmsERROR_COLORSPACE_CHECK = 9;
+ cmsERROR_ALREADY_DEFINED = 10;
+ cmsERROR_BAD_SIGNATURE = 11;
+ cmsERROR_CORRUPTION_DETECTED = 12;
+ cmsERROR_NOT_SUITABLE = 13;
+
+// Error logger is called with the ContextID when a message is raised. This gives the
+// chance to know which thread is responsible of the warning and any environment associated
+// with it. Non-multithreading applications may safely ignore this parameter.
+// Note that under certain special circumstances, ContextID may be NULL.
+
+TYPE
+
+ cmsLogErrorHandlerFunction = PROCEDURE( ContextID: cmsContext; ErrorCode: cmsUInt32Number; Text: PAnsiChar); CDecl;
+
+ // Allows user to set any specific logger
+ PROCEDURE cmsSetLogErrorHandler(Fn: cmsLogErrorHandlerFunction); StdCall;
+
+
+// Conversions --------------------------------------------------------------------------------------------------------------
+
+
+// Returns pointers to constant structs
+FUNCTION cmsD50_XYZ: LPcmsCIEXYZ; StdCall;
+FUNCTION cmsD50_xyY: LPcmsCIExyY; StdCall;
+
+// Colorimetric space conversions
+PROCEDURE cmsXYZ2xyY(Dest: LPcmsCIExyY; Source: LPcmsCIEXYZ); StdCall;
+PROCEDURE cmsxyY2XYZ(Dest: LPcmsCIEXYZ; Source: LPcmsCIExyY); StdCall;
+PROCEDURE cmsLab2XYZ(WhitePoint: LPcmsCIEXYZ; xyz: LPcmsCIEXYZ; Lab: LPcmsCIELab); StdCall;
+PROCEDURE cmsXYZ2Lab(WhitePoint: LPcmsCIEXYZ; Lab: LPcmsCIELab; xyz: LPcmsCIEXYZ); StdCall;
+PROCEDURE cmsLab2LCh(LCh: LPcmsCIELCh; Lab: LPcmsCIELab); StdCall;
+PROCEDURE cmsLCh2Lab(Lab: LPcmsCIELab; LCh: LPcmsCIELCh); StdCall;
+
+// Encoding /Decoding on PCS
+PROCEDURE cmsLabEncoded2Float(Lab: LPcmsCIELab; wLab: Pointer); StdCall;
+PROCEDURE cmsLabEncoded2FloatV2(Lab: LPcmsCIELab; wLab: Pointer); StdCall;
+PROCEDURE cmsFloat2LabEncoded(wLab: Pointer; Lab: LPcmsCIELab); StdCall;
+PROCEDURE cmsFloat2LabEncodedV2(wLab: Pointer; Lab: LPcmsCIELab); StdCall;
+PROCEDURE cmsXYZEncoded2Float(fxyz : LPcmsCIEXYZ; XYZ: Pointer); StdCall;
+PROCEDURE cmsFloat2XYZEncoded(XYZ: Pointer; fXYZ: LPcmsCIEXYZ); StdCall;
+
+
+// DeltaE metrics
+FUNCTION cmsDeltaE(Lab1, Lab2: LPcmsCIELab): Double; StdCall;
+FUNCTION cmsCIE94DeltaE(Lab1, Lab2: LPcmsCIELab): Double; StdCall;
+FUNCTION cmsBFDdeltaE(Lab1, Lab2: LPcmsCIELab): Double; StdCall;
+FUNCTION cmsCMCdeltaE(Lab1, Lab2: LPcmsCIELab): Double; StdCall;
+FUNCTION cmsCIE2000DeltaE(Lab1, Lab2: LPcmsCIELab; Kl, Kc, Kh: Double): Double; StdCall;
+
+
+// Temperature <-> Chromaticity (Black body)
+FUNCTION cmsWhitePointFromTemp(var WhitePoint: cmsCIExyY; TempK: cmsFloat64Number) : cmsBool; StdCall;
+FUNCTION cmsTempFromWhitePoint(var TeampK: cmsFloat64Number; var WhitePoint: cmsCIExyY) : cmsBool; StdCall;
+
+
+// Chromatic adaptation
+FUNCTION cmsAdaptToIlluminant(Result: LPcmsCIEXYZ; SourceWhitePt: LPcmsCIEXYZ;
+ Illuminant: LPcmsCIEXYZ; Value: LPcmsCIEXYZ): cmsBool; StdCall;
+
+
+// CIECAM02 ---------------------------------------------------------------------------------------------------
+
+// Viewing conditions. Please note those are CAM model viewing conditions, and not the ICC tag viewing
+// conditions, which I'm naming cmsICCViewingConditions to make differences evident. Unfortunately, the tag
+// cannot deal with surround La, Yb and D value so is basically useless to store CAM02 viewing conditions.
+
+ CONST
+
+ AVG_SURROUND = 1;
+ DIM_SURROUND = 2;
+ DARK_SURROUND = 3;
+ CUTSHEET_SURROUND = 4;
+
+ D_CALCULATE = -1;
+
+ TYPE
+
+ cmsViewingConditions = PACKED RECORD
+
+ WhitePoint: cmsCIEXYZ;
+ Yb : cmsFloat64Number;
+ La : cmsFloat64Number;
+ surround : Integer;
+ D_value : cmsFloat64Number
+ END;
+
+
+ LPcmsViewingConditions = ^cmsViewingConditions;
+
+FUNCTION cmsCIECAM02Init(pVC : LPcmsViewingConditions ) : Pointer; StdCall;
+PROCEDURE cmsCIECAM02Done(hModel : Pointer); StdCall;
+PROCEDURE cmsCIECAM02Forward(hModel: Pointer; pIn: LPcmsCIEXYZ; pOut: LPcmsJCh ); StdCall;
+PROCEDURE cmsCIECAM02Reverse(hModel: Pointer; pIn: LPcmsJCh; pOut: LPcmsCIEXYZ ); StdCall;
+
+// Tone curves -----------------------------------------------------------------------------------------
+
+// This describes a curve segment. For a table of supported types, see the manual. User can increase the number of
+// available types by using a proper plug-in. Parametric segments allow 10 parameters at most
+
+TYPE
+cmsCurveSegment = PACKED RECORD
+ x0, x1: cmsFloat32Number; // Domain; for x0 < x <= x1
+ PType: cmsInt32Number; // Parametric type, Type == 0 means sampled segment. Negative values are reserved
+ Params: array [0..9] of cmsFloat64Number; // Parameters if Type != 0
+ nGridPoints: cmsUInt32Number; // Number of grid points if Type == 0
+ SampledPoints: LPcmsFloat32Number; // Points to an array of floats if Type == 0
+END;
+
+LPcmsToneCurve = Pointer;
+LPcmsCurveSegmentArray = ^cmsCurveSegmentArray;
+cmsCurveSegmentArray = array[0..0] of cmsCurveSegment;
+
+LPcmsFloat64NumberArray = ^cmsFloat64NumberArray;
+cmsFloat64NumberArray = array[0..0] of cmsFloat64Number;
+
+LPcmsUInt16NumberArray = ^cmsUInt16NumberArray;
+cmsUInt16NumberArray = array[0..0] of cmsUInt16Number;
+
+LPcmsFloat32NumberArray = ^cmsFloat32NumberArray;
+cmsFloat32NumberArray = array[0..0] of cmsFloat32Number;
+
+LPLPcmsToneCurveArray = ^LPcmsToneCurveArray;
+LPcmsToneCurveArray = array[0..0] of LPcmsToneCurve;
+
+LPcmsUInt32NumberArray = ^cmsUInt32NumberArray;
+cmsUInt32NumberArray = array[0..0] of cmsUInt32Number;
+
+FUNCTION cmsBuildSegmentedToneCurve(ContextID: cmsContext; nSegments: cmsInt32Number; Segments: LPcmsCurveSegmentArray): LPcmsToneCurve; StdCall;
+FUNCTION cmsBuildParametricToneCurve(ContextID: cmsContext; CType: cmsInt32Number; Params: LPcmsFloat64NumberArray): LPcmsToneCurve; StdCall;
+FUNCTION cmsBuildGamma(ContextID: cmsContext; Gamma: cmsFloat64Number): LPcmsToneCurve; StdCall;
+FUNCTION cmsBuildTabulatedToneCurve16(ContextID: cmsContext; nEntries: cmsInt32Number; values: LPcmsUInt16NumberArray): LPcmsToneCurve; StdCall;
+FUNCTION cmsBuildTabulatedToneCurveFloat(ContextID: cmsContext; nEntries: cmsUInt32Number; values: LPcmsFloat32NumberArray): LPcmsToneCurve; StdCall;
+PROCEDURE cmsFreeToneCurve(Curve: LPcmsToneCurve); StdCall;
+PROCEDURE cmsFreeToneCurveTriple(Curve: LPLPcmsToneCurveArray); StdCall;
+FUNCTION cmsDupToneCurve(Src: LPcmsToneCurve): LPcmsToneCurve; StdCall;
+FUNCTION cmsReverseToneCurve(InGamma: LPcmsToneCurve): LPcmsToneCurve; StdCall;
+FUNCTION cmsReverseToneCurveEx(nResultSamples: cmsInt32Number; InGamma: LPcmsToneCurve): LPcmsToneCurve; StdCall;
+FUNCTION cmsJoinToneCurve(ContextID: cmsContext; X, Y: LPcmsToneCurve; nPoints: cmsUInt32Number ): LPcmsToneCurve; StdCall;
+FUNCTION cmsSmoothToneCurve(Tab: LPcmsToneCurve; lambda: cmsFloat64Number): cmsBool; StdCall;
+FUNCTION cmsEvalToneCurveFloat(Curve: LPcmsToneCurve; v: cmsFloat32Number):cmsFloat32Number; StdCall;
+FUNCTION cmsEvalToneCurve16(Curve: LPcmsToneCurve; v:cmsUInt16Number):cmsUInt16Number; StdCall;
+FUNCTION cmsIsToneCurveMultisegment(InGamma: LPcmsToneCurve):cmsBool; StdCall;
+FUNCTION cmsIsToneCurveLinear(Curve: LPcmsToneCurve):cmsBool; StdCall;
+FUNCTION cmsIsToneCurveMonotonic(t: LPcmsToneCurve):cmsBool; StdCall;
+FUNCTION cmsIsToneCurveDescending(t: LPcmsToneCurve):cmsBool; StdCall;
+FUNCTION cmsGetToneCurveParametricType(t: LPcmsToneCurve):cmsInt32Number; StdCall;
+FUNCTION cmsEstimateGamma(t: LPcmsToneCurve; Precision:cmsFloat64Number):cmsFloat64Number; StdCall;
+
+
+// Implements pipelines of multi-processing elements -------------------------------------------------------------
+
+TYPE
+ LPcmsPipeline = Pointer;
+ LPcmsStage = Pointer;
+ LPLPcmsStage = ^LPcmsStage;
+
+// Those are hi-level pipelines
+FUNCTION cmsPipelineAlloc(ContextID: cmsContext; InputChannels, OutputChannels: cmsUInt32Number): LPcmsPipeline; StdCall;
+PROCEDURE cmsPipelineFree(lut: LPcmsPipeline); StdCall;
+FUNCTION cmsPipelineDup(Orig: LPcmsPipeline): LPcmsPipeline; StdCall;
+FUNCTION cmsPipelineInputChannels(lut: LPcmsPipeline): cmsUInt32Number; StdCall;
+FUNCTION cmsPipelineOutputChannels(lut: LPcmsPipeline): cmsUInt32Number; StdCall;
+
+FUNCTION cmsPipelineStageCount(lut: LPcmsPipeline): cmsUInt32Number; StdCall;
+FUNCTION cmsPipelineGetPtrToFirstStage(lut: LPcmsPipeline): LPcmsStage; StdCall;
+FUNCTION cmsPipelineGetPtrToLastStage(lut: LPcmsPipeline): LPcmsStage; StdCall;
+
+PROCEDURE cmsPipelineEval16(Inv, Outv: LPcmsUInt16NumberArray; lut: LPcmsPipeline); StdCall;
+PROCEDURE cmsPipelineEvalFloat(Inv, Outv: LPcmsFloat32NumberArray; lut: LPcmsPipeline); StdCall;
+
+FUNCTION cmsPipelineEvalReverseFloat(Target, Result, Hint: LPcmsFloat32NumberArray; lut: LPcmsPipeline): cmsBool; StdCall;
+FUNCTION cmsPipelineCat(l1, l2: LPcmsPipeline): cmsBool; StdCall;
+FUNCTION cmsPipelineSetSaveAs8bitsFlag(lut: LPcmsPipeline; On: cmsBool): cmsBool; StdCall;
+
+// Where to place/locate the stages in the pipeline chain
+TYPE
+ cmsStageLoc = (cmsAT_BEGIN = 0, cmsAT_END = 1 );
+
+PROCEDURE cmsPipelineInsertStage(lut: LPcmsPipeline; loc: cmsStageLoc; mpe: LPcmsStage); StdCall;
+PROCEDURE cmsPipelineUnlinkStage(lut: LPcmsPipeline; loc: cmsStageLoc; mpe: LPLPcmsStage); StdCall;
+
+// This function is quite useful to analyze the structure of a Pipeline and retrieve the Stage elements
+// that conform the Pipeline. It should be called with the Pipeline, the number of expected elements and
+// then a list of expected types followed with a list of double pointers to Stage elements. If
+// the function founds a match with current pipeline, it fills the pointers and returns TRUE
+// if not, returns FALSE without touching anything.
+// FUNCTION cmsPipelineCheckAndRetreiveStages(const cmsPipeline* Lut, n: cmsUInt32Number, ...): cmsBool; StdCall;
+
+// Matrix has double precision and CLUT has only float precision. That is because an ICC profile can encode
+// matrices with far more precision that CLUTS
+FUNCTION cmsStageAllocIdentity(ContextID: cmsContext; nChannels: cmsUInt32Number): LPcmsStage; StdCall;
+FUNCTION cmsStageAllocToneCurves(ContextID: cmsContext; nChannels: cmsUInt32Number; Curves: LPLPcmsToneCurveArray): LPcmsStage; StdCall;
+FUNCTION cmsStageAllocMatrix(ContextID: cmsContext; Rows, Cols: cmsUInt32Number; Matrix, Offset: LPcmsFloat64NumberArray): LPcmsStage; StdCall;
+
+FUNCTION cmsStageAllocCLut16bit(ContextID: cmsContext; nGridPoints: cmsUInt32Number; inputChan, outputChan: cmsUInt32Number; Table: LPcmsUInt16NumberArray): LPcmsStage; StdCall;
+FUNCTION cmsStageAllocCLutFloat(ContextID: cmsContext; nGridPoints: cmsUInt32Number; inputChan, outputChan: cmsUInt32Number; Table: LPcmsFloat32NumberArray): LPcmsStage; StdCall;
+
+FUNCTION cmsStageAllocCLut16bitGranular(ContextID: cmsContext; nGridPoints: LPcmsUInt32NumberArray; inputChan, outputChan: cmsUInt32Number; Table: LPcmsUInt16NumberArray): LPcmsStage; StdCall;
+FUNCTION cmsStageAllocCLutFloatGranular(ContextID: cmsContext; nGridPoints: LPcmsUInt32NumberArray; inputChan, outputChan: cmsUInt32Number; Table: LPcmsFloat32NumberArray): LPcmsStage; StdCall;
+
+
+FUNCTION cmsStageDup(mpe: LPcmsStage): LPcmsStage; StdCall;
+PROCEDURE cmsStageFree(mpe: LPcmsStage); StdCall;
+FUNCTION cmsStageNext(mpe: LPcmsStage): LPcmsStage; StdCall;
+
+FUNCTION cmsStageInputChannels(mpe: LPcmsStage): cmsUInt32Number; StdCall;
+FUNCTION cmsStageOutputChannels(mpe: LPcmsStage): cmsUInt32Number; StdCall;
+FUNCTION cmsStageType(mpe: LPcmsStage): cmsStageSignature; StdCall;
+FUNCTION cmsStageData(mpe: LPcmsStage): Pointer; StdCall;
+
+// Sampling
+
+Type
+ cmsSAMPLER16 = FUNCTION (Inp, Outp: LPcmsUInt16NumberArray; Cargo: Pointer): cmsInt32Number; CDecl;
+ cmsSAMPLERFLOAT = FUNCTION (Inp, Outp: LPcmsFloat32NumberArray; Cargo: Pointer): cmsInt32Number; CDecl;
+
+// Use this flag to prevent changes being written to destination
+
+Const
+
+SAMPLER_INSPECT = $01000000;
+
+
+// For CLUT only
+FUNCTION cmsStageSampleCLut16bit(mpe: LPcmsStage; Sampler: cmsSAMPLER16; Cargo: Pointer; dwFlags: cmsUInt32Number): cmsBool; StdCall;
+FUNCTION cmsStageSampleCLutFloat(mpe: LPcmsStage; Sampler: cmsSAMPLERFLOAT; Cargo: Pointer; dwFlags: cmsUInt32Number): cmsBool; StdCall;
+
+
+// Slicers
+FUNCTION cmsSliceSpace16(nInputs: cmsUInt32Number; clutPoints: LPcmsUInt32NumberArray;
+ Sampler: cmsSAMPLER16; Cargo: Pointer): cmsBool; StdCall;
+
+FUNCTION cmsSliceSpaceFloat(nInputs: cmsUInt32Number; clutPoints: LPcmsUInt32NumberArray;
+ Sampler: cmsSAMPLERFLOAT; Cargo: Pointer): cmsBool; StdCall;
+
+// Multilocalized Unicode management ---------------------------------------------------------------------------------------
+
+Type
+ LPcmsMLU = Pointer;
+
+Const
+
+cmsNoLanguage = #0#0#0;
+cmsNoCountry = #0#0#0;
+
+
+FUNCTION cmsMLUalloc(ContextID: cmsContext; nItems: cmsUInt32Number): LPcmsMLU; StdCall;
+PROCEDURE cmsMLUfree(mlu: LPcmsMLU); StdCall;
+FUNCTION cmsMLUdup(mlu: LPcmsMLU): LPcmsMLU; StdCall;
+
+FUNCTION cmsMLUsetASCII(mlu: LPcmsMLU; LanguageCode, CountryCode, ASCIIString: PAnsiChar): cmsBool; StdCall;
+FUNCTION cmsMLUsetWide(mlu: LPcmsMLU; LanguageCode, CountryCode: PAnsiChar; WideString: PWChar): cmsBool; StdCall;
+
+FUNCTION cmsMLUgetASCII(mlu: LPcmsMLU; LanguageCode, CountryCode: PAnsiChar; Buffer: PAnsiChar; BufferSize: cmsUInt32Number): cmsUInt32Number; StdCall;
+
+FUNCTION cmsMLUgetWide(mlu: LPcmsMLU; LanguageCode, CountryCode: PAnsiChar; Buffer: PWChar; BufferSize: cmsUInt32Number): cmsUInt32Number; StdCall;
+
+FUNCTION cmsMLUgetTranslation(mlu: LPcmsMLU; LanguageCode, CountryCode, ObtainedLanguage, ObtainedCountry: PAnsiChar): cmsBool; StdCall;
+
+// Undercolorremoval & black generation -------------------------------------------------------------------------------------
+
+Type
+
+cmsUcrBg = PACKED RECORD
+ Ucr, Bg: LPcmsToneCurve;
+ Desc: LPcmsMLU;
+ END;
+
+
+// Screening ----------------------------------------------------------------------------------------------------------------
+
+Const
+
+ cmsPRINTER_DEFAULT_SCREENS = $0001;
+ cmsFREQUENCE_UNITS_LINES_CM = $0000;
+ cmsFREQUENCE_UNITS_LINES_INCH = $0002;
+
+ cmsSPOT_UNKNOWN = 0;
+ cmsSPOT_PRINTER_DEFAULT = 1;
+ cmsSPOT_ROUND = 2;
+ cmsSPOT_DIAMOND = 3;
+ cmsSPOT_ELLIPSE = 4;
+ cmsSPOT_LINE = 5;
+ cmsSPOT_SQUARE = 6;
+ cmsSPOT_CROSS = 7;
+
+
+Type
+
+cmsScreeningChannel = PACKED RECORD
+
+ Frequency,
+ ScreenAngle: cmsFloat64Number;
+ SpotShape: cmsUInt32Number;
+
+END;
+
+cmsScreening = PACKED RECORD
+
+ Flag,
+ nChannels : cmsUInt32Number;
+ Channels: Array [0..cmsMAXCHANNELS-1] OF cmsScreeningChannel;
+END;
+
+
+// Named color -----------------------------------------------------------------------------------------------------------------
+
+
+LPcmsNAMEDCOLORLIST = Pointer;
+
+FUNCTION cmsAllocNamedColorList(ContextID: cmsContext; n, ColorantCount :cmsUInt32Number;
+ Prefix, Suffix: PAnsiChar): LPcmsNAMEDCOLORLIST; StdCall;
+
+PROCEDURE cmsFreeNamedColorList(v: LPcmsNAMEDCOLORLIST); StdCall;
+FUNCTION cmsDupNamedColorList(v: LPcmsNAMEDCOLORLIST): LPcmsNAMEDCOLORLIST; StdCall;
+FUNCTION cmsAppendNamedColor(v: LPcmsNAMEDCOLORLIST; Name: PAnsiChar;
+ PCS, Colorant : LPcmsUInt16NumberArray): cmsBool; StdCall;
+
+FUNCTION cmsNamedColorCount(v: LPcmsNAMEDCOLORLIST): cmsUInt32Number; StdCall;
+FUNCTION cmsNamedColorIndex(v: LPcmsNAMEDCOLORLIST; Name: PAnsiChar): cmsInt32Number; StdCall;
+
+FUNCTION cmsNamedColorInfo(v: LPcmsNAMEDCOLORLIST; nColor : cmsUInt32Number;
+ Name,Prefix, Suffix : PAnsiChar;
+ PCS, Colorant : LPcmsUInt16NumberArray): cmsBool; StdCall;
+
+// Retrieve named color list from transform
+FUNCTION cmsGetNamedColorList(xform: cmsHTRANSFORM ): LPcmsNAMEDCOLORLIST; StdCall;
+
+// Profile sequence -----------------------------------------------------------------------------------------------------
+
+Type
+
+// Profile sequence descriptor. Some fields come from profile sequence descriptor tag, others
+// come from Profile Sequence Identifier Tag
+
+cmsPSEQDESC = PACKED RECORD
+ deviceMfg, deviceModel: cmsSignature;
+
+ attributes: cmsUInt64Number;
+ technology: cmsTechnologySignature;
+ ProfileID: cmsProfileID;
+ Manufacturer,
+ Model,
+ Description : LPcmsMLU;
+ END;
+
+ LPcmsSEQDESC = ^cmsPSEQDESC;
+
+cmsSEQ = PACKED RECORD
+
+ n: cmsUInt32Number;
+ ContextID: cmsContext;
+ seq: LPcmsSEQDESC;
+END;
+
+LPcmsSEQ = ^cmsSEQ;
+
+FUNCTION cmsAllocProfileSequenceDescription(ContextID: cmsContext; n: cmsUInt32Number):LPcmsSEQ; StdCall;
+FUNCTION cmsDupProfileSequenceDescription(pseq: LPcmsSEQ):LPcmsSEQ; StdCall;
+PROCEDURE cmsFreeProfileSequenceDescription(pseq: LPcmsSEQ); StdCall;
+
+// Dictionaries --------------------------------------------------------------------------------------------------------
+
+TYPE
+
+ LPcmsDICTentry = ^cmsDICTentry;
+
+cmsDICTentry = PACKED RECORD
+
+ Next: LPcmsDICTentry;
+
+ DisplayName, DisplayValue: LPcmsMLU;
+ Name, Value : PWChar;
+END;
+
+FUNCTION cmsDictAlloc(ContextID: cmsContext): cmsHANDLE; StdCall;
+PROCEDURE cmsDictFree(hDict: cmsHANDLE); StdCall;
+FUNCTION cmsDictDup(hDict: cmsHANDLE): cmsHANDLE; StdCall;
+
+FUNCTION cmsDictAddEntry(hDict: cmsHANDLE; Name, Value: PWChar; DisplayName, DisplayValue : LPcmsMLU): cmsBool; StdCall;
+FUNCTION cmsDictGetEntryList(hDict: cmsHANDLE): LPcmsDICTentry; StdCall;
+FUNCTION cmsDictNextEntry(e : LPcmsDICTentry): LPcmsDICTentry; StdCall;
+
+// Access to Profile data ----------------------------------------------------------------------------------------------
+FUNCTION cmsCreateProfilePlaceholder(ContextID: cmsContext): cmsHPROFILE; StdCall;
+
+FUNCTION cmsGetProfileContextID(hProfile: cmsHPROFILE):cmsContext; StdCall;
+FUNCTION cmsGetTagCount(hProfile: cmsHPROFILE): cmsInt32Number; StdCall;
+FUNCTION cmsGetTagSignature(hProfile: cmsHPROFILE; n: cmsUInt32Number): cmsTagSignature; StdCall;
+FUNCTION cmsIsTag(hProfile: cmsHPROFILE; sig: cmsTagSignature ): cmsBool; StdCall;
+
+// Read and write pre-formatted data
+FUNCTION cmsReadTag(hProfile: cmsHPROFILE; sig: cmsTagSignature ): Pointer; StdCall;
+FUNCTION cmsWriteTag(hProfile: cmsHPROFILE; sig: cmsTagSignature; data: Pointer): cmsBool; StdCall;
+FUNCTION cmsLinkTag(hProfile: cmsHPROFILE; sig: cmsTagSignature; dest: cmsTagSignature): cmsBool; StdCall;
+FUNCTION cmsTagLinkedTo(hProfile: cmsHPROFILE; sig: cmsTagSignature):cmsTagSignature; StdCall;
+
+// Read and write raw data
+FUNCTION cmsReadRawTag(hProfile: cmsHPROFILE; sig: cmsTagSignature; Buffer: Pointer; BufferSize: cmsUInt32Number): cmsInt32Number; StdCall;
+FUNCTION cmsWriteRawTag(hProfile: cmsHPROFILE; sig: cmsTagSignature; data: Pointer; Size: cmsUInt32Number): cmsBool; StdCall;
+
+// Access header data
+Const
+
+ cmsEmbeddedProfileFalse = $00000000;
+ cmsEmbeddedProfileTrue = $00000001;
+ cmsUseAnywhere = $00000000;
+ cmsUseWithEmbeddedDataOnly = $00000002;
+
+FUNCTION cmsGetHeaderFlags(hProfile: cmsHPROFILE): cmsUInt32Number; StdCall;
+PROCEDURE cmsGetHeaderAttributes(hProfile: cmsHPROFILE; Flags: LPcmsUInt64Number); StdCall;
+PROCEDURE cmsGetHeaderProfileID(hProfile: cmsHPROFILE; ProfileID: LPcmsUInt8Number); StdCall;
+
+// TODO:
+// FUNCTION cmsGetHeaderCreationDateTime(hProfile: cmsHPROFILE; struct tm *Dest): cmsBool; StdCall;
+
+FUNCTION cmsGetHeaderRenderingIntent(hProfile: cmsHPROFILE): cmsUInt32Number; StdCall;
+PROCEDURE cmsSetHeaderFlags(hProfile: cmsHPROFILE; Flags: cmsUInt32Number); StdCall;
+FUNCTION cmsGetHeaderManufacturer(hProfile: cmsHPROFILE): cmsUInt32Number; StdCall;
+PROCEDURE cmsSetHeaderManufacturer(hProfile: cmsHPROFILE; manufacturer: cmsUInt32Number ); StdCall;
+FUNCTION cmsGetHeaderModel(hProfile: cmsHPROFILE): cmsUInt32Number; StdCall;
+PROCEDURE cmsSetHeaderModel(hProfile: cmsHPROFILE; model: cmsUInt32Number ); StdCall;
+PROCEDURE cmsSetHeaderAttributes(hProfile: cmsHPROFILE; Flags: cmsUInt64Number); StdCall;
+PROCEDURE cmsSetHeaderProfileID(hProfile: cmsHPROFILE; ProfileID: LPcmsUInt8Number); StdCall;
+PROCEDURE cmsSetHeaderRenderingIntent(hProfile: cmsHPROFILE; RenderingIntent: cmsUInt32Number ); StdCall;
+
+FUNCTION cmsGetPCS(hProfile: cmsHPROFILE):cmsColorSpaceSignature; StdCall;
+PROCEDURE cmsSetPCS(hProfile: cmsHPROFILE; pcs: cmsColorSpaceSignature); StdCall;
+FUNCTION cmsGetColorSpace(hProfile: cmsHPROFILE): cmsColorSpaceSignature; StdCall;
+PROCEDURE cmsSetColorSpace(hProfile: cmsHPROFILE; sig: cmsColorSpaceSignature); StdCall;
+FUNCTION cmsGetDeviceClass(hProfile: cmsHPROFILE): cmsProfileClassSignature; StdCall;
+PROCEDURE cmsSetDeviceClass(hProfile: cmsHPROFILE; sig: cmsProfileClassSignature); StdCall;
+PROCEDURE cmsSetProfileVersion(hProfile: cmsHPROFILE; Version: cmsFloat64Number); StdCall;
+FUNCTION cmsGetProfileVersion(hProfile: cmsHPROFILE): cmsFloat64Number; StdCall;
+
+FUNCTION cmsGetEncodedICCversion(hProfile: cmsHPROFILE): cmsUInt32Number; StdCall;
+PROCEDURE cmsSetEncodedICCversion(hProfile: cmsHPROFILE; Version: cmsUInt32Number); StdCall;
+
+
+Const
+
+ // How profiles may be used
+ LCMS_USED_AS_INPUT = 0;
+ LCMS_USED_AS_OUTPUT = 1;
+ LCMS_USED_AS_PROOF = 2;
+
+FUNCTION cmsIsIntentSupported(hProfile: cmsHPROFILE; Intent: cmsUInt32Number; UsedDirection: cmsUInt32Number): cmsBool; StdCall;
+FUNCTION cmsIsMatrixShaper(hProfile: cmsHPROFILE): cmsBool; StdCall;
+FUNCTION cmsIsCLUT(hProfile: cmsHPROFILE; Intent: cmsUInt32Number; UsedDirection: cmsUInt32Number): cmsBool; StdCall;
+
+// Translate form/to our notation to ICC
+FUNCTION _cmsICCcolorSpace(OurNotation: Integer): cmsColorSpaceSignature; StdCall;
+FUNCTION _cmsLCMScolorSpace(ProfileSpace: cmsColorSpaceSignature): Integer; StdCall;
+
+FUNCTION cmsChannelsOf( ColorSpace: cmsColorSpaceSignature): cmsUInt32Number; StdCall;
+
+// Build a suitable formatter for the colorspace of this profile
+FUNCTION cmsFormatterForColorspaceOfProfile(hProfile: cmsHPROFILE; nBytes: cmsUInt32Number; lIsFloat: cmsBool): cmsUInt32Number; StdCall;
+FUNCTION cmsFormatterForPCSOfProfile(hProfile: cmsHPROFILE; nBytes: cmsUInt32Number; lIsFloat: cmsBool): cmsUInt32Number; StdCall;
+
+Type
+
+// Localized info
+cmsInfoType = (
+ cmsInfoDescription = 0,
+ cmsInfoManufacturer = 1,
+ cmsInfoModel = 2,
+ cmsInfoCopyright = 3
+);
+
+FUNCTION cmsGetProfileInfo(hProfile: cmsHPROFILE; Info: cmsInfoType; LanguageCode, CountryCode: PAnsiChar;
+ Buffer: PWChar; BufferSize: cmsUInt32Number): cmsUInt32Number; StdCall;
+
+FUNCTION cmsGetProfileInfoASCII(hProfile: cmsHPROFILE; Info: cmsInfoType; LanguageCode, CountryCode: PAnsiChar;
+ Buffer: PAnsiChar; BufferSize: cmsUInt32Number): cmsUInt32Number; StdCall;
+
+// IO handlers ----------------------------------------------------------------------------------------------------------
+
+Type
+
+LPcmsIOHANDLER = Pointer;
+
+FUNCTION cmsOpenIOhandlerFromFile(ContextID: cmsContext; FileName, AccessMode: PAnsiChar): LPcmsIOHANDLER; StdCall;
+// FUNCTION cmsOpenIOhandlerFromStream(ContextID: cmsContext; FILE* Stream): LPcmsIOHANDLER; StdCall;
+FUNCTION cmsOpenIOhandlerFromMem(ContextID: cmsContext; Buffer: Pointer; size: cmsUInt32Number; AccessMode: PAnsiChar): LPcmsIOHANDLER; StdCall;
+FUNCTION cmsOpenIOhandlerFromNULL(ContextID: cmsContext): LPcmsIOHANDLER; StdCall;
+FUNCTION cmsCloseIOhandler(io: LPcmsIOHANDLER): cmsBool; StdCall;
+
+// MD5 message digest --------------------------------------------------------------------------------------------------
+
+FUNCTION cmsMD5computeID(hProfile: cmsHPROFILE): cmsBool; StdCall;
+
+// Profile high level funtions ------------------------------------------------------------------------------------------
+
+FUNCTION cmsOpenProfileFromFile(ICCProfile : PAnsiChar; sAccess: PAnsiChar): cmsHPROFILE; StdCall;
+FUNCTION cmsOpenProfileFromFileTHR(ContextID: cmsContext; ICCProfile, sAccess: PAnsiChar): cmsHPROFILE; StdCall;
+// FUNCTION CMSEXPORT cmsOpenProfileFromStream(FILE* ICCProfile, const char* sAccess): cmsHPROFILE; StdCall;
+// FUNCTION CMSEXPORT cmsOpenProfileFromStreamTHR(ContextID: cmsContext; FILE* ICCProfile, const char* sAccess): cmsHPROFILE; StdCall;
+FUNCTION cmsOpenProfileFromMem(MemPtr: Pointer; dwSize: cmsUInt32Number): cmsHPROFILE; StdCall;
+FUNCTION cmsOpenProfileFromMemTHR(ContextID: cmsContext; MemPtr: Pointer; dwSize: cmsUInt32Number): cmsHPROFILE; StdCall;
+FUNCTION cmsOpenProfileFromIOhandlerTHR(ContextID: cmsContext; io: LPcmsIOHANDLER): cmsHPROFILE; StdCall;
+FUNCTION cmsCloseProfile(hProfile: cmsHPROFILE): cmsBool; StdCall;
+
+FUNCTION cmsSaveProfileToFile(hProfile: cmsHPROFILE; FileName: PAnsiChar): cmsBool; StdCall;
+// FUNCTION CMSEXPORT cmsSaveProfileToStream(hProfile: cmsHPROFILE, FILE* Stream): cmsBool; StdCall;
+FUNCTION cmsSaveProfileToMem(hProfile: cmsHPROFILE; MemPtr: Pointer; BytesNeeded: LPcmsUInt32Number): cmsBool; StdCall;
+FUNCTION cmsSaveProfileToIOhandler(hProfile: cmsHPROFILE; io: LPcmsIOHANDLER):cmsUInt32Number; StdCall;
+
+// Predefined virtual profiles ------------------------------------------------------------------------------------------
+
+FUNCTION cmsCreateRGBProfileTHR(ContextID: cmsContext;
+ WhitePoint: LPcmsCIExyY;
+ Primaries: LPcmsCIExyYTRIPLE;
+ TransferFunction: LPLPcmsToneCurveArray): cmsHPROFILE; StdCall;
+
+FUNCTION cmsCreateRGBProfile(WhitePoint: LPcmsCIExyY;
+ Primaries: LPcmsCIExyYTRIPLE;
+ TransferFunction: LPLPcmsToneCurveArray): cmsHPROFILE; StdCall;
+
+FUNCTION cmsCreateGrayProfileTHR(ContextID: cmsContext;
+ WhitePoint: LPcmsCIExyY;
+ TransferFunction: LPcmsToneCurve): cmsHPROFILE; StdCall;
+
+FUNCTION cmsCreateGrayProfile(WhitePoint: LPcmsCIExyY;
+ TransferFunction: LPcmsToneCurve): cmsHPROFILE; StdCall;
+
+FUNCTION cmsCreateLinearizationDeviceLinkTHR(ContextID: cmsContext;
+ ColorSpace: cmsColorSpaceSignature;
+ TransferFunctions: LPLPcmsToneCurveArray): cmsHPROFILE; StdCall;
+
+FUNCTION cmsCreateLinearizationDeviceLink(ColorSpace: cmsColorSpaceSignature;
+ TransferFunctions: LPLPcmsToneCurveArray): cmsHPROFILE; StdCall;
+
+FUNCTION cmsCreateInkLimitingDeviceLinkTHR(ContextID: cmsContext;
+ ColorSpace: cmsColorSpaceSignature; Limit: cmsFloat64Number): cmsHPROFILE; StdCall;
+
+FUNCTION cmsCreateInkLimitingDeviceLink(ColorSpace: cmsColorSpaceSignature; Limit: cmsFloat64Number): cmsHPROFILE; StdCall;
+
+
+FUNCTION cmsCreateLab2ProfileTHR(ContextID: cmsContext; WhitePoint: LPcmsCIExyY): cmsHPROFILE; StdCall;
+FUNCTION cmsCreateLab2Profile(WhitePoint: LPcmsCIExyY): cmsHPROFILE; StdCall;
+FUNCTION cmsCreateLab4ProfileTHR(ContextID: cmsContext; WhitePoint: LPcmsCIExyY): cmsHPROFILE; StdCall;
+FUNCTION cmsCreateLab4Profile(WhitePoint: LPcmsCIExyY): cmsHPROFILE; StdCall;
+
+FUNCTION cmsCreateXYZProfileTHR(ContextID: cmsContext): cmsHPROFILE; StdCall;
+FUNCTION cmsCreateXYZProfile: cmsHPROFILE; StdCall;
+
+FUNCTION cmsCreate_sRGBProfileTHR(ContextID: cmsContext): cmsHPROFILE; StdCall;
+FUNCTION cmsCreate_sRGBProfile: cmsHPROFILE; StdCall;
+
+FUNCTION cmsCreateBCHSWabstractProfileTHR(ContextID: cmsContext;
+ nLUTPoints: Integer;
+ Bright,
+ Contrast,
+ Hue,
+ Saturation: cmsFloat64Number;
+ TempSrc,
+ TempDest: Integer): cmsHPROFILE; StdCall;
+
+FUNCTION cmsCreateBCHSWabstractProfile( nLUTPoints: Integer;
+ Bright,
+ Contrast,
+ Hue,
+ Saturation: cmsFloat64Number;
+ TempSrc,
+ TempDest: Integer): cmsHPROFILE; StdCall;
+
+FUNCTION cmsCreateNULLProfileTHR(ContextID: cmsContext): cmsHPROFILE; StdCall;
+FUNCTION cmsCreateNULLProfile: cmsHPROFILE; StdCall;
+
+// Converts a transform to a devicelink profile
+FUNCTION cmsTransform2DeviceLink(hTransform: cmsHTRANSFORM; Version: cmsFloat64Number; dwFlags: cmsUInt32Number): cmsHPROFILE; StdCall;
+
+// Intents ----------------------------------------------------------------------------------------------
+
+Const
+
+// ICC Intents
+INTENT_PERCEPTUAL = 0;
+INTENT_RELATIVE_COLORIMETRIC = 1;
+INTENT_SATURATION = 2;
+INTENT_ABSOLUTE_COLORIMETRIC = 3;
+
+// Non-ICC intents
+INTENT_PRESERVE_K_ONLY_PERCEPTUAL = 10;
+INTENT_PRESERVE_K_ONLY_RELATIVE_COLORIMETRIC = 11;
+INTENT_PRESERVE_K_ONLY_SATURATION = 12;
+INTENT_PRESERVE_K_PLANE_PERCEPTUAL = 13;
+INTENT_PRESERVE_K_PLANE_RELATIVE_COLORIMETRIC = 14;
+INTENT_PRESERVE_K_PLANE_SATURATION = 15;
+
+Type
+LPPAnsiChar = ^PAnsiChar;
+
+// Call with NULL as parameters to get the intent count
+FUNCTION cmsGetSupportedIntents(nMax: cmsUInt32Number; Codes: LPcmsUInt32Number; Descriptions: LPPAnsiChar): cmsUInt32Number; StdCall;
+
+Const
+
+// Flags
+
+cmsFLAGS_NOCACHE = $0040; // Inhibit 1-pixel cache
+cmsFLAGS_NOOPTIMIZE = $0100; // Inhibit optimizations
+cmsFLAGS_NULLTRANSFORM = $0200; // Don't transform anyway
+
+// Proofing flags
+cmsFLAGS_GAMUTCHECK = $1000; // Out of Gamut alarm
+cmsFLAGS_SOFTPROOFING = $4000; // Do softproofing
+
+// Misc
+cmsFLAGS_BLACKPOINTCOMPENSATION = $2000;
+cmsFLAGS_NOWHITEONWHITEFIXUP = $0004; // Don't fix scum dot
+cmsFLAGS_HIGHRESPRECALC = $0400; // Use more memory to give better accurancy
+cmsFLAGS_LOWRESPRECALC = $0800; // Use less memory to minimize resouces
+
+// For devicelink creation
+cmsFLAGS_8BITS_DEVICELINK = $0008; // Create 8 bits devicelinks
+cmsFLAGS_GUESSDEVICECLASS = $0020; // Guess device class (for transform2devicelink)
+cmsFLAGS_KEEP_SEQUENCE = $0080; // Keep profile sequence for devicelink creation
+
+// Specific to a particular optimizations
+cmsFLAGS_FORCE_CLUT = $0002; // Force CLUT optimization
+cmsFLAGS_CLUT_POST_LINEARIZATION = $0001; // create postlinearization tables if possible
+cmsFLAGS_CLUT_PRE_LINEARIZATION = $0010; // create prelinearization tables if possible
+
+// CRD special
+cmsFLAGS_NODEFAULTRESOURCEDEF = $01000000;
+
+// Fine-tune control over number of gridpoints
+FUNCTION cmsFLAGS_GRIDPOINTS(n: Integer): Integer;
+
+
+// Transforms ---------------------------------------------------------------------------------------------------
+
+type
+ LPcmsHPROFILEArray = ^cmsHPROFILEArray;
+ cmsHPROFILEArray = array[0..0] of cmsHPROFILE;
+
+ LPcmsBoolArray = ^cmsBoolArray;
+ cmsBoolArray = array[0..0] of cmsBool;
+
+FUNCTION cmsCreateTransformTHR(ContextID: cmsContext;
+ Input: cmsHPROFILE;
+ InputFormat: cmsUInt32Number;
+ Output: cmsHPROFILE;
+ OutputFormat: cmsUInt32Number;
+ Intent: cmsUInt32Number;
+ dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall;
+
+FUNCTION cmsCreateTransform(Input: cmsHPROFILE;
+ InputFormat: cmsUInt32Number;
+ Output: cmsHPROFILE;
+ OutputFormat: cmsUInt32Number;
+ Intent: cmsUInt32Number;
+ dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall;
+
+FUNCTION cmsCreateProofingTransformTHR(ContextID: cmsContext;
+ Input: cmsHPROFILE;
+ InputFormat: cmsUInt32Number;
+ Output: cmsHPROFILE;
+ OutputFormat: cmsUInt32Number;
+ Proofing: cmsHPROFILE;
+ Intent: cmsUInt32Number;
+ ProofingIntent: cmsUInt32Number;
+ dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall;
+
+FUNCTION cmsCreateProofingTransform(Input: cmsHPROFILE;
+ InputFormat: cmsUInt32Number;
+ Output: cmsHPROFILE;
+ OutputFormat: cmsUInt32Number;
+ Proofing: cmsHPROFILE;
+ Intent: cmsUInt32Number;
+ ProofingIntent: cmsUInt32Number;
+ dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall;
+
+FUNCTION cmsCreateMultiprofileTransformTHR(ContextID: cmsContext;
+ hProfiles: LPcmsHPROFILEArray;
+ nProfiles: cmsUInt32Number;
+ InputFormat: cmsUInt32Number;
+ OutputFormat: cmsUInt32Number;
+ Intent: cmsUInt32Number;
+ dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall;
+
+
+FUNCTION cmsCreateMultiprofileTransform( hProfiles: LPcmsHPROFILEArray;
+ nProfiles: cmsUInt32Number;
+ InputFormat: cmsUInt32Number;
+ OutputFormat: cmsUInt32Number;
+ Intent: cmsUInt32Number;
+ dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall;
+
+
+FUNCTION cmsCreateExtendedTransform(ContextID: cmsContext;
+ nProfiles: cmsUInt32Number;
+ hProfiles: LPcmsHPROFILEArray;
+ BPC: LPcmsBoolArray;
+ Intents: LPcmsUInt32NumberArray;
+ AdaptationStates: LPcmsFloat64NumberArray;
+ hGamutProfile: cmsHPROFILE;
+ nGamutPCSposition: cmsUInt32Number;
+ InputFormat,
+ OutputFormat: cmsUInt32Number;
+ dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall;
+
+PROCEDURE cmsDeleteTransform(hTransform: cmsHTRANSFORM); StdCall;
+
+PROCEDURE cmsDoTransform(Transform: cmsHTRANSFORM; InputBuffer, OutputBuffer: Pointer; size: cmsUInt32Number); StdCall;
+
+PROCEDURE cmsSetAlarmCodes( NewAlarm: LPcmsUInt16NumberArray); StdCall;
+PROCEDURE cmsGetAlarmCodes(NewAlarm: LPcmsUInt16NumberArray); StdCall;
+
+// Adaptation state for absolute colorimetric intent
+FUNCTION cmsSetAdaptationState(d: cmsFloat64Number):cmsFloat64Number; StdCall;
+
+// Grab the ContextID from an open transform. Returns NULL if a NULL transform is passed
+FUNCTION cmsGetTransformContextID(hTransform: cmsHTRANSFORM):cmsContext; StdCall;
+
+// For backwards compatibility
+FUNCTION cmsChangeBuffersFormat(hTransform: cmsHTRANSFORM; InputFormat, OutputFormat: cmsUInt32Number): cmsBool; StdCall;
+
+
+
+// PostScript ColorRenderingDictionary and ColorSpaceArray ----------------------------------------------------
+
+Type
+
+cmsPSResourceType = (cmsPS_RESOURCE_CSA, cmsPS_RESOURCE_CRD ) ;
+
+// lcms2 unified method to access postscript color resources
+FUNCTION cmsGetPostScriptColorResource(ContextID: cmsContext; RType: cmsPSResourceType;
+ hProfile: cmsHPROFILE;
+ Intent: cmsUInt32Number;
+ dwFlags: cmsUInt32Number;
+ io: LPcmsIOHANDLER): cmsUInt32Number; StdCall;
+
+FUNCTION cmsGetPostScriptCSA(ContextID: cmsContext; hProfile: cmsHPROFILE; Intent: cmsUInt32Number; dwFlags: cmsUInt32Number; Buffer: Pointer; dwBufferLen: cmsUInt32Number ): cmsUInt32Number; StdCall;
+FUNCTION cmsGetPostScriptCRD(ContextID: cmsContext; hProfile: cmsHPROFILE; Intent: cmsUInt32Number; dwFlags: cmsUInt32Number; Buffer: Pointer; dwBufferLen: cmsUInt32Number): cmsUInt32Number; StdCall;
+
+
+// IT8.7 / CGATS.17-20$ handling -----------------------------------------------------------------------------
+
+
+// CGATS.13 parser
+
+FUNCTION cmsIT8Alloc: cmsHANDLE; StdCall;
+PROCEDURE cmsIT8Free(hIT8: cmsHANDLE); StdCall;
+
+// Tables
+
+FUNCTION cmsIT8TableCount(hIT8: cmsHANDLE): Integer; StdCall;
+FUNCTION cmsIT8SetTable(hIT8: cmsHANDLE; nTable: Integer): Integer; StdCall;
+
+// Persistence
+FUNCTION cmsIT8LoadFromFile(cFileName: PAnsiChar): cmsHANDLE; StdCall;
+FUNCTION cmsIT8LoadFromMem(Ptr: Pointer; size :DWord): cmsHANDLE; StdCall;
+
+FUNCTION cmsIT8SaveToFile(hIT8: cmsHANDLE; cFileName: PAnsiChar): cmsBool; StdCall;
+FUNCTION cmsIT8SaveToMem(hIT8: cmsHANDLE; MemPtr: Pointer; BytesNeeded: LPcmsUInt32Number): cmsBool; StdCall;
+// Properties
+
+FUNCTION cmsIT8GetSheetType(hIT8: cmsHANDLE): PAnsiChar; StdCall;
+FUNCTION cmsIT8SetSheetType(hIT8: cmsHANDLE; TheType: PAnsiChar): cmsBool; StdCall;
+
+FUNCTION cmsIT8SetComment(hIT8: cmsHANDLE; cComment: PAnsiChar): cmsBool; StdCall;
+
+FUNCTION cmsIT8SetPropertyStr(hIT8: cmsHANDLE; cProp, Str: PAnsiChar): cmsBool; StdCall;
+FUNCTION cmsIT8SetPropertyDbl(hIT8: cmsHANDLE; cProp: PAnsiChar; Val: Double): cmsBool; StdCall;
+FUNCTION cmsIT8SetPropertyHex(hIT8: cmsHANDLE; cProp: PAnsiChar; Val: Integer): cmsBool; StdCall;
+FUNCTION cmsIT8SetPropertyUncooked(hIT8: cmsHANDLE; Key, Buffer: PAnsiChar): cmsBool; StdCall;
+
+
+FUNCTION cmsIT8GetProperty(hIT8: cmsHANDLE; cProp: PAnsiChar): PAnsiChar; StdCall;
+FUNCTION cmsIT8GetPropertyDbl(hIT8: cmsHANDLE; cProp: PAnsiChar): Double; StdCall;
+FUNCTION cmsIT8EnumProperties(hIT8: cmsHANDLE; var PropertyNames: LPPAnsiChar): Integer; StdCall;
+
+// Datasets
+
+FUNCTION cmsIT8GetDataRowCol(hIT8: cmsHANDLE; row, col: Integer): PAnsiChar; StdCall;
+FUNCTION cmsIT8GetDataRowColDbl(hIT8: cmsHANDLE; row, col: Integer): Double; StdCall;
+
+FUNCTION cmsIT8SetDataRowCol(hIT8: cmsHANDLE; row, col: Integer; Val: PAnsiChar): cmsBool; StdCall;
+FUNCTION cmsIT8SetDataRowColDbl(hIT8: cmsHANDLE; row, col: Integer; Val: Double): cmsBool; StdCall;
+
+FUNCTION cmsIT8GetData(hIT8: cmsHANDLE; cPatch, cSample: PAnsiChar): PAnsiChar; StdCall;
+
+FUNCTION cmsIT8GetDataDbl(hIT8: cmsHANDLE;cPatch, cSample: PAnsiChar): Double; StdCall;
+
+FUNCTION cmsIT8SetData(hIT8: cmsHANDLE; cPatch, cSample, Val: PAnsiChar): cmsBool; StdCall;
+
+FUNCTION cmsIT8SetDataDbl(hIT8: cmsHANDLE; cPatch, cSample: PAnsiChar; Val: Double): cmsBool; StdCall;
+
+FUNCTION cmsIT8SetDataFormat(hIT8: cmsHANDLE; n: Integer; Sample: PAnsiChar): cmsBool; StdCall;
+FUNCTION cmsIT8EnumDataFormat(hIT8: cmsHANDLE; var SampleNames: LPPAnsiChar): Integer; StdCall;
+FUNCTION cmsIT8GetPatchName(hIT8: cmsHANDLE; nPatch: Integer; Buffer: PAnsiChar): PAnsiChar; StdCall;
+
+// The LABEL extension
+FUNCTION cmsIT8SetTableByLabel(hIT8: cmsHANDLE; cSet, cField, ExpectedType: PAnsiChar): Integer; StdCall;
+
+FUNCTION cmsIT8FindDataFormat(hIT8: cmsHANDLE; cSample: PAnsiChar): Integer; StdCall;
+
+// Formatter for double
+PROCEDURE cmsIT8DefineDblFormat(hIT8: cmsHANDLE; Formatter: PAnsiChar); StdCall;
+
+// Gamut boundary description routines ------------------------------------------------------------------------------
+
+FUNCTION cmsGBDAlloc(ContextID: cmsContext):cmsHANDLE; StdCall;
+PROCEDURE cmsGBDFree(hGBD: cmsHANDLE); StdCall;
+FUNCTION cmsGDBAddPoint(hGBD: cmsHANDLE; Lab: LPcmsCIELab): cmsBool; StdCall;
+FUNCTION cmsGDBCompute(hGDB: cmsHANDLE; dwFlags: cmsUInt32Number): cmsBool; StdCall;
+FUNCTION cmsGDBCheckPoint(hGBD: cmsHANDLE; Lab: LPcmsCIELab): cmsBool; StdCall;
+
+// Feature detection ----------------------------------------------------------------------------------------------
+
+// Estimate the black point
+FUNCTION cmsDetectBlackPoint( BlackPoint: LPcmsCIEXYZ; hProfile: cmsHPROFILE; Intent: cmsUInt32Number; dwFlags: cmsUInt32Number): cmsBool; StdCall;
+FUNCTION cmsDetectDestinationBlackPoint( BlackPoint: LPcmsCIEXYZ; hProfile: cmsHPROFILE; Intent: cmsUInt32Number; dwFlags: cmsUInt32Number): cmsBool; StdCall;
+
+
+// Estimate total area coverage
+FUNCTION cmsDetectTAC(hProfile: cmsHPROFILE): cmsFloat64Number; StdCall;
+
+
+// Poor man's gamut mapping
+FUNCTION cmsDesaturateLab(Lab: LPcmsCIELab; amax, amin, bmax, bmin: cmsFloat64Number): cmsBool; StdCall;
+
+
+IMPLEMENTATION
+
+
+
+ FUNCTION FLOAT_SH(a: cmsUInt32Number): cmsUInt32Number; begin FLOAT_SH := ((a) shl 22) end;
+ FUNCTION OPTIMIZED_SH(s: cmsUInt32Number): cmsUInt32Number; begin OPTIMIZED_SH := ((s) shl 21) end;
+ FUNCTION COLORSPACE_SH(s: cmsUInt32Number):cmsUInt32Number; begin COLORSPACE_SH := ((s) shl 16) end;
+ FUNCTION SWAPFIRST_SH(s: cmsUInt32Number):cmsUInt32Number; begin SWAPFIRST_SH := ((s) shl 14) end;
+ FUNCTION FLAVOR_SH(s: cmsUInt32Number):cmsUInt32Number; begin FLAVOR_SH := ((s) shl 13) end;
+ FUNCTION PLANAR_SH(p: cmsUInt32Number):cmsUInt32Number; begin PLANAR_SH := ((p) shl 12) end;
+ FUNCTION ENDIAN16_SH(e: cmsUInt32Number):cmsUInt32Number; begin ENDIAN16_SH := ((e) shl 11) end;
+ FUNCTION DOSWAP_SH(e: cmsUInt32Number):cmsUInt32Number; begin DOSWAP_SH := ((e) shl 10) end;
+ FUNCTION EXTRA_SH(e: cmsUInt32Number):cmsUInt32Number; begin EXTRA_SH := ((e) shl 7) end;
+ FUNCTION CHANNELS_SH(c: cmsUInt32Number):cmsUInt32Number; begin CHANNELS_SH := ((c) shl 3) end;
+ FUNCTION BYTES_SH(b: cmsUInt32Number):cmsUInt32Number; begin BYTES_SH := (b) end;
+
+
+ FUNCTION T_FLOAT(a: cmsUInt32Number): cmsUInt32Number; begin T_FLOAT := (((a) shr 22) and 1) end;
+ FUNCTION T_OPTIMIZED(o: cmsUInt32Number): cmsUInt32Number; begin T_OPTIMIZED := (((o) shr 21) and 1) end;
+ FUNCTION T_COLORSPACE(s: cmsUInt32Number): cmsUInt32Number; begin T_COLORSPACE := (((s) shr 16) and 31) end;
+ FUNCTION T_SWAPFIRST(s: cmsUInt32Number): cmsUInt32Number; begin T_SWAPFIRST := (((s) shr 14) and 1) end;
+ FUNCTION T_FLAVOR(s: cmsUInt32Number): cmsUInt32Number; begin T_FLAVOR := (((s) shr 13) and 1) end;
+ FUNCTION T_PLANAR(p: cmsUInt32Number): cmsUInt32Number; begin T_PLANAR := (((p) shr 12) and 1) end;
+ FUNCTION T_ENDIAN16(e: cmsUInt32Number): cmsUInt32Number; begin T_ENDIAN16 := (((e) shr 11) and 1) end;
+ FUNCTION T_DOSWAP(e: cmsUInt32Number): cmsUInt32Number; begin T_DOSWAP := (((e) shr 10) and 1) end;
+ FUNCTION T_EXTRA(e: cmsUInt32Number): cmsUInt32Number; begin T_EXTRA := (((e) shr 7) and 7) end;
+ FUNCTION T_CHANNELS(c: cmsUInt32Number): cmsUInt32Number; begin T_CHANNELS := (((c) shr 3) and 15) end;
+ FUNCTION T_BYTES(b: cmsUInt32Number): cmsUInt32Number; begin T_BYTES := ((b) and 7) end;
+
+
+
+//
+
+
+FUNCTION cmsPlugin(Plugin: Pointer): cmsBool; StdCall; external 'lcms2.dll';
+PROCEDURE cmsUnregisterPlugins; StdCall; external 'lcms2.dll';
+PROCEDURE cmsSetLogErrorHandler(Fn: cmsLogErrorHandlerFunction); StdCall; external 'lcms2.dll';
+FUNCTION cmsD50_XYZ: LPcmsCIEXYZ; StdCall; external 'lcms2.dll';
+FUNCTION cmsD50_xyY: LPcmsCIExyY; StdCall; external 'lcms2.dll';
+PROCEDURE cmsXYZ2xyY(Dest: LPcmsCIExyY; Source: LPcmsCIEXYZ); StdCall; external 'lcms2.dll';
+PROCEDURE cmsxyY2XYZ(Dest: LPcmsCIEXYZ; Source: LPcmsCIExyY); StdCall; external 'lcms2.dll';
+PROCEDURE cmsLab2XYZ(WhitePoint: LPcmsCIEXYZ; xyz: LPcmsCIEXYZ; Lab: LPcmsCIELab); StdCall; external 'lcms2.dll';
+PROCEDURE cmsXYZ2Lab(WhitePoint: LPcmsCIEXYZ; Lab: LPcmsCIELab; xyz: LPcmsCIEXYZ); StdCall; external 'lcms2.dll';
+PROCEDURE cmsLab2LCh(LCh: LPcmsCIELCh; Lab: LPcmsCIELab); StdCall; external 'lcms2.dll';
+PROCEDURE cmsLCh2Lab(Lab: LPcmsCIELab; LCh: LPcmsCIELCh); StdCall; external 'lcms2.dll';
+PROCEDURE cmsLabEncoded2Float(Lab: LPcmsCIELab; wLab: Pointer); StdCall; external 'lcms2.dll';
+PROCEDURE cmsLabEncoded2FloatV2(Lab: LPcmsCIELab; wLab: Pointer); StdCall; external 'lcms2.dll';
+PROCEDURE cmsFloat2LabEncoded(wLab: Pointer; Lab: LPcmsCIELab); StdCall; external 'lcms2.dll';
+PROCEDURE cmsFloat2LabEncodedV2(wLab: Pointer; Lab: LPcmsCIELab); StdCall; external 'lcms2.dll';
+PROCEDURE cmsXYZEncoded2Float(fxyz : LPcmsCIEXYZ; XYZ: Pointer); StdCall; external 'lcms2.dll';
+PROCEDURE cmsFloat2XYZEncoded(XYZ: Pointer; fXYZ: LPcmsCIEXYZ); StdCall; external 'lcms2.dll';
+FUNCTION cmsDeltaE(Lab1, Lab2: LPcmsCIELab): Double; StdCall; external 'lcms2.dll';
+FUNCTION cmsCIE94DeltaE(Lab1, Lab2: LPcmsCIELab): Double; StdCall; external 'lcms2.dll';
+FUNCTION cmsBFDdeltaE(Lab1, Lab2: LPcmsCIELab): Double; StdCall; external 'lcms2.dll';
+FUNCTION cmsCMCdeltaE(Lab1, Lab2: LPcmsCIELab): Double; StdCall; external 'lcms2.dll';
+FUNCTION cmsCIE2000DeltaE(Lab1, Lab2: LPcmsCIELab; Kl, Kc, Kh: Double): Double; StdCall; external 'lcms2.dll';
+FUNCTION cmsWhitePointFromTemp(var WhitePoint: cmsCIExyY; TempK: cmsFloat64Number) : cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsTempFromWhitePoint(var TeampK: cmsFloat64Number; var WhitePoint: cmsCIExyY) : cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsAdaptToIlluminant(Result: LPcmsCIEXYZ; SourceWhitePt: LPcmsCIEXYZ;
+ Illuminant: LPcmsCIEXYZ; Value: LPcmsCIEXYZ): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsCIECAM02Init(pVC : LPcmsViewingConditions ) : Pointer; StdCall; external 'lcms2.dll';
+PROCEDURE cmsCIECAM02Done(hModel : Pointer); StdCall; external 'lcms2.dll';
+PROCEDURE cmsCIECAM02Forward(hModel: Pointer; pIn: LPcmsCIEXYZ; pOut: LPcmsJCh ); StdCall; external 'lcms2.dll';
+PROCEDURE cmsCIECAM02Reverse(hModel: Pointer; pIn: LPcmsJCh; pOut: LPcmsCIEXYZ ); StdCall; external 'lcms2.dll';
+FUNCTION cmsBuildSegmentedToneCurve(ContextID: cmsContext; nSegments: cmsInt32Number; Segments: LPcmsCurveSegmentArray): LPcmsToneCurve; StdCall; external 'lcms2.dll';
+FUNCTION cmsBuildParametricToneCurve(ContextID: cmsContext; CType: cmsInt32Number; Params: LPcmsFloat64NumberArray): LPcmsToneCurve; StdCall; external 'lcms2.dll';
+FUNCTION cmsBuildGamma(ContextID: cmsContext; Gamma: cmsFloat64Number): LPcmsToneCurve; StdCall; external 'lcms2.dll';
+FUNCTION cmsBuildTabulatedToneCurve16(ContextID: cmsContext; nEntries: cmsInt32Number; values: LPcmsUInt16NumberArray): LPcmsToneCurve; StdCall; external 'lcms2.dll';
+FUNCTION cmsBuildTabulatedToneCurveFloat(ContextID: cmsContext; nEntries: cmsUInt32Number; values: LPcmsFloat32NumberArray): LPcmsToneCurve; StdCall; external 'lcms2.dll';
+PROCEDURE cmsFreeToneCurve(Curve: LPcmsToneCurve); StdCall; external 'lcms2.dll';
+PROCEDURE cmsFreeToneCurveTriple(Curve: LPLPcmsToneCurveArray); StdCall; external 'lcms2.dll';
+FUNCTION cmsDupToneCurve(Src: LPcmsToneCurve): LPcmsToneCurve; StdCall; external 'lcms2.dll';
+FUNCTION cmsReverseToneCurve(InGamma: LPcmsToneCurve): LPcmsToneCurve; StdCall; external 'lcms2.dll';
+FUNCTION cmsReverseToneCurveEx(nResultSamples: cmsInt32Number; InGamma: LPcmsToneCurve): LPcmsToneCurve; StdCall; external 'lcms2.dll';
+FUNCTION cmsJoinToneCurve(ContextID: cmsContext; X, Y: LPcmsToneCurve; nPoints: cmsUInt32Number ): LPcmsToneCurve; StdCall; external 'lcms2.dll';
+FUNCTION cmsSmoothToneCurve(Tab: LPcmsToneCurve; lambda: cmsFloat64Number): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsEvalToneCurveFloat(Curve: LPcmsToneCurve; v: cmsFloat32Number):cmsFloat32Number; StdCall; external 'lcms2.dll';
+FUNCTION cmsEvalToneCurve16(Curve: LPcmsToneCurve; v:cmsUInt16Number):cmsUInt16Number; StdCall; external 'lcms2.dll';
+FUNCTION cmsIsToneCurveMultisegment(InGamma: LPcmsToneCurve):cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsIsToneCurveLinear(Curve: LPcmsToneCurve):cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsIsToneCurveMonotonic(t: LPcmsToneCurve):cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsIsToneCurveDescending(t: LPcmsToneCurve):cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsGetToneCurveParametricType(t: LPcmsToneCurve):cmsInt32Number; StdCall; external 'lcms2.dll';
+FUNCTION cmsEstimateGamma(t: LPcmsToneCurve; Precision:cmsFloat64Number):cmsFloat64Number; StdCall; external 'lcms2.dll';
+FUNCTION cmsPipelineAlloc(ContextID: cmsContext; InputChannels, OutputChannels: cmsUInt32Number): LPcmsPipeline; StdCall; external 'lcms2.dll';
+PROCEDURE cmsPipelineFree(lut: LPcmsPipeline); StdCall; external 'lcms2.dll';
+FUNCTION cmsPipelineDup(Orig: LPcmsPipeline): LPcmsPipeline; StdCall; external 'lcms2.dll';
+FUNCTION cmsPipelineInputChannels(lut: LPcmsPipeline): cmsUInt32Number; StdCall; external 'lcms2.dll';
+FUNCTION cmsPipelineOutputChannels(lut: LPcmsPipeline): cmsUInt32Number; StdCall; external 'lcms2.dll';
+FUNCTION cmsPipelineStageCount(lut: LPcmsPipeline): cmsUInt32Number; StdCall; external 'lcms2.dll';
+FUNCTION cmsPipelineGetPtrToFirstStage(lut: LPcmsPipeline): LPcmsStage; StdCall; external 'lcms2.dll';
+FUNCTION cmsPipelineGetPtrToLastStage(lut: LPcmsPipeline): LPcmsStage; StdCall; external 'lcms2.dll';
+
+PROCEDURE cmsPipelineEval16(Inv, Outv: LPcmsUInt16NumberArray; lut: LPcmsPipeline); StdCall; external 'lcms2.dll';
+PROCEDURE cmsPipelineEvalFloat(Inv, Outv: LPcmsFloat32NumberArray; lut: LPcmsPipeline); StdCall; external 'lcms2.dll';
+
+FUNCTION cmsPipelineEvalReverseFloat(Target, Result, Hint: LPcmsFloat32NumberArray; lut: LPcmsPipeline): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsPipelineCat(l1, l2: LPcmsPipeline): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsPipelineSetSaveAs8bitsFlag(lut: LPcmsPipeline; On: cmsBool): cmsBool; StdCall; external 'lcms2.dll';
+PROCEDURE cmsPipelineInsertStage(lut: LPcmsPipeline; loc: cmsStageLoc; mpe: LPcmsStage); StdCall; external 'lcms2.dll';
+PROCEDURE cmsPipelineUnlinkStage(lut: LPcmsPipeline; loc: cmsStageLoc; mpe: LPLPcmsStage); StdCall; external 'lcms2.dll';
+FUNCTION cmsStageAllocIdentity(ContextID: cmsContext; nChannels: cmsUInt32Number): LPcmsStage; StdCall; external 'lcms2.dll';
+FUNCTION cmsStageAllocToneCurves(ContextID: cmsContext; nChannels: cmsUInt32Number; Curves: LPLPcmsToneCurveArray): LPcmsStage; StdCall; external 'lcms2.dll';
+FUNCTION cmsStageAllocMatrix(ContextID: cmsContext; Rows, Cols: cmsUInt32Number; Matrix, Offset: LPcmsFloat64NumberArray): LPcmsStage; StdCall; external 'lcms2.dll';
+FUNCTION cmsStageAllocCLut16bit(ContextID: cmsContext; nGridPoints: cmsUInt32Number; inputChan, outputChan: cmsUInt32Number; Table: LPcmsUInt16NumberArray): LPcmsStage; StdCall; external 'lcms2.dll';
+FUNCTION cmsStageAllocCLutFloat(ContextID: cmsContext; nGridPoints: cmsUInt32Number; inputChan, outputChan: cmsUInt32Number; Table: LPcmsFloat32NumberArray): LPcmsStage; StdCall; external 'lcms2.dll';
+FUNCTION cmsStageAllocCLut16bitGranular(ContextID: cmsContext; nGridPoints: LPcmsUInt32NumberArray; inputChan, outputChan: cmsUInt32Number; Table: LPcmsUInt16NumberArray): LPcmsStage; StdCall; external 'lcms2.dll';
+FUNCTION cmsStageAllocCLutFloatGranular(ContextID: cmsContext; nGridPoints: LPcmsUInt32NumberArray; inputChan, outputChan: cmsUInt32Number; Table: LPcmsFloat32NumberArray): LPcmsStage; StdCall; external 'lcms2.dll';
+FUNCTION cmsStageDup(mpe: LPcmsStage): LPcmsStage; StdCall; external 'lcms2.dll';
+PROCEDURE cmsStageFree(mpe: LPcmsStage); StdCall; external 'lcms2.dll';
+FUNCTION cmsStageNext(mpe: LPcmsStage): LPcmsStage; StdCall; external 'lcms2.dll';
+FUNCTION cmsStageInputChannels(mpe: LPcmsStage): cmsUInt32Number; StdCall; external 'lcms2.dll';
+FUNCTION cmsStageOutputChannels(mpe: LPcmsStage): cmsUInt32Number; StdCall; external 'lcms2.dll';
+FUNCTION cmsStageType(mpe: LPcmsStage): cmsStageSignature; StdCall; external 'lcms2.dll';
+FUNCTION cmsStageData(mpe: LPcmsStage): Pointer; StdCall; external 'lcms2.dll';
+FUNCTION cmsStageSampleCLut16bit(mpe: LPcmsStage; Sampler: cmsSAMPLER16; Cargo: Pointer; dwFlags: cmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsStageSampleCLutFloat(mpe: LPcmsStage; Sampler: cmsSAMPLERFLOAT; Cargo: Pointer; dwFlags: cmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsSliceSpace16(nInputs: cmsUInt32Number; clutPoints: LPcmsUInt32NumberArray;
+ Sampler: cmsSAMPLER16; Cargo: Pointer): cmsBool; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsSliceSpaceFloat(nInputs: cmsUInt32Number; clutPoints: LPcmsUInt32NumberArray;
+ Sampler: cmsSAMPLERFLOAT; Cargo: Pointer): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsMLUalloc(ContextID: cmsContext; nItems: cmsUInt32Number): LPcmsMLU; StdCall; external 'lcms2.dll';
+PROCEDURE cmsMLUfree(mlu: LPcmsMLU); StdCall; external 'lcms2.dll';
+FUNCTION cmsMLUdup(mlu: LPcmsMLU): LPcmsMLU; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsMLUsetASCII(mlu: LPcmsMLU; LanguageCode, CountryCode, ASCIIString: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsMLUsetWide(mlu: LPcmsMLU; LanguageCode, CountryCode: PAnsiChar; WideString: PWChar): cmsBool; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsMLUgetASCII(mlu: LPcmsMLU; LanguageCode, CountryCode: PAnsiChar; Buffer: PAnsiChar; BufferSize: cmsUInt32Number): cmsUInt32Number; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsMLUgetWide(mlu: LPcmsMLU; LanguageCode, CountryCode: PAnsiChar; Buffer: PWChar; BufferSize: cmsUInt32Number): cmsUInt32Number; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsMLUgetTranslation(mlu: LPcmsMLU; LanguageCode, CountryCode, ObtainedLanguage, ObtainedCountry: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsAllocNamedColorList(ContextID: cmsContext; n, ColorantCount :cmsUInt32Number;
+ Prefix, Suffix: PAnsiChar): LPcmsNAMEDCOLORLIST; StdCall; external 'lcms2.dll';
+
+PROCEDURE cmsFreeNamedColorList(v: LPcmsNAMEDCOLORLIST); StdCall; external 'lcms2.dll';
+FUNCTION cmsDupNamedColorList(v: LPcmsNAMEDCOLORLIST): LPcmsNAMEDCOLORLIST; StdCall; external 'lcms2.dll';
+FUNCTION cmsAppendNamedColor(v: LPcmsNAMEDCOLORLIST; Name: PAnsiChar;
+ PCS, Colorant : LPcmsUInt16NumberArray): cmsBool; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsNamedColorCount(v: LPcmsNAMEDCOLORLIST): cmsUInt32Number; StdCall; external 'lcms2.dll';
+FUNCTION cmsNamedColorIndex(v: LPcmsNAMEDCOLORLIST; Name: PAnsiChar): cmsInt32Number; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsNamedColorInfo(v: LPcmsNAMEDCOLORLIST; nColor : cmsUInt32Number;
+ Name,Prefix, Suffix : PAnsiChar;
+ PCS, Colorant : LPcmsUInt16NumberArray): cmsBool; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsGetNamedColorList(xform: cmsHTRANSFORM ): LPcmsNAMEDCOLORLIST; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsAllocProfileSequenceDescription(ContextID: cmsContext; n: cmsUInt32Number):LPcmsSEQ; StdCall; external 'lcms2.dll';
+FUNCTION cmsDupProfileSequenceDescription(pseq: LPcmsSEQ):LPcmsSEQ; StdCall; external 'lcms2.dll';
+PROCEDURE cmsFreeProfileSequenceDescription(pseq: LPcmsSEQ); StdCall; external 'lcms2.dll';
+
+FUNCTION cmsDictAlloc(ContextID: cmsContext): cmsHANDLE; StdCall; external 'lcms2.dll';
+PROCEDURE cmsDictFree(hDict: cmsHANDLE); StdCall; external 'lcms2.dll';
+FUNCTION cmsDictDup(hDict: cmsHANDLE): cmsHANDLE; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsDictAddEntry(hDict: cmsHANDLE; Name, Value: PWChar; DisplayName, DisplayValue : LPcmsMLU): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsDictGetEntryList(hDict: cmsHANDLE): LPcmsDICTentry; StdCall; external 'lcms2.dll';
+FUNCTION cmsDictNextEntry(e : LPcmsDICTentry): LPcmsDICTentry; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsCreateProfilePlaceholder(ContextID: cmsContext): cmsHPROFILE; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsGetProfileContextID(hProfile: cmsHPROFILE):cmsContext; StdCall; external 'lcms2.dll';
+FUNCTION cmsGetTagCount(hProfile: cmsHPROFILE): cmsInt32Number; StdCall; external 'lcms2.dll';
+FUNCTION cmsGetTagSignature(hProfile: cmsHPROFILE; n: cmsUInt32Number): cmsTagSignature; StdCall; external 'lcms2.dll';
+FUNCTION cmsIsTag(hProfile: cmsHPROFILE; sig: cmsTagSignature ): cmsBool; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsReadTag(hProfile: cmsHPROFILE; sig: cmsTagSignature ): Pointer; StdCall; external 'lcms2.dll';
+FUNCTION cmsWriteTag(hProfile: cmsHPROFILE; sig: cmsTagSignature; data: Pointer): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsLinkTag(hProfile: cmsHPROFILE; sig: cmsTagSignature; dest: cmsTagSignature): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsTagLinkedTo(hProfile: cmsHPROFILE; sig: cmsTagSignature):cmsTagSignature; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsReadRawTag(hProfile: cmsHPROFILE; sig: cmsTagSignature; Buffer: Pointer; BufferSize: cmsUInt32Number): cmsInt32Number; StdCall; external 'lcms2.dll';
+FUNCTION cmsWriteRawTag(hProfile: cmsHPROFILE; sig: cmsTagSignature; data: Pointer; Size: cmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsGetHeaderFlags(hProfile: cmsHPROFILE): cmsUInt32Number; StdCall; external 'lcms2.dll';
+PROCEDURE cmsGetHeaderAttributes(hProfile: cmsHPROFILE; Flags: LPcmsUInt64Number); StdCall; external 'lcms2.dll';
+PROCEDURE cmsGetHeaderProfileID(hProfile: cmsHPROFILE; ProfileID: LPcmsUInt8Number); StdCall; external 'lcms2.dll';
+
+FUNCTION cmsGetHeaderRenderingIntent(hProfile: cmsHPROFILE): cmsUInt32Number; StdCall; external 'lcms2.dll';
+PROCEDURE cmsSetHeaderFlags(hProfile: cmsHPROFILE; Flags: cmsUInt32Number); StdCall; external 'lcms2.dll';
+FUNCTION cmsGetHeaderManufacturer(hProfile: cmsHPROFILE): cmsUInt32Number; StdCall; external 'lcms2.dll';
+PROCEDURE cmsSetHeaderManufacturer(hProfile: cmsHPROFILE; manufacturer: cmsUInt32Number ); StdCall; external 'lcms2.dll';
+FUNCTION cmsGetHeaderModel(hProfile: cmsHPROFILE): cmsUInt32Number; StdCall; external 'lcms2.dll';
+PROCEDURE cmsSetHeaderModel(hProfile: cmsHPROFILE; model: cmsUInt32Number ); StdCall; external 'lcms2.dll';
+PROCEDURE cmsSetHeaderAttributes(hProfile: cmsHPROFILE; Flags: cmsUInt64Number); StdCall; external 'lcms2.dll';
+PROCEDURE cmsSetHeaderProfileID(hProfile: cmsHPROFILE; ProfileID: LPcmsUInt8Number); StdCall; external 'lcms2.dll';
+PROCEDURE cmsSetHeaderRenderingIntent(hProfile: cmsHPROFILE; RenderingIntent: cmsUInt32Number ); StdCall; external 'lcms2.dll';
+
+FUNCTION cmsGetPCS(hProfile: cmsHPROFILE):cmsColorSpaceSignature; StdCall; external 'lcms2.dll';
+PROCEDURE cmsSetPCS(hProfile: cmsHPROFILE; pcs: cmsColorSpaceSignature); StdCall; external 'lcms2.dll';
+FUNCTION cmsGetColorSpace(hProfile: cmsHPROFILE): cmsColorSpaceSignature; StdCall; external 'lcms2.dll';
+PROCEDURE cmsSetColorSpace(hProfile: cmsHPROFILE; sig: cmsColorSpaceSignature); StdCall; external 'lcms2.dll';
+FUNCTION cmsGetDeviceClass(hProfile: cmsHPROFILE): cmsProfileClassSignature; StdCall; external 'lcms2.dll';
+PROCEDURE cmsSetDeviceClass(hProfile: cmsHPROFILE; sig: cmsProfileClassSignature); StdCall; external 'lcms2.dll';
+PROCEDURE cmsSetProfileVersion(hProfile: cmsHPROFILE; Version: cmsFloat64Number); StdCall; external 'lcms2.dll';
+FUNCTION cmsGetProfileVersion(hProfile: cmsHPROFILE): cmsFloat64Number; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsGetEncodedICCversion(hProfile: cmsHPROFILE): cmsUInt32Number; StdCall; external 'lcms2.dll';
+PROCEDURE cmsSetEncodedICCversion(hProfile: cmsHPROFILE; Version: cmsUInt32Number); StdCall; external 'lcms2.dll';
+
+
+FUNCTION cmsIsIntentSupported(hProfile: cmsHPROFILE; Intent: cmsUInt32Number; UsedDirection: cmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsIsMatrixShaper(hProfile: cmsHPROFILE): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsIsCLUT(hProfile: cmsHPROFILE; Intent: cmsUInt32Number; UsedDirection: cmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION _cmsICCcolorSpace(OurNotation: Integer): cmsColorSpaceSignature; StdCall; external 'lcms2.dll';
+FUNCTION _cmsLCMScolorSpace(ProfileSpace: cmsColorSpaceSignature): Integer; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsChannelsOf( ColorSpace: cmsColorSpaceSignature): cmsUInt32Number; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsFormatterForColorspaceOfProfile(hProfile: cmsHPROFILE; nBytes: cmsUInt32Number; lIsFloat: cmsBool): cmsUInt32Number; StdCall; external 'lcms2.dll';
+FUNCTION cmsFormatterForPCSOfProfile(hProfile: cmsHPROFILE; nBytes: cmsUInt32Number; lIsFloat: cmsBool): cmsUInt32Number; StdCall; external 'lcms2.dll';
+
+
+FUNCTION cmsGetProfileInfo(hProfile: cmsHPROFILE; Info: cmsInfoType; LanguageCode, CountryCode: PAnsiChar;
+ Buffer: PWChar; BufferSize: cmsUInt32Number): cmsUInt32Number; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsGetProfileInfoASCII(hProfile: cmsHPROFILE; Info: cmsInfoType; LanguageCode, CountryCode: PAnsiChar;
+ Buffer: PAnsiChar; BufferSize: cmsUInt32Number): cmsUInt32Number; StdCall; external 'lcms2.dll';
+
+
+FUNCTION cmsOpenIOhandlerFromFile(ContextID: cmsContext; FileName, AccessMode: PAnsiChar): LPcmsIOHANDLER; StdCall; external 'lcms2.dll';
+// FUNCTION cmsOpenIOhandlerFromStream(ContextID: cmsContext; FILE* Stream): LPcmsIOHANDLER; StdCall; external 'lcms2.dll';
+FUNCTION cmsOpenIOhandlerFromMem(ContextID: cmsContext; Buffer: Pointer; size: cmsUInt32Number; AccessMode: PAnsiChar): LPcmsIOHANDLER; StdCall; external 'lcms2.dll';
+FUNCTION cmsOpenIOhandlerFromNULL(ContextID: cmsContext): LPcmsIOHANDLER; StdCall; external 'lcms2.dll';
+FUNCTION cmsCloseIOhandler(io: LPcmsIOHANDLER): cmsBool; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsMD5computeID(hProfile: cmsHPROFILE): cmsBool; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsOpenProfileFromFile(ICCProfile : PAnsiChar; sAccess: PAnsiChar): cmsHPROFILE; StdCall; external 'lcms2.dll';
+FUNCTION cmsOpenProfileFromFileTHR(ContextID: cmsContext; ICCProfile, sAccess: PAnsiChar): cmsHPROFILE; StdCall; external 'lcms2.dll';
+// FUNCTION CMSEXPORT cmsOpenProfileFromStream(FILE* ICCProfile, const char* sAccess): cmsHPROFILE; StdCall; external 'lcms2.dll';
+// FUNCTION CMSEXPORT cmsOpenProfileFromStreamTHR(ContextID: cmsContext; FILE* ICCProfile, const char* sAccess): cmsHPROFILE; StdCall; external 'lcms2.dll';
+FUNCTION cmsOpenProfileFromMem(MemPtr: Pointer; dwSize: cmsUInt32Number): cmsHPROFILE; StdCall; external 'lcms2.dll';
+FUNCTION cmsOpenProfileFromMemTHR(ContextID: cmsContext; MemPtr: Pointer; dwSize: cmsUInt32Number): cmsHPROFILE; StdCall; external 'lcms2.dll';
+FUNCTION cmsOpenProfileFromIOhandlerTHR(ContextID: cmsContext; io: LPcmsIOHANDLER): cmsHPROFILE; StdCall; external 'lcms2.dll';
+FUNCTION cmsCloseProfile(hProfile: cmsHPROFILE): cmsBool; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsSaveProfileToFile(hProfile: cmsHPROFILE; FileName: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
+// FUNCTION CMSEXPORT cmsSaveProfileToStream(hProfile: cmsHPROFILE, FILE* Stream): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsSaveProfileToMem(hProfile: cmsHPROFILE; MemPtr: Pointer; BytesNeeded: LPcmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsSaveProfileToIOhandler(hProfile: cmsHPROFILE; io: LPcmsIOHANDLER):cmsUInt32Number; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsCreateRGBProfileTHR(ContextID: cmsContext;
+ WhitePoint: LPcmsCIExyY;
+ Primaries: LPcmsCIExyYTRIPLE;
+ TransferFunction: LPLPcmsToneCurveArray): cmsHPROFILE; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsCreateRGBProfile(WhitePoint: LPcmsCIExyY;
+ Primaries: LPcmsCIExyYTRIPLE;
+ TransferFunction: LPLPcmsToneCurveArray): cmsHPROFILE; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsCreateGrayProfileTHR(ContextID: cmsContext;
+ WhitePoint: LPcmsCIExyY;
+ TransferFunction: LPcmsToneCurve): cmsHPROFILE; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsCreateGrayProfile(WhitePoint: LPcmsCIExyY;
+ TransferFunction: LPcmsToneCurve): cmsHPROFILE; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsCreateLinearizationDeviceLinkTHR(ContextID: cmsContext;
+ ColorSpace: cmsColorSpaceSignature;
+ TransferFunctions: LPLPcmsToneCurveArray): cmsHPROFILE; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsCreateLinearizationDeviceLink(ColorSpace: cmsColorSpaceSignature;
+ TransferFunctions: LPLPcmsToneCurveArray): cmsHPROFILE; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsCreateInkLimitingDeviceLinkTHR(ContextID: cmsContext;
+ ColorSpace: cmsColorSpaceSignature; Limit: cmsFloat64Number): cmsHPROFILE; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsCreateInkLimitingDeviceLink(ColorSpace: cmsColorSpaceSignature; Limit: cmsFloat64Number): cmsHPROFILE; StdCall; external 'lcms2.dll';
+
+
+FUNCTION cmsCreateLab2ProfileTHR(ContextID: cmsContext; WhitePoint: LPcmsCIExyY): cmsHPROFILE; StdCall; external 'lcms2.dll';
+FUNCTION cmsCreateLab2Profile(WhitePoint: LPcmsCIExyY): cmsHPROFILE; StdCall; external 'lcms2.dll';
+FUNCTION cmsCreateLab4ProfileTHR(ContextID: cmsContext; WhitePoint: LPcmsCIExyY): cmsHPROFILE; StdCall; external 'lcms2.dll';
+FUNCTION cmsCreateLab4Profile(WhitePoint: LPcmsCIExyY): cmsHPROFILE; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsCreateXYZProfileTHR(ContextID: cmsContext): cmsHPROFILE; StdCall; external 'lcms2.dll';
+FUNCTION cmsCreateXYZProfile: cmsHPROFILE; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsCreate_sRGBProfileTHR(ContextID: cmsContext): cmsHPROFILE; StdCall; external 'lcms2.dll';
+FUNCTION cmsCreate_sRGBProfile: cmsHPROFILE; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsCreateBCHSWabstractProfileTHR(ContextID: cmsContext;
+ nLUTPoints: Integer;
+ Bright,
+ Contrast,
+ Hue,
+ Saturation: cmsFloat64Number;
+ TempSrc,
+ TempDest: Integer): cmsHPROFILE; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsCreateBCHSWabstractProfile( nLUTPoints: Integer;
+ Bright,
+ Contrast,
+ Hue,
+ Saturation: cmsFloat64Number;
+ TempSrc,
+ TempDest: Integer): cmsHPROFILE; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsCreateNULLProfileTHR(ContextID: cmsContext): cmsHPROFILE; StdCall; external 'lcms2.dll';
+FUNCTION cmsCreateNULLProfile: cmsHPROFILE; StdCall; external 'lcms2.dll';
+
+// Converts a transform to a devicelink profile
+FUNCTION cmsTransform2DeviceLink(hTransform: cmsHTRANSFORM; Version: cmsFloat64Number; dwFlags: cmsUInt32Number): cmsHPROFILE; StdCall; external 'lcms2.dll';
+
+// Call with NULL as parameters to get the intent count
+FUNCTION cmsGetSupportedIntents(nMax: cmsUInt32Number; Codes: LPcmsUInt32Number; Descriptions: LPPAnsiChar): cmsUInt32Number; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsFLAGS_GRIDPOINTS(n: Integer): Integer; begin cmsFLAGS_GRIDPOINTS := (((n) and $FF) shl 16) end;
+
+
+FUNCTION cmsCreateTransformTHR(ContextID: cmsContext;
+ Input: cmsHPROFILE;
+ InputFormat: cmsUInt32Number;
+ Output: cmsHPROFILE;
+ OutputFormat: cmsUInt32Number;
+ Intent: cmsUInt32Number;
+ dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsCreateTransform(Input: cmsHPROFILE;
+ InputFormat: cmsUInt32Number;
+ Output: cmsHPROFILE;
+ OutputFormat: cmsUInt32Number;
+ Intent: cmsUInt32Number;
+ dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsCreateProofingTransformTHR(ContextID: cmsContext;
+ Input: cmsHPROFILE;
+ InputFormat: cmsUInt32Number;
+ Output: cmsHPROFILE;
+ OutputFormat: cmsUInt32Number;
+ Proofing: cmsHPROFILE;
+ Intent: cmsUInt32Number;
+ ProofingIntent: cmsUInt32Number;
+ dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsCreateProofingTransform(Input: cmsHPROFILE;
+ InputFormat: cmsUInt32Number;
+ Output: cmsHPROFILE;
+ OutputFormat: cmsUInt32Number;
+ Proofing: cmsHPROFILE;
+ Intent: cmsUInt32Number;
+ ProofingIntent: cmsUInt32Number;
+ dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsCreateMultiprofileTransformTHR(ContextID: cmsContext;
+ hProfiles: LPcmsHPROFILEArray;
+ nProfiles: cmsUInt32Number;
+ InputFormat: cmsUInt32Number;
+ OutputFormat: cmsUInt32Number;
+ Intent: cmsUInt32Number;
+ dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall; external 'lcms2.dll';
+
+
+FUNCTION cmsCreateMultiprofileTransform( hProfiles: LPcmsHPROFILEArray;
+ nProfiles: cmsUInt32Number;
+ InputFormat: cmsUInt32Number;
+ OutputFormat: cmsUInt32Number;
+ Intent: cmsUInt32Number;
+ dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall; external 'lcms2.dll';
+
+
+FUNCTION cmsCreateExtendedTransform(ContextID: cmsContext;
+ nProfiles: cmsUInt32Number;
+ hProfiles: LPcmsHPROFILEArray;
+ BPC: LPcmsBoolArray;
+ Intents: LPcmsUInt32NumberArray;
+ AdaptationStates: LPcmsFloat64NumberArray;
+ hGamutProfile: cmsHPROFILE;
+ nGamutPCSposition: cmsUInt32Number;
+ InputFormat,
+ OutputFormat: cmsUInt32Number;
+ dwFlags: cmsUInt32Number): cmsHTRANSFORM; StdCall; external 'lcms2.dll';
+
+PROCEDURE cmsDeleteTransform(hTransform: cmsHTRANSFORM); StdCall; external 'lcms2.dll';
+
+PROCEDURE cmsDoTransform(Transform: cmsHTRANSFORM; InputBuffer, OutputBuffer: Pointer; size: cmsUInt32Number); StdCall; external 'lcms2.dll';
+
+PROCEDURE cmsSetAlarmCodes( NewAlarm: LPcmsUInt16NumberArray); StdCall; external 'lcms2.dll';
+PROCEDURE cmsGetAlarmCodes(NewAlarm: LPcmsUInt16NumberArray); StdCall; external 'lcms2.dll';
+
+// Adaptation state for absolute colorimetric intent
+FUNCTION cmsSetAdaptationState(d: cmsFloat64Number):cmsFloat64Number; StdCall; external 'lcms2.dll';
+
+// Grab the ContextID from an open transform. Returns NULL if a NULL transform is passed
+FUNCTION cmsGetTransformContextID(hTransform: cmsHTRANSFORM):cmsContext; StdCall; external 'lcms2.dll';
+
+// For backwards compatibility
+FUNCTION cmsChangeBuffersFormat(hTransform: cmsHTRANSFORM; InputFormat, OutputFormat: cmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
+
+
+// lcms2 unified method to access postscript color resources
+FUNCTION cmsGetPostScriptColorResource(ContextID: cmsContext; RType: cmsPSResourceType;
+ hProfile: cmsHPROFILE;
+ Intent: cmsUInt32Number;
+ dwFlags: cmsUInt32Number;
+ io: LPcmsIOHANDLER): cmsUInt32Number; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsGetPostScriptCSA(ContextID: cmsContext; hProfile: cmsHPROFILE; Intent: cmsUInt32Number; dwFlags: cmsUInt32Number; Buffer: Pointer; dwBufferLen: cmsUInt32Number ): cmsUInt32Number; StdCall; external 'lcms2.dll';
+FUNCTION cmsGetPostScriptCRD(ContextID: cmsContext; hProfile: cmsHPROFILE; Intent: cmsUInt32Number; dwFlags: cmsUInt32Number; Buffer: Pointer; dwBufferLen: cmsUInt32Number): cmsUInt32Number; StdCall; external 'lcms2.dll';
+
+
+// CGATS.13 parser
+
+FUNCTION cmsIT8Alloc: cmsHANDLE; StdCall; external 'lcms2.dll';
+PROCEDURE cmsIT8Free(hIT8: cmsHANDLE); StdCall; external 'lcms2.dll';
+
+// Tables
+
+FUNCTION cmsIT8TableCount(hIT8: cmsHANDLE): Integer; StdCall; external 'lcms2.dll';
+FUNCTION cmsIT8SetTable(hIT8: cmsHANDLE; nTable: Integer): Integer; StdCall; external 'lcms2.dll';
+
+// Persistence
+FUNCTION cmsIT8LoadFromFile(cFileName: PAnsiChar): cmsHANDLE; StdCall; external 'lcms2.dll';
+FUNCTION cmsIT8LoadFromMem(Ptr: Pointer; size :DWord): cmsHANDLE; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsIT8SaveToFile(hIT8: cmsHANDLE; cFileName: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsIT8SaveToMem(hIT8: cmsHANDLE; MemPtr: Pointer; BytesNeeded: LPcmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
+// Properties
+
+FUNCTION cmsIT8GetSheetType(hIT8: cmsHANDLE): PAnsiChar; StdCall; external 'lcms2.dll';
+FUNCTION cmsIT8SetSheetType(hIT8: cmsHANDLE; TheType: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsIT8SetComment(hIT8: cmsHANDLE; cComment: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsIT8SetPropertyStr(hIT8: cmsHANDLE; cProp, Str: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsIT8SetPropertyDbl(hIT8: cmsHANDLE; cProp: PAnsiChar; Val: Double): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsIT8SetPropertyHex(hIT8: cmsHANDLE; cProp: PAnsiChar; Val: Integer): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsIT8SetPropertyUncooked(hIT8: cmsHANDLE; Key, Buffer: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
+
+
+FUNCTION cmsIT8GetProperty(hIT8: cmsHANDLE; cProp: PAnsiChar): PAnsiChar; StdCall; external 'lcms2.dll';
+FUNCTION cmsIT8GetPropertyDbl(hIT8: cmsHANDLE; cProp: PAnsiChar): Double; StdCall; external 'lcms2.dll';
+FUNCTION cmsIT8EnumProperties(hIT8: cmsHANDLE; var PropertyNames: LPPAnsiChar): Integer; StdCall; external 'lcms2.dll';
+
+// Datasets
+
+FUNCTION cmsIT8GetDataRowCol(hIT8: cmsHANDLE; row, col: Integer): PAnsiChar; StdCall; external 'lcms2.dll';
+FUNCTION cmsIT8GetDataRowColDbl(hIT8: cmsHANDLE; row, col: Integer): Double; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsIT8SetDataRowCol(hIT8: cmsHANDLE; row, col: Integer; Val: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsIT8SetDataRowColDbl(hIT8: cmsHANDLE; row, col: Integer; Val: Double): cmsBool; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsIT8GetData(hIT8: cmsHANDLE; cPatch, cSample: PAnsiChar): PAnsiChar; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsIT8GetDataDbl(hIT8: cmsHANDLE;cPatch, cSample: PAnsiChar): Double; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsIT8SetData(hIT8: cmsHANDLE; cPatch, cSample, Val: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsIT8SetDataDbl(hIT8: cmsHANDLE; cPatch, cSample: PAnsiChar; Val: Double): cmsBool; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsIT8SetDataFormat(hIT8: cmsHANDLE; n: Integer; Sample: PAnsiChar): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsIT8EnumDataFormat(hIT8: cmsHANDLE; var SampleNames: LPPAnsiChar): Integer; StdCall; external 'lcms2.dll';
+FUNCTION cmsIT8GetPatchName(hIT8: cmsHANDLE; nPatch: Integer; Buffer: PAnsiChar): PAnsiChar; StdCall; external 'lcms2.dll';
+
+// The LABEL extension
+
+FUNCTION cmsIT8SetTableByLabel(hIT8: cmsHANDLE; cSet, cField, ExpectedType: PAnsiChar): Integer; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsIT8FindDataFormat(hIT8: cmsHANDLE; cSample: PAnsiChar): Integer; StdCall; external 'lcms2.dll';
+
+// Formatter for double
+PROCEDURE cmsIT8DefineDblFormat(hIT8: cmsHANDLE; Formatter: PAnsiChar); StdCall; external 'lcms2.dll';
+
+FUNCTION cmsGBDAlloc(ContextID: cmsContext):cmsHANDLE; StdCall; external 'lcms2.dll';
+PROCEDURE cmsGBDFree(hGBD: cmsHANDLE); StdCall; external 'lcms2.dll';
+FUNCTION cmsGDBAddPoint(hGBD: cmsHANDLE; Lab: LPcmsCIELab): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsGDBCompute(hGDB: cmsHANDLE; dwFlags: cmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsGDBCheckPoint(hGBD: cmsHANDLE; Lab: LPcmsCIELab): cmsBool; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsDetectBlackPoint( BlackPoint: LPcmsCIEXYZ; hProfile: cmsHPROFILE; Intent: cmsUInt32Number; dwFlags: cmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
+FUNCTION cmsDetectDestinationBlackPoint( BlackPoint: LPcmsCIEXYZ; hProfile: cmsHPROFILE; Intent: cmsUInt32Number; dwFlags: cmsUInt32Number): cmsBool; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsDetectTAC(hProfile: cmsHPROFILE): cmsFloat64Number; StdCall; external 'lcms2.dll';
+
+FUNCTION cmsDesaturateLab(Lab: LPcmsCIELab; amax, amin, bmax, bmin: cmsFloat64Number): cmsBool; StdCall; external 'lcms2.dll';
+
+END.
diff --git a/utils/jpgicc/jpgicc.c b/utils/jpgicc/jpgicc.c
index 67899c1..3b18b54 100644
--- a/utils/jpgicc/jpgicc.c
+++ b/utils/jpgicc/jpgicc.c
@@ -1,1268 +1,1268 @@
-//---------------------------------------------------------------------------------
-//
-// Little Color Management System
-// Copyright (c) 1998-2010 Marti Maria Saguer
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the "Software"),
-// to deal in the Software without restriction, including without limitation
-// the rights to use, copy, modify, merge, publish, distribute, sublicense,
-// and/or sell copies of the Software, and to permit persons to whom the Software
-// is furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
-// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-// This program does apply profiles to (some) JPEG files
-
-
-#include "utils.h"
-
-#include "jpeglib.h"
-#include "iccjpeg.h"
-
-// Flags
-static cmsBool BlackPointCompensation = FALSE;
-static cmsBool IgnoreEmbedded = FALSE;
-static cmsBool GamutCheck = FALSE;
-static cmsBool lIsITUFax = FALSE;
-static cmsBool lIsPhotoshopApp13 = FALSE;
-static cmsBool lIsEXIF;
-static cmsBool lIsDeviceLink = FALSE;
-static cmsBool EmbedProfile = FALSE;
-
-static const char* SaveEmbedded = NULL;
-
-static int Intent = INTENT_PERCEPTUAL;
-static int ProofingIntent = INTENT_PERCEPTUAL;
-static int PrecalcMode = 1;
-
-static int jpegQuality = 75;
-
-static cmsFloat64Number ObserverAdaptationState = 0;
-
-
-static char *cInpProf = NULL;
-static char *cOutProf = NULL;
-static char *cProofing = NULL;
-
-static FILE * InFile;
-static FILE * OutFile;
-
-static struct jpeg_decompress_struct Decompressor;
-static struct jpeg_compress_struct Compressor;
-
-
-static struct my_error_mgr {
-
- struct jpeg_error_mgr pub; // "public" fields
- void* Cargo; // "private" fields
-
-} ErrorHandler;
-
-
-cmsUInt16Number Alarm[4] = {128,128,128,0};
-
-// Out of mem
-static
-void OutOfMem(size_t size)
-{
- FatalError("Out of memory on allocating %d bytes.", size);
-}
-
-
-static
-void my_error_exit (j_common_ptr cinfo)
-{
- char buffer[JMSG_LENGTH_MAX];
-
- (*cinfo->err->format_message) (cinfo, buffer);
- FatalError(buffer);
-}
-
-/*
-Definition of the APPn Markers Defined for continuous-tone G3FAX
-
-The application code APP1 initiates identification of the image as
-a G3FAX application and defines the spatial resolution and subsampling.
-This marker directly follows the SOI marker. The data format will be as follows:
-
-X'FFE1' (APP1), length, FAX identifier, version, spatial resolution.
-
-The above terms are defined as follows:
-
-Length: (Two octets) Total APP1 field octet count including the octet count itself, but excluding the APP1
-marker.
-
-FAX identifier: (Six octets) X'47', X'33', X'46', X'41', X'58', X'00'. This X'00'-terminated string "G3FAX"
-uniquely identifies this APP1 marker.
-
-Version: (Two octets) X'07CA'. This string specifies the year of approval of the standard, for identification
-in the case of future revision (for example, 1994).
-
-Spatial Resolution: (Two octets) Lightness pixel density in pels/25.4 mm. The basic value is 200. Allowed values are
-100, 200, 300, 400, 600 and 1200 pels/25.4 mm, with square (or equivalent) pels.
-
-NOTE – The functional equivalence of inch-based and mm-based resolutions is maintained. For example, the 200 × 200
-*/
-
-static
-cmsBool IsITUFax(jpeg_saved_marker_ptr ptr)
-{
- while (ptr)
- {
- if (ptr -> marker == (JPEG_APP0 + 1) && ptr -> data_length > 5) {
-
- const char* data = (const char*) ptr -> data;
-
- if (strcmp(data, "G3FAX") == 0) return TRUE;
- }
-
- ptr = ptr -> next;
- }
-
- return FALSE;
-}
-
-// Save a ITU T.42/Fax marker with defaults on boundaries. This is the only mode we support right now.
-static
-void SetITUFax(j_compress_ptr cinfo)
-{
- unsigned char Marker[] = "G3FAX\x00\0x07\xCA\x00\xC8";
-
- jpeg_write_marker(cinfo, (JPEG_APP0 + 1), Marker, 10);
-}
-
-
-// Build a profile for decoding ITU T.42/Fax JPEG streams.
-// The profile has an additional ability in the input direction of
-// gamut compress values between 85 < a < -85 and -75 < b < 125. This conforms
-// the default range for ITU/T.42 -- See RFC 2301, section 6.2.3 for details
-
-// L* = [0, 100]
-// a* = [–85, 85]
-// b* = [–75, 125]
-
-
-// These functions does convert the encoding of ITUFAX to floating point
-// and vice-versa. No gamut mapping is performed yet.
-
-static
-void ITU2Lab(const cmsUInt16Number In[3], cmsCIELab* Lab)
-{
- Lab -> L = (double) In[0] / 655.35;
- Lab -> a = (double) 170.* (In[1] - 32768.) / 65535.;
- Lab -> b = (double) 200.* (In[2] - 24576.) / 65535.;
-}
-
-static
-void Lab2ITU(const cmsCIELab* Lab, cmsUInt16Number Out[3])
-{
- Out[0] = (cmsUInt16Number) floor((double) (Lab -> L / 100.)* 65535. );
- Out[1] = (cmsUInt16Number) floor((double) (Lab -> a / 170.)* 65535. + 32768. );
- Out[2] = (cmsUInt16Number) floor((double) (Lab -> b / 200.)* 65535. + 24576. );
-}
-
-// These are the samplers-- They are passed as callbacks to cmsStageSampleCLut16bit()
-// then, cmsSample3DGrid() will sweel whole Lab gamut calling these functions
-// once for each node. In[] will contain the Lab PCS value to convert to ITUFAX
-// on PCS2ITU, or the ITUFAX value to convert to Lab in ITU2PCS
-// You can change the number of sample points if desired, the algorithm will
-// remain same. 33 points gives good accurancy, but you can reduce to 22 or less
-// is space is critical
-
-#define GRID_POINTS 33
-
-static
-int PCS2ITU(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
-{
- cmsCIELab Lab;
-
- cmsLabEncoded2Float(&Lab, In);
- cmsDesaturateLab(&Lab, 85, -85, 125, -75); // This function does the necessary gamut remapping
- Lab2ITU(&Lab, Out);
- return TRUE;
-
- UTILS_UNUSED_PARAMETER(Cargo);
-}
-
-
-static
-int ITU2PCS( register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
-{
- cmsCIELab Lab;
-
- ITU2Lab(In, &Lab);
- cmsFloat2LabEncoded(Out, &Lab);
- return TRUE;
-
- UTILS_UNUSED_PARAMETER(Cargo);
-}
-
-// This function does create the virtual input profile, which decodes ITU to the profile connection space
-static
-cmsHPROFILE CreateITU2PCS_ICC(void)
-{
- cmsHPROFILE hProfile;
- cmsPipeline* AToB0;
- cmsStage* ColorMap;
-
- AToB0 = cmsPipelineAlloc(0, 3, 3);
- if (AToB0 == NULL) return NULL;
-
- ColorMap = cmsStageAllocCLut16bit(0, GRID_POINTS, 3, 3, NULL);
- if (ColorMap == NULL) return NULL;
-
- cmsPipelineInsertStage(AToB0, cmsAT_BEGIN, ColorMap);
- cmsStageSampleCLut16bit(ColorMap, ITU2PCS, NULL, 0);
-
- hProfile = cmsCreateProfilePlaceholder(0);
- if (hProfile == NULL) {
- cmsPipelineFree(AToB0);
- return NULL;
- }
-
- cmsWriteTag(hProfile, cmsSigAToB0Tag, AToB0);
- cmsSetColorSpace(hProfile, cmsSigLabData);
- cmsSetPCS(hProfile, cmsSigLabData);
- cmsSetDeviceClass(hProfile, cmsSigColorSpaceClass);
- cmsPipelineFree(AToB0);
-
- return hProfile;
-}
-
-
-// This function does create the virtual output profile, with the necessary gamut mapping
-static
-cmsHPROFILE CreatePCS2ITU_ICC(void)
-{
- cmsHPROFILE hProfile;
- cmsPipeline* BToA0;
- cmsStage* ColorMap;
-
- BToA0 = cmsPipelineAlloc(0, 3, 3);
- if (BToA0 == NULL) return NULL;
-
- ColorMap = cmsStageAllocCLut16bit(0, GRID_POINTS, 3, 3, NULL);
- if (ColorMap == NULL) return NULL;
-
- cmsPipelineInsertStage(BToA0, cmsAT_BEGIN, ColorMap);
- cmsStageSampleCLut16bit(ColorMap, PCS2ITU, NULL, 0);
-
- hProfile = cmsCreateProfilePlaceholder(0);
- if (hProfile == NULL) {
- cmsPipelineFree(BToA0);
- return NULL;
- }
-
- cmsWriteTag(hProfile, cmsSigBToA0Tag, BToA0);
- cmsSetColorSpace(hProfile, cmsSigLabData);
- cmsSetPCS(hProfile, cmsSigLabData);
- cmsSetDeviceClass(hProfile, cmsSigColorSpaceClass);
-
- cmsPipelineFree(BToA0);
-
- return hProfile;
-}
-
-
-
-#define PS_FIXED_TO_FLOAT(h, l) ((float) (h) + ((float) (l)/(1<<16)))
-
-static
-cmsBool ProcessPhotoshopAPP13(JOCTET FAR *data, int datalen)
-{
- int i;
-
- for (i = 14; i < datalen; )
- {
- long len;
- unsigned int type;
-
- if (!(GETJOCTET(data[i] ) == 0x38 &&
- GETJOCTET(data[i+1]) == 0x42 &&
- GETJOCTET(data[i+2]) == 0x49 &&
- GETJOCTET(data[i+3]) == 0x4D)) break; // Not recognized
-
- i += 4; // identifying string
-
- type = (unsigned int) (GETJOCTET(data[i]<<8) + GETJOCTET(data[i+1]));
-
- i += 2; // resource type
-
- i += GETJOCTET(data[i]) + ((GETJOCTET(data[i]) & 1) ? 1 : 2); // resource name
-
- len = ((((GETJOCTET(data[i]<<8) + GETJOCTET(data[i+1]))<<8) +
- GETJOCTET(data[i+2]))<<8) + GETJOCTET(data[i+3]);
-
- i += 4; // Size
-
- if (type == 0x03ED && len >= 16) {
-
- Decompressor.X_density = (UINT16) PS_FIXED_TO_FLOAT(GETJOCTET(data[i]<<8) + GETJOCTET(data[i+1]),
- GETJOCTET(data[i+2]<<8) + GETJOCTET(data[i+3]));
- Decompressor.Y_density = (UINT16) PS_FIXED_TO_FLOAT(GETJOCTET(data[i+8]<<8) + GETJOCTET(data[i+9]),
- GETJOCTET(data[i+10]<<8) + GETJOCTET(data[i+11]));
-
- // Set the density unit to 1 since the
- // Vertical and Horizontal resolutions
- // are specified in Pixels per inch
-
- Decompressor.density_unit = 0x01;
- return TRUE;
-
- }
-
- i += len + ((len & 1) ? 1 : 0); // Alignment
- }
- return FALSE;
-}
-
-
-static
-cmsBool HandlePhotoshopAPP13(jpeg_saved_marker_ptr ptr)
-{
- while (ptr) {
-
- if (ptr -> marker == (JPEG_APP0 + 13) && ptr -> data_length > 9)
- {
- JOCTET FAR* data = ptr -> data;
-
- if(GETJOCTET(data[0]) == 0x50 &&
- GETJOCTET(data[1]) == 0x68 &&
- GETJOCTET(data[2]) == 0x6F &&
- GETJOCTET(data[3]) == 0x74 &&
- GETJOCTET(data[4]) == 0x6F &&
- GETJOCTET(data[5]) == 0x73 &&
- GETJOCTET(data[6]) == 0x68 &&
- GETJOCTET(data[7]) == 0x6F &&
- GETJOCTET(data[8]) == 0x70) {
-
- ProcessPhotoshopAPP13(data, ptr -> data_length);
- return TRUE;
- }
- }
-
- ptr = ptr -> next;
- }
-
- return FALSE;
-}
-
-
-typedef unsigned short uint16_t;
-typedef unsigned char uint8_t;
-typedef unsigned int uint32_t;
-
-#define INTEL_BYTE_ORDER 0x4949
-#define XRESOLUTION 0x011a
-#define YRESOLUTION 0x011b
-#define RESOLUTION_UNIT 0x128
-
-// Read a 16-bit word
-static
-uint16_t read16(uint8_t* arr, int pos, int swapBytes)
-{
- uint8_t b1 = arr[pos];
- uint8_t b2 = arr[pos+1];
-
- return (swapBytes) ? ((b2 << 8) | b1) : ((b1 << 8) | b2);
-}
-
-
-// Read a 32-bit word
-static
-uint32_t read32(uint8_t* arr, int pos, int swapBytes)
-{
-
- if(!swapBytes) {
-
- return (arr[pos] << 24) |
- (arr[pos+1] << 16) |
- (arr[pos+2] << 8) |
- arr[pos+3];
- }
-
- return arr[pos] |
- (arr[pos+1] << 8) |
- (arr[pos+2] << 16) |
- (arr[pos+3] << 24);
-}
-
-
-
-static
-int read_tag(uint8_t* arr, int pos, int swapBytes, void* dest)
-{
- // Format should be 5 over here (rational)
- uint32_t format = read16(arr, pos + 2, swapBytes);
- // Components should be 1
- uint32_t components = read32(arr, pos + 4, swapBytes);
- // Points to the value
- uint32_t offset;
-
- // sanity
- if (components != 1) return 0;
-
- if (format == 3)
- offset = pos + 8;
- else
- offset = read32(arr, pos + 8, swapBytes);
-
- switch (format) {
-
- case 5: // Rational
- {
- double num = read32(arr, offset, swapBytes);
- double den = read32(arr, offset + 4, swapBytes);
- *(double *) dest = num / den;
- }
- break;
-
- case 3: // uint 16
- *(int*) dest = read16(arr, offset, swapBytes);
- break;
-
- default: return 0;
- }
-
- return 1;
-}
-
-
-
-// Handler for EXIF data
-static
- cmsBool HandleEXIF(struct jpeg_decompress_struct* cinfo)
-{
- jpeg_saved_marker_ptr ptr;
- uint32_t ifd_ofs;
- int pos = 0, swapBytes = 0;
- uint32_t i, numEntries;
- double XRes = -1, YRes = -1;
- int Unit = 2; // Inches
-
-
- for (ptr = cinfo ->marker_list; ptr; ptr = ptr ->next) {
-
- if ((ptr ->marker == JPEG_APP0+1) && ptr ->data_length > 6) {
- JOCTET FAR* data = ptr -> data;
-
- if (memcmp(data, "Exif\0\0", 6) == 0) {
-
- data += 6; // Skip EXIF marker
-
- // 8 byte TIFF header
- // first two determine byte order
- pos = 0;
- if (read16(data, pos, 0) == INTEL_BYTE_ORDER) {
- swapBytes = 1;
- }
-
- pos += 2;
-
- // next two bytes are always 0x002A (TIFF version)
- pos += 2;
-
- // offset to Image File Directory (includes the previous 8 bytes)
- ifd_ofs = read32(data, pos, swapBytes);
-
- // Search the directory for resolution tags
- numEntries = read16(data, ifd_ofs, swapBytes);
-
- for (i=0; i < numEntries; i++) {
-
- uint32_t entryOffset = ifd_ofs + 2 + (12 * i);
- uint32_t tag = read16(data, entryOffset, swapBytes);
-
- switch (tag) {
-
- case RESOLUTION_UNIT:
- if (!read_tag(data, entryOffset, swapBytes, &Unit)) return FALSE;
- break;
-
- case XRESOLUTION:
- if (!read_tag(data, entryOffset, swapBytes, &XRes)) return FALSE;
- break;
-
- case YRESOLUTION:
- if (!read_tag(data, entryOffset, swapBytes, &YRes)) return FALSE;
- break;
-
- default:;
- }
-
- }
-
- // Proceed if all found
-
- if (XRes != -1 && YRes != -1)
- {
-
- // 1 = None
- // 2 = inches
- // 3 = cm
-
- switch (Unit) {
-
- case 2:
-
- cinfo ->X_density = (UINT16) floor(XRes + 0.5);
- cinfo ->Y_density = (UINT16) floor(YRes + 0.5);
- break;
-
- case 1:
-
- cinfo ->X_density = (UINT16) floor(XRes * 2.54 + 0.5);
- cinfo ->Y_density = (UINT16) floor(YRes * 2.54 + 0.5);
- break;
-
- default: return FALSE;
- }
-
- cinfo ->density_unit = 1; /* 1 for dots/inch, or 2 for dots/cm.*/
-
- }
-
-
- }
- }
- }
- return FALSE;
-}
-
-
-static
-cmsBool OpenInput(const char* FileName)
-{
- int m;
-
- lIsITUFax = FALSE;
- InFile = fopen(FileName, "rb");
- if (InFile == NULL) {
- FatalError("Cannot open '%s'", FileName);
- }
-
- // Now we can initialize the JPEG decompression object.
- Decompressor.err = jpeg_std_error(&ErrorHandler.pub);
- ErrorHandler.pub.error_exit = my_error_exit;
- ErrorHandler.pub.output_message = my_error_exit;
-
- jpeg_create_decompress(&Decompressor);
- jpeg_stdio_src(&Decompressor, InFile);
-
- for (m = 0; m < 16; m++)
- jpeg_save_markers(&Decompressor, JPEG_APP0 + m, 0xFFFF);
-
- // setup_read_icc_profile(&Decompressor);
-
- fseek(InFile, 0, SEEK_SET);
- jpeg_read_header(&Decompressor, TRUE);
-
- return TRUE;
-}
-
-
-static
-cmsBool OpenOutput(const char* FileName)
-{
-
- OutFile = fopen(FileName, "wb");
- if (OutFile == NULL) {
- FatalError("Cannot create '%s'", FileName);
-
- }
-
- Compressor.err = jpeg_std_error(&ErrorHandler.pub);
- ErrorHandler.pub.error_exit = my_error_exit;
- ErrorHandler.pub.output_message = my_error_exit;
-
- Compressor.input_components = Compressor.num_components = 4;
-
- jpeg_create_compress(&Compressor);
- jpeg_stdio_dest(&Compressor, OutFile);
- return TRUE;
-}
-
-static
-cmsBool Done(void)
-{
- jpeg_destroy_decompress(&Decompressor);
- jpeg_destroy_compress(&Compressor);
- return fclose(InFile) + fclose(OutFile);
-
-}
-
-
-// Build up the pixeltype descriptor
-
-static
-cmsUInt32Number GetInputPixelType(void)
-{
- int space, bps, extra, ColorChannels, Flavor;
-
- lIsITUFax = IsITUFax(Decompressor.marker_list);
- lIsPhotoshopApp13 = HandlePhotoshopAPP13(Decompressor.marker_list);
- lIsEXIF = HandleEXIF(&Decompressor);
-
- ColorChannels = Decompressor.num_components;
- extra = 0; // Alpha = None
- bps = 1; // 8 bits
- Flavor = 0; // Vanilla
-
- if (lIsITUFax) {
-
- space = PT_Lab;
- Decompressor.out_color_space = JCS_YCbCr; // Fake to don't touch
- }
- else
- switch (Decompressor.jpeg_color_space) {
-
- case JCS_GRAYSCALE: // monochrome
- space = PT_GRAY;
- Decompressor.out_color_space = JCS_GRAYSCALE;
- break;
-
- case JCS_RGB: // red/green/blue
- space = PT_RGB;
- Decompressor.out_color_space = JCS_RGB;
- break;
-
- case JCS_YCbCr: // Y/Cb/Cr (also known as YUV)
- space = PT_RGB; // Let IJG code to do the conversion
- Decompressor.out_color_space = JCS_RGB;
- break;
-
- case JCS_CMYK: // C/M/Y/K
- space = PT_CMYK;
- Decompressor.out_color_space = JCS_CMYK;
- if (Decompressor.saw_Adobe_marker) // Adobe keeps CMYK inverted, so change flavor
- Flavor = 1; // from vanilla to chocolate
- break;
-
- case JCS_YCCK: // Y/Cb/Cr/K
- space = PT_CMYK;
- Decompressor.out_color_space = JCS_CMYK;
- if (Decompressor.saw_Adobe_marker) // ditto
- Flavor = 1;
- break;
-
- default:
- FatalError("Unsupported color space (0x%x)", Decompressor.jpeg_color_space);
- return 0;
- }
-
- return (EXTRA_SH(extra)|CHANNELS_SH(ColorChannels)|BYTES_SH(bps)|COLORSPACE_SH(space)|FLAVOR_SH(Flavor));
-}
-
-
-// Rearrange pixel type to build output descriptor
-static
-cmsUInt32Number ComputeOutputFormatDescriptor(cmsUInt32Number dwInput, int OutColorSpace)
-{
- int IsPlanar = T_PLANAR(dwInput);
- int Channels = 0;
- int Flavor = 0;
-
- switch (OutColorSpace) {
-
- case PT_GRAY:
- Channels = 1;
- break;
- case PT_RGB:
- case PT_CMY:
- case PT_Lab:
- case PT_YUV:
- case PT_YCbCr:
- Channels = 3;
- break;
-
- case PT_CMYK:
- if (Compressor.write_Adobe_marker) // Adobe keeps CMYK inverted, so change flavor to chocolate
- Flavor = 1;
- Channels = 4;
- break;
- default:
- FatalError("Unsupported output color space");
- }
-
- return (COLORSPACE_SH(OutColorSpace)|PLANAR_SH(IsPlanar)|CHANNELS_SH(Channels)|BYTES_SH(1)|FLAVOR_SH(Flavor));
-}
-
-
-// Equivalence between ICC color spaces and lcms color spaces
-static
-int GetProfileColorSpace(cmsHPROFILE hProfile)
-{
- cmsColorSpaceSignature ProfileSpace = cmsGetColorSpace(hProfile);
-
- return _cmsLCMScolorSpace(ProfileSpace);
-}
-
-static
-int GetDevicelinkColorSpace(cmsHPROFILE hProfile)
-{
- cmsColorSpaceSignature ProfileSpace = cmsGetPCS(hProfile);
-
- return _cmsLCMScolorSpace(ProfileSpace);
-}
-
-
-// From TRANSUPP
-
-static
-void jcopy_markers_execute(j_decompress_ptr srcinfo, j_compress_ptr dstinfo)
-{
- jpeg_saved_marker_ptr marker;
-
- /* In the current implementation, we don't actually need to examine the
- * option flag here; we just copy everything that got saved.
- * But to avoid confusion, we do not output JFIF and Adobe APP14 markers
- * if the encoder library already wrote one.
- */
- for (marker = srcinfo->marker_list; marker != NULL; marker = marker->next) {
-
- if (dstinfo->write_JFIF_header &&
- marker->marker == JPEG_APP0 &&
- marker->data_length >= 5 &&
- GETJOCTET(marker->data[0]) == 0x4A &&
- GETJOCTET(marker->data[1]) == 0x46 &&
- GETJOCTET(marker->data[2]) == 0x49 &&
- GETJOCTET(marker->data[3]) == 0x46 &&
- GETJOCTET(marker->data[4]) == 0)
- continue; /* reject duplicate JFIF */
-
- if (dstinfo->write_Adobe_marker &&
- marker->marker == JPEG_APP0+14 &&
- marker->data_length >= 5 &&
- GETJOCTET(marker->data[0]) == 0x41 &&
- GETJOCTET(marker->data[1]) == 0x64 &&
- GETJOCTET(marker->data[2]) == 0x6F &&
- GETJOCTET(marker->data[3]) == 0x62 &&
- GETJOCTET(marker->data[4]) == 0x65)
- continue; /* reject duplicate Adobe */
-
- jpeg_write_marker(dstinfo, marker->marker,
- marker->data, marker->data_length);
- }
-}
-
-static
-void WriteOutputFields(int OutputColorSpace)
-{
- J_COLOR_SPACE in_space, jpeg_space;
- int components;
-
- switch (OutputColorSpace) {
-
- case PT_GRAY: in_space = jpeg_space = JCS_GRAYSCALE;
- components = 1;
- break;
-
- case PT_RGB: in_space = JCS_RGB;
- jpeg_space = JCS_YCbCr;
- components = 3;
- break; // red/green/blue
-
- case PT_YCbCr: in_space = jpeg_space = JCS_YCbCr;
- components = 3;
- break; // Y/Cb/Cr (also known as YUV)
-
- case PT_CMYK: in_space = JCS_CMYK;
- jpeg_space = JCS_YCCK;
- components = 4;
- break; // C/M/Y/components
-
- case PT_Lab: in_space = jpeg_space = JCS_YCbCr;
- components = 3;
- break; // Fake to don't touch
- default:
- FatalError("Unsupported output color space");
- return;
- }
-
-
- if (jpegQuality >= 100) {
-
- // avoid destructive conversion when asking for lossless compression
- jpeg_space = in_space;
- }
-
- Compressor.in_color_space = in_space;
- Compressor.jpeg_color_space = jpeg_space;
- Compressor.input_components = Compressor.num_components = components;
- jpeg_set_defaults(&Compressor);
- jpeg_set_colorspace(&Compressor, jpeg_space);
-
-
- // Make sure to pass resolution through
- if (OutputColorSpace == PT_CMYK)
- Compressor.write_JFIF_header = 1;
-
- // Avoid subsampling on high quality factor
- jpeg_set_quality(&Compressor, jpegQuality, 1);
- if (jpegQuality >= 70) {
-
- int i;
- for(i=0; i < Compressor.num_components; i++) {
-
- Compressor.comp_info[i].h_samp_factor = 1;
- Compressor.comp_info[i].v_samp_factor = 1;
- }
-
- }
-
-}
-
-
-static
-void DoEmbedProfile(const char* ProfileFile)
-{
- FILE* f;
- size_t size, EmbedLen;
- cmsUInt8Number* EmbedBuffer;
-
- f = fopen(ProfileFile, "rb");
- if (f == NULL) return;
-
- size = cmsfilelength(f);
- EmbedBuffer = (cmsUInt8Number*) malloc(size + 1);
- EmbedLen = fread(EmbedBuffer, 1, size, f);
- fclose(f);
- EmbedBuffer[EmbedLen] = 0;
-
- write_icc_profile (&Compressor, EmbedBuffer, EmbedLen);
- free(EmbedBuffer);
-}
-
-
-
-static
-int DoTransform(cmsHTRANSFORM hXForm, int OutputColorSpace)
-{
- JSAMPROW ScanLineIn;
- JSAMPROW ScanLineOut;
-
-
- //Preserve resolution values from the original
- // (Thanks to Robert Bergs for finding out this bug)
- Compressor.density_unit = Decompressor.density_unit;
- Compressor.X_density = Decompressor.X_density;
- Compressor.Y_density = Decompressor.Y_density;
-
- // Compressor.write_JFIF_header = 1;
-
- jpeg_start_decompress(&Decompressor);
- jpeg_start_compress(&Compressor, TRUE);
-
- if (OutputColorSpace == PT_Lab)
- SetITUFax(&Compressor);
-
- // Embed the profile if needed
- if (EmbedProfile && cOutProf)
- DoEmbedProfile(cOutProf);
-
- ScanLineIn = (JSAMPROW) malloc(Decompressor.output_width * Decompressor.num_components);
- ScanLineOut = (JSAMPROW) malloc(Compressor.image_width * Compressor.num_components);
-
- while (Decompressor.output_scanline <
- Decompressor.output_height) {
-
- jpeg_read_scanlines(&Decompressor, &ScanLineIn, 1);
-
- cmsDoTransform(hXForm, ScanLineIn, ScanLineOut, Decompressor.output_width);
-
- jpeg_write_scanlines(&Compressor, &ScanLineOut, 1);
- }
-
- free(ScanLineIn);
- free(ScanLineOut);
-
- jpeg_finish_decompress(&Decompressor);
- jpeg_finish_compress(&Compressor);
-
- return TRUE;
-}
-
-
-
-// Transform one image
-
-static
-int TransformImage(char *cDefInpProf, char *cOutProf)
-{
- cmsHPROFILE hIn, hOut, hProof;
- cmsHTRANSFORM xform;
- cmsUInt32Number wInput, wOutput;
- int OutputColorSpace;
- cmsUInt32Number dwFlags = 0;
- cmsUInt32Number EmbedLen;
- cmsUInt8Number* EmbedBuffer;
-
-
- cmsSetAdaptationState(ObserverAdaptationState);
-
- if (BlackPointCompensation) {
-
- dwFlags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
- }
-
-
- switch (PrecalcMode) {
-
- case 0: dwFlags |= cmsFLAGS_NOOPTIMIZE; break;
- case 2: dwFlags |= cmsFLAGS_HIGHRESPRECALC; break;
- case 3: dwFlags |= cmsFLAGS_LOWRESPRECALC; break;
- default:;
- }
-
-
- if (GamutCheck) {
- dwFlags |= cmsFLAGS_GAMUTCHECK;
- cmsSetAlarmCodes(Alarm);
- }
-
- // Take input color space
- wInput = GetInputPixelType();
-
- if (lIsDeviceLink) {
-
- hIn = cmsOpenProfileFromFile(cDefInpProf, "r");
- hOut = NULL;
- hProof = NULL;
- }
- else {
-
- if (!IgnoreEmbedded && read_icc_profile(&Decompressor, &EmbedBuffer, &EmbedLen))
- {
- hIn = cmsOpenProfileFromMem(EmbedBuffer, EmbedLen);
-
- if (Verbose) {
-
- fprintf(stdout, " (Embedded profile found)\n");
- PrintProfileInformation(hIn);
- fflush(stdout);
- }
-
- if (hIn != NULL && SaveEmbedded != NULL)
- SaveMemoryBlock(EmbedBuffer, EmbedLen, SaveEmbedded);
-
- free(EmbedBuffer);
- }
- else
- {
- // Default for ITU/Fax
- if (cDefInpProf == NULL && T_COLORSPACE(wInput) == PT_Lab)
- cDefInpProf = "*Lab";
-
- if (cDefInpProf != NULL && cmsstrcasecmp(cDefInpProf, "*lab") == 0)
- hIn = CreateITU2PCS_ICC();
- else
- hIn = OpenStockProfile(0, cDefInpProf);
- }
-
- if (cOutProf != NULL && cmsstrcasecmp(cOutProf, "*lab") == 0)
- hOut = CreatePCS2ITU_ICC();
- else
- hOut = OpenStockProfile(0, cOutProf);
-
- hProof = NULL;
- if (cProofing != NULL) {
-
- hProof = OpenStockProfile(0, cProofing);
- if (hProof == NULL) {
- FatalError("Proofing profile couldn't be read.");
- }
- dwFlags |= cmsFLAGS_SOFTPROOFING;
- }
- }
-
- if (!hIn)
- FatalError("Input profile couldn't be read.");
- if (!hOut)
- FatalError("Output profile couldn't be read.");
-
- // Assure both, input profile and input JPEG are on same colorspace
- if (cmsGetColorSpace(hIn) != _cmsICCcolorSpace(T_COLORSPACE(wInput)))
- FatalError("Input profile is not operating in proper color space");
-
-
- // Output colorspace is given by output profile
-
- if (lIsDeviceLink) {
- OutputColorSpace = GetDevicelinkColorSpace(hIn);
- }
- else {
- OutputColorSpace = GetProfileColorSpace(hOut);
- }
-
- jpeg_copy_critical_parameters(&Decompressor, &Compressor);
-
- WriteOutputFields(OutputColorSpace);
-
- wOutput = ComputeOutputFormatDescriptor(wInput, OutputColorSpace);
-
-
- xform = cmsCreateProofingTransform(hIn, wInput,
- hOut, wOutput,
- hProof, Intent,
- ProofingIntent, dwFlags);
- if (xform == NULL)
- FatalError("Cannot transform by using the profiles");
-
- DoTransform(xform, OutputColorSpace);
-
-
- jcopy_markers_execute(&Decompressor, &Compressor);
-
- cmsDeleteTransform(xform);
- cmsCloseProfile(hIn);
- cmsCloseProfile(hOut);
- if (hProof) cmsCloseProfile(hProof);
-
- return 1;
-}
-
-
-// Simply print help
-
-static
-void Help(int level)
-{
- fprintf(stderr, "little cms ICC profile applier for JPEG - v3.2 [LittleCMS %2.2f]\n\n", LCMS_VERSION / 1000.0);
-
- switch(level) {
-
- default:
- case 0:
-
- fprintf(stderr, "usage: jpgicc [flags] input.jpg output.jpg\n");
-
- fprintf(stderr, "\nflags:\n\n");
- fprintf(stderr, "%cv - Verbose\n", SW);
- fprintf(stderr, "%ci<profile> - Input profile (defaults to sRGB)\n", SW);
- fprintf(stderr, "%co<profile> - Output profile (defaults to sRGB)\n", SW);
-
- PrintRenderingIntents();
-
-
- fprintf(stderr, "%cb - Black point compensation\n", SW);
- fprintf(stderr, "%cd<0..1> - Observer adaptation state (abs.col. only)\n", SW);
- fprintf(stderr, "%cn - Ignore embedded profile\n", SW);
- fprintf(stderr, "%ce - Embed destination profile\n", SW);
- fprintf(stderr, "%cs<new profile> - Save embedded profile as <new profile>\n", SW);
-
- fprintf(stderr, "\n");
-
- fprintf(stderr, "%cc<0,1,2,3> - Precalculates transform (0=Off, 1=Normal, 2=Hi-res, 3=LoRes) [defaults to 1]\n", SW);
- fprintf(stderr, "\n");
-
- fprintf(stderr, "%cp<profile> - Soft proof profile\n", SW);
- fprintf(stderr, "%cm<0,1,2,3> - SoftProof intent\n", SW);
- fprintf(stderr, "%cg - Marks out-of-gamut colors on softproof\n", SW);
- fprintf(stderr, "%c!<r>,<g>,<b> - Out-of-gamut marker channel values\n", SW);
-
- fprintf(stderr, "\n");
- fprintf(stderr, "%cq<0..100> - Output JPEG quality\n", SW);
-
- fprintf(stderr, "\n");
- fprintf(stderr, "%ch<0,1,2,3> - More help\n", SW);
- break;
-
- case 1:
-
- fprintf(stderr, "Examples:\n\n"
- "To color correct from scanner to sRGB:\n"
- "\tjpgicc %ciscanner.icm in.jpg out.jpg\n"
- "To convert from monitor1 to monitor2:\n"
- "\tjpgicc %cimon1.icm %comon2.icm in.jpg out.jpg\n"
- "To make a CMYK separation:\n"
- "\tjpgicc %coprinter.icm inrgb.jpg outcmyk.jpg\n"
- "To recover sRGB from a CMYK separation:\n"
- "\tjpgicc %ciprinter.icm incmyk.jpg outrgb.jpg\n"
- "To convert from CIELab ITU/Fax JPEG to sRGB\n"
- "\tjpgicc in.jpg out.jpg\n\n",
- SW, SW, SW, SW, SW);
- break;
-
- case 2:
- PrintBuiltins();
- break;
-
- case 3:
-
- fprintf(stderr, "This program is intended to be a demo of the little cms\n"
- "engine. Both lcms and this program are freeware. You can\n"
- "obtain both in source code at http://www.littlecms.com\n"
- "For suggestions, comments, bug reports etc. send mail to\n"
- "marti@littlecms.com\n\n");
- break;
- }
-
- exit(0);
-}
-
-
-// The toggles stuff
-
-static
-void HandleSwitches(int argc, char *argv[])
-{
- int s;
-
- while ((s=xgetopt(argc,argv,"bBnNvVGgh:H:i:I:o:O:P:p:t:T:c:C:Q:q:M:m:L:l:eEs:S:!:D:d:")) != EOF) {
-
- switch (s)
- {
-
- case 'b':
- case 'B':
- BlackPointCompensation = TRUE;
- break;
-
- case 'd':
- case 'D': ObserverAdaptationState = atof(xoptarg);
- if (ObserverAdaptationState < 0 ||
- ObserverAdaptationState > 1.0)
- FatalError("Adaptation state should be 0..1");
- break;
-
- case 'v':
- case 'V':
- Verbose = TRUE;
- break;
-
- case 'i':
- case 'I':
- if (lIsDeviceLink)
- FatalError("Device-link already specified");
-
- cInpProf = xoptarg;
- break;
-
- case 'o':
- case 'O':
- if (lIsDeviceLink)
- FatalError("Device-link already specified");
-
- cOutProf = xoptarg;
- break;
-
- case 'l':
- case 'L':
- if (cInpProf != NULL || cOutProf != NULL)
- FatalError("input/output profiles already specified");
-
- cInpProf = xoptarg;
- lIsDeviceLink = TRUE;
- break;
-
- case 'p':
- case 'P':
- cProofing = xoptarg;
- break;
-
- case 't':
- case 'T':
- Intent = atoi(xoptarg);
- break;
-
- case 'N':
- case 'n':
- IgnoreEmbedded = TRUE;
- break;
-
- case 'e':
- case 'E':
- EmbedProfile = TRUE;
- break;
-
-
- case 'g':
- case 'G':
- GamutCheck = TRUE;
- break;
-
- case 'c':
- case 'C':
- PrecalcMode = atoi(xoptarg);
- if (PrecalcMode < 0 || PrecalcMode > 2)
- FatalError("Unknown precalc mode '%d'", PrecalcMode);
- break;
-
- case 'H':
- case 'h': {
-
- int a = atoi(xoptarg);
- Help(a);
- }
- break;
-
- case 'q':
- case 'Q':
- jpegQuality = atoi(xoptarg);
- if (jpegQuality > 100) jpegQuality = 100;
- if (jpegQuality < 0) jpegQuality = 0;
- break;
-
- case 'm':
- case 'M':
- ProofingIntent = atoi(xoptarg);
- break;
-
- case 's':
- case 'S': SaveEmbedded = xoptarg;
- break;
-
- case '!':
- if (sscanf(xoptarg, "%hu,%hu,%hu", &Alarm[0], &Alarm[1], &Alarm[2]) == 3) {
- int i;
- for (i=0; i < 3; i++) {
- Alarm[i] = (Alarm[i] << 8) | Alarm[i];
- }
- }
- break;
-
- default:
-
- FatalError("Unknown option - run without args to see valid ones");
- }
-
- }
-}
-
-
-int main(int argc, char* argv[])
-{
- InitUtils("jpgicc");
-
- HandleSwitches(argc, argv);
-
- if ((argc - xoptind) != 2) {
- Help(0);
- }
-
- OpenInput(argv[xoptind]);
- OpenOutput(argv[xoptind+1]);
-
- TransformImage(cInpProf, cOutProf);
-
-
- if (Verbose) { fprintf(stdout, "\n"); fflush(stdout); }
-
- Done();
-
- return 0;
-}
-
-
-
+//---------------------------------------------------------------------------------
+//
+// Little Color Management System
+// Copyright (c) 1998-2010 Marti Maria Saguer
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the Software
+// is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+// This program does apply profiles to (some) JPEG files
+
+
+#include "utils.h"
+
+#include "jpeglib.h"
+#include "iccjpeg.h"
+
+// Flags
+static cmsBool BlackPointCompensation = FALSE;
+static cmsBool IgnoreEmbedded = FALSE;
+static cmsBool GamutCheck = FALSE;
+static cmsBool lIsITUFax = FALSE;
+static cmsBool lIsPhotoshopApp13 = FALSE;
+static cmsBool lIsEXIF;
+static cmsBool lIsDeviceLink = FALSE;
+static cmsBool EmbedProfile = FALSE;
+
+static const char* SaveEmbedded = NULL;
+
+static int Intent = INTENT_PERCEPTUAL;
+static int ProofingIntent = INTENT_PERCEPTUAL;
+static int PrecalcMode = 1;
+
+static int jpegQuality = 75;
+
+static cmsFloat64Number ObserverAdaptationState = 0;
+
+
+static char *cInpProf = NULL;
+static char *cOutProf = NULL;
+static char *cProofing = NULL;
+
+static FILE * InFile;
+static FILE * OutFile;
+
+static struct jpeg_decompress_struct Decompressor;
+static struct jpeg_compress_struct Compressor;
+
+
+static struct my_error_mgr {
+
+ struct jpeg_error_mgr pub; // "public" fields
+ void* Cargo; // "private" fields
+
+} ErrorHandler;
+
+
+cmsUInt16Number Alarm[4] = {128,128,128,0};
+
+// Out of mem
+static
+void OutOfMem(size_t size)
+{
+ FatalError("Out of memory on allocating %d bytes.", size);
+}
+
+
+static
+void my_error_exit (j_common_ptr cinfo)
+{
+ char buffer[JMSG_LENGTH_MAX];
+
+ (*cinfo->err->format_message) (cinfo, buffer);
+ FatalError(buffer);
+}
+
+/*
+Definition of the APPn Markers Defined for continuous-tone G3FAX
+
+The application code APP1 initiates identification of the image as
+a G3FAX application and defines the spatial resolution and subsampling.
+This marker directly follows the SOI marker. The data format will be as follows:
+
+X'FFE1' (APP1), length, FAX identifier, version, spatial resolution.
+
+The above terms are defined as follows:
+
+Length: (Two octets) Total APP1 field octet count including the octet count itself, but excluding the APP1
+marker.
+
+FAX identifier: (Six octets) X'47', X'33', X'46', X'41', X'58', X'00'. This X'00'-terminated string "G3FAX"
+uniquely identifies this APP1 marker.
+
+Version: (Two octets) X'07CA'. This string specifies the year of approval of the standard, for identification
+in the case of future revision (for example, 1994).
+
+Spatial Resolution: (Two octets) Lightness pixel density in pels/25.4 mm. The basic value is 200. Allowed values are
+100, 200, 300, 400, 600 and 1200 pels/25.4 mm, with square (or equivalent) pels.
+
+NOTE – The functional equivalence of inch-based and mm-based resolutions is maintained. For example, the 200 × 200
+*/
+
+static
+cmsBool IsITUFax(jpeg_saved_marker_ptr ptr)
+{
+ while (ptr)
+ {
+ if (ptr -> marker == (JPEG_APP0 + 1) && ptr -> data_length > 5) {
+
+ const char* data = (const char*) ptr -> data;
+
+ if (strcmp(data, "G3FAX") == 0) return TRUE;
+ }
+
+ ptr = ptr -> next;
+ }
+
+ return FALSE;
+}
+
+// Save a ITU T.42/Fax marker with defaults on boundaries. This is the only mode we support right now.
+static
+void SetITUFax(j_compress_ptr cinfo)
+{
+ unsigned char Marker[] = "G3FAX\x00\0x07\xCA\x00\xC8";
+
+ jpeg_write_marker(cinfo, (JPEG_APP0 + 1), Marker, 10);
+}
+
+
+// Build a profile for decoding ITU T.42/Fax JPEG streams.
+// The profile has an additional ability in the input direction of
+// gamut compress values between 85 < a < -85 and -75 < b < 125. This conforms
+// the default range for ITU/T.42 -- See RFC 2301, section 6.2.3 for details
+
+// L* = [0, 100]
+// a* = [–85, 85]
+// b* = [–75, 125]
+
+
+// These functions does convert the encoding of ITUFAX to floating point
+// and vice-versa. No gamut mapping is performed yet.
+
+static
+void ITU2Lab(const cmsUInt16Number In[3], cmsCIELab* Lab)
+{
+ Lab -> L = (double) In[0] / 655.35;
+ Lab -> a = (double) 170.* (In[1] - 32768.) / 65535.;
+ Lab -> b = (double) 200.* (In[2] - 24576.) / 65535.;
+}
+
+static
+void Lab2ITU(const cmsCIELab* Lab, cmsUInt16Number Out[3])
+{
+ Out[0] = (cmsUInt16Number) floor((double) (Lab -> L / 100.)* 65535. );
+ Out[1] = (cmsUInt16Number) floor((double) (Lab -> a / 170.)* 65535. + 32768. );
+ Out[2] = (cmsUInt16Number) floor((double) (Lab -> b / 200.)* 65535. + 24576. );
+}
+
+// These are the samplers-- They are passed as callbacks to cmsStageSampleCLut16bit()
+// then, cmsSample3DGrid() will sweel whole Lab gamut calling these functions
+// once for each node. In[] will contain the Lab PCS value to convert to ITUFAX
+// on PCS2ITU, or the ITUFAX value to convert to Lab in ITU2PCS
+// You can change the number of sample points if desired, the algorithm will
+// remain same. 33 points gives good accurancy, but you can reduce to 22 or less
+// is space is critical
+
+#define GRID_POINTS 33
+
+static
+int PCS2ITU(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
+{
+ cmsCIELab Lab;
+
+ cmsLabEncoded2Float(&Lab, In);
+ cmsDesaturateLab(&Lab, 85, -85, 125, -75); // This function does the necessary gamut remapping
+ Lab2ITU(&Lab, Out);
+ return TRUE;
+
+ UTILS_UNUSED_PARAMETER(Cargo);
+}
+
+
+static
+int ITU2PCS( register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
+{
+ cmsCIELab Lab;
+
+ ITU2Lab(In, &Lab);
+ cmsFloat2LabEncoded(Out, &Lab);
+ return TRUE;
+
+ UTILS_UNUSED_PARAMETER(Cargo);
+}
+
+// This function does create the virtual input profile, which decodes ITU to the profile connection space
+static
+cmsHPROFILE CreateITU2PCS_ICC(void)
+{
+ cmsHPROFILE hProfile;
+ cmsPipeline* AToB0;
+ cmsStage* ColorMap;
+
+ AToB0 = cmsPipelineAlloc(0, 3, 3);
+ if (AToB0 == NULL) return NULL;
+
+ ColorMap = cmsStageAllocCLut16bit(0, GRID_POINTS, 3, 3, NULL);
+ if (ColorMap == NULL) return NULL;
+
+ cmsPipelineInsertStage(AToB0, cmsAT_BEGIN, ColorMap);
+ cmsStageSampleCLut16bit(ColorMap, ITU2PCS, NULL, 0);
+
+ hProfile = cmsCreateProfilePlaceholder(0);
+ if (hProfile == NULL) {
+ cmsPipelineFree(AToB0);
+ return NULL;
+ }
+
+ cmsWriteTag(hProfile, cmsSigAToB0Tag, AToB0);
+ cmsSetColorSpace(hProfile, cmsSigLabData);
+ cmsSetPCS(hProfile, cmsSigLabData);
+ cmsSetDeviceClass(hProfile, cmsSigColorSpaceClass);
+ cmsPipelineFree(AToB0);
+
+ return hProfile;
+}
+
+
+// This function does create the virtual output profile, with the necessary gamut mapping
+static
+cmsHPROFILE CreatePCS2ITU_ICC(void)
+{
+ cmsHPROFILE hProfile;
+ cmsPipeline* BToA0;
+ cmsStage* ColorMap;
+
+ BToA0 = cmsPipelineAlloc(0, 3, 3);
+ if (BToA0 == NULL) return NULL;
+
+ ColorMap = cmsStageAllocCLut16bit(0, GRID_POINTS, 3, 3, NULL);
+ if (ColorMap == NULL) return NULL;
+
+ cmsPipelineInsertStage(BToA0, cmsAT_BEGIN, ColorMap);
+ cmsStageSampleCLut16bit(ColorMap, PCS2ITU, NULL, 0);
+
+ hProfile = cmsCreateProfilePlaceholder(0);
+ if (hProfile == NULL) {
+ cmsPipelineFree(BToA0);
+ return NULL;
+ }
+
+ cmsWriteTag(hProfile, cmsSigBToA0Tag, BToA0);
+ cmsSetColorSpace(hProfile, cmsSigLabData);
+ cmsSetPCS(hProfile, cmsSigLabData);
+ cmsSetDeviceClass(hProfile, cmsSigColorSpaceClass);
+
+ cmsPipelineFree(BToA0);
+
+ return hProfile;
+}
+
+
+
+#define PS_FIXED_TO_FLOAT(h, l) ((float) (h) + ((float) (l)/(1<<16)))
+
+static
+cmsBool ProcessPhotoshopAPP13(JOCTET FAR *data, int datalen)
+{
+ int i;
+
+ for (i = 14; i < datalen; )
+ {
+ long len;
+ unsigned int type;
+
+ if (!(GETJOCTET(data[i] ) == 0x38 &&
+ GETJOCTET(data[i+1]) == 0x42 &&
+ GETJOCTET(data[i+2]) == 0x49 &&
+ GETJOCTET(data[i+3]) == 0x4D)) break; // Not recognized
+
+ i += 4; // identifying string
+
+ type = (unsigned int) (GETJOCTET(data[i]<<8) + GETJOCTET(data[i+1]));
+
+ i += 2; // resource type
+
+ i += GETJOCTET(data[i]) + ((GETJOCTET(data[i]) & 1) ? 1 : 2); // resource name
+
+ len = ((((GETJOCTET(data[i]<<8) + GETJOCTET(data[i+1]))<<8) +
+ GETJOCTET(data[i+2]))<<8) + GETJOCTET(data[i+3]);
+
+ i += 4; // Size
+
+ if (type == 0x03ED && len >= 16) {
+
+ Decompressor.X_density = (UINT16) PS_FIXED_TO_FLOAT(GETJOCTET(data[i]<<8) + GETJOCTET(data[i+1]),
+ GETJOCTET(data[i+2]<<8) + GETJOCTET(data[i+3]));
+ Decompressor.Y_density = (UINT16) PS_FIXED_TO_FLOAT(GETJOCTET(data[i+8]<<8) + GETJOCTET(data[i+9]),
+ GETJOCTET(data[i+10]<<8) + GETJOCTET(data[i+11]));
+
+ // Set the density unit to 1 since the
+ // Vertical and Horizontal resolutions
+ // are specified in Pixels per inch
+
+ Decompressor.density_unit = 0x01;
+ return TRUE;
+
+ }
+
+ i += len + ((len & 1) ? 1 : 0); // Alignment
+ }
+ return FALSE;
+}
+
+
+static
+cmsBool HandlePhotoshopAPP13(jpeg_saved_marker_ptr ptr)
+{
+ while (ptr) {
+
+ if (ptr -> marker == (JPEG_APP0 + 13) && ptr -> data_length > 9)
+ {
+ JOCTET FAR* data = ptr -> data;
+
+ if(GETJOCTET(data[0]) == 0x50 &&
+ GETJOCTET(data[1]) == 0x68 &&
+ GETJOCTET(data[2]) == 0x6F &&
+ GETJOCTET(data[3]) == 0x74 &&
+ GETJOCTET(data[4]) == 0x6F &&
+ GETJOCTET(data[5]) == 0x73 &&
+ GETJOCTET(data[6]) == 0x68 &&
+ GETJOCTET(data[7]) == 0x6F &&
+ GETJOCTET(data[8]) == 0x70) {
+
+ ProcessPhotoshopAPP13(data, ptr -> data_length);
+ return TRUE;
+ }
+ }
+
+ ptr = ptr -> next;
+ }
+
+ return FALSE;
+}
+
+
+typedef unsigned short uint16_t;
+typedef unsigned char uint8_t;
+typedef unsigned int uint32_t;
+
+#define INTEL_BYTE_ORDER 0x4949
+#define XRESOLUTION 0x011a
+#define YRESOLUTION 0x011b
+#define RESOLUTION_UNIT 0x128
+
+// Read a 16-bit word
+static
+uint16_t read16(uint8_t* arr, int pos, int swapBytes)
+{
+ uint8_t b1 = arr[pos];
+ uint8_t b2 = arr[pos+1];
+
+ return (swapBytes) ? ((b2 << 8) | b1) : ((b1 << 8) | b2);
+}
+
+
+// Read a 32-bit word
+static
+uint32_t read32(uint8_t* arr, int pos, int swapBytes)
+{
+
+ if(!swapBytes) {
+
+ return (arr[pos] << 24) |
+ (arr[pos+1] << 16) |
+ (arr[pos+2] << 8) |
+ arr[pos+3];
+ }
+
+ return arr[pos] |
+ (arr[pos+1] << 8) |
+ (arr[pos+2] << 16) |
+ (arr[pos+3] << 24);
+}
+
+
+
+static
+int read_tag(uint8_t* arr, int pos, int swapBytes, void* dest)
+{
+ // Format should be 5 over here (rational)
+ uint32_t format = read16(arr, pos + 2, swapBytes);
+ // Components should be 1
+ uint32_t components = read32(arr, pos + 4, swapBytes);
+ // Points to the value
+ uint32_t offset;
+
+ // sanity
+ if (components != 1) return 0;
+
+ if (format == 3)
+ offset = pos + 8;
+ else
+ offset = read32(arr, pos + 8, swapBytes);
+
+ switch (format) {
+
+ case 5: // Rational
+ {
+ double num = read32(arr, offset, swapBytes);
+ double den = read32(arr, offset + 4, swapBytes);
+ *(double *) dest = num / den;
+ }
+ break;
+
+ case 3: // uint 16
+ *(int*) dest = read16(arr, offset, swapBytes);
+ break;
+
+ default: return 0;
+ }
+
+ return 1;
+}
+
+
+
+// Handler for EXIF data
+static
+ cmsBool HandleEXIF(struct jpeg_decompress_struct* cinfo)
+{
+ jpeg_saved_marker_ptr ptr;
+ uint32_t ifd_ofs;
+ int pos = 0, swapBytes = 0;
+ uint32_t i, numEntries;
+ double XRes = -1, YRes = -1;
+ int Unit = 2; // Inches
+
+
+ for (ptr = cinfo ->marker_list; ptr; ptr = ptr ->next) {
+
+ if ((ptr ->marker == JPEG_APP0+1) && ptr ->data_length > 6) {
+ JOCTET FAR* data = ptr -> data;
+
+ if (memcmp(data, "Exif\0\0", 6) == 0) {
+
+ data += 6; // Skip EXIF marker
+
+ // 8 byte TIFF header
+ // first two determine byte order
+ pos = 0;
+ if (read16(data, pos, 0) == INTEL_BYTE_ORDER) {
+ swapBytes = 1;
+ }
+
+ pos += 2;
+
+ // next two bytes are always 0x002A (TIFF version)
+ pos += 2;
+
+ // offset to Image File Directory (includes the previous 8 bytes)
+ ifd_ofs = read32(data, pos, swapBytes);
+
+ // Search the directory for resolution tags
+ numEntries = read16(data, ifd_ofs, swapBytes);
+
+ for (i=0; i < numEntries; i++) {
+
+ uint32_t entryOffset = ifd_ofs + 2 + (12 * i);
+ uint32_t tag = read16(data, entryOffset, swapBytes);
+
+ switch (tag) {
+
+ case RESOLUTION_UNIT:
+ if (!read_tag(data, entryOffset, swapBytes, &Unit)) return FALSE;
+ break;
+
+ case XRESOLUTION:
+ if (!read_tag(data, entryOffset, swapBytes, &XRes)) return FALSE;
+ break;
+
+ case YRESOLUTION:
+ if (!read_tag(data, entryOffset, swapBytes, &YRes)) return FALSE;
+ break;
+
+ default:;
+ }
+
+ }
+
+ // Proceed if all found
+
+ if (XRes != -1 && YRes != -1)
+ {
+
+ // 1 = None
+ // 2 = inches
+ // 3 = cm
+
+ switch (Unit) {
+
+ case 2:
+
+ cinfo ->X_density = (UINT16) floor(XRes + 0.5);
+ cinfo ->Y_density = (UINT16) floor(YRes + 0.5);
+ break;
+
+ case 1:
+
+ cinfo ->X_density = (UINT16) floor(XRes * 2.54 + 0.5);
+ cinfo ->Y_density = (UINT16) floor(YRes * 2.54 + 0.5);
+ break;
+
+ default: return FALSE;
+ }
+
+ cinfo ->density_unit = 1; /* 1 for dots/inch, or 2 for dots/cm.*/
+
+ }
+
+
+ }
+ }
+ }
+ return FALSE;
+}
+
+
+static
+cmsBool OpenInput(const char* FileName)
+{
+ int m;
+
+ lIsITUFax = FALSE;
+ InFile = fopen(FileName, "rb");
+ if (InFile == NULL) {
+ FatalError("Cannot open '%s'", FileName);
+ }
+
+ // Now we can initialize the JPEG decompression object.
+ Decompressor.err = jpeg_std_error(&ErrorHandler.pub);
+ ErrorHandler.pub.error_exit = my_error_exit;
+ ErrorHandler.pub.output_message = my_error_exit;
+
+ jpeg_create_decompress(&Decompressor);
+ jpeg_stdio_src(&Decompressor, InFile);
+
+ for (m = 0; m < 16; m++)
+ jpeg_save_markers(&Decompressor, JPEG_APP0 + m, 0xFFFF);
+
+ // setup_read_icc_profile(&Decompressor);
+
+ fseek(InFile, 0, SEEK_SET);
+ jpeg_read_header(&Decompressor, TRUE);
+
+ return TRUE;
+}
+
+
+static
+cmsBool OpenOutput(const char* FileName)
+{
+
+ OutFile = fopen(FileName, "wb");
+ if (OutFile == NULL) {
+ FatalError("Cannot create '%s'", FileName);
+
+ }
+
+ Compressor.err = jpeg_std_error(&ErrorHandler.pub);
+ ErrorHandler.pub.error_exit = my_error_exit;
+ ErrorHandler.pub.output_message = my_error_exit;
+
+ Compressor.input_components = Compressor.num_components = 4;
+
+ jpeg_create_compress(&Compressor);
+ jpeg_stdio_dest(&Compressor, OutFile);
+ return TRUE;
+}
+
+static
+cmsBool Done(void)
+{
+ jpeg_destroy_decompress(&Decompressor);
+ jpeg_destroy_compress(&Compressor);
+ return fclose(InFile) + fclose(OutFile);
+
+}
+
+
+// Build up the pixeltype descriptor
+
+static
+cmsUInt32Number GetInputPixelType(void)
+{
+ int space, bps, extra, ColorChannels, Flavor;
+
+ lIsITUFax = IsITUFax(Decompressor.marker_list);
+ lIsPhotoshopApp13 = HandlePhotoshopAPP13(Decompressor.marker_list);
+ lIsEXIF = HandleEXIF(&Decompressor);
+
+ ColorChannels = Decompressor.num_components;
+ extra = 0; // Alpha = None
+ bps = 1; // 8 bits
+ Flavor = 0; // Vanilla
+
+ if (lIsITUFax) {
+
+ space = PT_Lab;
+ Decompressor.out_color_space = JCS_YCbCr; // Fake to don't touch
+ }
+ else
+ switch (Decompressor.jpeg_color_space) {
+
+ case JCS_GRAYSCALE: // monochrome
+ space = PT_GRAY;
+ Decompressor.out_color_space = JCS_GRAYSCALE;
+ break;
+
+ case JCS_RGB: // red/green/blue
+ space = PT_RGB;
+ Decompressor.out_color_space = JCS_RGB;
+ break;
+
+ case JCS_YCbCr: // Y/Cb/Cr (also known as YUV)
+ space = PT_RGB; // Let IJG code to do the conversion
+ Decompressor.out_color_space = JCS_RGB;
+ break;
+
+ case JCS_CMYK: // C/M/Y/K
+ space = PT_CMYK;
+ Decompressor.out_color_space = JCS_CMYK;
+ if (Decompressor.saw_Adobe_marker) // Adobe keeps CMYK inverted, so change flavor
+ Flavor = 1; // from vanilla to chocolate
+ break;
+
+ case JCS_YCCK: // Y/Cb/Cr/K
+ space = PT_CMYK;
+ Decompressor.out_color_space = JCS_CMYK;
+ if (Decompressor.saw_Adobe_marker) // ditto
+ Flavor = 1;
+ break;
+
+ default:
+ FatalError("Unsupported color space (0x%x)", Decompressor.jpeg_color_space);
+ return 0;
+ }
+
+ return (EXTRA_SH(extra)|CHANNELS_SH(ColorChannels)|BYTES_SH(bps)|COLORSPACE_SH(space)|FLAVOR_SH(Flavor));
+}
+
+
+// Rearrange pixel type to build output descriptor
+static
+cmsUInt32Number ComputeOutputFormatDescriptor(cmsUInt32Number dwInput, int OutColorSpace)
+{
+ int IsPlanar = T_PLANAR(dwInput);
+ int Channels = 0;
+ int Flavor = 0;
+
+ switch (OutColorSpace) {
+
+ case PT_GRAY:
+ Channels = 1;
+ break;
+ case PT_RGB:
+ case PT_CMY:
+ case PT_Lab:
+ case PT_YUV:
+ case PT_YCbCr:
+ Channels = 3;
+ break;
+
+ case PT_CMYK:
+ if (Compressor.write_Adobe_marker) // Adobe keeps CMYK inverted, so change flavor to chocolate
+ Flavor = 1;
+ Channels = 4;
+ break;
+ default:
+ FatalError("Unsupported output color space");
+ }
+
+ return (COLORSPACE_SH(OutColorSpace)|PLANAR_SH(IsPlanar)|CHANNELS_SH(Channels)|BYTES_SH(1)|FLAVOR_SH(Flavor));
+}
+
+
+// Equivalence between ICC color spaces and lcms color spaces
+static
+int GetProfileColorSpace(cmsHPROFILE hProfile)
+{
+ cmsColorSpaceSignature ProfileSpace = cmsGetColorSpace(hProfile);
+
+ return _cmsLCMScolorSpace(ProfileSpace);
+}
+
+static
+int GetDevicelinkColorSpace(cmsHPROFILE hProfile)
+{
+ cmsColorSpaceSignature ProfileSpace = cmsGetPCS(hProfile);
+
+ return _cmsLCMScolorSpace(ProfileSpace);
+}
+
+
+// From TRANSUPP
+
+static
+void jcopy_markers_execute(j_decompress_ptr srcinfo, j_compress_ptr dstinfo)
+{
+ jpeg_saved_marker_ptr marker;
+
+ /* In the current implementation, we don't actually need to examine the
+ * option flag here; we just copy everything that got saved.
+ * But to avoid confusion, we do not output JFIF and Adobe APP14 markers
+ * if the encoder library already wrote one.
+ */
+ for (marker = srcinfo->marker_list; marker != NULL; marker = marker->next) {
+
+ if (dstinfo->write_JFIF_header &&
+ marker->marker == JPEG_APP0 &&
+ marker->data_length >= 5 &&
+ GETJOCTET(marker->data[0]) == 0x4A &&
+ GETJOCTET(marker->data[1]) == 0x46 &&
+ GETJOCTET(marker->data[2]) == 0x49 &&
+ GETJOCTET(marker->data[3]) == 0x46 &&
+ GETJOCTET(marker->data[4]) == 0)
+ continue; /* reject duplicate JFIF */
+
+ if (dstinfo->write_Adobe_marker &&
+ marker->marker == JPEG_APP0+14 &&
+ marker->data_length >= 5 &&
+ GETJOCTET(marker->data[0]) == 0x41 &&
+ GETJOCTET(marker->data[1]) == 0x64 &&
+ GETJOCTET(marker->data[2]) == 0x6F &&
+ GETJOCTET(marker->data[3]) == 0x62 &&
+ GETJOCTET(marker->data[4]) == 0x65)
+ continue; /* reject duplicate Adobe */
+
+ jpeg_write_marker(dstinfo, marker->marker,
+ marker->data, marker->data_length);
+ }
+}
+
+static
+void WriteOutputFields(int OutputColorSpace)
+{
+ J_COLOR_SPACE in_space, jpeg_space;
+ int components;
+
+ switch (OutputColorSpace) {
+
+ case PT_GRAY: in_space = jpeg_space = JCS_GRAYSCALE;
+ components = 1;
+ break;
+
+ case PT_RGB: in_space = JCS_RGB;
+ jpeg_space = JCS_YCbCr;
+ components = 3;
+ break; // red/green/blue
+
+ case PT_YCbCr: in_space = jpeg_space = JCS_YCbCr;
+ components = 3;
+ break; // Y/Cb/Cr (also known as YUV)
+
+ case PT_CMYK: in_space = JCS_CMYK;
+ jpeg_space = JCS_YCCK;
+ components = 4;
+ break; // C/M/Y/components
+
+ case PT_Lab: in_space = jpeg_space = JCS_YCbCr;
+ components = 3;
+ break; // Fake to don't touch
+ default:
+ FatalError("Unsupported output color space");
+ return;
+ }
+
+
+ if (jpegQuality >= 100) {
+
+ // avoid destructive conversion when asking for lossless compression
+ jpeg_space = in_space;
+ }
+
+ Compressor.in_color_space = in_space;
+ Compressor.jpeg_color_space = jpeg_space;
+ Compressor.input_components = Compressor.num_components = components;
+ jpeg_set_defaults(&Compressor);
+ jpeg_set_colorspace(&Compressor, jpeg_space);
+
+
+ // Make sure to pass resolution through
+ if (OutputColorSpace == PT_CMYK)
+ Compressor.write_JFIF_header = 1;
+
+ // Avoid subsampling on high quality factor
+ jpeg_set_quality(&Compressor, jpegQuality, 1);
+ if (jpegQuality >= 70) {
+
+ int i;
+ for(i=0; i < Compressor.num_components; i++) {
+
+ Compressor.comp_info[i].h_samp_factor = 1;
+ Compressor.comp_info[i].v_samp_factor = 1;
+ }
+
+ }
+
+}
+
+
+static
+void DoEmbedProfile(const char* ProfileFile)
+{
+ FILE* f;
+ size_t size, EmbedLen;
+ cmsUInt8Number* EmbedBuffer;
+
+ f = fopen(ProfileFile, "rb");
+ if (f == NULL) return;
+
+ size = cmsfilelength(f);
+ EmbedBuffer = (cmsUInt8Number*) malloc(size + 1);
+ EmbedLen = fread(EmbedBuffer, 1, size, f);
+ fclose(f);
+ EmbedBuffer[EmbedLen] = 0;
+
+ write_icc_profile (&Compressor, EmbedBuffer, EmbedLen);
+ free(EmbedBuffer);
+}
+
+
+
+static
+int DoTransform(cmsHTRANSFORM hXForm, int OutputColorSpace)
+{
+ JSAMPROW ScanLineIn;
+ JSAMPROW ScanLineOut;
+
+
+ //Preserve resolution values from the original
+ // (Thanks to Robert Bergs for finding out this bug)
+ Compressor.density_unit = Decompressor.density_unit;
+ Compressor.X_density = Decompressor.X_density;
+ Compressor.Y_density = Decompressor.Y_density;
+
+ // Compressor.write_JFIF_header = 1;
+
+ jpeg_start_decompress(&Decompressor);
+ jpeg_start_compress(&Compressor, TRUE);
+
+ if (OutputColorSpace == PT_Lab)
+ SetITUFax(&Compressor);
+
+ // Embed the profile if needed
+ if (EmbedProfile && cOutProf)
+ DoEmbedProfile(cOutProf);
+
+ ScanLineIn = (JSAMPROW) malloc(Decompressor.output_width * Decompressor.num_components);
+ ScanLineOut = (JSAMPROW) malloc(Compressor.image_width * Compressor.num_components);
+
+ while (Decompressor.output_scanline <
+ Decompressor.output_height) {
+
+ jpeg_read_scanlines(&Decompressor, &ScanLineIn, 1);
+
+ cmsDoTransform(hXForm, ScanLineIn, ScanLineOut, Decompressor.output_width);
+
+ jpeg_write_scanlines(&Compressor, &ScanLineOut, 1);
+ }
+
+ free(ScanLineIn);
+ free(ScanLineOut);
+
+ jpeg_finish_decompress(&Decompressor);
+ jpeg_finish_compress(&Compressor);
+
+ return TRUE;
+}
+
+
+
+// Transform one image
+
+static
+int TransformImage(char *cDefInpProf, char *cOutProf)
+{
+ cmsHPROFILE hIn, hOut, hProof;
+ cmsHTRANSFORM xform;
+ cmsUInt32Number wInput, wOutput;
+ int OutputColorSpace;
+ cmsUInt32Number dwFlags = 0;
+ cmsUInt32Number EmbedLen;
+ cmsUInt8Number* EmbedBuffer;
+
+
+ cmsSetAdaptationState(ObserverAdaptationState);
+
+ if (BlackPointCompensation) {
+
+ dwFlags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
+ }
+
+
+ switch (PrecalcMode) {
+
+ case 0: dwFlags |= cmsFLAGS_NOOPTIMIZE; break;
+ case 2: dwFlags |= cmsFLAGS_HIGHRESPRECALC; break;
+ case 3: dwFlags |= cmsFLAGS_LOWRESPRECALC; break;
+ default:;
+ }
+
+
+ if (GamutCheck) {
+ dwFlags |= cmsFLAGS_GAMUTCHECK;
+ cmsSetAlarmCodes(Alarm);
+ }
+
+ // Take input color space
+ wInput = GetInputPixelType();
+
+ if (lIsDeviceLink) {
+
+ hIn = cmsOpenProfileFromFile(cDefInpProf, "r");
+ hOut = NULL;
+ hProof = NULL;
+ }
+ else {
+
+ if (!IgnoreEmbedded && read_icc_profile(&Decompressor, &EmbedBuffer, &EmbedLen))
+ {
+ hIn = cmsOpenProfileFromMem(EmbedBuffer, EmbedLen);
+
+ if (Verbose) {
+
+ fprintf(stdout, " (Embedded profile found)\n");
+ PrintProfileInformation(hIn);
+ fflush(stdout);
+ }
+
+ if (hIn != NULL && SaveEmbedded != NULL)
+ SaveMemoryBlock(EmbedBuffer, EmbedLen, SaveEmbedded);
+
+ free(EmbedBuffer);
+ }
+ else
+ {
+ // Default for ITU/Fax
+ if (cDefInpProf == NULL && T_COLORSPACE(wInput) == PT_Lab)
+ cDefInpProf = "*Lab";
+
+ if (cDefInpProf != NULL && cmsstrcasecmp(cDefInpProf, "*lab") == 0)
+ hIn = CreateITU2PCS_ICC();
+ else
+ hIn = OpenStockProfile(0, cDefInpProf);
+ }
+
+ if (cOutProf != NULL && cmsstrcasecmp(cOutProf, "*lab") == 0)
+ hOut = CreatePCS2ITU_ICC();
+ else
+ hOut = OpenStockProfile(0, cOutProf);
+
+ hProof = NULL;
+ if (cProofing != NULL) {
+
+ hProof = OpenStockProfile(0, cProofing);
+ if (hProof == NULL) {
+ FatalError("Proofing profile couldn't be read.");
+ }
+ dwFlags |= cmsFLAGS_SOFTPROOFING;
+ }
+ }
+
+ if (!hIn)
+ FatalError("Input profile couldn't be read.");
+ if (!hOut)
+ FatalError("Output profile couldn't be read.");
+
+ // Assure both, input profile and input JPEG are on same colorspace
+ if (cmsGetColorSpace(hIn) != _cmsICCcolorSpace(T_COLORSPACE(wInput)))
+ FatalError("Input profile is not operating in proper color space");
+
+
+ // Output colorspace is given by output profile
+
+ if (lIsDeviceLink) {
+ OutputColorSpace = GetDevicelinkColorSpace(hIn);
+ }
+ else {
+ OutputColorSpace = GetProfileColorSpace(hOut);
+ }
+
+ jpeg_copy_critical_parameters(&Decompressor, &Compressor);
+
+ WriteOutputFields(OutputColorSpace);
+
+ wOutput = ComputeOutputFormatDescriptor(wInput, OutputColorSpace);
+
+
+ xform = cmsCreateProofingTransform(hIn, wInput,
+ hOut, wOutput,
+ hProof, Intent,
+ ProofingIntent, dwFlags);
+ if (xform == NULL)
+ FatalError("Cannot transform by using the profiles");
+
+ DoTransform(xform, OutputColorSpace);
+
+
+ jcopy_markers_execute(&Decompressor, &Compressor);
+
+ cmsDeleteTransform(xform);
+ cmsCloseProfile(hIn);
+ cmsCloseProfile(hOut);
+ if (hProof) cmsCloseProfile(hProof);
+
+ return 1;
+}
+
+
+// Simply print help
+
+static
+void Help(int level)
+{
+ fprintf(stderr, "little cms ICC profile applier for JPEG - v3.2 [LittleCMS %2.2f]\n\n", LCMS_VERSION / 1000.0);
+
+ switch(level) {
+
+ default:
+ case 0:
+
+ fprintf(stderr, "usage: jpgicc [flags] input.jpg output.jpg\n");
+
+ fprintf(stderr, "\nflags:\n\n");
+ fprintf(stderr, "%cv - Verbose\n", SW);
+ fprintf(stderr, "%ci<profile> - Input profile (defaults to sRGB)\n", SW);
+ fprintf(stderr, "%co<profile> - Output profile (defaults to sRGB)\n", SW);
+
+ PrintRenderingIntents();
+
+
+ fprintf(stderr, "%cb - Black point compensation\n", SW);
+ fprintf(stderr, "%cd<0..1> - Observer adaptation state (abs.col. only)\n", SW);
+ fprintf(stderr, "%cn - Ignore embedded profile\n", SW);
+ fprintf(stderr, "%ce - Embed destination profile\n", SW);
+ fprintf(stderr, "%cs<new profile> - Save embedded profile as <new profile>\n", SW);
+
+ fprintf(stderr, "\n");
+
+ fprintf(stderr, "%cc<0,1,2,3> - Precalculates transform (0=Off, 1=Normal, 2=Hi-res, 3=LoRes) [defaults to 1]\n", SW);
+ fprintf(stderr, "\n");
+
+ fprintf(stderr, "%cp<profile> - Soft proof profile\n", SW);
+ fprintf(stderr, "%cm<0,1,2,3> - SoftProof intent\n", SW);
+ fprintf(stderr, "%cg - Marks out-of-gamut colors on softproof\n", SW);
+ fprintf(stderr, "%c!<r>,<g>,<b> - Out-of-gamut marker channel values\n", SW);
+
+ fprintf(stderr, "\n");
+ fprintf(stderr, "%cq<0..100> - Output JPEG quality\n", SW);
+
+ fprintf(stderr, "\n");
+ fprintf(stderr, "%ch<0,1,2,3> - More help\n", SW);
+ break;
+
+ case 1:
+
+ fprintf(stderr, "Examples:\n\n"
+ "To color correct from scanner to sRGB:\n"
+ "\tjpgicc %ciscanner.icm in.jpg out.jpg\n"
+ "To convert from monitor1 to monitor2:\n"
+ "\tjpgicc %cimon1.icm %comon2.icm in.jpg out.jpg\n"
+ "To make a CMYK separation:\n"
+ "\tjpgicc %coprinter.icm inrgb.jpg outcmyk.jpg\n"
+ "To recover sRGB from a CMYK separation:\n"
+ "\tjpgicc %ciprinter.icm incmyk.jpg outrgb.jpg\n"
+ "To convert from CIELab ITU/Fax JPEG to sRGB\n"
+ "\tjpgicc in.jpg out.jpg\n\n",
+ SW, SW, SW, SW, SW);
+ break;
+
+ case 2:
+ PrintBuiltins();
+ break;
+
+ case 3:
+
+ fprintf(stderr, "This program is intended to be a demo of the little cms\n"
+ "engine. Both lcms and this program are freeware. You can\n"
+ "obtain both in source code at http://www.littlecms.com\n"
+ "For suggestions, comments, bug reports etc. send mail to\n"
+ "marti@littlecms.com\n\n");
+ break;
+ }
+
+ exit(0);
+}
+
+
+// The toggles stuff
+
+static
+void HandleSwitches(int argc, char *argv[])
+{
+ int s;
+
+ while ((s=xgetopt(argc,argv,"bBnNvVGgh:H:i:I:o:O:P:p:t:T:c:C:Q:q:M:m:L:l:eEs:S:!:D:d:")) != EOF) {
+
+ switch (s)
+ {
+
+ case 'b':
+ case 'B':
+ BlackPointCompensation = TRUE;
+ break;
+
+ case 'd':
+ case 'D': ObserverAdaptationState = atof(xoptarg);
+ if (ObserverAdaptationState < 0 ||
+ ObserverAdaptationState > 1.0)
+ FatalError("Adaptation state should be 0..1");
+ break;
+
+ case 'v':
+ case 'V':
+ Verbose = TRUE;
+ break;
+
+ case 'i':
+ case 'I':
+ if (lIsDeviceLink)
+ FatalError("Device-link already specified");
+
+ cInpProf = xoptarg;
+ break;
+
+ case 'o':
+ case 'O':
+ if (lIsDeviceLink)
+ FatalError("Device-link already specified");
+
+ cOutProf = xoptarg;
+ break;
+
+ case 'l':
+ case 'L':
+ if (cInpProf != NULL || cOutProf != NULL)
+ FatalError("input/output profiles already specified");
+
+ cInpProf = xoptarg;
+ lIsDeviceLink = TRUE;
+ break;
+
+ case 'p':
+ case 'P':
+ cProofing = xoptarg;
+ break;
+
+ case 't':
+ case 'T':
+ Intent = atoi(xoptarg);
+ break;
+
+ case 'N':
+ case 'n':
+ IgnoreEmbedded = TRUE;
+ break;
+
+ case 'e':
+ case 'E':
+ EmbedProfile = TRUE;
+ break;
+
+
+ case 'g':
+ case 'G':
+ GamutCheck = TRUE;
+ break;
+
+ case 'c':
+ case 'C':
+ PrecalcMode = atoi(xoptarg);
+ if (PrecalcMode < 0 || PrecalcMode > 2)
+ FatalError("Unknown precalc mode '%d'", PrecalcMode);
+ break;
+
+ case 'H':
+ case 'h': {
+
+ int a = atoi(xoptarg);
+ Help(a);
+ }
+ break;
+
+ case 'q':
+ case 'Q':
+ jpegQuality = atoi(xoptarg);
+ if (jpegQuality > 100) jpegQuality = 100;
+ if (jpegQuality < 0) jpegQuality = 0;
+ break;
+
+ case 'm':
+ case 'M':
+ ProofingIntent = atoi(xoptarg);
+ break;
+
+ case 's':
+ case 'S': SaveEmbedded = xoptarg;
+ break;
+
+ case '!':
+ if (sscanf(xoptarg, "%hu,%hu,%hu", &Alarm[0], &Alarm[1], &Alarm[2]) == 3) {
+ int i;
+ for (i=0; i < 3; i++) {
+ Alarm[i] = (Alarm[i] << 8) | Alarm[i];
+ }
+ }
+ break;
+
+ default:
+
+ FatalError("Unknown option - run without args to see valid ones");
+ }
+
+ }
+}
+
+
+int main(int argc, char* argv[])
+{
+ InitUtils("jpgicc");
+
+ HandleSwitches(argc, argv);
+
+ if ((argc - xoptind) != 2) {
+ Help(0);
+ }
+
+ OpenInput(argv[xoptind]);
+ OpenOutput(argv[xoptind+1]);
+
+ TransformImage(cInpProf, cOutProf);
+
+
+ if (Verbose) { fprintf(stdout, "\n"); fflush(stdout); }
+
+ Done();
+
+ return 0;
+}
+
+
+
diff --git a/utils/matlab/icctrans.c b/utils/matlab/icctrans.c
index d6cdfed..2125f94 100755..100644
--- a/utils/matlab/icctrans.c
+++ b/utils/matlab/icctrans.c
@@ -611,14 +611,14 @@ void PrintHelp(void)
mexPrintf("\nYou can use following built-ins as profiles:\n\n");
- mexPrintf("\t*Lab2 -- D50-based v2 CIEL*a*b\n"
- "\t*Lab4 -- D50-based v4 CIEL*a*b\n"
- "\t*Lab -- D50-based v4 CIEL*a*b\n"
- "\t*XYZ -- CIE XYZ (PCS)\n"
- "\t*sRGB -- IEC6 1996-2.1 sRGB color space\n"
- "\t*Gray22 - Monochrome of Gamma 2.2\n"
- "\t*Gray30 - Monochrome of Gamma 3.0\n"
- "\t*null - Monochrome black for all input\n"
+ mexPrintf("\t*Lab2 -- D50-based v2 CIEL*a*b\n"
+ "\t*Lab4 -- D50-based v4 CIEL*a*b\n"
+ "\t*Lab -- D50-based v4 CIEL*a*b\n"
+ "\t*XYZ -- CIE XYZ (PCS)\n"
+ "\t*sRGB -- IEC6 1996-2.1 sRGB color space\n"
+ "\t*Gray22 - Monochrome of Gamma 2.2\n"
+ "\t*Gray30 - Monochrome of Gamma 3.0\n"
+ "\t*null - Monochrome black for all input\n"
"\t*Lin2222- CMYK linearization of gamma 2.2 on each channel\n\n");
mexPrintf("For suggestions, comments, bug reports etc. send mail to info@littlecms.com\n\n");
diff --git a/utils/matlab/lcms_rsp b/utils/matlab/lcms_rsp
index c2b8c8d..c2b8c8d 100755..100644
--- a/utils/matlab/lcms_rsp
+++ b/utils/matlab/lcms_rsp
diff --git a/utils/samples/vericc.c b/utils/samples/vericc.c
index 9ac94a7..9ac94a7 100755..100644
--- a/utils/samples/vericc.c
+++ b/utils/samples/vericc.c