Commit cb48cef8 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

added gimp_drawable_mask_intersect() which returns the same bounding box

2004-10-20  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpdrawable.[ch]: added gimp_drawable_mask_intersect()
	which returns the same bounding box as gimp_drawable_mask_bounds(),
	but returns TRUE only if there is a non-empty intersection between
	the drawable and the selection, or no selection at all. It also
	returns the intersection as x,y,width,height instead of the
	eeky x1,y1,x2,y2.

	* app/core/gimp-edit.c
	* app/core/gimpdrawable-blend.c
	* app/core/gimpdrawable-bucket-fill.c
	* app/core/gimpdrawable-desaturate.c
	* app/core/gimpdrawable-equalize.c
	* app/core/gimpdrawable-histogram.c
	* app/core/gimpdrawable-invert.c
	* app/core/gimpdrawable-stroke.c
	* app/core/gimpimagemap.c
	* app/core/gimpselection.c
	* tools/pdbgen/pdb/color.pdb
	* tools/pdbgen/pdb/transform_tools.pdb: either switch from
	gimp_drawable_mask_bounds() to _intersect() or check the return
	values of _mask_bounds() manually to avoid operations on empty
	areas. Return successfully because it's a nop, not a failure.
	Fixes bug #155733 for the core.

	* app/pdb/color_cmds.c
	* app/pdb/transform_tools_cmds.c: regenerated.
parent 925cb489
2004-10-20 Michael Natterer <mitch@gimp.org>
* app/core/gimpdrawable.[ch]: added gimp_drawable_mask_intersect()
which returns the same bounding box as gimp_drawable_mask_bounds(),
but returns TRUE only if there is a non-empty intersection between
the drawable and the selection, or no selection at all. It also
returns the intersection as x,y,width,height instead of the
eeky x1,y1,x2,y2.
* app/core/gimp-edit.c
* app/core/gimpdrawable-blend.c
* app/core/gimpdrawable-bucket-fill.c
* app/core/gimpdrawable-desaturate.c
* app/core/gimpdrawable-equalize.c
* app/core/gimpdrawable-histogram.c
* app/core/gimpdrawable-invert.c
* app/core/gimpdrawable-stroke.c
* app/core/gimpimagemap.c
* app/core/gimpselection.c
* tools/pdbgen/pdb/color.pdb
* tools/pdbgen/pdb/transform_tools.pdb: either switch from
gimp_drawable_mask_bounds() to _intersect() or check the return
values of _mask_bounds() manually to avoid operations on empty
areas. Return successfully because it's a nop, not a failure.
Fixes bug #155733 for the core.
* app/pdb/color_cmds.c
* app/pdb/transform_tools_cmds.c: regenerated.
2004-10-19 Michael Natterer <mitch@gimp.org>
* app/tools/gimptextoptions.c (gimp_text_options_gui): removed
......
......@@ -130,10 +130,6 @@ gimp_edit_paste (GimpImage *gimage,
if (! layer)
return NULL;
/* Start a group undo */
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_EDIT_PASTE,
_("Paste"));
if (drawable)
{
/* if pasting to a drawable */
......@@ -198,6 +194,10 @@ gimp_edit_paste (GimpImage *gimage,
GIMP_ITEM (layer)->offset_x = offset_x;
GIMP_ITEM (layer)->offset_y = offset_y;
/* Start a group undo */
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_EDIT_PASTE,
_("Paste"));
/* If there is a selection mask clear it--
* this might not always be desired, but in general,
* it seems like the correct behavior.
......@@ -388,15 +388,13 @@ gimp_edit_fill_internal (GimpImage *gimage,
{
TileManager *buf_tiles;
PixelRegion bufPR;
gint x1, y1, x2, y2;
gint x, y, width, height;
gint tiles_bytes;
guchar col[MAX_CHANNELS];
TempBuf *pat_buf = NULL;
gboolean new_buf;
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
if (x1 == x2 || y1 == y2)
if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
return TRUE; /* nothing to do, but the fill succeded */
tiles_bytes = gimp_drawable_bytes (drawable);
......@@ -440,9 +438,9 @@ gimp_edit_fill_internal (GimpImage *gimage,
return TRUE; /* nothing to do, but the fill succeded */
}
buf_tiles = tile_manager_new (x2 - x1, y2 - y1, tiles_bytes);
buf_tiles = tile_manager_new (width, height, tiles_bytes);
pixel_region_init (&bufPR, buf_tiles, 0, 0, x2 - x1, y2 - y1, TRUE);
pixel_region_init (&bufPR, buf_tiles, 0, 0, width, height, TRUE);
if (pat_buf)
{
......@@ -459,17 +457,17 @@ gimp_edit_fill_internal (GimpImage *gimage,
color_region (&bufPR, col);
}
pixel_region_init (&bufPR, buf_tiles, 0, 0, x2 - x1, y2 - y1, FALSE);
pixel_region_init (&bufPR, buf_tiles, 0, 0, width, height, FALSE);
gimp_drawable_apply_region (drawable, &bufPR,
TRUE, undo_desc,
GIMP_OPACITY_OPAQUE,
(fill_type == GIMP_TRANSPARENT_FILL) ?
GIMP_ERASE_MODE : GIMP_NORMAL_MODE,
NULL, x1, y1);
NULL, x, y);
tile_manager_unref (buf_tiles);
gimp_drawable_update (drawable, x1, y1, x2 - x1, y2 - y1);
gimp_drawable_update (drawable, x, y, width, height);
return TRUE;
}
......@@ -191,7 +191,7 @@ gimp_drawable_blend (GimpDrawable *drawable,
TileManager *buf_tiles;
PixelRegion bufPR;
gint bytes;
gint x1, y1, x2, y2;
gint x, y, width, height;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_CONTEXT (context));
......@@ -201,9 +201,10 @@ gimp_drawable_blend (GimpDrawable *drawable,
g_return_if_fail (GIMP_IS_IMAGE (gimage));
gimp_set_busy (gimage->gimp);
if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
return;
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
gimp_set_busy (gimage->gimp);
bytes = gimp_drawable_bytes (drawable);
......@@ -213,15 +214,15 @@ gimp_drawable_blend (GimpDrawable *drawable,
bytes += 1;
}
buf_tiles = tile_manager_new ((x2 - x1), (y2 - y1), bytes);
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), TRUE);
buf_tiles = tile_manager_new (width, height, bytes);
pixel_region_init (&bufPR, buf_tiles, 0, 0, width, height, TRUE);
gradient_fill_region (gimage, drawable, context,
&bufPR, (x2 - x1), (y2 - y1),
&bufPR, width, height,
blend_mode, gradient_type, offset, repeat, reverse,
supersample, max_depth, threshold, dither,
(startx - x1), (starty - y1),
(endx - x1), (endy - y1),
(startx - x), (starty - y),
(endx - x), (endy - y),
progress);
if (distR.tiles)
......@@ -230,14 +231,14 @@ gimp_drawable_blend (GimpDrawable *drawable,
distR.tiles = NULL;
}
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&bufPR, buf_tiles, 0, 0, width, height, FALSE);
gimp_drawable_apply_region (drawable, &bufPR,
TRUE, _("Blend"),
opacity, paint_mode,
NULL, x1, y1);
NULL, x, y);
/* update the image */
gimp_drawable_update (drawable, x1, y1, x2 - x1, y2 - y1);
gimp_drawable_update (drawable, x, y, width, height);
/* free the temporary buffer */
tile_manager_unref (buf_tiles);
......
......@@ -138,6 +138,12 @@ gimp_drawable_bucket_fill_full (GimpDrawable *drawable,
g_return_if_fail (GIMP_IS_IMAGE (gimage));
bytes = gimp_drawable_bytes (drawable);
selection = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
if ((x1 == x2) || (y1 == y2))
return;
if (fill_mode == GIMP_FG_BUCKET_FILL ||
fill_mode == GIMP_BG_BUCKET_FILL)
{
......@@ -164,9 +170,6 @@ gimp_drawable_bucket_fill_full (GimpDrawable *drawable,
gimp_set_busy (gimage->gimp);
bytes = gimp_drawable_bytes (drawable);
selection = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
/* Do a seed bucket fill...To do this, calculate a new
* contiguous region. If there is a selection, calculate the
* intersection of this region with the existing selection.
......
......@@ -41,18 +41,20 @@ gimp_drawable_desaturate (GimpDrawable *drawable)
gint lightness, min, max;
gboolean has_alpha;
gpointer pr;
gint x1, y1, x2, y2;
gint x, y, width, height;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_drawable_is_rgb (drawable));
has_alpha = gimp_drawable_has_alpha (drawable);
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
return;
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), FALSE);
x, y, width, height, FALSE);
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x1, y1, (x2 - x1), (y2 - y1), TRUE);
x, y, width, height, TRUE);
for (pr = pixel_regions_register (2, &srcPR, &destPR);
pr != NULL;
......@@ -94,5 +96,5 @@ gimp_drawable_desaturate (GimpDrawable *drawable)
gimp_drawable_merge_shadow (drawable, TRUE, _("Desaturate"));
gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
gimp_drawable_update (drawable, x, y, width, height);
}
......@@ -44,20 +44,19 @@ gimp_drawable_equalize (GimpDrawable *drawable,
gboolean mask_only)
{
PixelRegion srcPR, destPR;
guchar *mask;
gint bytes;
gint x1, y1, x2, y2;
gint x, y, width, height;
GimpHistogram *hist;
GimpLut *lut;
GimpImage *gimage;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
mask = NULL;
bytes = gimp_drawable_bytes (drawable);
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
bytes = gimp_drawable_bytes (drawable);
if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
return;
hist = gimp_histogram_new (GIMP_BASE_CONFIG (gimage->gimp->config));
gimp_drawable_calculate_histogram (drawable, hist);
......@@ -66,14 +65,12 @@ gimp_drawable_equalize (GimpDrawable *drawable,
lut = eq_histogram_lut_new (hist, bytes);
/* Apply the histogram */
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), FALSE);
x, y, width, height, FALSE);
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x1, y1, (x2 - x1), (y2 - y1), TRUE);
x, y, width, height, TRUE);
pixel_regions_process_parallel ((p_func) gimp_lut_process, lut,
pixel_regions_process_parallel ((p_func) gimp_lut_process, lut,
2, &srcPR, &destPR);
gimp_lut_free (lut);
......@@ -81,5 +78,5 @@ gimp_drawable_equalize (GimpDrawable *drawable,
gimp_drawable_merge_shadow (drawable, TRUE, _("Equalize"));
gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
gimp_drawable_update (drawable, x, y, width, height);
}
......@@ -38,13 +38,16 @@ gimp_drawable_calculate_histogram (GimpDrawable *drawable,
PixelRegion region;
PixelRegion mask;
gint x1, y1, x2, y2;
gint off_x, off_y;
gboolean have_mask;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (histogram != NULL);
have_mask = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
if ((x1 == x2) || (y1 == y2))
return;
pixel_region_init (&region, gimp_drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), FALSE);
......@@ -52,6 +55,7 @@ gimp_drawable_calculate_histogram (GimpDrawable *drawable,
{
GimpChannel *sel_mask;
GimpImage *gimage;
gint off_x, off_y;
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
sel_mask = gimp_image_get_mask (gimage);
......
......@@ -37,25 +37,25 @@ void
gimp_drawable_invert (GimpDrawable *drawable)
{
PixelRegion srcPR, destPR;
gint x1, y1, x2, y2;
gint x, y, width, height;
GimpLut *lut;
if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
return;
lut = invert_lut_new (gimp_drawable_bytes (drawable));
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), FALSE);
x, y, width, height, FALSE);
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x1, y1, (x2 - x1), (y2 - y1), TRUE);
x, y, width, height, TRUE);
pixel_regions_process_parallel ((p_func)gimp_lut_process, lut,
pixel_regions_process_parallel ((p_func)gimp_lut_process, lut,
2, &srcPR, &destPR);
gimp_lut_free (lut);
gimp_drawable_merge_shadow (drawable, TRUE, _("Invert"));
gimp_drawable_update (drawable,
x1, y1,
(x2 - x1), (y2 - y1));
gimp_drawable_update (drawable, x, y, width, height);
}
......@@ -205,7 +205,8 @@ gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
GimpStrokeOptions *options,
GimpScanConvert *scan_convert)
{
/* Stroke options */
GimpContext *context = GIMP_CONTEXT (options);
GimpImage *gimage;
gdouble width;
TileManager *base;
TileManager *mask;
......@@ -214,28 +215,11 @@ gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
gint off_x, off_y;
guchar bg[1] = { 0, };
PixelRegion maskPR, basePR;
GimpContext *context;
GimpImage *gimage;
context = GIMP_CONTEXT (options);
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
/* what area do we operate on? */
if (! gimp_channel_is_empty (gimp_image_get_mask (gimage)))
{
gint x2, y2;
gimp_drawable_mask_bounds (drawable, &x, &y, &x2, &y2);
w = x2 - x;
h = y2 - y;
}
else
{
x = y = 0;
w = gimp_item_width (GIMP_ITEM (drawable));
h = gimp_item_height (GIMP_ITEM (drawable));
}
if (! gimp_drawable_mask_intersect (drawable, &x, &y, &w, &h))
return;
gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
......
......@@ -1065,8 +1065,7 @@ gimp_drawable_merge_shadow (GimpDrawable *drawable,
const gchar *undo_desc)
{
GimpImage *gimage;
PixelRegion shadowPR;
gint x1, y1, x2, y2;
gint x, y, width, height;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
......@@ -1079,13 +1078,17 @@ gimp_drawable_merge_shadow (GimpDrawable *drawable,
* extents of the selection mask, as it cannot extend beyond
* them.
*/
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
pixel_region_init (&shadowPR, gimage->shadow,
x1, y1, (x2 - x1), (y2 - y1), FALSE);
gimp_drawable_apply_region (drawable, &shadowPR,
push_undo, undo_desc,
GIMP_OPACITY_OPAQUE, GIMP_REPLACE_MODE,
NULL, x1, y1);
if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
{
PixelRegion shadowPR;
pixel_region_init (&shadowPR, gimage->shadow,
x, y, width, height, FALSE);
gimp_drawable_apply_region (drawable, &shadowPR,
push_undo, undo_desc,
GIMP_OPACITY_OPAQUE, GIMP_REPLACE_MODE,
NULL, x, y);
}
}
void
......@@ -1214,10 +1217,10 @@ gimp_drawable_mask_bounds (GimpDrawable *drawable,
g_return_val_if_fail (y2 != NULL, FALSE);
item = GIMP_ITEM (drawable);
gimage = gimp_item_get_image (item);
g_return_val_if_fail (gimage != NULL, FALSE);
g_return_val_if_fail (gimp_item_is_attached (item), FALSE);
gimage = gimp_item_get_image (item);
selection = gimp_image_get_mask (gimage);
if (GIMP_DRAWABLE (selection) != drawable &&
......@@ -1243,6 +1246,54 @@ gimp_drawable_mask_bounds (GimpDrawable *drawable,
return FALSE;
}
gboolean
gimp_drawable_mask_intersect (GimpDrawable *drawable,
gint *x,
gint *y,
gint *width,
gint *height)
{
GimpItem *item;
GimpImage *gimage;
GimpChannel *selection;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (x != NULL, FALSE);
g_return_val_if_fail (y != NULL, FALSE);
g_return_val_if_fail (width != NULL, FALSE);
g_return_val_if_fail (height != NULL, FALSE);
item = GIMP_ITEM (drawable);
g_return_val_if_fail (gimp_item_is_attached (item), FALSE);
gimage = gimp_item_get_image (item);
selection = gimp_image_get_mask (gimage);
if (GIMP_DRAWABLE (selection) != drawable &&
gimp_channel_bounds (selection, x, y, width, height))
{
gint off_x, off_y;
gimp_item_offsets (item, &off_x, &off_y);
return gimp_rectangle_intersect (*x - off_x, *y - off_y,
*width - *x, *height - *y,
0, 0,
gimp_item_width (item),
gimp_item_height (item),
x, y,
width, height);
}
*x = 0;
*y = 0;
*width = gimp_item_width (item);
*height = gimp_item_height (item);
return TRUE;
}
gboolean
gimp_drawable_has_alpha (const GimpDrawable *drawable)
{
......
......@@ -189,10 +189,15 @@ void gimp_drawable_fill_by_type (GimpDrawable *drawable,
GimpFillType fill_type);
gboolean gimp_drawable_mask_bounds (GimpDrawable *drawable,
gint *x1,
gint *y1,
gint *x2,
gint *y2);
gint *x1,
gint *y1,
gint *x2,
gint *y2);
gboolean gimp_drawable_mask_intersect (GimpDrawable *drawable,
gint *x,
gint *y,
gint *width,
gint *height);
gboolean gimp_drawable_has_alpha (const GimpDrawable *drawable);
GimpImageType gimp_drawable_type (const GimpDrawable *drawable);
......
......@@ -275,10 +275,10 @@ gimp_image_map_apply (GimpImageMap *image_map,
GimpImageMapApplyFunc apply_func,
gpointer apply_data)
{
gint x1, y1;
gint x2, y2;
gint offset_x, offset_y;
gint x, y;
gint width, height;
gint undo_offset_x, undo_offset_y;
gint undo_width, undo_height;
g_return_if_fail (GIMP_IS_IMAGE_MAP (image_map));
g_return_if_fail (apply_func != NULL);
......@@ -301,33 +301,38 @@ gimp_image_map_apply (GimpImageMap *image_map,
return;
/* The application should occur only within selection bounds */
gimp_drawable_mask_bounds (image_map->drawable, &x1, &y1, &x2, &y2);
if ((x2 - x1 < 1) || (y2 - y1 < 1))
if (! gimp_drawable_mask_intersect (image_map->drawable,
&x, &y, &width, &height))
return;
/* If undo tiles don't exist, or change size, (re)allocate */
if (image_map->undo_tiles)
{
offset_x = image_map->undo_offset_x;
offset_y = image_map->undo_offset_y;
width = tile_manager_width (image_map->undo_tiles);
height = tile_manager_height (image_map->undo_tiles);
undo_offset_x = image_map->undo_offset_x;
undo_offset_y = image_map->undo_offset_y;
undo_width = tile_manager_width (image_map->undo_tiles);
undo_height = tile_manager_height (image_map->undo_tiles);
}
else
{
offset_x = offset_y = width = height = 0;
undo_offset_x = 0;
undo_offset_y = 0;
undo_width = 0;
undo_height = 0;
}
if (! image_map->undo_tiles ||
offset_x != x1 || offset_y != y1 ||
width != (x2 - x1) || height != (y2 - y1))
undo_offset_x != x ||
undo_offset_y != y ||
undo_width != width ||
undo_height != height)
{
/* If either the extents changed or the tiles don't exist,
* allocate new
*/
if (! image_map->undo_tiles ||
width != (x2 - x1) || height != (y2 - y1))
undo_width != width ||
undo_height != height)
{
/* Destroy old tiles */
if (image_map->undo_tiles)
......@@ -335,44 +340,45 @@ gimp_image_map_apply (GimpImageMap *image_map,
/* Allocate new tiles */
image_map->undo_tiles =
tile_manager_new ((x2 - x1), (y2 - y1),
tile_manager_new (width, height,
gimp_drawable_bytes (image_map->drawable));
}
/* Copy from the image to the new tiles */
pixel_region_init (&image_map->srcPR,
gimp_drawable_data (image_map->drawable),
x1, y1, (x2 - x1), (y2 - y1), FALSE);
x, y, width, height, FALSE);
pixel_region_init (&image_map->destPR, image_map->undo_tiles,
0, 0, (x2 - x1), (y2 - y1), TRUE);
0, 0, width, height, TRUE);
copy_region (&image_map->srcPR, &image_map->destPR);
/* Set the offsets */
image_map->undo_offset_x = x1;
image_map->undo_offset_y = y1;
image_map->undo_offset_x = x;
image_map->undo_offset_y = y;
}
else /* image_map->undo_tiles exist AND drawable dimensions have not changed... */
{
/* Reset to initial drawable conditions. */
/* Copy from the backup undo tiles to the drawable */
pixel_region_init (&image_map->srcPR, image_map->undo_tiles,
0, 0, width, height, FALSE);
0, 0, undo_width, undo_height, FALSE);
pixel_region_init (&image_map->destPR,
gimp_drawable_data (image_map->drawable),
offset_x, offset_y, width, height, TRUE);
undo_offset_x, undo_offset_y,
undo_width, undo_height, TRUE);
copy_region (&image_map->srcPR, &image_map->destPR);
}
/* Configure the src from the drawable data */
pixel_region_init (&image_map->srcPR, image_map->undo_tiles,
0, 0, (x2 - x1), (y2 - y1), FALSE);
0, 0, width, height, FALSE);
/* Configure the dest as the shadow buffer */
pixel_region_init (&image_map->destPR,
gimp_drawable_shadow (image_map->drawable),
x1, y1, (x2 - x1), (y2 - y1), TRUE);
x, y, width, height, TRUE);
/* Apply the image transformation to the pixels */
image_map->PRI = pixel_regions_register (2,
......
......@@ -652,8 +652,8 @@ gimp_selection_extract (GimpChannel *selection,
GimpImageBaseType base_type = GIMP_RGB;
gint bytes = 0;
gint x1, y1, x2, y2;
gint off_x, off_y;
gboolean non_empty;
gint off_x, off_y;
g_return_val_if_fail (GIMP_IS_SELECTION (selection), NULL);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
......@@ -668,7 +668,7 @@ gimp_selection_extract (GimpChannel *selection,
* actual selection mask
*/
non_empty = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
if (non_empty && (!(x2 - x1) || !(y2 - y1)))
if (non_empty && ((x1 == x2) || (y1 == y2)))
{
g_message (_("Unable to cut or copy because the "
"selected region is empty."));
......@@ -803,9 +803,8 @@ gimp_selection_float (GimpChannel *selection,
GimpImage *gimage;
GimpLayer *layer;
TileManager *tiles;
gint x1, y1, x2, y2;
gboolean non_empty;
gint x1, y1;
gint x2, y2;
g_return_val_if_fail (GIMP_IS_SELECTION (selection), NULL);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
......@@ -816,7 +815,7 @@ gimp_selection_float (GimpChannel *selection,
/* Make sure there is a region to float... */
non_empty = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
if (! non_empty || (x2 - x1) == 0 || (y2 - y1) == 0)
if (! non_empty || (x1 == x2) || (y1 == y2))
{
g_message (_("Cannot float selection because the "
"selected region is empty."));
......
This diff is collapsed.
......@@ -170,36 +170,39 @@ perspective_invoker (Gimp *gimp,
if (success)
{
gint x1, y1, x2, y2;
GimpMatrix3 matrix;
GimpInterpolationType interpolation_type;
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
/* Assemble the transformation matrix */
gimp_transform_matrix_perspective (x1, y1, x2, y2,
trans_info[X0], trans_info[Y0],
trans_info[X1], trans_info[Y1],
trans_info[X2], trans_info[Y2],
trans_info[X3], trans_info[Y3],
&matrix);
if (interpolation)
interpolation_type = gimp->config->interpolation_type;
else
interpolation_type = GIMP_INTERPOLATION_NONE;
if (progress)
gimp_progress_start (progress, _("Perspective..."), FALSE);
/* Perspective the selection */
success = gimp_drawable_transform_affine (drawable, context,
&matrix, GIMP_TRANSFORM_FORWARD,
interpolation_type, TRUE, 3,
FALSE, progress);
if (progress)
gimp_progress_end (progress);
gint x, y, width, height;
if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
{
GimpMatrix3 matrix;
GimpInterpolationType interpolation_type;
/* Assemble the transformation matrix */
gimp_transform_matrix_perspective (x, y, x + width, y + height,
trans_info[X0], trans_info[Y0],
trans_info[X1], trans_info[Y1],
trans_info[X2], trans_info[Y2],
trans_info[X3], trans_info[Y3],
&matrix);
if (interpolation)
interpolation_type = gimp->config->interpolation_type;
else
interpolation_type = GIMP_INTERPOLATION_NONE;