[gimp] libgimpcolor: add CMYK formats to gimp_color_profile_get_format()



commit ff3e9d76ac784624942e9d6257e845a4ac770e78
Author: Michael Natterer <mitch gimp org>
Date:   Fri May 27 00:33:56 2016 +0200

    libgimpcolor: add CMYK formats to gimp_color_profile_get_format()
    
    Makes the CMYK color selector not crash.

 libgimpcolor/gimpcolorprofile.c |  115 ++++++++++++++++++++++++++-------------
 1 files changed, 78 insertions(+), 37 deletions(-)
---
diff --git a/libgimpcolor/gimpcolorprofile.c b/libgimpcolor/gimpcolorprofile.c
index 385a79b..453b7f2 100644
--- a/libgimpcolor/gimpcolorprofile.c
+++ b/libgimpcolor/gimpcolorprofile.c
@@ -55,6 +55,22 @@
 #define TYPE_GRAYA_DBL      (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|EXTRA_SH(1)|CHANNELS_SH(1)|BYTES_SH(0))
 #endif
 
+#ifndef TYPE_CMYKA_DBL
+#define TYPE_CMYKA_DBL      (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|EXTRA_SH(1)|CHANNELS_SH(4)|BYTES_SH(0))
+#endif
+
+#ifndef TYPE_CMYKA_HALF_FLT
+#define TYPE_CMYKA_HALF_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|EXTRA_SH(1)|CHANNELS_SH(4)|BYTES_SH(2))
+#endif
+
+#ifndef TYPE_CMYKA_FLT
+#define TYPE_CMYKA_FLT      (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|EXTRA_SH(1)|CHANNELS_SH(4)|BYTES_SH(4))
+#endif
+
+#ifndef TYPE_CMYKA_16
+#define TYPE_CMYKA_16       (COLORSPACE_SH(PT_CMYK)|EXTRA_SH(1)|CHANNELS_SH(4)|BYTES_SH(2))
+#endif
+
 
 /**
  * SECTION: gimpcolorprofile
@@ -1468,8 +1484,10 @@ gimp_color_profile_get_format (const Babl *format,
   const Babl *type;
   const Babl *model;
   gboolean    has_alpha;
-  gboolean    gray;
-  gboolean    linear;
+  gboolean    rgb    = FALSE;
+  gboolean    gray   = FALSE;
+  gboolean    cmyk   = FALSE;
+  gboolean    linear = FALSE;
 
   g_return_val_if_fail (format != NULL, NULL);
   g_return_val_if_fail (lcms_format != NULL, NULL);
@@ -1497,14 +1515,13 @@ gimp_color_profile_get_format (const Babl *format,
   else if (model == babl_model ("RGB") ||
            model == babl_model ("RGBA"))
     {
-      gray   = FALSE;
+      rgb    = TRUE;
       linear = TRUE;
     }
   else if (model == babl_model ("R'G'B'") ||
            model == babl_model ("R'G'B'A"))
     {
-      gray   = FALSE;
-      linear = FALSE;
+      rgb = TRUE;
     }
   else if (model == babl_model ("Y") ||
            model == babl_model ("YA"))
@@ -1515,8 +1532,12 @@ gimp_color_profile_get_format (const Babl *format,
   else if (model == babl_model ("Y'") ||
            model == babl_model ("Y'A"))
     {
-      gray   = TRUE;
-      linear = FALSE;
+      gray = TRUE;
+    }
+  else if (model == babl_model ("CMYK") ||
+           model == babl_model ("CMYKA"))
+    {
+      cmyk = TRUE;
     }
   else if (babl_format_is_palette (format))
     {
@@ -1552,17 +1573,21 @@ gimp_color_profile_get_format (const Babl *format,
     {
       if (has_alpha)
         {
-          if (gray)
-            *lcms_format = TYPE_GRAYA_8;
-          else
+          if (rgb)
             *lcms_format = TYPE_RGBA_8;
+          else if (gray)
+            *lcms_format = TYPE_GRAYA_8;
+          else if (cmyk)
+            *lcms_format = TYPE_CMYKA_8;
         }
       else
         {
-          if (gray)
-            *lcms_format = TYPE_GRAY_8;
-          else
+          if (rgb)
             *lcms_format = TYPE_RGB_8;
+          else if (gray)
+            *lcms_format = TYPE_GRAY_8;
+          else if (cmyk)
+            *lcms_format = TYPE_CMYK_8;
         }
 
       output_format = format;
@@ -1571,17 +1596,21 @@ gimp_color_profile_get_format (const Babl *format,
     {
       if (has_alpha)
         {
-          if (gray)
-            *lcms_format = TYPE_GRAYA_16;
-          else
+          if (rgb)
             *lcms_format = TYPE_RGBA_16;
+          else if (gray)
+            *lcms_format = TYPE_GRAYA_16;
+          else if (cmyk)
+            *lcms_format = TYPE_CMYKA_16;
         }
       else
         {
-          if (gray)
-            *lcms_format = TYPE_GRAY_16;
-          else
+          if (rgb)
             *lcms_format = TYPE_RGB_16;
+          else if (gray)
+            *lcms_format = TYPE_GRAY_16;
+          else if (cmyk)
+            *lcms_format = TYPE_CMYK_16;
         }
 
       output_format = format;
@@ -1590,17 +1619,21 @@ gimp_color_profile_get_format (const Babl *format,
     {
       if (has_alpha)
         {
-          if (gray)
-            *lcms_format = TYPE_GRAYA_HALF_FLT;
-          else
+          if (rgb)
             *lcms_format = TYPE_RGBA_HALF_FLT;
+          else if (gray)
+            *lcms_format = TYPE_GRAYA_HALF_FLT;
+          else if (cmyk)
+            *lcms_format = TYPE_CMYKA_HALF_FLT;
         }
       else
         {
-          if (gray)
-            *lcms_format = TYPE_GRAY_HALF_FLT;
-          else
+          if (rgb)
             *lcms_format = TYPE_RGB_HALF_FLT;
+          else if (gray)
+            *lcms_format = TYPE_GRAY_HALF_FLT;
+          else if (cmyk)
+            *lcms_format = TYPE_CMYK_HALF_FLT;
         }
 
       output_format = format;
@@ -1609,17 +1642,21 @@ gimp_color_profile_get_format (const Babl *format,
     {
       if (has_alpha)
         {
-          if (gray)
-            *lcms_format = TYPE_GRAYA_FLT;
-          else
+          if (rgb)
             *lcms_format = TYPE_RGBA_FLT;
+          else if (gray)
+            *lcms_format = TYPE_GRAYA_FLT;
+          else if (cmyk)
+            *lcms_format = TYPE_CMYKA_FLT;
         }
       else
         {
-          if (gray)
-            *lcms_format = TYPE_GRAY_FLT;
-          else
+          if (rgb)
             *lcms_format = TYPE_RGB_FLT;
+          else if (gray)
+            *lcms_format = TYPE_GRAY_FLT;
+          else if (cmyk)
+            *lcms_format = TYPE_CMYK_FLT;
         }
 
       output_format = format;
@@ -1628,17 +1665,21 @@ gimp_color_profile_get_format (const Babl *format,
     {
       if (has_alpha)
         {
-          if (gray)
-            *lcms_format = TYPE_GRAYA_DBL;
-          else
+          if (rgb)
             *lcms_format = TYPE_RGBA_DBL;
+          else if (gray)
+            *lcms_format = TYPE_GRAYA_DBL;
+          else if (cmyk)
+            *lcms_format = TYPE_CMYKA_DBL;
         }
       else
         {
-          if (gray)
-            *lcms_format = TYPE_GRAY_DBL;
-          else
+          if (rgb)
             *lcms_format = TYPE_RGB_DBL;
+          else if (gray)
+            *lcms_format = TYPE_GRAY_DBL;
+          else if (cmyk)
+            *lcms_format = TYPE_CMYK_DBL;
         }
 
       output_format = format;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]