-
Notifications
You must be signed in to change notification settings - Fork 206
Description
Hello.
This issue is continuation of this one: #273
That bug was caused by the "broken" PYCC.pf profile which did not include the "B" step. After the "B" was added to that profile the example code in that issue start to work fine.
The updated profile can be found here: https://bugs.openjdk.org/secure/attachment/99226/pycc2.icc
The icc inspector and ProfileDump mark this profile as "Valid".
Unfortunately I have found that the new updated profile can produce similar errors like before if cmsCreateTransform will be replaced by the cmsCreateMultiprofileTransform. So it cannot be saved to the memory if it was used by the cmsCreateMultiprofileTransform(). Tested on LittleCMS 2.12 and 2.13.
The test code:
#include "lcms2.h"
#include <stdlib.h>
void LogErrorHandler(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *Text){
fprintf(stderr, "%s\n", Text);
}
void check(cmsHPROFILE hProfile) {
cmsUInt32Number pfSize = 0;
cmsHPROFILE pfSanity = NULL;
if (cmsSaveProfileToMem(hProfile, NULL, &pfSize)) {
void* buf = malloc((pfSize));
if (buf != NULL) {
if (cmsSaveProfileToMem(hProfile, buf, &pfSize)) {
pfSanity = cmsOpenProfileFromMem(buf, pfSize);
cmsCloseProfile(pfSanity);
fprintf(stderr, "This step passed\n");
}
free(buf);
}
}
}
int main(void) {
cmsSetLogErrorHandler(LogErrorHandler);
cmsHPROFILE mid = cmsOpenProfileFromFile(".../.../PYCC.pf", "r");
cmsHPROFILE input = cmsCreate_sRGBProfile();
cmsHPROFILE output = cmsCreate_sRGBProfile();
cmsHPROFILE _iccArray[20];
int j = 0;
_iccArray[j++] = input;
_iccArray[j++] = mid;
_iccArray[j++] = mid;
// can the user request same profile again? skip it for now
// _iccArray[j++] = mid;
// _iccArray[j++] = mid;
_iccArray[j++] = output;
// this transform works fine
cmsHTRANSFORM transform = cmsCreateTransform(mid, PT_ANY,
output, PT_ANY,
INTENT_PERCEPTUAL,
cmsFLAGS_COPY_ALPHA);
cmsDeleteTransform(transform);
//// Comment the block below to solve the error
cmsHTRANSFORM hTransform = cmsCreateMultiprofileTransform(_iccArray, j,
TYPE_RGB_8, TYPE_RGB_8, INTENT_PERCEPTUAL, cmsFLAGS_COPY_ALPHA);
cmsDeleteTransform(hTransform);
//// Comment the block above to solve the error
check(input);
check(mid);
check(output);
cmsCloseProfile(input);
cmsCloseProfile(mid);
cmsCloseProfile(output);
return 0;
}The code above will print:
LUT is not suitable to be saved as LutAToB
Couldn't write type 'mAB '
But if the block of code is commented out(or just remove the cmsCreateMultiprofileTransform and cmsDeleteTransform) in the example, then cmsSaveProfileToMem/cmsOpenProfileFromMem will work fine.