[gimp/goat-invasion: 441/608] app: add gimp_babl_format_get_image_type, base_type()



commit 19b27c69ac85dc1bd62d14328787a7367a806de0
Author: Michael Natterer <mitch gimp org>
Date:   Sat Apr 7 02:24:07 2012 +0200

    app: add gimp_babl_format_get_image_type,base_type()

 app/gegl/gimp-gegl-utils.c |   47 ++++++++++++++++++++++++++++++++++++++++++++
 app/gegl/gimp-gegl-utils.h |    3 ++
 2 files changed, 50 insertions(+), 0 deletions(-)
---
diff --git a/app/gegl/gimp-gegl-utils.c b/app/gegl/gimp-gegl-utils.c
index 0d8247f..7995476 100644
--- a/app/gegl/gimp-gegl-utils.c
+++ b/app/gegl/gimp-gegl-utils.c
@@ -33,6 +33,53 @@
 #include "gimptilebackendtilemanager.h"
 
 
+GimpImageType
+gimp_babl_format_get_image_type (const Babl *format)
+{
+  g_return_val_if_fail (format != NULL, -1);
+
+  if (format == babl_format ("Y' u8"))
+    return GIMP_GRAY_IMAGE;
+  else if (format == babl_format ("Y'A u8"))
+    return GIMP_GRAYA_IMAGE;
+  else if (format == babl_format ("R'G'B' u8"))
+    return GIMP_RGB_IMAGE;
+  else if (format == babl_format ("R'G'B'A u8"))
+    return GIMP_RGBA_IMAGE;
+  else if (babl_format_is_palette (format))
+    {
+      if (babl_format_has_alpha (format))
+        return GIMP_INDEXEDA_IMAGE;
+      else
+        return GIMP_INDEXED_IMAGE;
+    }
+
+  g_return_val_if_reached (-1);
+}
+
+GimpImageBaseType
+gimp_babl_format_get_base_type (const Babl *format)
+{
+  g_return_val_if_fail (format != NULL, -1);
+
+  if (format == babl_format ("Y' u8") ||
+      format == babl_format ("Y'A u8"))
+    {
+      return GIMP_GRAY;
+    }
+  else if (format == babl_format ("R'G'B' u8") ||
+           format == babl_format ("R'G'B'A u8"))
+    {
+      return GIMP_RGB;
+    }
+  else if (babl_format_is_palette (format))
+    {
+      return GIMP_INDEXED;
+    }
+
+  g_return_val_if_reached (-1);
+}
+
 /**
  * gimp_bpp_to_babl_format:
  * @bpp: bytes per pixel
diff --git a/app/gegl/gimp-gegl-utils.h b/app/gegl/gimp-gegl-utils.h
index ca3a8a7..ec0ae23 100644
--- a/app/gegl/gimp-gegl-utils.h
+++ b/app/gegl/gimp-gegl-utils.h
@@ -25,6 +25,9 @@
 #include <gdk-pixbuf/gdk-pixbuf.h> /* temp hack */
 
 
+GimpImageType     gimp_babl_format_get_image_type (const Babl           *format);
+GimpImageBaseType gimp_babl_format_get_base_type  (const Babl           *format);
+
 const Babl  * gimp_bpp_to_babl_format            (guint                  bpp) G_GNUC_CONST;
 const Babl  * gimp_bpp_to_babl_format_with_alpha (guint                  bpp) G_GNUC_CONST;
 



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