[gegl-gtk/soc-2011-warp] clean the warp example, and make the window to adapt to the input buffer size



commit 1aea4f263ffda550f5c9062236167f054ce70948
Author: Michael Murà <batolettre gmail com>
Date:   Thu Jul 21 20:09:01 2011 +0200

    clean the warp example, and make the window to adapt to the input buffer size

 examples/warp.c |   27 +++++++++++----------------
 1 files changed, 11 insertions(+), 16 deletions(-)
---
diff --git a/examples/warp.c b/examples/warp.c
index b83ad24..c0f35b2 100644
--- a/examples/warp.c
+++ b/examples/warp.c
@@ -48,7 +48,7 @@ GtkWidget               *window;
 GtkWidget               *view;
 GtkWidget               *eventbox;
 
-static GeglRectangle     rect   = {0, 0, 512, 512}; /* fixed size for the view/window */
+static GeglRectangle     rect; /* size for the view/window */
 static GeglBuffer       *original_buffer = NULL; /* image to be warped */
 static GeglNode         *readbuf; /* node to read this image */
 
@@ -111,10 +111,6 @@ static gboolean paint_release (GtkWidget      *widget,
 {
   g_source_remove (stroke_timer);
 
-  gegl_dot_node_to_png_default(graph);
-  /* added this, not sure */
-  gegl_node_process (render_node);
-
   return TRUE;
 }
 
@@ -152,6 +148,13 @@ gint
 main (gint    argc,
       gchar **argv)
 {
+  if (argv[1] == NULL)
+    {
+      printf("usage: %s filename.gegl\n", argv[0]);
+      printf("filename.gegl must be a Gegl buffer file, for instance created with the 2geglbuffer example from Gegl.\n");
+      return 0;
+    }
+
   g_thread_init (NULL);
   gtk_init (&argc, &argv);
   gegl_init (&argc, &argv);
@@ -159,14 +162,8 @@ main (gint    argc,
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_window_set_title (GTK_WINDOW (window), "Warp example");
 
-  if (argv[1] == NULL)
-    {
-      original_buffer = gegl_buffer_new (&rect, babl_format ("RGBA float"));
-    }
-  else
-    {
-      original_buffer = gegl_buffer_open (argv[1]);
-    }
+  original_buffer = gegl_buffer_open (argv[1]);
+  rect = *gegl_buffer_get_extent(original_buffer);
 
   create_graph ();
 
@@ -184,14 +181,12 @@ main (gint    argc,
 
   gtk_container_add (GTK_CONTAINER (eventbox), view);
   gtk_container_add (GTK_CONTAINER (window), eventbox);
-  gtk_widget_set_size_request (view, 512, 512);
+  gtk_widget_set_size_request (view, rect.width, rect.height);
 
   g_signal_connect (G_OBJECT (window), "delete-event",
                     G_CALLBACK (gtk_main_quit), window);
   gtk_widget_show_all (window);
 
-  gegl_dot_node_to_png_default(graph);
-
   gtk_main ();
   g_object_unref (graph);
   gegl_buffer_destroy (original_buffer);



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