[gimp] libgimpcolor: add API to create profile variants with linear/sRGB gamma
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimpcolor: add API to create profile variants with linear/sRGB gamma
- Date: Tue, 20 Oct 2015 18:13:54 +0000 (UTC)
commit 6eb9f9d4aab93909bfafcc21f82719b4f366927b
Author: Michael Natterer <mitch gimp org>
Date: Tue Oct 20 20:12:18 2015 +0200
libgimpcolor: add API to create profile variants with linear/sRGB gamma
and the original profile's RGB chromacities and whitepoint.
libgimpcolor/gimpcolor.def | 2 +
libgimpcolor/gimpcolorprofile.c | 79 +++++++++++++++++++++++++++++++++------
libgimpcolor/gimpcolorprofile.h | 5 ++
3 files changed, 74 insertions(+), 12 deletions(-)
---
diff --git a/libgimpcolor/gimpcolor.def b/libgimpcolor/gimpcolor.def
index 7819e61..897575a 100644
--- a/libgimpcolor/gimpcolor.def
+++ b/libgimpcolor/gimpcolor.def
@@ -43,7 +43,9 @@ EXPORTS
gimp_color_profile_new_from_icc_profile
gimp_color_profile_new_from_lcms_profile
gimp_color_profile_new_linear_rgb
+ gimp_color_profile_new_linear_rgb_from_color_profile
gimp_color_profile_new_srgb
+ gimp_color_profile_new_srgb_gamma_from_color_profile
gimp_hsl_get_type
gimp_hsl_set
gimp_hsl_set_alpha
diff --git a/libgimpcolor/gimpcolorprofile.c b/libgimpcolor/gimpcolorprofile.c
index cbd44f2..819c43b 100644
--- a/libgimpcolor/gimpcolorprofile.c
+++ b/libgimpcolor/gimpcolorprofile.c
@@ -704,13 +704,9 @@ gimp_color_profile_get_rgb_matrix_colorants (GimpColorProfile *profile,
}
static GimpColorProfile *
-gimp_color_profile_new_from_profile (GimpColorProfile *profile,
- gboolean linear)
+gimp_color_profile_new_from_color_profile (GimpColorProfile *profile,
+ gboolean linear)
{
- /* Make the target RGB working space. Until the ICC allows other
- * illuminants, and corresponding LCMS code has been added, use the
- * D50 color space reference white and illuminant.
- */
GimpColorProfile *new_profile;
cmsHPROFILE target_profile;
GimpMatrix3 matrix;
@@ -719,6 +715,8 @@ gimp_color_profile_new_from_profile (GimpColorProfile *profile,
cmsCIEXYZ blue;
cmsCIEXYZ *whitepoint;
cmsToneCurve *curve;
+ const gchar *model;
+ gchar *new_model;
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
@@ -758,8 +756,8 @@ gimp_color_profile_new_from_profile (GimpColorProfile *profile,
/* linear light */
curve = cmsBuildGamma (NULL, 1.00);
- gimp_color_profile_set_tag (profile, cmsSigProfileDescriptionTag,
- "GIMP generated with linear gamma TRC");
+ gimp_color_profile_set_tag (target_profile, cmsSigProfileDescriptionTag,
+ "linear variant generated by GIMP");
}
else
{
@@ -769,8 +767,8 @@ gimp_color_profile_new_from_profile (GimpColorProfile *profile,
/* sRGB curve */
curve = cmsBuildParametricToneCurve (NULL, 4, srgb_parameters);
- gimp_color_profile_set_tag (profile, cmsSigProfileDescriptionTag,
- "GIMP generated with sRGB gamma TRC");
+ gimp_color_profile_set_tag (target_profile, cmsSigProfileDescriptionTag,
+ "sRGB gamma variant generated by GIMP");
}
cmsWriteTag (target_profile, cmsSigRedTRCTag, curve);
@@ -779,11 +777,28 @@ gimp_color_profile_new_from_profile (GimpColorProfile *profile,
cmsFreeToneCurve (curve);
- gimp_color_profile_set_tag (profile, cmsSigDeviceMfgDescTag,
+ 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 (profile, cmsSigCopyrightTag,
+ 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);
@@ -791,6 +806,46 @@ gimp_color_profile_new_from_profile (GimpColorProfile *profile,
return new_profile;
}
+/**
+ * gimp_color_profile_new_srgb_gamma_from_color_profile:
+ * @profile: a #GimpColorProfile
+ *
+ * This function creates a new RGB #GimpColorProfile with a sRGB gamma
+ * TRC and @profile's RGB chromacities and whitepoint.
+ *
+ * Return value: the new #GimpColorProfile, or %NULL if @profile is not
+ * an RGB profile or not matrix-based.
+ *
+ * Since: 2.10
+ **/
+GimpColorProfile *
+gimp_color_profile_new_srgb_gamma_from_color_profile (GimpColorProfile *profile)
+{
+ g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
+
+ return gimp_color_profile_new_from_color_profile (profile, FALSE);
+}
+
+/**
+ * gimp_color_profile_new_linear_rgb_from_color_profile:
+ * @profile: a #GimpColorProfile
+ *
+ * This function creates a new RGB #GimpColorProfile with a linear TRC
+ * and @profile's RGB chromacities and whitepoint.
+ *
+ * Return value: the new #GimpColorProfile, or %NULL if @profile is not
+ * an RGB profile or not matrix-based.
+ *
+ * Since: 2.10
+ **/
+GimpColorProfile *
+gimp_color_profile_new_linear_rgb_from_color_profile (GimpColorProfile *profile)
+{
+ g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
+
+ return gimp_color_profile_new_from_color_profile (profile, TRUE);
+}
+
static cmsHPROFILE *
gimp_color_profile_new_srgb_internal (void)
{
diff --git a/libgimpcolor/gimpcolorprofile.h b/libgimpcolor/gimpcolorprofile.h
index 04b123a..3c290d7 100644
--- a/libgimpcolor/gimpcolorprofile.h
+++ b/libgimpcolor/gimpcolorprofile.h
@@ -69,6 +69,11 @@ GimpColorProfile * gimp_color_profile_new_linear_rgb (void);
GimpColorProfile * gimp_color_profile_new_adobe_rgb (void);
+GimpColorProfile *
+ gimp_color_profile_new_srgb_gamma_from_color_profile (GimpColorProfile *profile);
+GimpColorProfile *
+ gimp_color_profile_new_linear_rgb_from_color_profile (GimpColorProfile *profile);
+
GimpColorProfile * gimp_color_profile_new_from_file (GFile *file,
GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]