static void gimp_cage_tool_create_render_node (GimpCageTool *ct) { GimpCageOptions *options = GIMP_CAGE_TOOL_GET_OPTIONS (ct); GeglNode *coef, *cage, *render; /* Render nodes */ GeglNode *input, *output; /* Proxy nodes*/ GeglNode *node; /* wraper to be returned */ GObject *transform; g_return_if_fail (ct->render_node == NULL); /* render_node is not supposed to be recreated */ node = gegl_node_new (); input = gegl_node_get_input_proxy (node, "input"); output = gegl_node_get_output_proxy (node, "output"); coef = gegl_node_new_child (node, "operation", "gegl:buffer-source", "buffer", ct->coef, NULL); cage = gegl_node_new_child (node, "operation", "gimp:cage-transform", "config", ct->config, "fill_plain_color", options->fill_plain_color, NULL); render = gegl_node_new_child (node, "operation", "gegl:map-absolute", NULL); gegl_node_connect_to (input, "output", cage, "input"); gegl_node_connect_to (coef, "output", cage, "aux"); gegl_node_connect_to (input, "output", render, "input"); gegl_node_connect_to (cage, "output", render, "aux"); gegl_node_connect_to (render, "output", output, "input"); ct->render_node = node; ct->cage_node = cage; ct->coef_node = coef; g_object_get (cage, "gegl-operation", &transform, NULL); g_signal_connect (transform, "notify::progress", G_CALLBACK (gimp_cage_tool_transform_progress), ct); g_object_unref (transform); }
GeglNode * gimp_filter_stack_get_graph (GimpFilterStack *stack) { GList *list; GeglNode *first = NULL; GeglNode *previous = NULL; GeglNode *input; GeglNode *output; g_return_val_if_fail (GIMP_IS_FILTER_STACK (stack), NULL); if (stack->graph) return stack->graph; stack->graph = gegl_node_new (); for (list = GIMP_LIST (stack)->queue->tail; list; list = g_list_previous (list)) { GimpFilter *filter = list->data; GeglNode *node = gimp_filter_get_node (filter); if (! first) first = node; gegl_node_add_child (stack->graph, node); if (previous) gegl_node_connect_to (previous, "output", node, "input"); previous = node; } input = gegl_node_get_input_proxy (stack->graph, "input"); output = gegl_node_get_output_proxy (stack->graph, "output"); if (first && previous) { gegl_node_connect_to (input, "output", first, "input"); gegl_node_connect_to (previous, "output", output, "input"); } else { gegl_node_connect_to (input, "output", output, "input"); } return stack->graph; }
void gimp_applicator_set_mask_buffer (GimpApplicator *applicator, GeglBuffer *mask_buffer) { g_return_if_fail (GIMP_IS_APPLICATOR (applicator)); g_return_if_fail (mask_buffer == NULL || GEGL_IS_BUFFER (mask_buffer)); if (applicator->mask_buffer == mask_buffer) return; gegl_node_set (applicator->mask_node, "buffer", mask_buffer, NULL); if (mask_buffer) { gegl_node_connect_to (applicator->mask_offset_node, "output", applicator->mode_node, "aux2"); } else { gegl_node_disconnect (applicator->mode_node, "aux2"); } applicator->mask_buffer = mask_buffer; }
static void attach (GeglOperation *operation) { GeglNode *gegl, *input, *output, *invert, *blur, *opacity, *over, *contrast; gegl = operation->node; input = gegl_node_get_input_proxy (gegl, "input"); output = gegl_node_get_output_proxy (gegl, "output"); invert = gegl_node_new_child (gegl, "operation", "gegl:invert-linear", NULL); blur = gegl_node_new_child (gegl, "operation", "gegl:gaussian-blur", NULL); opacity = gegl_node_new_child (gegl, "operation", "gegl:opacity", "value", 0.5, NULL); over = gegl_node_new_child (gegl, "operation", "gegl:over", NULL); contrast = gegl_node_new_child (gegl, "operation", "gegl:brightness-contrast", NULL); gegl_node_link_many (input, invert, blur, opacity, NULL); gegl_node_connect_to (opacity, "output", over, "aux"); gegl_node_link_many (input, over, contrast, output, NULL); gegl_operation_meta_redirect (operation, "std-dev", blur, "std-dev-x"); gegl_operation_meta_redirect (operation, "std-dev", blur, "std-dev-y"); gegl_operation_meta_redirect (operation, "contrast", contrast, "contrast"); gegl_operation_meta_watch_nodes (operation, invert, blur, opacity, over, contrast, NULL); }
gint layer_connected_pads (gpointer host, GeglEditor* editor, gint from, const gchar* output, gint to, const gchar* input) { GeglEditorLayer* self = (GeglEditorLayer*)host; GeglNode* from_node = NULL; GeglNode* to_node = NULL; GSList* pair = self->pairs; for(;pair != NULL; pair = pair->next) { node_id_pair* data = pair->data; if(data->id == from) from_node = data->node; if(data->id == to) to_node = data->node; if(from_node != NULL && to_node != NULL) break; } g_assert(from_node != NULL && to_node != NULL); g_assert(from_node != to_node); gboolean success = gegl_node_connect_to(from_node, output, to_node, input); g_print("connected (%d): %s(%s) to %s(%s), %i\n", success, gegl_node_get_operation(from_node), output, gegl_node_get_operation(to_node), input, success); refresh_images(self); }
gboolean gimp_warp_tool_undo (GimpTool *tool, GimpDisplay *display) { GimpWarpTool *wt = GIMP_WARP_TOOL (tool); GeglNode *to_delete; GeglNode *previous; const gchar *type; if (! wt->render_node) return FALSE; to_delete = gegl_node_get_producer (wt->render_node, "aux", NULL); type = gegl_node_get_operation (to_delete); if (strcmp (type, "gegl:warp")) return FALSE; previous = gegl_node_get_producer (to_delete, "input", NULL); gegl_node_disconnect (to_delete, "input"); gegl_node_connect_to (previous, "output", wt->render_node, "aux"); wt->redo_stack = g_list_prepend (wt->redo_stack, g_object_ref (to_delete)); gegl_node_remove_child (wt->graph, to_delete); gimp_warp_tool_update_stroke (wt, to_delete); return TRUE; }
static void gimp_cage_tool_compute_coef (GimpCageTool *ct) { GimpCageConfig *config = ct->config; GimpProgress *progress; const Babl *format; GeglNode *gegl; GeglNode *input; GeglNode *output; GeglProcessor *processor; GeglBuffer *buffer; gdouble value; progress = gimp_progress_start (GIMP_PROGRESS (ct), _("Computing Cage Coefficients"), FALSE); if (ct->coef) { g_object_unref (ct->coef); ct->coef = NULL; } format = babl_format_n (babl_type ("float"), gimp_cage_config_get_n_points (config) * 2); gegl = gegl_node_new (); input = gegl_node_new_child (gegl, "operation", "gimp:cage-coef-calc", "config", ct->config, NULL); output = gegl_node_new_child (gegl, "operation", "gegl:buffer-sink", "buffer", &buffer, "format", format, NULL); gegl_node_connect_to (input, "output", output, "input"); processor = gegl_node_new_processor (output, NULL); while (gegl_processor_work (processor, &value)) { if (progress) gimp_progress_set_value (progress, value); } if (progress) gimp_progress_end (progress); g_object_unref (processor); ct->coef = buffer; g_object_unref (gegl); ct->dirty_coef = FALSE; }
GeglNode * gimp_projection_get_sink_node (GimpProjection *proj) { GeglNode *graph; GeglBuffer *buffer; g_return_val_if_fail (GIMP_IS_PROJECTION (proj), NULL); if (proj->sink_node) return proj->sink_node; proj->graph = gegl_node_new (); g_object_set (proj->graph, "dont-cache", TRUE, NULL); graph = gimp_projectable_get_graph (proj->projectable); gegl_node_add_child (proj->graph, graph); buffer = gimp_projection_get_buffer (GIMP_PICKABLE (proj)); proj->sink_node = gegl_node_new_child (proj->graph, "operation", "gegl:write-buffer", "buffer", buffer, NULL); gegl_node_connect_to (graph, "output", proj->sink_node, "input"); return proj->sink_node; }
static gboolean paint_press (GtkWidget *widget, GdkEventButton *event) { if (event->button == 1) { vector = gegl_path_new (); over = gegl_node_new_child (gegl, "operation", "gegl:over", NULL); stroke = gegl_node_new_child (gegl, "operation", "gegl:path", "d", vector, "fill-opacity", 0.0, "stroke", gegl_color_new (COLOR), "stroke-width", LINEWIDTH, "stroke-hardness", HARDNESS, NULL); gegl_node_link_many (top, over, out, NULL); gegl_node_connect_to (stroke, "output", over, "aux"); gegl_path_append (vector, 'M', event->x, event->y); pen_down = TRUE; return TRUE; } return FALSE; }
static AuxInput * gimp_operation_tool_aux_input_new (GimpOperationTool *tool, GeglNode *operation, const gchar *input_pad, const gchar *label) { AuxInput *input = g_slice_new (AuxInput); GimpContext *context; input->node = gegl_node_new_child (NULL, "operation", "gegl:buffer-source", NULL); gegl_node_connect_to (input->node, "output", operation, input_pad); context = GIMP_CONTEXT (GIMP_TOOL_GET_OPTIONS (tool)); input->box = gimp_buffer_source_box_new (context, input->node, label); g_signal_connect (input->box, "notify::pickable", G_CALLBACK (gimp_operation_tool_aux_input_notify), tool); g_signal_connect (input->box, "notify::enabled", G_CALLBACK (gimp_operation_tool_aux_input_notify), tool); return input; }
GeglNode * gimp_gegl_add_buffer_source (GeglNode *parent, GeglBuffer *buffer, gint offset_x, gint offset_y) { GeglNode *buffer_source; g_return_val_if_fail (GEGL_IS_NODE (parent), NULL); g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL); buffer_source = gegl_node_new_child (parent, "operation", "gegl:buffer-source", "buffer", buffer, NULL); if (offset_x != 0 || offset_y != 0) { GeglNode *translate = gegl_node_new_child (parent, "operation", "gegl:translate", "x", (gdouble) offset_x, "y", (gdouble) offset_y, NULL); gegl_node_connect_to (buffer_source, "output", translate, "input"); buffer_source = translate; } return buffer_source; }
static void gimp_filter_stack_add_node (GimpFilterStack *stack, GimpFilter *filter) { GimpFilter *filter_below; GeglNode *node_above; GeglNode *node_below; GeglNode *node; gint index; node = gimp_filter_get_node (filter); index = gimp_container_get_child_index (GIMP_CONTAINER (stack), GIMP_OBJECT (filter)); if (index == 0) { node_above = gegl_node_get_output_proxy (stack->graph, "output"); } else { GimpFilter *filter_above = (GimpFilter *) gimp_container_get_child_by_index (GIMP_CONTAINER (stack), index - 1); node_above = gimp_filter_get_node (filter_above); } gegl_node_connect_to (node, "output", node_above, "input"); filter_below = (GimpFilter *) gimp_container_get_child_by_index (GIMP_CONTAINER (stack), index + 1); if (filter_below) { node_below = gimp_filter_get_node (filter_below); } else { node_below = gegl_node_get_input_proxy (stack->graph, "input"); } gegl_node_connect_to (node_below, "output", node, "input"); }
void gimp_applicator_set_src_buffer (GimpApplicator *applicator, GeglBuffer *src_buffer) { g_return_if_fail (GIMP_IS_APPLICATOR (applicator)); g_return_if_fail (src_buffer == NULL || GEGL_IS_BUFFER (src_buffer)); if (src_buffer == applicator->src_buffer) return; if (src_buffer) { if (! applicator->src_node) { applicator->src_node = gegl_node_new_child (applicator->node, "operation", "gegl:buffer-source", "buffer", src_buffer, NULL); } else { gegl_node_set (applicator->src_node, "buffer", src_buffer, NULL); } if (! applicator->src_buffer) { gegl_node_connect_to (applicator->src_node, "output", applicator->mode_node, "input"); gegl_node_connect_to (applicator->src_node, "output", applicator->affect_node, "input"); } } else if (applicator->src_buffer) { gegl_node_connect_to (applicator->input_node, "output", applicator->mode_node, "input"); gegl_node_connect_to (applicator->input_node, "output", applicator->affect_node, "input"); } applicator->src_buffer = src_buffer; }
void gimp_applicator_set_dest_buffer (GimpApplicator *applicator, GeglBuffer *dest_buffer) { g_return_if_fail (GIMP_IS_APPLICATOR (applicator)); g_return_if_fail (dest_buffer == NULL || GEGL_IS_BUFFER (dest_buffer)); if (dest_buffer == applicator->dest_buffer) return; if (dest_buffer) { if (! applicator->dest_node) { applicator->dest_node = gegl_node_new_child (applicator->node, "operation", "gegl:write-buffer", "buffer", dest_buffer, NULL); } else { gegl_node_set (applicator->dest_node, "buffer", dest_buffer, NULL); } if (! applicator->dest_buffer) { gegl_node_disconnect (applicator->output_node, "input"); gegl_node_connect_to (applicator->affect_node, "output", applicator->dest_node, "input"); } } else if (applicator->dest_buffer) { gegl_node_disconnect (applicator->dest_node, "input"); gegl_node_connect_to (applicator->affect_node, "output", applicator->output_node, "input"); } applicator->dest_buffer = dest_buffer; }
static void gimp_warp_tool_add_op (GimpWarpTool *wt, GeglNode *new_op) { GeglNode *last_op; g_return_if_fail (GEGL_IS_NODE (wt->render_node)); gegl_node_add_child (wt->graph, new_op); last_op = gegl_node_get_producer (wt->render_node, "aux", NULL); gegl_node_disconnect (wt->render_node, "aux"); gegl_node_connect_to (last_op, "output", new_op, "input"); gegl_node_connect_to (new_op, "output", wt->render_node, "aux"); }
static void attach (GeglOperation *operation) { /** * <input (BG)> <aux (FG)> * |"output" "output"| * | | * | "input" "aux" | * +-----> <seamless-clone> <----+ * | "output"| * | | * | "input" "aux" | * +---> <overlay> <---+ * |"output" * v * <output> */ GeglNode *gegl = operation->node; GeglNode *input, *aux, *seamless, *overlay, *output; input = gegl_node_get_input_proxy (gegl, "input"); aux = gegl_node_get_input_proxy (gegl, "aux"); seamless = gegl_node_new_child (gegl, "operation", "gegl:seamless-clone", NULL); /* Don't use a regular gegl:over, since we want the alpha to be set * by the background buffer - we need this for area which had opacity * which was more than half but not fulll. */ overlay = gegl_node_new_child (gegl, "operation", "svg:src-atop", NULL); output = gegl_node_get_output_proxy (gegl, "output"); gegl_node_connect_to (input, "output", seamless, "input"); gegl_node_connect_to (aux, "output", seamless, "aux"); gegl_node_connect_to (input, "output", overlay, "input"); gegl_node_connect_to (seamless, "output", overlay, "aux"); gegl_node_connect_to (overlay, "output", output, "input"); gegl_operation_meta_redirect (operation, "max-refine-scale", seamless, "max-refine-scale"); gegl_operation_meta_redirect (operation, "xoff", seamless, "xoff"); gegl_operation_meta_redirect (operation, "yoff", seamless, "yoff"); gegl_operation_meta_redirect (operation, "error-msg", seamless, "error-msg"); gegl_operation_meta_watch_nodes (operation, seamless, overlay, NULL); }
static gpointer test (gpointer data) { GeglNode *node; GeglNode *input; GeglNode *last; gint i; node = gegl_node_new (); input = gegl_node_get_input_proxy (node, "input"); last = input; for (i = 0; i < 64; i++) { GeglNode *over; over = gegl_node_new_child (node, "operation", "gegl:over", NULL); gegl_node_connect_to (last, "output", over, "input"); gegl_node_connect_to (last, "output", over, "aux"); last = over; } gegl_node_invalidated (input, NULL, FALSE); g_object_unref (node); g_mutex_lock (&mutex); finished = TRUE; g_cond_signal (&cond); g_mutex_unlock (&mutex); return NULL; }
void gimp_applicator_set_apply_buffer (GimpApplicator *applicator, GeglBuffer *apply_buffer) { g_return_if_fail (apply_buffer == NULL || GEGL_IS_BUFFER (apply_buffer)); if (apply_buffer == applicator->apply_buffer) return; if (apply_buffer) { if (! applicator->apply_src_node) { applicator->apply_src_node = gegl_node_new_child (applicator->node, "operation", "gegl:buffer-source", "buffer", apply_buffer, NULL); } else { gegl_node_set (applicator->apply_src_node, "buffer", apply_buffer, NULL); } if (! applicator->apply_buffer) { gegl_node_connect_to (applicator->apply_src_node, "output", applicator->apply_offset_node, "input"); } } else if (applicator->apply_buffer) { gegl_node_connect_to (applicator->aux_node, "output", applicator->apply_offset_node, "input"); } applicator->apply_buffer = apply_buffer; }
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; }
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); }
GeglNode * gimp_gegl_create_apply_opacity_node (GeglBuffer *mask, gint mask_offset_x, gint mask_offset_y, gdouble opacity) { GeglNode *node; GeglNode *input; GeglNode *output; GeglNode *opacity_node; GeglNode *mask_source; g_return_val_if_fail (GEGL_IS_BUFFER (mask), NULL); node = gegl_node_new (); input = gegl_node_get_input_proxy (node, "input"); output = gegl_node_get_output_proxy (node, "output"); opacity_node = gegl_node_new_child (node, "operation", "gegl:opacity", "value", opacity, NULL); mask_source = gimp_gegl_add_buffer_source (node, mask, mask_offset_x, mask_offset_y); gegl_node_connect_to (input, "output", opacity_node, "input"); gegl_node_connect_to (mask_source, "output", opacity_node, "aux"); gegl_node_connect_to (opacity_node, "output", output, "input"); return node; }
GeglNode * gimp_gegl_create_flatten_node (const GimpRGB *background) { GeglNode *node; GeglNode *input; GeglNode *output; GeglNode *color; GeglNode *over; GeglColor *c; g_return_val_if_fail (background != NULL, NULL); node = gegl_node_new (); input = gegl_node_get_input_proxy (node, "input"); output = gegl_node_get_output_proxy (node, "output"); c = gimp_gegl_color_new (background); color = gegl_node_new_child (node, "operation", "gegl:color", "value", c, NULL); g_object_unref (c); over = gegl_node_new_child (node, "operation", "gegl:over", NULL); gegl_node_connect_to (input, "output", over, "aux"); gegl_node_connect_to (color, "output", over, "input"); gegl_node_connect_to (over, "output", output, "input"); return node; }
static void gimp_warp_tool_create_graph (GimpWarpTool *wt) { GeglNode *graph; /* Wraper to be returned */ GeglNode *input, *output; /* Proxy nodes */ GeglNode *coords, *render; /* Render nodes */ /* render_node is not supposed to be recreated */ g_return_if_fail (wt->graph == NULL); graph = gegl_node_new (); input = gegl_node_get_input_proxy (graph, "input"); output = gegl_node_get_output_proxy (graph, "output"); coords = gegl_node_new_child (graph, "operation", "gegl:buffer-source", "buffer", wt->coords_buffer, NULL); render = gegl_node_new_child (graph, "operation", "gegl:map-relative", NULL); gegl_node_connect_to (input, "output", render, "input"); gegl_node_connect_to (coords, "output", render, "aux"); gegl_node_connect_to (render, "output", output, "input"); wt->graph = graph; wt->render_node = render; }
void gimp_applicator_set_crop (GimpApplicator *applicator, const GeglRectangle *rect) { g_return_if_fail (GIMP_IS_APPLICATOR (applicator)); if (applicator->crop_enabled != (rect != NULL) || (rect && ! gegl_rectangle_equal (&applicator->crop_rect, rect))) { if (rect) { if (! applicator->crop_enabled) { gegl_node_set (applicator->crop_node, "operation", "gimp:compose-crop", "x", rect->x, "y", rect->y, "width", rect->width, "height", rect->height, NULL); gegl_node_connect_to (applicator->input_node, "output", applicator->crop_node, "aux"); } else { gegl_node_set (applicator->crop_node, "x", rect->x, "y", rect->y, "width", rect->width, "height", rect->height, NULL); } applicator->crop_enabled = TRUE; applicator->crop_rect = *rect; } else { gegl_node_disconnect (applicator->crop_node, "aux"); gegl_node_set (applicator->crop_node, "operation", "gegl:nop", NULL); applicator->crop_enabled = FALSE; } } }
static void gimp_warp_tool_remove_op (GimpWarpTool *wt, GeglNode *op) { GeglNode *previous; g_return_if_fail (GEGL_IS_NODE (wt->render_node)); previous = gegl_node_get_producer (op, "input", NULL); gegl_node_disconnect (op, "input"); gegl_node_connect_to (previous, "output", wt->render_node, "aux"); gegl_node_remove_child (wt->graph, op); }
static void photos_operation_insta_hefe_attach (GeglOperation *operation) { PhotosOperationInstaHefe *self = PHOTOS_OPERATION_INSTA_HEFE (operation); GeglNode *curve; GeglNode *multiply; self->input = gegl_node_get_output_proxy (operation->node, "input"); self->output = gegl_node_get_output_proxy (operation->node, "output"); curve = gegl_node_new_child (operation->node, "operation", "photos:insta-hefe-curve", NULL); multiply = gegl_node_new_child (operation->node, "operation", "photos:svg-multiply", "srgb", TRUE, NULL); self->vignette = gegl_node_new_child (operation->node, "operation", "photos:insta-hefe-vignette", NULL); gegl_node_connect_to (self->vignette, "output", multiply, "aux"); gegl_node_link_many (self->input, multiply, curve, self->output, NULL); gegl_operation_meta_watch_nodes (operation, curve, multiply, self->vignette, NULL); }
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; }
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); }
void gimp_applicator_set_mask_buffer (GimpApplicator *applicator, GeglBuffer *mask_buffer) { if (applicator->mask_buffer == mask_buffer) return; gegl_node_set (applicator->mask_node, "buffer", mask_buffer, NULL); if (mask_buffer) { gegl_node_connect_to (applicator->mask_offset_node, "output", applicator->mode_node, "aux2"); } else { gegl_node_disconnect (applicator->mode_node, "aux2"); } applicator->mask_buffer = mask_buffer; }
void gimp_applicator_set_preview (GimpApplicator *applicator, gboolean enable, const GeglRectangle *rect) { g_return_if_fail (GIMP_IS_APPLICATOR (applicator)); g_return_if_fail (rect != NULL); if (! applicator->preview_cache_node) return; if (applicator->preview_enabled != enable || applicator->preview_rect.x != rect->x || applicator->preview_rect.y != rect->y || applicator->preview_rect.width != rect->width || applicator->preview_rect.height != rect->height) { if (enable) { if (! applicator->preview_enabled) { gegl_node_set (applicator->preview_crop_node, "operation", "gimp:compose-crop", "x", rect->x, "y", rect->y, "width", rect->width, "height", rect->height, NULL); gegl_node_connect_to (applicator->input_node, "output", applicator->preview_crop_node, "aux"); } else { gegl_node_set (applicator->preview_crop_node, "x", rect->x, "y", rect->y, "width", rect->width, "height", rect->height, NULL); } } else if (applicator->preview_enabled) { GeglBuffer *cache; gegl_node_disconnect (applicator->preview_crop_node, "aux"); gegl_node_set (applicator->preview_crop_node, "operation", "gegl:nop", NULL); /* when disabling the preview, preserve the cached result * by processing it into the output cache, which only * involves the mode and affect nodes. */ gegl_node_get (applicator->preview_cache_node, "cache", &cache, NULL); if (cache) { GeglRectangle *rectangles; gint n_rectangles; if (gegl_buffer_list_valid_rectangles (cache, &rectangles, &n_rectangles)) { gint i; for (i = 0; i < n_rectangles; i++) gegl_node_blit (applicator->output_cache_node, 1.0, &rectangles[i], NULL, NULL, 0, GEGL_BLIT_DEFAULT); g_free (rectangles); } g_object_unref (cache); } } applicator->preview_enabled = enable; applicator->preview_rect = *rect; } }