[gimp] app: use GimpBezierDesc in gimp_channel_select_vectors() too



commit 0f91a11b75eff0eca764cc03542f0b41a27510a7
Author: Michael Natterer <mitch gimp org>
Date:   Sun Apr 10 22:42:39 2011 +0200

    app: use GimpBezierDesc in gimp_channel_select_vectors() too

 app/core/gimpchannel-select.c |   50 +++++++++-------------------------------
 1 files changed, 12 insertions(+), 38 deletions(-)
---
diff --git a/app/core/gimpchannel-select.c b/app/core/gimpchannel-select.c
index 9f669e1..db26dbc 100644
--- a/app/core/gimpchannel-select.c
+++ b/app/core/gimpchannel-select.c
@@ -19,6 +19,7 @@
 
 #include <string.h>
 
+#include <cairo.h>
 #include <gegl.h>
 
 #include "libgimpbase/gimpbase.h"
@@ -290,56 +291,29 @@ gimp_channel_select_vectors (GimpChannel    *channel,
                              gdouble         feather_radius_y,
                              gboolean        push_undo)
 {
-  GimpScanConvert *scan_convert;
-  GList           *stroke;
-  gboolean         coords_added = FALSE;
+  const GimpBezierDesc *bezier;
 
   g_return_if_fail (GIMP_IS_CHANNEL (channel));
   g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (channel)));
   g_return_if_fail (undo_desc != NULL);
   g_return_if_fail (GIMP_IS_VECTORS (vectors));
 
-  scan_convert = gimp_scan_convert_new ();
+  bezier = gimp_vectors_get_bezier (vectors);
 
-  for (stroke = vectors->strokes; stroke; stroke = stroke->next)
+  if (bezier && bezier->num_data > 4)
     {
-      GArray   *coords;
-      gboolean  closed;
-
-      coords = gimp_stroke_interpolate (GIMP_STROKE (stroke->data),
-                                        1.0, &closed);
-
-      if (coords && coords->len)
-        {
-          GimpVector2 *points;
-          gint         i;
-
-          points = g_new0 (GimpVector2, coords->len);
+      GimpScanConvert *scan_convert;
 
-          for (i = 0; i < coords->len; i++)
-            {
-              points[i].x = g_array_index (coords, GimpCoords, i).x;
-              points[i].y = g_array_index (coords, GimpCoords, i).y;
-            }
+      scan_convert = gimp_scan_convert_new ();
+      gimp_scan_convert_add_bezier (scan_convert, bezier);
 
-          gimp_scan_convert_add_polyline (scan_convert, coords->len,
-                                          points, TRUE);
-          coords_added = TRUE;
+      gimp_channel_select_scan_convert (channel, undo_desc, scan_convert, 0, 0,
+                                        op, antialias, feather,
+                                        feather_radius_x, feather_radius_y,
+                                        push_undo);
 
-          g_free (points);
-        }
-
-      if (coords)
-        g_array_free (coords, TRUE);
+      gimp_scan_convert_free (scan_convert);
     }
-
-  if (coords_added)
-    gimp_channel_select_scan_convert (channel, undo_desc, scan_convert, 0, 0,
-                                      op, antialias, feather,
-                                      feather_radius_x, feather_radius_y,
-                                      push_undo);
-
-  gimp_scan_convert_free (scan_convert);
 }
 
 



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