[gegl] bin: use gegl:pdf-load directly instead of loading into temp buffer



commit eb7775aa87a26d43072413daa1ea57e136c4d2e5
Author: Øyvind Kolås <pippin gimp org>
Date:   Thu Feb 21 13:21:35 2019 +0100

    bin: use gegl:pdf-load directly instead of loading into temp buffer
    
    This permits using GEGL as a PDF viewer by tweaking the page-number.
    Also adjusted to 36 PPI for rendering when generating PDF thumbnails.

 bin/gegl.c                     |  2 ++
 bin/lua/gegl_vector-stroke.lua | 31 +++++++++++++++++--------------
 bin/ui.c                       | 17 +++++++++++++++--
 3 files changed, 34 insertions(+), 16 deletions(-)
---
diff --git a/bin/gegl.c b/bin/gegl.c
index ca112d244..010b13324 100644
--- a/bin/gegl.c
+++ b/bin/gegl.c
@@ -408,6 +408,8 @@ int gegl_str_has_image_suffix (char *path)
          g_str_has_suffix (path, ".png") ||
          g_str_has_suffix (path, ".xml") ||
          g_str_has_suffix (path, ".svg") ||
+         g_str_has_suffix (path, ".pdf") ||
+         g_str_has_suffix (path, ".PDF") ||
          g_str_has_suffix (path, ".SVG") ||
          g_str_has_suffix (path, ".JPG") ||
          g_str_has_suffix (path, ".PNG") ||
diff --git a/bin/lua/gegl_vector-stroke.lua b/bin/lua/gegl_vector-stroke.lua
index 82629006b..539780199 100644
--- a/bin/lua/gegl_vector-stroke.lua
+++ b/bin/lua/gegl_vector-stroke.lua
@@ -9,8 +9,6 @@ local path = active:get_property("d").value
 --print ('a:' .. a.type)
 
 
-
-
 local no = 0
 
 path:foreach_flat( function(el)
@@ -62,12 +60,20 @@ path:foreach( function(el)
     cr:arc(x, y, dim/15, 0, 3.1415 * 2)
     mrg:listen(Mrg.DRAG, function(ev)
       if ev.type == Mrg.DRAG_MOTION then
-        local x = el.point[coord_no].x
-        local y = el.point[coord_no].y
-        x = x + ev.delta_x
-        y = y + ev.delta_y
-        el.point[coord_no].x = x
-        el.point[coord_no].y = y
+
+        if coord_no == 3 then
+          el.point[3].x = el.point[3].x + ev.delta_x
+          el.point[3].y = el.point[3].y + ev.delta_y
+
+          el.point[2].x = el.point[2].x + ev.delta_x
+          el.point[2].y = el.point[2].y + ev.delta_y
+
+          -- todo also drag part of previous if it indeed is a curve
+        else
+          el.point[coord_no].x = el.point[coord_no].x + ev.delta_x
+          el.point[coord_no].y = el.point[coord_no].y + ev.delta_y
+        end
+
         path:dirty()
         ev:stop_propagate();
       end
@@ -86,12 +92,9 @@ path:foreach( function(el)
     cr:arc(x, y, dim/15, 0, 3.1415 * 2)
     mrg:listen(Mrg.DRAG, function(ev)
       if ev.type == Mrg.DRAG_MOTION then
-        local x = el.point[coord_no].x
-        local y = el.point[coord_no].y
-        x = x + ev.delta_x
-        y = y + ev.delta_y
-        el.point[coord_no].x = x
-        el.point[coord_no].y = y
+        el.point[coord_no].x = el.point[coord_no].x + ev.delta_x
+        el.point[coord_no].y = el.point[coord_no].y + ev.delta_y
+
         path:dirty()
         ev:stop_propagate();
       end
diff --git a/bin/ui.c b/bin/ui.c
index 2d4f286a2..921ca452d 100644
--- a/bin/ui.c
+++ b/bin/ui.c
@@ -974,6 +974,10 @@ int thumbgen_main (int argc, char **argv)
       g_free (o->path);
     o->path = g_strdup (*arg);
     load_path (o);
+
+    if (!strcmp (gegl_node_get_operation (o->source), "gegl:pdf-load"))
+        gegl_node_set (o->source, "ppi", 72/2.0, NULL);
+
     argvs_eval ("thumb");
   }
 
@@ -5927,8 +5931,17 @@ static void load_path_inner (GeState *o,
   o->prev_frame_played = 0;
   o->thumbbar_pan_x = 0;
 
-  fprintf (stderr, "{%s %s\n", o->path, o->save_path);
-  if (g_str_has_suffix (path, ".gif"))
+  if (g_str_has_suffix (path, ".pdf") ||
+      g_str_has_suffix (path, ".PDF"))
+  {
+    o->gegl = gegl_node_new ();
+    o->sink = gegl_node_new_child (o->gegl,
+                       "operation", "gegl:nop", NULL);
+    o->source = gegl_node_new_child (o->gegl,
+         "operation", "gegl:pdf-load", "path", path, NULL);
+    gegl_node_link_many (o->source, o->sink, NULL);
+  }
+  else if (g_str_has_suffix (path, ".gif"))
   {
     o->gegl = gegl_node_new ();
     o->sink = gegl_node_new_child (o->gegl,


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