From ee5f898649aca5c93335580f0f5ac4564ca2ea64 Mon Sep 17 00:00:00 2001 From: GMT 1999 Austin Donnelly Date: Wed, 27 Jan 1999 22:00:44 +0000 Subject: [PATCH] oops - should use the image resolution, not the screen resolution. D'oh! Wed Jan 27 21:52:43 GMT 1999 Austin Donnelly * app/scale.c: oops - should use the image resolution, not the screen resolution. D'oh! * app/gimpdrawable.c: only merge shadow image if there actually is one. * plug-ins/emboss/emboss.c: small optimisation: use gimp_drawable_mask_bounds() to calculate only the pixels that are actually in the selection. --- ChangeLog | 12 ++++++++++++ app/core/gimpdrawable.c | 3 +++ app/display/gimpdisplay-scale.c | 8 ++++---- app/display/gimpdisplayshell-scale.c | 8 ++++---- app/gimpdrawable.c | 3 +++ app/scale.c | 8 ++++---- plug-ins/common/emboss.c | 29 ++++++++++++++++++---------- plug-ins/emboss/emboss.c | 29 ++++++++++++++++++---------- 8 files changed, 68 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index bf548bbe89..b4a0eed012 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Wed Jan 27 21:52:43 GMT 1999 Austin Donnelly + + * app/scale.c: oops - should use the image resolution, not the + screen resolution. D'oh! + + * app/gimpdrawable.c: only merge shadow image if there actually is + one. + + * plug-ins/emboss/emboss.c: small optimisation: use + gimp_drawable_mask_bounds() to calculate only the pixels that + are actually in the selection. + Wed Jan 27 12:25:00 CST 1999 Seth Burgess * plug-ins/script-fu/scripts/add-bevel.scm: fixed the SF-ADJUSTMENT so that diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c index 53b6d41acc..10cf1ced99 100644 --- a/app/core/gimpdrawable.c +++ b/app/core/gimpdrawable.c @@ -111,6 +111,9 @@ gimp_drawable_merge_shadow (GimpDrawable *drawable, int undo) if (! (gimage = gimp_drawable_gimage (drawable))) return; + if (! gimage->shadow) + return; + /* A useful optimization here is to limit the update to the * extents of the selection mask, as it cannot extend beyond * them. diff --git a/app/display/gimpdisplay-scale.c b/app/display/gimpdisplay-scale.c index bb82235283..29f3f50ed6 100644 --- a/app/display/gimpdisplay-scale.c +++ b/app/display/gimpdisplay-scale.c @@ -160,17 +160,17 @@ change_scale (GDisplay *gdisp, /* scale image coord to realworld units (cm, inches, pixels) */ static gdouble -img2real (GDisplay *g, gboolean xdir, gdouble a) +img2real (GDisplay *gdisp, gboolean xdir, gdouble a) { float res; - if (g->dot_for_dot) + if (gdisp->dot_for_dot) return a; if (xdir) - res = monitor_xres; + res = gdisp->gimage->xresolution; else - res = monitor_yres; + res = gdisp->gimage->yresolution; switch (ruler_units) { case GTK_PIXELS: diff --git a/app/display/gimpdisplayshell-scale.c b/app/display/gimpdisplayshell-scale.c index bb82235283..29f3f50ed6 100644 --- a/app/display/gimpdisplayshell-scale.c +++ b/app/display/gimpdisplayshell-scale.c @@ -160,17 +160,17 @@ change_scale (GDisplay *gdisp, /* scale image coord to realworld units (cm, inches, pixels) */ static gdouble -img2real (GDisplay *g, gboolean xdir, gdouble a) +img2real (GDisplay *gdisp, gboolean xdir, gdouble a) { float res; - if (g->dot_for_dot) + if (gdisp->dot_for_dot) return a; if (xdir) - res = monitor_xres; + res = gdisp->gimage->xresolution; else - res = monitor_yres; + res = gdisp->gimage->yresolution; switch (ruler_units) { case GTK_PIXELS: diff --git a/app/gimpdrawable.c b/app/gimpdrawable.c index 53b6d41acc..10cf1ced99 100644 --- a/app/gimpdrawable.c +++ b/app/gimpdrawable.c @@ -111,6 +111,9 @@ gimp_drawable_merge_shadow (GimpDrawable *drawable, int undo) if (! (gimage = gimp_drawable_gimage (drawable))) return; + if (! gimage->shadow) + return; + /* A useful optimization here is to limit the update to the * extents of the selection mask, as it cannot extend beyond * them. diff --git a/app/scale.c b/app/scale.c index bb82235283..29f3f50ed6 100644 --- a/app/scale.c +++ b/app/scale.c @@ -160,17 +160,17 @@ change_scale (GDisplay *gdisp, /* scale image coord to realworld units (cm, inches, pixels) */ static gdouble -img2real (GDisplay *g, gboolean xdir, gdouble a) +img2real (GDisplay *gdisp, gboolean xdir, gdouble a) { float res; - if (g->dot_for_dot) + if (gdisp->dot_for_dot) return a; if (xdir) - res = monitor_xres; + res = gdisp->gimage->xresolution; else - res = monitor_yres; + res = gdisp->gimage->yresolution; switch (ruler_units) { case GTK_PIXELS: diff --git a/plug-ins/common/emboss.c b/plug-ins/common/emboss.c index c816b4106f..a288156d51 100644 --- a/plug-ins/common/emboss.c +++ b/plug-ins/common/emboss.c @@ -314,21 +314,30 @@ int pluginCore(struct piArgs *argp) { GPixelRgn src, dst; gint p_update; gint y; + gint x1, y1, x2, y2; guint width, height; gint bypp, rowsize, has_alpha; guchar *srcbuf, *dstbuf; drw=gimp_drawable_get(argp->drw); - width=drw->width; - height=drw->height; + gimp_drawable_mask_bounds(argp->drw, &x1, &y1, &x2, &y2); + + /* expand the bounds a little */ + x1 = MAX(0, x1 - 5); + y1 = MAX(0, y1 - 5); + x2 = MIN(drw->width, x2+5); + y2 = MIN(drw->height, y2+5); + + width = x2 - x1; + height = y2 - y1; bypp=drw->bpp; p_update = height/20; rowsize = width * bypp; has_alpha = gimp_drawable_has_alpha (argp->drw); - gimp_pixel_rgn_init (&src, drw, 0, 0, width, height, FALSE, FALSE); - gimp_pixel_rgn_init (&dst, drw, 0, 0, width, height, TRUE, TRUE); + gimp_pixel_rgn_init (&src, drw, x1, y1, width, height, FALSE, FALSE); + gimp_pixel_rgn_init (&dst, drw, x1, y1, width, height, TRUE, TRUE); srcbuf=(guchar*)malloc(rowsize*3); dstbuf=(guchar*)malloc(rowsize); @@ -342,25 +351,25 @@ int pluginCore(struct piArgs *argp) { gimp_tile_cache_ntiles((width + gimp_tile_width() - 1) / gimp_tile_width()); /* first row */ - gimp_pixel_rgn_get_rect(&src, srcbuf, 0, 0, width, 3); + gimp_pixel_rgn_get_rect(&src, srcbuf, x1, y1, width, 3); memcpy(srcbuf, srcbuf+rowsize, rowsize); EmbossRow(srcbuf, argp->embossp ? (guchar *)0 : srcbuf, dstbuf, width, bypp, has_alpha); gimp_pixel_rgn_set_row(&dst, dstbuf, 0, 0, width); /* last row */ - gimp_pixel_rgn_get_rect(&src, srcbuf, 0, height-3, width, 3); + gimp_pixel_rgn_get_rect(&src, srcbuf, x1, y2-3, width, 3); memcpy(srcbuf+rowsize*2, srcbuf+rowsize, rowsize); EmbossRow(srcbuf, argp->embossp ? (guchar *)0 : srcbuf, dstbuf, width, bypp, has_alpha); - gimp_pixel_rgn_set_row(&dst, dstbuf, 0, height-1, width); + gimp_pixel_rgn_set_row(&dst, dstbuf, x1, y2-1, width); for(y=0 ;yembossp ? (guchar *)0 : srcbuf, dstbuf, width, bypp, has_alpha); - gimp_pixel_rgn_set_row(&dst, dstbuf, 0, y+1, width); + gimp_pixel_rgn_set_row(&dst, dstbuf, x1, y1+y+1, width); } free(srcbuf); @@ -368,7 +377,7 @@ int pluginCore(struct piArgs *argp) { gimp_drawable_flush(drw); gimp_drawable_merge_shadow (drw->id, TRUE); - gimp_drawable_update(drw->id, 0, 0, width, height); + gimp_drawable_update(drw->id, x1, y1, width, height); gimp_displays_flush(); return 0; diff --git a/plug-ins/emboss/emboss.c b/plug-ins/emboss/emboss.c index c816b4106f..a288156d51 100644 --- a/plug-ins/emboss/emboss.c +++ b/plug-ins/emboss/emboss.c @@ -314,21 +314,30 @@ int pluginCore(struct piArgs *argp) { GPixelRgn src, dst; gint p_update; gint y; + gint x1, y1, x2, y2; guint width, height; gint bypp, rowsize, has_alpha; guchar *srcbuf, *dstbuf; drw=gimp_drawable_get(argp->drw); - width=drw->width; - height=drw->height; + gimp_drawable_mask_bounds(argp->drw, &x1, &y1, &x2, &y2); + + /* expand the bounds a little */ + x1 = MAX(0, x1 - 5); + y1 = MAX(0, y1 - 5); + x2 = MIN(drw->width, x2+5); + y2 = MIN(drw->height, y2+5); + + width = x2 - x1; + height = y2 - y1; bypp=drw->bpp; p_update = height/20; rowsize = width * bypp; has_alpha = gimp_drawable_has_alpha (argp->drw); - gimp_pixel_rgn_init (&src, drw, 0, 0, width, height, FALSE, FALSE); - gimp_pixel_rgn_init (&dst, drw, 0, 0, width, height, TRUE, TRUE); + gimp_pixel_rgn_init (&src, drw, x1, y1, width, height, FALSE, FALSE); + gimp_pixel_rgn_init (&dst, drw, x1, y1, width, height, TRUE, TRUE); srcbuf=(guchar*)malloc(rowsize*3); dstbuf=(guchar*)malloc(rowsize); @@ -342,25 +351,25 @@ int pluginCore(struct piArgs *argp) { gimp_tile_cache_ntiles((width + gimp_tile_width() - 1) / gimp_tile_width()); /* first row */ - gimp_pixel_rgn_get_rect(&src, srcbuf, 0, 0, width, 3); + gimp_pixel_rgn_get_rect(&src, srcbuf, x1, y1, width, 3); memcpy(srcbuf, srcbuf+rowsize, rowsize); EmbossRow(srcbuf, argp->embossp ? (guchar *)0 : srcbuf, dstbuf, width, bypp, has_alpha); gimp_pixel_rgn_set_row(&dst, dstbuf, 0, 0, width); /* last row */ - gimp_pixel_rgn_get_rect(&src, srcbuf, 0, height-3, width, 3); + gimp_pixel_rgn_get_rect(&src, srcbuf, x1, y2-3, width, 3); memcpy(srcbuf+rowsize*2, srcbuf+rowsize, rowsize); EmbossRow(srcbuf, argp->embossp ? (guchar *)0 : srcbuf, dstbuf, width, bypp, has_alpha); - gimp_pixel_rgn_set_row(&dst, dstbuf, 0, height-1, width); + gimp_pixel_rgn_set_row(&dst, dstbuf, x1, y2-1, width); for(y=0 ;yembossp ? (guchar *)0 : srcbuf, dstbuf, width, bypp, has_alpha); - gimp_pixel_rgn_set_row(&dst, dstbuf, 0, y+1, width); + gimp_pixel_rgn_set_row(&dst, dstbuf, x1, y1+y+1, width); } free(srcbuf); @@ -368,7 +377,7 @@ int pluginCore(struct piArgs *argp) { gimp_drawable_flush(drw); gimp_drawable_merge_shadow (drw->id, TRUE); - gimp_drawable_update(drw->id, 0, 0, width, height); + gimp_drawable_update(drw->id, x1, y1, width, height); gimp_displays_flush(); return 0;