/* Get the link from the CMS, but include proofing. We need to note that as an option in the rendering params. If we are doing transparency, that would only occur at the top of the stack TODO: Add error checking */ gcmmhlink_t gscms_get_link_proof(gcmmhprofile_t lcms_srchandle, gcmmhprofile_t lcms_deshandle, gcmmhprofile_t lcms_proofhandle, gsicc_rendering_param_t *rendering_params) { DWORD src_data_type,des_data_type; icColorSpaceSignature src_color_space,des_color_space; int src_nChannels,des_nChannels; /* Get the data types */ src_color_space = cmsGetColorSpace(lcms_srchandle); des_color_space = cmsGetColorSpace(lcms_deshandle); src_nChannels = _cmsChannelsOf(src_color_space); des_nChannels = _cmsChannelsOf(des_color_space); /* For now, just do single byte data, interleaved. We can change this when we use the transformation. */ src_data_type= (CHANNELS_SH(src_nChannels)|BYTES_SH(1)); des_data_type= (CHANNELS_SH(des_nChannels)|BYTES_SH(1)); /* Create the link. Note the gamut check alarm */ return(cmsCreateProofingTransform(lcms_srchandle, src_data_type, lcms_deshandle, des_data_type, lcms_proofhandle, rendering_params->rendering_intent, INTENT_ABSOLUTE_COLORIMETRIC, cmsFLAGS_GAMUTCHECK | cmsFLAGS_SOFTPROOFING )); }
/* Get the link from the CMS, but include proofing and/or a device link profile. */ gcmmhlink_t gscms_get_link_proof_devlink(gcmmhprofile_t lcms_srchandle, gcmmhprofile_t lcms_proofhandle, gcmmhprofile_t lcms_deshandle, gcmmhprofile_t lcms_devlinkhandle, gsicc_rendering_param_t *rendering_params, bool src_dev_link, int cmm_flags, gs_memory_t *mem) { DWORD src_data_type,des_data_type; icColorSpaceSignature src_color_space,des_color_space; int src_nChannels,des_nChannels; int lcms_src_color_space, lcms_des_color_space; cmsHPROFILE hProfiles[5]; int nProfiles = 0; /* First handle all the source stuff */ src_color_space = cmsGetColorSpace(lcms_srchandle); lcms_src_color_space = _cmsLCMScolorSpace(src_color_space); /* littlecms returns -1 for types it does not (but should) understand */ if (lcms_src_color_space < 0) lcms_src_color_space = 0; src_nChannels = _cmsChannelsOf(src_color_space); /* For now, just do single byte data, interleaved. We can change this when we use the transformation. */ src_data_type = (COLORSPACE_SH(lcms_src_color_space)| CHANNELS_SH(src_nChannels)|BYTES_SH(2)); if (lcms_deshandle != NULL) { des_color_space = cmsGetColorSpace(lcms_deshandle); } else { /* We must have a device link profile. */ des_color_space = cmsGetPCS(lcms_deshandle); } lcms_des_color_space = _cmsLCMScolorSpace(des_color_space); if (lcms_des_color_space < 0) lcms_des_color_space = 0; des_nChannels = _cmsChannelsOf(des_color_space); des_data_type = (COLORSPACE_SH(lcms_des_color_space)| CHANNELS_SH(des_nChannels)|BYTES_SH(2)); /* lcms proofing transform has a clunky API and can't include the device link profile if we have both. So use cmsCreateMultiprofileTransform instead and round trip the proofing profile. */ hProfiles[nProfiles++] = lcms_srchandle; if (lcms_proofhandle != NULL) { hProfiles[nProfiles++] = lcms_proofhandle; hProfiles[nProfiles++] = lcms_proofhandle; } hProfiles[nProfiles++] = lcms_deshandle; if (lcms_devlinkhandle != NULL) { hProfiles[nProfiles++] = lcms_devlinkhandle; } return(cmsCreateMultiprofileTransform(hProfiles, nProfiles, src_data_type, des_data_type, rendering_params->rendering_intent, (cmm_flags | cmsFLAGS_BLACKPOINTCOMPENSATION | cmsFLAGS_HIGHRESPRECALC | cmsFLAGS_NOTCACHE))); }
/* Get the number of output channels for the profile */ int gscms_get_output_channel_count(gcmmhprofile_t profile) { icColorSpaceSignature colorspace; colorspace = cmsGetPCS(profile); return(_cmsChannelsOf(colorspace)); }
/* Get the link from the CMS. TODO: Add error checking */ gcmmhlink_t gscms_get_link(gcmmhprofile_t lcms_srchandle, gcmmhprofile_t lcms_deshandle, gsicc_rendering_param_t *rendering_params) { DWORD src_data_type,des_data_type; icColorSpaceSignature src_color_space,des_color_space; int src_nChannels,des_nChannels; int lcms_src_color_space, lcms_des_color_space; /* Check for case of request for a transfrom from a device link profile in that case, the destination profile is NULL */ /* First handle all the source stuff */ src_color_space = cmsGetColorSpace(lcms_srchandle); lcms_src_color_space = _cmsLCMScolorSpace(src_color_space); /* littlecms returns -1 for types it does not (but should) understand */ if (lcms_src_color_space < 0) lcms_src_color_space = 0; src_nChannels = _cmsChannelsOf(src_color_space); /* For now, just do single byte data, interleaved. We can change this when we use the transformation. */ src_data_type = (COLORSPACE_SH(lcms_src_color_space)| CHANNELS_SH(src_nChannels)|BYTES_SH(2)); if (lcms_deshandle != NULL) { des_color_space = cmsGetColorSpace(lcms_deshandle); } else { /* We must have a device link profile. */ des_color_space = cmsGetPCS(lcms_deshandle); } lcms_des_color_space = _cmsLCMScolorSpace(des_color_space); if (lcms_des_color_space < 0) lcms_des_color_space = 0; des_nChannels = _cmsChannelsOf(des_color_space); des_data_type = (COLORSPACE_SH(lcms_des_color_space)| CHANNELS_SH(des_nChannels)|BYTES_SH(2)); /* Create the link */ return(cmsCreateTransform(lcms_srchandle, src_data_type, lcms_deshandle, des_data_type, rendering_params->rendering_intent, (cmsFLAGS_BLACKPOINTCOMPENSATION | cmsFLAGS_HIGHRESPRECALC))); /* cmsFLAGS_HIGHRESPRECALC) cmsFLAGS_NOTPRECALC cmsFLAGS_LOWRESPRECALC*/ }
static cmsHPROFILE CreateNamedColorDevicelink(cmsHTRANSFORM xform) { _LPcmsTRANSFORM v = (_LPcmsTRANSFORM) xform; cmsHPROFILE hICC; cmsCIEXYZ WhitePoint; int i, nColors; size_t Size; LPcmsNAMEDCOLORLIST nc2; hICC = _cmsCreateProfilePlaceholder(); if (hICC == NULL) return NULL; cmsSetRenderingIntent(hICC, v -> Intent); cmsSetDeviceClass(hICC, icSigNamedColorClass); cmsSetColorSpace(hICC, v ->ExitColorSpace); cmsSetPCS(hICC, cmsGetPCS(v ->InputProfile)); cmsTakeMediaWhitePoint(&WhitePoint, v ->InputProfile); cmsAddTag(hICC, icSigMediaWhitePointTag, &WhitePoint); cmsAddTag(hICC, icSigDeviceMfgDescTag, (LPVOID) "LittleCMS"); cmsAddTag(hICC, icSigProfileDescriptionTag, (LPVOID) "Named color Device link"); cmsAddTag(hICC, icSigDeviceModelDescTag, (LPVOID) "Named color Device link"); nColors = cmsNamedColorCount(xform); nc2 = cmsAllocNamedColorList(nColors); Size = sizeof(cmsNAMEDCOLORLIST) + (sizeof(cmsNAMEDCOLOR) * (nColors-1)); CopyMemory(nc2, v->NamedColorList, Size); nc2 ->ColorantCount = _cmsChannelsOf(v ->ExitColorSpace); for (i=0; i < nColors; i++) { cmsDoTransform(xform, &i, nc2 ->List[i].DeviceColorant, 1); } cmsAddTag(hICC, icSigNamedColor2Tag, (void*) nc2); cmsFreeNamedColorList(nc2); return hICC; }
cmsHPROFILE LCMSEXPORT cmsCreateLinearizationDeviceLink(icColorSpaceSignature ColorSpace, LPGAMMATABLE TransferFunctions[]) { cmsHPROFILE hICC; LPLUT Lut; hICC = _cmsCreateProfilePlaceholder(); if (!hICC) // can't allocate return NULL; cmsSetDeviceClass(hICC, icSigLinkClass); cmsSetColorSpace(hICC, ColorSpace); cmsSetPCS(hICC, ColorSpace); cmsSetRenderingIntent(hICC, INTENT_PERCEPTUAL); // Creates a LUT with prelinearization step only Lut = cmsAllocLUT(); if (Lut == NULL) return NULL; // Set up channels Lut ->InputChan = Lut ->OutputChan = _cmsChannelsOf(ColorSpace); // Copy tables to LUT cmsAllocLinearTable(Lut, TransferFunctions, 1); // Create tags cmsAddTag(hICC, icSigDeviceMfgDescTag, (LPVOID) "(lcms internal)"); cmsAddTag(hICC, icSigProfileDescriptionTag, (LPVOID) "lcms linearization device link"); cmsAddTag(hICC, icSigDeviceModelDescTag, (LPVOID) "linearization built-in"); cmsAddTag(hICC, icSigMediaWhitePointTag, (LPVOID) cmsD50_XYZ()); cmsAddTag(hICC, icSigAToB0Tag, (LPVOID) Lut); // LUT is already on virtual profile cmsFreeLUT(Lut); // Ok, done return hICC; }
// Simplified version of multiprofile transform creator // Flags are removed from arguments. // Gamut checking and named color profiles are not supported. // WARNING: I/O pixel formats should be specified for the created transform later by caller. cmsHTRANSFORM cmmCreateMultiprofileTransform(cmsHPROFILE hProfiles[], int nProfiles, int Intent) { DWORD inFmt, outFmt; cmsHPROFILE hTargetProfile, hProfile; icColorSpaceSignature csIn, csOut; LPLUT Grid = NULL; int nGridPoints, nInChannels, nOutChannels = 3, i = 0; _LPcmsTRANSFORM p; // Resulting transform cmsHTRANSFORM transforms[255]; // Cannot merge more than 255 profiles ZeroMemory(transforms, sizeof(transforms)); if (nProfiles > 255) { return NULL; // Too many profiles } // Check if there are any named color profiles for (i=0; i < nProfiles; i++) { if (cmsGetDeviceClass(hProfiles[i]) == icSigNamedColorClass || cmsGetDeviceClass(hProfiles[i]) == icSigLinkClass) { return NULL; // Unsupported named color and device link profiles } } // Create a placeholder transform with dummy I/O formats to place LUT in it p = (_LPcmsTRANSFORM) cmsCreateTransform(NULL, TYPE_RGB_8, NULL, TYPE_RGB_8, Intent, cmsFLAGS_NULLTRANSFORM); p->EntryColorSpace = cmsGetColorSpace(hProfiles[0]); // Gater information about first input profile hProfile = hProfiles[0]; csIn = cmsGetColorSpace(hProfile); nInChannels = _cmsChannelsOf(csIn); inFmt = BYTES_SH(2) | CHANNELS_SH(nInChannels); // Create a sequence for (i=1; i < nProfiles; i++) { // Gather output parameters hTargetProfile = hProfiles[i]; csOut = cmsGetColorSpace(hTargetProfile); nOutChannels = _cmsChannelsOf(csOut); outFmt = BYTES_SH(2)|CHANNELS_SH(nOutChannels); transforms[i-1] = cmsCreateTransform( hProfile, inFmt, hTargetProfile, outFmt, Intent, cmsFLAGS_NOTPRECALC | cmsFLAGS_NOTCACHE ); if(transforms[i-1] == NULL) CLEANUP_AND_RETURN(NULL); // Incompatible profiles? // Assign output parameters to input hProfile = hTargetProfile; csIn = csOut; nInChannels = nOutChannels; inFmt = outFmt; } p->ExitColorSpace = csOut; transforms[i] = NULL; // End marker p->InputProfile = hProfiles[0]; p->OutputProfile = hProfiles[nProfiles-1]; nGridPoints = _cmsReasonableGridpointsByColorspace(p->EntryColorSpace, 0); nInChannels = _cmsChannelsOf(cmsGetColorSpace(p->InputProfile)); // Create 3DCLUT if (! (Grid = cmsAllocLUT())) CLEANUP_AND_RETURN(NULL); Grid = cmsAlloc3DGrid(Grid, nGridPoints, nInChannels, nOutChannels); _cmsComputePrelinearizationTablesFromXFORM(transforms, nProfiles-1, Grid); // Compute device link on 16-bit basis if (!cmsSample3DGrid(Grid, cmmMultiprofileSampler, (LPVOID) transforms, Grid -> wFlags)) CLEANUP_AND_RETURN(NULL); // Put the new LUT into resulting transform p->DeviceLink = Grid; // Set transform method p->xform = cmmPrecalculatedXformImpl; // Commented out since it is not clear if it is correct or not // Sequential transforms gives same result as multiprofile with this call commented out /* if(Intent != INTENT_ABSOLUTE_COLORIMETRIC) _cmsFixWhiteMisalignment(p); */ // Don't clean LUT Grid = NULL; CLEANUP_AND_RETURN((cmsHTRANSFORM) p); }
cmsHPROFILE LCMSEXPORT cmsCreateInkLimitingDeviceLink(icColorSpaceSignature ColorSpace, double Limit) { cmsHPROFILE hICC; LPLUT Lut; if (ColorSpace != icSigCmykData) { cmsSignalError(LCMS_ERRC_ABORTED, "InkLimiting: Only CMYK currently supported"); return NULL; } if (Limit < 0.0 || Limit > 400) { cmsSignalError(LCMS_ERRC_WARNING, "InkLimiting: Limit should be between 0..400"); if (Limit < 0) Limit = 0; if (Limit > 400) Limit = 400; } hICC = _cmsCreateProfilePlaceholder(); if (!hICC) // can't allocate return NULL; cmsSetDeviceClass(hICC, icSigLinkClass); cmsSetColorSpace(hICC, ColorSpace); cmsSetPCS(hICC, ColorSpace); cmsSetRenderingIntent(hICC, INTENT_PERCEPTUAL); // Creates a LUT with 3D grid only Lut = cmsAllocLUT(); if (Lut == NULL) { cmsCloseProfile(hICC); return NULL; } cmsAlloc3DGrid(Lut, 17, _cmsChannelsOf(ColorSpace), _cmsChannelsOf(ColorSpace)); if (!cmsSample3DGrid(Lut, InkLimitingSampler, (LPVOID) &Limit, 0)) { // Shouldn't reach here cmsFreeLUT(Lut); cmsCloseProfile(hICC); return NULL; } // Create tags cmsAddTag(hICC, icSigDeviceMfgDescTag, (LPVOID) "(lcms internal)"); cmsAddTag(hICC, icSigProfileDescriptionTag, (LPVOID) "lcms ink limiting device link"); cmsAddTag(hICC, icSigDeviceModelDescTag, (LPVOID) "ink limiting built-in"); cmsAddTag(hICC, icSigMediaWhitePointTag, (LPVOID) cmsD50_XYZ()); cmsAddTag(hICC, icSigAToB0Tag, (LPVOID) Lut); // LUT is already on virtual profile cmsFreeLUT(Lut); // Ok, done return hICC; }
static DWORD MakeFormatDescriptor(icColorSpaceSignature ColorSpace, int Bytes) { int Channels = _cmsChannelsOf(ColorSpace); return COLORSPACE_SH(ICC2LCMS(ColorSpace))|BYTES_SH(Bytes)|CHANNELS_SH(Channels)|PLANAR_SH(1); }
static void OpenTransforms(int argc, char *argv[]) { DWORD dwIn, dwOut, dwFlags; if (lMultiProfileChain) { int i; cmsHTRANSFORM hTmp; nProfiles = argc - xoptind; for (i=0; i < nProfiles; i++) { hProfiles[i] = OpenProfile(argv[i+xoptind]); } // Create a temporary devicelink hTmp = cmsCreateMultiprofileTransform(hProfiles, nProfiles, 0, 0, Intent, GetFlags()); hInput = cmsTransform2DeviceLink(hTmp, 0); hOutput = NULL; cmsDeleteTransform(hTmp); InputColorSpace = cmsGetColorSpace(hInput); OutputColorSpace = cmsGetPCS(hInput); lIsDeviceLink = TRUE; } else if (lIsDeviceLink) { hInput = cmsOpenProfileFromFile(cInProf, "r"); hOutput = NULL; InputColorSpace = cmsGetColorSpace(hInput); OutputColorSpace = cmsGetPCS(hInput); } else { hInput = OpenProfile(cInProf); hOutput = OpenProfile(cOutProf); InputColorSpace = cmsGetColorSpace(hInput); OutputColorSpace = cmsGetColorSpace(hOutput); if (cmsGetDeviceClass(hInput) == icSigLinkClass || cmsGetDeviceClass(hOutput) == icSigLinkClass) FatalError("Use %cl flag for devicelink profiles!\n", SW); } if (Verbose) { mexPrintf("From: %s\n", cmsTakeProductName(hInput)); if (hOutput) mexPrintf("To : %s\n\n", cmsTakeProductName(hOutput)); } OutputChannels = _cmsChannelsOf(OutputColorSpace); InputChannels = _cmsChannelsOf(InputColorSpace); dwIn = MakeFormatDescriptor(InputColorSpace, nBytesDepth); dwOut = MakeFormatDescriptor(OutputColorSpace, nBytesDepth); dwFlags = GetFlags(); if (cProofing != NULL) { hProof = OpenProfile(cProofing); dwFlags |= cmsFLAGS_SOFTPROOFING; } hColorTransform = cmsCreateProofingTransform(hInput, dwIn, hOutput, dwOut, hProof, Intent, ProofingIntent, dwFlags); }
static LPLUT ComputeGamutWithInput(cmsHPROFILE hInput, cmsHPROFILE hProfile, int Intent) { cmsHPROFILE hLab; LPLUT Gamut; DWORD dwFormat; GAMUTCHAIN Chain; int nErrState, nChannels, nGridpoints; LPGAMMATABLE Trans[3]; icColorSpaceSignature ColorSpace; ZeroMemory(&Chain, sizeof(GAMUTCHAIN)); hLab = cmsCreateLabProfile(NULL); // Safeguard against early abortion nErrState = cmsErrorAction(LCMS_ERROR_IGNORE); // The figure of merit. On matrix-shaper profiles, should be almost zero as // the conversion is pretty exact. On LUT based profiles, different resolutions // of input and output CLUT may result in differences. if (!cmsIsIntentSupported(hProfile, Intent, LCMS_USED_AS_INPUT) && !cmsIsIntentSupported(hProfile, Intent, LCMS_USED_AS_OUTPUT)) Chain.Thereshold = 1.0; else Chain.Thereshold = ERR_THERESHOLD; ColorSpace = cmsGetColorSpace(hProfile); // If input profile specified, create a transform from such profile to Lab if (hInput != NULL) { nChannels = _cmsChannelsOf(ColorSpace); nGridpoints = _cmsReasonableGridpointsByColorspace(ColorSpace, cmsFLAGS_HIGHRESPRECALC); dwFormat = (CHANNELS_SH(nChannels)|BYTES_SH(2)); Chain.hInput = cmsCreateTransform(hInput, dwFormat, hLab, TYPE_Lab_16, Intent, cmsFLAGS_NOTPRECALC); } else { // Input transform=NULL (Lab) Used to compute the gamut tag // This table will take 53 points to give some accurancy, // 53 * 53 * 53 * 2 = 291K nChannels = 3; // For Lab nGridpoints = 53; Chain.hInput = NULL; dwFormat = (CHANNELS_SH(_cmsChannelsOf(ColorSpace))|BYTES_SH(2)); } // Does create the forward step Chain.hForward = cmsCreateTransform(hLab, TYPE_Lab_16, hProfile, dwFormat, INTENT_RELATIVE_COLORIMETRIC, cmsFLAGS_NOTPRECALC); // Does create the backwards step Chain.hReverse = cmsCreateTransform(hProfile, dwFormat, hLab, TYPE_Lab_16, INTENT_RELATIVE_COLORIMETRIC, cmsFLAGS_NOTPRECALC); // Restores error handler previous state cmsErrorAction(nErrState); // All ok? if (Chain.hForward && Chain.hReverse) { // Go on, try to compute gamut LUT from PCS. // This consist on a single channel containing // dE when doing a transform back and forth on // the colorimetric intent. Gamut = cmsAllocLUT(); Gamut = cmsAlloc3DGrid(Gamut, nGridpoints, nChannels, 1); // If no input, then this is a gamut tag operated by Lab, // so include pertinent prelinearization if (hInput == NULL) { CreateLabPrelinearization(Trans); cmsAllocLinearTable(Gamut, Trans, 1); cmsFreeGammaTriple(Trans); } cmsSample3DGrid(Gamut, GamutSampler, (LPVOID) &Chain, Gamut ->wFlags); } else Gamut = NULL; // Didn't work... // Free all needed stuff. if (Chain.hInput) cmsDeleteTransform(Chain.hInput); if (Chain.hForward) cmsDeleteTransform(Chain.hForward); if (Chain.hReverse) cmsDeleteTransform(Chain.hReverse); cmsCloseProfile(hLab); // And return computed hull return Gamut; }
void ColorICCSelector::_switchToProfile( gchar const* name ) { bool dirty = false; SPColor tmp( _color ); if ( name ) { if ( tmp.icc && tmp.icc->colorProfile == name ) { #ifdef DEBUG_LCMS g_message("Already at name [%s]", name ); #endif // DEBUG_LCMS } else { #ifdef DEBUG_LCMS g_message("Need to switch to profile [%s]", name ); #endif // DEBUG_LCMS if ( tmp.icc ) { tmp.icc->colors.clear(); } else { tmp.icc = new SVGICCColor(); } tmp.icc->colorProfile = name; Inkscape::ColorProfile* newProf = SP_ACTIVE_DOCUMENT->profileManager->find(name); if ( newProf ) { cmsHTRANSFORM trans = newProf->getTransfFromSRGB8(); if ( trans ) { guint32 val = _color.toRGBA32(0); guchar pre[4] = { static_cast<guchar>(SP_RGBA32_R_U(val)), static_cast<guchar>(SP_RGBA32_G_U(val)), static_cast<guchar>(SP_RGBA32_B_U(val)), 255}; #ifdef DEBUG_LCMS g_message("Shoving in [%02x] [%02x] [%02x]", pre[0], pre[1], pre[2]); #endif // DEBUG_LCMS cmsUInt16Number post[4] = {0,0,0,0}; cmsDoTransform( trans, pre, post, 1 ); #ifdef DEBUG_LCMS g_message("got on out [%04x] [%04x] [%04x] [%04x]", post[0], post[1], post[2], post[3]); #endif // DEBUG_LCMS #if HAVE_LIBLCMS1 guint count = _cmsChannelsOf( asICColorSpaceSig(newProf->getColorSpace()) ); #elif HAVE_LIBLCMS2 guint count = cmsChannelsOf( asICColorSpaceSig(newProf->getColorSpace()) ); #endif gchar const** names = 0; gchar const** tips = 0; guint const* scales = 0; getThings( asICColorSpaceSig(newProf->getColorSpace()), names, tips, scales ); for ( guint i = 0; i < count; i++ ) { gdouble val = (((gdouble)post[i])/65535.0) * (gdouble)scales[i]; #ifdef DEBUG_LCMS g_message(" scaled %d by %d to be %f", i, scales[i], val); #endif // DEBUG_LCMS tmp.icc->colors.push_back(val); } cmsHTRANSFORM retrans = newProf->getTransfToSRGB8(); if ( retrans ) { cmsDoTransform( retrans, post, pre, 1 ); #ifdef DEBUG_LCMS g_message(" back out [%02x] [%02x] [%02x]", pre[0], pre[1], pre[2]); #endif // DEBUG_LCMS tmp.set(SP_RGBA32_U_COMPOSE(pre[0], pre[1], pre[2], 0xff)); } } } dirty = true; } } else { #ifdef DEBUG_LCMS g_message("NUKE THE ICC"); #endif // DEBUG_LCMS if ( tmp.icc ) { delete tmp.icc; tmp.icc = 0; dirty = true; _fixupHit( 0, this ); } else { #ifdef DEBUG_LCMS g_message("No icc to nuke"); #endif // DEBUG_LCMS } } if ( dirty ) { #ifdef DEBUG_LCMS g_message("+----------------"); g_message("+ new color is [%s]", tmp.toString().c_str()); #endif // DEBUG_LCMS _setProfile( tmp.icc ); //_adjustmentChanged( _fooAdj[0], SP_COLOR_ICC_SELECTOR(_csel) ); setColorAlpha( tmp, _alpha, true ); #ifdef DEBUG_LCMS g_message("+_________________"); #endif // DEBUG_LCMS } }
static void TakeValues(WORD Encoded[]) { if (cmsGetDeviceClass(hInput) == icSigNamedColorClass) { Encoded[0] = GetIndex(); return; } switch (InputColorSpace) { case icSigXYZData: xyz.X = GetDbl("X"); xyz.Y = GetDbl("Y"); xyz.Z = GetDbl("Z"); cmsFloat2XYZEncoded(Encoded, &xyz); break; case icSigLabData: Lab.L = GetDbl("L*"); Lab.a = GetDbl("a*"); Lab.b = GetDbl("b*"); cmsFloat2LabEncoded(Encoded, &Lab); break; case icSigLuvData: Encoded[0] = GetVal("L"); Encoded[1] = GetVal("u"); Encoded[2] = GetVal("v"); break; case icSigYCbCrData: Encoded[0] = GetVal("Y"); Encoded[1] = GetVal("Cb"); Encoded[2] = GetVal("Cr"); break; case icSigYxyData: Encoded[0] = GetVal("Y"); Encoded[1] = GetVal("x"); Encoded[2] = GetVal("y"); break; case icSigRgbData: Encoded[0] = GetVal("R"); Encoded[1] = GetVal("G"); Encoded[2] = GetVal("B"); break; case icSigGrayData: Encoded[0] = GetVal("G"); break; case icSigHsvData: Encoded[0] = GetVal("H"); Encoded[1] = GetVal("s"); Encoded[2] = GetVal("v"); break; case icSigHlsData: Encoded[0] = GetVal("H"); Encoded[1] = GetVal("l"); Encoded[2] = GetVal("s"); break; case icSigCmykData: Encoded[0] = Get100("C"); Encoded[1] = Get100("M"); Encoded[2] = Get100("Y"); Encoded[3] = Get100("K"); break; case icSigCmyData: Encoded[0] = Get100("C"); Encoded[1] = Get100("M"); Encoded[2] = Get100("Y"); break; case icSigHexachromeData: Encoded[0] = Get100("C"); Encoded[1] = Get100("M"); Encoded[2] = Get100("Y"); Encoded[3] = Get100("K"); Encoded[4] = Get100("c"); Encoded[5] = Get100("m"); break; case icSigHeptachromeData: case icSigOctachromeData: case icSig2colorData: case icSig3colorData: case icSig4colorData: case icSig5colorData: case icSig6colorData: case icSig7colorData: case icSig8colorData: { int i; for (i=0; i < _cmsChannelsOf(InputColorSpace); i++) { char Name[100]; sprintf(Name, "Channel #%d", i+1); Encoded[i] = GetVal(Name); } } break; default: FatalError("Unsupported %d channel profile", _cmsChannelsOf(InputColorSpace)); } }
static void PrintResults(WORD Encoded[], icColorSpaceSignature ColorSpace) { int i; switch (ColorSpace) { case icSigXYZData: cmsXYZEncoded2Float(&xyz, Encoded); PrintCooked("X", xyz.X * 100.); PrintCooked("Y", xyz.Y * 100.); PrintCooked("Z", xyz.Z * 100.); break; case icSigLabData: cmsLabEncoded2Float(&Lab, Encoded); PrintCooked("L*", Lab.L); PrintCooked("a*", Lab.a); PrintCooked("b*", Lab.b); break; case icSigLuvData: PrintOne("L", Encoded[0]); PrintOne("u", Encoded[1]); PrintOne("v", Encoded[2]); break; case icSigYCbCrData: PrintOne("Y", Encoded[0]); PrintOne("Cb", Encoded[1]); PrintOne("Cr", Encoded[2]); break; case icSigYxyData: PrintOne("Y", Encoded[0]); PrintOne("x", Encoded[1]); PrintOne("y", Encoded[2]); break; case icSigRgbData: PrintOne("R", Encoded[0]); PrintOne("G", Encoded[1]); PrintOne("B", Encoded[2]); break; case icSigGrayData: PrintOne("G", Encoded[0]); break; case icSigHsvData: PrintOne("H", Encoded[0]); PrintOne("s", Encoded[1]); PrintOne("v", Encoded[2]); break; case icSigHlsData: PrintOne("H", Encoded[0]); PrintOne("l", Encoded[1]); PrintOne("s", Encoded[2]); break; case icSigCmykData: Print100("C", Encoded[0]); Print100("M", Encoded[1]); Print100("Y", Encoded[2]); Print100("K", Encoded[3]); break; case icSigCmyData: Print100("C", Encoded[0]); Print100("M", Encoded[1]); Print100("Y", Encoded[2]); break; case icSigHexachromeData: case icSig6colorData: Print100("C", Encoded[0]); Print100("M", Encoded[1]); Print100("Y", Encoded[2]); Print100("K", Encoded[3]); Print100("c", Encoded[1]); Print100("m", Encoded[2]); break; default: for (i=0; i < _cmsChannelsOf(OutputColorSpace); i++) { char Buffer[10]; sprintf(Buffer, "CHAN%d", i + 1); PrintOne(Buffer, Encoded[i]); } } }
static void OpenTransforms(void) { DWORD dwIn, dwOut, dwFlags; dwFlags = 0; if (lIsDeviceLink) { hInput = cmsOpenProfileFromFile(cInProf, "r"); hOutput = NULL; InputColorSpace = cmsGetColorSpace(hInput); OutputColorSpace = cmsGetPCS(hInput); } else { hInput = OpenStockProfile(cInProf); hOutput = OpenStockProfile(cOutProf); hProof = NULL; if (cProofing != NULL) { hProof = OpenStockProfile(cProofing); dwFlags |= cmsFLAGS_SOFTPROOFING; } InputColorSpace = cmsGetColorSpace(hInput); OutputColorSpace = cmsGetColorSpace(hOutput); if (cmsGetDeviceClass(hInput) == icSigLinkClass || cmsGetDeviceClass(hOutput) == icSigLinkClass) FatalError("Use %cl flag for devicelink profiles!\n", SW); } hXYZ = cmsCreateXYZProfile(); hLab = cmsCreateLabProfile(NULL); if (Verbose) { printf("From: %s\n", cmsTakeProductName(hInput)); printf("Desc: %s\n", cmsTakeProductDesc(hInput)); if (hOutput) printf("To : %s\n\n", cmsTakeProductName(hOutput)); } dwIn = BYTES_SH(2) | CHANNELS_SH(_cmsChannelsOf(InputColorSpace)); dwOut = BYTES_SH(2) | CHANNELS_SH(_cmsChannelsOf(OutputColorSpace)); switch (PrecalcMode) { case 0: dwFlags |= cmsFLAGS_NOTPRECALC; break; case 2: dwFlags |= cmsFLAGS_HIGHRESPRECALC; break; case 3: dwFlags |= cmsFLAGS_LOWRESPRECALC; break; case 1: break; default: FatalError("Unknown precalculation mode '%d'", PrecalcMode); } if (BlackPointCompensation) dwFlags |= cmsFLAGS_BLACKPOINTCOMPENSATION; if (GamutCheck) { if (hProof == NULL) FatalError("I need proofing profile -p for gamut checking!"); cmsSetAlarmCodes(0xFF, 0xFF, 0xFF); dwFlags |= cmsFLAGS_GAMUTCHECK; } if (cmsGetDeviceClass(hInput) == icSigNamedColorClass) { dwIn = TYPE_NAMED_COLOR_INDEX; } hTrans = cmsCreateProofingTransform(hInput, dwIn, hOutput, dwOut, hProof, Intent, ProofingIntent, dwFlags); hTransXYZ = NULL; hTransLab = NULL; if (hOutput && Verbose) { hTransXYZ = cmsCreateTransform(hInput, dwIn, hXYZ, TYPE_XYZ_16, Intent, cmsFLAGS_NOTPRECALC); hTransLab = cmsCreateTransform(hInput, dwIn, hLab, TYPE_Lab_16, Intent, cmsFLAGS_NOTPRECALC); } }