I have a CMYK->CMYK profile that I've chained with a device link profile to
apply tonal correction to the image. This works as expected. I now want to
separate this into 2 passes and I find that making 2 transforms does not
work. I get an Invalid PCS error from cmsCreateTransform. The PCS is invalid
because it is CMYK and cmsCreateTransform is expecting Lab or XYZ.

Here is some code that shows the problem.

int main (int argc, const char * argv[]) {

    LPGAMMATABLE transferFunctions[4];

    // load a stock CMYK profile (this is distributed with Photoshop but
anyone should do)
    cmsHPROFILE hInProfile = cmsOpenProfileFromFile("CoatedGRACoL2006.icc",
"r");

    // build a linear gamma table (my app doesn't use linear but it doesn't
matter in this example)
    const int numberOfEntries = 255;
    transferFunctions[0] = cmsBuildGamma(numberOfEntries, 1.0);
    transferFunctions[1] = cmsBuildGamma(numberOfEntries, 1.0);
    transferFunctions[2] = cmsBuildGamma(numberOfEntries, 1.0);
    transferFunctions[3] = cmsBuildGamma(numberOfEntries, 1.0);

    cmsHPROFILE tonalProfile =
cmsCreateLinearizationDeviceLink(icSigCmykData, transferFunctions);

    // build the chain of profile, first xform is CMYK->CMYK, second xform
    // is CMYK->CMYK with the above transfer function
    cmsHPROFILE profiles[3];

    profiles[0] = hInProfile;
    profiles[1] = hInProfile;
    profiles[2] = tonalProfile;

    int intent = INTENT_ABSOLUTE_COLORIMETRIC;
    int flags = cmsFLAGS_NOTPRECALC  | cmsFLAGS_HIGHRESPRECALC |
cmsFLAGS_NOPRELINEARIZATION;

    // this succeeds
    cmsHTRANSFORM chainedTrans = cmsCreateMultiprofileTransform(profiles, 3,
TYPE_CMYK_8, TYPE_CMYK_8, intent, flags);

    // but doing it twice fails.
    // The second transform is not built because of an invalid PCS
    //

    // passes
    cmsHTRANSFORM trans1 = cmsCreateTransform(hInProfile, TYPE_CMYK_8,
hInProfile,  TYPE_CMYK_8,  intent,  flags);

    // fails
    cmsHTRANSFORM trans2 = cmsCreateTransform(hInProfile, TYPE_CMYK_8,
tonalProfile,  TYPE_CMYK_8,  intent,  flags);

}

How can I separate these steps? Thank you.
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Lcms-user mailing list
Lcms-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lcms-user

Reply via email to