[gimp/soc-2009-siox-drb] 8.9



commit c620f78d22bff0e473e616bcaf06fa7e9bdb009f
Author: Jie Ding <jieding src gnome org>
Date:   Sun Aug 9 17:53:33 2009 +0800

    8.9

 app/base/siox.c                            |   27 +++++++++-------
 app/base/siox.h                            |    4 ++-
 app/core/gimpdrawable-foreground-extract.c |    6 +++-
 app/core/gimpdrawable-foreground-extract.h |    9 ++++++
 app/tools/gimpforegroundselecttool.c       |   44 +++++++++++++++++-----------
 5 files changed, 59 insertions(+), 31 deletions(-)
---
diff --git a/app/base/siox.c b/app/base/siox.c
index 5a416c8..ad025a1 100644
--- a/app/base/siox.c
+++ b/app/base/siox.c
@@ -1291,7 +1291,9 @@ siox_drb (SioxState    *state,
           gfloat        threshold,
           const gdouble sensitivity[3],
           gboolean      multiblob,
-	  gint          smoothness)
+	  gint          smoothness,
+	  GimpVector2  *drbpoints,
+          gint          drbnum)
 {
   PixelRegion  srcPR;
   PixelRegion  mapPR;
@@ -1300,7 +1302,8 @@ siox_drb (SioxState    *state,
   gfloat       clustersize;
   gfloat       limits[3];
   gint         n;
-
+  gint         p;
+  
   g_return_if_fail (state != NULL);
   g_return_if_fail (mask != NULL && tile_manager_bpp (mask) == 1);
 	
@@ -1432,16 +1435,16 @@ siox_drb (SioxState    *state,
     g_hash_table_foreach_remove(state->cache,siox_cache_remove_fg,NULL);
   if (optionsrefinement & SIOX_DRB_CHANGE_THRESHOLD)
     optionsrefinement = SIOX_DRB_RECALCULATE;
-//  if (optionsrefinement & (SIOX_DRB_ADD |
-//                           SIOX_DRB_SUBTRACT)) 
-//    {
-    	 
-      pixel_region_init (&srcPR, state->pixels,
-                         x , y , state->width, state->height, FALSE);
-      pixel_region_init (&mapPR, mask, x, y,
-                         brush_radius * 2,
-                         brush_radius * 2, TRUE);
 
+  for (p = 0; p<drbnum; p++)
+    { 
+      pixel_region_init (&srcPR, state->pixels,
+                       drbpoints[p].x - brush_radius, drbpoints[p].y - brush_radius, brush_radius * 2,
+                       brush_radius * 2, FALSE);
+ 
+      pixel_region_init (&mapPR, mask, drbpoints[p].x- brush_radius , drbpoints[p].y - brush_radius,
+                       brush_radius * 2, brush_radius * 2, TRUE);
+    	 
       for (pr = pixel_regions_register (2, &srcPR, &mapPR);
            pr != NULL;
            pr = pixel_regions_process (pr))
@@ -1521,7 +1524,7 @@ siox_drb (SioxState    *state,
               map += mapPR.rowstride;
             }
         }
-    //}
+    }
 }
 
 /**
diff --git a/app/base/siox.h b/app/base/siox.h
index 1fd94f0..224bd02 100644
--- a/app/base/siox.h
+++ b/app/base/siox.h
@@ -81,7 +81,9 @@ void        siox_drb                (SioxState          *state,
                                      gfloat              threshold,
                                      const gdouble       sensitivity[3],
                                      gboolean            multiblob,
-                                     gint                smoothness);
+                                     gint                smoothness,
+                                     GimpVector2        *drbpoints,
+                                     gint                drbnum);
 
 
 #endif /* __SIOX_H__ */
diff --git a/app/core/gimpdrawable-foreground-extract.c b/app/core/gimpdrawable-foreground-extract.c
index e104f3c..5094b62 100644
--- a/app/core/gimpdrawable-foreground-extract.c
+++ b/app/core/gimpdrawable-foreground-extract.c
@@ -72,6 +72,7 @@ gimp_drawable_foreground_extract (GimpDrawable              *drawable,
                                              FALSE,
                                              FALSE,
                                              18,
+                                             NULL,
                                              progress);
 
       gimp_drawable_foreground_extract_siox_done (state);
@@ -128,6 +129,7 @@ gimp_drawable_foreground_extract_siox (GimpDrawable       *mask,
                                        gboolean            multiblob,
                                        gboolean            drbsignal,
                                        gint                brush_radius,
+                                       FgSelectStroke     *drbpoints,
                                        GimpProgress       *progress)
 {
   gint x1, y1;
@@ -173,7 +175,9 @@ gimp_drawable_foreground_extract_siox (GimpDrawable       *mask,
                 sioxdrbthreshold,
                 sensitivity,
 	        multiblob,
-		smoothness);
+		smoothness,
+		drbpoints->points,
+		drbpoints->num_points);
     }
   if (progress)
     gimp_progress_end (progress);
diff --git a/app/core/gimpdrawable-foreground-extract.h b/app/core/gimpdrawable-foreground-extract.h
index cda8464..0f1dd85 100644
--- a/app/core/gimpdrawable-foreground-extract.h
+++ b/app/core/gimpdrawable-foreground-extract.h
@@ -20,6 +20,14 @@
 
 
 /*  general API (as seen from the PDB)  */
+typedef struct
+{
+  gint         width;
+  gboolean     background;	
+  gboolean     refinement;	
+  gint         num_points;
+  GimpVector2 *points;
+} FgSelectStroke;
 
 void       gimp_drawable_foreground_extract (GimpDrawable              *drawable,
                                              GimpForegroundExtractMode  mode,
@@ -43,6 +51,7 @@ void        gimp_drawable_foreground_extract_siox  (GimpDrawable       *mask,
                                                     gboolean            multiblob,
                                                     gboolean            drbsignal,
                                                     gint                brush_radius,
+                                                    FgSelectStroke     *drbpoints,
                                                     GimpProgress       *progress);
 void        gimp_drawable_foreground_extract_siox_done (SioxState      *state);
 
diff --git a/app/tools/gimpforegroundselecttool.c b/app/tools/gimpforegroundselecttool.c
index 6289b49..f007093 100644
--- a/app/tools/gimpforegroundselecttool.c
+++ b/app/tools/gimpforegroundselecttool.c
@@ -54,15 +54,8 @@
 #include "base/siox.h"
 #include "gdk/gdkkeysyms.h"
 
-typedef struct
-{
-  gint         width;
-  gboolean     background;
-  gboolean     refinement;	
-  gint         num_points;
-  GimpVector2 *points;
-} FgSelectStroke;
-
+#include "base/pixel-region.h"
+#include "base/tile-manager.h"
 
 static GObject * gimp_foreground_select_tool_constructor (GType             type,
                                                           guint             n_params,
@@ -130,7 +123,8 @@ static void   gimp_foreground_select_options_notify (GimpForegroundSelectOptions
                                                      GParamSpec                  *pspec,
                                                      GimpForegroundSelectTool    *fg_select);
 
-
+static void    gimp_scan_convert_compose_value_drb (GimpScanConvert   *sc,  
+                                                    TileManager       *tile_manager);
 
 G_DEFINE_TYPE (GimpForegroundSelectTool, gimp_foreground_select_tool,
                GIMP_TYPE_FREE_SELECT_TOOL)
@@ -717,13 +711,11 @@ gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel,
   const GimpVector2           *points;
   gint                         n_points;
   gint                         radius;
-  GimpDisplayShell            *shell;	
+	
   
   drawable  = gimp_image_get_active_drawable (image);
   fg_select = GIMP_FOREGROUND_SELECT_TOOL (free_sel);
   options   = GIMP_FOREGROUND_SELECT_TOOL_GET_OPTIONS (free_sel);
-  shell     = GIMP_DISPLAY_SHELL (display->shell);
-  radius    = (options->stroke_width / shell->scale_y) / 2;
   		
   if (fg_select->idle_id)
     {
@@ -772,6 +764,8 @@ gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel,
 			
       if (fg_select->state)
 	{
+	  if (options->drb)
+	    for (drblist = fg_select->drbsignals; drblist->next; drblist = drblist->next);	
 	  gimp_drawable_foreground_extract_siox (GIMP_DRAWABLE (mask),
 	                                         fg_select->state,
 	                                         fg_select->refinement,
@@ -781,7 +775,8 @@ gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel,
 	                                         options->sensitivity, 
 	                                         ! options->contiguous,
 	                                         options->drb, 
-	                                         radius,
+	                                         options->stroke_width/2,
+						 drblist->data,
 	                                         GIMP_PROGRESS (display));
 
       fg_select->refinement = SIOX_REFINEMENT_NO_CHANGE;
@@ -924,9 +919,8 @@ gimp_foreground_select_tool_stroke (GimpChannel    *mask,
                                      0, 0, stroke->background ? 0 : 255);
      
   else
-    gimp_scan_convert_compose_value (scan_convert,
-                                     gimp_drawable_get_tiles (GIMP_DRAWABLE (mask)),
-                                     0, 0, stroke->refinement ? 255 : 0);	
+    gimp_scan_convert_compose_value_drb (scan_convert,
+                                         gimp_drawable_get_tiles (GIMP_DRAWABLE (mask)));
 	
   gimp_scan_convert_free (scan_convert);
 }
@@ -1062,4 +1056,20 @@ gimp_foreground_select_options_notify (GimpForegroundSelectOptions *options,
     }
 }
 
+static void 
+gimp_scan_convert_compose_value_drb (GimpScanConvert *sc,
+                                     TileManager     *tile_manager)
+
+{
+  PixelRegion      maskPR;
+  gint             x, y;
+  gint             width, height;
+
+  x      = 0;
+  y      = 0;
+  width  = tile_manager_width (tile_manager);
+  height = tile_manager_height (tile_manager);
+
+  pixel_region_init (&maskPR, tile_manager, x, y, width, height, TRUE);
+} 
 



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