Commit 9b8bf8de authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

made gimp->global_buffer a GimpBuffer, not TileManager.

2001-12-13  Michael Natterer  <mitch@gimp.org>

	* app/core/gimp.[ch]: made gimp->global_buffer a GimpBuffer,
	not TileManager.

	* app/core/gimpbuffer.[ch]: added a "gboolean copy_pixels" to
	gimp_buffer_new().

	* app/core/gimpimage-new.c
	* app/core/gimpedit.[ch]
	* app/core/gimpimage-qmask.c
	* app/widgets/gimpbufferpreview.c
	* app/widgets/gimpbufferview.c
	* app/widgets/gimpcontainerview-utils.c: chaned accordingly, don't
	include "base/tile-manager.h".

	* app/core/gimpdrawable.[ch]: added gimp_drawable_copy().

	* app/core/gimpchannel.[ch]
	* app/core/gimplayer.[ch]
	* app/core/gimplayermask.[ch]: use it in
	gimp_[channel|layer|layer_mask]_copy(), added "GType new_type" as
	paramater to all of them.

	* app/core/gimpimage-duplicate.c
	* app/gui/channels-commands.c
	* app/gui/edit-commands.c
	* app/gui/layers-commands.c
	* app/widgets/gimpchannellistview.c
	* tools/pdbgen/pdb/channel.pdb
	* tools/pdbgen/pdb/layer.pdb
	* tools/pdbgen/pdb/selection.pdb: changed accordingly.

	* app/pdb/channel_cmds.c
	* app/pdb/layer_cmds.c
	* app/pdb/selection_cmds.c: regenerated.

	* app/core/gimplayer.[ch]: removed the "layer_type" parameter from
	gimp_layer_new_from_tiles() because it always needed to be equal
	to gimp_image_base_type_with_alpha() of the passed image.

	* app/core/gimpdrawable-transform.c
	* app/core/gimpedit.c
	* app/core/gimpimage-mask.c: cahanged accordingly.

	* app/core/gimpimage.[ch]: added some new GIMP_IMAGE_TYPE_FOO()
	marcos to get rid of magic values like "pixels = 3" all over the
	place.

	* app/core/gimplayer.[ch]: added gimp_layer_new_from_drawable()
	which creates a layer from an other image's drawable.

	* app/core/gimpimage-convert.[ch]: made the RGB and GRAY converters
	public to use them above, use the new GIMP_IMAGE_TYPE() macros.

	* app/display/gimpdisplayshell-dnd.c
	* app/gui/toolbox.c: removed tile manager stuff and use the new
	functions.

	* app/widgets/gimpdrawablelistview.[ch]: added a
	"convert_drawable_func" which is used to handle drops from other
	images.

	* app/widgets/gimpdrawablelistitem.c
	* app/widgets/gimplayerlistitem.c
	* app/widgets/gimplistitem.[ch]: implemented DND of layers between
	images using gimp_layer_new_from_drawable().

	* app/gui/dialogs-constructors.c: changed accordingly.
parent 6b21e2a7
2001-12-13 Michael Natterer <mitch@gimp.org>
* app/core/gimp.[ch]: made gimp->global_buffer a GimpBuffer,
not TileManager.
* app/core/gimpbuffer.[ch]: added a "gboolean copy_pixels" to
gimp_buffer_new().
* app/core/gimpimage-new.c
* app/core/gimpedit.[ch]
* app/core/gimpimage-qmask.c
* app/widgets/gimpbufferpreview.c
* app/widgets/gimpbufferview.c
* app/widgets/gimpcontainerview-utils.c: chaned accordingly, don't
include "base/tile-manager.h".
* app/core/gimpdrawable.[ch]: added gimp_drawable_copy().
* app/core/gimpchannel.[ch]
* app/core/gimplayer.[ch]
* app/core/gimplayermask.[ch]: use it in
gimp_[channel|layer|layer_mask]_copy(), added "GType new_type" as
paramater to all of them.
* app/core/gimpimage-duplicate.c
* app/gui/channels-commands.c
* app/gui/edit-commands.c
* app/gui/layers-commands.c
* app/widgets/gimpchannellistview.c
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb
* tools/pdbgen/pdb/selection.pdb: changed accordingly.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c
* app/pdb/selection_cmds.c: regenerated.
* app/core/gimplayer.[ch]: removed the "layer_type" parameter from
gimp_layer_new_from_tiles() because it always needed to be equal
to gimp_image_base_type_with_alpha() of the passed image.
* app/core/gimpdrawable-transform.c
* app/core/gimpedit.c
* app/core/gimpimage-mask.c: cahanged accordingly.
* app/core/gimpimage.[ch]: added some new GIMP_IMAGE_TYPE_FOO()
marcos to get rid of magic values like "pixels = 3" all over the
place.
* app/core/gimplayer.[ch]: added gimp_layer_new_from_drawable()
which creates a layer from an other image's drawable.
* app/core/gimpimage-convert.[ch]: made the RGB and GRAY converters
public to use them above, use the new GIMP_IMAGE_TYPE() macros.
* app/display/gimpdisplayshell-dnd.c
* app/gui/toolbox.c: removed tile manager stuff and use the new
functions.
* app/widgets/gimpdrawablelistview.[ch]: added a
"convert_drawable_func" which is used to handle drops from other
images.
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplistitem.[ch]: implemented DND of layers between
images using gimp_layer_new_from_drawable().
* app/gui/dialogs-constructors.c: changed accordingly.
2001-12-12 Michael Natterer <mitch@gimp.org>
* app/core/Makefile.am
......
......@@ -109,7 +109,9 @@ channels_duplicate_channel_cmd_callback (GtkWidget *widget,
if ((active_channel = gimp_image_get_active_channel (gimage)))
{
new_channel = gimp_channel_copy (active_channel, TRUE);
new_channel = gimp_channel_copy (active_channel,
G_TYPE_FROM_INSTANCE (active_channel),
TRUE);
gimp_image_add_channel (gimage, new_channel, -1);
gdisplays_flush ();
}
......@@ -168,7 +170,9 @@ channels_add_channel_to_sel_cmd_callback (GtkWidget *widget,
if ((active_channel = gimp_image_get_active_channel (gimage)))
{
new_channel = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
new_channel = gimp_channel_copy (gimp_image_get_mask (gimage),
G_TYPE_FROM_INSTANCE (gimp_image_get_mask (gimage)),
TRUE);
gimp_channel_combine_mask (new_channel,
active_channel,
CHANNEL_OP_ADD,
......@@ -194,7 +198,9 @@ channels_sub_channel_from_sel_cmd_callback (GtkWidget *widget,
if ((active_channel = gimp_image_get_active_channel (gimage)))
{
new_channel = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
new_channel = gimp_channel_copy (gimp_image_get_mask (gimage),
G_TYPE_FROM_INSTANCE (gimp_image_get_mask (gimage)),
TRUE);
gimp_channel_combine_mask (new_channel,
active_channel,
CHANNEL_OP_SUB,
......@@ -220,7 +226,9 @@ channels_intersect_channel_with_sel_cmd_callback (GtkWidget *widget,
if ((active_channel = gimp_image_get_active_channel (gimage)))
{
new_channel = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
new_channel = gimp_channel_copy (gimp_image_get_mask (gimage),
G_TYPE_FROM_INSTANCE (gimp_image_get_mask (gimage)),
TRUE);
gimp_channel_combine_mask (new_channel,
active_channel,
CHANNEL_OP_INTERSECT,
......
......@@ -277,20 +277,22 @@ cut_named_buffer_callback (GtkWidget *widget,
gchar *name,
gpointer data)
{
TileManager *new_tiles;
GimpImage *gimage;
GimpBuffer *cut_buffer;
GimpImage *gimage;
gimage = (GimpImage *) data;
new_tiles = gimp_edit_cut (gimage,
gimp_image_active_drawable (gimage));
if (new_tiles)
cut_buffer = gimp_edit_cut (gimage,
gimp_image_active_drawable (gimage));
if (cut_buffer)
{
GimpBuffer *buffer;
GimpBuffer *new_buffer;
new_buffer = gimp_buffer_new (cut_buffer->tiles, name, TRUE);
buffer = gimp_buffer_new (new_tiles, name);
gimp_container_add (gimage->gimp->named_buffers, GIMP_OBJECT (buffer));
gimp_container_add (gimage->gimp->named_buffers,
GIMP_OBJECT (new_buffer));
}
gdisplays_flush ();
......@@ -301,19 +303,21 @@ copy_named_buffer_callback (GtkWidget *widget,
gchar *name,
gpointer data)
{
TileManager *new_tiles;
GimpImage *gimage;
GimpBuffer *copy_buffer;
GimpImage *gimage;
gimage = (GimpImage *) data;
new_tiles = gimp_edit_copy (gimage,
gimp_image_active_drawable (gimage));
copy_buffer = gimp_edit_copy (gimage,
gimp_image_active_drawable (gimage));
if (new_tiles)
if (copy_buffer)
{
GimpBuffer *buffer;
GimpBuffer *new_buffer;
new_buffer = gimp_buffer_new (copy_buffer->tiles, name, TRUE);
buffer = gimp_buffer_new (new_tiles, name);
gimp_container_add (gimage->gimp->named_buffers, GIMP_OBJECT (buffer));
gimp_container_add (gimage->gimp->named_buffers,
GIMP_OBJECT (new_buffer));
}
}
......@@ -28,8 +28,6 @@
#include "gui-types.h"
#include "paint-funcs/paint-funcs.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpdrawable-desaturate.h"
......@@ -190,7 +188,9 @@ layers_duplicate_cmd_callback (GtkWidget *widget,
return_if_no_image (gimage);
active_layer = gimp_image_get_active_layer (gimage);
new_layer = gimp_layer_copy (active_layer, TRUE);
new_layer = gimp_layer_copy (active_layer,
G_TYPE_FROM_INSTANCE (active_layer),
TRUE);
gimp_image_add_layer (gimage, new_layer, -1);
gdisplays_flush ();
......
......@@ -47,7 +47,7 @@
#include "libgimp/gimpintl.h"
TileManager *
GimpBuffer *
gimp_edit_cut (GimpImage *gimage,
GimpDrawable *drawable)
{
......@@ -93,16 +93,18 @@ gimp_edit_cut (GimpImage *gimage,
{
/* Free the old global edit buffer */
if (gimage->gimp->global_buffer)
tile_manager_destroy (gimage->gimp->global_buffer);
g_object_unref (G_OBJECT (gimage->gimp->global_buffer));
/* Set the global edit buffer */
gimage->gimp->global_buffer = cropped_cut;
gimage->gimp->global_buffer = gimp_buffer_new (cropped_cut,
"Global Buffer",
TRUE);
}
return cropped_cut;
return gimp_buffer_new (cropped_cut, "Cut Pixels", FALSE);
}
TileManager *
GimpBuffer *
gimp_edit_copy (GimpImage *gimage,
GimpDrawable *drawable)
{
......@@ -142,19 +144,21 @@ gimp_edit_copy (GimpImage *gimage,
{
/* Free the old global edit buffer */
if (gimage->gimp->global_buffer)
tile_manager_destroy (gimage->gimp->global_buffer);
g_object_unref (G_OBJECT (gimage->gimp->global_buffer));
/* Set the global edit buffer */
gimage->gimp->global_buffer = cropped_copy;
gimage->gimp->global_buffer = gimp_buffer_new (cropped_copy,
"Global Buffer",
TRUE);
}
return cropped_copy;
return gimp_buffer_new (cropped_copy, "Copied Pixels", FALSE);
}
GimpLayer *
gimp_edit_paste (GimpImage *gimage,
GimpDrawable *drawable,
TileManager *paste,
GimpBuffer *paste,
gboolean paste_into)
{
GimpLayer *layer;
......@@ -170,14 +174,12 @@ gimp_edit_paste (GimpImage *gimage,
if (drawable != NULL)
layer = gimp_layer_new_from_tiles (gimage,
gimp_drawable_type_with_alpha (drawable),
paste,
paste->tiles,
_("Pasted Layer"),
OPAQUE_OPACITY, GIMP_NORMAL_MODE);
else
layer = gimp_layer_new_from_tiles (gimage,
gimp_image_base_type_with_alpha (gimage),
paste,
paste->tiles,
_("Pasted Layer"),
OPAQUE_OPACITY, GIMP_NORMAL_MODE);
......@@ -188,7 +190,7 @@ gimp_edit_paste (GimpImage *gimage,
undo_push_group_start (gimage, EDIT_PASTE_UNDO);
/* Set the offsets to the center of the image */
if (drawable != NULL)
if (drawable)
{
gimp_drawable_offsets (drawable, &cx, &cy);
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
......@@ -229,17 +231,17 @@ gimp_edit_paste (GimpImage *gimage,
}
GimpImage *
gimp_edit_paste_as_new (Gimp *gimp,
GimpImage *invoke,
TileManager *paste)
gimp_edit_paste_as_new (Gimp *gimp,
GimpImage *invoke,
GimpBuffer *paste)
{
GimpImage *gimage;
GimpLayer *layer;
/* create a new image (always of type GIMP_RGB) */
gimage = gimp_create_image (gimp,
tile_manager_width (paste),
tile_manager_height (paste),
gimp_buffer_get_width (paste),
gimp_buffer_get_height (paste),
GIMP_RGB,
TRUE);
gimp_image_undo_disable (gimage);
......@@ -252,8 +254,7 @@ gimp_edit_paste_as_new (Gimp *gimp,
}
layer = gimp_layer_new_from_tiles (gimage,
gimp_image_base_type_with_alpha (gimage),
paste,
paste->tiles,
_("Pasted Layer"),
OPAQUE_OPACITY, GIMP_NORMAL_MODE);
......
......@@ -20,22 +20,22 @@
#define __GIMP_EDIT_H__
TileManager * gimp_edit_cut (GimpImage *gimage,
GimpDrawable *drawable);
TileManager * gimp_edit_copy (GimpImage *gimage,
GimpDrawable *drawable);
GimpLayer * gimp_edit_paste (GimpImage *gimage,
GimpDrawable *drawable,
TileManager *paste,
gboolean paste_into);
GimpImage * gimp_edit_paste_as_new (Gimp *gimp,
GimpImage *gimage,
TileManager *tiles);
gboolean gimp_edit_clear (GimpImage *gimage,
GimpDrawable *drawable);
gboolean gimp_edit_fill (GimpImage *gimage,
GimpDrawable *drawable,
GimpFillType fill_type);
GimpBuffer * gimp_edit_cut (GimpImage *gimage,
GimpDrawable *drawable);
GimpBuffer * gimp_edit_copy (GimpImage *gimage,
GimpDrawable *drawable);
GimpLayer * gimp_edit_paste (GimpImage *gimage,
GimpDrawable *drawable,
GimpBuffer *paste,
gboolean paste_into);
GimpImage * gimp_edit_paste_as_new (Gimp *gimp,
GimpImage *gimage,
GimpBuffer *paste);
gboolean gimp_edit_clear (GimpImage *gimage,
GimpDrawable *drawable);
gboolean gimp_edit_fill (GimpImage *gimage,
GimpDrawable *drawable,
GimpFillType fill_type);
#endif /* __GIMP_EDIT_H__ */
......@@ -738,7 +738,6 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
{
layer =
gimp_layer_new_from_tiles (gimage,
gimp_drawable_type_with_alpha (drawable),
tiles,
_("Transformation"),
OPAQUE_OPACITY, GIMP_NORMAL_MODE);
......
......@@ -27,8 +27,6 @@
#include "core-types.h"
#include "pdb/pdb-types.h"
#include "base/tile-manager.h"
#include "pdb/procedural_db.h"
#include "pdb/internal_procs.h"
......@@ -285,7 +283,7 @@ gimp_finalize (GObject *object)
if (gimp->global_buffer)
{
tile_manager_destroy (gimp->global_buffer);
g_object_unref (G_OBJECT (gimp->global_buffer));
gimp->global_buffer = NULL;
}
......
......@@ -82,7 +82,7 @@ struct _Gimp
gint next_drawable_ID;
GHashTable *drawable_table;
TileManager *global_buffer;
GimpBuffer *global_buffer;
GimpContainer *named_buffers;
GimpDataFactory *brush_factory;
......
......@@ -162,7 +162,8 @@ gimp_buffer_get_new_preview (GimpViewable *viewable,
GimpBuffer *
gimp_buffer_new (TileManager *tiles,
const gchar *name)
const gchar *name,
gboolean copy_pixels)
{
GimpBuffer *buffer;
PixelRegion srcPR, destPR;
......@@ -178,11 +179,34 @@ gimp_buffer_new (TileManager *tiles,
gimp_object_set_name (GIMP_OBJECT (buffer), name);
buffer->tiles = tile_manager_new (width, height, tile_manager_bpp (tiles));
if (copy_pixels)
{
buffer->tiles = tile_manager_new (width, height, tile_manager_bpp (tiles));
pixel_region_init (&srcPR, tiles, 0, 0, width, height, FALSE);
pixel_region_init (&destPR, buffer->tiles, 0, 0, width, height, TRUE);
copy_region (&srcPR, &destPR);
pixel_region_init (&srcPR, tiles, 0, 0, width, height, FALSE);
pixel_region_init (&destPR, buffer->tiles, 0, 0, width, height, TRUE);
copy_region (&srcPR, &destPR);
}
else
{
buffer->tiles = tiles;
}
return GIMP_BUFFER (buffer);
}
gint
gimp_buffer_get_width (GimpBuffer *buffer)
{
g_return_val_if_fail (GIMP_IS_BUFFER (buffer), 0);
return tile_manager_width (buffer->tiles);
}
gint
gimp_buffer_get_height (GimpBuffer *buffer)
{
g_return_val_if_fail (GIMP_IS_BUFFER (buffer), 0);
return tile_manager_height (buffer->tiles);
}
......@@ -46,10 +46,14 @@ struct _GimpBufferClass
};
GType gimp_buffer_get_type (void) G_GNUC_CONST;
GType gimp_buffer_get_type (void) G_GNUC_CONST;
GimpBuffer * gimp_buffer_new (TileManager *tiles,
const gchar *name);
GimpBuffer * gimp_buffer_new (TileManager *tiles,
const gchar *name,
gboolean copy_pixels);
gint gimp_buffer_get_width (GimpBuffer *buffer);
gint gimp_buffer_get_height (GimpBuffer *buffer);
#endif /* __GIMP_BUFFER_H__ */
......@@ -118,7 +118,6 @@ gimp_channel_init (GimpChannel *channel)
channel->y1 = 0;
channel->x2 = 0;
channel->y2 = 0;
}
static void
......@@ -171,19 +170,20 @@ gimp_channel_new (GimpImage *gimage,
gimage, width, height, GIMP_GRAY_IMAGE, name);
/* set the channel color and opacity */
channel->color = *color;
channel->color = *color;
channel->show_masked = TRUE;
/* selection mask variables */
channel->x2 = width;
channel->y2 = height;
channel->x2 = width;
channel->y2 = height;
return channel;
}
GimpChannel *
gimp_channel_copy (const GimpChannel *channel,
GType new_type,
gboolean dummy) /* the dummy is for symmetry with
* gimp_layer_copy() because
* both functions are used as
......@@ -191,55 +191,23 @@ gimp_channel_copy (const GimpChannel *channel,
* GimpDrawableListView --Mitch
*/
{
gchar *channel_name;
GimpChannel *new_channel;
PixelRegion srcPR, destPR;
gchar *ext;
gint number;
const gchar *name;
gint len;
/* formulate the new channel name */
name = gimp_object_get_name (GIMP_OBJECT (channel));
ext = strrchr (name, '#');
len = strlen (_("copy"));
if ((strlen (name) >= len &&
strcmp (&name[strlen (name) - len], _("copy")) == 0) ||
(ext && (number = atoi (ext + 1)) > 0 &&
((int)(log10 (number) + 1)) == strlen (ext + 1)))
/* don't have redundant "copy"s */
channel_name = g_strdup (name);
else
channel_name = g_strdup_printf (_("%s copy"), name);
/* allocate a new channel object */
new_channel = gimp_channel_new (GIMP_DRAWABLE (channel)->gimage,
GIMP_DRAWABLE (channel)->width,
GIMP_DRAWABLE (channel)->height,
channel_name,
&channel->color);
GIMP_DRAWABLE (new_channel)->visible = GIMP_DRAWABLE (channel)->visible;
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL);
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_CHANNEL), NULL);
new_channel->show_masked = channel->show_masked;
new_channel = GIMP_CHANNEL (gimp_drawable_copy (GIMP_DRAWABLE (channel),
new_type,
FALSE));
/* copy the contents across channels */
pixel_region_init (&srcPR, GIMP_DRAWABLE (channel)->tiles, 0, 0,
GIMP_DRAWABLE (channel)->width,
GIMP_DRAWABLE (channel)->height, FALSE);
pixel_region_init (&destPR, GIMP_DRAWABLE (new_channel)->tiles,
0, 0,
GIMP_DRAWABLE (channel)->width,
GIMP_DRAWABLE (channel)->height, TRUE);
copy_region (&srcPR, &destPR);
/* set the channel color and opacity */
new_channel->color = channel->color;
/* copy the parasites */
GIMP_DRAWABLE (new_channel)->parasites =
gimp_parasite_list_copy (GIMP_DRAWABLE (channel)->parasites);
new_channel->show_masked = channel->show_masked;
/* free up the channel_name memory */
g_free (channel_name);
/* selection mask variables */
new_channel->x2 = gimp_drawable_width (GIMP_DRAWABLE (new_channel));
new_channel->y2 = gimp_drawable_height (GIMP_DRAWABLE (new_channel));
return new_channel;
}
......
......@@ -92,6 +92,7 @@ GimpChannel * gimp_channel_new (GimpImage *gimage,
const gchar *name,
const GimpRGB *color);
GimpChannel * gimp_channel_copy (const GimpChannel *channel,
GType new_type,
gboolean dummy);
gint gimp_channel_get_opacity (const GimpChannel *channel);
......
......@@ -118,7 +118,6 @@ gimp_channel_init (GimpChannel *channel)
channel->y1 = 0;
channel->x2 = 0;
channel->y2 = 0;
}
static void
......@@ -171,19 +170,20 @@ gimp_channel_new (GimpImage *gimage,
gimage, width, height, GIMP_GRAY_IMAGE, name);
/* set the channel color and opacity */
channel->color = *color;
channel->color = *color;
channel->show_masked = TRUE;
/* selection mask variables */
channel->x2 = width;
channel->y2 = height;
channel->x2 = width;
channel->y2 = height;
return channel;
}
GimpChannel *
gimp_channel_copy (const GimpChannel *channel,
GType new_type,
gboolean dummy) /* the dummy is for symmetry with
* gimp_layer_copy() because
* both functions are used as
......@@ -191,55 +191,23 @@ gimp_channel_copy (const GimpChannel *channel,
* GimpDrawableListView --Mitch
*/
{
gchar *channel_name;
GimpChannel *new_channel;
PixelRegion srcPR, destPR;
gchar *ext;
gint number;
const gchar *name;
gint len;
/* formulate the new channel name */
name = gimp_object_get_name (GIMP_OBJECT (channel));
ext = strrchr (name, '#');
len = strlen (_("copy"));
if ((strlen (name) >= len &&
strcmp (&name[strlen (name) - len], _("copy")) == 0) ||
(ext && (number = atoi (ext + 1)) > 0 &&
((int)(log10 (number) + 1)) == strlen (ext + 1)))
/* don't have redundant "copy"s */
channel_name = g_strdup (name);
else
channel_name = g_strdup_printf (_("%s copy"), name);
/* allocate a new channel object */
new_channel = gimp_channel_new (GIMP_DRAWABLE (channel)->gimage,
GIMP_DRAWABLE (channel)->width,
GIMP_DRAWABLE (channel)->height,
channel_name,
&channel->color);
GIMP_DRAWABLE (new_channel)->visible = GIMP_DRAWABLE (channel)->visible;
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL);
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_CHANNEL), NULL);
new_channel->show_masked = channel->show_masked;
new_channel = GIMP_CHANNEL (gimp_drawable_copy (GIMP_DRAWABLE (channel),
new_type,
FALSE));
/* copy the contents across channels */
pixel_region_init (&srcPR, GIMP_DRAWABLE (channel)->tiles, 0, 0,
GIMP_DRAWABLE (channel)->width,
GIMP_DRAWABLE (channel)->height, FALSE);
pixel_region_init (&destPR, GIMP_DRAWABLE (new_channel)->tiles,
0, 0,
GIMP_DRAWABLE (channel)->width,
GIMP_DRAWABLE (channel)->height, TRUE);
copy_region (&srcPR, &destPR);
/* set the channel color and opacity */
new_channel->color = channel->color;
/* copy the parasites */
GIMP_DRAWABLE (new_channel)->parasites =
gimp_parasite_list_copy (GIMP_DRAWABLE (channel)->parasites);
new_channel->show_masked = channel->show_masked;
/* free up the channel_name memory */
g_free (channel_name);
/* selection mask variables */
new_channel->x2 = gimp_drawable_width (GIMP_DRAWABLE (new_channel));
new_channel->y2 = gimp_drawable_height (GIMP_DRAWABLE (new_channel));
return new_channel;
}
......
......@@ -92,6 +92,7 @@ GimpChannel * gimp_channel_new (GimpImage *gimage,
const gchar *name,
const GimpRGB *color);
GimpChannel * gimp_channel_copy (const GimpChannel *channel,
GType new_type,
gboolean dummy);
gint gimp_channel_get_opacity (const GimpChannel *channel);
......
......@@ -738,7 +738,6 @@ gimp_drawable_transform_paste (GimpDrawable *drawable,
{
layer =
gimp_layer_new_from_tiles (gimage,
gimp_drawable_type_with_alpha (drawable),
tiles,
_("Transformation"),
OPAQUE_OPACITY, GIMP_NORMAL_MODE);
......
......@@ -331,53 +331,29 @@ gimp_drawable_configure (GimpDrawable *drawable,
GimpImageType type,
const gchar *name)
{
gint bpp;
gboolean alpha;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (name != NULL);
drawable->ID = gimage->gimp->next_drawable_ID++;
g_hash_table_insert (gimage->gimp->drawable_table,
GINT_TO_POINTER (drawable->ID),
(gpointer) drawable);
if (!name)
name = _("Unnamed");
switch (type)
{
case GIMP_RGB_IMAGE:
bpp = 3; alpha = FALSE; break;
case GIMP_GRAY_IMAGE:
bpp = 1; alpha = FALSE; break;
case GIMP_RGBA_IMAGE:
bpp = 4; alpha = TRUE; break;
case GIMP_GRAYA_IMAGE:
bpp = 2; alpha = TRUE; break;
case GIMP_INDEXED_IMAGE:
bpp = 1; alpha = FALSE; break;
case GIMP_INDEXEDA_IMAGE: