[gimp/gimp-2-10] libgimpcolor: add gimp_color_profile_get_space()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] libgimpcolor: add gimp_color_profile_get_space()
- Date: Mon, 16 Jul 2018 12:33:54 +0000 (UTC)
commit 7d897a451efda9740b8e88f2e1f258e199f59ee5
Author: Michael Natterer <mitch gimp org>
Date: Mon Jul 16 14:06:32 2018 +0200
libgimpcolor: add gimp_color_profile_get_space()
which returns the Babl space matching the profile.
(cherry picked from commit ac57af58a2c00d5c5995965f854a5d7d9e8aef76)
libgimpcolor/gimpcolor.def | 1 +
libgimpcolor/gimpcolorprofile.c | 53 +++++++++++++++++++++++++++++++----------
libgimpcolor/gimpcolorprofile.h | 4 ++++
3 files changed, 46 insertions(+), 12 deletions(-)
---
diff --git a/libgimpcolor/gimpcolor.def b/libgimpcolor/gimpcolor.def
index 8bbcbe3c35..f5a749a43e 100644
--- a/libgimpcolor/gimpcolor.def
+++ b/libgimpcolor/gimpcolor.def
@@ -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
diff --git a/libgimpcolor/gimpcolorprofile.c b/libgimpcolor/gimpcolorprofile.c
index f8aa1fe856..fe7c10cfa5 100644
--- a/libgimpcolor/gimpcolorprofile.c
+++ b/libgimpcolor/gimpcolorprofile.c
@@ -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);
}
diff --git a/libgimpcolor/gimpcolorprofile.h b/libgimpcolor/gimpcolorprofile.h
index 6f54095355..c09470b612 100644
--- a/libgimpcolor/gimpcolorprofile.h
+++ b/libgimpcolor/gimpcolorprofile.h
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]