[gimp/goat-invasion: 116/412] app: add gimp_bpp_to_babl_format_with_alpha()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 116/412] app: add gimp_bpp_to_babl_format_with_alpha()
- Date: Tue, 3 Apr 2012 09:42:51 +0000 (UTC)
commit c7f126ecbbf9e83ef469c8a535940c3976f7e765
Author: Michael Natterer <mitch gimp org>
Date: Sun Mar 18 15:00:08 2012 +0100
app: add gimp_bpp_to_babl_format_with_alpha()
app/gegl/gimp-gegl-utils.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
app/gegl/gimp-gegl-utils.h | 24 +++++++++++++-----------
2 files changed, 57 insertions(+), 11 deletions(-)
---
diff --git a/app/gegl/gimp-gegl-utils.c b/app/gegl/gimp-gegl-utils.c
index 5f01ca4..446639c 100644
--- a/app/gegl/gimp-gegl-utils.c
+++ b/app/gegl/gimp-gegl-utils.c
@@ -78,6 +78,50 @@ gimp_bpp_to_babl_format (guint bpp,
return NULL;
}
+/**
+ * gimp_bpp_to_babl_format_with_alpha:
+ * @bpp: bytes per pixel
+ * @linear: whether the pixels are linear or gamma-corrected.
+ *
+ * Return the Babl format to use for a given number of bytes per pixel.
+ * This function assumes that the data is 8bit.
+ *
+ * Return value: the Babl format to use
+ **/
+const Babl *
+gimp_bpp_to_babl_format_with_alpha (guint bpp,
+ gboolean linear)
+{
+ g_return_val_if_fail (bpp > 0 && bpp <= 4, NULL);
+
+ if (linear)
+ {
+ switch (bpp)
+ {
+ case 1:
+ case 2:
+ return babl_format ("YA u8");
+ case 3:
+ case 4:
+ return babl_format ("RGBA u8");
+ }
+ }
+ else
+ {
+ switch (bpp)
+ {
+ case 1:
+ case 2:
+ return babl_format ("Y'A u8");
+ case 3:
+ case 4:
+ return babl_format ("R'G'B'A u8");
+ }
+ }
+
+ return NULL;
+}
+
const gchar *
gimp_layer_mode_to_gegl_operation (GimpLayerModeEffects mode)
{
diff --git a/app/gegl/gimp-gegl-utils.h b/app/gegl/gimp-gegl-utils.h
index ba69f65..4956fbe 100644
--- a/app/gegl/gimp-gegl-utils.h
+++ b/app/gegl/gimp-gegl-utils.h
@@ -25,21 +25,23 @@
#include <gdk-pixbuf/gdk-pixbuf.h> /* temp hack */
-const Babl * gimp_bpp_to_babl_format (guint bpp,
- gboolean linear) G_GNUC_CONST;
+const Babl * gimp_bpp_to_babl_format (guint bpp,
+ gboolean linear) G_GNUC_CONST;
+const Babl * gimp_bpp_to_babl_format_with_alpha (guint bpp,
+ gboolean linear) G_GNUC_CONST;
-const gchar * gimp_layer_mode_to_gegl_operation (GimpLayerModeEffects mode) G_GNUC_CONST;
-const gchar * gimp_interpolation_to_gegl_filter (GimpInterpolationType interpolation) G_GNUC_CONST;
+const gchar * gimp_layer_mode_to_gegl_operation (GimpLayerModeEffects mode) G_GNUC_CONST;
+const gchar * gimp_interpolation_to_gegl_filter (GimpInterpolationType interpolation) G_GNUC_CONST;
-GeglBuffer * gimp_tile_manager_create_buffer (TileManager *tm,
- const Babl *format,
- gboolean write);
-GeglBuffer * gimp_pixbuf_create_buffer (GdkPixbuf *pixbuf);
+GeglBuffer * gimp_tile_manager_create_buffer (TileManager *tm,
+ const Babl *format,
+ gboolean write);
+GeglBuffer * gimp_pixbuf_create_buffer (GdkPixbuf *pixbuf);
-void gimp_gegl_buffer_refetch_tiles (GeglBuffer *buffer);
+void gimp_gegl_buffer_refetch_tiles (GeglBuffer *buffer);
-void gimp_gegl_color_set_rgba (GeglColor *color,
- const GimpRGB *rgb);
+void gimp_gegl_color_set_rgba (GeglColor *color,
+ const GimpRGB *rgb);
#endif /* __GIMP_GEGL_UTILS_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]