--Sven
This commit is contained in:
Sven Neumann 2000-02-11 02:22:01 +00:00
parent cfbe1bd61a
commit 7213555631
2 changed files with 37 additions and 36 deletions

View File

@ -1,6 +1,11 @@
Thu Feb 10 22:05:42 CET 2000 Sven Neumann <sven@gimp.org>
* plug-ins/common/grid.c: use upper left corner as origin when
calculating the offset, not lower right. Fixes bug #5624.
Thu Feb 10 20:47:51 CET 2000 Sven Neumann <sven@gimp.org> Thu Feb 10 20:47:51 CET 2000 Sven Neumann <sven@gimp.org>
* app/main.c: removed test_function for gserialize. * app/main.c: removed test function for gserialize.
2000-02-10 Michael Natterer <mitch@gimp.org> 2000-02-10 Michael Natterer <mitch@gimp.org>

View File

@ -45,10 +45,10 @@
/* Declare local functions. */ /* Declare local functions. */
static void query (void); static void query (void);
static void run (char *name, static void run (gchar *name,
int nparams, gint nparams,
GParam *param, GParam *param,
int *nreturn_vals, gint *nreturn_vals,
GParam **return_vals); GParam **return_vals);
static gint dialog (gint32 image_ID, GDrawable *drawable); static gint dialog (gint32 image_ID, GDrawable *drawable);
@ -123,8 +123,8 @@ void query (void)
{PARAM_INT8, "iopacity", "Intersection Opacity (0...255)"}, {PARAM_INT8, "iopacity", "Intersection Opacity (0...255)"},
}; };
static GParamDef *return_vals = NULL; static GParamDef *return_vals = NULL;
static int nargs = sizeof (args) / sizeof (args[0]); static gint nargs = sizeof (args) / sizeof (args[0]);
static int nreturn_vals = 0; static gint nreturn_vals = 0;
INIT_I18N(); INIT_I18N();
@ -142,10 +142,10 @@ void query (void)
} }
static void static void
run (char *name, run (gchar *name,
int n_params, gint n_params,
GParam *param, GParam *param,
int *nreturn_vals, gint *nreturn_vals,
GParam **return_vals) GParam **return_vals)
{ {
static GParam values[1]; static GParam values[1];
@ -246,10 +246,10 @@ run (char *name,
G_INLINE_FUNC void G_INLINE_FUNC void
pix_composite (guchar *p1, pix_composite (guchar *p1,
guchar p2[4], guchar p2[4],
int bytes, gint bytes,
int alpha) gint alpha)
{ {
int b; gint b;
if (alpha) if (alpha)
{ {
@ -275,21 +275,15 @@ doit (GDrawable * drawable)
GPixelRgn srcPR, destPR; GPixelRgn srcPR, destPR;
gint width, height, bytes; gint width, height, bytes;
guchar *dest; guchar *dest;
int x, y, alpha; gint x, y, alpha;
/* Get the input area. This is the bounding box of the selection in /* Get the input area. This is the bounding box of the selection in
* the image (or the entire image if there is no selection). Only * the image (or the entire image if there is no selection).
* operating on the input area is simply an optimization. It doesn't
* need to be done for correct operation. (It simply makes it go
* faster, since fewer pixels need to be operated on).
*/ */
gimp_drawable_mask_bounds (drawable->id, &sx1, &sy1, &sx2, &sy2); gimp_drawable_mask_bounds (drawable->id, &sx1, &sy1, &sx2, &sy2);
/* Get the size of the input image. width = gimp_drawable_width (drawable->id);
* (This will/must be the same as the size of the output image.) height = gimp_drawable_height (drawable->id);
*/
width = drawable->width;
height = drawable->height;
bytes = drawable->bpp; bytes = drawable->bpp;
alpha = gimp_drawable_has_alpha (drawable->id); alpha = gimp_drawable_has_alpha (drawable->id);
@ -297,12 +291,12 @@ doit (GDrawable * drawable)
gimp_pixel_rgn_init (&srcPR, drawable, 0, 0, width, height, FALSE, FALSE); gimp_pixel_rgn_init (&srcPR, drawable, 0, 0, width, height, FALSE, FALSE);
gimp_pixel_rgn_init (&destPR, drawable, 0, 0, width, height, TRUE, TRUE); gimp_pixel_rgn_init (&destPR, drawable, 0, 0, width, height, TRUE, TRUE);
dest = malloc (width * bytes); dest = g_malloc (width * bytes);
for (y = sy1; y < sy2; y++) for (y = sy1; y < sy2; y++)
{ {
gimp_pixel_rgn_get_row (&srcPR, dest, sx1, y, (sx2-sx1)); gimp_pixel_rgn_get_row (&srcPR, dest, sx1, y, (sx2-sx1));
if (((y - grid_cfg.voffset + height) % grid_cfg.vspace) < grid_cfg.vwidth ) if ( abs ((y - grid_cfg.voffset) % grid_cfg.vspace) < grid_cfg.vwidth )
{ /* Draw row */ { /* Draw row */
for (x = sx1; x < sx2; x++) for (x = sx1; x < sx2; x++)
{ {
@ -310,14 +304,15 @@ doit (GDrawable * drawable)
} }
} }
if (((y - grid_cfg.voffset + height + ((grid_cfg.iwidth - grid_cfg.vwidth) / 2)) % grid_cfg.vspace) < grid_cfg.iwidth ) if ( abs ((y - grid_cfg.voffset + ((grid_cfg.iwidth - grid_cfg.vwidth) / 2)) % grid_cfg.vspace)
< grid_cfg.iwidth )
{ /* Draw irow */ { /* Draw irow */
for (x = sx1; x < sx2; x++) for (x = sx1; x < sx2; x++)
{ {
if ((((x - grid_cfg.hoffset + width - (grid_cfg.hwidth /2)) % grid_cfg.hspace) >= grid_cfg.ispace if (( abs ((x - grid_cfg.hoffset - (grid_cfg.hwidth / 2)) % grid_cfg.hspace) >= grid_cfg.ispace
&& ((x - grid_cfg.hoffset + width - (grid_cfg.hwidth /2)) % grid_cfg.hspace) < grid_cfg.ioffset) && ( abs (x - grid_cfg.hoffset - (grid_cfg.hwidth / 2)) % grid_cfg.hspace) < grid_cfg.ioffset)
|| (abs(((x - grid_cfg.hoffset + width - (grid_cfg.hwidth /2)) % grid_cfg.hspace) - grid_cfg.hspace) >= grid_cfg.ispace || (abs (((x - grid_cfg.hoffset - (grid_cfg.hwidth / 2)) % grid_cfg.hspace) - grid_cfg.hspace) >= grid_cfg.ispace
&& (abs(((x - grid_cfg.hoffset + width - (grid_cfg.hwidth /2)) % grid_cfg.hspace) - grid_cfg.hspace) < grid_cfg.ioffset))) { && (abs (((x - grid_cfg.hoffset - (grid_cfg.hwidth / 2)) % grid_cfg.hspace) - grid_cfg.hspace) < grid_cfg.ioffset))) {
pix_composite ( &dest[(x-sx1) * bytes], grid_cfg.icolor, bytes, alpha); pix_composite ( &dest[(x-sx1) * bytes], grid_cfg.icolor, bytes, alpha);
} }
} }
@ -325,16 +320,16 @@ doit (GDrawable * drawable)
for (x = sx1; x < sx2; x++) for (x = sx1; x < sx2; x++)
{ {
if (((x - grid_cfg.hoffset + width) % grid_cfg.hspace) < grid_cfg.hwidth ) if (abs ((x - grid_cfg.hoffset) % grid_cfg.hspace) < grid_cfg.hwidth)
{ {
pix_composite ( &dest[(x-sx1) * bytes], grid_cfg.vcolor, bytes, alpha); pix_composite ( &dest[(x-sx1) * bytes], grid_cfg.vcolor, bytes, alpha);
} }
if ((((x - grid_cfg.hoffset + width + ((grid_cfg.iwidth - grid_cfg.hwidth)/ 2)) % grid_cfg.hspace) < grid_cfg.iwidth) if (abs (((x - grid_cfg.hoffset + ((grid_cfg.iwidth - grid_cfg.hwidth) / 2)) % grid_cfg.hspace) < grid_cfg.iwidth)
&& (( (((y - grid_cfg.voffset + height - (grid_cfg.vwidth / 2)) % grid_cfg.vspace) >= grid_cfg.ispace) && (( (abs ((y - grid_cfg.voffset - (grid_cfg.vwidth / 2)) % grid_cfg.vspace) >= grid_cfg.ispace)
&& (((y - grid_cfg.voffset + height - (grid_cfg.vwidth / 2)) % grid_cfg.vspace) < grid_cfg.ioffset)) && (abs ((y - grid_cfg.voffset - (grid_cfg.vwidth / 2)) % grid_cfg.vspace) < grid_cfg.ioffset))
|| (( (abs(((y - grid_cfg.voffset + height - (grid_cfg.vwidth / 2)) % grid_cfg.vspace) - grid_cfg.vspace) >= grid_cfg.ispace) || (( (abs (((y - grid_cfg.voffset - (grid_cfg.vwidth / 2)) % grid_cfg.vspace) - grid_cfg.vspace) >= grid_cfg.ispace)
&& (abs(((y - grid_cfg.voffset + height - (grid_cfg.vwidth / 2)) % grid_cfg.vspace) - grid_cfg.vspace) < grid_cfg.ioffset)) && (abs (((y - grid_cfg.voffset - (grid_cfg.vwidth / 2)) % grid_cfg.vspace) - grid_cfg.vspace) < grid_cfg.ioffset))
)) ))
) )
{ {
@ -345,7 +340,8 @@ doit (GDrawable * drawable)
gimp_pixel_rgn_set_row (&destPR, dest, sx1, y, (sx2-sx1) ); gimp_pixel_rgn_set_row (&destPR, dest, sx1, y, (sx2-sx1) );
gimp_progress_update ((double) y / (double) (sy2 - sy1)); gimp_progress_update ((double) y / (double) (sy2 - sy1));
} }
free (dest);
g_free (dest);
/* update the timred region */ /* update the timred region */
gimp_drawable_flush (drawable); gimp_drawable_flush (drawable);