[gimp/goat-invasion: 435/608] app: add gimp_image_get_layer_format()



commit 439a4c92a2de64f0f8b0f44c48c5a729020f491d
Author: Michael Natterer <mitch gimp org>
Date:   Sat Apr 7 00:15:48 2012 +0200

    app: add gimp_image_get_layer_format()

 app/core/gimpimage.c |   30 ++++++++++++++++++++++++++++++
 app/core/gimpimage.h |    3 +++
 2 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 02b95f4..50b0de0 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -1556,6 +1556,36 @@ gimp_image_get_format_without_alpha (const GimpImage *image,
   return NULL;
 }
 
+const Babl *
+gimp_image_get_layer_format (const GimpImage *image,
+                             gboolean         with_alpha)
+{
+  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+
+  switch (GIMP_IMAGE_GET_PRIVATE (image)->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:
+      if (with_alpha)
+        return gimp_image_colormap_get_rgba_format (image);
+      else
+        return gimp_image_colormap_get_rgb_format (image);
+    }
+
+  g_return_val_if_reached (NULL);
+}
+
 gint
 gimp_image_get_ID (const GimpImage *image)
 {
diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h
index e9aaaa9..5fdf9f8 100644
--- a/app/core/gimpimage.h
+++ b/app/core/gimpimage.h
@@ -177,6 +177,9 @@ const Babl * gimp_image_get_format_with_alpha    (const GimpImage    *image,
 const Babl * gimp_image_get_format_without_alpha (const GimpImage    *image,
                                                   GimpImageType       type);
 
+const Babl * gimp_image_get_layer_format         (const GimpImage    *image,
+                                                  gboolean            with_alpha);
+
 gint            gimp_image_get_ID                (const GimpImage    *image);
 GimpImage     * gimp_image_get_by_ID             (Gimp               *gimp,
                                                   gint                id);



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