summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarti Maria <info@littlecms.com>2017-03-13 12:59:30 +0100
committerMarti Maria <info@littlecms.com>2017-03-13 12:59:30 +0100
commit4e2015dbb09be4e2ac710bbd00ff4254fdc170b8 (patch)
tree00cf09274435952c3960ae63854f2f6d921b9aaf /src
parenta99291c5bdaaf1637c2b3389c3deae76c61ce157 (diff)
downloadlcms2-4e2015dbb09be4e2ac710bbd00ff4254fdc170b8.tar.gz
Fix NULL profile builtin
Now the NULL builtin profile can be saved and is fully conformant. Previous profile could be regarded as corrupted as was using a 3->3 lut for Lab to gray
Diffstat (limited to 'src')
-rw-r--r--src/cmslut.c4
-rw-r--r--src/cmsvirt.c24
2 files changed, 17 insertions, 11 deletions
diff --git a/src/cmslut.c b/src/cmslut.c
index 9c4554d..16169f9 100644
--- a/src/cmslut.c
+++ b/src/cmslut.c
@@ -1299,9 +1299,7 @@ cmsBool BlessLUT(cmsPipeline* lut)
while (next != NULL)
{
- // It is admisible to have some unconnected channels, but not to
- // have uninitialized channels
- if (next->InputChannels > prev->OutputChannels)
+ if (next->InputChannels != prev->OutputChannels)
return FALSE;
next = next->Next;
diff --git a/src/cmsvirt.c b/src/cmsvirt.c
index b8795be..1c282f2 100644
--- a/src/cmsvirt.c
+++ b/src/cmsvirt.c
@@ -830,8 +830,10 @@ cmsHPROFILE CMSEXPORT cmsCreateNULLProfileTHR(cmsContext ContextID)
cmsHPROFILE hProfile;
cmsPipeline* LUT = NULL;
cmsStage* PostLin;
- cmsToneCurve* EmptyTab;
+ cmsStage* OutLin;
+ cmsToneCurve* EmptyTab[3];
cmsUInt16Number Zero[2] = { 0, 0 };
+ const cmsFloat64Number PickLstarMatrix[] = { 1, 0, 0 };
hProfile = cmsCreateProfilePlaceholder(ContextID);
if (!hProfile) // can't allocate
@@ -842,22 +844,28 @@ cmsHPROFILE CMSEXPORT cmsCreateNULLProfileTHR(cmsContext ContextID)
if (!SetTextTags(hProfile, L"NULL profile built-in")) goto Error;
-
cmsSetDeviceClass(hProfile, cmsSigOutputClass);
cmsSetColorSpace(hProfile, cmsSigGrayData);
cmsSetPCS(hProfile, cmsSigLabData);
- // An empty LUTs is all we need
- LUT = cmsPipelineAlloc(ContextID, 1, 1);
+ // Create a valid ICC 4 structure
+ LUT = cmsPipelineAlloc(ContextID, 3, 1);
if (LUT == NULL) goto Error;
-
- EmptyTab = cmsBuildTabulatedToneCurve16(ContextID, 2, Zero);
- PostLin = cmsStageAllocToneCurves(ContextID, 1, &EmptyTab);
- cmsFreeToneCurve(EmptyTab);
+
+ EmptyTab[0] = EmptyTab[1] = EmptyTab[2] = cmsBuildTabulatedToneCurve16(ContextID, 2, Zero);
+ PostLin = cmsStageAllocToneCurves(ContextID, 3, EmptyTab);
+ OutLin = cmsStageAllocToneCurves(ContextID, 1, EmptyTab);
+ cmsFreeToneCurve(EmptyTab[0]);
if (!cmsPipelineInsertStage(LUT, cmsAT_END, PostLin))
goto Error;
+ if (!cmsPipelineInsertStage(LUT, cmsAT_END, cmsStageAllocMatrix(ContextID, 1, 3, PickLstarMatrix, NULL)))
+ goto Error;
+
+ if (!cmsPipelineInsertStage(LUT, cmsAT_END, OutLin))
+ goto Error;
+
if (!cmsWriteTag(hProfile, cmsSigBToA0Tag, (void*) LUT)) goto Error;
if (!cmsWriteTag(hProfile, cmsSigMediaWhitePointTag, cmsD50_XYZ())) goto Error;