[gimp] app: Add diagonal_neighbors parameter to...



commit 93bf78b83e4db6add88c79f1c1516c0aa1c881ea
Author: Ell <ell_se yahoo com>
Date:   Fri Jan 8 12:53:07 2016 +0000

    app: Add diagonal_neighbors parameter to...
    
    ...gimp_pickable_contiguous_region_by_seed(), in preperation
    for adding a similar option to the relevant tools.
    
    When this parameter is TRUE, all eight neighbors of each pixel
    are considered when calculating the resulting region, instead
    of just the four orthogonal ones.
    
    This commit also modifies all callers to pass FALSE for this
    parameter, to retain the current behavior.

 app/core/gimpchannel-select.c             |    1 +
 app/core/gimpdrawable-bucket-fill.c       |    1 +
 app/core/gimppickable-contiguous-region.c |   14 +++++++++++++-
 app/core/gimppickable-contiguous-region.h |    1 +
 app/tools/gimpfuzzyselecttool.c           |    1 +
 5 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/app/core/gimpchannel-select.c b/app/core/gimpchannel-select.c
index 896f4a9..22f230c 100644
--- a/app/core/gimpchannel-select.c
+++ b/app/core/gimpchannel-select.c
@@ -519,6 +519,7 @@ gimp_channel_select_fuzzy (GimpChannel         *channel,
                                                     threshold,
                                                     select_transparent,
                                                     select_criterion,
+                                                    FALSE /* no diagonal neighbors */,
                                                     x, y);
 
   if (! sample_merged)
diff --git a/app/core/gimpdrawable-bucket-fill.c b/app/core/gimpdrawable-bucket-fill.c
index c4253a8..93d1bf6 100644
--- a/app/core/gimpdrawable-bucket-fill.c
+++ b/app/core/gimpdrawable-bucket-fill.c
@@ -158,6 +158,7 @@ gimp_drawable_bucket_fill_internal (GimpDrawable        *drawable,
                                                          threshold,
                                                          fill_transparent,
                                                          fill_criterion,
+                                                         FALSE /* no diagonal neighbors */,
                                                          (gint) x,
                                                          (gint) y);
 
diff --git a/app/core/gimppickable-contiguous-region.c b/app/core/gimppickable-contiguous-region.c
index b623d6a..663ba63 100644
--- a/app/core/gimppickable-contiguous-region.c
+++ b/app/core/gimppickable-contiguous-region.c
@@ -74,6 +74,7 @@ static void     find_contiguous_region    (GeglBuffer          *src_buffer,
                                            GimpSelectCriterion  select_criterion,
                                            gboolean             antialias,
                                            gfloat               threshold,
+                                           gboolean             diagonal_neighbors,
                                            gint                 x,
                                            gint                 y,
                                            const gfloat        *col);
@@ -87,6 +88,7 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable        *pickable,
                                          gfloat               threshold,
                                          gboolean             select_transparent,
                                          GimpSelectCriterion  select_criterion,
+                                         gboolean             diagonal_neighbors,
                                          gint                 x,
                                          gint                 y)
 {
@@ -138,7 +140,7 @@ gimp_pickable_contiguous_region_by_seed (GimpPickable        *pickable,
       find_contiguous_region (src_buffer, mask_buffer,
                               format, n_components, has_alpha,
                               select_transparent, select_criterion,
-                              antialias, threshold,
+                              antialias, threshold, diagonal_neighbors,
                               x, y, start_col);
 
       GIMP_TIMER_END("foo");
@@ -496,6 +498,7 @@ find_contiguous_region (GeglBuffer          *src_buffer,
                         GimpSelectCriterion  select_criterion,
                         gboolean             antialias,
                         gfloat               threshold,
+                        gboolean             diagonal_neighbors,
                         gint                 x,
                         gint                 y,
                         const gfloat        *col)
@@ -547,6 +550,15 @@ find_contiguous_region (GeglBuffer          *src_buffer,
                                          row))
             continue;
 
+          if (diagonal_neighbors)
+            {
+              if (new_start >= 0)
+                new_start--;
+
+              if (new_end < gegl_buffer_get_width (src_buffer))
+                new_end++;
+            }
+
           if (y + 1 < gegl_buffer_get_height (src_buffer))
             {
               g_queue_push_tail (coord_stack, GINT_TO_POINTER (y + 1));
diff --git a/app/core/gimppickable-contiguous-region.h b/app/core/gimppickable-contiguous-region.h
index f5e5a1e..24adc1e 100644
--- a/app/core/gimppickable-contiguous-region.h
+++ b/app/core/gimppickable-contiguous-region.h
@@ -24,6 +24,7 @@ GeglBuffer * gimp_pickable_contiguous_region_by_seed  (GimpPickable           *p
                                                        gfloat               threshold,
                                                        gboolean             select_transparent,
                                                        GimpSelectCriterion  select_criterion,
+                                                       gboolean             diagonal_neighbors,
                                                        gint                 x,
                                                        gint                 y);
 
diff --git a/app/tools/gimpfuzzyselecttool.c b/app/tools/gimpfuzzyselecttool.c
index 3af6f2c..ea164f2 100644
--- a/app/tools/gimpfuzzyselecttool.c
+++ b/app/tools/gimpfuzzyselecttool.c
@@ -127,5 +127,6 @@ gimp_fuzzy_select_tool_get_mask (GimpRegionSelectTool *region_select,
                                                   options->threshold / 255.0,
                                                   options->select_transparent,
                                                   options->select_criterion,
+                                                  FALSE /* no diagonal neighbors */,
                                                   x, y);
 }


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