[gimp] Bug 756389 - Color-managing grayscale images
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 756389 - Color-managing grayscale images
- Date: Sun, 13 Dec 2015 22:38:24 +0000 (UTC)
commit 11e8cacf7e185398e2517784961f6642e5ff65de
Author: Michael Natterer <mitch gimp org>
Date: Sun Dec 13 23:36:31 2015 +0100
Bug 756389 - Color-managing grayscale images
Support creating linear/sRGB-gamma variants of gray profiles and
rename gimp_color_profile_new_linear_rgb_from_color_profile() to
gimp_color_profile_new_linear_gamma_from_color_profile() because it's
not RGB-specific any longer.
app/core/gimpimage-convert-precision.c | 2 +-
app/core/gimplayer.c | 2 +-
libgimpcolor/gimpcolor.def | 2 +-
libgimpcolor/gimpcolorprofile.c | 74 ++++++++++++++++++++------------
libgimpcolor/gimpcolorprofile.h | 4 +-
5 files changed, 51 insertions(+), 33 deletions(-)
---
diff --git a/app/core/gimpimage-convert-precision.c b/app/core/gimpimage-convert-precision.c
index fbd6f88..ab36fef 100644
--- a/app/core/gimpimage-convert-precision.c
+++ b/app/core/gimpimage-convert-precision.c
@@ -173,7 +173,7 @@ gimp_image_convert_precision (GimpImage *image,
if (gimp_babl_format_get_linear (new_format))
{
new_profile =
- gimp_color_profile_new_linear_rgb_from_color_profile (old_profile);
+ gimp_color_profile_new_linear_gamma_from_color_profile (old_profile);
}
else
{
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index a0f6c1a..1fce1ce 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -1136,7 +1136,7 @@ gimp_layer_convert_type (GimpDrawable *drawable,
if (gimp_babl_format_get_linear (new_format))
{
dest_profile =
- gimp_color_profile_new_linear_rgb_from_color_profile (src_profile);
+ gimp_color_profile_new_linear_gamma_from_color_profile (src_profile);
}
else
{
diff --git a/libgimpcolor/gimpcolor.def b/libgimpcolor/gimpcolor.def
index 1b1e384..6122cba 100644
--- a/libgimpcolor/gimpcolor.def
+++ b/libgimpcolor/gimpcolor.def
@@ -44,9 +44,9 @@ EXPORTS
gimp_color_profile_new_from_file
gimp_color_profile_new_from_icc_profile
gimp_color_profile_new_from_lcms_profile
+ gimp_color_profile_new_linear_gamma_from_color_profile
gimp_color_profile_new_linear_gray
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_gray
gimp_color_profile_new_srgb_gamma_from_color_profile
diff --git a/libgimpcolor/gimpcolorprofile.c b/libgimpcolor/gimpcolorprofile.c
index c60f7d5..785802d 100644
--- a/libgimpcolor/gimpcolorprofile.c
+++ b/libgimpcolor/gimpcolorprofile.c
@@ -788,10 +788,7 @@ gimp_color_profile_new_from_color_profile (GimpColorProfile *profile,
{
GimpColorProfile *new_profile;
cmsHPROFILE target_profile;
- GimpMatrix3 matrix;
- cmsCIEXYZ red;
- cmsCIEXYZ green;
- cmsCIEXYZ blue;
+ GimpMatrix3 matrix = { 0, };
cmsCIEXYZ *whitepoint;
cmsToneCurve *curve;
const gchar *model;
@@ -799,37 +796,27 @@ gimp_color_profile_new_from_color_profile (GimpColorProfile *profile,
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
- if (! gimp_color_profile_get_rgb_matrix_colorants (profile, &matrix))
- return 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);
- 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];
-
target_profile = cmsCreateProfilePlaceholder (0);
cmsSetProfileVersion (target_profile, 4.3);
cmsSetDeviceClass (target_profile, cmsSigDisplayClass);
- cmsSetColorSpace (target_profile, cmsSigRgbData);
cmsSetPCS (target_profile, cmsSigXYZData);
cmsWriteTag (target_profile, cmsSigMediaWhitePointTag, whitepoint);
- cmsWriteTag (target_profile, cmsSigRedColorantTag, &red);
- cmsWriteTag (target_profile, cmsSigGreenColorantTag, &green);
- cmsWriteTag (target_profile, cmsSigBlueColorantTag, &blue);
-
if (linear)
{
/* linear light */
@@ -850,9 +837,40 @@ gimp_color_profile_new_from_color_profile (GimpColorProfile *profile,
"sRGB gamma variant generated by GIMP");
}
- cmsWriteTag (target_profile, cmsSigRedTRCTag, curve);
- cmsWriteTag (target_profile, cmsSigGreenTRCTag, curve);
- cmsWriteTag (target_profile, cmsSigBlueTRCTag, curve);
+ 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);
@@ -906,7 +924,7 @@ gimp_color_profile_new_srgb_gamma_from_color_profile (GimpColorProfile *profile)
}
/**
- * gimp_color_profile_new_linear_rgb_from_color_profile:
+ * gimp_color_profile_new_linear_gamma_from_color_profile:
* @profile: a #GimpColorProfile
*
* This function creates a new RGB #GimpColorProfile with a linear TRC
@@ -918,7 +936,7 @@ gimp_color_profile_new_srgb_gamma_from_color_profile (GimpColorProfile *profile)
* Since: 2.10
**/
GimpColorProfile *
-gimp_color_profile_new_linear_rgb_from_color_profile (GimpColorProfile *profile)
+gimp_color_profile_new_linear_gamma_from_color_profile (GimpColorProfile *profile)
{
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
diff --git a/libgimpcolor/gimpcolorprofile.h b/libgimpcolor/gimpcolorprofile.h
index 34ebea4..e9767a6 100644
--- a/libgimpcolor/gimpcolorprofile.h
+++ b/libgimpcolor/gimpcolorprofile.h
@@ -72,9 +72,9 @@ GimpColorProfile * gimp_color_profile_new_srgb_gray (void);
GimpColorProfile * gimp_color_profile_new_linear_gray (void);
GimpColorProfile *
- gimp_color_profile_new_srgb_gamma_from_color_profile (GimpColorProfile *profile);
+ gimp_color_profile_new_srgb_gamma_from_color_profile (GimpColorProfile *profile);
GimpColorProfile *
- gimp_color_profile_new_linear_rgb_from_color_profile (GimpColorProfile *profile);
+ gimp_color_profile_new_linear_gamma_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]