libgimpcolor: add gimp_color_profile_get_space()

which returns the Babl space matching the profile.
This commit is contained in:
Michael Natterer 2018-07-16 14:06:32 +02:00
parent a810c6b60b
commit ac57af58a2
3 changed files with 46 additions and 12 deletions

View file

@ -32,6 +32,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

View file

@ -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);
}

View file

@ -115,10 +115,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);