app: add gimp_gegl_node_set_matrix() and use it instead of manual fiddling

This commit is contained in:
Michael Natterer 2012-03-31 16:18:13 +02:00
parent 2af0681587
commit 2957795372
4 changed files with 25 additions and 10 deletions

View file

@ -29,6 +29,7 @@
#include "core-types.h"
#include "gegl/gimp-gegl-nodes.h"
#include "gegl/gimp-gegl-utils.h"
#include "gimp.h"
@ -83,7 +84,6 @@ gimp_drawable_transform_buffer_affine (GimpDrawable *drawable,
gint u1, v1, u2, v2; /* source bounding box */
gint x1, y1, x2, y2; /* target bounding box */
GeglNode *affine;
gchar *matrix_string;
GimpMatrix3 gegl_matrix;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
@ -135,14 +135,13 @@ gimp_drawable_transform_buffer_affine (GimpDrawable *drawable,
gimp_matrix3_mult (&inv, &gegl_matrix);
gimp_matrix3_translate (&gegl_matrix, -x1, -y1);
matrix_string = gegl_matrix3_to_string ((GeglMatrix3 *) &gegl_matrix);
affine = gegl_node_new_child (NULL,
"operation", "gegl:transform",
"transform", matrix_string,
"filter", gimp_interpolation_to_gegl_filter (interpolation_type),
"hard-edges", TRUE,
NULL);
g_free (matrix_string);
gimp_gegl_node_set_matrix (affine, &gegl_matrix);
gimp_apply_operation (orig_buffer, progress, NULL,
affine,

View file

@ -319,3 +319,21 @@ gimp_gegl_node_set_layer_mode (GeglNode *node,
"premultiplied", premultiplied,
NULL);
}
void
gimp_gegl_node_set_matrix (GeglNode *node,
const GimpMatrix3 *matrix)
{
gchar *matrix_string;
g_return_if_fail (GEGL_IS_NODE (node));
g_return_if_fail (matrix != NULL);
matrix_string = gegl_matrix3_to_string ((GeglMatrix3 *) matrix);
gegl_node_set (node,
"transform", matrix_string,
NULL);
g_free (matrix_string);
}

View file

@ -48,6 +48,8 @@ GeglNode * gimp_gegl_add_buffer_source (GeglNode *parent,
void gimp_gegl_node_set_layer_mode (GeglNode *node,
GimpLayerModeEffects mode,
gboolean premultiplied);
void gimp_gegl_node_set_matrix (GeglNode *node,
const GimpMatrix3 *matrix);
#endif /* __GIMP_GEGL_NODES_H__ */

View file

@ -29,6 +29,7 @@
#include "base/temp-buf.h"
#include "gegl/gimp-gegl-nodes.h"
#include "gegl/gimp-gegl-utils.h"
#include "core/gimp.h"
@ -351,7 +352,6 @@ gimp_perspective_clone_get_source (GimpSourceCore *source_core,
gdouble x1s, y1s, x2s, y2s, x3s, y3s, x4s, y4s;
gint xmin, ymin, xmax, ymax;
GimpMatrix3 matrix;
gchar *matrix_string;
GimpMatrix3 gegl_matrix;
src_buffer = gimp_pickable_get_buffer (src_pickable);
@ -398,11 +398,7 @@ gimp_perspective_clone_get_source (GimpSourceCore *source_core,
gimp_matrix3_mult (&matrix, &gegl_matrix);
gimp_matrix3_translate (&gegl_matrix, -x1d, -y1d);
matrix_string = gegl_matrix3_to_string ((GeglMatrix3 *) &gegl_matrix);
gegl_node_set (clone->transform_node,
"transform", matrix_string,
NULL);
g_free (matrix_string);
gimp_gegl_node_set_matrix (clone->transform_node, &gegl_matrix);
gegl_node_set (clone->dest_node,
"buffer", dest_buffer,