[gimp/goat-invasion: 525/526] app: add gimp_babl_format() and use it in gimp_image_get_format()



commit 94d3ee844ad6332124ed5a2ccc163caaae1870ef
Author: Michael Natterer <mitch gimp org>
Date:   Sun Apr 22 00:02:10 2012 +0200

    app: add gimp_babl_format() and use it in gimp_image_get_format()

 app/core/gimpimage.c |   12 ++----------
 app/gegl/gimp-babl.c |   26 ++++++++++++++++++++++++++
 app/gegl/gimp-babl.h |    7 +++++--
 3 files changed, 33 insertions(+), 12 deletions(-)
---
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index b8e665c..1ec8804 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -32,7 +32,7 @@
 
 #include "config/gimpcoreconfig.h"
 
-#include "gegl/gimp-gegl-utils.h"
+#include "gegl/gimp-babl.h"
 
 #include "gimp.h"
 #include "gimp-parasites.h"
@@ -1484,16 +1484,8 @@ gimp_image_get_format (const GimpImage   *image,
   switch (base_type)
     {
     case GIMP_RGB:
-      if (with_alpha)
-        return babl_format ("R'G'B'A u8");
-      else
-        return babl_format ("R'G'B' u8");
-
     case GIMP_GRAY:
-      if (with_alpha)
-        return babl_format ("Y'A u8");
-      else
-        return babl_format ("Y' u8");
+      return gimp_babl_format (base_type, with_alpha);
 
     case GIMP_INDEXED:
       if (with_alpha)
diff --git a/app/gegl/gimp-babl.c b/app/gegl/gimp-babl.c
index 63d47fa..9968ffc 100644
--- a/app/gegl/gimp-babl.c
+++ b/app/gegl/gimp-babl.c
@@ -146,3 +146,29 @@ gimp_babl_format_get_base_type (const Babl *format)
 
   g_return_val_if_reached (-1);
 }
+
+const Babl *
+gimp_babl_format (GimpImageBaseType  base_type,
+                  gboolean           with_alpha)
+{
+  switch (base_type)
+    {
+    case GIMP_RGB:
+      if (with_alpha)
+        return babl_format ("R'G'B'A u8");
+      else
+        return babl_format ("R'G'B' u8");
+
+    case GIMP_GRAY:
+      if (with_alpha)
+        return babl_format ("Y'A u8");
+      else
+        return babl_format ("Y' u8");
+
+    case GIMP_INDEXED:
+      /* need to use the image's api for this */
+      break;
+    }
+
+  g_return_val_if_reached (NULL);
+}
diff --git a/app/gegl/gimp-babl.h b/app/gegl/gimp-babl.h
index 9d56592..704f611 100644
--- a/app/gegl/gimp-babl.h
+++ b/app/gegl/gimp-babl.h
@@ -24,9 +24,12 @@
 
 void                gimp_babl_init                  (void);
 
-const gchar       * gimp_babl_get_description       (const Babl *babl);
+const gchar       * gimp_babl_get_description       (const Babl        *babl);
 
-GimpImageBaseType   gimp_babl_format_get_base_type  (const Babl *format);
+GimpImageBaseType   gimp_babl_format_get_base_type  (const Babl        *format);
+
+const Babl        * gimp_babl_format                (GimpImageBaseType  base_type,
+                                                     gboolean           with_alpha);
 
 
 #endif /* __GIMP_BABL_H__ */



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