[gegl] gegl: preserve CMYK format in colors serialized to strings
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] gegl: preserve CMYK format in colors serialized to strings
- Date: Tue, 8 Jan 2019 02:43:40 +0000 (UTC)
commit 0fa33bbea9afbe6efad8e000a7717f7c50fe3571
Author: Øyvind Kolås <pippin gimp org>
Date: Tue Jan 8 03:41:09 2019 +0100
gegl: preserve CMYK format in colors serialized to strings
For UI/script specified CMYK values we expect untagged values - which
is nicely serializable. It would actually be nice if we start tagging
with sRGB in all places applicable to permit similar untagged RGB to
exist.
gegl/property-types/gegl-color.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
---
diff --git a/gegl/property-types/gegl-color.c b/gegl/property-types/gegl-color.c
index 8614ebe28..b4d5e32d9 100644
--- a/gegl/property-types/gegl-color.c
+++ b/gegl/property-types/gegl-color.c
@@ -429,6 +429,26 @@ gegl_color_get_string (GeglColor *color)
gegl_color_get_pixel (color, gegl_babl_rgba_linear_float (), rgba);
+ if (babl_get_model_flags (color->priv->format) & BABL_MODEL_FLAG_CMYK)
+ {
+ gfloat cmyka[5];
+ gchar buf [5][G_ASCII_DTOSTR_BUF_SIZE];
+ gegl_color_get_pixel (color, babl_format ("CMYKA float"), cmyka);
+ g_ascii_formatd (buf[0], G_ASCII_DTOSTR_BUF_SIZE, "%1.4f", cmyka[0]*100);
+ g_ascii_formatd (buf[1], G_ASCII_DTOSTR_BUF_SIZE, "%1.4f", cmyka[1]*100);
+ g_ascii_formatd (buf[2], G_ASCII_DTOSTR_BUF_SIZE, "%1.4f", cmyka[2]*100);
+ g_ascii_formatd (buf[3], G_ASCII_DTOSTR_BUF_SIZE, "%1.4f", cmyka[3]*100);
+ g_ascii_formatd (buf[4], G_ASCII_DTOSTR_BUF_SIZE, "%1.4f", cmyka[3]);
+ if (cmyka[4] == 1.0)
+ {
+ return g_strdup_printf ("cmyk(%s, %s, %s, %s)", buf[0], buf[1], buf[2], buf[3]);
+ }
+ else
+ {
+ return g_strdup_printf ("cmyka(%s, %s, %s, %s, %s)", buf[0], buf[1], buf[2], buf[3], buf[4]);
+ }
+ }
+
if (rgba[3] == 1.0)
{
gchar buf [3][G_ASCII_DTOSTR_BUF_SIZE];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]