/** * gimp_color_profile_get_label: * @profile: a #GimpColorProfile * * This function returns a newly allocated string containing * @profile's "title", a string that can be used to label the profile * in a user interface. * * Return value: the @profile's label. Free with g_free(). * * Since: 2.10 **/ gchar * gimp_color_profile_get_label (GimpColorProfile profile) { gchar *label; g_return_val_if_fail (profile != NULL, NULL); label = gimp_color_profile_get_description (profile); if (label && ! strlen (label)) { g_free (label); label = NULL; } if (! label) label = gimp_color_profile_get_model (profile); if (label && ! strlen (label)) { g_free (label); label = NULL; } if (! label) label = g_strdup (_("(unnamed profile)")); return label; }
/** * gimp_color_profile_get_summary: * @profile: a #GimpColorProfile * * This function return a string containing a multi-line summary of * @profile's description, model, manufacturer and copyright, to be * used as detailled information about the profile in a user * interface. * * Return value: the @profile's summary. The returned value belongs to * @profile and must not be modified or freed. * * Since: 2.10 **/ const gchar * gimp_color_profile_get_summary (GimpColorProfile *profile) { g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL); if (! profile->priv->summary) { GString *string = g_string_new (NULL); const gchar *text; text = gimp_color_profile_get_description (profile); if (text) g_string_append (string, text); text = gimp_color_profile_get_model (profile); if (text) { if (string->len > 0) g_string_append (string, "\n"); g_string_append_printf (string, _("Model: %s"), text); } text = gimp_color_profile_get_manufacturer (profile); if (text) { if (string->len > 0) g_string_append (string, "\n"); g_string_append_printf (string, _("Manufacturer: %s"), text); } text = gimp_color_profile_get_copyright (profile); if (text) { if (string->len > 0) g_string_append (string, "\n"); g_string_append_printf (string, _("Copyright: %s"), text); } profile->priv->summary = g_string_free (string, FALSE); } return profile->priv->summary; }
/** * gimp_color_profile_get_summary: * @profile: a #GimpColorProfile * * This function return a newly allocated string containing a * multi-line summary of @profile's description, model, manufacturer * and copyright, to be used as detailled information about the * prpfile in a user interface. * * Return value: the @profile's summary. Free with g_free(). * * Since: 2.10 **/ gchar * gimp_color_profile_get_summary (GimpColorProfile profile) { GString *string; gchar *text; g_return_val_if_fail (profile != NULL, NULL); string = g_string_new (NULL); text = gimp_color_profile_get_description (profile); if (text) { g_string_append (string, text); g_free (text); } text = gimp_color_profile_get_model (profile); if (text) { if (string->len > 0) g_string_append (string, "\n"); g_string_append (string, text); } text = gimp_color_profile_get_manufacturer (profile); if (text) { if (string->len > 0) g_string_append (string, "\n"); g_string_append (string, text); } text = gimp_color_profile_get_copyright (profile); if (text) { if (string->len > 0) g_string_append (string, "\n"); g_string_append (string, text); } return g_string_free (string, FALSE); }
/** * gimp_color_profile_get_label: * @profile: a #GimpColorProfile * * This function returns a string containing @profile's "title", a * string that can be used to label the profile in a user interface. * * Unlike gimp_color_profile_get_description(), this function always * returns a string (as a fallback, it returns "(unnamed profile)". * * Return value: the @profile's label. The returned value belongs to * @profile and must not be modified or freed. * * Since: 2.10 **/ const gchar * gimp_color_profile_get_label (GimpColorProfile *profile) { g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL); if (! profile->priv->label) { const gchar *label = gimp_color_profile_get_description (profile); if (! label || ! strlen (label)) label = _("(unnamed profile)"); profile->priv->label = g_strdup (label); } return profile->priv->label; }
static GimpColorProfile * gimp_color_profile_new_from_color_profile (GimpColorProfile *profile, gboolean linear) { GimpColorProfile *new_profile; cmsHPROFILE target_profile; GimpMatrix3 matrix = { 0, }; cmsCIEXYZ *whitepoint; cmsToneCurve *curve; const gchar *model; gchar *new_model; g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL); if (gimp_color_profile_is_rgb (profile)) { if (! gimp_color_profile_get_rgb_matrix_colorants (profile, &matrix)) return NULL; } else if (! gimp_color_profile_is_gray (profile)) { return NULL; } whitepoint = cmsReadTag (profile->priv->lcms_profile, cmsSigMediaWhitePointTag); target_profile = cmsCreateProfilePlaceholder (0); cmsSetProfileVersion (target_profile, 4.3); cmsSetDeviceClass (target_profile, cmsSigDisplayClass); cmsSetPCS (target_profile, cmsSigXYZData); cmsWriteTag (target_profile, cmsSigMediaWhitePointTag, whitepoint); if (linear) { /* linear light */ curve = cmsBuildGamma (NULL, 1.00); gimp_color_profile_set_tag (target_profile, cmsSigProfileDescriptionTag, "linear TRC variant generated by GIMP"); } else { cmsFloat64Number srgb_parameters[5] = { 2.4, 1.0 / 1.055, 0.055 / 1.055, 1.0 / 12.92, 0.04045 }; /* sRGB curve */ curve = cmsBuildParametricToneCurve (NULL, 4, srgb_parameters); gimp_color_profile_set_tag (target_profile, cmsSigProfileDescriptionTag, "sRGB TRC variant generated by GIMP"); } if (gimp_color_profile_is_rgb (profile)) { cmsCIEXYZ red; cmsCIEXYZ green; cmsCIEXYZ blue; cmsSetColorSpace (target_profile, cmsSigRgbData); red.X = matrix.coeff[0][0]; red.Y = matrix.coeff[0][1]; red.Z = matrix.coeff[0][2]; green.X = matrix.coeff[1][0]; green.Y = matrix.coeff[1][1]; green.Z = matrix.coeff[1][2]; blue.X = matrix.coeff[2][0]; blue.Y = matrix.coeff[2][1]; blue.Z = matrix.coeff[2][2]; cmsWriteTag (target_profile, cmsSigRedColorantTag, &red); cmsWriteTag (target_profile, cmsSigGreenColorantTag, &green); cmsWriteTag (target_profile, cmsSigBlueColorantTag, &blue); cmsWriteTag (target_profile, cmsSigRedTRCTag, curve); cmsWriteTag (target_profile, cmsSigGreenTRCTag, curve); cmsWriteTag (target_profile, cmsSigBlueTRCTag, curve); } else { cmsSetColorSpace (target_profile, cmsSigGrayData); cmsWriteTag (target_profile, cmsSigGrayTRCTag, curve); } cmsFreeToneCurve (curve); model = gimp_color_profile_get_model (profile); if (model && g_str_has_prefix (model, "Generated from '")) { /* don't add multiple "Generated from 'foo'" */ new_model = g_strdup (model); } else { new_model = g_strdup_printf ("Generated from '%s'", gimp_color_profile_get_description (profile)); } gimp_color_profile_set_tag (target_profile, cmsSigDeviceMfgDescTag, "GIMP"); gimp_color_profile_set_tag (target_profile, cmsSigDeviceModelDescTag, new_model); gimp_color_profile_set_tag (target_profile, cmsSigCopyrightTag, "Public Domain"); g_free (new_model); new_profile = gimp_color_profile_new_from_lcms_profile (target_profile, NULL); cmsCloseProfile (target_profile); return new_profile; }