crop the image, even if the layer is fully opaque. Fixes bug #413906.

2007-05-04  Sven Neumann  <sven@gimp.org>

	* plug-ins/common/autocrop.c (autocrop): crop the image, even if
	the layer is fully opaque. Fixes bug #413906.

svn path=/trunk/; revision=22413
This commit is contained in:
Sven Neumann 2007-05-04 12:36:08 +00:00 committed by Sven Neumann
parent 0bcf615e24
commit e47366fa2f
2 changed files with 40 additions and 36 deletions

View File

@ -1,3 +1,8 @@
2007-05-04 Sven Neumann <sven@gimp.org>
* plug-ins/common/autocrop.c (autocrop): crop the image, even if
the layer is fully opaque. Fixes bug #413906.
2007-05-04 Sven Neumann <sven@gimp.org>
* plug-ins/common/autocrop.c (guess_bgcolor): special case fully

View File

@ -221,10 +221,12 @@ autocrop (GimpDrawable *drawable,
if (y1 == height && !abort)
{
/* whee - a plain color drawable. Do nothing. */
g_free (buffer);
gimp_drawable_detach (drawable);
return;
/* whee - a plain color drawable. */
x1 = 0;
x2 = width;
y1 = 0;
y2 = height;
goto done;
}
if (show_progress)
@ -242,7 +244,6 @@ autocrop (GimpDrawable *drawable,
y2++; /* to make y2 - y1 == height */
/* The coordinates are now the first rows which DON'T match
* the color. Crop instead to one row larger:
*/
@ -289,48 +290,46 @@ autocrop (GimpDrawable *drawable,
if (x2 < width)
x2++;
done:
g_free (buffer);
gimp_drawable_detach (drawable);
if (x2 - x1 != width || y2 - y1 != height)
if (layer_only &&
(x2 - x1 != width || y2 - y1 != height))
{
if (layer_only)
gimp_layer_resize (layer_id, x2 - x1, y2 - y1, -x1, -y1);
}
else
{
/* convert to image coordinates */
x1 += off_x; x2 += off_x;
y1 += off_y; y2 += off_y;
gimp_image_undo_group_start (image_id);
if (x1 < 0 || y1 < 0 ||
x2 > gimp_image_width (image_id) ||
y2 > gimp_image_height (image_id))
{
gimp_layer_resize (layer_id, x2 - x1, y2 - y1, -x1, -y1);
/*
* partially outside the image area, we need to
* resize the image to be able to crop properly.
*/
gimp_image_resize (image_id, x2 - x1, y2 - y1, -x1, -y1);
x2 -= x1;
y2 -= y1;
x1 = y1 = 0;
}
else
{
/* convert to image coordinates */
x1 += off_x; x2 += off_x;
y1 += off_y; y2 += off_y;
gimp_image_undo_group_start (image_id);
gimp_image_crop (image_id, x2 - x1, y2 - y1, x1, y1);
if (x1 < 0 || y1 < 0 ||
x2 > gimp_image_width (image_id) ||
y2 > gimp_image_height (image_id))
{
/*
* partially outside the image area, we need to
* resize the image to be able to crop properly.
*/
gimp_image_resize (image_id, x2 - x1, y2 - y1, -x1, -y1);
x2 -= x1;
y2 -= y1;
x1 = y1 = 0;
}
gimp_image_crop (image_id, x2 - x1, y2 - y1, x1, y1);
gimp_image_undo_group_end (image_id);
}
gimp_image_undo_group_end (image_id);
}
if (show_progress)
gimp_progress_update (1.00);
gimp_progress_update (1.0);
}
static gint