LPLUT LCMSEXPORT cmsSetMatrixLUT4(LPLUT Lut, LPMAT3 M, LPVEC3 off, DWORD dwFlags) { WMAT3 WMat; WVEC3 Woff; VEC3 Zero = {{0, 0, 0}}; MAT3toFix(&WMat, M); if (off == NULL) off = &Zero; VEC3toFix(&Woff, off); // Nop if identity if (MAT3isIdentity(&WMat, 0.0001) && (Woff.n[VX] == 0 && Woff.n[VY] == 0 && Woff.n[VZ] == 0)) return Lut; switch (dwFlags) { case LUT_HASMATRIX: Lut ->Matrix = WMat; Lut ->wFlags |= LUT_HASMATRIX; break; case LUT_HASMATRIX3: Lut ->Mat3 = WMat; Lut ->Ofs3 = Woff; Lut ->wFlags |= LUT_HASMATRIX3; break; case LUT_HASMATRIX4: Lut ->Mat4 = WMat; Lut ->Ofs4 = Woff; Lut ->wFlags |= LUT_HASMATRIX4; break; default:; } return Lut; }
int cmsChooseCnvrt(int Absolute, int Phase1, LPcmsCIEXYZ BlackPointIn, LPcmsCIEXYZ WhitePointIn, LPcmsCIEXYZ IlluminantIn, LPMAT3 ChromaticAdaptationMatrixIn, int Phase2, LPcmsCIEXYZ BlackPointOut, LPcmsCIEXYZ WhitePointOut, LPcmsCIEXYZ IlluminantOut, LPMAT3 ChromaticAdaptationMatrixOut, int DoBlackPointCompensation, double AdaptationState, _cmsADJFN *fn1, LPWMAT3 wm, LPWVEC3 wof) { int rc; MAT3 m; VEC3 of; MAT3identity(&m); VEC3init(&of, 0, 0, 0); switch (Phase1) { // Input LUT is giving XYZ relative values. case XYZRel: rc = FromXYZRelLUT(Absolute, BlackPointIn, WhitePointIn, IlluminantIn, ChromaticAdaptationMatrixIn, Phase2, BlackPointOut, WhitePointOut, IlluminantOut, ChromaticAdaptationMatrixOut, DoBlackPointCompensation, AdaptationState, fn1, &m, &of); break; // Input LUT is giving Lab relative values case LabRel: rc = FromLabRelLUT(Absolute, BlackPointIn, WhitePointIn, IlluminantIn, ChromaticAdaptationMatrixIn, Phase2, BlackPointOut, WhitePointOut, IlluminantOut, ChromaticAdaptationMatrixOut, DoBlackPointCompensation, AdaptationState, fn1, &m, &of); break; // Unrecognized combination default: cmsSignalError(LCMS_ERRC_ABORTED, "(internal) Phase error"); return FALSE; } MAT3toFix(wm, &m); VEC3toFix(wof, &of); // Do some optimization -- discard conversion if identity parameters. if (*fn1 == XYZ2XYZ || *fn1 == Lab2XYZ2Lab) { if (IdentityParameters(wm, wof)) *fn1 = NULL; } return rc; }