libgimpcolor: add gimp_pixbuf_get_icc_profile()

which decodes and returns the pixbuf's base64-encoded "icc-profile"
property.
This commit is contained in:
Michael Natterer 2015-06-16 23:43:40 +02:00
parent 16971ff186
commit 4422128ecc
3 changed files with 43 additions and 2 deletions

View File

@ -59,6 +59,7 @@ EXPORTS
gimp_param_spec_rgb_has_alpha
gimp_pixbuf_create_buffer
gimp_pixbuf_get_format
gimp_pixbuf_get_icc_profile
gimp_rgb_add
gimp_rgb_clamp
gimp_rgb_composite

View File

@ -114,3 +114,40 @@ gimp_pixbuf_create_buffer (GdkPixbuf *pixbuf)
return buffer;
}
}
/**
* gimp_pixbuf_get_icc_profile:
* @pixbuf: a #GdkPixbuf
* @length: return location for the ICC profile's length
*
* Returns the ICC profile attached to the @pixbuf, or %NULL if there
* is none.
*
* Return value: The ICC profile data, or %NULL. The value should be freed
* with g_free().
*
* Since: 2.10
**/
guint8 *
gimp_pixbuf_get_icc_profile (GdkPixbuf *pixbuf,
gsize *length)
{
gchar *icc_base64 = NULL;
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
g_return_val_if_fail (length != NULL, NULL);
g_object_get (pixbuf, "icc-profile", icc_base64, NULL);
if (icc_base64)
{
guint8 *icc_data;
icc_data = g_base64_decode (icc_base64, length);
g_free (icc_base64);
return icc_data;
}
return NULL;
}

View File

@ -31,8 +31,11 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
const Babl * gimp_pixbuf_get_format (GdkPixbuf *pixbuf);
GeglBuffer * gimp_pixbuf_create_buffer (GdkPixbuf *pixbuf);
const Babl * gimp_pixbuf_get_format (GdkPixbuf *pixbuf);
GeglBuffer * gimp_pixbuf_create_buffer (GdkPixbuf *pixbuf);
guint8 * gimp_pixbuf_get_icc_profile (GdkPixbuf *pixbuf,
gsize *length);
G_END_DECLS