app: add GimpPickable::get_babl_format()

This commit is contained in:
Michael Natterer 2012-03-17 15:21:11 +01:00
parent b2d8aef239
commit f05de34cd6
5 changed files with 105 additions and 52 deletions

View file

@ -269,12 +269,13 @@ 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_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_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

View file

@ -97,30 +97,31 @@ struct _GimpImageMap
static void gimp_image_map_pickable_iface_init (GimpPickableInterface *iface);
static void gimp_image_map_dispose (GObject *object);
static void gimp_image_map_finalize (GObject *object);
static void gimp_image_map_dispose (GObject *object);
static void gimp_image_map_finalize (GObject *object);
static GimpImage * gimp_image_map_get_image (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);
static TileManager * gimp_image_map_get_tiles (GimpPickable *pickable);
static gboolean gimp_image_map_get_pixel_at (GimpPickable *pickable,
gint x,
gint y,
guchar *pixel);
static GimpImage * gimp_image_map_get_image (GimpPickable *pickable);
static const Babl * gimp_image_map_get_babl_format (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);
static TileManager * gimp_image_map_get_tiles (GimpPickable *pickable);
static gboolean gimp_image_map_get_pixel_at (GimpPickable *pickable,
gint x,
gint y,
guchar *pixel);
static void gimp_image_map_update_undo_tiles
(GimpImageMap *image_map,
const GeglRectangle *rect);
static gboolean gimp_image_map_do (GimpImageMap *image_map);
static void gimp_image_map_data_written (GObject *operation,
const GeglRectangle *extent,
GimpImageMap *image_map);
(GimpImageMap *image_map,
const GeglRectangle *rect);
static gboolean gimp_image_map_do (GimpImageMap *image_map);
static void gimp_image_map_data_written (GObject *operation,
const GeglRectangle *extent,
GimpImageMap *image_map);
static void gimp_image_map_cancel_any_idle_jobs
(GimpImageMap *image_map);
(GimpImageMap *image_map);
static void gimp_image_map_kill_any_idle_processors
(GimpImageMap *image_map);
(GimpImageMap *image_map);
G_DEFINE_TYPE_WITH_CODE (GimpImageMap, gimp_image_map, GIMP_TYPE_OBJECT,
@ -153,12 +154,13 @@ 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_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_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
@ -262,6 +264,14 @@ gimp_image_map_get_image (GimpPickable *pickable)
return gimp_pickable_get_image (GIMP_PICKABLE (image_map->drawable));
}
static const Babl *
gimp_image_map_get_babl_format (GimpPickable *pickable)
{
GimpImageMap *image_map = GIMP_IMAGE_MAP (pickable);
return gimp_pickable_get_babl_format (GIMP_PICKABLE (image_map->drawable));
}
static GimpImageType
gimp_image_map_get_image_type (GimpPickable *pickable)
{

View file

@ -106,6 +106,21 @@ gimp_pickable_get_image_type (GimpPickable *pickable)
return -1;
}
const Babl *
gimp_pickable_get_babl_format (GimpPickable *pickable)
{
GimpPickableInterface *pickable_iface;
g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), -1);
pickable_iface = GIMP_PICKABLE_GET_INTERFACE (pickable);
if (pickable_iface->get_babl_format)
return pickable_iface->get_babl_format (pickable);
return NULL;
}
gint
gimp_pickable_get_bytes (GimpPickable *pickable)
{

View file

@ -35,19 +35,20 @@ struct _GimpPickableInterface
GTypeInterface base_iface;
/* virtual functions */
void (* flush) (GimpPickable *pickable);
GimpImage * (* get_image) (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);
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);
};
@ -55,6 +56,7 @@ 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);
GimpImageType gimp_pickable_get_image_type (GimpPickable *pickable);
gint gimp_pickable_get_bytes (GimpPickable *pickable);
GeglBuffer * gimp_pickable_get_buffer (GimpPickable *pickable);

View file

@ -61,6 +61,7 @@ static gint64 gimp_projection_get_memsize (GimpObject *objec
static void gimp_projection_pickable_flush (GimpPickable *pickable);
static GimpImage * gimp_projection_get_image (GimpPickable *pickable);
static const Babl * gimp_projection_get_babl_format (GimpPickable *pickable);
static GimpImageType gimp_projection_get_image_type (GimpPickable *pickable);
static gint gimp_projection_get_bytes (GimpPickable *pickable);
static GeglBuffer * gimp_projection_get_buffer (GimpPickable *pickable);
@ -161,14 +162,15 @@ 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_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_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
@ -292,6 +294,29 @@ gimp_projection_get_image (GimpPickable *pickable)
return gimp_projectable_get_image (proj->projectable);
}
static const Babl *
gimp_projection_get_babl_format (GimpPickable *pickable)
{
GimpProjection *proj = GIMP_PROJECTION (pickable);
GimpImageType type;
type = gimp_projectable_get_image_type (proj->projectable);
switch (GIMP_IMAGE_TYPE_BASE_TYPE (type))
{
case GIMP_RGB:
case GIMP_INDEXED:
return babl_format ("RGBA u8");
case GIMP_GRAY:
return babl_format ("YA u8");
}
g_assert_not_reached ();
return NULL;
}
static GimpImageType
gimp_projection_get_image_type (GimpPickable *pickable)
{