Commit 7d897a45 authored by Michael Natterer's avatar Michael Natterer 😴

libgimpcolor: add gimp_color_profile_get_space()

which returns the Babl space matching the profile.

(cherry picked from commit ac57af58)
parent 75837694
......@@ -35,6 +35,7 @@ EXPORTS
gimp_color_profile_get_lcms_profile
gimp_color_profile_get_manufacturer
gimp_color_profile_get_model
gimp_color_profile_get_space
gimp_color_profile_get_summary
gimp_color_profile_get_type
gimp_color_profile_is_cmyk
......
......@@ -1452,10 +1452,48 @@ gimp_color_profile_new_d50_gray_lab_trc (void)
return gimp_color_profile_new_from_icc_profile (data, length, NULL);
}
/**
* gimp_color_profile_get_space:
* @profile: a #GimpColorProfile
* @intent: a #GimpColorRenderingIntent
* @error: return location for #GError
*
* This function returns the #Babl space of @profile, for the
* specified @intent.
*
* Return value: the new #Babl space.
*
* Since: 2.10.6
**/
const Babl *
gimp_color_profile_get_space (GimpColorProfile *profile,
GimpColorRenderingIntent intent,
GError **error)
{
const Babl *space;
const gchar *babl_error = NULL;
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
space = babl_icc_make_space ((const gchar *) profile->priv->data,
profile->priv->length,
(BablIccIntent) intent,
&babl_error);
if (! space)
g_set_error (error, GIMP_COLOR_PROFILE_ERROR, 0,
"%s: %s",
gimp_color_profile_get_label (profile), babl_error);
return space;
}
/**
* gimp_color_profile_get_format:
* @profile: a #GimpColorProfile
* @format: a #Babl format
* @intent: a #GimpColorRenderingIntent
* @error: return location for #GError
*
* This function takes a #GimpColorProfile and a #Babl format and
......@@ -1472,25 +1510,16 @@ gimp_color_profile_get_format (GimpColorProfile *profile,
GimpColorRenderingIntent intent,
GError **error)
{
const Babl *space;
const gchar *babl_error = NULL;
const Babl *space;
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile), NULL);
g_return_val_if_fail (format != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
space = babl_icc_make_space ((const gchar *) profile->priv->data,
profile->priv->length,
(BablIccIntent)intent,
&babl_error);
space = gimp_color_profile_get_space (profile, intent, error);
if (! space)
{
g_set_error (error, GIMP_COLOR_PROFILE_ERROR, 0,
"%s: %s",
gimp_color_profile_get_label (profile), babl_error);
return NULL;
}
return NULL;
return babl_format_with_space (babl_get_name (format), space);
}
......
......@@ -111,10 +111,14 @@ gboolean gimp_color_profile_is_cmyk (GimpColorProfile *
gboolean gimp_color_profile_is_linear (GimpColorProfile *profile);
const Babl * gimp_color_profile_get_space (GimpColorProfile *profile,
GimpColorRenderingIntent intent,
GError **error);
const Babl * gimp_color_profile_get_format (GimpColorProfile *profile,
const Babl *format,
GimpColorRenderingIntent intent,
GError **error);
const Babl * gimp_color_profile_get_lcms_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