summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarti Maria <info@littlecms.com>2013-05-13 12:01:21 +0200
committerMarti Maria <info@littlecms.com>2013-05-13 12:01:21 +0200
commit861a932020b8da50328b44ad26e1f41fb1cc3191 (patch)
tree30b67fc51385133ce2994ac57cb6b32f28bc3d22
parentf54d4b0a44df66ce8f47750669ccd80c12127c47 (diff)
downloadlcms2-861a932020b8da50328b44ad26e1f41fb1cc3191.tar.gz
Clean tabs & format after the GIT merge disaster
-rw-r--r--ChangeLog1
-rw-r--r--src/cmscam02.c112
-rw-r--r--src/cmscnvrt.c84
-rw-r--r--src/cmserr.c2
-rw-r--r--src/cmsgamma.c16
-rw-r--r--src/cmsgmt.c222
-rw-r--r--src/cmsio0.c167
-rw-r--r--src/cmsio1.c128
-rw-r--r--src/cmsmd5.c2
-rw-r--r--src/cmsmtrx.c14
-rw-r--r--src/cmsopt.c26
-rw-r--r--src/cmspcs.c8
-rw-r--r--src/cmsps2.c2
-rw-r--r--src/cmssamp.c30
-rw-r--r--src/cmssm.c16
-rw-r--r--src/cmstypes.c8
-rw-r--r--src/cmsvirt.c114
-rw-r--r--src/cmswtpnt.c240
-rw-r--r--testbed/testcms2.c60
-rw-r--r--utils/jpgicc/jpgicc.c224
-rw-r--r--utils/transicc/transicc.c50
21 files changed, 758 insertions, 768 deletions
diff --git a/ChangeLog b/ChangeLog
index 6cb877e..3d6f1be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -106,3 +106,4 @@ More changes from Artifex
Added TIFF Lab16 handling on tifficc
Added some fixes from XhmikosR
Fixed a bug in parametric curves
+Remove spurious tabs added by git merge of pull request
diff --git a/src/cmscam02.c b/src/cmscam02.c
index 4532c3e..6aeed1e 100644
--- a/src/cmscam02.c
+++ b/src/cmscam02.c
@@ -52,7 +52,7 @@ typedef struct {
cmsUInt32Number surround;
cmsFloat64Number n, Nbb, Ncb, z, FL, D;
- cmsContext ContextID;
+ cmsContext ContextID;
} cmsCIECAM02;
@@ -358,70 +358,70 @@ CAM02COLOR CAT02toXYZ(CAM02COLOR clr)
cmsHANDLE CMSEXPORT cmsCIECAM02Init(cmsContext ContextID, const cmsViewingConditions* pVC)
{
- cmsCIECAM02* lpMod;
+ cmsCIECAM02* lpMod;
- _cmsAssert(pVC != NULL);
+ _cmsAssert(pVC != NULL);
- if((lpMod = (cmsCIECAM02*) _cmsMallocZero(ContextID, sizeof(cmsCIECAM02))) == NULL) {
- return NULL;
- }
+ if((lpMod = (cmsCIECAM02*) _cmsMallocZero(ContextID, sizeof(cmsCIECAM02))) == NULL) {
+ return NULL;
+ }
- lpMod ->ContextID = ContextID;
+ lpMod ->ContextID = ContextID;
- lpMod ->adoptedWhite.XYZ[0] = pVC ->whitePoint.X;
- lpMod ->adoptedWhite.XYZ[1] = pVC ->whitePoint.Y;
- lpMod ->adoptedWhite.XYZ[2] = pVC ->whitePoint.Z;
+ lpMod ->adoptedWhite.XYZ[0] = pVC ->whitePoint.X;
+ lpMod ->adoptedWhite.XYZ[1] = pVC ->whitePoint.Y;
+ lpMod ->adoptedWhite.XYZ[2] = pVC ->whitePoint.Z;
- lpMod -> LA = pVC ->La;
- lpMod -> Yb = pVC ->Yb;
- lpMod -> D = pVC ->D_value;
- lpMod -> surround = pVC ->surround;
+ lpMod -> LA = pVC ->La;
+ lpMod -> Yb = pVC ->Yb;
+ lpMod -> D = pVC ->D_value;
+ lpMod -> surround = pVC ->surround;
- switch (lpMod -> surround) {
+ switch (lpMod -> surround) {
- case CUTSHEET_SURROUND:
- lpMod->F = 0.8;
- lpMod->c = 0.41;
- lpMod->Nc = 0.8;
- break;
+ case CUTSHEET_SURROUND:
+ lpMod->F = 0.8;
+ lpMod->c = 0.41;
+ lpMod->Nc = 0.8;
+ break;
- case DARK_SURROUND:
- lpMod -> F = 0.8;
- lpMod -> c = 0.525;
- lpMod -> Nc = 0.8;
- break;
+ case DARK_SURROUND:
+ lpMod -> F = 0.8;
+ lpMod -> c = 0.525;
+ lpMod -> Nc = 0.8;
+ break;
- case DIM_SURROUND:
- lpMod -> F = 0.9;
- lpMod -> c = 0.59;
- lpMod -> Nc = 0.95;
- break;
+ case DIM_SURROUND:
+ lpMod -> F = 0.9;
+ lpMod -> c = 0.59;
+ lpMod -> Nc = 0.95;
+ break;
- default:
- // Average surround
- lpMod -> F = 1.0;
- lpMod -> c = 0.69;
- lpMod -> Nc = 1.0;
- }
+ default:
+ // Average surround
+ lpMod -> F = 1.0;
+ lpMod -> c = 0.69;
+ lpMod -> Nc = 1.0;
+ }
- lpMod -> n = compute_n(lpMod);
- lpMod -> z = compute_z(lpMod);
- lpMod -> Nbb = computeNbb(lpMod);
- lpMod -> FL = computeFL(lpMod);
+ lpMod -> n = compute_n(lpMod);
+ lpMod -> z = compute_z(lpMod);
+ lpMod -> Nbb = computeNbb(lpMod);
+ lpMod -> FL = computeFL(lpMod);
- if (lpMod -> D == D_CALCULATE) {
- lpMod -> D = computeD(lpMod);
- }
+ if (lpMod -> D == D_CALCULATE) {
+ lpMod -> D = computeD(lpMod);
+ }
- lpMod -> Ncb = lpMod -> Nbb;
+ lpMod -> Ncb = lpMod -> Nbb;
- lpMod -> adoptedWhite = XYZtoCAT02(lpMod -> adoptedWhite);
- lpMod -> adoptedWhite = ChromaticAdaptation(lpMod -> adoptedWhite, lpMod);
- lpMod -> adoptedWhite = CAT02toHPE(lpMod -> adoptedWhite);
- lpMod -> adoptedWhite = NonlinearCompression(lpMod -> adoptedWhite, lpMod);
+ lpMod -> adoptedWhite = XYZtoCAT02(lpMod -> adoptedWhite);
+ lpMod -> adoptedWhite = ChromaticAdaptation(lpMod -> adoptedWhite, lpMod);
+ lpMod -> adoptedWhite = CAT02toHPE(lpMod -> adoptedWhite);
+ lpMod -> adoptedWhite = NonlinearCompression(lpMod -> adoptedWhite, lpMod);
- return (cmsHANDLE) lpMod;
+ return (cmsHANDLE) lpMod;
}
@@ -429,7 +429,7 @@ void CMSEXPORT cmsCIECAM02Done(cmsHANDLE hModel)
{
cmsCIECAM02* lpMod = (cmsCIECAM02*) hModel;
- if (lpMod) _cmsFree(lpMod ->ContextID, lpMod);
+ if (lpMod) _cmsFree(lpMod ->ContextID, lpMod);
}
@@ -438,9 +438,9 @@ void CMSEXPORT cmsCIECAM02Forward(cmsHANDLE hModel, const cmsCIEXYZ* pIn, cmsJCh
CAM02COLOR clr;
cmsCIECAM02* lpMod = (cmsCIECAM02*) hModel;
- _cmsAssert(lpMod != NULL);
- _cmsAssert(pIn != NULL);
- _cmsAssert(pOut != NULL);
+ _cmsAssert(lpMod != NULL);
+ _cmsAssert(pIn != NULL);
+ _cmsAssert(pOut != NULL);
clr.XYZ[0] = pIn ->X;
clr.XYZ[1] = pIn ->Y;
@@ -462,9 +462,9 @@ void CMSEXPORT cmsCIECAM02Reverse(cmsHANDLE hModel, const cmsJCh* pIn, cmsCIEXYZ
CAM02COLOR clr;
cmsCIECAM02* lpMod = (cmsCIECAM02*) hModel;
- _cmsAssert(lpMod != NULL);
- _cmsAssert(pIn != NULL);
- _cmsAssert(pOut != NULL);
+ _cmsAssert(lpMod != NULL);
+ _cmsAssert(pIn != NULL);
+ _cmsAssert(pOut != NULL);
clr.J = pIn -> J;
clr.C = pIn -> C;
diff --git a/src/cmscnvrt.c b/src/cmscnvrt.c
index 0185c64..908f787 100644
--- a/src/cmscnvrt.c
+++ b/src/cmscnvrt.c
@@ -382,63 +382,61 @@ cmsBool AddConversion(cmsPipeline* Result, cmsColorSpaceSignature InPCS, cmsColo
// Handle PCS mismatches. A specialized stage is added to the LUT in such case
switch (InPCS) {
- case cmsSigXYZData: // Input profile operates in XYZ
+ case cmsSigXYZData: // Input profile operates in XYZ
- switch (OutPCS) {
+ switch (OutPCS) {
- case cmsSigXYZData: // XYZ -> XYZ
- if (!IsEmptyLayer(m, off) &&
- !cmsPipelineInsertStage(Result, cmsAT_END, cmsStageAllocMatrix(Result ->ContextID, 3, 3, m_as_dbl, off_as_dbl)))
- return FALSE;
- break;
-
- case cmsSigLabData: // XYZ -> Lab
- if (!IsEmptyLayer(m, off) &&
- !cmsPipelineInsertStage(Result, cmsAT_END, cmsStageAllocMatrix(Result ->ContextID, 3, 3, m_as_dbl, off_as_dbl)))
- return FALSE;
- if (!cmsPipelineInsertStage(Result, cmsAT_END, _cmsStageAllocXYZ2Lab(Result ->ContextID)))
- return FALSE;
- break;
+ case cmsSigXYZData: // XYZ -> XYZ
+ if (!IsEmptyLayer(m, off) &&
+ !cmsPipelineInsertStage(Result, cmsAT_END, cmsStageAllocMatrix(Result ->ContextID, 3, 3, m_as_dbl, off_as_dbl)))
+ return FALSE;
+ break;
- default:
- return FALSE; // Colorspace mismatch
- }
- break;
+ case cmsSigLabData: // XYZ -> Lab
+ if (!IsEmptyLayer(m, off) &&
+ !cmsPipelineInsertStage(Result, cmsAT_END, cmsStageAllocMatrix(Result ->ContextID, 3, 3, m_as_dbl, off_as_dbl)))
+ return FALSE;
+ if (!cmsPipelineInsertStage(Result, cmsAT_END, _cmsStageAllocXYZ2Lab(Result ->ContextID)))
+ return FALSE;
+ break;
+ default:
+ return FALSE; // Colorspace mismatch
+ }
+ break;
- case cmsSigLabData: // Input profile operates in Lab
+ case cmsSigLabData: // Input profile operates in Lab
- switch (OutPCS) {
+ switch (OutPCS) {
- case cmsSigXYZData: // Lab -> XYZ
+ case cmsSigXYZData: // Lab -> XYZ
- if (!cmsPipelineInsertStage(Result, cmsAT_END, _cmsStageAllocLab2XYZ(Result ->ContextID)))
- return FALSE;
- if (!IsEmptyLayer(m, off) &&
- !cmsPipelineInsertStage(Result, cmsAT_END, cmsStageAllocMatrix(Result ->ContextID, 3, 3, m_as_dbl, off_as_dbl)))
- return FALSE;
- break;
-
- case cmsSigLabData: // Lab -> Lab
+ if (!cmsPipelineInsertStage(Result, cmsAT_END, _cmsStageAllocLab2XYZ(Result ->ContextID)))
+ return FALSE;
+ if (!IsEmptyLayer(m, off) &&
+ !cmsPipelineInsertStage(Result, cmsAT_END, cmsStageAllocMatrix(Result ->ContextID, 3, 3, m_as_dbl, off_as_dbl)))
+ return FALSE;
+ break;
- if (!IsEmptyLayer(m, off)) {
- if (!cmsPipelineInsertStage(Result, cmsAT_END, _cmsStageAllocLab2XYZ(Result ->ContextID)) ||
- !cmsPipelineInsertStage(Result, cmsAT_END, cmsStageAllocMatrix(Result ->ContextID, 3, 3, m_as_dbl, off_as_dbl)) ||
- !cmsPipelineInsertStage(Result, cmsAT_END, _cmsStageAllocXYZ2Lab(Result ->ContextID)))
- return FALSE;
- }
- break;
+ case cmsSigLabData: // Lab -> Lab
- default:
- return FALSE; // Mismatch
+ if (!IsEmptyLayer(m, off)) {
+ if (!cmsPipelineInsertStage(Result, cmsAT_END, _cmsStageAllocLab2XYZ(Result ->ContextID)) ||
+ !cmsPipelineInsertStage(Result, cmsAT_END, cmsStageAllocMatrix(Result ->ContextID, 3, 3, m_as_dbl, off_as_dbl)) ||
+ !cmsPipelineInsertStage(Result, cmsAT_END, _cmsStageAllocXYZ2Lab(Result ->ContextID)))
+ return FALSE;
}
break;
-
- // On colorspaces other than PCS, check for same space
default:
- if (InPCS != OutPCS) return FALSE;
- break;
+ return FALSE; // Mismatch
+ }
+ break;
+
+ // On colorspaces other than PCS, check for same space
+ default:
+ if (InPCS != OutPCS) return FALSE;
+ break;
}
return TRUE;
diff --git a/src/cmserr.c b/src/cmserr.c
index 5756c0d..166793f 100644
--- a/src/cmserr.c
+++ b/src/cmserr.c
@@ -273,8 +273,6 @@ _cmsSubAllocator_chunk* _cmsCreateSubAllocChunk(cmsContext ContextID, cmsUInt32N
return NULL;
}
-
-
chunk ->BlockSize = Initial;
chunk ->Used = 0;
chunk ->next = NULL;
diff --git a/src/cmsgamma.c b/src/cmsgamma.c
index a43d086..e153103 100644
--- a/src/cmsgamma.c
+++ b/src/cmsgamma.c
@@ -430,7 +430,7 @@ cmsFloat64Number DefaultEvalParametricFn(cmsInt32Number Type, const cmsFloat64Nu
e = Params[1]*R + Params[2];
if (e < 0)
- Val = 0;
+ Val = Params[3];
else
Val = pow(e, Params[0]) + Params[3];
break;
@@ -450,7 +450,7 @@ cmsFloat64Number DefaultEvalParametricFn(cmsInt32Number Type, const cmsFloat64Nu
e = Params[2] * pow(R, Params[0]) + Params[3];
if (e <= 0)
- Val = 0;
+ Val = Params[4];
else
Val = Params[1]*log10(e) + Params[4];
break;
@@ -623,17 +623,17 @@ cmsToneCurve* CMSEXPORT cmsBuildTabulatedToneCurveFloat(cmsContext ContextID, cm
Seg[1].nGridPoints = nEntries;
Seg[1].SampledPoints = (cmsFloat32Number*) values;
- // Final segment is constant = lastsample
- Seg[2].x0 = 1.0;
- Seg[2].x1 = PLUS_INF;
- Seg[2].Type = 6;
-
+ // Final segment is constant = lastsample
+ Seg[2].x0 = 1.0;
+ Seg[2].x1 = PLUS_INF;
+ Seg[2].Type = 6;
+
Seg[2].Params[0] = 1;
Seg[2].Params[1] = 0;
Seg[2].Params[2] = 0;
Seg[2].Params[3] = values[nEntries-1];
Seg[2].Params[4] = 0;
-
+
return cmsBuildSegmentedToneCurve(ContextID, 3, Seg);
}
diff --git a/src/cmsgmt.c b/src/cmsgmt.c
index 061b6d6..ea977d0 100644
--- a/src/cmsgmt.c
+++ b/src/cmsgmt.c
@@ -285,106 +285,106 @@ int GamutSampler(register const cmsUInt16Number In[], register cmsUInt16Number O
// 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 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);
+ 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);
@@ -397,17 +397,17 @@ cmsPipeline* _cmsCreateGamutCheckPipeline(cmsContext ContextID,
}
}
}
- else
- Gamut = NULL; // Didn't work...
+ 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);
+ // 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;
+ // And return computed hull
+ return Gamut;
}
// Total Area Coverage estimation ----------------------------------------------------------------
@@ -493,9 +493,9 @@ cmsFloat64Number CMSEXPORT cmsDetectTAC(cmsHPROFILE hProfile)
GridPoints[2] = 74;
- if (!cmsSliceSpace16(3, GridPoints, EstimateTAC, &bp)) {
- bp.MaxTAC = 0;
- }
+ if (!cmsSliceSpace16(3, GridPoints, EstimateTAC, &bp)) {
+ bp.MaxTAC = 0;
+ }
cmsDeleteTransform(bp.hRoundTrip);
diff --git a/src/cmsio0.c b/src/cmsio0.c
index f0a926f..b7aea72 100644
--- a/src/cmsio0.c
+++ b/src/cmsio0.c
@@ -186,19 +186,24 @@ cmsUInt32Number MemoryTell(struct _cms_io_handler* iohandler)
{
FILEMEM* ResData = (FILEMEM*) iohandler ->stream;
- if (ResData == NULL) return 0;
+ if (ResData == NULL) return 0;
return ResData -> Pointer;
}
// Writes data to memory, also keeps used space for further reference.
static
-cmsBool MemoryWrite(struct _cms_io_handler* iohandler, cmsUInt32Number size, const void *Ptr)
+cmsBool MemoryWrite(struct _cms_io_handler* iohandler, cmsUInt32Number size, const void *Ptr)
{
FILEMEM* ResData = (FILEMEM*) iohandler ->stream;
- if (ResData == NULL) return FALSE; // Housekeeping
+ if (ResData == NULL) return FALSE; // Housekeeping
+ // Check for available space. Clip.
+ if (iohandler ->UsedSpace + size > ResData->Size) {
+ size = ResData ->Size - iohandler ->UsedSpace;
+ }
+
if (size == 0) return TRUE; // Write zero bytes is ok, but does nothing
memmove(ResData ->Block + ResData ->Pointer, Ptr, size);
@@ -236,7 +241,7 @@ cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromMem(cmsContext ContextID, void *Buff
cmsIOHANDLER* iohandler = NULL;
FILEMEM* fm = NULL;
- _cmsAssert(AccessMode != NULL);
+ _cmsAssert(AccessMode != NULL);
iohandler = (cmsIOHANDLER*) _cmsMallocZero(ContextID, sizeof(cmsIOHANDLER));
if (iohandler == NULL) return NULL;
@@ -484,7 +489,7 @@ cmsContext CMSEXPORT cmsGetProfileContextID(cmsHPROFILE hProfile)
cmsInt32Number CMSEXPORT cmsGetTagCount(cmsHPROFILE hProfile)
{
_cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- if (Icc == NULL) return -1;
+ if (Icc == NULL) return -1;
return Icc->TagCount;
}
@@ -504,45 +509,45 @@ cmsTagSignature CMSEXPORT cmsGetTagSignature(cmsHPROFILE hProfile, cmsUInt32Numb
static
int SearchOneTag(_cmsICCPROFILE* Profile, cmsTagSignature sig)
{
- cmsUInt32Number i;
+ cmsUInt32Number i;
- for (i=0; i < Profile -> TagCount; i++) {
+ for (i=0; i < Profile -> TagCount; i++) {
- if (sig == Profile -> TagNames[i])
- return i;
- }
+ if (sig == Profile -> TagNames[i])
+ return i;
+ }
- return -1;
+ return -1;
}
// Search for a specific tag in tag dictionary. Returns position or -1 if tag not found.
// If followlinks is turned on, then the position of the linked tag is returned
int _cmsSearchTag(_cmsICCPROFILE* Icc, cmsTagSignature sig, cmsBool lFollowLinks)
{
- int n;
- cmsTagSignature LinkedSig;
+ int n;
+ cmsTagSignature LinkedSig;
- do {
+ do {
- // Search for given tag in ICC profile directory
- n = SearchOneTag(Icc, sig);
- if (n < 0)
- return -1; // Not found
+ // Search for given tag in ICC profile directory
+ n = SearchOneTag(Icc, sig);
+ if (n < 0)
+ return -1; // Not found
- if (!lFollowLinks)
- return n; // Found, don't follow links
+ if (!lFollowLinks)
+ return n; // Found, don't follow links
- // Is this a linked tag?
- LinkedSig = Icc ->TagLinked[n];
+ // Is this a linked tag?
+ LinkedSig = Icc ->TagLinked[n];
- // Yes, follow link
- if (LinkedSig != (cmsTagSignature) 0) {
- sig = LinkedSig;
- }
+ // Yes, follow link
+ if (LinkedSig != (cmsTagSignature) 0) {
+ sig = LinkedSig;
+ }
- } while (LinkedSig != (cmsTagSignature) 0);
+ } while (LinkedSig != (cmsTagSignature) 0);
- return n;
+ return n;
}
@@ -551,9 +556,9 @@ int _cmsSearchTag(_cmsICCPROFILE* Icc, cmsTagSignature sig, cmsBool lFollowLinks
static
cmsBool _cmsNewTag(_cmsICCPROFILE* Icc, cmsTagSignature sig, int* NewPos)
{
- int i;
+ int i;
- // Search for the tag
+ // Search for the tag
i = _cmsSearchTag(Icc, sig, FALSE);
// Now let's do it easy. If the tag has been already written, that's an error
@@ -570,11 +575,11 @@ cmsBool _cmsNewTag(_cmsICCPROFILE* Icc, cmsTagSignature sig, int* NewPos)
return FALSE;
}
- *NewPos = Icc ->TagCount;
+ *NewPos = Icc ->TagCount;
Icc -> TagCount++;
}
- return TRUE;
+ return TRUE;
}
@@ -1031,8 +1036,8 @@ cmsHPROFILE CMSEXPORT cmsOpenProfileFromMemTHR(cmsContext ContextID, const void*
NewIcc = (_cmsICCPROFILE*) hEmpty;
- // Ok, in this case const void* is casted to void* just because open IO handler
- // shares read and writting modes. Don't abuse this feature!
+ // Ok, in this case const void* is casted to void* just because open IO handler
+ // shares read and writting modes. Don't abuse this feature!
NewIcc ->IOhandler = cmsOpenIOhandlerFromMem(ContextID, (void*) MemPtr, dwSize, "r");
if (NewIcc ->IOhandler == NULL) goto Error;
@@ -1069,7 +1074,6 @@ cmsBool SaveTags(_cmsICCPROFILE* Icc, _cmsICCPROFILE* FileOrig)
for (i=0; i < Icc -> TagCount; i++) {
-
if (Icc ->TagNames[i] == 0) continue;
// Linked tags are not written
@@ -1375,24 +1379,24 @@ void* CMSEXPORT cmsReadTag(cmsHPROFILE hProfile, cmsTagSignature sig)
cmsUInt32Number ElemCount;
int n;
- n = _cmsSearchTag(Icc, sig, TRUE);
- if (n < 0) return NULL; // Not found, return NULL
+ n = _cmsSearchTag(Icc, sig, TRUE);
+ if (n < 0) return NULL; // Not found, return NULL
- // If the element is already in memory, return the pointer
- if (Icc -> TagPtrs[n]) {
+ // If the element is already in memory, return the pointer
+ if (Icc -> TagPtrs[n]) {
- if (Icc ->TagSaveAsRaw[n]) return NULL; // We don't support read raw tags as cooked
- return Icc -> TagPtrs[n];
- }
+ if (Icc ->TagSaveAsRaw[n]) return NULL; // We don't support read raw tags as cooked
+ return Icc -> TagPtrs[n];
+ }
- // We need to read it. Get the offset and size to the file
+ // We need to read it. Get the offset and size to the file
Offset = Icc -> TagOffsets[n];
TagSize = Icc -> TagSizes[n];
// Seek to its location
if (!io -> Seek(io, Offset))
- return NULL;
+ return NULL;
// Search for support on this tag
TagDescriptor = _cmsGetTagDescriptor(sig);
@@ -1438,7 +1442,7 @@ void* CMSEXPORT cmsReadTag(cmsHPROFILE hProfile, cmsTagSignature sig)
_cmsTagSignature2String(String, sig);
cmsSignalError(Icc ->ContextID, cmsERROR_CORRUPTION_DETECTED, "'%s' Inconsistent number of items: expected %d, got %d",
- String, TagDescriptor ->ElemCount, ElemCount);
+ String, TagDescriptor ->ElemCount, ElemCount);
}
@@ -1450,17 +1454,17 @@ void* CMSEXPORT cmsReadTag(cmsHPROFILE hProfile, cmsTagSignature sig)
// Get true type of data
cmsTagTypeSignature _cmsGetTagTrueType(cmsHPROFILE hProfile, cmsTagSignature sig)
{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
- cmsTagTypeHandler* TypeHandler;
- int n;
+ _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
+ cmsTagTypeHandler* TypeHandler;
+ int n;
- // Search for given tag in ICC profile directory
- n = _cmsSearchTag(Icc, sig, TRUE);
- if (n < 0) return (cmsTagTypeSignature) 0; // Not found, return NULL
+ // Search for given tag in ICC profile directory
+ n = _cmsSearchTag(Icc, sig, TRUE);
+ if (n < 0) return (cmsTagTypeSignature) 0; // Not found, return NULL
- // Get the handler. The true type is there
- TypeHandler = Icc -> TagTypeHandlers[n];
- return TypeHandler ->Signature;
+ // Get the handler. The true type is there
+ TypeHandler = Icc -> TagTypeHandlers[n];
+ return TypeHandler ->Signature;
}
@@ -1616,27 +1620,28 @@ cmsInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature sig
cmsUInt32Number rc;
cmsUInt32Number Offset, TagSize;
- // Search for given tag in ICC profile directory
- i = _cmsSearchTag(Icc, sig, TRUE);
- if (i < 0) return 0; // Not found, return 0
+ // Search for given tag in ICC profile directory
+ i = _cmsSearchTag(Icc, sig, TRUE);
+ if (i < 0) return 0; // Not found, return 0
- // It is already read?
+ // It is already read?
if (Icc -> TagPtrs[i] == NULL) {
// No yet, get original position
Offset = Icc ->TagOffsets[i];
TagSize = Icc ->TagSizes[i];
-
// read the data directly, don't keep copy
- if (data != NULL) {
+ if (data != NULL) {
- if (BufferSize < TagSize)
- TagSize = BufferSize;
+ if (BufferSize < TagSize)
+ TagSize = BufferSize;
if (!Icc ->IOhandler ->Seek(Icc ->IOhandler, Offset)) return 0;
if (!Icc ->IOhandler ->Read(Icc ->IOhandler, data, 1, TagSize)) return 0;
- }
+
+ return TagSize;
+ }
return Icc ->TagSizes[i];
}
@@ -1645,14 +1650,16 @@ cmsInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature sig
// raw data. In this case, return the raw data directly
if (Icc ->TagSaveAsRaw[i]) {
- if (data != NULL) {
+ if (data != NULL) {
- TagSize = Icc ->TagSizes[i];
- if (BufferSize < TagSize)
- TagSize = BufferSize;
+ TagSize = Icc ->TagSizes[i];
+ if (BufferSize < TagSize)
+ TagSize = BufferSize;
memmove(data, Icc ->TagPtrs[i], TagSize);
- }
+
+ return TagSize;
+ }
return Icc ->TagSizes[i];
}
@@ -1664,19 +1671,19 @@ cmsInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature sig
// Now we need to serialize to a memory block: just use a memory iohandler
- if (data == NULL) {
- MemIO = cmsOpenIOhandlerFromNULL(cmsGetProfileContextID(hProfile));
- } else{
- MemIO = cmsOpenIOhandlerFromMem(cmsGetProfileContextID(hProfile), data, BufferSize, "w");
- }
+ if (data == NULL) {
+ MemIO = cmsOpenIOhandlerFromNULL(cmsGetProfileContextID(hProfile));
+ } else{
+ MemIO = cmsOpenIOhandlerFromMem(cmsGetProfileContextID(hProfile), data, BufferSize, "w");
+ }
if (MemIO == NULL) return 0;
// Obtain type handling for the tag
TypeHandler = Icc ->TagTypeHandlers[i];
TagDescriptor = _cmsGetTagDescriptor(sig);
if (TagDescriptor == NULL) {
- cmsCloseIOhandler(MemIO);
- return 0;
+ cmsCloseIOhandler(MemIO);
+ return 0;
}
// FIXME: No handling for TypeHandler == NULL here?
@@ -1711,7 +1718,7 @@ cmsBool CMSEXPORT cmsWriteRawTag(cmsHPROFILE hProfile, cmsTagSignature sig, cons
_cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
int i;
- if (!_cmsNewTag(Icc, sig, &i)) return FALSE;
+ if (!_cmsNewTag(Icc, sig, &i)) return FALSE;
// Mark the tag as being written as RAW
Icc ->TagSaveAsRaw[i] = TRUE;
@@ -1728,10 +1735,10 @@ cmsBool CMSEXPORT cmsWriteRawTag(cmsHPROFILE hProfile, cmsTagSignature sig, cons
// Using this function you can collapse several tag entries to the same block in the profile
cmsBool CMSEXPORT cmsLinkTag(cmsHPROFILE hProfile, cmsTagSignature sig, cmsTagSignature dest)
{
- _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
+ _cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
int i;
- if (!_cmsNewTag(Icc, sig, &i)) return FALSE;
+ if (!_cmsNewTag(Icc, sig, &i)) return FALSE;
// Keep necessary information
Icc ->TagSaveAsRaw[i] = FALSE;
@@ -1753,8 +1760,8 @@ cmsTagSignature CMSEXPORT cmsTagLinkedTo(cmsHPROFILE hProfile, cmsTagSignature
int i;
// Search for given tag in ICC profile directory
- i = _cmsSearchTag(Icc, sig, FALSE);
- if (i < 0) return (cmsTagSignature) 0; // Not found, return 0
+ i = _cmsSearchTag(Icc, sig, FALSE);
+ if (i < 0) return (cmsTagSignature) 0; // Not found, return 0
return Icc -> TagLinked[i];
}
diff --git a/src/cmsio1.c b/src/cmsio1.c
index 102be75..71f4910 100644
--- a/src/cmsio1.c
+++ b/src/cmsio1.c
@@ -100,7 +100,6 @@ cmsBool _cmsReadCHAD(cmsMAT3* Dest, cmsHPROFILE hProfile)
Tag = (cmsMAT3*) cmsReadTag(hProfile, cmsSigChromaticAdaptationTag);
if (Tag != NULL) {
-
*Dest = *Tag;
return TRUE;
}
@@ -183,22 +182,24 @@ cmsPipeline* BuildGrayInputMatrixPipeline(cmsHPROFILE hProfile)
LabCurves[1] = EmptyTab;
LabCurves[2] = EmptyTab;
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocMatrix(ContextID, 3, 1, OneToThreeInputMatrix, NULL)) ||
- !cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocToneCurves(ContextID, 3, LabCurves))) {
- cmsFreeToneCurve(EmptyTab);
- goto Error;
- }
+ if (!cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocMatrix(ContextID, 3, 1, OneToThreeInputMatrix, NULL)) ||
+ !cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocToneCurves(ContextID, 3, LabCurves))) {
+ cmsFreeToneCurve(EmptyTab);
+ goto Error;
+ }
cmsFreeToneCurve(EmptyTab);
}
else {
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocToneCurves(ContextID, 1, &GrayTRC)) ||
- !cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocMatrix(ContextID, 3, 1, GrayInputMatrix, NULL)))
- goto Error;
+
+ if (!cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocToneCurves(ContextID, 1, &GrayTRC)) ||
+ !cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocMatrix(ContextID, 3, 1, GrayInputMatrix, NULL)))
+ goto Error;
}
return Lut;
+
Error:
cmsFreeToneCurve(GrayTRC);
cmsPipelineFree(Lut);
@@ -235,23 +236,24 @@ cmsPipeline* BuildRGBInputMatrixShaper(cmsHPROFILE hProfile)
Lut = cmsPipelineAlloc(ContextID, 3, 3);
if (Lut != NULL) {
-
+
if (!cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocToneCurves(ContextID, 3, Shapes)) ||
!cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocMatrix(ContextID, 3, 3, (cmsFloat64Number*) &Mat, NULL)))
- goto Error;
-
+ goto Error;
+
// Note that it is certainly possible a single profile would have a LUT based
// tag for output working in lab and a matrix-shaper for the fallback cases.
// This is not allowed by the spec, but this code is tolerant to those cases
if (cmsGetPCS(hProfile) == cmsSigLabData) {
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocXYZ2Lab(ContextID)))
- goto Error;
+ if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocXYZ2Lab(ContextID)))
+ goto Error;
}
}
return Lut;
+
Error:
cmsPipelineFree(Lut);
return NULL;
@@ -260,35 +262,6 @@ Error:
// Read the DToAX tag, adjusting the encoding of Lab or XYZ if neded
-/*static
-cmsPipeline* _cmsReadFloatInputTag(cmsHPROFILE hProfile, cmsTagSignature tagFloat)
-{
- cmsContext ContextID = cmsGetProfileContextID(hProfile);
- cmsPipeline* Lut = cmsPipelineDup((cmsPipeline*) cmsReadTag(hProfile, tagFloat));
- cmsColorSpaceSignature spc = cmsGetColorSpace(hProfile);
-
- if (Lut == NULL) return NULL;
-
- // If PCS is Lab or XYZ, the floating point tag is accepting data in the space encoding,
- // and since the formatter has already accomodated to 0..1.0, we should undo this change
- if ( spc == cmsSigLabData)
- {
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromLabFloat(ContextID)))
- goto Error;
- }
- else
- if (spc == cmsSigXYZData)
- {
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromXyzFloat(ContextID)))
- goto Error;
- }
-
- return Lut;
-Error:
- cmsPipelineFree(Lut);
- return NULL;
-}
-*/
static
cmsPipeline* _cmsReadFloatInputTag(cmsHPROFILE hProfile, cmsTagSignature tagFloat)
{
@@ -324,6 +297,7 @@ cmsPipeline* _cmsReadFloatInputTag(cmsHPROFILE hProfile, cmsTagSignature tagFloa
}
return Lut;
+
Error:
cmsPipelineFree(Lut);
return NULL;
@@ -458,9 +432,10 @@ cmsPipeline* BuildGrayOutputPipeline(cmsHPROFILE hProfile)
if (!cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocToneCurves(ContextID, 1, &RevGrayTRC)))
goto Error;
- cmsFreeToneCurve(RevGrayTRC);
+ cmsFreeToneCurve(RevGrayTRC);
return Lut;
+
Error:
cmsFreeToneCurve(RevGrayTRC);
cmsPipelineFree(Lut);
@@ -468,8 +443,6 @@ Error:
}
-
-
static
cmsPipeline* BuildRGBOutputMatrixShaper(cmsHPROFILE hProfile)
{
@@ -516,13 +489,13 @@ cmsPipeline* BuildRGBOutputMatrixShaper(cmsHPROFILE hProfile)
// This is not allowed by the spec, but this code is tolerant to those cases
if (cmsGetPCS(hProfile) == cmsSigLabData) {
- if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLab2XYZ(ContextID)))
- goto Error;
+ if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLab2XYZ(ContextID)))
+ goto Error;
}
if (!cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocMatrix(ContextID, 3, 3, (cmsFloat64Number*) &Inv, NULL)) ||
!cmsPipelineInsertStage(Lut, cmsAT_END, cmsStageAllocToneCurves(ContextID, 3, InvShapes)))
- goto Error;
+ goto Error;
}
cmsFreeToneCurveTriple(InvShapes);
@@ -556,35 +529,6 @@ void ChangeInterpolationToTrilinear(cmsPipeline* Lut)
// Read the DToAX tag, adjusting the encoding of Lab or XYZ if neded
-/*static
-cmsPipeline* _cmsReadFloatOutputTag(cmsHPROFILE hProfile, cmsTagSignature tagFloat)
-{
- cmsContext ContextID = cmsGetProfileContextID(hProfile);
- cmsPipeline* Lut = cmsPipelineDup((cmsPipeline*) cmsReadTag(hProfile, tagFloat));
- cmsColorSpaceSignature PCS = cmsGetPCS(hProfile);
-
- if (Lut == NULL) return NULL;
-
- // If PCS is Lab or XYZ, the floating point tag is accepting data in the space encoding,
- // and since the formatter has already accomodated to 0..1.0, we should undo this change
- if ( PCS == cmsSigLabData)
- {
- if (!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToLabFloat(ContextID)))
- goto Error;
- }
- else
- if (PCS == cmsSigXYZData)
- {
- if (!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageNormalizeToXyzFloat(ContextID)))
- goto Error;
- }
-
- return Lut;
-Error:
- cmsPipelineFree(Lut);
- return NULL;
-}*/
-
static
cmsPipeline* _cmsReadFloatOutputTag(cmsHPROFILE hProfile, cmsTagSignature tagFloat)
{
@@ -615,13 +559,14 @@ cmsPipeline* _cmsReadFloatOutputTag(cmsHPROFILE hProfile, cmsTagSignature tagFlo
if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromLabFloat(ContextID)))
goto Error;
}
- else if ( dataSpace == cmsSigXYZData)
+ else if (dataSpace == cmsSigXYZData)
{
if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageNormalizeFromXyzFloat(ContextID)))
goto Error;
}
return Lut;
+
Error:
cmsPipelineFree(Lut);
return NULL;
@@ -664,7 +609,7 @@ cmsPipeline* _cmsReadOutputLUT(cmsHPROFILE hProfile, int Intent)
// Now it is time for a controversial stuff. I found that for 3D LUTS using
// Lab used as indexer space, trilinear interpolation should be used
if (cmsGetPCS(hProfile) == cmsSigLabData)
- ChangeInterpolationToTrilinear(Lut);
+ ChangeInterpolationToTrilinear(Lut);
// We need to adjust data only for Lab and Lut16 type
if (OriginalType != cmsSigLut16Type || cmsGetPCS(hProfile) != cmsSigLabData)
@@ -681,18 +626,18 @@ cmsPipeline* _cmsReadOutputLUT(cmsHPROFILE hProfile, int Intent)
return Lut;
Error:
- cmsPipelineFree(Lut);
- return NULL;
+ cmsPipelineFree(Lut);
+ return NULL;
}
// Lut not found, try to create a matrix-shaper
// Check if this is a grayscale profile.
- if (cmsGetColorSpace(hProfile) == cmsSigGrayData) {
+ if (cmsGetColorSpace(hProfile) == cmsSigGrayData) {
- // if so, build appropiate conversion tables.
- // The tables are the PCS iluminant, scaled across GrayTRC
- return BuildGrayOutputPipeline(hProfile);
+ // if so, build appropiate conversion tables.
+ // The tables are the PCS iluminant, scaled across GrayTRC
+ return BuildGrayOutputPipeline(hProfile);
}
// Not gray, create a normal matrix-shaper, which only operates in XYZ space
@@ -764,11 +709,13 @@ cmsPipeline* _cmsReadDevicelinkLUT(cmsHPROFILE hProfile, int Intent)
if (Lut == NULL)
goto Error;
- if (!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageAllocNamedColor(nc, FALSE)))
+ if (!cmsPipelineInsertStage(Lut, cmsAT_BEGIN, _cmsStageAllocNamedColor(nc, FALSE)))
goto Error;
+
if (cmsGetColorSpace(hProfile) == cmsSigLabData)
if (!cmsPipelineInsertStage(Lut, cmsAT_END, _cmsStageAllocLabV2ToV4(ContextID)))
goto Error;
+
return Lut;
Error:
cmsPipelineFree(Lut);
@@ -804,10 +751,10 @@ Error:
Lut = cmsPipelineDup(Lut);
if (Lut == NULL) return NULL;
- // Now it is time for a controversial stuff. I found that for 3D LUTS using
- // Lab used as indexer space, trilinear interpolation should be used
+ // Now it is time for a controversial stuff. I found that for 3D LUTS using
+ // Lab used as indexer space, trilinear interpolation should be used
if (cmsGetColorSpace(hProfile) == cmsSigLabData)
- ChangeInterpolationToTrilinear(Lut);
+ ChangeInterpolationToTrilinear(Lut);
// After reading it, we have info about the original type
OriginalType = _cmsGetTagTrueType(hProfile, tag16);
@@ -828,6 +775,7 @@ Error:
}
return Lut;
+
Error2:
cmsPipelineFree(Lut);
return NULL;
diff --git a/src/cmsmd5.c b/src/cmsmd5.c
index b52c396..966730c 100644
--- a/src/cmsmd5.c
+++ b/src/cmsmd5.c
@@ -267,7 +267,7 @@ cmsBool CMSEXPORT cmsMD5computeID(cmsHPROFILE hProfile)
_cmsICCPROFILE* Icc = (_cmsICCPROFILE*) hProfile;
_cmsICCPROFILE Keep;
- _cmsAssert(hProfile != NULL);
+ _cmsAssert(hProfile != NULL);
ContextID = cmsGetProfileContextID(hProfile);
diff --git a/src/cmsmtrx.c b/src/cmsmtrx.c
index 6195867..583b1ab 100644
--- a/src/cmsmtrx.c
+++ b/src/cmsmtrx.c
@@ -97,16 +97,16 @@ cmsBool CloseEnough(cmsFloat64Number a, cmsFloat64Number b)
cmsBool CMSEXPORT _cmsMAT3isIdentity(const cmsMAT3* a)
{
- cmsMAT3 Identity;
- int i, j;
+ cmsMAT3 Identity;
+ int i, j;
- _cmsMAT3identity(&Identity);
+ _cmsMAT3identity(&Identity);
- for (i=0; i < 3; i++)
- for (j=0; j < 3; j++)
- if (!CloseEnough(a ->v[i].n[j], Identity.v[i].n[j])) return FALSE;
+ for (i=0; i < 3; i++)
+ for (j=0; j < 3; j++)
+ if (!CloseEnough(a ->v[i].n[j], Identity.v[i].n[j])) return FALSE;
- return TRUE;
+ return TRUE;
}
diff --git a/src/cmsopt.c b/src/cmsopt.c
index 116b96a..7478e5e 100644
--- a/src/cmsopt.c
+++ b/src/cmsopt.c
@@ -553,7 +553,6 @@ cmsBool OptimizeByResampling(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3
cmsToneCurve** DataSetOut;
Prelin16Data* p16;
-
// This is a loosy optimization! does not apply in floating-point cases
if (_cmsFormatterIsFloat(*InputFormat) || _cmsFormatterIsFloat(*OutputFormat)) return FALSE;
@@ -567,10 +566,10 @@ cmsBool OptimizeByResampling(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3
Src = *Lut;
- // Named color pipelines cannot be optimized either
- for (mpe = cmsPipelineGetPtrToFirstStage(Src);
- mpe != NULL;
- mpe = cmsStageNext(mpe)) {
+ // Named color pipelines cannot be optimized either
+ for (mpe = cmsPipelineGetPtrToFirstStage(Src);
+ mpe != NULL;
+ mpe = cmsStageNext(mpe)) {
if (cmsStageType(mpe) == cmsSigNamedColorElemType) return FALSE;
}
@@ -643,12 +642,12 @@ Error:
if (!cmsPipelineInsertStage(Src, cmsAT_BEGIN, KeepPreLin)) {
_cmsAssert(0); // This never happens
}
- }
+ }
if (KeepPostLin != NULL) {
if (!cmsPipelineInsertStage(Src, cmsAT_END, KeepPostLin)) {
- _cmsAssert(0); // This never happens
+ _cmsAssert(0); // This never happens
}
- }
+ }
cmsPipelineFree(Dest);
return FALSE;
}
@@ -675,12 +674,11 @@ Error:
else {
p16 = PrelinOpt16alloc(Dest ->ContextID,
- DataCLUT ->Params,
- Dest ->InputChannels,
- DataSetIn,
- Dest ->OutputChannels,
- DataSetOut);
-
+ DataCLUT ->Params,
+ Dest ->InputChannels,
+ DataSetIn,
+ Dest ->OutputChannels,
+ DataSetOut);
_cmsPipelineSetOptimizationParameters(Dest, PrelinEval16, (void*) p16, PrelinOpt16free, Prelin16dup);
}
diff --git a/src/cmspcs.c b/src/cmspcs.c
index 3279d71..d20e6e6 100644
--- a/src/cmspcs.c
+++ b/src/cmspcs.c
@@ -169,26 +169,26 @@ void CMSEXPORT cmsLab2XYZ(const cmsCIEXYZ* WhitePoint, cmsCIEXYZ* xyz, const cm
static
cmsFloat64Number L2float2(cmsUInt16Number v)
{
- return (cmsFloat64Number) v / 652.800;
+ return (cmsFloat64Number) v / 652.800;
}
// the a/b part
static
cmsFloat64Number ab2float2(cmsUInt16Number v)
{
- return ((cmsFloat64Number) v / 256.0) - 128.0;
+ return ((cmsFloat64Number) v / 256.0) - 128.0;
}
static
cmsUInt16Number L2Fix2(cmsFloat64Number L)
{
- return _cmsQuickSaturateWord(L * 652.8);
+ return _cmsQuickSaturateWord(L * 652.8);
}
static
cmsUInt16Number ab2Fix2(cmsFloat64Number ab)
{
- return _cmsQuickSaturateWord((ab + 128.0) * 256.0);
+ return _cmsQuickSaturateWord((ab + 128.0) * 256.0);
}
diff --git a/src/cmsps2.c b/src/cmsps2.c
index a469a97..fe91500 100644
--- a/src/cmsps2.c
+++ b/src/cmsps2.c
@@ -917,7 +917,7 @@ int WriteInputLUT(cmsIOHANDLER* m, cmsHPROFILE hProfile, int Intent, cmsUInt32Nu
rc = EmitCIEBasedDEF(m, DeviceLink, Intent, &BlackPointAdaptedToD50);
cmsPipelineFree(DeviceLink);
- if (rc == 0) return 0;
+ if (rc == 0) return 0;
}
break;
diff --git a/src/cmssamp.c b/src/cmssamp.c
index 82a14b8..70e4691 100644
--- a/src/cmssamp.c
+++ b/src/cmssamp.c
@@ -197,17 +197,17 @@ cmsBool CMSEXPORT cmsDetectBlackPoint(cmsCIEXYZ* BlackPoint, cmsHPROFILE hProfil
if (devClass == cmsSigLinkClass ||
devClass == cmsSigAbstractClass ||
devClass == cmsSigNamedColorClass) {
- BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
- return FALSE;
+ BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
+ return FALSE;
}
// Make sure intent is adequate
if (Intent != INTENT_PERCEPTUAL &&
Intent != INTENT_RELATIVE_COLORIMETRIC &&
- Intent != INTENT_SATURATION) {
- BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
- return FALSE;
- }
+ Intent != INTENT_SATURATION) {
+ BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
+ return FALSE;
+ }
// v4 + perceptual & saturation intents does have its own black point, and it is
// well specified enough to use it. Black point tag is deprecated in V4.
@@ -344,8 +344,8 @@ cmsFloat64Number RootOfLeastSquaresFitQuadraticCurve(int n, cmsFloat64Number x[]
static
cmsBool IsMonotonic(int n, const cmsFloat64Number Table[])
{
- int i;
- cmsFloat64Number last;
+ int i;
+ cmsFloat64Number last;
last = Table[n-1];
@@ -384,17 +384,17 @@ cmsBool CMSEXPORT cmsDetectDestinationBlackPoint(cmsCIEXYZ* BlackPoint, cmsHPROF
if (devClass == cmsSigLinkClass ||
devClass == cmsSigAbstractClass ||
devClass == cmsSigNamedColorClass) {
- BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
- return FALSE;
+ BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
+ return FALSE;
}
// Make sure intent is adequate
if (Intent != INTENT_PERCEPTUAL &&
Intent != INTENT_RELATIVE_COLORIMETRIC &&
- Intent != INTENT_SATURATION) {
- BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
- return FALSE;
- }
+ Intent != INTENT_SATURATION) {
+ BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
+ return FALSE;
+ }
// v4 + perceptual & saturation intents does have its own black point, and it is
@@ -546,7 +546,7 @@ cmsBool CMSEXPORT cmsDetectDestinationBlackPoint(cmsCIEXYZ* BlackPoint, cmsHPROF
}
}
-
+
// No suitable points
if (n < 3 ) {
cmsDeleteTransform(hRoundTrip);
diff --git a/src/cmssm.c b/src/cmssm.c
index 0eaa9a8..e41cb68 100644
--- a/src/cmssm.c
+++ b/src/cmssm.c
@@ -170,10 +170,10 @@ void QuantizeToSector(const cmsSpherical* sp, int* alpha, int* theta)
*alpha = (int) floor(((sp->alpha * (SECTORS)) / 360.0) );
*theta = (int) floor(((sp->theta * (SECTORS)) / 180.0) );
- if (*alpha >= SECTORS)
- *alpha = SECTORS-1;
- if (*theta >= SECTORS)
- *theta = SECTORS-1;
+ if (*alpha >= SECTORS)
+ *alpha = SECTORS-1;
+ if (*theta >= SECTORS)
+ *theta = SECTORS-1;
}
@@ -326,8 +326,8 @@ cmsGDBPoint* GetPoint(cmsGDB* gbd, const cmsCIELab* Lab, cmsSpherical* sp)
// Housekeeping
_cmsAssert(gbd != NULL);
- _cmsAssert(Lab != NULL);
- _cmsAssert(sp != NULL);
+ _cmsAssert(Lab != NULL);
+ _cmsAssert(sp != NULL);
// Center L* by substracting half of its domain, that's 50
_cmsVEC3init(&v, Lab ->L - 50.0, Lab ->a, Lab ->b);
@@ -709,10 +709,10 @@ cmsBool cmsGBDdumpVRML(cmsHANDLE hGBD, const char* fname)
else
if (pt ->Type == GP_MODELED)
fprintf (fp, "\t\t\t\t\t%g %g %g", 1.0, .5, .5);
- else {
+ else {
fprintf (fp, "\t\t\t\t\t%g %g %g", 1.0, 1.0, 1.0);
- }
+ }
if ((j == SECTORS - 1) && (i == SECTORS - 1))
fprintf (fp, "]\n");
diff --git a/src/cmstypes.c b/src/cmstypes.c
index 2baf044..c056a76 100644
--- a/src/cmstypes.c
+++ b/src/cmstypes.c
@@ -427,7 +427,7 @@ static
void* Type_Chromaticity_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
{
return _cmsDupMem(self ->ContextID, Ptr, sizeof(cmsCIExyYTRIPLE));
-
+
cmsUNUSED_PARAMETER(n);
}
@@ -2088,10 +2088,10 @@ void *Type_LUT16_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cm
goto Error;
}
- if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, cmsStageAllocCLut16bit(self ->ContextID, CLUTpoints, InputChannels, OutputChannels, T))) {
- _cmsFree(self ->ContextID, T);
+ if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, cmsStageAllocCLut16bit(self ->ContextID, CLUTpoints, InputChannels, OutputChannels, T))) {
+ _cmsFree(self ->ContextID, T);
goto Error;
- }
+ }
_cmsFree(self ->ContextID, T);
}
diff --git a/src/cmsvirt.c b/src/cmsvirt.c
index daccb44..262b9ea 100644
--- a/src/cmsvirt.c
+++ b/src/cmsvirt.c
@@ -724,85 +724,83 @@ int bchswSampler(register const cmsUInt16Number In[], register cmsUInt16Number O
// contrast, Saturation and white point displacement
cmsHPROFILE CMSEXPORT cmsCreateBCHSWabstractProfileTHR(cmsContext ContextID,
- int nLUTPoints,
- cmsFloat64Number Bright,
- cmsFloat64Number Contrast,
- cmsFloat64Number Hue,
- cmsFloat64Number Saturation,
- int TempSrc,
- int TempDest)
+ int nLUTPoints,
+ cmsFloat64Number Bright,
+ cmsFloat64Number Contrast,
+ cmsFloat64Number Hue,
+ cmsFloat64Number Saturation,
+ int TempSrc,
+ int TempDest)
{
- cmsHPROFILE hICC;
- cmsPipeline* Pipeline;
- BCHSWADJUSTS bchsw;
- cmsCIExyY WhitePnt;
- cmsStage* CLUT;
- cmsUInt32Number Dimensions[MAX_INPUT_DIMENSIONS];
- int i;
-
-
- bchsw.Brightness = Bright;
- bchsw.Contrast = Contrast;
- bchsw.Hue = Hue;
- bchsw.Saturation = Saturation;
+ cmsHPROFILE hICC;
+ cmsPipeline* Pipeline;
+ BCHSWADJUSTS bchsw;
+ cmsCIExyY WhitePnt;
+ cmsStage* CLUT;
+ cmsUInt32Number Dimensions[MAX_INPUT_DIMENSIONS];
+ int i;
- cmsWhitePointFromTemp(&WhitePnt, TempSrc );
- cmsxyY2XYZ(&bchsw.WPsrc, &WhitePnt);
+ bchsw.Brightness = Bright;
+ bchsw.Contrast = Contrast;
+ bchsw.Hue = Hue;
+ bchsw.Saturation = Saturation;
- cmsWhitePointFromTemp(&WhitePnt, TempDest);
- cmsxyY2XYZ(&bchsw.WPdest, &WhitePnt);
+ cmsWhitePointFromTemp(&WhitePnt, TempSrc );
+ cmsxyY2XYZ(&bchsw.WPsrc, &WhitePnt);
- hICC = cmsCreateProfilePlaceholder(ContextID);
- if (!hICC) // can't allocate
- return NULL;
+ cmsWhitePointFromTemp(&WhitePnt, TempDest);
+ cmsxyY2XYZ(&bchsw.WPdest, &WhitePnt);
+ hICC = cmsCreateProfilePlaceholder(ContextID);
+ if (!hICC) // can't allocate
+ return NULL;
- cmsSetDeviceClass(hICC, cmsSigAbstractClass);
- cmsSetColorSpace(hICC, cmsSigLabData);
- cmsSetPCS(hICC, cmsSigLabData);
- cmsSetHeaderRenderingIntent(hICC, INTENT_PERCEPTUAL);
+ cmsSetDeviceClass(hICC, cmsSigAbstractClass);
+ cmsSetColorSpace(hICC, cmsSigLabData);
+ cmsSetPCS(hICC, cmsSigLabData);
+ cmsSetHeaderRenderingIntent(hICC, INTENT_PERCEPTUAL);
- // Creates a Pipeline with 3D grid only
- Pipeline = cmsPipelineAlloc(ContextID, 3, 3);
- if (Pipeline == NULL) {
- cmsCloseProfile(hICC);
- return NULL;
- }
+ // Creates a Pipeline with 3D grid only
+ Pipeline = cmsPipelineAlloc(ContextID, 3, 3);
+ if (Pipeline == NULL) {
+ cmsCloseProfile(hICC);
+ return NULL;
+ }
- for (i=0; i < MAX_INPUT_DIMENSIONS; i++) Dimensions[i] = nLUTPoints;
- CLUT = cmsStageAllocCLut16bitGranular(ContextID, Dimensions, 3, 3, NULL);
- if (CLUT == NULL) return NULL;
+ for (i=0; i < MAX_INPUT_DIMENSIONS; i++) Dimensions[i] = nLUTPoints;
+ CLUT = cmsStageAllocCLut16bitGranular(ContextID, Dimensions, 3, 3, NULL);
+ if (CLUT == NULL) return NULL;
- if (!cmsStageSampleCLut16bit(CLUT, bchswSampler, (void*) &bchsw, 0)) {
+ if (!cmsStageSampleCLut16bit(CLUT, bchswSampler, (void*) &bchsw, 0)) {
- // Shouldn't reach here
- goto Error;
- }
+ // Shouldn't reach here
+ goto Error;
+ }
- if (!cmsPipelineInsertStage(Pipeline, cmsAT_END, CLUT)) {
- goto Error;
- }
+ if (!cmsPipelineInsertStage(Pipeline, cmsAT_END, CLUT)) {
+ goto Error;
+ }
- // Create tags
+ // Create tags
+ if (!SetTextTags(hICC, L"BCHS built-in")) return NULL;
- if (!SetTextTags(hICC, L"BCHS built-in")) return NULL;
+ cmsWriteTag(hICC, cmsSigMediaWhitePointTag, (void*) cmsD50_XYZ());
- cmsWriteTag(hICC, cmsSigMediaWhitePointTag, (void*) cmsD50_XYZ());
+ cmsWriteTag(hICC, cmsSigAToB0Tag, (void*) Pipeline);
- cmsWriteTag(hICC, cmsSigAToB0Tag, (void*) Pipeline);
+ // Pipeline is already on virtual profile
+ cmsPipelineFree(Pipeline);
- // Pipeline is already on virtual profile
- cmsPipelineFree(Pipeline);
+ // Ok, done
+ return hICC;
- // Ok, done
- return hICC;
Error:
- cmsPipelineFree(Pipeline);
- cmsCloseProfile(hICC);
- return NULL;
+ cmsPipelineFree(Pipeline);
+ cmsCloseProfile(hICC);
+ return NULL;
}
diff --git a/src/cmswtpnt.c b/src/cmswtpnt.c
index 2e4b484..84e3a32 100644
--- a/src/cmswtpnt.c
+++ b/src/cmswtpnt.c
@@ -47,48 +47,48 @@ const cmsCIExyY* CMSEXPORT cmsD50_xyY(void)
// Obtains WhitePoint from Temperature
cmsBool CMSEXPORT cmsWhitePointFromTemp(cmsCIExyY* WhitePoint, cmsFloat64Number TempK)
{
- cmsFloat64Number x, y;
- cmsFloat64Number T, T2, T3;
- // cmsFloat64Number M1, M2;
+ cmsFloat64Number x, y;
+ cmsFloat64Number T, T2, T3;
+ // cmsFloat64Number M1, M2;
- _cmsAssert(WhitePoint != NULL);
+ _cmsAssert(WhitePoint != NULL);
- T = TempK;
- T2 = T*T; // Square
- T3 = T2*T; // Cube
+ T = TempK;
+ T2 = T*T; // Square
+ T3 = T2*T; // Cube
- // For correlated color temperature (T) between 4000K and 7000K:
+ // For correlated color temperature (T) between 4000K and 7000K:
- if (T >= 4000. && T <= 7000.)
- {
- x = -4.6070*(1E9/T3) + 2.9678*(1E6/T2) + 0.09911*(1E3/T) + 0.244063;
- }
- else
- // or for correlated color temperature (T) between 7000K and 25000K:
+ if (T >= 4000. && T <= 7000.)
+ {
+ x = -4.6070*(1E9/T3) + 2.9678*(1E6/T2) + 0.09911*(1E3/T) + 0.244063;
+ }
+ else
+ // or for correlated color temperature (T) between 7000K and 25000K:
- if (T > 7000.0 && T <= 25000.0)
- {
- x = -2.0064*(1E9/T3) + 1.9018*(1E6/T2) + 0.24748*(1E3/T) + 0.237040;
- }
- else {
- cmsSignalError(0, cmsERROR_RANGE, "cmsWhitePointFromTemp: invalid temp");
- return FALSE;
- }
+ if (T > 7000.0 && T <= 25000.0)
+ {
+ x = -2.0064*(1E9/T3) + 1.9018*(1E6/T2) + 0.24748*(1E3/T) + 0.237040;
+ }
+ else {
+ cmsSignalError(0, cmsERROR_RANGE, "cmsWhitePointFromTemp: invalid temp");
+ return FALSE;
+ }
- // Obtain y(x)
+ // Obtain y(x)
- y = -3.000*(x*x) + 2.870*x - 0.275;
+ y = -3.000*(x*x) + 2.870*x - 0.275;
- // wave factors (not used, but here for futures extensions)
+ // wave factors (not used, but here for futures extensions)
- // M1 = (-1.3515 - 1.7703*x + 5.9114 *y)/(0.0241 + 0.2562*x - 0.7341*y);
- // M2 = (0.0300 - 31.4424*x + 30.0717*y)/(0.0241 + 0.2562*x - 0.7341*y);
+ // M1 = (-1.3515 - 1.7703*x + 5.9114 *y)/(0.0241 + 0.2562*x - 0.7341*y);
+ // M2 = (0.0300 - 31.4424*x + 30.0717*y)/(0.0241 + 0.2562*x - 0.7341*y);
- WhitePoint -> x = x;
- WhitePoint -> y = y;
- WhitePoint -> Y = 1.0;
+ WhitePoint -> x = x;
+ WhitePoint -> y = y;
+ WhitePoint -> Y = 1.0;
- return TRUE;
+ return TRUE;
}
@@ -143,46 +143,46 @@ static ISOTEMPERATURE isotempdata[] = {
// Robertson's method
cmsBool CMSEXPORT cmsTempFromWhitePoint(cmsFloat64Number* TempK, const cmsCIExyY* WhitePoint)
{
- cmsUInt32Number j;
- cmsFloat64Number us,vs;
- cmsFloat64Number uj,vj,tj,di,dj,mi,mj;
- cmsFloat64Number xs, ys;
+ cmsUInt32Number j;
+ cmsFloat64Number us,vs;
+ cmsFloat64Number uj,vj,tj,di,dj,mi,mj;
+ cmsFloat64Number xs, ys;
- _cmsAssert(WhitePoint != NULL);
+ _cmsAssert(WhitePoint != NULL);
_cmsAssert(TempK != NULL);
- di = mi = 0;
- xs = WhitePoint -> x;
- ys = WhitePoint -> y;
+ di = mi = 0;
+ xs = WhitePoint -> x;
+ ys = WhitePoint -> y;
- // convert (x,y) to CIE 1960 (u,WhitePoint)
+ // convert (x,y) to CIE 1960 (u,WhitePoint)
- us = (2*xs) / (-xs + 6*ys + 1.5);
- vs = (3*ys) / (-xs + 6*ys + 1.5);
+ us = (2*xs) / (-xs + 6*ys + 1.5);
+ vs = (3*ys) / (-xs + 6*ys + 1.5);
- for (j=0; j < NISO; j++) {
+ for (j=0; j < NISO; j++) {
- uj = isotempdata[j].ut;
- vj = isotempdata[j].vt;
- tj = isotempdata[j].tt;
- mj = isotempdata[j].mirek;
+ uj = isotempdata[j].ut;
+ vj = isotempdata[j].vt;
+ tj = isotempdata[j].tt;
+ mj = isotempdata[j].mirek;
- dj = ((vs - vj) - tj * (us - uj)) / sqrt(1.0 + tj * tj);
+ dj = ((vs - vj) - tj * (us - uj)) / sqrt(1.0 + tj * tj);
- if ((j != 0) && (di/dj < 0.0)) {
+ if ((j != 0) && (di/dj < 0.0)) {
- // Found a match
- *TempK = 1000000.0 / (mi + (di / (di - dj)) * (mj - mi));
- return TRUE;
- }
+ // Found a match
+ *TempK = 1000000.0 / (mi + (di / (di - dj)) * (mj - mi));
+ return TRUE;
+ }
- di = dj;
- mi = mj;
- }
+ di = dj;
+ mi = mj;
+ }
- // Not found
- return FALSE;
+ // Not found
+ return FALSE;
}
@@ -226,41 +226,41 @@ cmsBool ComputeChromaticAdaptation(cmsMAT3* Conversion,
_cmsMAT3per(&Tmp, &Cone, Chad);
_cmsMAT3per(Conversion, &Chad_Inv, &Tmp);
- return TRUE;
+ return TRUE;
}
// Returns the final chrmatic adaptation from illuminant FromIll to Illuminant ToIll
// The cone matrix can be specified in ConeMatrix. If NULL, Bradford is assumed
cmsBool _cmsAdaptationMatrix(cmsMAT3* r, const cmsMAT3* ConeMatrix, const cmsCIEXYZ* FromIll, const cmsCIEXYZ* ToIll)
{
- cmsMAT3 LamRigg = {{ // Bradford matrix
- {{ 0.8951, 0.2664, -0.1614 }},
- {{ -0.7502, 1.7135, 0.0367 }},
- {{ 0.0389, -0.0685, 1.0296 }}
- }};
+ cmsMAT3 LamRigg = {{ // Bradford matrix
+ {{ 0.8951, 0.2664, -0.1614 }},
+ {{ -0.7502, 1.7135, 0.0367 }},
+ {{ 0.0389, -0.0685, 1.0296 }}
+ }};
- if (ConeMatrix == NULL)
- ConeMatrix = &LamRigg;
+ if (ConeMatrix == NULL)
+ ConeMatrix = &LamRigg;
- return ComputeChromaticAdaptation(r, FromIll, ToIll, ConeMatrix);
+ return ComputeChromaticAdaptation(r, FromIll, ToIll, ConeMatrix);
}
// Same as anterior, but assuming D50 destination. White point is given in xyY
static
cmsBool _cmsAdaptMatrixToD50(cmsMAT3* r, const cmsCIExyY* SourceWhitePt)
{
- cmsCIEXYZ Dn;
- cmsMAT3 Bradford;
- cmsMAT3 Tmp;
+ cmsCIEXYZ Dn;
+ cmsMAT3 Bradford;
+ cmsMAT3 Tmp;
- cmsxyY2XYZ(&Dn, SourceWhitePt);
+ cmsxyY2XYZ(&Dn, SourceWhitePt);
- if (!_cmsAdaptationMatrix(&Bradford, NULL, &Dn, cmsD50_XYZ())) return FALSE;
+ if (!_cmsAdaptationMatrix(&Bradford, NULL, &Dn, cmsD50_XYZ())) return FALSE;
- Tmp = *r;
- _cmsMAT3per(r, &Bradford, &Tmp);
+ Tmp = *r;
+ _cmsMAT3per(r, &Bradford, &Tmp);
- return TRUE;
+ return TRUE;
}
// Build a White point, primary chromas transfer matrix from RGB to CIE XYZ
@@ -278,45 +278,45 @@ cmsBool _cmsAdaptMatrixToD50(cmsMAT3* r, const cmsCIExyY* SourceWhitePt)
//
cmsBool _cmsBuildRGB2XYZtransferMatrix(cmsMAT3* r, const cmsCIExyY* WhitePt, const cmsCIExyYTRIPLE* Primrs)
{
- cmsVEC3 WhitePoint, Coef;
- cmsMAT3 Result, Primaries;
- cmsFloat64Number xn, yn;
- cmsFloat64Number xr, yr;
- cmsFloat64Number xg, yg;
- cmsFloat64Number xb, yb;
+ cmsVEC3 WhitePoint, Coef;
+ cmsMAT3 Result, Primaries;
+ cmsFloat64Number xn, yn;
+ cmsFloat64Number xr, yr;
+ cmsFloat64Number xg, yg;
+ cmsFloat64Number xb, yb;
- xn = WhitePt -> x;
- yn = WhitePt -> y;
- xr = Primrs -> Red.x;
- yr = Primrs -> Red.y;
- xg = Primrs -> Green.x;
- yg = Primrs -> Green.y;
- xb = Primrs -> Blue.x;
- yb = Primrs -> Blue.y;
+ xn = WhitePt -> x;
+ yn = WhitePt -> y;
+ xr = Primrs -> Red.x;
+ yr = Primrs -> Red.y;
+ xg = Primrs -> Green.x;
+ yg = Primrs -> Green.y;
+ xb = Primrs -> Blue.x;
+ yb = Primrs -> Blue.y;
- // Build Primaries matrix
- _cmsVEC3init(&Primaries.v[0], xr, xg, xb);
- _cmsVEC3init(&Primaries.v[1], yr, yg, yb);
- _cmsVEC3init(&Primaries.v[2], (1-xr-yr), (1-xg-yg), (1-xb-yb));
+ // Build Primaries matrix
+ _cmsVEC3init(&Primaries.v[0], xr, xg, xb);
+ _cmsVEC3init(&Primaries.v[1], yr, yg, yb);
+ _cmsVEC3init(&Primaries.v[2], (1-xr-yr), (1-xg-yg), (1-xb-yb));
- // Result = Primaries ^ (-1) inverse matrix
- if (!_cmsMAT3inverse(&Primaries, &Result))
- return FALSE;
+ // Result = Primaries ^ (-1) inverse matrix
+ if (!_cmsMAT3inverse(&Primaries, &Result))
+ return FALSE;
- _cmsVEC3init(&WhitePoint, xn/yn, 1.0, (1.0-xn-yn)/yn);
+ _cmsVEC3init(&WhitePoint, xn/yn, 1.0, (1.0-xn-yn)/yn);
- // Across inverse primaries ...
- _cmsMAT3eval(&Coef, &Result, &WhitePoint);
+ // Across inverse primaries ...
+ _cmsMAT3eval(&Coef, &Result, &WhitePoint);
- // Give us the Coefs, then I build transformation matrix
- _cmsVEC3init(&r -> v[0], Coef.n[VX]*xr, Coef.n[VY]*xg, Coef.n[VZ]*xb);
- _cmsVEC3init(&r -> v[1], Coef.n[VX]*yr, Coef.n[VY]*yg, Coef.n[VZ]*yb);
- _cmsVEC3init(&r -> v[2], Coef.n[VX]*(1.0-xr-yr), Coef.n[VY]*(1.0-xg-yg), Coef.n[VZ]*(1.0-xb-yb));
+ // Give us the Coefs, then I build transformation matrix
+ _cmsVEC3init(&r -> v[0], Coef.n[VX]*xr, Coef.n[VY]*xg, Coef.n[VZ]*xb);
+ _cmsVEC3init(&r -> v[1], Coef.n[VX]*yr, Coef.n[VY]*yg, Coef.n[VZ]*yb);
+ _cmsVEC3init(&r -> v[2], Coef.n[VX]*(1.0-xr-yr), Coef.n[VY]*(1.0-xg-yg), Coef.n[VZ]*(1.0-xb-yb));
- return _cmsAdaptMatrixToD50(r, WhitePt);
+ return _cmsAdaptMatrixToD50(r, WhitePt);
}
@@ -324,28 +324,28 @@ cmsBool _cmsBuildRGB2XYZtransferMatrix(cmsMAT3* r, const cmsCIExyY* WhitePt, con
// Adapts a color to a given illuminant. Original color is expected to have
// a SourceWhitePt white point.
cmsBool CMSEXPORT cmsAdaptToIlluminant(cmsCIEXYZ* Result,
- const cmsCIEXYZ* SourceWhitePt,
- const cmsCIEXYZ* Illuminant,
- const cmsCIEXYZ* Value)
+ const cmsCIEXYZ* SourceWhitePt,
+ const cmsCIEXYZ* Illuminant,
+ const cmsCIEXYZ* Value)
{
- cmsMAT3 Bradford;
- cmsVEC3 In, Out;
+ cmsMAT3 Bradford;
+ cmsVEC3 In, Out;
- _cmsAssert(Result != NULL);
- _cmsAssert(SourceWhitePt != NULL);
- _cmsAssert(Illuminant != NULL);
- _cmsAssert(Value != NULL);
+ _cmsAssert(Result != NULL);
+ _cmsAssert(SourceWhitePt != NULL);
+ _cmsAssert(Illuminant != NULL);
+ _cmsAssert(Value != NULL);
- if (!_cmsAdaptationMatrix(&Bradford, NULL, SourceWhitePt, Illuminant)) return FALSE;
+ if (!_cmsAdaptationMatrix(&Bradford, NULL, SourceWhitePt, Illuminant)) return FALSE;
- _cmsVEC3init(&In, Value -> X, Value -> Y, Value -> Z);
- _cmsMAT3eval(&Out, &Bradford, &In);
+ _cmsVEC3init(&In, Value -> X, Value -> Y, Value -> Z);
+ _cmsMAT3eval(&Out, &Bradford, &In);
- Result -> X = Out.n[0];
- Result -> Y = Out.n[1];
- Result -> Z = Out.n[2];
+ Result -> X = Out.n[0];
+ Result -> Y = Out.n[1];
+ Result -> Z = Out.n[2];
- return TRUE;
+ return TRUE;
}
diff --git a/testbed/testcms2.c b/testbed/testcms2.c
index f4b948d..01deae2 100644
--- a/testbed/testcms2.c
+++ b/testbed/testcms2.c
@@ -7095,7 +7095,7 @@ int CheckLinking(void)
cmsWriteTag(h, cmsSigAToB0Tag, pipeline);
cmsPipelineFree(pipeline);
- if (!cmsSaveProfileToFile(h, "lcms2link2.icc")) return 0;
+ if (!cmsSaveProfileToFile(h, "lcms2link2.icc")) return 0;
cmsCloseProfile(h);
@@ -7307,19 +7307,19 @@ double Rec709(double L)
static
cmsInt32Number CheckParametricRec709(void)
{
- cmsFloat64Number params[7];
- cmsToneCurve* t;
+ cmsFloat64Number params[7];
+ cmsToneCurve* t;
int i;
params[0] = 0.45; /* y */
- params[1] = pow(1.099, 1.0 / 0.45); /* a */
- params[2] = 0.0; /* b */
- params[3] = 4.5; /* c */
- params[4] = 0.018; /* d */
+ params[1] = pow(1.099, 1.0 / 0.45); /* a */
+ params[2] = 0.0; /* b */
+ params[3] = 4.5; /* c */
+ params[4] = 0.018; /* d */
params[5] = -0.099; /* e */
params[6] = 0.0; /* f */
-
- t = cmsBuildParametricToneCurve (NULL, 5, params);
+
+ t = cmsBuildParametricToneCurve (NULL, 5, params);
for (i=0; i < 256; i++)
@@ -7443,6 +7443,47 @@ cmsInt32Number CheckFloatSegments(void)
}
+static
+cmsInt32Number CheckReadRAW(void)
+{
+ cmsInt32Number tag_size, tag_size1;
+ char buffer[4];
+ cmsHPROFILE hProfile;
+
+
+ SubTest("RAW read on on-disk");
+ hProfile = cmsOpenProfileFromFile("test1.icc", "r");
+
+ if (hProfile == NULL)
+ return 0;
+
+ tag_size = cmsReadRawTag(hProfile, cmsSigGamutTag, buffer, 4);
+ tag_size1 = cmsReadRawTag(hProfile, cmsSigGamutTag, NULL, 0);
+
+ cmsCloseProfile(hProfile);
+
+ if (tag_size != 4)
+ return 0;
+
+ if (tag_size1 != 37009)
+ return 0;
+
+ SubTest("RAW read on in-memory created profiles");
+ hProfile = cmsCreate_sRGBProfile();
+ tag_size = cmsReadRawTag(hProfile, cmsSigGreenColorantTag, buffer, 4);
+ tag_size1 = cmsReadRawTag(hProfile, cmsSigGreenColorantTag, NULL, 0);
+
+ cmsCloseProfile(hProfile);
+
+ if (tag_size != 4)
+ return 0;
+ if (tag_size1 != 20)
+ return 0;
+
+ return 1;
+}
+
+
// --------------------------------------------------------------------------------------------------
// P E R F O R M A N C E C H E C K S
@@ -8316,6 +8357,7 @@ int main(int argc, char* argv[])
Check("Parametric curve on Rec709", CheckParametricRec709);
Check("Floating Point sampled curve with non-zero start", CheckFloatSamples);
Check("Floating Point segmented curve with short sampled segement", CheckFloatSegments);
+ Check("Read RAW portions", CheckReadRAW);
}
diff --git a/utils/jpgicc/jpgicc.c b/utils/jpgicc/jpgicc.c
index 010db4a..67899c1 100644
--- a/utils/jpgicc/jpgicc.c
+++ b/utils/jpgicc/jpgicc.c
@@ -118,28 +118,28 @@ NOTE – The functional equivalence of inch-based and mm-based resolutions is main
static
cmsBool IsITUFax(jpeg_saved_marker_ptr ptr)
{
- while (ptr)
- {
+ while (ptr)
+ {
if (ptr -> marker == (JPEG_APP0 + 1) && ptr -> data_length > 5) {
- const char* data = (const char*) ptr -> data;
+ const char* data = (const char*) ptr -> data;
- if (strcmp(data, "G3FAX") == 0) return TRUE;
- }
+ if (strcmp(data, "G3FAX") == 0) return TRUE;
+ }
- ptr = ptr -> next;
- }
+ ptr = ptr -> next;
+ }
- return FALSE;
+ 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";
+ unsigned char Marker[] = "G3FAX\x00\0x07\xCA\x00\xC8";
- jpeg_write_marker(cinfo, (JPEG_APP0 + 1), Marker, 10);
+ jpeg_write_marker(cinfo, (JPEG_APP0 + 1), Marker, 10);
}
@@ -159,17 +159,17 @@ void SetITUFax(j_compress_ptr cinfo)
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.;
+ 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. );
+ 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()
@@ -185,12 +185,12 @@ void Lab2ITU(const cmsCIELab* Lab, cmsUInt16Number Out[3])
static
int PCS2ITU(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
{
- cmsCIELab Lab;
+ cmsCIELab Lab;
- cmsLabEncoded2Float(&Lab, In);
- cmsDesaturateLab(&Lab, 85, -85, 125, -75); // This function does the necessary gamut remapping
- Lab2ITU(&Lab, Out);
- return TRUE;
+ 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);
}
@@ -199,11 +199,11 @@ int PCS2ITU(register const cmsUInt16Number In[], register cmsUInt16Number Out[],
static
int ITU2PCS( register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
{
- cmsCIELab Lab;
+ cmsCIELab Lab;
- ITU2Lab(In, &Lab);
- cmsFloat2LabEncoded(Out, &Lab);
- return TRUE;
+ ITU2Lab(In, &Lab);
+ cmsFloat2LabEncoded(Out, &Lab);
+ return TRUE;
UTILS_UNUSED_PARAMETER(Cargo);
}
@@ -212,32 +212,32 @@ int ITU2PCS( register const cmsUInt16Number In[], register cmsUInt16Number Out[]
static
cmsHPROFILE CreateITU2PCS_ICC(void)
{
- cmsHPROFILE hProfile;
- cmsPipeline* AToB0;
- cmsStage* ColorMap;
+ cmsHPROFILE hProfile;
+ cmsPipeline* AToB0;
+ cmsStage* ColorMap;
- AToB0 = cmsPipelineAlloc(0, 3, 3);
- if (AToB0 == NULL) return NULL;
+ AToB0 = cmsPipelineAlloc(0, 3, 3);
+ if (AToB0 == NULL) return NULL;
- ColorMap = cmsStageAllocCLut16bit(0, GRID_POINTS, 3, 3, NULL);
- if (ColorMap == 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);
+ cmsStageSampleCLut16bit(ColorMap, ITU2PCS, NULL, 0);
- hProfile = cmsCreateProfilePlaceholder(0);
- if (hProfile == NULL) {
- cmsPipelineFree(AToB0);
- return NULL;
- }
+ 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);
+ cmsWriteTag(hProfile, cmsSigAToB0Tag, AToB0);
+ cmsSetColorSpace(hProfile, cmsSigLabData);
+ cmsSetPCS(hProfile, cmsSigLabData);
+ cmsSetDeviceClass(hProfile, cmsSigColorSpaceClass);
+ cmsPipelineFree(AToB0);
- return hProfile;
+ return hProfile;
}
@@ -544,31 +544,31 @@ static
static
cmsBool OpenInput(const char* FileName)
{
- int m;
+ int m;
- lIsITUFax = FALSE;
- InFile = fopen(FileName, "rb");
- if (InFile == NULL) {
- FatalError("Cannot open '%s'", FileName);
- }
+ 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;
+ // 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);
+ jpeg_create_decompress(&Decompressor);
+ jpeg_stdio_src(&Decompressor, InFile);
- for (m = 0; m < 16; m++)
- jpeg_save_markers(&Decompressor, JPEG_APP0 + m, 0xFFFF);
+ for (m = 0; m < 16; m++)
+ jpeg_save_markers(&Decompressor, JPEG_APP0 + m, 0xFFFF);
- // setup_read_icc_profile(&Decompressor);
+ // setup_read_icc_profile(&Decompressor);
- fseek(InFile, 0, SEEK_SET);
- jpeg_read_header(&Decompressor, TRUE);
+ fseek(InFile, 0, SEEK_SET);
+ jpeg_read_header(&Decompressor, TRUE);
- return TRUE;
+ return TRUE;
}
@@ -576,29 +576,29 @@ static
cmsBool OpenOutput(const char* FileName)
{
- OutFile = fopen(FileName, "wb");
- if (OutFile == NULL) {
- FatalError("Cannot create '%s'", 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.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;
+ Compressor.input_components = Compressor.num_components = 4;
- jpeg_create_compress(&Compressor);
- jpeg_stdio_dest(&Compressor, OutFile);
- return TRUE;
+ 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);
+ jpeg_destroy_decompress(&Decompressor);
+ jpeg_destroy_compress(&Compressor);
+ return fclose(InFile) + fclose(OutFile);
}
@@ -669,33 +669,33 @@ cmsUInt32Number GetInputPixelType(void)
static
cmsUInt32Number ComputeOutputFormatDescriptor(cmsUInt32Number dwInput, int OutColorSpace)
{
- int IsPlanar = T_PLANAR(dwInput);
- int Channels = 0;
- int Flavor = 0;
+ int IsPlanar = T_PLANAR(dwInput);
+ int Channels = 0;
+ int Flavor = 0;
- switch (OutColorSpace) {
+ switch (OutColorSpace) {
case PT_GRAY:
- Channels = 1;
- break;
+ Channels = 1;
+ break;
case PT_RGB:
case PT_CMY:
case PT_Lab:
case PT_YUV:
case PT_YCbCr:
- Channels = 3;
- break;
+ 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;
+ 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");
- }
+ FatalError("Unsupported output color space");
+ }
- return (COLORSPACE_SH(OutColorSpace)|PLANAR_SH(IsPlanar)|CHANNELS_SH(Channels)|BYTES_SH(1)|FLAVOR_SH(Flavor));
+ return (COLORSPACE_SH(OutColorSpace)|PLANAR_SH(IsPlanar)|CHANNELS_SH(Channels)|BYTES_SH(1)|FLAVOR_SH(Flavor));
}
@@ -705,7 +705,7 @@ int GetProfileColorSpace(cmsHPROFILE hProfile)
{
cmsColorSpaceSignature ProfileSpace = cmsGetColorSpace(hProfile);
- return _cmsLCMScolorSpace(ProfileSpace);
+ return _cmsLCMScolorSpace(ProfileSpace);
}
static
@@ -713,7 +713,7 @@ int GetDevicelinkColorSpace(cmsHPROFILE hProfile)
{
cmsColorSpaceSignature ProfileSpace = cmsGetPCS(hProfile);
- return _cmsLCMScolorSpace(ProfileSpace);
+ return _cmsLCMScolorSpace(ProfileSpace);
}
@@ -815,7 +815,7 @@ void WriteOutputFields(int OutputColorSpace)
int i;
for(i=0; i < Compressor.num_components; i++) {
- Compressor.comp_info[i].h_samp_factor = 1;
+ Compressor.comp_info[i].h_samp_factor = 1;
Compressor.comp_info[i].v_samp_factor = 1;
}
@@ -949,7 +949,7 @@ int TransformImage(char *cDefInpProf, char *cOutProf)
if (Verbose) {
fprintf(stdout, " (Embedded profile found)\n");
- PrintProfileInformation(hIn);
+ PrintProfileInformation(hIn);
fflush(stdout);
}
@@ -1016,7 +1016,7 @@ int TransformImage(char *cDefInpProf, char *cOutProf)
hOut, wOutput,
hProof, Intent,
ProofingIntent, dwFlags);
- if (xform == NULL)
+ if (xform == NULL)
FatalError("Cannot transform by using the profiles");
DoTransform(xform, OutputColorSpace);
@@ -1052,7 +1052,7 @@ void Help(int level)
fprintf(stderr, "%ci<profile> - Input profile (defaults to sRGB)\n", SW);
fprintf(stderr, "%co<profile> - Output profile (defaults to sRGB)\n", SW);
- PrintRenderingIntents();
+ PrintRenderingIntents();
fprintf(stderr, "%cb - Black point compensation\n", SW);
@@ -1095,8 +1095,8 @@ void Help(int level)
break;
case 2:
- PrintBuiltins();
- break;
+ PrintBuiltins();
+ break;
case 3:
@@ -1159,8 +1159,8 @@ void HandleSwitches(int argc, char *argv[])
case 'l':
case 'L':
- if (cInpProf != NULL || cOutProf != NULL)
- FatalError("input/output profiles already specified");
+ if (cInpProf != NULL || cOutProf != NULL)
+ FatalError("input/output profiles already specified");
cInpProf = xoptarg;
lIsDeviceLink = TRUE;
@@ -1243,25 +1243,25 @@ void HandleSwitches(int argc, char *argv[])
int main(int argc, char* argv[])
{
- InitUtils("jpgicc");
+ InitUtils("jpgicc");
- HandleSwitches(argc, argv);
+ HandleSwitches(argc, argv);
- if ((argc - xoptind) != 2) {
- Help(0);
- }
+ if ((argc - xoptind) != 2) {
+ Help(0);
+ }
- OpenInput(argv[xoptind]);
- OpenOutput(argv[xoptind+1]);
+ OpenInput(argv[xoptind]);
+ OpenOutput(argv[xoptind+1]);
- TransformImage(cInpProf, cOutProf);
+ TransformImage(cInpProf, cOutProf);
- if (Verbose) { fprintf(stdout, "\n"); fflush(stdout); }
+ if (Verbose) { fprintf(stdout, "\n"); fflush(stdout); }
- Done();
+ Done();
- return 0;
+ return 0;
}
diff --git a/utils/transicc/transicc.c b/utils/transicc/transicc.c
index 3bab4b4..332696a 100644
--- a/utils/transicc/transicc.c
+++ b/utils/transicc/transicc.c
@@ -842,7 +842,7 @@ cmsFloat64Number GetIT8Val(const char* Name, cmsFloat64Number Max)
// Read input values from CGATS file.
static
-void TakeCGATSValues(int nPatch, cmsFloat64Number Float[])
+ void TakeCGATSValues(int nPatch, cmsFloat64Number Float[])
{
// At first take the name if SAMPLE_ID is present
@@ -856,15 +856,15 @@ void TakeCGATSValues(int nPatch, cmsFloat64Number Float[])
if (InputNamedColor) {
- const cmsNAMEDCOLORLIST* NamedColorList;
- int index;
+ const cmsNAMEDCOLORLIST* NamedColorList;
+ int index;
- NamedColorList = cmsGetNamedColorList(hTrans);
- if (NamedColorList == NULL)
- FatalError("Malformed named color profile");
-
- index = cmsNamedColorIndex(NamedColorList, CGATSPatch);
- if (index < 0)
+ NamedColorList = cmsGetNamedColorList(hTrans);
+ if (NamedColorList == NULL)
+ FatalError("Malformed named color profile");
+
+ index = cmsNamedColorIndex(NamedColorList, CGATSPatch);
+ if (index < 0)
FatalError("Named color '%s' not found in the profile", CGATSPatch);
Float[0] = index;
@@ -941,7 +941,7 @@ void TakeCGATSValues(int nPatch, cmsFloat64Number Float[])
}
}
- break;
+ break;
default:
{
@@ -1050,7 +1050,7 @@ void PutCGATSValues(cmsFloat64Number Float[])
SetCGATSfld(Buffer, Float[i] * 100.0);
}
}
- break;
+ break;
default:
{
@@ -1154,20 +1154,20 @@ void SetOutputDataFormat(void)
case cmsSig13colorData:
case cmsSig14colorData:
case cmsSig15colorData:
- {
- int i, n;
- char Buffer[255];
-
- n = cmsChannelsOf(OutputColorSpace);
- cmsIT8SetPropertyDbl(hIT8out, "NUMBER_OF_FIELDS", n+1);
- cmsIT8SetDataFormat(hIT8out, 0, "SAMPLE_ID");
-
- for (i=1; i <= n; i++) {
- sprintf(Buffer, "%dCLR_%d", n, i);
- cmsIT8SetDataFormat(hIT8out, i, Buffer);
- }
- }
- break;
+ {
+ int i, n;
+ char Buffer[255];
+
+ n = cmsChannelsOf(OutputColorSpace);
+ cmsIT8SetPropertyDbl(hIT8out, "NUMBER_OF_FIELDS", n+1);
+ cmsIT8SetDataFormat(hIT8out, 0, "SAMPLE_ID");
+
+ for (i=1; i <= n; i++) {
+ sprintf(Buffer, "%dCLR_%d", n, i);
+ cmsIT8SetDataFormat(hIT8out, i, Buffer);
+ }
+ }
+ break;
default: {