static
int bchswSampler(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
{
    cmsCIELab LabIn, LabOut;
    cmsCIELCh LChIn, LChOut;
    cmsCIEXYZ XYZ;
    LPBCHSWADJUSTS bchsw = (LPBCHSWADJUSTS) Cargo;


    cmsLabEncoded2Float(&LabIn, In);


    cmsLab2LCh(&LChIn, &LabIn);

    // Do some adjusts on LCh

    LChOut.L = LChIn.L * bchsw ->Contrast + bchsw ->Brightness;
    LChOut.C = LChIn.C + bchsw -> Saturation;
    LChOut.h = LChIn.h + bchsw -> Hue;


    cmsLCh2Lab(&LabOut, &LChOut);

    // Move white point in Lab

    cmsLab2XYZ(&bchsw ->WPsrc,  &XYZ, &LabOut);
    cmsXYZ2Lab(&bchsw ->WPdest, &LabOut, &XYZ);

    // Back to encoded

    cmsFloat2LabEncoded(Out, &LabOut);

    return TRUE;
}
Example #2
0
static
int ITU2PCS(const register cmsUInt16Number In[], register cmsUInt16Number Out[], register void*  Cargo)
{   
	cmsCIELab Lab;

	ITU2Lab(In, &Lab);
	cmsFloat2LabEncoded(Out, &Lab);    
	return TRUE;
}
static
int bchswSampler(register WORD In[], register WORD Out[], register LPVOID Cargo)
{
    cmsCIELab LabIn, LabOut;
    cmsCIELCh LChIn, LChOut;
    cmsCIEXYZ XYZ;
    double l;
    double power;
    gboolean shift;

    LPBCHSWADJUSTS bchsw = (LPBCHSWADJUSTS) Cargo;    

    cmsLabEncoded2Float(&LabIn, In);
         // Move white point in Lab

    cmsLab2XYZ(&bchsw ->WPsrc,  &XYZ, &LabIn);
    cmsXYZ2Lab(&bchsw ->WPdest, &LabIn, &XYZ);

    shift = (LabIn.L > 0.5);
    l = LabIn.L / 100;
    if (shift)
	    l = 1.0 - l;

    if (l < 0.0)
	    l = 0.0;

    if (bchsw->Contrast < 0)
	    power = 1.0 + bchsw->Contrast;
    else
	    power = (bchsw->Contrast == 1.0) ? 127 : 1.0 / (1.0 - bchsw->Contrast);
	    
    l = 0.5 * pow (l * 2.0 , power);

    if (shift)
	    l = 1.0 - l;

    LabIn.L = l * 100;

    cmsLab2LCh(&LChIn, &LabIn);

    // Do some adjusts on LCh
    
    LChOut.L = LChIn.L * bchsw ->Exposure + bchsw ->Brightness;

    LChOut.C = MAX (0, LChIn.C + bchsw ->Saturation);
    LChOut.h = LChIn.h + bchsw ->Hue;
    
    cmsLCh2Lab(&LabOut, &LChOut);

    // Back to encoded

    cmsFloat2LabEncoded(Out, &LabOut);
    

    return TRUE;
}
Example #4
0
static
int ITU2PCS( register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void*  Cargo)
{
	cmsCIELab Lab;

	ITU2Lab(In, &Lab);
	cmsFloat2LabEncoded(Out, &Lab);
	return TRUE;

    UTILS_UNUSED_PARAMETER(Cargo);
}
Example #5
0
static
int Forward(register WORD In[], register WORD Out[], register LPVOID Cargo)
{
    cmsCIELab Lab;



    cmsLabEncoded2Float(&Lab, In);
    Lab.a = Lab.b = 0;
    cmsFloat2LabEncoded(Out, &Lab);

    return TRUE;
}
Example #6
0
static
int RegressionSamplerA2B(register WORD In[], register WORD Out[], register LPVOID Cargo)
{
    cmsCIEXYZ xyz;
    cmsCIELab Lab;
    VEC3 RGB, RGBlinear, vxyz;
    LPMONITORPROFILERDATA sys = (LPMONITORPROFILERDATA) Cargo;


        RGB.n[0] = _cmsxSaturate65535To255(In[0]);
        RGB.n[1] = _cmsxSaturate65535To255(In[1]);
        RGB.n[2] = _cmsxSaturate65535To255(In[2]);

        cmsxApplyLinearizationTable(RGB.n, sys->PreLab, RGBlinear.n);
        cmsxApplyLinearizationTable(RGBlinear.n, sys->Prelinearization, RGBlinear.n);

        RGBlinear.n[0] /= 255.;
        RGBlinear.n[1] /= 255.;
        RGBlinear.n[2] /= 255.;

        MAT3eval(&vxyz, &sys->PrimariesMatrix, &RGBlinear);

        xyz.X = vxyz.n[0];
        xyz.Y = vxyz.n[1];
        xyz.Z = vxyz.n[2];

        cmsxChromaticAdaptationAndNormalization(&sys ->hdr, &xyz, false);


       /* To PCS encoding */

       cmsXYZ2Lab(NULL, &Lab, &xyz);
       cmsFloat2LabEncoded(Out, &Lab);


    return true; /* And done witch success */
}
Example #7
0
/**
 * cd_util_create_named_color:
 **/
static gboolean
cd_util_create_named_color (CdUtilPrivate *priv,
			    CdDom *dom,
			    const GNode *root,
			    GError **error)
{
	CdColorLab lab;
	cmsNAMEDCOLORLIST *nc2 = NULL;
	cmsUInt16Number pcs[3];
	const GNode *name;
	const GNode *named;
	const GNode *prefix;
	const GNode *suffix;
	const GNode *tmp;
	gboolean ret = TRUE;

	priv->lcms_profile = cmsCreateNULLProfileTHR (cd_icc_get_context (priv->icc));
	if (priv->lcms_profile == NULL) {
		ret = FALSE;
		g_set_error_literal (error, 1, 0,
				     "failed to create NULL profile");
		goto out;
	}

	cmsSetDeviceClass(priv->lcms_profile, cmsSigNamedColorClass);
	cmsSetPCS (priv->lcms_profile, cmsSigLabData);
	cmsSetColorSpace (priv->lcms_profile, cmsSigLabData);

	/* create a named color structure */
	prefix = cd_dom_get_node (dom, root, "prefix");
	suffix = cd_dom_get_node (dom, root, "suffix");
	nc2 = cmsAllocNamedColorList (NULL, 1, /* will realloc more as required */
				      3,
				      prefix != NULL ? cd_dom_get_node_data (prefix) : "",
				      suffix != NULL ? cd_dom_get_node_data (suffix) : "");

	named = cd_dom_get_node (dom, root, "named");
	if (named == NULL) {
		ret = FALSE;
		g_set_error_literal (error, 1, 0,
				     "XML error: missing named");
		goto out;
	}
	for (tmp = named->children; tmp != NULL; tmp = tmp->next) {
		name = cd_dom_get_node (dom, tmp, "name");
		if (name == NULL) {
			ret = FALSE;
			g_set_error_literal (error, 1, 0,
					     "XML error: missing name");
			goto out;
		}
		ret = cd_dom_get_node_lab (tmp, &lab);
		if (!ret) {
			ret = FALSE;
			g_set_error (error, 1, 0,
				     "XML error: missing Lab for %s",
				     cd_dom_get_node_data (name));
			goto out;
		}

		/* PCS = colours in PCS colour space CIE*Lab
		 * colorant = colours in device colour space */
		cmsFloat2LabEncoded (pcs, (cmsCIELab *) &lab);
		ret = cmsAppendNamedColor (nc2, cd_dom_get_node_data (name), pcs, pcs);
		g_assert (ret);
	}
	cmsWriteTag (priv->lcms_profile, cmsSigNamedColor2Tag, nc2);
out:
	if (nc2 != NULL)
		cmsFreeNamedColorList (nc2);
	return ret;
}
Example #8
0
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));
    }

}