gimp/app/gegl/gimp-gegl-nodes.c

106 lines
3.1 KiB
C
Raw Normal View History

/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimp-gegl-nodes.h
* Copyright (C) 2012 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include "gimp-gegl-types.h"
#include "gimp-gegl-nodes.h"
#include "gimp-gegl-utils.h"
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 = gegl_color_new (NULL);
gimp_gegl_color_set_rgba (c, 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;
}
GeglNode *
gimp_gegl_create_apply_opacity_node (GeglBuffer *mask,
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 = gegl_node_new_child (node,
"operation", "gegl:buffer-source",
"buffer", mask,
NULL);
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;
}