[gimp] libgimpcolor: add gimp_color_profile_is_gray()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimpcolor: add gimp_color_profile_is_gray()
- Date: Sun, 13 Dec 2015 13:35:26 +0000 (UTC)
commit 4780471c5f71f54f8cdf5d2f75059619019cba4a
Author: Michael Natterer <mitch gimp org>
Date: Sun Dec 13 14:33:51 2015 +0100
libgimpcolor: add gimp_color_profile_is_gray()
and improve gimp_color_profile_is_linear() to return TRUE for linear
gray matrix profiles.
libgimpcolor/gimpcolor.def | 1 +
libgimpcolor/gimpcolorprofile.c | 84 ++++++++++++++++++++++++++------------
libgimpcolor/gimpcolorprofile.h | 4 +-
3 files changed, 61 insertions(+), 28 deletions(-)
---
diff --git a/libgimpcolor/gimpcolor.def b/libgimpcolor/gimpcolor.def
index 70f3168..9f4dc8c 100644
--- a/libgimpcolor/gimpcolor.def
+++ b/libgimpcolor/gimpcolor.def
@@ -37,6 +37,7 @@ EXPORTS
gimp_color_profile_get_type
gimp_color_profile_is_cmyk
gimp_color_profile_is_equal
+ gimp_color_profile_is_gray
gimp_color_profile_is_linear
gimp_color_profile_is_rgb
gimp_color_profile_new_adobe_rgb
diff --git a/libgimpcolor/gimpcolorprofile.c b/libgimpcolor/gimpcolorprofile.c
index 3159497..fd8b4fe 100644
--- a/libgimpcolor/gimpcolorprofile.c
+++ b/libgimpcolor/gimpcolorprofile.c
@@ -634,6 +634,40 @@ gimp_color_profile_is_rgb (GimpColorProfile *profile)
return (cmsGetColorSpace (profile->priv->lcms_profile) == cmsSigRgbData);
}
+/**
+ * gimp_color_profile_is_gray:
+ * @profile: a #GimpColorProfile
+ *
+ * Return value: %TRUE if the profile's color space is grayscale, %FALSE
+ * otherwise.
+ *
+ * Since: 2.10
+ **/
+gboolean
+gimp_color_profile_is_gray (GimpColorProfile *profile)
+{
+ g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), FALSE);
+
+ return (cmsGetColorSpace (profile->priv->lcms_profile) == cmsSigGrayData);
+}
+
+/**
+ * gimp_color_profile_is_cmyk:
+ * @profile: a #GimpColorProfile
+ *
+ * Return value: %TRUE if the profile's color space is CMYK, %FALSE
+ * otherwise.
+ *
+ * Since: 2.10
+ **/
+gboolean
+gimp_color_profile_is_cmyk (GimpColorProfile *profile)
+{
+ g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), FALSE);
+
+ return (cmsGetColorSpace (profile->priv->lcms_profile) == cmsSigCmykData);
+}
+
/**
* gimp_color_profile_is_linear:
@@ -651,7 +685,7 @@ gimp_color_profile_is_rgb (GimpColorProfile *profile)
gboolean
gimp_color_profile_is_linear (GimpColorProfile *profile)
{
- cmsHPROFILE prof;
+ cmsHPROFILE prof;
cmsToneCurve *curve;
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), FALSE);
@@ -667,38 +701,34 @@ gimp_color_profile_is_linear (GimpColorProfile *profile)
if (cmsIsCLUT (prof, INTENT_PERCEPTUAL, LCMS_USED_AS_OUTPUT))
return FALSE;
- curve = cmsReadTag(prof, cmsSigRedTRCTag);
- if (curve == NULL || ! cmsIsToneCurveLinear (curve))
- return FALSE;
+ if (gimp_color_profile_is_rgb (profile))
+ {
+ curve = cmsReadTag(prof, cmsSigRedTRCTag);
+ if (curve == NULL || ! cmsIsToneCurveLinear (curve))
+ return FALSE;
- curve = cmsReadTag (prof, cmsSigGreenTRCTag);
- if (curve == NULL || ! cmsIsToneCurveLinear (curve))
- return FALSE;
+ curve = cmsReadTag (prof, cmsSigGreenTRCTag);
+ if (curve == NULL || ! cmsIsToneCurveLinear (curve))
+ return FALSE;
- curve = cmsReadTag (prof, cmsSigBlueTRCTag);
- if (curve == NULL || ! cmsIsToneCurveLinear (curve))
- return FALSE;
+ curve = cmsReadTag (prof, cmsSigBlueTRCTag);
+ if (curve == NULL || ! cmsIsToneCurveLinear (curve))
+ return FALSE;
+ }
+ else if (gimp_color_profile_is_gray (profile))
+ {
+ curve = cmsReadTag(prof, cmsSigGrayTRCTag);
+ if (curve == NULL || ! cmsIsToneCurveLinear (curve))
+ return FALSE;
+ }
+ else
+ {
+ return FALSE;
+ }
return TRUE;
}
-/**
- * gimp_color_profile_is_cmyk:
- * @profile: a #GimpColorProfile
- *
- * Return value: %TRUE if the profile's color space is CMYK, %FALSE
- * otherwise.
- *
- * Since: 2.10
- **/
-gboolean
-gimp_color_profile_is_cmyk (GimpColorProfile *profile)
-{
- g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), FALSE);
-
- return (cmsGetColorSpace (profile->priv->lcms_profile) == cmsSigCmykData);
-}
-
static void
gimp_color_profile_set_tag (cmsHPROFILE profile,
cmsTagSignature sig,
diff --git a/libgimpcolor/gimpcolorprofile.h b/libgimpcolor/gimpcolorprofile.h
index b184e7d..ec3b22d 100644
--- a/libgimpcolor/gimpcolorprofile.h
+++ b/libgimpcolor/gimpcolorprofile.h
@@ -99,9 +99,11 @@ gboolean gimp_color_profile_is_equal (GimpColorProfile *
GimpColorProfile *profile2);
gboolean gimp_color_profile_is_rgb (GimpColorProfile *profile);
-gboolean gimp_color_profile_is_linear (GimpColorProfile *profile);
+gboolean gimp_color_profile_is_gray (GimpColorProfile *profile);
gboolean gimp_color_profile_is_cmyk (GimpColorProfile *profile);
+gboolean gimp_color_profile_is_linear (GimpColorProfile *profile);
+
const Babl * gimp_color_profile_get_format (const Babl *format,
guint32 *lcms_format);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]