cmsHPROFILE dt_colorspaces_create_xyz_profile(void) { cmsHPROFILE hXYZ = cmsCreateXYZProfile(); // revert some settings which prevent us from using XYZ as output profile: cmsSetDeviceClass(hXYZ, cmsSigDisplayClass); cmsSetColorSpace(hXYZ, cmsSigRgbData); cmsSetPCS(hXYZ, cmsSigXYZData); cmsSetHeaderRenderingIntent(hXYZ, INTENT_PERCEPTUAL); if (hXYZ == NULL) return NULL; cmsSetProfileVersion(hXYZ, 2.1); cmsMLU *mlu0 = cmsMLUalloc(NULL, 1); cmsMLUsetASCII(mlu0, "en", "US", "(dt internal)"); cmsMLU *mlu1 = cmsMLUalloc(NULL, 1); cmsMLUsetASCII(mlu1, "en", "US", "linear XYZ"); cmsMLU *mlu2 = cmsMLUalloc(NULL, 1); cmsMLUsetASCII(mlu2, "en", "US", "Darktable linear XYZ"); cmsWriteTag(hXYZ, cmsSigDeviceMfgDescTag, mlu0); cmsWriteTag(hXYZ, cmsSigDeviceModelDescTag, mlu1); // this will only be displayed when the embedded profile is read by for example GIMP cmsWriteTag(hXYZ, cmsSigProfileDescriptionTag, mlu2); cmsMLUfree(mlu0); cmsMLUfree(mlu1); cmsMLUfree(mlu2); return hXYZ; }
static cmsHPROFILE OpenProfile(const char* File) { if (!File) return cmsCreate_sRGBProfile(); if (stricmp(File, "*sRGB") == 0) return cmsCreate_sRGBProfile(NULL); if (stricmp(File, "*Lab") == 0) return cmsCreateLabProfile(NULL); if (stricmp(File, "*LabD65") == 0) { cmsCIExyY D65xyY; cmsWhitePointFromTemp(6504, &D65xyY); return cmsCreateLabProfile(&D65xyY); } if (stricmp(File, "*XYZ") == 0) return cmsCreateXYZProfile(); if (stricmp(File, "*Gray22") == 0) { LPGAMMATABLE Gamma = cmsBuildGamma(256, 2.2); cmsHPROFILE hProfile = cmsCreateGrayProfile(cmsD50_xyY(), Gamma); cmsFreeGamma(Gamma); return hProfile; } return cmsOpenProfileFromFile(File, "r"); }
static KoCIExyY RGB2xyY(cmsHPROFILE RGBProfile, qreal red, qreal green, qreal blue) { cmsHPROFILE XYZProfile = cmsCreateXYZProfile(); const cmsUInt32Number inputFormat = TYPE_RGB_DBL; const cmsUInt32Number outputFormat = TYPE_XYZ_DBL; const cmsUInt32Number transformFlags = cmsFLAGS_LOWRESPRECALC; cmsHTRANSFORM transform = cmsCreateTransform(RGBProfile, inputFormat, XYZProfile, outputFormat, INTENT_ABSOLUTE_COLORIMETRIC, transformFlags); struct XYZPixel { qreal X; qreal Y; qreal Z; }; struct RGBPixel { qreal red; qreal green; qreal blue; }; XYZPixel xyzPixel; RGBPixel rgbPixel; rgbPixel.red = red; rgbPixel.green = green; rgbPixel.blue = blue; const unsigned int numPixelsToTransform = 1; cmsDoTransform(transform, &rgbPixel, &xyzPixel, numPixelsToTransform); cmsCIEXYZ xyzPixelXYZ; xyzPixelXYZ.X = xyzPixel.X; xyzPixelXYZ.Y = xyzPixel.Y; xyzPixelXYZ.Z = xyzPixel.Z; cmsCIExyY xyzPixelxyY; cmsXYZ2xyY(&xyzPixelxyY, &xyzPixelXYZ); cmsDeleteTransform(transform); cmsCloseProfile(XYZProfile); KoCIExyY res; lcmsToPigmentViceVersaStructureCopy(res, xyzPixelxyY); return res; }
static cmsHPROFILE OpenProfile(const char* File) { cmsHPROFILE h; if (!File) return cmsCreate_sRGBProfile(); if (stricmp(File, "*Lab") == 0) return cmsCreateLabProfile(NULL); if (stricmp(File, "*XYZ") == 0) return cmsCreateXYZProfile(); if (stricmp(File, "*srgb") == 0) return cmsCreate_sRGBProfile(); if (stricmp(File, "*Gray22") == 0) { LPGAMMATABLE Gamma = cmsBuildGamma(256, 2.2); cmsHPROFILE hProfile = cmsCreateGrayProfile(cmsD50_xyY(), Gamma); cmsFreeGamma(Gamma); return hProfile; } if (stricmp(File, "*Lin2222") == 0) { LPGAMMATABLE Gamma = cmsBuildGamma(256, 2.2); LPGAMMATABLE Gamma4[4]; cmsHPROFILE hProfile; Gamma4[0] = Gamma4[1] = Gamma4[2] = Gamma4[3] = Gamma; hProfile = cmsCreateLinearizationDeviceLink(icSigCmykData, Gamma4); cmsFreeGamma(Gamma); return hProfile; } h = cmsOpenProfileFromFile(File, "r"); if (cmsGetDeviceClass(h) == icSigNamedColorClass) FatalError("ERROR: Cannot make devicelink of named color profiles!"); return h; }
static PyObject * createProfile(PyObject *self, PyObject *args) { char *sColorSpace; cmsHPROFILE hProfile; int iColorTemp = 0; LPcmsCIExyY whitePoint = NULL; LCMSBOOL result; if (!PyArg_ParseTuple(args, "s|i:createProfile", &sColorSpace, &iColorTemp)) return NULL; cmsErrorAction(LCMS_ERROR_IGNORE); if (strcmp(sColorSpace, "LAB") == 0) { if (iColorTemp > 0) { result = cmsWhitePointFromTemp(iColorTemp, whitePoint); if (!result) { PyErr_SetString(PyExc_ValueError,"ERROR: Could not calculate "\ "white point from color temperature provided, must be "\ "integer in degrees Kelvin"); return NULL; } hProfile = cmsCreateLabProfile(whitePoint); } else hProfile = cmsCreateLabProfile(NULL); } else if (strcmp(sColorSpace, "XYZ") == 0) hProfile = cmsCreateXYZProfile(); else if (strcmp(sColorSpace, "sRGB") == 0) hProfile = cmsCreate_sRGBProfile(); else hProfile = NULL; if (!hProfile) { PyErr_SetString(PyExc_ValueError, "failed to create requested color space"); return NULL; } return cms_profile_new(hProfile); }
static PyObject * createProfile(PyObject *self, PyObject *args) { char *sColorSpace; cmsHPROFILE hProfile; cmsFloat64Number dColorTemp = 0.0; cmsCIExyY whitePoint; cmsBool result; if (!PyArg_ParseTuple(args, "s|d:createProfile", &sColorSpace, &dColorTemp)) return NULL; if (strcmp(sColorSpace, "LAB") == 0) { if (dColorTemp > 0.0) { result = cmsWhitePointFromTemp(&whitePoint, dColorTemp); if (!result) { PyErr_SetString(PyExc_ValueError, "ERROR: Could not calculate white point from color temperature provided, must be float in degrees Kelvin"); return NULL; } hProfile = cmsCreateLab2Profile(&whitePoint); } else { hProfile = cmsCreateLab2Profile(NULL); } } else if (strcmp(sColorSpace, "XYZ") == 0) { hProfile = cmsCreateXYZProfile(); } else if (strcmp(sColorSpace, "sRGB") == 0) { hProfile = cmsCreate_sRGBProfile(); } else { hProfile = NULL; } if (!hProfile) { PyErr_SetString(PyExc_ValueError, "failed to create requested color space"); return NULL; } return cms_profile_new(hProfile); }
static cmsToneCurve* ExtractGray2Y(cmsContext ContextID, cmsHPROFILE hProfile, int Intent) { cmsToneCurve* Out = cmsBuildTabulatedToneCurve16(ContextID, 256, NULL); cmsHPROFILE hXYZ = cmsCreateXYZProfile(); cmsHTRANSFORM xform = cmsCreateTransformTHR(ContextID, hProfile, TYPE_GRAY_8, hXYZ, TYPE_XYZ_DBL, Intent, cmsFLAGS_NOOPTIMIZE); int i; for (i=0; i < 256; i++) { cmsUInt8Number Gray = (cmsUInt8Number) i; cmsCIEXYZ XYZ; cmsDoTransform(xform, &Gray, &XYZ, 1); Out ->Table16[i] =_cmsQuickSaturateWord(XYZ.Y * 65535.0); } cmsDeleteTransform(xform); cmsCloseProfile(hXYZ); return Out; }
cmsBool GetProfileRGBPrimaries(cmsHPROFILE hProfile, cmsCIEXYZTRIPLE* const result, cmsUInt32Number intent) { cmsHPROFILE hXYZ; cmsHTRANSFORM hTransform; cmsFloat64Number rgb[3][3] = {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}}; hXYZ = cmsCreateXYZProfile(); if (hXYZ == NULL) return FALSE; hTransform = cmsCreateTransform(hProfile, TYPE_RGB_DBL, hXYZ, TYPE_XYZ_DBL, intent, cmsFLAGS_NOCACHE | cmsFLAGS_NOOPTIMIZE); cmsCloseProfile(hXYZ); if (hTransform == NULL) return FALSE; cmsDoTransform(hTransform, rgb, result, 3); cmsDeleteTransform(hTransform); return TRUE; }
static cmsHTRANSFORM cd_sensor_get_fake_transform (CdSensorDummyPrivate *priv) { cmsHTRANSFORM transform; cmsHPROFILE profile_srgb; cmsHPROFILE profile_xyz; profile_srgb = cmsCreate_sRGBProfile (); profile_xyz = cmsCreateXYZProfile (); transform = cmsCreateTransform (profile_srgb, TYPE_RGB_DBL, profile_xyz, TYPE_XYZ_DBL, INTENT_RELATIVE_COLORIMETRIC, cmsFLAGS_NOOPTIMIZE); if (transform == NULL) { g_warning ("failed to setup RGB -> XYZ transform"); goto out; } out: if (profile_srgb != NULL) cmsCloseProfile (profile_srgb); if (profile_xyz != NULL) cmsCloseProfile (profile_xyz); return transform; }
// Creates all needed color transforms static cmsBool OpenTransforms(void) { cmsHPROFILE hInput, hOutput, hProof; cmsUInt32Number dwIn, dwOut, dwFlags; cmsNAMEDCOLORLIST* List; int i; // We don't need cache dwFlags = cmsFLAGS_NOCACHE; if (lIsDeviceLink) { hInput = OpenStockProfile(0, cInProf); if (hInput == NULL) return FALSE; hOutput = NULL; hProof = NULL; if (cmsGetDeviceClass(hInput) == cmsSigNamedColorClass) { OutputColorSpace = cmsGetColorSpace(hInput); InputColorSpace = cmsGetPCS(hInput); } else { InputColorSpace = cmsGetColorSpace(hInput); OutputColorSpace = cmsGetPCS(hInput); } // Read colorant tables if present if (cmsIsTag(hInput, cmsSigColorantTableTag)) { List = cmsReadTag(hInput, cmsSigColorantTableTag); InputColorant = cmsDupNamedColorList(List); InputRange = 1; } else InputColorant = ComponentNames(InputColorSpace, TRUE); if (cmsIsTag(hInput, cmsSigColorantTableOutTag)){ List = cmsReadTag(hInput, cmsSigColorantTableOutTag); OutputColorant = cmsDupNamedColorList(List); OutputRange = 1; } else OutputColorant = ComponentNames(OutputColorSpace, FALSE); } else { hInput = OpenStockProfile(0, cInProf); if (hInput == NULL) return FALSE; hOutput = OpenStockProfile(0, cOutProf); if (hOutput == NULL) return FALSE; hProof = NULL; if (cmsGetDeviceClass(hInput) == cmsSigLinkClass || cmsGetDeviceClass(hOutput) == cmsSigLinkClass) FatalError("Use %cl flag for devicelink profiles!\n", SW); InputColorSpace = cmsGetColorSpace(hInput); OutputColorSpace = cmsGetColorSpace(hOutput); // Read colorant tables if present if (cmsIsTag(hInput, cmsSigColorantTableTag)) { List = cmsReadTag(hInput, cmsSigColorantTableTag); InputColorant = cmsDupNamedColorList(List); if (cmsNamedColorCount(InputColorant) <= 3) SetRange(255, TRUE); else SetRange(1, TRUE); // Inks are already divided by 100 in the formatter } else InputColorant = ComponentNames(InputColorSpace, TRUE); if (cmsIsTag(hOutput, cmsSigColorantTableTag)){ List = cmsReadTag(hOutput, cmsSigColorantTableTag); OutputColorant = cmsDupNamedColorList(List); if (cmsNamedColorCount(OutputColorant) <= 3) SetRange(255, FALSE); else SetRange(1, FALSE); // Inks are already divided by 100 in the formatter } else OutputColorant = ComponentNames(OutputColorSpace, FALSE); if (cProofing != NULL) { hProof = OpenStockProfile(0, cProofing); if (hProof == NULL) return FALSE; dwFlags |= cmsFLAGS_SOFTPROOFING; } } // Print information on profiles if (Verbose > 2) { printf("Profile:\n"); PrintProfileInformation(hInput); if (hOutput) { printf("Output profile:\n"); PrintProfileInformation(hOutput); } if (hProof != NULL) { printf("Proofing profile:\n"); PrintProfileInformation(hProof); } } // Input is always in floating point dwIn = cmsFormatterForColorspaceOfProfile(hInput, 0, TRUE); if (lIsDeviceLink) { dwOut = cmsFormatterForPCSOfProfile(hInput, lIsFloat ? 0 : 2, lIsFloat); } else { // 16 bits or floating point (only on output) dwOut = cmsFormatterForColorspaceOfProfile(hOutput, lIsFloat ? 0 : 2, lIsFloat); } // For named color, there is a specialized formatter if (cmsGetDeviceClass(hInput) == cmsSigNamedColorClass) { dwIn = TYPE_NAMED_COLOR_INDEX; InputNamedColor = TRUE; } // Precision mode switch (PrecalcMode) { case 0: dwFlags |= cmsFLAGS_NOOPTIMIZE; 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) { cmsUInt16Number Alarm[cmsMAXCHANNELS]; if (hProof == NULL) FatalError("I need proofing profile -p for gamut checking!"); for (i=0; i < cmsMAXCHANNELS; i++) Alarm[i] = 0xFFFF; cmsSetAlarmCodes(Alarm); dwFlags |= cmsFLAGS_GAMUTCHECK; } // The main transform hTrans = cmsCreateProofingTransform(hInput, dwIn, hOutput, dwOut, hProof, Intent, ProofingIntent, dwFlags); if (hProof) cmsCloseProfile(hProof); if (hTrans == NULL) return FALSE; // PCS Dump if requested hTransXYZ = NULL; hTransLab = NULL; if (hOutput && Verbose > 1) { cmsHPROFILE hXYZ = cmsCreateXYZProfile(); cmsHPROFILE hLab = cmsCreateLab4Profile(NULL); hTransXYZ = cmsCreateTransform(hInput, dwIn, hXYZ, lIsFloat ? TYPE_XYZ_DBL : TYPE_XYZ_16, Intent, cmsFLAGS_NOCACHE); if (hTransXYZ == NULL) return FALSE; hTransLab = cmsCreateTransform(hInput, dwIn, hLab, lIsFloat? TYPE_Lab_DBL : TYPE_Lab_16, Intent, cmsFLAGS_NOCACHE); if (hTransLab == NULL) return FALSE; cmsCloseProfile(hXYZ); cmsCloseProfile(hLab); } if (hInput) cmsCloseProfile(hInput); if (hOutput) cmsCloseProfile(hOutput); return TRUE; }
cmsHPROFILE dkCmsCreateXYZProfile() { return cmsCreateXYZProfile(); }
/** * mcm_picker_refresh_results: **/ static void mcm_picker_refresh_results (void) { McmXyz *xyz = NULL; GtkImage *image; GtkLabel *label; GdkPixbuf *pixbuf = NULL; gdouble color_xyz[3]; guint8 color_rgb[3]; gdouble color_lab[3]; gdouble color_error[3]; gchar *text_xyz = NULL; gchar *text_lab = NULL; gchar *text_rgb = NULL; gchar *text_error = NULL; cmsHPROFILE profile_xyz; cmsHPROFILE profile_rgb; cmsHPROFILE profile_lab; cmsHTRANSFORM transform_rgb; cmsHTRANSFORM transform_lab; cmsHTRANSFORM transform_error; /* nothing set yet */ if (profile_filename == NULL) goto out; /* get new value */ g_object_get (calibrate, "xyz", &xyz, NULL); /* create new pixbuf of the right size */ pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 200, 200); /* get values */ g_object_get (xyz, "cie-x", &color_xyz[0], "cie-y", &color_xyz[1], "cie-z", &color_xyz[2], NULL); /* lcms scales these for some reason */ color_xyz[0] /= 100.0f; color_xyz[1] /= 100.0f; color_xyz[2] /= 100.0f; /* get profiles */ profile_xyz = cmsCreateXYZProfile (); profile_rgb = cmsOpenProfileFromFile (profile_filename, "r"); profile_lab = cmsCreateLab4Profile (cmsD50_xyY ()); /* create transforms */ transform_rgb = cmsCreateTransform (profile_xyz, TYPE_XYZ_DBL, profile_rgb, TYPE_RGB_8, INTENT_PERCEPTUAL, 0); if (transform_rgb == NULL) goto out; transform_lab = cmsCreateTransform (profile_xyz, TYPE_XYZ_DBL, profile_lab, TYPE_Lab_DBL, INTENT_PERCEPTUAL, 0); if (transform_lab == NULL) goto out; transform_error = cmsCreateTransform (profile_rgb, TYPE_RGB_8, profile_xyz, TYPE_XYZ_DBL, INTENT_PERCEPTUAL, 0); if (transform_error == NULL) goto out; cmsDoTransform (transform_rgb, color_xyz, color_rgb, 1); cmsDoTransform (transform_lab, color_xyz, color_lab, 1); cmsDoTransform (transform_error, color_rgb, color_error, 1); /* destroy lcms state */ cmsDeleteTransform (transform_rgb); cmsDeleteTransform (transform_lab); cmsDeleteTransform (transform_error); cmsCloseProfile (profile_xyz); cmsCloseProfile (profile_rgb); cmsCloseProfile (profile_lab); /* set XYZ */ label = GTK_LABEL (gtk_builder_get_object (builder, "label_xyz")); text_xyz = g_strdup_printf ("%.3f, %.3f, %.3f", color_xyz[0], color_xyz[1], color_xyz[2]); gtk_label_set_label (label, text_xyz); /* set LAB */ label = GTK_LABEL (gtk_builder_get_object (builder, "label_lab")); text_lab = g_strdup_printf ("%.3f, %.3f, %.3f", color_lab[0], color_lab[1], color_lab[2]); gtk_label_set_label (label, text_lab); /* set RGB */ label = GTK_LABEL (gtk_builder_get_object (builder, "label_rgb")); text_rgb = g_strdup_printf ("%i, %i, %i (#%02X%02X%02X)", color_rgb[0], color_rgb[1], color_rgb[2], color_rgb[0], color_rgb[1], color_rgb[2]); gtk_label_set_label (label, text_rgb); mcm_picker_set_pixbuf_color (pixbuf, color_rgb[0], color_rgb[1], color_rgb[2]); /* set error */ label = GTK_LABEL (gtk_builder_get_object (builder, "label_error")); text_error = g_strdup_printf ("%.1f%%, %.1f%%, %.1f%%", ABS ((color_error[0] - color_xyz[0]) / color_xyz[0] * 100), ABS ((color_error[1] - color_xyz[1]) / color_xyz[1] * 100), ABS ((color_error[2] - color_xyz[2]) / color_xyz[2] * 100)); gtk_label_set_label (label, text_error); /* set image */ image = GTK_IMAGE (gtk_builder_get_object (builder, "image_preview")); gtk_image_set_from_pixbuf (image, pixbuf); out: g_free (text_xyz); g_free (text_lab); g_free (text_rgb); g_free (text_error); if (xyz != NULL) g_object_unref (xyz); if (pixbuf != NULL) g_object_unref (pixbuf); }
static void gcm_picker_refresh_results (GcmPickerPrivate *priv) { cmsCIExyY xyY; cmsHPROFILE profile_lab; cmsHPROFILE profile_rgb; cmsHPROFILE profile_xyz; cmsHTRANSFORM transform_error; cmsHTRANSFORM transform_lab; cmsHTRANSFORM transform_rgb; gboolean ret; CdColorLab color_lab; CdColorRGB8 color_rgb; CdColorXYZ color_error; CdColorXYZ color_xyz; gdouble temperature = 0.0f; GtkImage *image; GtkLabel *label; g_autoptr(GdkPixbuf) pixbuf = NULL; g_autofree gchar *text_ambient = NULL; g_autofree gchar *text_error = NULL; g_autofree gchar *text_lab = NULL; g_autofree gchar *text_rgb = NULL; g_autofree gchar *text_temperature = NULL; g_autofree gchar *text_whitepoint = NULL; g_autofree gchar *text_xyz = NULL; /* nothing set yet */ if (priv->profile_filename == NULL) return; /* copy as we're modifying the value */ cd_color_xyz_copy (&priv->last_sample, &color_xyz); /* create new pixbuf of the right size */ image = GTK_IMAGE (gtk_builder_get_object (priv->builder, "image_preview")); pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, gtk_widget_get_allocated_width (GTK_WIDGET (image)), gtk_widget_get_allocated_height (GTK_WIDGET (image))); /* lcms scales these for some reason */ color_xyz.X /= 100.0f; color_xyz.Y /= 100.0f; color_xyz.Z /= 100.0f; /* get profiles */ profile_xyz = cmsCreateXYZProfile (); profile_rgb = cmsOpenProfileFromFile (priv->profile_filename, "r"); profile_lab = cmsCreateLab4Profile (cmsD50_xyY ()); /* create transforms */ transform_rgb = cmsCreateTransform (profile_xyz, TYPE_XYZ_DBL, profile_rgb, TYPE_RGB_8, INTENT_PERCEPTUAL, 0); if (transform_rgb == NULL) return; transform_lab = cmsCreateTransform (profile_xyz, TYPE_XYZ_DBL, profile_lab, TYPE_Lab_DBL, INTENT_PERCEPTUAL, 0); if (transform_lab == NULL) return; transform_error = cmsCreateTransform (profile_rgb, TYPE_RGB_8, profile_xyz, TYPE_XYZ_DBL, INTENT_PERCEPTUAL, 0); if (transform_error == NULL) return; cmsDoTransform (transform_rgb, &color_xyz, &color_rgb, 1); cmsDoTransform (transform_lab, &color_xyz, &color_lab, 1); cmsDoTransform (transform_error, &color_rgb, &color_error, 1); /* destroy lcms state */ cmsDeleteTransform (transform_rgb); cmsDeleteTransform (transform_lab); cmsDeleteTransform (transform_error); cmsCloseProfile (profile_xyz); cmsCloseProfile (profile_rgb); cmsCloseProfile (profile_lab); /* set XYZ */ label = GTK_LABEL (gtk_builder_get_object (priv->builder, "label_xyz")); text_xyz = g_strdup_printf ("%.3f, %.3f, %.3f", priv->last_sample.X, priv->last_sample.Y, priv->last_sample.Z); gtk_label_set_label (label, text_xyz); /* set LAB */ label = GTK_LABEL (gtk_builder_get_object (priv->builder, "label_lab")); text_lab = g_strdup_printf ("%.3f, %.3f, %.3f", color_lab.L, color_lab.a, color_lab.b); gtk_label_set_label (label, text_lab); /* set whitepoint */ cmsXYZ2xyY (&xyY, (cmsCIEXYZ *)&priv->last_sample); label = GTK_LABEL (gtk_builder_get_object (priv->builder, "label_whitepoint")); text_whitepoint = g_strdup_printf ("%.3f,%.3f [%.3f]", xyY.x, xyY.y, xyY.Y); gtk_label_set_label (label, text_whitepoint); /* set temperature */ ret = cmsTempFromWhitePoint (&temperature, &xyY); if (ret) { /* round to nearest 10K */ temperature = (((guint) temperature) / 10) * 10; } label = GTK_LABEL (gtk_builder_get_object (priv->builder, "label_temperature")); text_temperature = g_strdup_printf ("%.0fK", temperature); gtk_label_set_label (label, text_temperature); /* set RGB */ label = GTK_LABEL (gtk_builder_get_object (priv->builder, "label_rgb")); text_rgb = g_strdup_printf ("%i, %i, %i (#%02X%02X%02X)", color_rgb.R, color_rgb.G, color_rgb.B, color_rgb.R, color_rgb.G, color_rgb.B); gtk_label_set_label (label, text_rgb); gcm_picker_set_pixbuf_color (pixbuf, color_rgb.R, color_rgb.G, color_rgb.B); /* set error */ label = GTK_LABEL (gtk_builder_get_object (priv->builder, "label_error")); if (color_xyz.X > 0.01f && color_xyz.Y > 0.01f && color_xyz.Z > 0.01f) { text_error = g_strdup_printf ("%.1f%%, %.1f%%, %.1f%%", ABS ((color_error.X - color_xyz.X) / color_xyz.X * 100), ABS ((color_error.Y - color_xyz.Y) / color_xyz.Y * 100), ABS ((color_error.Z - color_xyz.Z) / color_xyz.Z * 100)); gtk_label_set_label (label, text_error); } else { /* TRANSLATORS: this is when the error is invalid */ gtk_label_set_label (label, _("Unknown")); } /* set ambient */ label = GTK_LABEL (gtk_builder_get_object (priv->builder, "label_ambient")); if (priv->last_ambient < 0) { /* TRANSLATORS: this is when the ambient light level is unknown */ gtk_label_set_label (label, _("Unknown")); } else { text_ambient = g_strdup_printf ("%.1f Lux", priv->last_ambient); gtk_label_set_label (label, text_ambient); } /* set image */ gtk_image_set_from_pixbuf (image, pixbuf); }
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); } }