mirror of https://github.com/GNOME/gimp.git
Bug 155733 - need to check return values of gimp_drawable_mask_bounds()
Remove calls to gimp_drawable_mask_bounds() from most plug-ins. This just leaves a python gimp interface plug-in.
This commit is contained in:
parent
f4cb2dd881
commit
cfa9132c4d
|
@ -458,13 +458,11 @@ dog (gint32 image_ID,
|
||||||
gint32 layer1;
|
gint32 layer1;
|
||||||
gint32 layer2;
|
gint32 layer2;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
gint x1, y1, x2, y2;
|
gint x1, y1;
|
||||||
guchar maxval = 255;
|
guchar maxval = 255;
|
||||||
|
|
||||||
gimp_drawable_mask_bounds (drawable_id, &x1, &y1, &x2, &y2);
|
if (! gimp_drawable_mask_intersect (drawable_id, &x1, &y1, &width, &height))
|
||||||
|
return;
|
||||||
width = (x2 - x1);
|
|
||||||
height = (y2 - y1);
|
|
||||||
|
|
||||||
gimp_drawable_flush (drawable);
|
gimp_drawable_flush (drawable);
|
||||||
|
|
||||||
|
@ -522,17 +520,13 @@ compute_difference (GimpDrawable *drawable,
|
||||||
gint bpp;
|
gint bpp;
|
||||||
gpointer pr;
|
gpointer pr;
|
||||||
gint x, y, k;
|
gint x, y, k;
|
||||||
gint x1, y1, x2, y2;
|
gint x1, y1;
|
||||||
gboolean has_alpha;
|
gboolean has_alpha;
|
||||||
|
|
||||||
*maxval = 0;
|
*maxval = 0;
|
||||||
|
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
|
||||||
|
&x1, &y1, &width, &height))
|
||||||
width = (x2 - x1);
|
|
||||||
height = (y2 - y1);
|
|
||||||
|
|
||||||
if (width < 1 || height < 1)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bpp = drawable->bpp;
|
bpp = drawable->bpp;
|
||||||
|
@ -607,7 +601,8 @@ normalize_invert (GimpDrawable *drawable,
|
||||||
gint bpp;
|
gint bpp;
|
||||||
gpointer pr;
|
gpointer pr;
|
||||||
gint x, y, k;
|
gint x, y, k;
|
||||||
gint x1, y1, x2, y2;
|
gint x1, y1;
|
||||||
|
gint width, height;
|
||||||
gboolean has_alpha;
|
gboolean has_alpha;
|
||||||
gdouble factor;
|
gdouble factor;
|
||||||
|
|
||||||
|
@ -617,7 +612,10 @@ normalize_invert (GimpDrawable *drawable,
|
||||||
else
|
else
|
||||||
factor = 1.0;
|
factor = 1.0;
|
||||||
|
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
|
||||||
|
&x1, &y1, &width, &height))
|
||||||
|
return;
|
||||||
|
|
||||||
bpp = drawable->bpp;
|
bpp = drawable->bpp;
|
||||||
has_alpha = gimp_drawable_has_alpha(drawable->drawable_id);
|
has_alpha = gimp_drawable_has_alpha(drawable->drawable_id);
|
||||||
|
|
||||||
|
@ -690,7 +688,7 @@ gauss_rle (GimpDrawable *drawable,
|
||||||
gint *buf, *bb;
|
gint *buf, *bb;
|
||||||
gint pixels;
|
gint pixels;
|
||||||
gint total = 1;
|
gint total = 1;
|
||||||
gint x1, y1, x2, y2;
|
gint x1, y1;
|
||||||
gint i, row, col, b;
|
gint i, row, col, b;
|
||||||
gint start, end;
|
gint start, end;
|
||||||
gdouble progress, max_progress;
|
gdouble progress, max_progress;
|
||||||
|
@ -704,12 +702,8 @@ gauss_rle (GimpDrawable *drawable,
|
||||||
if (radius <= 0.0)
|
if (radius <= 0.0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
|
||||||
|
&x1, &y1, &width, &height))
|
||||||
width = (x2 - x1);
|
|
||||||
height = (y2 - y1);
|
|
||||||
|
|
||||||
if (width < 1 || height < 1)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bytes = drawable->bpp;
|
bytes = drawable->bpp;
|
||||||
|
@ -748,7 +742,7 @@ gauss_rle (GimpDrawable *drawable,
|
||||||
|
|
||||||
for (col = 0; col < width; col++)
|
for (col = 0; col < width; col++)
|
||||||
{
|
{
|
||||||
gimp_pixel_rgn_get_col (&src_rgn, src, col + x1, y1, (y2 - y1));
|
gimp_pixel_rgn_get_col (&src_rgn, src, col + x1, y1, height);
|
||||||
|
|
||||||
if (has_alpha)
|
if (has_alpha)
|
||||||
multiply_alpha (src, height, bytes);
|
multiply_alpha (src, height, bytes);
|
||||||
|
@ -800,7 +794,7 @@ gauss_rle (GimpDrawable *drawable,
|
||||||
if (has_alpha)
|
if (has_alpha)
|
||||||
separate_alpha (dest, height, bytes);
|
separate_alpha (dest, height, bytes);
|
||||||
|
|
||||||
gimp_pixel_rgn_set_col (&dest_rgn, dest, col + x1, y1, (y2 - y1));
|
gimp_pixel_rgn_set_col (&dest_rgn, dest, col + x1, y1, height);
|
||||||
|
|
||||||
if (show_progress)
|
if (show_progress)
|
||||||
{
|
{
|
||||||
|
@ -819,7 +813,7 @@ gauss_rle (GimpDrawable *drawable,
|
||||||
/* Now the horizontal pass */
|
/* Now the horizontal pass */
|
||||||
for (row = 0; row < height; row++)
|
for (row = 0; row < height; row++)
|
||||||
{
|
{
|
||||||
gimp_pixel_rgn_get_row (&src_rgn, src, x1, row + y1, (x2 - x1));
|
gimp_pixel_rgn_get_row (&src_rgn, src, x1, row + y1, width);
|
||||||
if (has_alpha)
|
if (has_alpha)
|
||||||
multiply_alpha (src, width, bytes);
|
multiply_alpha (src, width, bytes);
|
||||||
|
|
||||||
|
@ -869,7 +863,7 @@ gauss_rle (GimpDrawable *drawable,
|
||||||
if (has_alpha)
|
if (has_alpha)
|
||||||
separate_alpha (dest, width, bytes);
|
separate_alpha (dest, width, bytes);
|
||||||
|
|
||||||
gimp_pixel_rgn_set_row (&dest_rgn, dest, x1, row + y1, (x2 - x1));
|
gimp_pixel_rgn_set_row (&dest_rgn, dest, x1, row + y1, width);
|
||||||
|
|
||||||
if (show_progress)
|
if (show_progress)
|
||||||
{
|
{
|
||||||
|
@ -883,7 +877,7 @@ gauss_rle (GimpDrawable *drawable,
|
||||||
/* merge the shadow, update the drawable */
|
/* merge the shadow, update the drawable */
|
||||||
gimp_drawable_flush (drawable);
|
gimp_drawable_flush (drawable);
|
||||||
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
|
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
|
||||||
gimp_drawable_update (drawable->drawable_id, x1, y1, (x2 - x1), (y2 - y1));
|
gimp_drawable_update (drawable->drawable_id, x1, y1, width, height);
|
||||||
|
|
||||||
/* free buffers */
|
/* free buffers */
|
||||||
g_free (buf);
|
g_free (buf);
|
||||||
|
|
|
@ -632,18 +632,21 @@ compute_lum_threshold (GimpDrawable *drawable,
|
||||||
gboolean gray;
|
gboolean gray;
|
||||||
gboolean has_alpha;
|
gboolean has_alpha;
|
||||||
gint i;
|
gint i;
|
||||||
gint x1, y1, x2, y2;
|
gint x1, y1;
|
||||||
|
gint width, height;
|
||||||
|
|
||||||
/* zero out the luminosity values array */
|
/* zero out the luminosity values array */
|
||||||
memset (values, 0, sizeof (gint) * 256);
|
memset (values, 0, sizeof (gint) * 256);
|
||||||
|
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
|
||||||
|
&x1, &y1, &width, &height))
|
||||||
|
return 0;
|
||||||
|
|
||||||
gray = gimp_drawable_is_gray (drawable->drawable_id);
|
gray = gimp_drawable_is_gray (drawable->drawable_id);
|
||||||
has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
||||||
|
|
||||||
gimp_pixel_rgn_init (&src_rgn, drawable,
|
gimp_pixel_rgn_init (&src_rgn, drawable,
|
||||||
x1, y1, (x2 - x1), (y2 - y1), FALSE, FALSE);
|
x1, y1, width, height, FALSE, FALSE);
|
||||||
|
|
||||||
for (pr = gimp_pixel_rgns_register (1, &src_rgn);
|
for (pr = gimp_pixel_rgns_register (1, &src_rgn);
|
||||||
pr != NULL;
|
pr != NULL;
|
||||||
|
@ -668,7 +671,7 @@ compute_lum_threshold (GimpDrawable *drawable,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
total = (x2 - x1) * (y2 - y1);
|
total = width * height;
|
||||||
sum = 0;
|
sum = 0;
|
||||||
|
|
||||||
for (i = 255; i >= 0; i--)
|
for (i = 255; i >= 0; i--)
|
||||||
|
@ -702,8 +705,6 @@ sparkle (GimpDrawable *drawable,
|
||||||
GRand *gr;
|
GRand *gr;
|
||||||
guchar *dest_buf = NULL;
|
guchar *dest_buf = NULL;
|
||||||
|
|
||||||
gr = g_rand_new ();
|
|
||||||
|
|
||||||
bytes = drawable->bpp;
|
bytes = drawable->bpp;
|
||||||
|
|
||||||
if (preview)
|
if (preview)
|
||||||
|
@ -717,12 +718,19 @@ sparkle (GimpDrawable *drawable,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id,
|
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
|
||||||
&x1, &y1, &x2, &y2);
|
&x1, &y1, &width, &height))
|
||||||
width = x2 - x1;
|
return;
|
||||||
height = y2 - y1;
|
|
||||||
|
x2 = x1 + width;
|
||||||
|
y2 = y1 + height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (width < 1 || height < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
gr = g_rand_new ();
|
||||||
|
|
||||||
if (svals.border)
|
if (svals.border)
|
||||||
{
|
{
|
||||||
num_sparkles = 2 * (width + height);
|
num_sparkles = 2 * (width + height);
|
||||||
|
|
|
@ -2948,8 +2948,8 @@ realrender (GimpDrawable *drawable)
|
||||||
gint x, y;
|
gint x, y;
|
||||||
ray r;
|
ray r;
|
||||||
GimpVector4 rcol;
|
GimpVector4 rcol;
|
||||||
gint tx, ty;
|
gint width, height;
|
||||||
gint x1, y1, x2, y2;
|
gint x1, y1;
|
||||||
guchar *dest;
|
guchar *dest;
|
||||||
gint bpp;
|
gint bpp;
|
||||||
GimpPixelRgn pr, dpr;
|
GimpPixelRgn pr, dpr;
|
||||||
|
@ -2960,6 +2960,10 @@ realrender (GimpDrawable *drawable)
|
||||||
r.v1.z = -10.0;
|
r.v1.z = -10.0;
|
||||||
r.v2.z = 0.0;
|
r.v2.z = 0.0;
|
||||||
|
|
||||||
|
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
|
||||||
|
&x1, &y1, &width, &height))
|
||||||
|
return;
|
||||||
|
|
||||||
gimp_pixel_rgn_init (&pr, drawable, 0, 0,
|
gimp_pixel_rgn_init (&pr, drawable, 0, 0,
|
||||||
gimp_drawable_width (drawable->drawable_id),
|
gimp_drawable_width (drawable->drawable_id),
|
||||||
gimp_drawable_height (drawable->drawable_id), FALSE,
|
gimp_drawable_height (drawable->drawable_id), FALSE,
|
||||||
|
@ -2968,23 +2972,19 @@ realrender (GimpDrawable *drawable)
|
||||||
gimp_drawable_width (drawable->drawable_id),
|
gimp_drawable_width (drawable->drawable_id),
|
||||||
gimp_drawable_height (drawable->drawable_id), TRUE,
|
gimp_drawable_height (drawable->drawable_id), TRUE,
|
||||||
TRUE);
|
TRUE);
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
|
||||||
bpp = gimp_drawable_bpp (drawable->drawable_id);
|
bpp = gimp_drawable_bpp (drawable->drawable_id);
|
||||||
buffer = g_malloc ((x2 - x1) * 4);
|
buffer = g_malloc (width * 4);
|
||||||
ibuffer = g_malloc ((x2 - x1) * 4);
|
ibuffer = g_malloc (width * 4);
|
||||||
|
|
||||||
tx = x2 - x1;
|
|
||||||
ty = y2 - y1;
|
|
||||||
|
|
||||||
gimp_progress_init (_("Rendering sphere"));
|
gimp_progress_init (_("Rendering sphere"));
|
||||||
|
|
||||||
for (y = 0; y < ty; y++)
|
for (y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
dest = buffer;
|
dest = buffer;
|
||||||
for (x = 0; x < tx; x++)
|
for (x = 0; x < width; x++)
|
||||||
{
|
{
|
||||||
r.v1.x = r.v2.x = 8.1 * (x / (float) (tx - 1) - 0.5);
|
r.v1.x = r.v2.x = 8.1 * (x / (float) (width - 1) - 0.5);
|
||||||
r.v1.y = r.v2.y = 8.1 * (y / (float) (ty - 1) - 0.5);
|
r.v1.y = r.v2.y = 8.1 * (y / (float) (height - 1) - 0.5);
|
||||||
|
|
||||||
traceray (&r, &rcol, 10, 1.0);
|
traceray (&r, &rcol, 10, 1.0);
|
||||||
dest[0] = pixelval (255 * rcol.x);
|
dest[0] = pixelval (255 * rcol.x);
|
||||||
|
@ -2993,8 +2993,8 @@ realrender (GimpDrawable *drawable)
|
||||||
dest[3] = pixelval (255 * rcol.w);
|
dest[3] = pixelval (255 * rcol.w);
|
||||||
dest += 4;
|
dest += 4;
|
||||||
}
|
}
|
||||||
gimp_pixel_rgn_get_row (&pr, ibuffer, x1, y1 + y, x2 - x1);
|
gimp_pixel_rgn_get_row (&pr, ibuffer, x1, y1 + y, width);
|
||||||
for (x = 0; x < (x2 - x1); x++)
|
for (x = 0; x < width; x++)
|
||||||
{
|
{
|
||||||
gint k, dx = x * 4, sx = x * bpp;
|
gint k, dx = x * 4, sx = x * bpp;
|
||||||
gfloat a = buffer[dx + 3] / 255.0;
|
gfloat a = buffer[dx + 3] / 255.0;
|
||||||
|
@ -3005,15 +3005,15 @@ realrender (GimpDrawable *drawable)
|
||||||
buffer[dx + k] * a + ibuffer[sx + k] * (1.0 - a);
|
buffer[dx + k] * a + ibuffer[sx + k] * (1.0 - a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gimp_pixel_rgn_set_row (&dpr, ibuffer, x1, y1 + y, x2 - x1);
|
gimp_pixel_rgn_set_row (&dpr, ibuffer, x1, y1 + y, width);
|
||||||
gimp_progress_update ((gdouble) y / (gdouble) ty);
|
gimp_progress_update ((gdouble) y / (gdouble) height);
|
||||||
}
|
}
|
||||||
gimp_progress_update (1.0);
|
gimp_progress_update (1.0);
|
||||||
g_free (buffer);
|
g_free (buffer);
|
||||||
g_free (ibuffer);
|
g_free (ibuffer);
|
||||||
gimp_drawable_flush (drawable);
|
gimp_drawable_flush (drawable);
|
||||||
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
|
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
|
||||||
gimp_drawable_update (drawable->drawable_id, x1, y1, x2 - x1, y2 - y1);
|
gimp_drawable_update (drawable->drawable_id, x1, y1, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -144,7 +144,6 @@ query (void)
|
||||||
GIMP_PLUGIN,
|
GIMP_PLUGIN,
|
||||||
G_N_ELEMENTS (args), 0,
|
G_N_ELEMENTS (args), 0,
|
||||||
args, NULL);
|
args, NULL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -536,7 +535,7 @@ unsharp_mask (GimpDrawable *drawable,
|
||||||
gdouble amount)
|
gdouble amount)
|
||||||
{
|
{
|
||||||
GimpPixelRgn srcPR, destPR;
|
GimpPixelRgn srcPR, destPR;
|
||||||
gint x1, y1, x2, y2;
|
gint x1, y1, width, height;
|
||||||
|
|
||||||
/* initialize pixel regions */
|
/* initialize pixel regions */
|
||||||
gimp_pixel_rgn_init (&srcPR, drawable,
|
gimp_pixel_rgn_init (&srcPR, drawable,
|
||||||
|
@ -545,16 +544,18 @@ unsharp_mask (GimpDrawable *drawable,
|
||||||
0, 0, drawable->width, drawable->height, TRUE, TRUE);
|
0, 0, drawable->width, drawable->height, TRUE, TRUE);
|
||||||
|
|
||||||
/* Get the input */
|
/* Get the input */
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
|
||||||
|
&x1, &y1, &width, &height))
|
||||||
|
return;
|
||||||
|
|
||||||
unsharp_region (&srcPR, &destPR, drawable->bpp,
|
unsharp_region (&srcPR, &destPR, drawable->bpp,
|
||||||
radius, amount,
|
radius, amount,
|
||||||
x1, x2, y1, y2,
|
x1, x1 + width, y1, y1 + width,
|
||||||
TRUE);
|
TRUE);
|
||||||
|
|
||||||
gimp_drawable_flush (drawable);
|
gimp_drawable_flush (drawable);
|
||||||
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
|
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
|
||||||
gimp_drawable_update (drawable->drawable_id, x1, y1, x2 - x1, y2 - y1);
|
gimp_drawable_update (drawable->drawable_id, x1, y1, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform an unsharp mask on the region, given a source region, dest.
|
/* Perform an unsharp mask on the region, given a source region, dest.
|
||||||
|
|
|
@ -93,7 +93,7 @@ static gdouble isteps = 20.0;
|
||||||
static gboolean source_drw_has_alpha = FALSE;
|
static gboolean source_drw_has_alpha = FALSE;
|
||||||
|
|
||||||
static gint effect_width, effect_height;
|
static gint effect_width, effect_height;
|
||||||
static gint border_x1, border_y1, border_x2, border_y2;
|
static gint border_x, border_y, border_w, border_h;
|
||||||
|
|
||||||
static GtkWidget *dialog;
|
static GtkWidget *dialog;
|
||||||
|
|
||||||
|
@ -444,8 +444,8 @@ rgb_to_hsl (GimpDrawable *drawable,
|
||||||
|
|
||||||
maxc = drawable->width * drawable->height;
|
maxc = drawable->width * drawable->height;
|
||||||
|
|
||||||
gimp_pixel_rgn_init (®ion, drawable, border_x1, border_y1,
|
gimp_pixel_rgn_init (®ion, drawable, border_x, border_y,
|
||||||
border_x2 - border_x1, border_y2 - border_y1, FALSE, FALSE);
|
border_w, border_h, FALSE, FALSE);
|
||||||
|
|
||||||
themap = g_new (guchar, maxc);
|
themap = g_new (guchar, maxc);
|
||||||
|
|
||||||
|
@ -496,14 +496,12 @@ compute_lic (GimpDrawable *drawable,
|
||||||
GimpPixelRgn src_rgn, dest_rgn;
|
GimpPixelRgn src_rgn, dest_rgn;
|
||||||
|
|
||||||
gimp_pixel_rgn_init (&src_rgn, drawable,
|
gimp_pixel_rgn_init (&src_rgn, drawable,
|
||||||
border_x1, border_y1,
|
border_x, border_y,
|
||||||
border_x2 - border_x1,
|
border_w, border_h, FALSE, FALSE);
|
||||||
border_y2 - border_y1, FALSE, FALSE);
|
|
||||||
|
|
||||||
gimp_pixel_rgn_init (&dest_rgn, drawable,
|
gimp_pixel_rgn_init (&dest_rgn, drawable,
|
||||||
border_x1, border_y1,
|
border_x, border_y,
|
||||||
border_x2 - border_x1,
|
border_w, border_h, TRUE, TRUE);
|
||||||
border_y2 - border_y1, TRUE, TRUE);
|
|
||||||
|
|
||||||
for (ycount = 0; ycount < src_rgn.h; ycount++)
|
for (ycount = 0; ycount < src_rgn.h; ycount++)
|
||||||
{
|
{
|
||||||
|
@ -563,8 +561,9 @@ compute_image (GimpDrawable *drawable)
|
||||||
|
|
||||||
/* Get some useful info on the input drawable */
|
/* Get some useful info on the input drawable */
|
||||||
/* ========================================== */
|
/* ========================================== */
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id,
|
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
|
||||||
&border_x1, &border_y1, &border_x2, &border_y2);
|
&border_x, &border_y, &border_w, &border_h))
|
||||||
|
return;
|
||||||
|
|
||||||
gimp_progress_init (_("Van Gogh (LIC)"));
|
gimp_progress_init (_("Van Gogh (LIC)"));
|
||||||
|
|
||||||
|
@ -609,8 +608,8 @@ compute_image (GimpDrawable *drawable)
|
||||||
|
|
||||||
gimp_drawable_flush (drawable);
|
gimp_drawable_flush (drawable);
|
||||||
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
|
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
|
||||||
gimp_drawable_update (drawable->drawable_id, border_x1, border_y1,
|
gimp_drawable_update (drawable->drawable_id, border_x, border_y,
|
||||||
border_x2 - border_x1, border_y2 - border_y1);
|
border_w, border_h);
|
||||||
|
|
||||||
gimp_displays_flush ();
|
gimp_displays_flush ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,10 +403,10 @@ explorer (GimpDrawable * drawable)
|
||||||
gint height;
|
gint height;
|
||||||
gint bpp;
|
gint bpp;
|
||||||
gint row;
|
gint row;
|
||||||
gint x1;
|
gint x;
|
||||||
gint y1;
|
gint y;
|
||||||
gint x2;
|
gint w;
|
||||||
gint y2;
|
gint h;
|
||||||
guchar *src_row;
|
guchar *src_row;
|
||||||
guchar *dest_row;
|
guchar *dest_row;
|
||||||
|
|
||||||
|
@ -416,7 +416,8 @@ explorer (GimpDrawable * drawable)
|
||||||
* need to be done for correct operation. (It simply makes it go
|
* need to be done for correct operation. (It simply makes it go
|
||||||
* faster, since fewer pixels need to be operated on).
|
* faster, since fewer pixels need to be operated on).
|
||||||
*/
|
*/
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
if (! gimp_drawable_mask_intersect (drawable->drawable_id, &x, &y, &w, &h))
|
||||||
|
return;
|
||||||
|
|
||||||
/* Get the size of the input image. (This will/must be the same
|
/* Get the size of the input image. (This will/must be the same
|
||||||
* as the size of the output image.
|
* as the size of the output image.
|
||||||
|
@ -426,8 +427,8 @@ explorer (GimpDrawable * drawable)
|
||||||
bpp = drawable->bpp;
|
bpp = drawable->bpp;
|
||||||
|
|
||||||
/* allocate row buffers */
|
/* allocate row buffers */
|
||||||
src_row = g_new (guchar, bpp * (x2 - x1));
|
src_row = g_new (guchar, bpp * w);
|
||||||
dest_row = g_new (guchar, bpp * (x2 - x1));
|
dest_row = g_new (guchar, bpp * w);
|
||||||
|
|
||||||
/* initialize the pixel regions */
|
/* initialize the pixel regions */
|
||||||
gimp_pixel_rgn_init (&srcPR, drawable, 0, 0, width, height, FALSE, FALSE);
|
gimp_pixel_rgn_init (&srcPR, drawable, 0, 0, width, height, FALSE, FALSE);
|
||||||
|
@ -448,28 +449,28 @@ explorer (GimpDrawable * drawable)
|
||||||
colormap[i].b);
|
colormap[i].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (row = y1; row < y2; row++)
|
for (row = y; row < y + h; row++)
|
||||||
{
|
{
|
||||||
gimp_pixel_rgn_get_row (&srcPR, src_row, x1, row, (x2 - x1));
|
gimp_pixel_rgn_get_row (&srcPR, src_row, x, row, w);
|
||||||
|
|
||||||
explorer_render_row (src_row,
|
explorer_render_row (src_row,
|
||||||
dest_row,
|
dest_row,
|
||||||
row,
|
row,
|
||||||
(x2 - x1),
|
w,
|
||||||
bpp);
|
bpp);
|
||||||
|
|
||||||
/* store the dest */
|
/* store the dest */
|
||||||
gimp_pixel_rgn_set_row (&destPR, dest_row, x1, row, (x2 - x1));
|
gimp_pixel_rgn_set_row (&destPR, dest_row, x, row, w);
|
||||||
|
|
||||||
if ((row % 10) == 0)
|
if ((row % 10) == 0)
|
||||||
gimp_progress_update ((double) row / (double) (y2 - y1));
|
gimp_progress_update ((double) row / (double) h);
|
||||||
}
|
}
|
||||||
gimp_progress_update (1.0);
|
gimp_progress_update (1.0);
|
||||||
|
|
||||||
/* update the processed region */
|
/* update the processed region */
|
||||||
gimp_drawable_flush (drawable);
|
gimp_drawable_flush (drawable);
|
||||||
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
|
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
|
||||||
gimp_drawable_update (drawable->drawable_id, x1, y1, (x2 - x1), (y2 - y1));
|
gimp_drawable_update (drawable->drawable_id, x, y, w, h);
|
||||||
|
|
||||||
g_free (src_row);
|
g_free (src_row);
|
||||||
g_free (dest_row);
|
g_free (dest_row);
|
||||||
|
|
|
@ -98,7 +98,7 @@ gdouble org_scale_x_factor, org_scale_y_factor;
|
||||||
|
|
||||||
|
|
||||||
/* Stuff for the preview bit */
|
/* Stuff for the preview bit */
|
||||||
static gint sel_x1, sel_y1, sel_x2, sel_y2;
|
static gint sel_x, sel_y;
|
||||||
static gint sel_width, sel_height;
|
static gint sel_width, sel_height;
|
||||||
gint preview_width, preview_height;
|
gint preview_width, preview_height;
|
||||||
gdouble scale_x_factor, scale_y_factor;
|
gdouble scale_x_factor, scale_y_factor;
|
||||||
|
@ -178,12 +178,14 @@ run (const gchar *name,
|
||||||
if (! gimp_selection_is_empty (gfig_context->image_id))
|
if (! gimp_selection_is_empty (gfig_context->image_id))
|
||||||
gimp_selection_none (gfig_context->image_id);
|
gimp_selection_none (gfig_context->image_id);
|
||||||
|
|
||||||
gimp_drawable_mask_bounds (drawable_id,
|
if (! gimp_drawable_mask_intersect (drawable_id, &sel_x, &sel_y,
|
||||||
&sel_x1, &sel_y1, &sel_x2, &sel_y2);
|
&sel_width, &sel_height))
|
||||||
|
{
|
||||||
sel_width = sel_x2 - sel_x1;
|
gimp_context_pop ();
|
||||||
sel_height = sel_y2 - sel_y1;
|
|
||||||
|
|
||||||
|
gimp_image_undo_group_end (gfig_context->image_id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Calculate preview size */
|
/* Calculate preview size */
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ brushdmenuselect (GtkWidget *widget,
|
||||||
gint bpp;
|
gint bpp;
|
||||||
gint x, y;
|
gint x, y;
|
||||||
ppm_t *p;
|
ppm_t *p;
|
||||||
gint x1, y1, x2, y2;
|
gint x1, y1, w, h;
|
||||||
gint row;
|
gint row;
|
||||||
GimpDrawable *drawable;
|
GimpDrawable *drawable;
|
||||||
gint rowstride;
|
gint rowstride;
|
||||||
|
@ -132,46 +132,50 @@ brushdmenuselect (GtkWidget *widget,
|
||||||
|
|
||||||
drawable = gimp_drawable_get (id);
|
drawable = gimp_drawable_get (id);
|
||||||
|
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
if (! gimp_drawable_mask_intersect (drawable->drawable_id, &x1, &y1, &w, &h))
|
||||||
|
return;
|
||||||
|
|
||||||
bpp = gimp_drawable_bpp (drawable->drawable_id);
|
bpp = gimp_drawable_bpp (drawable->drawable_id);
|
||||||
|
|
||||||
ppm_kill (&brushppm);
|
ppm_kill (&brushppm);
|
||||||
ppm_new (&brushppm, x2 - x1, y2 - y1);
|
ppm_new (&brushppm, w, h);
|
||||||
p = &brushppm;
|
p = &brushppm;
|
||||||
|
|
||||||
rowstride = p->width * 3;
|
rowstride = p->width * 3;
|
||||||
|
|
||||||
src_row = g_new (guchar, (x2 - x1) * bpp);
|
src_row = g_new (guchar, w * bpp);
|
||||||
|
|
||||||
gimp_pixel_rgn_init (&src_rgn, drawable,
|
gimp_pixel_rgn_init (&src_rgn, drawable,
|
||||||
0, 0, x2 - x1, y2 - y1,
|
0, 0, w, h, FALSE, FALSE);
|
||||||
FALSE, FALSE);
|
|
||||||
|
|
||||||
if (bpp == 3)
|
if (bpp == 3)
|
||||||
{ /* RGB */
|
{ /* RGB */
|
||||||
int bpr = (x2 - x1) * 3;
|
gint bpr = w * 3;
|
||||||
|
gint y2 = y1 + h;
|
||||||
|
|
||||||
for (row = 0, y = y1; y < y2; row++, y++)
|
for (row = 0, y = y1; y < y2; row++, y++)
|
||||||
{
|
{
|
||||||
gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, (x2 - x1));
|
gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, w);
|
||||||
memcpy (p->col + row*rowstride, src_row, bpr);
|
memcpy (p->col + row*rowstride, src_row, bpr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* RGBA (bpp > 3) GrayA (bpp == 2) or Gray */
|
{ /* RGBA (bpp > 3) GrayA (bpp == 2) or Gray */
|
||||||
gboolean is_gray = ((bpp > 3) ? TRUE : FALSE);
|
gboolean is_gray = ((bpp > 3) ? TRUE : FALSE);
|
||||||
|
gint y2 = y1 + h;
|
||||||
|
|
||||||
for (row = 0, y = y1; y < y2; row++, y++)
|
for (row = 0, y = y1; y < y2; row++, y++)
|
||||||
{
|
{
|
||||||
guchar *tmprow = p->col + row * rowstride;
|
guchar *tmprow = p->col + row * rowstride;
|
||||||
guchar *tmprow_ptr;
|
guchar *tmprow_ptr;
|
||||||
|
gint x2 = x1 + w;
|
||||||
|
|
||||||
gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, (x2 - x1));
|
|
||||||
|
gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, w);
|
||||||
src = src_row;
|
src = src_row;
|
||||||
tmprow_ptr = tmprow;
|
tmprow_ptr = tmprow;
|
||||||
/* Possible micro-optimization here:
|
/* Possible micro-optimization here:
|
||||||
* src_end = src + src_rgn.bpp * (x2-x1);
|
* src_end = src + src_rgn.bpp * w);
|
||||||
* for ( ; src < src_end ; src += src_rgn.bpp)
|
* for ( ; src < src_end ; src += src_rgn.bpp)
|
||||||
*/
|
*/
|
||||||
for (x = x1; x < x2; x++)
|
for (x = x1; x < x2; x++)
|
||||||
|
|
|
@ -282,7 +282,7 @@ typedef struct
|
||||||
{
|
{
|
||||||
gint is_color;
|
gint is_color;
|
||||||
gint has_alpha;
|
gint has_alpha;
|
||||||
gint x1, y1, x2, y2; /* mask bounds */
|
gint x, y, w, h; /* mask bounds */
|
||||||
gint tile_width, tile_height;
|
gint tile_width, tile_height;
|
||||||
/* these values don't belong to drawable, though. */
|
/* these values don't belong to drawable, though. */
|
||||||
} DrawableInfo;
|
} DrawableInfo;
|
||||||
|
@ -850,8 +850,11 @@ plugin_run (const gchar *name,
|
||||||
drawable = gimp_drawable_get (param[2].data.d_drawable);
|
drawable = gimp_drawable_get (param[2].data.d_drawable);
|
||||||
dinfo.is_color = gimp_drawable_is_rgb (drawable->drawable_id);
|
dinfo.is_color = gimp_drawable_is_rgb (drawable->drawable_id);
|
||||||
dinfo.has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
dinfo.has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id, &dinfo.x1, &dinfo.y1,
|
|
||||||
&dinfo.x2, &dinfo.y2);
|
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
|
||||||
|
&dinfo.x, &dinfo.y, &dinfo.w, &dinfo.h))
|
||||||
|
return;
|
||||||
|
|
||||||
dinfo.tile_width = gimp_tile_width ();
|
dinfo.tile_width = gimp_tile_width ();
|
||||||
dinfo.tile_height = gimp_tile_height ();
|
dinfo.tile_height = gimp_tile_height ();
|
||||||
|
|
||||||
|
@ -1007,8 +1010,8 @@ plugin_do (void)
|
||||||
calc_deinit ();
|
calc_deinit ();
|
||||||
gimp_drawable_flush (drawable);
|
gimp_drawable_flush (drawable);
|
||||||
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
|
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
|
||||||
gimp_drawable_update (drawable->drawable_id, dinfo.x1, dinfo.y1,
|
gimp_drawable_update (drawable->drawable_id, dinfo.x, dinfo.y,
|
||||||
(dinfo.x2 - dinfo.x1), (dinfo.y2 - dinfo.y1));
|
dinfo.w, dinfo.h);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* these routines should be almost rewritten anyway */
|
/* these routines should be almost rewritten anyway */
|
||||||
|
@ -1018,19 +1021,16 @@ plugin_do_non_asupsample (void)
|
||||||
{
|
{
|
||||||
GimpPixelRgn src_rgn, dest_rgn;
|
GimpPixelRgn src_rgn, dest_rgn;
|
||||||
gpointer pr;
|
gpointer pr;
|
||||||
gint width, height;
|
|
||||||
gint progress, max_progress;
|
gint progress, max_progress;
|
||||||
|
|
||||||
width = dinfo.x2 - dinfo.x1;
|
|
||||||
height = dinfo.y2 - dinfo.y1;
|
|
||||||
|
|
||||||
progress = 0;
|
progress = 0;
|
||||||
max_progress = width * height;
|
max_progress = dinfo.w * dinfo.h;
|
||||||
|
|
||||||
gimp_pixel_rgn_init (&src_rgn, drawable,
|
gimp_pixel_rgn_init (&src_rgn, drawable,
|
||||||
dinfo.x1, dinfo.y1, width, height, FALSE, FALSE);
|
dinfo.x, dinfo.y, dinfo.w, dinfo.h, FALSE, FALSE);
|
||||||
gimp_pixel_rgn_init (&dest_rgn, drawable,
|
gimp_pixel_rgn_init (&dest_rgn, drawable,
|
||||||
dinfo.x1, dinfo.y1, width, height, TRUE, TRUE);
|
dinfo.x, dinfo.y, dinfo.w, dinfo.h, TRUE, TRUE);
|
||||||
|
|
||||||
for (pr = gimp_pixel_rgns_register (2, &src_rgn, &dest_rgn);
|
for (pr = gimp_pixel_rgns_register (2, &src_rgn, &dest_rgn);
|
||||||
pr != NULL; pr = gimp_pixel_rgns_process (pr))
|
pr != NULL; pr = gimp_pixel_rgns_process (pr))
|
||||||
|
@ -1093,8 +1093,8 @@ plugin_do_asupsample (void)
|
||||||
|
|
||||||
tk_write = gimp_pixel_fetcher_new (drawable, TRUE);
|
tk_write = gimp_pixel_fetcher_new (drawable, TRUE);
|
||||||
|
|
||||||
gimp_adaptive_supersample_area (dinfo.x1, dinfo.y1,
|
gimp_adaptive_supersample_area (dinfo.x, dinfo.y,
|
||||||
dinfo.x2 - 1, dinfo.y2 - 1,
|
dinfo.x + dinfo.w - 1, dinfo.y + dinfo.h - 1,
|
||||||
pvals.asupsample_max_depth,
|
pvals.asupsample_max_depth,
|
||||||
pvals.asupsample_threshold,
|
pvals.asupsample_threshold,
|
||||||
plugin_render_func,
|
plugin_render_func,
|
||||||
|
|
|
@ -347,6 +347,9 @@ gint
|
||||||
image_setup (GimpDrawable *drawable,
|
image_setup (GimpDrawable *drawable,
|
||||||
gint interactive)
|
gint interactive)
|
||||||
{
|
{
|
||||||
|
gint w, h;
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
compute_maps ();
|
compute_maps ();
|
||||||
|
|
||||||
/* Get some useful info on the input drawable */
|
/* Get some useful info on the input drawable */
|
||||||
|
@ -355,8 +358,14 @@ image_setup (GimpDrawable *drawable,
|
||||||
input_drawable = drawable;
|
input_drawable = drawable;
|
||||||
output_drawable = drawable;
|
output_drawable = drawable;
|
||||||
|
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id,
|
ret = gimp_drawable_mask_intersect (drawable->drawable_id,
|
||||||
&border_x1, &border_y1, &border_x2, &border_y2);
|
&border_x1, &border_y1, &w, &h);
|
||||||
|
|
||||||
|
border_x2 = border_x1 + w;
|
||||||
|
border_y2 = border_y1 + h;
|
||||||
|
|
||||||
|
if (! ret)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
width = input_drawable->width;
|
width = input_drawable->width;
|
||||||
height = input_drawable->height;
|
height = input_drawable->height;
|
||||||
|
|
|
@ -270,8 +270,8 @@ run (const gchar *name,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_RUN_WITH_LAST_VALS:
|
case GIMP_RUN_WITH_LAST_VALS:
|
||||||
image_setup (drawable, FALSE);
|
if (image_setup (drawable, FALSE))
|
||||||
compute_image ();
|
compute_image ();
|
||||||
gimp_displays_flush ();
|
gimp_displays_flush ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -305,8 +305,8 @@ run (const gchar *name,
|
||||||
mapvals.transparent_background = (gint) param[23].data.d_int32;
|
mapvals.transparent_background = (gint) param[23].data.d_int32;
|
||||||
|
|
||||||
check_drawables ();
|
check_drawables ();
|
||||||
image_setup (drawable, FALSE);
|
if (image_setup (drawable, FALSE))
|
||||||
compute_image ();
|
compute_image ();
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1118,9 +1118,8 @@ main_dialog (GimpDrawable *drawable)
|
||||||
gdk_cursor_unref (cursor);
|
gdk_cursor_unref (cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
image_setup (drawable, TRUE);
|
if (image_setup (drawable, TRUE))
|
||||||
|
preview_compute ();
|
||||||
preview_compute ();
|
|
||||||
|
|
||||||
if (gimp_dialog_run (GIMP_DIALOG (appwin)) == GTK_RESPONSE_OK)
|
if (gimp_dialog_run (GIMP_DIALOG (appwin)) == GTK_RESPONSE_OK)
|
||||||
run = TRUE;
|
run = TRUE;
|
||||||
|
|
|
@ -41,7 +41,7 @@ gint imgtype,width,height,in_channels,out_channels,image_id;
|
||||||
GimpRGB background;
|
GimpRGB background;
|
||||||
gdouble oldtreshold;
|
gdouble oldtreshold;
|
||||||
|
|
||||||
gint border_x1, border_y1, border_x2, border_y2;
|
gint border_x, border_y, border_w, border_h;
|
||||||
|
|
||||||
/******************/
|
/******************/
|
||||||
/* Implementation */
|
/* Implementation */
|
||||||
|
@ -153,7 +153,7 @@ gint
|
||||||
checkbounds (gint x,
|
checkbounds (gint x,
|
||||||
gint y)
|
gint y)
|
||||||
{
|
{
|
||||||
if (x < border_x1 || y < border_y1 || x >= border_x2 || y >= border_y2)
|
if (x < border_x || y < border_y || x >= border_x + border_w || y >= border_y + border_h)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
else
|
else
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -361,8 +361,9 @@ image_setup (GimpDrawable *drawable,
|
||||||
input_drawable = drawable;
|
input_drawable = drawable;
|
||||||
output_drawable = drawable;
|
output_drawable = drawable;
|
||||||
|
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id,
|
if (! gimp_drawable_mask_intersect (drawable->drawable_id, &border_x, &border_y,
|
||||||
&border_x1, &border_y1, &border_x2, &border_y2);
|
&border_w, &border_h))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
width = input_drawable->width;
|
width = input_drawable->width;
|
||||||
height = input_drawable->height;
|
height = input_drawable->height;
|
||||||
|
|
|
@ -251,8 +251,8 @@ run (const gchar *name,
|
||||||
case GIMP_RUN_WITH_LAST_VALS:
|
case GIMP_RUN_WITH_LAST_VALS:
|
||||||
gimp_get_data (PLUG_IN_PROC, &mapvals);
|
gimp_get_data (PLUG_IN_PROC, &mapvals);
|
||||||
check_drawables (drawable);
|
check_drawables (drawable);
|
||||||
image_setup (drawable, FALSE);
|
if (image_setup (drawable, FALSE))
|
||||||
compute_image ();
|
compute_image ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_RUN_NONINTERACTIVE:
|
case GIMP_RUN_NONINTERACTIVE:
|
||||||
|
@ -309,8 +309,8 @@ run (const gchar *name,
|
||||||
mapvals.cylindermap_id[i] = param[47+i].data.d_drawable;
|
mapvals.cylindermap_id[i] = param[47+i].data.d_drawable;
|
||||||
|
|
||||||
check_drawables (drawable);
|
check_drawables (drawable);
|
||||||
image_setup (drawable, FALSE);
|
if (image_setup (drawable, FALSE))
|
||||||
compute_image ();
|
compute_image ();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,9 @@ compute_preview (gint x,
|
||||||
|
|
||||||
init_compute ();
|
init_compute ();
|
||||||
|
|
||||||
|
if (! preview_surface)
|
||||||
|
return;
|
||||||
|
|
||||||
p1 = int_to_pos (x, y);
|
p1 = int_to_pos (x, y);
|
||||||
p2 = int_to_pos (x + w, y + h);
|
p2 = int_to_pos (x + w, y + h);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue