[gimp] Bug 765247: Foreground select tool does not respect item offsets



commit a357bfec89abd3a7a4689136922e83c14de10aa6
Author: Massimo Valentini <mvalentini src gnome org>
Date:   Wed Apr 20 06:48:04 2016 +0200

    Bug 765247: Foreground select tool does not respect item offsets

 app/core/gimpdrawable-foreground-extract.c |   38 +++++++++++++++++++++++----
 1 files changed, 32 insertions(+), 6 deletions(-)
---
diff --git a/app/core/gimpdrawable-foreground-extract.c b/app/core/gimpdrawable-foreground-extract.c
index 3178e84..3653e28 100644
--- a/app/core/gimpdrawable-foreground-extract.c
+++ b/app/core/gimpdrawable-foreground-extract.c
@@ -56,6 +56,7 @@ gimp_drawable_foreground_extract (GimpDrawable      *drawable,
   GeglBuffer    *buffer;
   GeglProcessor *processor;
   gdouble        value;
+  gint           off_x, off_y;
 
   g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
   g_return_val_if_fail (GEGL_IS_BUFFER (trimap), NULL);
@@ -98,12 +99,37 @@ gimp_drawable_foreground_extract (GimpDrawable      *drawable,
                                           NULL);
     }
 
-  gegl_node_connect_to (input_node,   "output",
-                        matting_node, "input");
-  gegl_node_connect_to (trimap_node,  "output",
-                        matting_node, "aux");
-  gegl_node_connect_to (matting_node, "output",
-                        output_node,  "input");
+  gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
+
+  if (off_x || off_y)
+    {
+      GeglNode *pre;
+      GeglNode *post;
+
+      pre = gegl_node_new_child (gegl,
+                                 "operation", "gegl:translate",
+                                 "x", -1.0 * off_x,
+                                 "y", -1.0 * off_y,
+                                 NULL);
+      post = gegl_node_new_child (gegl,
+                                  "operation", "gegl:translate",
+                                  "x", 1.0 * off_x,
+                                  "y", 1.0 * off_y,
+                                  NULL);
+
+      gegl_node_connect_to (trimap_node,   "output", pre, "input");
+      gegl_node_connect_to (pre,  "output", matting_node, "aux");
+      gegl_node_link_many (input_node, matting_node, post, output_node, NULL);
+    }
+  else
+    {
+      gegl_node_connect_to (input_node,   "output",
+                            matting_node, "input");
+      gegl_node_connect_to (trimap_node,  "output",
+                            matting_node, "aux");
+      gegl_node_connect_to (matting_node, "output",
+                            output_node,  "input");
+    }
 
   processor = gegl_node_new_processor (output_node, NULL);
 


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