[gimp] Bug 639920: Gaussian blur can't work on specified selection



commit 94a404ed2428ec8a8c19b5c1c17afdfe396b5b7f
Author: Massimo Valentini <mvalentini src gnome org>
Date:   Sun Jan 27 17:04:04 2013 +0100

    Bug 639920: Gaussian blur can't work on specified selection
    
    In presence of a selection extend the area processed

 plug-ins/common/blur-gauss-selective.c |   10 +++++++++-
 plug-ins/common/blur-gauss.c           |   16 ++++++++++++++--
 2 files changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/plug-ins/common/blur-gauss-selective.c b/plug-ins/common/blur-gauss-selective.c
index 1d589c9..5acf2d5 100644
--- a/plug-ins/common/blur-gauss-selective.c
+++ b/plug-ins/common/blur-gauss-selective.c
@@ -736,7 +736,7 @@ sel_gauss (GimpDrawable *drawable,
   gboolean     has_alpha;
   guchar      *dest;
   guchar      *src;
-  gint         x, y;
+  gint         x, y, x2, y2;
   gint         width, height;
   gdouble     *mat;
   gint         numrad;
@@ -752,6 +752,14 @@ sel_gauss (GimpDrawable *drawable,
   mat = g_new (gdouble, numrad);
   init_matrix (radius, mat, numrad);
 
+  x2 = MIN (x + width - 1 + numrad, drawable->width);
+  y2 = MIN (y + height - 1 + numrad, drawable->height);
+
+  x = MAX (x - numrad + 1, 0);
+  y = MAX (y - numrad + 1, 0);
+  width = x2 - x;
+  height = y2 - y;
+
   /*  allocate with extra padding because MMX instructions may read
       more than strictly necessary  */
   src  = g_new (guchar, width * height * bytes + 16);
diff --git a/plug-ins/common/blur-gauss.c b/plug-ins/common/blur-gauss.c
index f100562..edffda0 100644
--- a/plug-ins/common/blur-gauss.c
+++ b/plug-ins/common/blur-gauss.c
@@ -1442,8 +1442,20 @@ gauss (GimpDrawable *drawable,
       preview_buffer = g_new (guchar, width * height * drawable->bpp);
 
     }
-  else if (! gimp_drawable_mask_intersect (drawable->drawable_id,
-                                           &x, &y, &width, &height))
+  else if (gimp_drawable_mask_intersect (drawable->drawable_id,
+                                         &x, &y, &width, &height))
+    { /* With a selection, extend the input area of the amount required */
+      gint hor_extra = method == BLUR_IIR ? 4 : 1 + ceil (horz);
+      gint ver_extra = method == BLUR_IIR ? 4 : 1 + ceil (vert);
+      gint x2        = x + width;
+      gint y2        = y + height;
+
+      x = MAX (x - hor_extra, 0);
+      y = MAX (y - ver_extra, 0);
+      width  = MIN (x2 + hor_extra, drawable->width) - x;
+      height = MIN (y2 + ver_extra, drawable->height) - y;
+    }
+  else
     {
       return;
     }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]