summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjetil Orbekk <kjetil.orbekk@gmail.com>2016-08-04 23:08:57 -0400
committerKjetil Orbekk <kjetil.orbekk@gmail.com>2016-08-04 23:08:57 -0400
commit8733acc4a69a55162cfd62a6bf2705dfdb72c5ee (patch)
tree97cd8cd0a5f5c3af11fec354a5f6761f5fe3cf73
parent48a9f74752aafd419a259e3db1aa2217aa2e9fca (diff)
Include gegl example code to read and write files.
-rw-r--r--src/gegltest.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/gegltest.c b/src/gegltest.c
new file mode 100644
index 0000000..4201556
--- /dev/null
+++ b/src/gegltest.c
@@ -0,0 +1,59 @@
+#include <gegl.h>
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+ GeglNode *graph, *src, *sink;
+ GeglBuffer *buffer = NULL;
+
+ gegl_init (&argc, &argv);
+
+ if (argc != 3)
+ {
+ g_print ("GEGL based image conversion tool\n");
+ g_print ("Usage: %s <imageA> <imageB>\n", argv[0]);
+ return 1;
+ }
+
+ graph = gegl_node_new ();
+ src = gegl_node_new_child (graph,
+ "operation", "gegl:load",
+ "path", argv[1],
+ NULL);
+ sink = gegl_node_new_child (graph,
+ "operation", "gegl:buffer-sink",
+ "buffer", &buffer,
+ NULL);
+
+ gegl_node_link_many (src, sink, NULL);
+
+ gegl_node_process (sink);
+ g_object_unref (graph);
+
+ /* FIXME: Currently a buffer will always be returned, even if the source is missing */
+ if (!buffer)
+ {
+ g_print ("Failed to open %s\n", argv[1]);
+ return 1;
+ }
+
+ graph = gegl_node_new ();
+ src = gegl_node_new_child (graph,
+ "operation", "gegl:buffer-source",
+ "buffer", buffer,
+ NULL);
+ sink = gegl_node_new_child (graph,
+ "operation", "gegl:save",
+ "path", argv[2],
+ NULL);
+
+ gegl_node_link_many (src, sink, NULL);
+
+ gegl_node_process (sink);
+ g_object_unref (graph);
+
+ g_object_unref (buffer);
+ gegl_exit ();
+ return 0;
+}