static void init(void) { cmsCIEXYZ D65_XYZ = {0.95047, 1.0, 1.08883 }; cmsCIExyY D65; cmsXYZ2xyY(&D65, &D65_XYZ); cmsToneCurve *linear = cmsBuildGamma(NULL, 1.0); cmsToneCurve *linrgb[3] = {linear,linear,linear}; cmsCIExyYTRIPLE primaries = { {0.64, 0.33, 1.0}, {0.30, 0.60, 1.0}, {0.15, 0.06, 1.0} }; cmsFloat64Number P[5] = { 2.4, 1. / 1.055, 0.055 / 1.055, 1. / 12.92, 0.04045 }; cmsToneCurve *srgb = cmsBuildParametricToneCurve(NULL, 4, P); cmsToneCurve *srgbcurve[3] = {srgb,srgb,srgb}; cmsHPROFILE hsRGB = cmsCreateRGBProfile(&D65, &primaries, srgbcurve); cmsHPROFILE hLab = cmsCreateLab4Profile(NULL); cmsHPROFILE hlRGB = cmsCreateRGBProfile(&D65, &primaries, linrgb); cmsHPROFILE hlGray = cmsCreateGrayProfile(cmsD50_xyY(), linear); cmsSetHeaderFlags(hlGray, cmsEmbeddedProfileTrue); cmsSaveProfileToFile(hlGray,"lgray.icc"); cmsSetHeaderFlags(hlRGB, cmsEmbeddedProfileTrue); cmsSaveProfileToFile(hlRGB,"lrgb.icc"); xform_srgb_to_lrgb = cmsCreateTransform(hsRGB, TYPE_RGB_DBL, hlRGB, TYPE_RGB_DBL, INTENT_RELATIVE_COLORIMETRIC, cmsFLAGS_NOOPTIMIZE /* preserve precision */ ); xform_srgb_to_lab = cmsCreateTransform(hsRGB, TYPE_RGB_DBL, hLab, TYPE_Lab_DBL, INTENT_RELATIVE_COLORIMETRIC, cmsFLAGS_NOOPTIMIZE); xform_srgb_to_lgray = cmsCreateTransform(hsRGB, TYPE_RGB_DBL, hlGray, TYPE_GRAY_DBL, INTENT_RELATIVE_COLORIMETRIC, cmsFLAGS_NOOPTIMIZE); cmsCloseProfile(hsRGB); cmsCloseProfile(hlRGB); cmsCloseProfile(hLab); cmsCloseProfile(hlGray); cmsFreeToneCurve(linear); cmsFreeToneCurve(srgb); cmsSetLogErrorHandler(errlog); /* sRGB, RGB, Lab, Gray */ printf("R',G',B',R,G,B,L,a,b,Gray\n"); }
cmsBool _setHeaderInfo(cmsHPROFILE pf, jbyte* pBuffer, jint bufferSize) { cmsICCHeader pfHeader = { 0 }; if (pBuffer == NULL || bufferSize < sizeof(cmsICCHeader)) { return FALSE; } memcpy(&pfHeader, pBuffer, sizeof(cmsICCHeader)); // now set header fields, which we can access using the lcms2 public API cmsSetHeaderFlags(pf, pfHeader.flags); cmsSetHeaderManufacturer(pf, pfHeader.manufacturer); cmsSetHeaderModel(pf, pfHeader.model); cmsSetHeaderAttributes(pf, pfHeader.attributes); cmsSetHeaderProfileID(pf, (cmsUInt8Number*)&(pfHeader.profileID)); cmsSetHeaderRenderingIntent(pf, pfHeader.renderingIntent); cmsSetPCS(pf, pfHeader.pcs); cmsSetColorSpace(pf, pfHeader.colorSpace); cmsSetDeviceClass(pf, pfHeader.deviceClass); cmsSetEncodedICCversion(pf, pfHeader.version); return TRUE; }