From e9ecc40f028cf1d3ce9c855500b931f365732051 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sun, 18 Mar 2012 15:37:12 +0100 Subject: [PATCH] app: add GimpPickable::get_babl_format_with_alpha() --- app/core/gimpdrawable.c | 15 ++++++++------- app/core/gimpimagemap.c | 25 ++++++++++++++++++------- app/core/gimppickable.c | 17 ++++++++++++++++- app/core/gimppickable.h | 31 +++++++++++++++++-------------- app/core/gimpprojection.c | 19 ++++++++++--------- 5 files changed, 69 insertions(+), 38 deletions(-) diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c index 92fcf3bc4a..fd272bf8f4 100644 --- a/app/core/gimpdrawable.c +++ b/app/core/gimpdrawable.c @@ -269,13 +269,14 @@ gimp_drawable_init (GimpDrawable *drawable) static void gimp_drawable_pickable_iface_init (GimpPickableInterface *iface) { - iface->get_image = (GimpImage * (*) (GimpPickable *pickable)) gimp_item_get_image; - iface->get_babl_format = (const Babl * (*) (GimpPickable *pickable)) gimp_drawable_get_babl_format; - iface->get_image_type = (GimpImageType (*) (GimpPickable *pickable)) gimp_drawable_type; - iface->get_bytes = (gint (*) (GimpPickable *pickable)) gimp_drawable_bytes; - iface->get_buffer = (GeglBuffer * (*) (GimpPickable *pickable)) gimp_drawable_get_read_buffer; - iface->get_tiles = (TileManager * (*) (GimpPickable *pickable)) gimp_drawable_get_tiles; - iface->get_pixel_at = gimp_drawable_get_pixel_at; + iface->get_image = (GimpImage * (*) (GimpPickable *pickable)) gimp_item_get_image; + iface->get_babl_format = (const Babl * (*) (GimpPickable *pickable)) gimp_drawable_get_babl_format; + iface->get_babl_format_with_alpha = (const Babl * (*) (GimpPickable *pickable)) gimp_drawable_get_babl_format_with_alpha; + iface->get_image_type = (GimpImageType (*) (GimpPickable *pickable)) gimp_drawable_type; + iface->get_bytes = (gint (*) (GimpPickable *pickable)) gimp_drawable_bytes; + iface->get_buffer = (GeglBuffer * (*) (GimpPickable *pickable)) gimp_drawable_get_read_buffer; + iface->get_tiles = (TileManager * (*) (GimpPickable *pickable)) gimp_drawable_get_tiles; + iface->get_pixel_at = gimp_drawable_get_pixel_at; } static void diff --git a/app/core/gimpimagemap.c b/app/core/gimpimagemap.c index ed8ad182de..74634594b4 100644 --- a/app/core/gimpimagemap.c +++ b/app/core/gimpimagemap.c @@ -102,6 +102,8 @@ static void gimp_image_map_finalize (GObject *obje static GimpImage * gimp_image_map_get_image (GimpPickable *pickable); static const Babl * gimp_image_map_get_babl_format (GimpPickable *pickable); +static const Babl * gimp_image_map_get_babl_format_with_alpha + (GimpPickable *pickable); static GimpImageType gimp_image_map_get_image_type (GimpPickable *pickable); static gint gimp_image_map_get_bytes (GimpPickable *pickable); static GeglBuffer * gimp_image_map_get_buffer (GimpPickable *pickable); @@ -154,13 +156,14 @@ gimp_image_map_class_init (GimpImageMapClass *klass) static void gimp_image_map_pickable_iface_init (GimpPickableInterface *iface) { - iface->get_image = gimp_image_map_get_image; - iface->get_babl_format = gimp_image_map_get_babl_format; - iface->get_image_type = gimp_image_map_get_image_type; - iface->get_bytes = gimp_image_map_get_bytes; - iface->get_buffer = gimp_image_map_get_buffer; - iface->get_tiles = gimp_image_map_get_tiles; - iface->get_pixel_at = gimp_image_map_get_pixel_at; + iface->get_image = gimp_image_map_get_image; + iface->get_babl_format = gimp_image_map_get_babl_format; + iface->get_babl_format_with_alpha = gimp_image_map_get_babl_format_with_alpha; + iface->get_image_type = gimp_image_map_get_image_type; + iface->get_bytes = gimp_image_map_get_bytes; + iface->get_buffer = gimp_image_map_get_buffer; + iface->get_tiles = gimp_image_map_get_tiles; + iface->get_pixel_at = gimp_image_map_get_pixel_at; } static void @@ -272,6 +275,14 @@ gimp_image_map_get_babl_format (GimpPickable *pickable) return gimp_pickable_get_babl_format (GIMP_PICKABLE (image_map->drawable)); } +static const Babl * +gimp_image_map_get_babl_format_with_alpha (GimpPickable *pickable) +{ + GimpImageMap *image_map = GIMP_IMAGE_MAP (pickable); + + return gimp_pickable_get_babl_format_with_alpha (GIMP_PICKABLE (image_map->drawable)); +} + static GimpImageType gimp_image_map_get_image_type (GimpPickable *pickable) { diff --git a/app/core/gimppickable.c b/app/core/gimppickable.c index 7f2d051039..a43b0b3751 100644 --- a/app/core/gimppickable.c +++ b/app/core/gimppickable.c @@ -111,7 +111,7 @@ gimp_pickable_get_babl_format (GimpPickable *pickable) { GimpPickableInterface *pickable_iface; - g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), -1); + g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), NULL); pickable_iface = GIMP_PICKABLE_GET_INTERFACE (pickable); @@ -121,6 +121,21 @@ gimp_pickable_get_babl_format (GimpPickable *pickable) return NULL; } +const Babl * +gimp_pickable_get_babl_format_with_alpha (GimpPickable *pickable) +{ + GimpPickableInterface *pickable_iface; + + g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), NULL); + + pickable_iface = GIMP_PICKABLE_GET_INTERFACE (pickable); + + if (pickable_iface->get_babl_format_with_alpha) + return pickable_iface->get_babl_format_with_alpha (pickable); + + return NULL; +} + gint gimp_pickable_get_bytes (GimpPickable *pickable) { diff --git a/app/core/gimppickable.h b/app/core/gimppickable.h index 195a31479f..3ab755e09a 100644 --- a/app/core/gimppickable.h +++ b/app/core/gimppickable.h @@ -35,20 +35,21 @@ struct _GimpPickableInterface GTypeInterface base_iface; /* virtual functions */ - void (* flush) (GimpPickable *pickable); - GimpImage * (* get_image) (GimpPickable *pickable); - const Babl * (* get_babl_format) (GimpPickable *pickable); - GimpImageType (* get_image_type) (GimpPickable *pickable); - gint (* get_bytes) (GimpPickable *pickable); - GeglBuffer * (* get_buffer) (GimpPickable *pickable); - TileManager * (* get_tiles) (GimpPickable *pickable); - gboolean (* get_pixel_at) (GimpPickable *pickable, - gint x, - gint y, - guchar *pixel); - gint (* get_opacity_at) (GimpPickable *pickable, - gint x, - gint y); + void (* flush) (GimpPickable *pickable); + GimpImage * (* get_image) (GimpPickable *pickable); + const Babl * (* get_babl_format) (GimpPickable *pickable); + const Babl * (* get_babl_format_with_alpha) (GimpPickable *pickable); + GimpImageType (* get_image_type) (GimpPickable *pickable); + gint (* get_bytes) (GimpPickable *pickable); + GeglBuffer * (* get_buffer) (GimpPickable *pickable); + TileManager * (* get_tiles) (GimpPickable *pickable); + gboolean (* get_pixel_at) (GimpPickable *pickable, + gint x, + gint y, + guchar *pixel); + gint (* get_opacity_at) (GimpPickable *pickable, + gint x, + gint y); }; @@ -57,6 +58,8 @@ GType gimp_pickable_interface_get_type (void) G_GNUC_CONST; void gimp_pickable_flush (GimpPickable *pickable); GimpImage * gimp_pickable_get_image (GimpPickable *pickable); const Babl * gimp_pickable_get_babl_format (GimpPickable *pickable); +const Babl * gimp_pickable_get_babl_format_with_alpha + (GimpPickable *pickable); GimpImageType gimp_pickable_get_image_type (GimpPickable *pickable); gint gimp_pickable_get_bytes (GimpPickable *pickable); GeglBuffer * gimp_pickable_get_buffer (GimpPickable *pickable); diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c index 2de3323ba5..6b660f5a7c 100644 --- a/app/core/gimpprojection.c +++ b/app/core/gimpprojection.c @@ -162,15 +162,16 @@ gimp_projection_init (GimpProjection *proj) static void gimp_projection_pickable_iface_init (GimpPickableInterface *iface) { - iface->flush = gimp_projection_pickable_flush; - iface->get_image = gimp_projection_get_image; - iface->get_babl_format = gimp_projection_get_babl_format; - iface->get_image_type = gimp_projection_get_image_type; - iface->get_bytes = gimp_projection_get_bytes; - iface->get_buffer = gimp_projection_get_buffer; - iface->get_tiles = gimp_projection_get_tiles; - iface->get_pixel_at = gimp_projection_get_pixel_at; - iface->get_opacity_at = gimp_projection_get_opacity_at; + iface->flush = gimp_projection_pickable_flush; + iface->get_image = gimp_projection_get_image; + iface->get_babl_format = gimp_projection_get_babl_format; + iface->get_babl_format_with_alpha = gimp_projection_get_babl_format; /* sic */ + iface->get_image_type = gimp_projection_get_image_type; + iface->get_bytes = gimp_projection_get_bytes; + iface->get_buffer = gimp_projection_get_buffer; + iface->get_tiles = gimp_projection_get_tiles; + iface->get_pixel_at = gimp_projection_get_pixel_at; + iface->get_opacity_at = gimp_projection_get_opacity_at; } static void