mirror of https://github.com/GNOME/gimp.git
Bug 155733 – need to check return values of gimp_drawable_mask_bounds()
Finally commit the patch from Luidnel Maignan, but don't spit messages when the effected region is empty (core functions don't spit messages either). Also got rid of some x2 and y2 variables that are not needed any longer.
This commit is contained in:
parent
90db6c0891
commit
9b6c9e1fe4
|
@ -567,11 +567,13 @@ apply_blinds (GimpDrawable *drawable)
|
|||
|
||||
gimp_drawable_get_color_uchar (drawable->drawable_id, &background, bg);
|
||||
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id,
|
||||
&sel_x1, &sel_y1, &sel_x2, &sel_y2);
|
||||
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
|
||||
&sel_x1, &sel_y1,
|
||||
&sel_width, &sel_height))
|
||||
return;
|
||||
|
||||
sel_width = sel_x2 - sel_x1;
|
||||
sel_height = sel_y2 - sel_y1;
|
||||
sel_x2 = sel_x1 + sel_width;
|
||||
sel_y2 = sel_y1 + sel_height;
|
||||
|
||||
gimp_pixel_rgn_init (&src_rgn, drawable,
|
||||
sel_x1, sel_y1, sel_width, sel_height, FALSE, FALSE);
|
||||
|
|
|
@ -730,19 +730,19 @@ sel_gauss (GimpDrawable *drawable,
|
|||
gint maxdelta)
|
||||
{
|
||||
GimpPixelRgn src_rgn, dest_rgn;
|
||||
gint width, height;
|
||||
gint bytes;
|
||||
gboolean has_alpha;
|
||||
guchar *dest;
|
||||
guchar *src;
|
||||
gint x1, y1, x2, y2;
|
||||
gint x, y;
|
||||
gint width, height;
|
||||
gdouble *mat;
|
||||
gint numrad;
|
||||
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
||||
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
|
||||
&x, &y, &width, &height))
|
||||
return;
|
||||
|
||||
width = x2 - x1;
|
||||
height = y2 - y1;
|
||||
bytes = drawable->bpp;
|
||||
has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
||||
|
||||
|
@ -754,20 +754,20 @@ sel_gauss (GimpDrawable *drawable,
|
|||
dest = g_new (guchar, width * height * bytes);
|
||||
|
||||
gimp_pixel_rgn_init (&src_rgn,
|
||||
drawable, x1, y1, width, height, FALSE, FALSE);
|
||||
gimp_pixel_rgn_get_rect (&src_rgn, src, x1, y1, width, height);
|
||||
drawable, x, y, width, height, FALSE, FALSE);
|
||||
gimp_pixel_rgn_get_rect (&src_rgn, src, x, y, width, height);
|
||||
|
||||
matrixmult (src, dest, width, height, mat, numrad,
|
||||
bytes, has_alpha, maxdelta, FALSE);
|
||||
|
||||
gimp_pixel_rgn_init (&dest_rgn,
|
||||
drawable, x1, y1, width, height, TRUE, TRUE);
|
||||
gimp_pixel_rgn_set_rect (&dest_rgn, dest, x1, y1, width, height);
|
||||
drawable, x, y, width, height, TRUE, TRUE);
|
||||
gimp_pixel_rgn_set_rect (&dest_rgn, dest, x, y, width, height);
|
||||
|
||||
/* merge the shadow, update the drawable */
|
||||
gimp_drawable_flush (drawable);
|
||||
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
|
||||
gimp_drawable_update (drawable->drawable_id, x1, y1, width, height);
|
||||
gimp_drawable_update (drawable->drawable_id, x, y, width, height);
|
||||
|
||||
/* free up buffers */
|
||||
g_free (src);
|
||||
|
@ -780,7 +780,7 @@ preview_update (GimpPreview *preview)
|
|||
{
|
||||
GimpDrawable *drawable;
|
||||
glong bytes;
|
||||
gint x1, y1;
|
||||
gint x, y;
|
||||
guchar *render_buffer; /* Buffer to hold rendered image */
|
||||
gint width; /* Width of preview widget */
|
||||
gint height; /* Height of preview widget */
|
||||
|
@ -800,19 +800,19 @@ preview_update (GimpPreview *preview)
|
|||
/*
|
||||
* Setup for filter...
|
||||
*/
|
||||
gimp_preview_get_position (preview, &x1, &y1);
|
||||
gimp_preview_get_position (preview, &x, &y);
|
||||
gimp_preview_get_size (preview, &width, &height);
|
||||
|
||||
/* initialize pixel regions */
|
||||
gimp_pixel_rgn_init (&srcPR, drawable,
|
||||
x1, y1, width, height,
|
||||
x, y, width, height,
|
||||
FALSE, FALSE);
|
||||
render_buffer = g_new (guchar, width * height * bytes);
|
||||
|
||||
src = g_new (guchar, width * height * bytes);
|
||||
|
||||
/* render image */
|
||||
gimp_pixel_rgn_get_rect (&srcPR, src, x1, y1, width, height);
|
||||
gimp_pixel_rgn_get_rect (&srcPR, src, x, y, width, height);
|
||||
has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
||||
|
||||
radius = fabs (bvals.radius) + 1.0;
|
||||
|
|
|
@ -250,7 +250,13 @@ blur (GimpDrawable *drawable)
|
|||
gint ind;
|
||||
gboolean has_alpha;
|
||||
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
||||
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
|
||||
&x1, &y1, &width, &height))
|
||||
return;
|
||||
|
||||
x2 = x1 + width;
|
||||
y2 = y1 + height;
|
||||
|
||||
/*
|
||||
* Get the size of the input image. (This will/must be the same
|
||||
* as the size of the output image. Also get alpha info.
|
||||
|
|
|
@ -204,12 +204,9 @@ deinterlace (GimpDrawable *drawable,
|
|||
}
|
||||
else
|
||||
{
|
||||
gint x2, y2;
|
||||
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x, &y, &x2, &y2);
|
||||
|
||||
width = x2 - x;
|
||||
height = y2 - y;
|
||||
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
|
||||
&x, &y, &width, &height))
|
||||
return;
|
||||
|
||||
dest = g_new (guchar, width * bytes);
|
||||
|
||||
|
|
|
@ -367,35 +367,35 @@ pixel_copy (guchar *dest,
|
|||
static void
|
||||
despeckle (void)
|
||||
{
|
||||
GimpPixelRgn src_rgn, /* Source image region */
|
||||
dst_rgn;
|
||||
guchar *src, *dst;
|
||||
GimpPixelRgn src_rgn; /* Source image region */
|
||||
GimpPixelRgn dst_rgn;
|
||||
guchar *src;
|
||||
guchar *dst;
|
||||
gint img_bpp;
|
||||
gint width;
|
||||
gint height;
|
||||
gint x1, y1 ,x2 ,y2;
|
||||
gint x, y;
|
||||
gint width, height;
|
||||
|
||||
img_bpp = gimp_drawable_bpp (drawable->drawable_id);
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
||||
|
||||
width = x2 - x1;
|
||||
height = y2 - y1;
|
||||
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
|
||||
&x, &y, &width, &height))
|
||||
return;
|
||||
|
||||
gimp_pixel_rgn_init (&src_rgn, drawable, x1, y1, width, height, FALSE, FALSE);
|
||||
gimp_pixel_rgn_init (&dst_rgn, drawable, x1, y1, width, height, TRUE, TRUE);
|
||||
gimp_pixel_rgn_init (&src_rgn, drawable, x, y, width, height, FALSE, FALSE);
|
||||
gimp_pixel_rgn_init (&dst_rgn, drawable, x, y, width, height, TRUE, TRUE);
|
||||
|
||||
src = g_new (guchar, width * height * img_bpp);
|
||||
dst = g_new (guchar, width * height * img_bpp);
|
||||
|
||||
gimp_pixel_rgn_get_rect (&src_rgn, src, x1, y1, width, height);
|
||||
gimp_pixel_rgn_get_rect (&src_rgn, src, x, y, width, height);
|
||||
|
||||
despeckle_median (src, dst, width, height, img_bpp, despeckle_radius, FALSE);
|
||||
|
||||
gimp_pixel_rgn_set_rect (&dst_rgn, dst, x1, y1, width, height);
|
||||
gimp_pixel_rgn_set_rect (&dst_rgn, dst, x, y, width, height);
|
||||
|
||||
gimp_drawable_flush (drawable);
|
||||
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
|
||||
gimp_drawable_update (drawable->drawable_id, x1, y1, width, height);
|
||||
gimp_drawable_update (drawable->drawable_id, x, y, width, height);
|
||||
|
||||
g_free (dst);
|
||||
g_free (src);
|
||||
|
|
|
@ -185,11 +185,10 @@ static void iwarp_scale_preview (gint new_width,
|
|||
static void iwarp_preview_build (GtkWidget *dialog,
|
||||
GtkWidget *vbox);
|
||||
|
||||
static void iwarp_init (void);
|
||||
static gboolean iwarp_init (void);
|
||||
static void iwarp_preview_init (void);
|
||||
|
||||
|
||||
|
||||
const GimpPlugInInfo PLUG_IN_INFO =
|
||||
{
|
||||
NULL, /* init_proc */
|
||||
|
@ -963,14 +962,20 @@ iwarp_preview_init (void)
|
|||
g_free (linebuffer);
|
||||
}
|
||||
|
||||
static void
|
||||
static gboolean
|
||||
iwarp_init (void)
|
||||
{
|
||||
gint i;
|
||||
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id, &xl, &yl, &xh, &yh);
|
||||
sel_width = xh - xl;
|
||||
sel_height = yh - yl;
|
||||
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
|
||||
&xl, &yl, &sel_width, &sel_height))
|
||||
{
|
||||
g_message (_("Region affected by plug-in is empty"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
xh = xl + sel_width;
|
||||
yh = yl + sel_height;
|
||||
|
||||
image_bpp = gimp_drawable_bpp (drawable->drawable_id);
|
||||
|
||||
|
@ -1000,6 +1005,8 @@ iwarp_init (void)
|
|||
pow ((cos (sqrt((gdouble) i / MAX_DEFORM_AREA_RADIUS) * G_PI) + 1) *
|
||||
0.5, 0.7); /*0.7*/
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1269,7 +1276,8 @@ iwarp_dialog (void)
|
|||
|
||||
gimp_ui_init (PLUG_IN_BINARY, TRUE);
|
||||
|
||||
iwarp_init ();
|
||||
if (! iwarp_init ())
|
||||
return FALSE;
|
||||
|
||||
dialog = gimp_dialog_new (_("IWarp"), PLUG_IN_BINARY,
|
||||
NULL, 0,
|
||||
|
|
|
@ -488,14 +488,18 @@ mosaic (GimpDrawable *drawable,
|
|||
{
|
||||
gimp_preview_get_position (preview, &x1, &y1);
|
||||
gimp_preview_get_size (preview, &width, &height);
|
||||
|
||||
x2 = x1 + width;
|
||||
y2 = y1 + height;
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
||||
width = (x2 - x1);
|
||||
height = (y2 - y1);
|
||||
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
|
||||
&x1, &y1, &width, &height))
|
||||
return;
|
||||
|
||||
x2 = x1 + width;
|
||||
y2 = y1 + height;
|
||||
|
||||
/* progress bar for gradient finding */
|
||||
gimp_progress_init (_("Finding edges"));
|
||||
|
@ -517,7 +521,7 @@ mosaic (GimpDrawable *drawable,
|
|||
grid_create_octagons (x1, y1, x2, y2);
|
||||
break;
|
||||
case TRIANGLES:
|
||||
grid_create_triangles(x1, y1, x2, y2);
|
||||
grid_create_triangles (x1, y1, x2, y2);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -460,10 +460,12 @@ pixelize_large (GimpDrawable *drawable,
|
|||
}
|
||||
else
|
||||
{
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id,
|
||||
&x1, &y1, &x2, &y2);
|
||||
width = x2 - x1;
|
||||
height = y2 - y1;
|
||||
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
|
||||
&x1, &y1, &width, &height))
|
||||
return;
|
||||
|
||||
x2 = x1 + width;
|
||||
y2 = y1 + height;
|
||||
|
||||
/* Initialize progress */
|
||||
progress = 0;
|
||||
|
@ -632,10 +634,15 @@ pixelize_small (GimpDrawable *drawable,
|
|||
{
|
||||
GimpPixelRgn src_rgn, dest_rgn;
|
||||
gint bpp, has_alpha;
|
||||
gint x1, y1, x2, y2;
|
||||
gint x1, y1, x2, y2, w, h;
|
||||
gint progress, max_progress;
|
||||
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
||||
if (! gimp_drawable_mask_intersect (drawable->drawable_id, &x1, &y1, &w, &h))
|
||||
return;
|
||||
|
||||
x2 = x1 + w;
|
||||
y2 = y1 + h;
|
||||
|
||||
gimp_pixel_rgn_init (&src_rgn, drawable, x1, y1, x2-x1, y2-y1, FALSE, FALSE);
|
||||
gimp_pixel_rgn_init (&dest_rgn, drawable, x1, y1, x2-x1, y2-y1, TRUE, TRUE);
|
||||
|
||||
|
|
|
@ -202,13 +202,14 @@ run (const gchar *name,
|
|||
img_height = gimp_drawable_height (drawable->drawable_id);
|
||||
img_has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
||||
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id,
|
||||
&sel_x1, &sel_y1, &sel_x2, &sel_y2);
|
||||
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
|
||||
&sel_x1, &sel_y1, &sel_width, &sel_height))
|
||||
return;
|
||||
|
||||
/* Calculate scaling parameters */
|
||||
|
||||
sel_width = sel_x2 - sel_x1;
|
||||
sel_height = sel_y2 - sel_y1;
|
||||
sel_x2 = sel_x1 + sel_width;
|
||||
sel_y2 = sel_y1 + sel_height;
|
||||
|
||||
cen_x = (double) (sel_x1 + sel_x2 - 1) / 2.0;
|
||||
cen_y = (double) (sel_y1 + sel_y2 - 1) / 2.0;
|
||||
|
|
|
@ -291,17 +291,19 @@ sharpen (GimpDrawable *drawable)
|
|||
|
||||
filter = NULL;
|
||||
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id,
|
||||
&x1, &y1, &x2, &y2);
|
||||
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
|
||||
&x1, &y1, &sel_width, &sel_height))
|
||||
return;
|
||||
|
||||
sel_width = x2 - x1;
|
||||
sel_height = y2 - y1;
|
||||
img_bpp = gimp_drawable_bpp (drawable->drawable_id);
|
||||
x2 = x1 + sel_width;
|
||||
y2 = y1 + sel_height;
|
||||
|
||||
img_bpp = gimp_drawable_bpp (drawable->drawable_id);
|
||||
|
||||
/*
|
||||
* Let the user know what we're doing...
|
||||
*/
|
||||
gimp_progress_init( _("Sharpening"));
|
||||
gimp_progress_init (_("Sharpening"));
|
||||
|
||||
/*
|
||||
* Setup for filter...
|
||||
|
|
|
@ -429,20 +429,23 @@ value_propagate_body (GimpDrawable *drawable,
|
|||
dtype = gimp_drawable_type (drawable->drawable_id);
|
||||
bytes = drawable->bpp;
|
||||
|
||||
/* Here I use the algorithm of blur.c . */
|
||||
/* Here I use the algorithm of blur.c */
|
||||
if (preview)
|
||||
{
|
||||
gimp_preview_get_position (preview, &begx, &begy);
|
||||
gimp_preview_get_size (preview, &width, &height);
|
||||
|
||||
endx = begx + width;
|
||||
endy = begy + height;
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id,
|
||||
&begx, &begy, &endx, &endy);
|
||||
width = endx - begx;
|
||||
height = endy - begy;
|
||||
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
|
||||
&begx, &begy, &width, &height))
|
||||
return;
|
||||
|
||||
endx = begx + width;
|
||||
endy = begy + height;
|
||||
}
|
||||
|
||||
gimp_tile_cache_ntiles (2 * ((width) / gimp_tile_width () + 1));
|
||||
|
|
|
@ -1350,14 +1350,18 @@ warp_one (GimpDrawable *draw,
|
|||
|
||||
/* Get selection area */
|
||||
|
||||
if (! gimp_drawable_mask_intersect (draw->drawable_id, &x1, &y1, &x2, &y2))
|
||||
if (! gimp_drawable_mask_intersect (draw->drawable_id,
|
||||
&x1, &y1, &width, &height))
|
||||
return;
|
||||
|
||||
width = draw->width;
|
||||
height = draw->height;
|
||||
dest_bytes = draw->bpp;
|
||||
x2 = x1 + width;
|
||||
y2 = y1 + height;
|
||||
|
||||
dmap_bytes = map_x->bpp;
|
||||
width = draw->width;
|
||||
height = draw->height;
|
||||
dest_bytes = draw->bpp;
|
||||
|
||||
dmap_bytes = map_x->bpp;
|
||||
|
||||
max_progress = (x2 - x1) * (y2 - y1);
|
||||
|
||||
|
|
Loading…
Reference in New Issue