[gimp/goat-invasion: 122/234] app: add gimp_drawable_get_format_without_alpha()



commit 09edc734f431a0cf449f2563fdb89d79d134b9df
Author: Michael Natterer <mitch gimp org>
Date:   Sun Mar 18 16:24:29 2012 +0100

    app: add gimp_drawable_get_format_without_alpha()

 app/core/gimpdrawable.c |   29 +++++++++++++++++++++++++++++
 app/core/gimpdrawable.h |    2 ++
 2 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index 5ea007b..7ccc715 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -1881,6 +1881,35 @@ gimp_drawable_get_format_with_alpha (const GimpDrawable *drawable)
   return NULL;
 }
 
+const Babl *
+gimp_drawable_get_format_without_alpha (const GimpDrawable *drawable)
+{
+  GimpImageType type;
+
+  g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
+
+  type = gimp_drawable_type (drawable);
+
+  switch (type)
+    {
+    case GIMP_RGB_IMAGE:
+    case GIMP_RGBA_IMAGE:   return babl_format ("RGB u8");
+    case GIMP_GRAY_IMAGE:
+    case GIMP_GRAYA_IMAGE:  return babl_format ("Y u8");
+    case GIMP_INDEXED_IMAGE:
+    case GIMP_INDEXEDA_IMAGE:
+      {
+        GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
+
+        return gimp_image_colormap_get_rgb_format (image);
+      }
+    }
+
+  g_warn_if_reached ();
+
+  return NULL;
+}
+
 gboolean
 gimp_drawable_has_alpha (const GimpDrawable *drawable)
 {
diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h
index c6a7878..77f27b6 100644
--- a/app/core/gimpdrawable.h
+++ b/app/core/gimpdrawable.h
@@ -228,6 +228,8 @@ void            gimp_drawable_fill_by_type       (GimpDrawable       *drawable,
 const Babl    * gimp_drawable_get_format        (const GimpDrawable *drawable);
 const Babl    * gimp_drawable_get_format_with_alpha
                                                  (const GimpDrawable *drawable);
+const Babl    * gimp_drawable_get_format_without_alpha
+                                                 (const GimpDrawable *drawable);
 gboolean        gimp_drawable_has_alpha          (const GimpDrawable *drawable);
 GimpImageType   gimp_drawable_type               (const GimpDrawable *drawable);
 GimpImageType   gimp_drawable_type_with_alpha    (const GimpDrawable *drawable);



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