0

I've been working on a piece of code that does precisely this. I input a color value, either RGB or CMYK, then utilize an ICC profile—specifically AdobeRGB1998.icc for RGB and CoatedFOGRA39.icc for CMYK—coupled with a rendering intent set to RelativeColorimetric. The result? A converted XYZ value representing that color in a device-independent color space.

However, I hit a stumbling block when I tried to reverse this operation. Using the same approach, I aimed to input an XYZ value and, through the AdobeRGB1998.icc profile and RelativeColorimetric rendering intent, convert it back to its RGB counterpart. To my dismay, I encountered an error: icCmmStatBadSpaceLink = 2.

Upon inspection of the AdobeRGB1998.icc header details, I confirmed:

Color Space: "icSigRgbData" PCS: "icSigXYZData" Profile/Device Class: "icSigLinkClass"

Here's the relevant code segment:

// Setup color transformation from XYZ to RGB
CIccCmm cmmRGB(icSigXYZData, icSigRgbData);
icStatusCMM statusRGB = cmmRGB.AddXform(profilePath2, icRelativeColorimetric, icInterpLinear, icXformLutColor, true, NULL);
if (statusRGB == icCmmStatCantOpenProfile) {
    qDebug() << "Error: Can't open the ICC profile at path:" << profilePath2;
    return -1;
}
else if (statusRGB != icCmmStatOk) {
    qDebug() << "Error setting up the transform to RGB. Status:" << statusRGB;
    return -1;
}

icFloatNumber RGBVals[3];
cmmRGB.Begin(); // Initialization to prevent crashes
qDebug() << "Begin";
cmmRGB.Apply(XYZVals, RGBVals);
qDebug() << "Output RGB: " << RGBVals[0] << RGBVals[1] << RGBVals[2];

Can solve the convert problem.

Edward
  • 11
  • 2

0 Answers0