Commit 4780471c authored by Michael Natterer's avatar Michael Natterer 😴

libgimpcolor: add gimp_color_profile_is_gray()

and improve gimp_color_profile_is_linear() to return TRUE for linear
gray matrix profiles.
parent 8bdcc2f5
......@@ -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
......
......@@ -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,
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment