Esempio n. 1
0
static void
grey_blur_buffer (GeglBuffer  *input,
                  gdouble      mask_radius,
                  GeglBuffer **dest1,
                  GeglBuffer **dest2)
{
  GeglNode *gegl, *image, *write1, *write2, *grey, *blur1, *blur2;
  gdouble radius, std_dev1, std_dev2;

  gegl = gegl_node_new ();
  image = gegl_node_new_child (gegl,
                "operation", "gegl:buffer-source",
                "buffer", input,
                NULL);
  grey = gegl_node_new_child (gegl,
                "operation", "gegl:grey",
                NULL);

  radius   = 1.0;
  radius   = fabs (radius) + 1.0;
  std_dev1 = sqrt (-(radius * radius) / (2 * log (1.0 / 255.0)));

  radius   = fabs (mask_radius) + 1.0;
  std_dev2 = sqrt (-(radius * radius) / (2 * log (1.0 / 255.0)));

  blur1 =  gegl_node_new_child (gegl,
                "operation", "gegl:gaussian-blur",
                "std_dev_x", std_dev1,
                "std_dev_y", std_dev1,
                NULL);
  blur2 =  gegl_node_new_child (gegl,
                "operation", "gegl:gaussian-blur",
                "std_dev_x", std_dev2,
                "std_dev_y", std_dev2,
                NULL);

  write1 = gegl_node_new_child(gegl,
                "operation", "gegl:buffer-sink",
                "buffer", dest1, NULL);

  write2 = gegl_node_new_child(gegl,
                "operation", "gegl:buffer-sink",
                "buffer", dest2, NULL);

  gegl_node_link_many (image, grey, blur1, write1, NULL);
  gegl_node_process (write1);

  gegl_node_link_many (grey, blur2, write2, NULL);
  gegl_node_process (write2);

  g_object_unref (gegl);
}
Esempio n. 2
0
/* Test that the redraw signal is emitted when the GeglNode has been computed.
 *
 * NOTE: Does not test that the actual drawing happens, or even
 * that queue_redraw is called, as this is hard to observe reliably
 * Redraws can be triggered by other things, and the exposed events
 * can be coalesced by GTK. */
static void
test_redraw_on_computed (int x, int y, float scale,
                         GeglRectangle *input, GeglRectangle *output)
{
    ViewHelperTest test;
    RedrawTestState test_data;
    test_data.expected_result = output;

    setup_helper_test(&test);
    /* Setup will invalidate the node, make sure those events are processed. */
    while (gtk_events_pending()) {
        gtk_main_iteration();
    }
    gegl_node_process (test.out);

    view_helper_set_x(test.helper, x);
    view_helper_set_y(test.helper, y);
    view_helper_set_scale(test.helper, scale);

    g_signal_connect(G_OBJECT(test.helper), "redraw-needed",
                      G_CALLBACK(needs_redraw_event),
                      &test_data);

    g_signal_emit_by_name(test.out, "computed", input, NULL);

    g_timeout_add(300, test_utils_quit_gtk_main, NULL);
    gtk_main();

    g_assert(test_data.needs_redraw_called);

    teardown_helper_test(&test);
}
Esempio n. 3
0
static void
load_cache (GeglProperties *op_magick_load)
{
  if (!op_magick_load->user_data)
    {
      gchar    *filename;
      gchar    *cmd;
      GeglNode *graph, *sink;
      GeglBuffer *newbuf = NULL;

      /* ImageMagick backed fallback FIXME: make this robust.
       * maybe use pipes in a manner similar to the raw loader,
       * or at least use a properly unique filename  */

      filename = g_build_filename (g_get_tmp_dir (), "gegl-magick.png", NULL);
      cmd = g_strdup_printf ("convert \"%s\"'[0]' \"%s\"",
                             op_magick_load->path, filename);
      if (system (cmd) == -1)
        g_warning ("Error executing ImageMagick convert program");

      graph = gegl_graph (sink=gegl_node ("gegl:buffer-sink", "buffer", &newbuf, NULL,
                                          gegl_node ("gegl:png-load", "path", filename, NULL)));
      gegl_node_process (sink);
      op_magick_load->user_data = (gpointer) newbuf;
      g_object_unref (graph);
      g_free (cmd);
      g_free (filename);
    }
}
Esempio n. 4
0
TileManager *
gimp_buffer_to_tiles (GeglBuffer *buffer)
{
  const Babl    *format     = gegl_buffer_get_format (buffer);
  TileManager   *new_tiles  = NULL;
  GeglNode      *source     = NULL;
  GeglNode      *sink       = NULL;

  g_return_val_if_fail (buffer != NULL, NULL);

  /* Setup and process the graph */
  new_tiles = tile_manager_new (gegl_buffer_get_width (buffer),
                                gegl_buffer_get_height (buffer),
                                gimp_babl_format_to_legacy_bpp (format));
  source = gegl_node_new_child (NULL,
                                "operation", "gegl:buffer-source",
                                "buffer",    buffer,
                                NULL);
  sink = gegl_node_new_child (NULL,
                              "operation",    "gimp:tilemanager-sink",
                              "tile-manager", new_tiles,
                              NULL);
  gegl_node_link_many (source, sink, NULL);
  gegl_node_process (sink);

  /* Clenaup */
  g_object_unref (sink);
  g_object_unref (source);

  return new_tiles;
}
Esempio n. 5
0
gint
main (gint    argc,
      gchar **argv)
{
  GeglBuffer *buffer, *buffer2;
  GeglNode   *gegl, *source, *node1, *node2, *node3, *node4, *sink;
  gint i;

  gegl_init (&argc, &argv);

  buffer = test_buffer (2048, 1024, babl_format ("RGBA float"));

#define ITERATIONS 16
  test_start ();
  for (i=0;i< ITERATIONS;i++)
    {
      gegl = gegl_node_new ();
      source = gegl_node_new_child (gegl, "operation", "gegl:buffer-source", "buffer", buffer, NULL);
      node1 = gegl_node_new_child (gegl, "operation", "gegl:brightness-contrast", "contrast", 0.2, NULL);
      node2 = gegl_node_new_child (gegl, "operation", "gegl:brightness-contrast", "contrast", 0.2, NULL);
      node3 = gegl_node_new_child (gegl, "operation", "gegl:brightness-contrast", "contrast", 0.2, NULL);
      node4 = gegl_node_new_child (gegl, "operation", "gegl:brightness-contrast", "contrast", 0.2, NULL);
      sink = gegl_node_new_child (gegl, "operation", "gegl:buffer-sink", "buffer", &buffer2, NULL);

      gegl_node_link_many (source, node1, node2, node3, node4, sink, NULL);
      gegl_node_process (sink);
      g_object_unref (gegl);
      g_object_unref (buffer2);
    }
  test_end ("bcontrast_4x", gegl_buffer_get_pixel_count (buffer) * 16 * ITERATIONS);

  return 0;
}
Esempio n. 6
0
static GeglNode *
photos_base_item_load (PhotosBaseItem *self, GCancellable *cancellable, GError **error)
{
  PhotosBaseItemPrivate *priv = self->priv;
  GeglNode *ret_val = NULL;
  gchar *path = NULL;

  if (priv->graph == NULL)
    {
      path = photos_base_item_download (self, cancellable, error);
      if (path == NULL)
        goto out;

      priv->graph = gegl_node_new ();
      priv->node = gegl_node_new_child (priv->graph,
                                        "operation", "gegl:load",
                                        "path", path,
                                        NULL);
    }

  gegl_node_process (priv->node);
  priv->bbox = gegl_node_get_bounding_box (priv->node);
  ret_val = g_object_ref (priv->node);

 out:
  g_free (path);
  return ret_val;
}
Esempio n. 7
0
gint
main (gint    argc,
      gchar **argv)
{
  GeglBuffer *buffer, *buffer2;
  GeglNode   *gegl, *sink;
  gint i;

  g_thread_init (NULL);
  gegl_init (&argc, &argv);

  g_object_set (gegl_config (), "chunk-size", 128 * 128, NULL);

  buffer = test_buffer (1024, 1024, babl_format ("RGBA float"));

#define ITERATIONS 6
  test_start ();
  for (i=0;i< ITERATIONS;i++)
    {
      gegl = gegl_graph (sink = gegl_node ("gegl:buffer-sink", "buffer", &buffer2, NULL,
                                gegl_node ("gegl:brightness-contrast", "contrast", 0.2, NULL,
                                gegl_node ("gegl:buffer-source", "buffer", buffer, NULL))));

      gegl_node_process (sink);
      g_object_unref (gegl);
      g_object_unref (buffer2);
    }
  test_end ("bcontrast-minichunk", gegl_buffer_get_pixel_count (buffer) * 16 * ITERATIONS);


  return 0;
}
Esempio n. 8
0
gint
main (gint    argc,
      gchar **argv)
{
  GeglBuffer *buffer, *buffer2;
  GeglNode   *gegl, *sink;
  gint i;

  gegl_init (&argc, &argv);

  buffer = test_buffer (1024, 1024, babl_format ("RGBA float"));

#define ITERATIONS 8
  test_start ();
  for (i=0;i< ITERATIONS;i++)
  gegl = gegl_graph (sink = gegl_node ("gegl:buffer-sink", "buffer", &buffer2, NULL,
                            gegl_node ("gegl:brightness-contrast", "contrast", 0.2, NULL,
                            gegl_node ("gegl:brightness-contrast", "contrast", 0.2, NULL,
                            gegl_node ("gegl:brightness-contrast", "contrast", 0.2, NULL,
                            gegl_node ("gegl:brightness-contrast", "contrast", 1.2, NULL,
                            gegl_node ("gegl:buffer-source", "buffer", buffer, NULL)))))));

  gegl_node_process (sink);
  test_end ("passthrough", gegl_buffer_get_pixel_count (buffer2) * 16);
  g_object_unref (gegl);
  g_object_unref (buffer2);

  return 0;
}
Esempio n. 9
0
/* Test that the GeglNode is processed when invalidated. */
static void
test_processing(void)
{
    ViewHelperTest test;
    gboolean got_computed_event = FALSE;
    GeglRectangle invalidated_rect = {0, 0, 128, 128};

    setup_helper_test(&test);
    /* Setup will invalidate the node, make sure those events are processed. */
    while (gtk_events_pending()) {
        gtk_main_iteration();
    }
    gegl_node_process(test.out);

    g_signal_connect(test.out, "computed",
                     G_CALLBACK(computed_event),
                     &got_computed_event);

    gegl_node_invalidated(test.out, &invalidated_rect, FALSE);

    g_timeout_add(300, test_utils_quit_gtk_main, NULL);
    gtk_main();

    /* FIXME: test that the computed events span the invalidated area */
    g_assert(got_computed_event);

    teardown_helper_test(&test);
}
Esempio n. 10
0
void 
process_func(gpointer key, Processor *value, gpointer unused)
{
    g_assert(value);
    if (value->node) {
        gegl_node_process(value->node);
    }
}
Esempio n. 11
0
static gboolean
debug_show_image_graph (GimpImage *source_image)
{
  Gimp            *gimp        = source_image->gimp;
  GimpProjectable *projectable = GIMP_PROJECTABLE (source_image);
  GeglNode        *image_graph = gimp_projectable_get_graph (projectable);
  GeglNode        *output_node = gegl_node_get_output_proxy (image_graph, "output");
  GimpImage       *new_image   = NULL;
  GimpLayer       *layer       = NULL;
  GeglNode        *introspect  = NULL;
  GeglNode        *sink        = NULL;
  GeglBuffer      *buffer      = NULL;
  gchar           *new_name    = NULL;

  /* Setup and process the introspection graph */
  introspect = gegl_node_new_child (NULL,
                                    "operation", "gegl:introspect",
                                    "node",      output_node,
                                    NULL);
  sink = gegl_node_new_child (NULL,
                              "operation", "gegl:buffer-sink",
                              "buffer",    &buffer,
                              NULL);
  gegl_node_link_many (introspect, sink, NULL);
  gegl_node_process (sink);

  /* Create a new image of the result */
  new_name = g_strdup_printf ("%s GEGL graph",
                              gimp_image_get_display_name (source_image));
  new_image = gimp_create_image (gimp,
                                 gegl_buffer_get_width (buffer),
                                 gegl_buffer_get_height (buffer),
                                 GIMP_RGB,
                                 GIMP_PRECISION_U8,
                                 FALSE);
  gimp_image_set_uri (new_image, new_name);
  layer = gimp_layer_new_from_buffer (buffer,
                                      new_image,
                                      gimp_image_get_layer_format (new_image,
                                                                   TRUE),
                                      new_name,
                                      1.0,
                                      GIMP_NORMAL_MODE);
  gimp_image_add_layer (new_image, layer, NULL, 0, FALSE);
  gimp_create_display (gimp, new_image, GIMP_UNIT_PIXEL, 1.0);

  /* Cleanup */
  g_object_unref (new_image);
  g_free (new_name);
  g_object_unref (buffer);
  g_object_unref (sink);
  g_object_unref (introspect);
  g_object_unref (source_image);

  return FALSE;
}
Esempio n. 12
0
static gboolean
test_comparison (const gfloat        *reference,
                 const gfloat        *test_case,
                 const CompareResult *expected_result)
{
  GeglBuffer    *src_ref_buffer;
  GeglBuffer    *src_aux_buffer;
  GeglRectangle  extent;
  const Babl    *input_format = babl_format ("R'G'B'A float");
  GeglNode      *graph, *source_ref, *source_aux, *comparison;
  gint           test_result;

  /* Set up all buffers */
  extent = *GEGL_RECTANGLE (0, 0, NUM_COLS, NUM_ROWS);

  src_ref_buffer = gegl_buffer_new (&extent, input_format);
  src_aux_buffer = gegl_buffer_new (&extent, input_format);

  gegl_buffer_set (src_ref_buffer, &extent, 0, input_format,
                   reference, GEGL_AUTO_ROWSTRIDE);
  gegl_buffer_set (src_aux_buffer, &extent, 0, input_format,
                   test_case, GEGL_AUTO_ROWSTRIDE);

  /* Build the test graph */
  graph = gegl_node_new ();
  source_ref = gegl_node_new_child (graph,
                                    "operation", "gegl:buffer-source",
                                    "buffer", src_ref_buffer,
                                    NULL);
  source_aux = gegl_node_new_child (graph,
                                    "operation", "gegl:buffer-source",
                                    "buffer", src_aux_buffer,
                                    NULL);
  comparison = gegl_node_new_child (graph,
                                    "operation", "gegl:image-compare",
                                    NULL);

  gegl_node_link_many (source_ref, comparison, NULL);
  gegl_node_connect_to (source_aux, "output",  comparison, "aux");

  gegl_node_process (comparison);

  /* Compare with reference */
  test_result = compare_values (comparison, expected_result);

  /* We are done, clean and quit */
  g_object_unref (graph);
  g_object_unref (src_aux_buffer);
  g_object_unref (src_ref_buffer);

  return test_result;
}
Esempio n. 13
0
gint
main (gint argc,
      gchar **argv)
{
  GeglNode *gegl, *sink;

  if (argc != 4)
    {
      g_print ("Usage: %s <input image> \"string\" <output image>\n\n", argv[0]);
      return -1;
    }

  g_thread_init (NULL);
  gegl_init (&argc, &argv);

  gegl =
    gegl_graph (
    sink = gegl_node ("gegl:png-save", "path", argv[3], NULL,
    gegl_node   ("gegl:over", NULL,
      gegl_node ("gegl:scale",
                 "x", 0.4,
                 "y", 0.4,
                 NULL,
      gegl_node ("gegl:invert",
                 NULL,
      gegl_node ("gegl:load",
                 "path", argv[1],
                 NULL
    ))),
      gegl_node ("gegl:translate",
                 "x", 50.0,
                 "y", 50.0,
                 NULL,
      gegl_node ("gegl:dropshadow",
                 "opacity", 1.0,
                 "radius", 3.0,
                 "x", 3.0,
                 "y", 3.0,
                 NULL,
      gegl_node ("gegl:text",
                 "size", 40.0,
                 "font", "sans bold",
                 "string", argv[2],
                 "color", gegl_color_new("green"),
                 NULL
    ))))));

  gegl_node_process (sink);
  g_object_unref (gegl);
  gegl_exit ();
  return 0;
}
Esempio n. 14
0
static void image_update(GtkObject *obj, GtkImage *view)
{
	if(gegl_can_process(geglGraph->node_pixbuf))
	{
		//g_free(geglGraph->pixbuf);
		geglGraph->pixbuf=NULL;
		gegl_node_process(geglGraph->node_pixbuf);

	}

	gtk_image_clear(view);
	gtk_image_set_from_pixbuf(view,geglGraph->pixbuf);
}
Esempio n. 15
0
static void
gegl_introspect_load_cache (GeglProperties *op_introspect)
{
  GeglBuffer *new_buffer   = NULL;
  GeglNode   *png_load     = NULL;
  GeglNode   *buffer_sink  = NULL;
  gchar      *dot_string   = NULL;
  gchar      *png_filename = NULL;
  gchar      *dot_filename = NULL;
  gchar      *dot_cmd      = NULL;

  if (op_introspect->user_data || op_introspect->node == NULL)
    return;

  /* Construct temp filenames */
  dot_filename = g_build_filename (g_get_tmp_dir (), "gegl-introspect.dot", NULL);
  png_filename = g_build_filename (g_get_tmp_dir (), "gegl-introspect.png", NULL);

  /* Construct the .dot source */
  dot_string = gegl_to_dot (GEGL_NODE (op_introspect->node));
  g_file_set_contents (dot_filename, dot_string, -1, NULL);

  /* Process the .dot to a .png */
  dot_cmd = g_strdup_printf ("dot -o %s -Tpng %s", png_filename, dot_filename);
  if (system (dot_cmd) == -1)
    g_warning ("Error executing GraphViz dot program");

  /* Create a graph that loads the png into a GeglBuffer and process
   * it
   */
  png_load = gegl_node_new_child (NULL,
                                  "operation", "gegl:png-load",
                                  "path",      png_filename,
                                  NULL);
  buffer_sink = gegl_node_new_child (NULL,
                                     "operation", "gegl:buffer-sink",
                                     "buffer",    &new_buffer,
                                     NULL);
  gegl_node_link_many (png_load, buffer_sink, NULL);
  gegl_node_process (buffer_sink);

  op_introspect->user_data= new_buffer;

  /* Cleanup */
  g_object_unref (buffer_sink);
  g_object_unref (png_load);
  g_free (dot_string);
  g_free (dot_cmd);
  g_free (dot_filename);
  g_free (png_filename);
}
Esempio n. 16
0
void
gegl_apply_op_valist (GeglBuffer  *buffer,
                      const gchar *first_property_name,
                      va_list      var_args)
{
    GeglBuffer  *tempbuf = NULL;
    GeglNode    *node;
    GeglNode    *source;
    GeglNode    *sink;

    g_return_if_fail (GEGL_IS_BUFFER (buffer));

    g_object_ref (buffer);

    source  = gegl_node_new_child (NULL, "operation", "gegl:buffer-source",
                                   "buffer", buffer,
                                   NULL);
    node   = gegl_node_new_child (NULL, "operation", first_property_name, NULL);

    if (!GEGL_IS_OPERATION_POINT_FILTER (node->operation))
    {
        tempbuf = gegl_buffer_new (gegl_buffer_get_extent (buffer), gegl_buffer_get_format (buffer));

        sink = gegl_node_new_child (NULL, "operation", "gegl:write-buffer",
                                    "buffer", tempbuf,
                                    NULL);
    }
    else
    {
        sink = gegl_node_new_child (NULL, "operation", "gegl:write-buffer",
                                    "buffer", buffer,
                                    NULL);
    }

    gegl_node_link_many (source, node, sink, NULL);

    gegl_node_set_props (node, var_args);

    gegl_node_process (sink);

    g_object_unref (source);
    g_object_unref (node);
    g_object_unref (sink);

    if (tempbuf)
    {
        gegl_buffer_copy (tempbuf, NULL, buffer, NULL);
        g_object_unref (tempbuf);
    }
    g_object_unref (buffer);
}
Esempio n. 17
0
static void
standard_output (const gchar *op_name)
{
  GeglNode *composition, *input, *aux, *operation, *crop, *output;
  gchar    *input_path  = g_build_path (G_DIR_SEPARATOR_S, data_dir,
                                        "standard-input.png", NULL);
  gchar    *aux_path    = g_build_path (G_DIR_SEPARATOR_S, data_dir,
                                        "standard-aux.png", NULL);
  gchar    *output_path = operation_to_path (op_name, FALSE);

  composition = gegl_node_new ();
  operation = gegl_node_create_child (composition, op_name);

  if (gegl_node_has_pad (operation, "output"))
    {
      input = gegl_node_new_child (composition,
                                   "operation", "gegl:load",
                                   "path", input_path,
                                   NULL);
      aux = gegl_node_new_child (composition,
                                 "operation", "gegl:load",
                                 "path", aux_path,
                                 NULL);
      crop = gegl_node_new_child (composition,
                                  "operation", "gegl:crop",
                                  "width", 200.0,
                                  "height", 200.0,
                                  NULL);
      output = gegl_node_new_child (composition,
                                    "operation", "gegl:png-save",
                                    "compression", 9,
                                    "path", output_path,
                                    NULL);

      gegl_node_link_many (operation, crop, output, NULL);

      if (gegl_node_has_pad (operation, "input"))
        gegl_node_link (input, operation);

      if (gegl_node_has_pad (operation, "aux"))
        gegl_node_connect_to (aux, "output", operation, "aux");

      gegl_node_process (output);
    }

  g_free (input_path);
  g_free (aux_path);
  g_free (output_path);
  g_object_unref (composition);
}
Esempio n. 18
0
void saturation(GeglBuffer *buffer)
{
  GeglBuffer *buffer2;
  GeglNode   *gegl, *source, *saturation, *sink;

  gegl = gegl_node_new ();
  source = gegl_node_new_child (gegl, "operation", "gegl:buffer-source", "buffer", buffer, NULL);
  saturation = gegl_node_new_child (gegl, "operation", "gegl:saturation", "scale", 1.25, NULL);
  sink = gegl_node_new_child (gegl, "operation", "gegl:buffer-sink", "buffer", &buffer2, NULL);

  gegl_node_link_many (source, saturation, sink, NULL);
  gegl_node_process (sink);
  g_object_unref (gegl);
  g_object_unref (buffer2);
}
static void
gimp_n_point_deformation_tool_perform_deformation (GimpNPointDeformationTool *npd_tool)
{
  GObject *operation;

  g_object_get (npd_tool->npd_node,
                "gegl-operation", &operation,
                NULL);
  gimp_npd_debug (("gegl_operation_invalidate\n"));
  gegl_operation_invalidate (GEGL_OPERATION (operation), NULL, FALSE);
  g_object_unref (operation);

  gimp_npd_debug (("gegl_node_process\n"));
  gegl_node_process (npd_tool->sink);
}
Esempio n. 20
0
void blur(GeglBuffer *buffer)
{
  GeglBuffer *buffer2;
  GeglNode   *gegl, *source, *node, *sink;

  gegl = gegl_node_new ();
  source = gegl_node_new_child (gegl, "operation", "gegl:buffer-source", "buffer", buffer, NULL);
  node = gegl_node_new_child (gegl, "operation", "gegl:brightness-contrast", "contrast", 0.2, NULL);
  sink = gegl_node_new_child (gegl, "operation", "gegl:buffer-sink", "buffer", &buffer2, NULL);

  gegl_node_link_many (source, node, sink, NULL);
  gegl_node_process (sink);
  g_object_unref (gegl);
  g_object_unref (buffer2);
}
Esempio n. 21
0
static void decode_frame_no (int frame)
{
  if (video_frame)
  {
    if (strstr (format, "histogram"))
    {
       if (previous_video_frame)
         g_object_unref (previous_video_frame);
       previous_video_frame = gegl_buffer_dup (video_frame);
    }
    g_object_unref (video_frame);
  }
  video_frame = NULL;
  gegl_node_set (load, "frame", frame, NULL);
  gegl_node_process (store);
}
Esempio n. 22
0
GdkPixbuf *
photos_utils_create_pixbuf_from_node (GeglNode *node)
{
  GdkPixbuf *pixbuf = NULL;
  GeglNode *save_pixbuf;

  save_pixbuf = gegl_node_new_child (gegl_node_get_parent (node),
                                     "operation", "gegl:save-pixbuf",
                                     "pixbuf", &pixbuf,
                                     NULL);
  gegl_node_link_many (node, save_pixbuf, NULL);
  gegl_node_process (save_pixbuf);
  g_object_unref (save_pixbuf);

  return pixbuf;
}
Esempio n. 23
0
void
save_png(MyPaintSurface *surface, const char *path,
         int x, int y, int width, int height)
{
    MyPaintGeglTiledSurface *self = (MyPaintGeglTiledSurface *)surface;
    GeglNode *graph, *save, *source;

    graph = gegl_node_new();
    source = gegl_node_new_child(graph, "operation", "gegl:buffer-source",
                                 "buffer", mypaint_gegl_tiled_surface_get_buffer(self), NULL);
    save = gegl_node_new_child(graph, "operation", "gegl:png-save", "path", path, NULL);
    gegl_node_link(source, save);

    gegl_node_process(save);
    g_object_unref(graph);
}
Esempio n. 24
0
void blur(GeglBuffer *buffer)
{
  GeglBuffer *buffer2;
  GeglNode   *gegl, *source, *node, *sink;

  gegl = gegl_node_new ();
  source = gegl_node_new_child (gegl, "operation", "gegl:buffer-source", "buffer", buffer, NULL);
  node = gegl_node_new_child (gegl, "operation", "gegl:gaussian-blur",
                                       "std-dev-x", 10.0,
                                       "std-dev-y", 10.0,
                                       NULL);
  sink = gegl_node_new_child (gegl, "operation", "gegl:buffer-sink", "buffer", &buffer2, NULL);

  gegl_node_link_many (source, node, sink, NULL);
  gegl_node_process (sink);
  g_object_unref (gegl);
  g_object_unref (buffer2);
}
Esempio n. 25
0
static GeglBuffer *
grey_blur_buffer (GeglBuffer          *input,
                  gdouble              glow_radius,
                  const GeglRectangle *result)
{
  GeglNode *gegl, *image, *write, *blur, *crop;
  GeglBuffer *dest;
  gdouble radius, std_dev;

  gegl = gegl_node_new ();
  image = gegl_node_new_child (gegl,
                               "operation", "gegl:buffer-source",
                               "buffer",    input,
                               NULL);

  radius   = fabs (glow_radius) + 1.0;
  std_dev = sqrt (-(radius * radius) / (2 * log (1.0 / 255.0)));

  blur =  gegl_node_new_child (gegl,
                               "operation",    "gegl:gaussian-blur",
                               "std_dev_x",    std_dev,
                               "std_dev_y",    std_dev,
                               "abyss-policy", 0,
                               NULL);

  crop =  gegl_node_new_child (gegl,
                               "operation", "gegl:crop",
                               "x",         (gdouble) result->x,
                               "y",         (gdouble) result->y,
                               "width",     (gdouble) result->width,
                               "height",    (gdouble) result->height,
                               NULL);

  write = gegl_node_new_child (gegl,
                               "operation", "gegl:buffer-sink",
                               "buffer", &dest, NULL);

  gegl_node_link_many (image, blur, crop, write, NULL);
  gegl_node_process (write);

  g_object_unref (gegl);

  return dest;
}
Esempio n. 26
0
GeglBuffer *gegl_filter_op_valist (GeglBuffer    *buffer,
                                   const gchar   *first_property_name,
                                   va_list        var_args)
{
    GeglBuffer  *tempbuf = NULL;
    GeglNode    *node;
    GeglNode    *source;
    GeglNode    *sink;

    //g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);

    if (buffer)
    {
        g_object_ref (buffer);
        source  = gegl_node_new_child (NULL, "operation", "gegl:buffer-source",
                                       "buffer", buffer,
                                       NULL);
    }
    node   = gegl_node_new_child (NULL, "operation", first_property_name, NULL);

    sink = gegl_node_new_child (NULL, "operation", "gegl:buffer-sink",
                                "buffer", &tempbuf,
                                NULL);

    if (buffer)
        gegl_node_link_many (source, node, sink, NULL);
    else
        gegl_node_link_many (node, sink, NULL);

    gegl_node_set_props (node, var_args);

    gegl_node_process (sink);

    if (buffer)
    {
        g_object_unref (source);
        g_object_unref (buffer);
    }
    g_object_unref (node);
    g_object_unref (sink);

    return tempbuf;
}
Esempio n. 27
0
static GraphData *create_graph(void)
{
	GraphData *graphData = g_new(GraphData,1);
	graphData->graph =  gegl_node_new();

	graphData->node_image = gegl_node_new_child(graphData->graph,
    		"operation","gegl:load",
    		"path","001.png",NULL);

    graphData->pixbuf=NULL;
    graphData->node_pixbuf = gegl_node_new_child(graphData->graph,
    		"operation","gegl:save-pixbuf",
    		"pixbuf",&graphData->pixbuf,NULL);

    gegl_node_connect_to(graphData->node_image,"output",graphData->node_pixbuf,"input");

    gegl_node_process (graphData->node_pixbuf);

    return graphData;
}
Esempio n. 28
0
static void
dump_to_png (const char *filename, GeglBuffer *buffer)
{
  GeglNode *ptn, *src, *dst;

  ptn = gegl_node_new();
  src = gegl_node_new_child(ptn, "operation", "gegl:buffer-source",
                            "buffer", buffer,
                            NULL);

  dst = gegl_node_new_child(ptn, "operation", "gegl:png-save",
                            "path", filename,
                            "compression", 6,
                            NULL);

  gegl_node_connect_to (src, "output",  dst, "input");

  gegl_node_process(dst);

  g_object_unref(ptn);
}
Esempio n. 29
0
gint
main (gint    argc,
      gchar **argv)
{
  GeglBuffer *buffer, *buffer2;
  GeglNode   *gegl, *sink;

  gegl_init (&argc, &argv);

  buffer = test_buffer (1024, 1024, babl_format ("RGBA float"));

  gegl = gegl_graph (sink = gegl_node ("gegl:buffer-sink", "buffer", &buffer2, NULL,
                            gegl_node ("gegl:rotate", "degrees", 4.0, NULL,
                            gegl_node ("gegl:buffer-source", "buffer", buffer, NULL))));

  test_start ();
  gegl_node_process (sink);
  test_end ("rotate",  gegl_buffer_get_pixel_count (buffer) * 16);

  g_object_unref (gegl);

  return 0;
}
Esempio n. 30
0
void
gegl_render_op_valist (GeglBuffer  *source_buffer,
                       GeglBuffer  *target_buffer,
                       const gchar *first_property_name,
                       va_list      var_args)
{
    GeglNode    *node;
    GeglNode    *source;
    GeglNode    *sink;

    g_return_if_fail (GEGL_IS_BUFFER (source_buffer));
    g_return_if_fail (GEGL_IS_BUFFER (target_buffer));

    g_object_ref (source_buffer);
    g_object_ref (target_buffer);

    source  = gegl_node_new_child (NULL, "operation", "gegl:buffer-source",
                                   "buffer", source_buffer,
                                   NULL);
    node   = gegl_node_new_child (NULL, "operation", first_property_name, NULL);

    sink   = gegl_node_new_child (NULL, "operation", "gegl:write-buffer",
                                  "buffer", target_buffer,
                                  NULL);

    gegl_node_link_many (source, node, sink, NULL);
    gegl_node_set_props (node, var_args);
    gegl_node_process (sink);

    g_object_unref (source);
    g_object_unref (node);
    g_object_unref (sink);

    g_object_unref (source_buffer);
    g_object_unref (target_buffer);
}