1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdlib.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "core-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "base/pixel-region.h"
|
|
|
|
#include "base/tile-manager.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
#include "base/tile-manager-crop.h"
|
2001-05-15 19:25:25 +08:00
|
|
|
|
2001-04-07 23:58:26 +08:00
|
|
|
#include "paint-funcs/paint-funcs.h"
|
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "gimp.h"
|
2001-07-04 02:38:56 +08:00
|
|
|
#include "gimpbuffer.h"
|
|
|
|
#include "gimpchannel.h"
|
|
|
|
#include "gimpcontext.h"
|
|
|
|
#include "gimpedit.h"
|
|
|
|
#include "gimpimage.h"
|
|
|
|
#include "gimpimage-mask.h"
|
2001-07-05 23:34:26 +08:00
|
|
|
#include "gimpimage-new.h"
|
2001-07-04 02:38:56 +08:00
|
|
|
#include "gimplayer.h"
|
|
|
|
#include "gimplist.h"
|
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "app_procs.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "floating_sel.h"
|
|
|
|
#include "undo.h"
|
2001-01-22 09:46:28 +08:00
|
|
|
|
1998-11-23 22:47:09 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
TileManager *
|
2001-06-30 03:25:03 +08:00
|
|
|
gimp_edit_cut (GimpImage *gimage,
|
|
|
|
GimpDrawable *drawable)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
TileManager *cut;
|
|
|
|
TileManager *cropped_cut;
|
2001-06-26 20:09:43 +08:00
|
|
|
gboolean empty;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
g_return_val_if_fail (gimage != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
|
|
|
g_return_val_if_fail (drawable != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Start a group undo */
|
|
|
|
undo_push_group_start (gimage, EDIT_CUT_UNDO);
|
|
|
|
|
|
|
|
/* See if the gimage mask is empty */
|
|
|
|
empty = gimage_mask_is_empty (gimage);
|
|
|
|
|
|
|
|
/* Next, cut the mask portion from the gimage */
|
2000-03-27 02:39:03 +08:00
|
|
|
cut = gimage_mask_extract (gimage, drawable, TRUE, FALSE, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
if (cut)
|
2001-07-05 23:34:26 +08:00
|
|
|
gimp_image_new_set_have_current_cut_buffer (gimage->gimp);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Only crop if the gimage mask wasn't empty */
|
2001-06-26 20:09:43 +08:00
|
|
|
if (cut && ! empty)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-06-26 20:09:43 +08:00
|
|
|
cropped_cut = tile_manager_crop (cut, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (cropped_cut != cut)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
|
|
|
tile_manager_destroy (cut);
|
|
|
|
cut = NULL;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else if (cut)
|
|
|
|
cropped_cut = cut;
|
|
|
|
else
|
|
|
|
cropped_cut = NULL;
|
|
|
|
|
|
|
|
/* end the group undo */
|
|
|
|
undo_push_group_end (gimage);
|
|
|
|
|
|
|
|
if (cropped_cut)
|
|
|
|
{
|
|
|
|
/* Free the old global edit buffer */
|
2001-07-05 03:31:35 +08:00
|
|
|
if (gimage->gimp->global_buffer)
|
|
|
|
tile_manager_destroy (gimage->gimp->global_buffer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
/* Set the global edit buffer */
|
2001-07-05 03:31:35 +08:00
|
|
|
gimage->gimp->global_buffer = cropped_cut;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
return cropped_cut;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TileManager *
|
2001-06-30 03:25:03 +08:00
|
|
|
gimp_edit_copy (GimpImage *gimage,
|
|
|
|
GimpDrawable *drawable)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-02-11 05:54:12 +08:00
|
|
|
TileManager *copy;
|
|
|
|
TileManager *cropped_copy;
|
2001-06-26 20:09:43 +08:00
|
|
|
gboolean empty;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
g_return_val_if_fail (gimage != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
|
|
|
g_return_val_if_fail (drawable != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* See if the gimage mask is empty */
|
|
|
|
empty = gimage_mask_is_empty (gimage);
|
|
|
|
|
|
|
|
/* First, copy the masked portion of the gimage */
|
2000-03-27 02:39:03 +08:00
|
|
|
copy = gimage_mask_extract (gimage, drawable, FALSE, FALSE, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
if (copy)
|
2001-07-05 23:34:26 +08:00
|
|
|
gimp_image_new_set_have_current_cut_buffer (gimage->gimp);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Only crop if the gimage mask wasn't empty */
|
2001-06-26 20:09:43 +08:00
|
|
|
if (copy && ! empty)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-06-26 20:09:43 +08:00
|
|
|
cropped_copy = tile_manager_crop (copy, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (cropped_copy != copy)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
|
|
|
tile_manager_destroy (copy);
|
|
|
|
copy = NULL;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else if (copy)
|
|
|
|
cropped_copy = copy;
|
|
|
|
else
|
|
|
|
cropped_copy = NULL;
|
|
|
|
|
|
|
|
if (cropped_copy)
|
|
|
|
{
|
|
|
|
/* Free the old global edit buffer */
|
2001-07-05 03:31:35 +08:00
|
|
|
if (gimage->gimp->global_buffer)
|
|
|
|
tile_manager_destroy (gimage->gimp->global_buffer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
/* Set the global edit buffer */
|
2001-07-05 03:31:35 +08:00
|
|
|
gimage->gimp->global_buffer = cropped_copy;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
return cropped_copy;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-02-11 05:54:12 +08:00
|
|
|
GimpLayer *
|
2001-06-30 03:25:03 +08:00
|
|
|
gimp_edit_paste (GimpImage *gimage,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
TileManager *paste,
|
|
|
|
gboolean paste_into)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-01-29 07:25:25 +08:00
|
|
|
GimpLayer *layer;
|
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
gint cx, cy;
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
g_return_val_if_fail (gimage != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
|
|
|
g_return_val_if_fail (! drawable || GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
|
|
|
|
/* Make a new layer: if drawable == NULL,
|
|
|
|
* user is pasting into an empty image.
|
2000-02-11 05:54:12 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
if (drawable != NULL)
|
2001-01-29 07:25:25 +08:00
|
|
|
layer = gimp_layer_new_from_tiles (gimage,
|
|
|
|
gimp_drawable_type_with_alpha (drawable),
|
|
|
|
paste,
|
|
|
|
_("Pasted Layer"),
|
|
|
|
OPAQUE_OPACITY, NORMAL_MODE);
|
2000-01-16 17:34:45 +08:00
|
|
|
else
|
2001-01-29 07:25:25 +08:00
|
|
|
layer = gimp_layer_new_from_tiles (gimage,
|
|
|
|
gimp_image_base_type_with_alpha (gimage),
|
|
|
|
paste,
|
|
|
|
_("Pasted Layer"),
|
|
|
|
OPAQUE_OPACITY, NORMAL_MODE);
|
2001-03-30 19:16:05 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
if (! layer)
|
|
|
|
return NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
/* Start a group undo */
|
|
|
|
undo_push_group_start (gimage, EDIT_PASTE_UNDO);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
/* Set the offsets to the center of the image */
|
|
|
|
if (drawable != NULL)
|
|
|
|
{
|
|
|
|
gimp_drawable_offsets (drawable, &cx, &cy);
|
|
|
|
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
|
|
|
|
cx += (x1 + x2) >> 1;
|
|
|
|
cy += (y1 + y2) >> 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cx = gimage->width >> 1;
|
|
|
|
cy = gimage->height >> 1;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
GIMP_DRAWABLE (layer)->offset_x = cx - (GIMP_DRAWABLE (layer)->width >> 1);
|
|
|
|
GIMP_DRAWABLE (layer)->offset_y = cy - (GIMP_DRAWABLE (layer)->height >> 1);
|
2001-03-30 19:16:05 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
/* If there is a selection mask clear it--
|
|
|
|
* this might not always be desired, but in general,
|
|
|
|
* it seems like the correct behavior.
|
|
|
|
*/
|
|
|
|
if (! gimage_mask_is_empty (gimage) && ! paste_into)
|
|
|
|
gimp_channel_clear (gimp_image_get_mask (gimage));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
/* if there's a drawable, add a new floating selection */
|
|
|
|
if (drawable != NULL)
|
|
|
|
{
|
|
|
|
floating_sel_attach (layer, drawable);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer), gimage);
|
|
|
|
gimp_image_add_layer (gimage, layer, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
/* end the group undo */
|
|
|
|
undo_push_group_end (gimage);
|
|
|
|
|
|
|
|
return layer;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2000-01-16 17:34:45 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
GimpImage *
|
2001-07-05 03:31:35 +08:00
|
|
|
gimp_edit_paste_as_new (Gimp *gimp,
|
|
|
|
GimpImage *invoke,
|
2001-06-30 03:25:03 +08:00
|
|
|
TileManager *paste)
|
1999-07-07 04:43:52 +08:00
|
|
|
{
|
2001-07-03 07:18:10 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *layer;
|
1999-07-07 04:43:52 +08:00
|
|
|
|
2000-01-01 21:59:58 +08:00
|
|
|
/* create a new image (always of type RGB) */
|
2001-07-06 00:21:36 +08:00
|
|
|
gimage = gimp_create_image (gimp,
|
|
|
|
tile_manager_width (paste),
|
|
|
|
tile_manager_height (paste),
|
|
|
|
RGB,
|
|
|
|
TRUE);
|
2000-12-30 08:16:50 +08:00
|
|
|
gimp_image_undo_disable (gimage);
|
2001-07-03 04:57:58 +08:00
|
|
|
|
|
|
|
if (invoke)
|
|
|
|
{
|
|
|
|
gimp_image_set_resolution (gimage,
|
|
|
|
invoke->xresolution, invoke->yresolution);
|
|
|
|
gimp_image_set_unit (gimage, invoke->unit);
|
|
|
|
}
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-01-29 07:25:25 +08:00
|
|
|
layer = gimp_layer_new_from_tiles (gimage,
|
|
|
|
gimp_image_base_type_with_alpha (gimage),
|
|
|
|
paste,
|
|
|
|
_("Pasted Layer"),
|
|
|
|
OPAQUE_OPACITY, NORMAL_MODE);
|
1999-07-07 04:43:52 +08:00
|
|
|
|
2000-02-11 05:54:12 +08:00
|
|
|
if (layer)
|
2000-01-16 00:32:02 +08:00
|
|
|
{
|
|
|
|
/* add the new layer to the image */
|
|
|
|
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer), gimage);
|
2000-12-30 08:16:50 +08:00
|
|
|
gimp_image_add_layer (gimage, layer, 0);
|
2000-01-02 02:33:40 +08:00
|
|
|
|
2000-12-30 08:16:50 +08:00
|
|
|
gimp_image_undo_enable (gimage);
|
2000-01-02 02:33:40 +08:00
|
|
|
|
2001-07-06 00:21:36 +08:00
|
|
|
gimp_create_display (gimp, gimage);
|
1999-07-07 04:43:52 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
return gimage;
|
2000-01-16 00:32:02 +08:00
|
|
|
}
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
return NULL;
|
1999-07-07 04:43:52 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-06-30 09:14:36 +08:00
|
|
|
gboolean
|
2001-06-30 03:25:03 +08:00
|
|
|
gimp_edit_clear (GimpImage *gimage,
|
|
|
|
GimpDrawable *drawable)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
TileManager *buf_tiles;
|
2000-02-11 05:54:12 +08:00
|
|
|
PixelRegion bufPR;
|
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
guchar col[MAX_CHANNELS];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
g_return_val_if_fail (gimage != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (drawable != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-12-30 08:16:50 +08:00
|
|
|
gimp_image_get_background (gimage, drawable, col);
|
2001-01-15 05:11:52 +08:00
|
|
|
if (gimp_drawable_has_alpha (drawable))
|
|
|
|
col [gimp_drawable_bytes (drawable) - 1] = OPAQUE_OPACITY;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-15 05:11:52 +08:00
|
|
|
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (!(x2 - x1) || !(y2 - y1))
|
2000-01-23 01:53:23 +08:00
|
|
|
return TRUE; /* nothing to do, but the clear succeded */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-15 05:11:52 +08:00
|
|
|
buf_tiles = tile_manager_new ((x2 - x1), (y2 - y1),
|
|
|
|
gimp_drawable_bytes (drawable));
|
1997-11-25 06:05:25 +08:00
|
|
|
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), TRUE);
|
|
|
|
color_region (&bufPR, col);
|
|
|
|
|
|
|
|
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE);
|
2001-06-26 20:09:43 +08:00
|
|
|
gimp_image_apply_image (gimage, drawable, &bufPR, TRUE, OPAQUE_OPACITY,
|
2000-12-30 08:16:50 +08:00
|
|
|
ERASE_MODE, NULL, x1, y1);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* update the image */
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_drawable_update (drawable,
|
|
|
|
x1, y1,
|
|
|
|
(x2 - x1), (y2 - y1));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* free the temporary tiles */
|
|
|
|
tile_manager_destroy (buf_tiles);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1998-06-30 09:14:36 +08:00
|
|
|
gboolean
|
2001-06-30 03:25:03 +08:00
|
|
|
gimp_edit_fill (GimpImage *gimage,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpFillType fill_type)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
TileManager *buf_tiles;
|
2000-02-11 05:54:12 +08:00
|
|
|
PixelRegion bufPR;
|
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
guchar col[MAX_CHANNELS];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
g_return_val_if_fail (gimage != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
|
|
|
g_return_val_if_fail (drawable != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-15 05:11:52 +08:00
|
|
|
if (gimp_drawable_has_alpha (drawable))
|
|
|
|
col [gimp_drawable_bytes (drawable) - 1] = OPAQUE_OPACITY;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-03-24 22:54:59 +08:00
|
|
|
switch (fill_type)
|
|
|
|
{
|
|
|
|
case FOREGROUND_FILL:
|
2000-12-30 08:16:50 +08:00
|
|
|
gimp_image_get_foreground (gimage, drawable, col);
|
2000-03-24 22:54:59 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BACKGROUND_FILL:
|
2000-12-30 08:16:50 +08:00
|
|
|
gimp_image_get_background (gimage, drawable, col);
|
2000-03-24 22:54:59 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WHITE_FILL:
|
2001-03-30 19:16:05 +08:00
|
|
|
col[RED_PIX] = 255;
|
2000-03-24 22:54:59 +08:00
|
|
|
col[GREEN_PIX] = 255;
|
2001-03-30 19:16:05 +08:00
|
|
|
col[BLUE_PIX] = 255;
|
2000-03-24 22:54:59 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TRANSPARENT_FILL:
|
2001-03-30 19:16:05 +08:00
|
|
|
col[RED_PIX] = 0;
|
2000-03-24 22:54:59 +08:00
|
|
|
col[GREEN_PIX] = 0;
|
2001-03-30 19:16:05 +08:00
|
|
|
col[BLUE_PIX] = 0;
|
2001-01-15 05:11:52 +08:00
|
|
|
if (gimp_drawable_has_alpha (drawable))
|
|
|
|
col [gimp_drawable_bytes (drawable) - 1] = TRANSPARENT_OPACITY;
|
2000-03-24 22:54:59 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NO_FILL:
|
|
|
|
return TRUE; /* nothing to do, but the fill succeded */
|
|
|
|
|
|
|
|
default:
|
2001-03-30 19:16:05 +08:00
|
|
|
g_warning ("%s(): unknown fill type", G_GNUC_FUNCTION);
|
2000-12-30 08:16:50 +08:00
|
|
|
gimp_image_get_background (gimage, drawable, col);
|
2000-03-24 22:54:59 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-01-15 05:11:52 +08:00
|
|
|
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (!(x2 - x1) || !(y2 - y1))
|
2000-01-23 01:53:23 +08:00
|
|
|
return TRUE; /* nothing to do, but the fill succeded */
|
2001-03-30 19:16:05 +08:00
|
|
|
|
2001-01-15 05:11:52 +08:00
|
|
|
buf_tiles = tile_manager_new ((x2 - x1), (y2 - y1),
|
|
|
|
gimp_drawable_bytes (drawable));
|
1997-11-25 06:05:25 +08:00
|
|
|
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), TRUE);
|
|
|
|
color_region (&bufPR, col);
|
|
|
|
|
|
|
|
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE);
|
2001-06-26 20:09:43 +08:00
|
|
|
gimp_image_apply_image (gimage, drawable, &bufPR, TRUE, OPAQUE_OPACITY,
|
2000-12-30 08:16:50 +08:00
|
|
|
NORMAL_MODE, NULL, x1, y1);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* update the image */
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_drawable_update (drawable,
|
|
|
|
x1, y1,
|
|
|
|
(x2 - x1), (y2 - y1));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* free the temporary tiles */
|
|
|
|
tile_manager_destroy (buf_tiles);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|