[gimp/goat-invasion: 189/234] app: replace GimpDraable's type by a Babl format
- From: Ãyvind KolÃs <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 189/234] app: replace GimpDraable's type by a Babl format
- Date: Fri, 23 Mar 2012 12:09:16 +0000 (UTC)
commit e226696bf2557d4e5a38f48f8172edd1d931d1cf
Author: Michael Natterer <mitch gimp org>
Date: Wed Mar 21 20:21:11 2012 +0100
app: replace GimpDraable's type by a Babl format
and change gimp_drawable_new() and all gimp_layer_new() variants to
take formats instead of types.
app/actions/debug-commands.c | 11 +++---
app/actions/edit-commands.c | 5 ++-
app/actions/layers-commands.c | 23 +++++++++----
app/core/gimp-edit.c | 3 +-
app/core/gimpchannel.c | 10 +++--
app/core/gimpdrawable-private.h | 2 +-
app/core/gimpdrawable-transform.c | 2 +-
app/core/gimpdrawable.c | 65 ++++++++++++++++++++++++-----------
app/core/gimpdrawable.h | 2 +-
app/core/gimpgrouplayer.c | 8 +++--
app/core/gimpimage-merge.c | 4 +-
app/core/gimpimage-new.c | 10 ++++--
app/core/gimplayer.c | 22 +++++++-----
app/core/gimplayer.h | 6 ++--
app/core/gimplayermask.c | 3 +-
app/core/gimpselection.c | 5 ++-
app/display/gimpdisplayshell-dnd.c | 3 +-
app/pdb/layer-cmds.c | 12 ++++--
app/tests/gimp-app-test-utils.c | 2 +-
app/text/gimptextlayer-xcf.c | 4 +-
app/text/gimptextlayer.c | 3 +-
app/widgets/gimplayertreeview.c | 12 +++++--
app/xcf/xcf-load.c | 7 ++--
tools/pdbgen/pdb/layer.pdb | 12 ++++--
24 files changed, 151 insertions(+), 85 deletions(-)
---
diff --git a/app/actions/debug-commands.c b/app/actions/debug-commands.c
index e5f50d9..85f9381 100644
--- a/app/actions/debug-commands.c
+++ b/app/actions/debug-commands.c
@@ -357,11 +357,12 @@ debug_show_image_graph (GimpImage *source_image)
FALSE);
gimp_image_set_uri (new_image, new_name);
layer = gimp_layer_new_from_buffer (buffer,
- new_image,
- GIMP_RGBA_IMAGE,
- new_name,
- 1.0,
- GIMP_NORMAL_MODE);
+ new_image,
+ gimp_image_get_format (new_image,
+ GIMP_RGBA_IMAGE),
+ new_name,
+ 1.0,
+ GIMP_NORMAL_MODE);
gimp_image_add_layer (new_image, layer, NULL, 0, FALSE);
gimp_create_display (gimp, new_image, GIMP_UNIT_PIXEL, 1.0);
diff --git a/app/actions/edit-commands.c b/app/actions/edit-commands.c
index 90788ae..a13f7ee 100644
--- a/app/actions/edit-commands.c
+++ b/app/actions/edit-commands.c
@@ -340,11 +340,12 @@ edit_paste_as_new_layer_cmd_callback (GtkAction *action,
if (buffer)
{
- GimpLayer *layer;
+ GimpLayer *layer;
+ GimpImageType type = gimp_image_base_type_with_alpha (image);
layer = gimp_layer_new_from_buffer (gimp_buffer_get_buffer (buffer),
image,
- gimp_image_base_type_with_alpha (image),
+ gimp_image_get_format (image, type),
_("Clipboard"),
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
g_object_unref (buffer);
diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c
index 55fd134..d0ddeb5 100644
--- a/app/actions/layers-commands.c
+++ b/app/actions/layers-commands.c
@@ -272,6 +272,7 @@ layers_new_last_vals_cmd_callback (GtkAction *action,
GimpLayer *new_layer;
gint width, height;
gint off_x, off_y;
+ GimpImageType type;
gdouble opacity;
GimpLayerModeEffects mode;
return_if_no_image (image, data);
@@ -319,8 +320,10 @@ layers_new_last_vals_cmd_callback (GtkAction *action,
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_EDIT_PASTE,
_("New Layer"));
+ type = gimp_image_base_type_with_alpha (image);
+
new_layer = gimp_layer_new (image, width, height,
- gimp_image_base_type_with_alpha (image),
+ gimp_image_get_format (image, type),
layer_name,
opacity, mode);
@@ -341,18 +344,21 @@ void
layers_new_from_visible_cmd_callback (GtkAction *action,
gpointer data)
{
- GimpImage *image;
- GimpLayer *layer;
- GimpPickable *pickable;
+ GimpImage *image;
+ GimpLayer *layer;
+ GimpPickable *pickable;
+ GimpImageType type;
return_if_no_image (image, data);
pickable = GIMP_PICKABLE (gimp_image_get_projection (image));
gimp_pickable_flush (pickable);
+ type = gimp_image_base_type_with_alpha (image);
+
layer = gimp_layer_new_from_buffer (gimp_pickable_get_buffer (pickable),
image,
- gimp_image_base_type_with_alpha (image),
+ gimp_image_get_format (image, type),
_("Visible"),
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
@@ -973,7 +979,8 @@ layers_new_layer_response (GtkWidget *widget,
{
if (response_id == GTK_RESPONSE_OK)
{
- GimpLayer *layer;
+ GimpLayer *layer;
+ GimpImageType type;
if (layer_name)
g_free (layer_name);
@@ -990,10 +997,12 @@ layers_new_layer_response (GtkWidget *widget,
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (dialog->size_se),
1));
+ type = gimp_image_base_type_with_alpha (dialog->image);
+
layer = gimp_layer_new (dialog->image,
dialog->xsize,
dialog->ysize,
- gimp_image_base_type_with_alpha (dialog->image),
+ gimp_image_get_format (dialog->image, type),
layer_name,
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c
index 8de9757..2be178a 100644
--- a/app/core/gimp-edit.c
+++ b/app/core/gimp-edit.c
@@ -181,7 +181,8 @@ gimp_edit_paste (GimpImage *image,
type = gimp_image_base_type_with_alpha (image);
layer = gimp_layer_new_from_buffer (gimp_buffer_get_buffer (paste),
- image, type,
+ image,
+ gimp_image_get_format (image, type),
_("Pasted Layer"),
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c
index e786579..8df564d 100644
--- a/app/core/gimpchannel.c
+++ b/app/core/gimpchannel.c
@@ -1608,10 +1608,12 @@ gimp_channel_new (GimpImage *image,
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
- channel = GIMP_CHANNEL (gimp_drawable_new (GIMP_TYPE_CHANNEL,
- image, name,
- 0, 0, width, height,
- GIMP_GRAY_IMAGE));
+ channel =
+ GIMP_CHANNEL (gimp_drawable_new (GIMP_TYPE_CHANNEL,
+ image, name,
+ 0, 0, width, height,
+ gimp_image_get_format (image,
+ GIMP_GRAY_IMAGE)));
if (color)
channel->color = *color;
diff --git a/app/core/gimpdrawable-private.h b/app/core/gimpdrawable-private.h
index b9cfe24..d42f93d 100644
--- a/app/core/gimpdrawable-private.h
+++ b/app/core/gimpdrawable-private.h
@@ -20,7 +20,7 @@
struct _GimpDrawablePrivate
{
- GimpImageType type; /* type of drawable */
+ const Babl *format; /* format of drawable */
TileManager *tiles; /* tiles for drawable data */
TileManager *shadow; /* shadow buffer tiles */
diff --git a/app/core/gimpdrawable-transform.c b/app/core/gimpdrawable-transform.c
index 1768d95..9141e77 100644
--- a/app/core/gimpdrawable-transform.c
+++ b/app/core/gimpdrawable-transform.c
@@ -1018,7 +1018,7 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
{
layer =
gimp_layer_new_from_buffer (buffer, image,
- gimp_drawable_type_with_alpha (drawable),
+ gimp_drawable_get_format_with_alpha (drawable),
_("Transformation"),
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index 5f317b1..c7357fe 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -260,8 +260,6 @@ gimp_drawable_init (GimpDrawable *drawable)
drawable->private = G_TYPE_INSTANCE_GET_PRIVATE (drawable,
GIMP_TYPE_DRAWABLE,
GimpDrawablePrivate);
-
- drawable->private->type = -1;
}
/* sorry for the evil casts */
@@ -429,9 +427,9 @@ gimp_drawable_duplicate (GimpItem *item,
{
GimpDrawable *drawable = GIMP_DRAWABLE (item);
GimpDrawable *new_drawable = GIMP_DRAWABLE (new_item);
- GimpImageType image_type = gimp_drawable_type (drawable);
+ const Babl *format = gimp_drawable_get_format (drawable);
- new_drawable->private->type = image_type;
+ new_drawable->private->format = format;
if (new_drawable->private->tiles)
tile_manager_unref (new_drawable->private->tiles);
@@ -823,8 +821,9 @@ gimp_drawable_real_set_tiles (GimpDrawable *drawable,
if (drawable->private->tiles)
tile_manager_unref (drawable->private->tiles);
- drawable->private->tiles = tiles;
- drawable->private->type = type;
+ drawable->private->tiles = tiles;
+ drawable->private->format = gimp_image_get_format (gimp_item_get_image (item),
+ type);
if (drawable->private->buffer)
{
@@ -1188,22 +1187,23 @@ gimp_drawable_new (GType type,
gint offset_y,
gint width,
gint height,
- GimpImageType image_type)
+ const Babl *format)
{
GimpDrawable *drawable;
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (g_type_is_a (type, GIMP_TYPE_DRAWABLE), NULL);
g_return_val_if_fail (width > 0 && height > 0, NULL);
+ g_return_val_if_fail (format != NULL, NULL);
drawable = GIMP_DRAWABLE (gimp_item_new (type,
image, name,
offset_x, offset_y,
width, height));
- drawable->private->type = image_type;
- drawable->private->tiles = tile_manager_new (width, height,
- gimp_drawable_bytes (drawable));
+ drawable->private->format = format;
+ drawable->private->tiles = tile_manager_new (width, height,
+ gimp_drawable_bytes (drawable));
return drawable;
}
@@ -1813,8 +1813,7 @@ gimp_drawable_get_format (const GimpDrawable *drawable)
{
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
- return gimp_image_get_format (gimp_item_get_image (GIMP_ITEM (drawable)),
- gimp_drawable_type (drawable));
+ return drawable->private->format;
}
const Babl *
@@ -1840,15 +1839,37 @@ gimp_drawable_has_alpha (const GimpDrawable *drawable)
{
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
- return GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_drawable_type (drawable));
+ return babl_format_has_alpha (drawable->private->format);
}
GimpImageType
gimp_drawable_type (const GimpDrawable *drawable)
{
+ const Babl *format;
+
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
- return drawable->private->type;
+ format = drawable->private->format;
+
+ if (format == babl_format ("Y u8"))
+ return GIMP_GRAY_IMAGE;
+ else if (format == babl_format ("YA u8"))
+ return GIMP_GRAYA_IMAGE;
+ else if (format == babl_format ("RGB u8"))
+ return GIMP_RGB_IMAGE;
+ else if (format == babl_format ("RGBA u8"))
+ return GIMP_RGBA_IMAGE;
+ else
+ {
+ GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
+
+ if (format == gimp_image_get_format (image, GIMP_INDEXED_IMAGE))
+ return GIMP_INDEXED_IMAGE;
+ if (format == gimp_image_get_format (image, GIMP_INDEXEDA_IMAGE))
+ return GIMP_INDEXEDA_IMAGE;
+ }
+
+ g_return_val_if_reached (-1);
}
GimpImageType
@@ -1896,31 +1917,33 @@ gimp_drawable_bytes (const GimpDrawable *drawable)
{
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
- return GIMP_IMAGE_TYPE_BYTES (drawable->private->type);
+ return babl_format_get_bytes_per_pixel (drawable->private->format);
}
gint
gimp_drawable_bytes_with_alpha (const GimpDrawable *drawable)
{
- GimpImageType type;
+ const Babl *format;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
- type = GIMP_IMAGE_TYPE_WITH_ALPHA (gimp_drawable_type (drawable));
+ format = gimp_image_get_format_with_alpha (gimp_item_get_image (GIMP_ITEM (drawable)),
+ gimp_drawable_type (drawable));
- return GIMP_IMAGE_TYPE_BYTES (type);
+ return babl_format_get_bytes_per_pixel (format);
}
gint
gimp_drawable_bytes_without_alpha (const GimpDrawable *drawable)
{
- GimpImageType type;
+ const Babl *format;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
- type = GIMP_IMAGE_TYPE_WITHOUT_ALPHA (gimp_drawable_type (drawable));
+ format = gimp_image_get_format_without_alpha (gimp_item_get_image (GIMP_ITEM (drawable)),
+ gimp_drawable_type (drawable));
- return GIMP_IMAGE_TYPE_BYTES (type);
+ return babl_format_get_bytes_per_pixel (format);
}
const guchar *
diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h
index 4b5dfe4..a4681e9 100644
--- a/app/core/gimpdrawable.h
+++ b/app/core/gimpdrawable.h
@@ -123,7 +123,7 @@ GimpDrawable * gimp_drawable_new (GType type,
gint offset_y,
gint width,
gint height,
- GimpImageType image_type);
+ const Babl *format);
gint64 gimp_drawable_estimate_memsize (const GimpDrawable *drawable,
gint width,
diff --git a/app/core/gimpgrouplayer.c b/app/core/gimpgrouplayer.c
index 3a31c6d..a7ab0d0 100644
--- a/app/core/gimpgrouplayer.c
+++ b/app/core/gimpgrouplayer.c
@@ -846,10 +846,11 @@ gimp_group_layer_convert_type (GimpDrawable *drawable,
new_type = GIMP_IMAGE_TYPE_WITH_ALPHA (new_type);
/* FIXME: find a better way to do this: need to set the drawable's
- * type to the new values so the projection will create its tiles
+ * format to the new values so the projection will create its tiles
* with the right depth
*/
- drawable->private->type = new_type;
+ drawable->private->format = gimp_image_get_format (gimp_item_get_image (GIMP_ITEM (drawable)),
+ new_type);
gimp_projectable_structure_changed (GIMP_PROJECTABLE (drawable));
@@ -935,7 +936,8 @@ gimp_group_layer_new (GimpImage *image)
group = GIMP_GROUP_LAYER (gimp_drawable_new (GIMP_TYPE_GROUP_LAYER,
image, NULL,
0, 0, 1, 1,
- type));
+ gimp_image_get_format (image,
+ type)));
if (gimp_image_get_projection (image)->use_gegl)
GET_PRIVATE (group)->projection->use_gegl = TRUE;
diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c
index f53cfe0..10067f7 100644
--- a/app/core/gimpimage-merge.c
+++ b/app/core/gimpimage-merge.c
@@ -527,7 +527,7 @@ gimp_image_merge_layers (GimpImage *image,
type = GIMP_IMAGE_TYPE_FROM_BASE_TYPE (gimp_image_base_type (image));
merge_layer = gimp_layer_new (image, (x2 - x1), (y2 - y1),
- type,
+ gimp_image_get_format (image, type),
gimp_object_get_name (layer),
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
if (! merge_layer)
@@ -557,7 +557,7 @@ gimp_image_merge_layers (GimpImage *image,
merge_layer =
gimp_layer_new (image, (x2 - x1), (y2 - y1),
- gimp_drawable_type_with_alpha (GIMP_DRAWABLE (layer)),
+ gimp_drawable_get_format_with_alpha (GIMP_DRAWABLE (layer)),
"merged layer",
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
diff --git a/app/core/gimpimage-new.c b/app/core/gimpimage-new.c
index 48fd5ec..af276ce 100644
--- a/app/core/gimpimage-new.c
+++ b/app/core/gimpimage-new.c
@@ -136,7 +136,8 @@ gimp_image_new_from_template (Gimp *gimp,
break;
}
- layer = gimp_layer_new (image, width, height, type,
+ layer = gimp_layer_new (image, width, height,
+ gimp_image_get_format (image, type),
_("Background"),
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
@@ -297,7 +298,8 @@ gimp_image_new_from_buffer (Gimp *gimp,
}
layer = gimp_layer_new_from_buffer (gimp_buffer_get_buffer (paste),
- image, type,
+ image,
+ gimp_image_get_format (image, type),
_("Pasted Layer"),
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
@@ -341,7 +343,9 @@ gimp_image_new_from_pixbuf (Gimp *gimp,
gimp_image_undo_disable (new_image);
- layer = gimp_layer_new_from_pixbuf (pixbuf, new_image, image_type,
+ layer = gimp_layer_new_from_pixbuf (pixbuf, new_image,
+ gimp_image_get_format (new_image,
+ image_type),
layer_name,
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 4fca49b..d67370d 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -1080,7 +1080,7 @@ GimpLayer *
gimp_layer_new (GimpImage *image,
gint width,
gint height,
- GimpImageType type,
+ const Babl *format,
const gchar *name,
gdouble opacity,
GimpLayerModeEffects mode)
@@ -1090,11 +1090,12 @@ gimp_layer_new (GimpImage *image,
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (width > 0, NULL);
g_return_val_if_fail (height > 0, NULL);
+ g_return_val_if_fail (format != NULL, NULL);
layer = GIMP_LAYER (gimp_drawable_new (GIMP_TYPE_LAYER,
image, name,
0, 0, width, height,
- type));
+ format));
opacity = CLAMP (opacity, GIMP_OPACITY_TRANSPARENT, GIMP_OPACITY_OPAQUE);
@@ -1122,7 +1123,7 @@ gimp_layer_new (GimpImage *image,
GimpLayer *
gimp_layer_new_from_buffer (GeglBuffer *buffer,
GimpImage *dest_image,
- GimpImageType type,
+ const Babl *format,
const gchar *name,
gdouble opacity,
GimpLayerModeEffects mode)
@@ -1132,12 +1133,16 @@ gimp_layer_new_from_buffer (GeglBuffer *buffer,
g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (dest_image), NULL);
+ g_return_val_if_fail (format != NULL, NULL);
+ /* do *not* use the buffer's format because this function gets
+ * buffers of any format passed, and converts them
+ */
layer = gimp_layer_new (dest_image,
gegl_buffer_get_width (buffer),
gegl_buffer_get_height (buffer),
- type, name,
- opacity, mode);
+ format,
+ name, opacity, mode);
dest = gimp_drawable_get_buffer (GIMP_DRAWABLE (layer));
gegl_buffer_copy (buffer, NULL, dest, NULL);
@@ -1163,7 +1168,7 @@ gimp_layer_new_from_buffer (GeglBuffer *buffer,
GimpLayer *
gimp_layer_new_from_pixbuf (GdkPixbuf *pixbuf,
GimpImage *dest_image,
- GimpImageType type,
+ const Babl *format,
const gchar *name,
gdouble opacity,
GimpLayerModeEffects mode)
@@ -1173,12 +1178,11 @@ gimp_layer_new_from_pixbuf (GdkPixbuf *pixbuf,
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (dest_image), NULL);
- g_return_val_if_fail (GIMP_IMAGE_TYPE_BASE_TYPE (type) ==
- gimp_image_base_type (dest_image), NULL);
+ g_return_val_if_fail (format != NULL, NULL);
buffer = gimp_pixbuf_create_buffer (pixbuf);
- layer = gimp_layer_new_from_buffer (buffer, dest_image, type,
+ layer = gimp_layer_new_from_buffer (buffer, dest_image, format,
name, opacity, mode);
g_object_unref (buffer);
diff --git a/app/core/gimplayer.h b/app/core/gimplayer.h
index 11f8245..67d6d7b 100644
--- a/app/core/gimplayer.h
+++ b/app/core/gimplayer.h
@@ -78,20 +78,20 @@ GType gimp_layer_get_type (void) G_GNUC_CONST;
GimpLayer * gimp_layer_new (GimpImage *image,
gint width,
gint height,
- GimpImageType type,
+ const Babl *format,
const gchar *name,
gdouble opacity,
GimpLayerModeEffects mode);
GimpLayer * gimp_layer_new_from_buffer (GeglBuffer *buffer,
GimpImage *dest_image,
- GimpImageType type,
+ const Babl *format,
const gchar *name,
gdouble opacity,
GimpLayerModeEffects mode);
GimpLayer * gimp_layer_new_from_pixbuf (GdkPixbuf *pixbuf,
GimpImage *dest_image,
- GimpImageType type,
+ const Babl *format,
const gchar *name,
gdouble opacity,
GimpLayerModeEffects mode);
diff --git a/app/core/gimplayermask.c b/app/core/gimplayermask.c
index 50d6943..3c507cd 100644
--- a/app/core/gimplayermask.c
+++ b/app/core/gimplayermask.c
@@ -148,7 +148,8 @@ gimp_layer_mask_new (GimpImage *image,
layer_mask = GIMP_LAYER_MASK (gimp_drawable_new (GIMP_TYPE_LAYER_MASK,
image, name,
0, 0, width, height,
- GIMP_GRAY_IMAGE));
+ gimp_image_get_format (image,
+ GIMP_GRAY_IMAGE)));
/* set the layer_mask color and opacity */
gimp_channel_set_color (GIMP_CHANNEL (layer_mask), color, FALSE);
diff --git a/app/core/gimpselection.c b/app/core/gimpselection.c
index 5f20caf..34998f4 100644
--- a/app/core/gimpselection.c
+++ b/app/core/gimpselection.c
@@ -527,7 +527,8 @@ gimp_selection_new (GimpImage *image,
channel = GIMP_CHANNEL (gimp_drawable_new (GIMP_TYPE_SELECTION,
image, NULL,
0, 0, width, height,
- GIMP_GRAY_IMAGE));
+ gimp_image_get_format (image,
+ GIMP_GRAY_IMAGE)));
gimp_channel_set_color (channel, &black, FALSE);
gimp_channel_set_show_masked (channel, TRUE);
@@ -827,7 +828,7 @@ gimp_selection_float (GimpSelection *selection,
* a channel or layer mask
*/
layer = gimp_layer_new_from_buffer (buffer, image,
- gimp_drawable_type_with_alpha (drawable),
+ gimp_drawable_get_format_with_alpha (drawable),
_("Floated Layer"),
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
diff --git a/app/display/gimpdisplayshell-dnd.c b/app/display/gimpdisplayshell-dnd.c
index dde31a6..6187b39 100644
--- a/app/display/gimpdisplayshell-dnd.c
+++ b/app/display/gimpdisplayshell-dnd.c
@@ -677,7 +677,8 @@ gimp_display_shell_drop_pixbuf (GtkWidget *widget,
}
new_layer =
- gimp_layer_new_from_pixbuf (pixbuf, image, image_type,
+ gimp_layer_new_from_pixbuf (pixbuf, image,
+ gimp_image_get_format (image, image_type),
_("Dropped Buffer"),
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
diff --git a/app/pdb/layer-cmds.c b/app/pdb/layer-cmds.c
index f4c2fc5..596676a 100644
--- a/app/pdb/layer-cmds.c
+++ b/app/pdb/layer-cmds.c
@@ -75,8 +75,9 @@ layer_new_invoker (GimpProcedure *procedure,
if (success)
{
- layer = gimp_layer_new (image, width, height, type, name,
- opacity / 100.0, mode);
+ layer = gimp_layer_new (image, width, height,
+ gimp_image_get_format (image, type),
+ name, opacity / 100.0, mode);
if (! layer)
success = FALSE;
@@ -112,13 +113,16 @@ layer_new_from_visible_invoker (GimpProcedure *procedure,
if (success)
{
- GimpPickable *pickable = GIMP_PICKABLE (gimp_image_get_projection (image));
+ GimpPickable *pickable = GIMP_PICKABLE (gimp_image_get_projection (image));
+ GimpImageType type;
gimp_pickable_flush (pickable);
+ type = gimp_image_base_type_with_alpha (dest_image);
+
layer = gimp_layer_new_from_buffer (gimp_pickable_get_buffer (pickable),
dest_image,
- gimp_image_base_type_with_alpha (dest_image),
+ gimp_image_get_format (dest_image, type),
name,
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
}
diff --git a/app/tests/gimp-app-test-utils.c b/app/tests/gimp-app-test-utils.c
index 5947113..4b123b3 100644
--- a/app/tests/gimp-app-test-utils.c
+++ b/app/tests/gimp-app-test-utils.c
@@ -126,7 +126,7 @@ gimp_test_utils_create_image (Gimp *gimp,
layer = gimp_layer_new (image,
width,
height,
- GIMP_RGBA_IMAGE,
+ gimp_image_get_format (image, GIMP_RGBA_IMAGE),
"layer1",
1.0,
GIMP_NORMAL_MODE);
diff --git a/app/text/gimptextlayer-xcf.c b/app/text/gimptextlayer-xcf.c
index f49c18a..61e65f5 100644
--- a/app/text/gimptextlayer-xcf.c
+++ b/app/text/gimptextlayer-xcf.c
@@ -194,8 +194,8 @@ gimp_text_layer_from_layer (GimpLayer *layer,
drawable = GIMP_DRAWABLE (text_layer);
- drawable->private->type = gimp_drawable_type (GIMP_DRAWABLE (layer));
- drawable->private->tiles = gimp_drawable_get_tiles (GIMP_DRAWABLE (layer));
+ drawable->private->format = gimp_drawable_get_format (GIMP_DRAWABLE (layer));
+ drawable->private->tiles = gimp_drawable_get_tiles (GIMP_DRAWABLE (layer));
GIMP_DRAWABLE (layer)->private->tiles = NULL;
gimp_layer_set_opacity (GIMP_LAYER (text_layer),
diff --git a/app/text/gimptextlayer.c b/app/text/gimptextlayer.c
index e207b85..b486247 100644
--- a/app/text/gimptextlayer.c
+++ b/app/text/gimptextlayer.c
@@ -393,7 +393,8 @@ gimp_text_layer_new (GimpImage *image,
layer = GIMP_TEXT_LAYER (gimp_drawable_new (GIMP_TYPE_TEXT_LAYER,
image, NULL,
0, 0, 1, 1,
- type));
+ gimp_image_get_format (image,
+ type)));
gimp_text_layer_set_text (layer, text);
diff --git a/app/widgets/gimplayertreeview.c b/app/widgets/gimplayertreeview.c
index 4f3f9f3..1e7f158 100644
--- a/app/widgets/gimplayertreeview.c
+++ b/app/widgets/gimplayertreeview.c
@@ -790,15 +790,18 @@ gimp_layer_tree_view_drop_pixbuf (GimpContainerTreeView *tree_view,
GimpImage *image = gimp_item_tree_view_get_image (item_view);
GimpLayer *new_layer;
GimpLayer *parent;
+ GimpImageType type;
gint index;
+ type = gimp_image_base_type_with_alpha (image);
+
index = gimp_item_tree_view_get_drop_index (item_view, dest_viewable,
drop_pos,
(GimpViewable **) &parent);
new_layer =
gimp_layer_new_from_pixbuf (pixbuf, image,
- gimp_image_base_type_with_alpha (image),
+ gimp_image_get_format (image, type),
_("Dropped Buffer"),
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
@@ -831,15 +834,18 @@ gimp_layer_tree_view_set_image (GimpItemTreeView *view,
static GimpItem *
gimp_layer_tree_view_item_new (GimpImage *image)
{
- GimpLayer *new_layer;
+ GimpLayer *new_layer;
+ GimpImageType type;
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_EDIT_PASTE,
_("New Layer"));
+ type = gimp_image_base_type_with_alpha (image);
+
new_layer = gimp_layer_new (image,
gimp_image_get_width (image),
gimp_image_get_height (image),
- gimp_image_base_type_with_alpha (image),
+ gimp_image_get_format (image, type),
NULL, 1.0, GIMP_NORMAL_MODE);
gimp_image_add_layer (image, new_layer,
diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c
index 19aeb8d..3007e44 100644
--- a/app/xcf/xcf-load.c
+++ b/app/xcf/xcf-load.c
@@ -865,8 +865,8 @@ xcf_load_layer_props (XcfInfo *info,
gimp_object_set_name (GIMP_OBJECT (group),
gimp_object_get_name (*layer));
- GIMP_DRAWABLE (group)->private->type =
- gimp_drawable_type (GIMP_DRAWABLE (*layer));
+ GIMP_DRAWABLE (group)->private->format =
+ gimp_drawable_get_format (GIMP_DRAWABLE (*layer));
g_object_ref_sink (*layer);
g_object_unref (*layer);
@@ -1108,7 +1108,8 @@ xcf_load_layer (XcfInfo *info,
/* create a new layer */
layer = gimp_layer_new (image, width, height,
- type, name, 255, GIMP_NORMAL_MODE);
+ gimp_image_get_format (image, type),
+ name, 255, GIMP_NORMAL_MODE);
g_free (name);
if (! layer)
return NULL;
diff --git a/tools/pdbgen/pdb/layer.pdb b/tools/pdbgen/pdb/layer.pdb
index 0e85104..9cac746 100644
--- a/tools/pdbgen/pdb/layer.pdb
+++ b/tools/pdbgen/pdb/layer.pdb
@@ -55,8 +55,9 @@ HELP
%invoke = (
code => <<'CODE'
{
- layer = gimp_layer_new (image, width, height, type, name,
- opacity / 100.0, mode);
+ layer = gimp_layer_new (image, width, height,
+ gimp_image_get_format (image, type),
+ name, opacity / 100.0, mode);
if (! layer)
success = FALSE;
@@ -95,13 +96,16 @@ HELP
%invoke = (
code => <<'CODE'
{
- GimpPickable *pickable = GIMP_PICKABLE (gimp_image_get_projection (image));
+ GimpPickable *pickable = GIMP_PICKABLE (gimp_image_get_projection (image));
+ GimpImageType type;
gimp_pickable_flush (pickable);
+ type = gimp_image_base_type_with_alpha (dest_image);
+
layer = gimp_layer_new_from_buffer (gimp_pickable_get_buffer (pickable),
dest_image,
- gimp_image_base_type_with_alpha (dest_image),
+ gimp_image_get_format (dest_image, type),
name,
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]