[gimp/goat-invasion: 439/526] app: add gimp_drawable_get_base_type()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 439/526] app: add gimp_drawable_get_base_type()
- Date: Sun, 22 Apr 2012 13:36:09 +0000 (UTC)
commit 59a8630757203ca9f05fd751722afa17043471db
Author: Michael Natterer <mitch gimp org>
Date: Sat Apr 7 01:34:44 2012 +0200
app: add gimp_drawable_get_base_type()
app/core/gimpdrawable.c | 33 +++++++++++++++++++++++++++++++++
app/core/gimpdrawable.h | 1 +
2 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index dfc590e..7b47a01 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -1665,6 +1665,39 @@ gimp_drawable_type_with_alpha (const GimpDrawable *drawable)
return GIMP_IMAGE_TYPE_WITH_ALPHA (gimp_drawable_type (drawable));
}
+GimpImageType
+gimp_drawable_get_base_type (const GimpDrawable *drawable)
+{
+ const Babl *format;
+
+ g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
+
+ format = gegl_buffer_get_format (drawable->private->buffer);
+
+ 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
+ {
+ GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
+
+ if (format == gimp_image_get_format (image, GIMP_INDEXED_IMAGE) ||
+ format == gimp_image_get_format (image, GIMP_INDEXEDA_IMAGE))
+ {
+ return GIMP_INDEXED;
+ }
+ }
+
+ g_return_val_if_reached (-1);
+}
+
gboolean
gimp_drawable_is_rgb (const GimpDrawable *drawable)
{
diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h
index 40055c1..f79e5e0 100644
--- a/app/core/gimpdrawable.h
+++ b/app/core/gimpdrawable.h
@@ -226,6 +226,7 @@ const Babl * gimp_drawable_get_format_without_alpha
gboolean gimp_drawable_has_alpha (const GimpDrawable *drawable);
GimpImageType gimp_drawable_type (const GimpDrawable *drawable);
GimpImageType gimp_drawable_type_with_alpha (const GimpDrawable *drawable);
+GimpImageType gimp_drawable_get_base_type (const GimpDrawable *drawable);
gboolean gimp_drawable_is_rgb (const GimpDrawable *drawable);
gboolean gimp_drawable_is_gray (const GimpDrawable *drawable);
gboolean gimp_drawable_is_indexed (const GimpDrawable *drawable);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]