diff options
author | Marti Maria <marti.maria@littlecms.com> | 2023-04-26 16:30:35 +0200 |
---|---|---|
committer | Marti Maria <marti.maria@littlecms.com> | 2023-04-26 16:30:35 +0200 |
commit | b97071f1a069eaff94f2b9aacdd593fe47591adf (patch) | |
tree | 4155ff3bb068aa1bf785a0cb4081cccdbf9e7543 | |
parent | 7984408c8fe800a27175e4a8bd6115663c553ec1 (diff) | |
download | lcms2-b97071f1a069eaff94f2b9aacdd593fe47591adf.tar.gz |
fix black preservation on compound profile chains
K preservation now works with abstract profiles in the middle and and CMYK devicelinks at the end of the transform chain
-rw-r--r-- | src/cmscnvrt.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/cmscnvrt.c b/src/cmscnvrt.c index de63975..7803c1e 100644 --- a/src/cmscnvrt.c +++ b/src/cmscnvrt.c @@ -715,6 +715,16 @@ int BlackPreservingGrayOnlySampler(CMSREGISTER const cmsUInt16Number In[], CMSRE return TRUE; } + +// Check whatever the profile is a CMYK->CMYK devicelink +static +cmsBool is_cmyk_devicelink(cmsHPROFILE hProfile) +{ + return cmsGetDeviceClass(hProfile) == cmsSigLinkClass && + cmsGetColorSpace(hProfile) == cmsSigCmykData && + cmsGetColorSpace(hProfile) == cmsSigCmykData; +} + // This is the entry for black-preserving K-only intents, which are non-ICC static cmsPipeline* BlackPreservingKOnlyIntents(cmsContext ContextID, @@ -747,14 +757,16 @@ cmsPipeline* BlackPreservingKOnlyIntents(cmsContext ContextID, lastProfilePos = nProfiles - 1; hLastProfile = hProfiles[lastProfilePos]; - while (lastProfilePos > 1) + // Skip CMYK->CMYK devicelinks on ending + while (is_cmyk_devicelink(hLastProfile)) { - hLastProfile = hProfiles[--lastProfilePos]; - if (cmsGetColorSpace(hLastProfile) != cmsSigCmykData || - cmsGetDeviceClass(hLastProfile) != cmsSigLinkClass) + if (lastProfilePos < 2) break; + + hLastProfile = hProfiles[--lastProfilePos]; } + preservationProfilesCount = lastProfilePos + 1; // Check for non-cmyk profiles @@ -973,13 +985,14 @@ cmsPipeline* BlackPreservingKPlaneIntents(cmsContext ContextID, lastProfilePos = nProfiles - 1; hLastProfile = hProfiles[lastProfilePos]; - while (lastProfilePos > 1) - { + // Skip CMYK->CMYK devicelinks on ending + while (is_cmyk_devicelink(hLastProfile)) + { + if (lastProfilePos < 2) + break; + hLastProfile = hProfiles[--lastProfilePos]; - if (cmsGetColorSpace(hLastProfile) != cmsSigCmykData || - cmsGetDeviceClass(hLastProfile) != cmsSigLinkClass) - break; - } + } preservationProfilesCount = lastProfilePos + 1; |