Commit fbedc720 authored by Michael Muré's avatar Michael Muré Committed by Michael Muré

transform: add scaleratio and scalesize operation to be more user-friendly the...

transform: add scaleratio and scalesize operation to be more user-friendly the scaleratio operation is the same as the original scale the scale operation is to be removed with the next major version of GEGL
parent 7c25b450
......@@ -14,6 +14,8 @@ transformops_la_SOURCES = \
reflect.c \
rotate.c \
scale.c \
scale-ratio.c \
scale-size.c \
shear.c \
transform.c \
translate.c \
......
......@@ -39,11 +39,13 @@ gegl_module_query (GTypeModule *module)
return &modinfo;
}
GType rotate_get_type (void);
GType scale_get_type (void);
GType shear_get_type (void);
GType translate_get_type (void);
GType reflect_get_type (void);
GType rotate_get_type (void);
GType scale_get_type (void);
GType scaleratio_get_type (void);
GType scalesize_get_type (void);
GType shear_get_type (void);
GType translate_get_type (void);
GType reflect_get_type (void);
GType transform_get_type (void);
G_MODULE_EXPORT gboolean
......@@ -55,6 +57,8 @@ gegl_module_register (GTypeModule *module)
dummy = op_affine_get_type ();
dummy = rotate_get_type ();
dummy = scale_get_type ();
dummy = scaleratio_get_type ();
dummy = scalesize_get_type ();
dummy = shear_get_type ();
dummy = translate_get_type ();
dummy = reflect_get_type ();
......
/* This file is part of GEGL
*
* GEGL is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* GEGL 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2006 Philip Lafleur
*/
#include "config.h"
#include <glib/gi18n-lib.h>
#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_double (x, -G_MAXDOUBLE, G_MAXDOUBLE, 1.0,
_("Horizontal scale factor"))
gegl_chant_double (y, -G_MAXDOUBLE, G_MAXDOUBLE, 1.0,
_("Vertical scale factor"))
#else
#define GEGL_CHANT_NAME scaleratio
#define GEGL_CHANT_DESCRIPTION _("Scales the buffer according to a ratio.")
#define GEGL_CHANT_SELF "scale-ratio.c"
#include "chant.h"
#include <math.h>
static void
create_matrix (OpTransform *op,
GeglMatrix3 *matrix)
{
GeglChantOperation *chant = GEGL_CHANT_OPERATION (op);
matrix->coeff [0][0] = chant->x;
matrix->coeff [1][1] = chant->y;
}
#endif
/* This file is part of GEGL
*
* GEGL is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* GEGL 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2012 Michael Muré <batolettre@gmail.com>
*/
#include "config.h"
#include <glib/gi18n-lib.h>
#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_double (x, -G_MAXDOUBLE, G_MAXDOUBLE, 100.0,
_("Horizontal size"))
gegl_chant_double (y, -G_MAXDOUBLE, G_MAXDOUBLE, 100.0,
_("Vertical size"))
#else
#define GEGL_CHANT_NAME scalesize
#define GEGL_CHANT_DESCRIPTION _("Scales the buffer according to a size.")
#define GEGL_CHANT_SELF "scale-size.c"
#include "chant.h"
#include <math.h>
static void
create_matrix (OpTransform *op,
GeglMatrix3 *matrix)
{
GeglChantOperation *chant = GEGL_CHANT_OPERATION (op);
GeglOperation *operation = GEGL_OPERATION (op);
GeglRectangle in_rect = {0,0,0,0};
if (gegl_operation_source_get_bounding_box (operation, "input"))
in_rect = *gegl_operation_source_get_bounding_box (operation, "input");
if(in_rect.width < 1)
in_rect.width = 1;
if(in_rect.height < 1)
in_rect.height = 1;
matrix->coeff [0][0] = chant->x / (gdouble) in_rect.width;
matrix->coeff [1][1] = chant->y / (gdouble) in_rect.height;
}
#endif
......@@ -19,6 +19,9 @@
#include "config.h"
#include <glib/gi18n-lib.h>
/* This operation is deprecated and is to be removed with the next version of GEGL.
* Use the scaleratio operation instead.
*/
#ifdef GEGL_CHANT_PROPERTIES
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment