[gegl] transform: add scaleratio and scalesize operation to be more user-friendly the scaleratio operation
- From: Michael Murà <mmure src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] transform: add scaleratio and scalesize operation to be more user-friendly the scaleratio operation
- Date: Sat, 28 Apr 2012 15:26:15 +0000 (UTC)
commit fbedc720da5432b19456b5f7547dafbd8c193d16
Author: Michael Murà <batolettre gmail com>
Date: Fri Apr 27 17:35:42 2012 +0900
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
operations/transform/Makefile.am | 2 +
operations/transform/module.c | 14 +++++---
operations/transform/scale-ratio.c | 49 +++++++++++++++++++++++++++++
operations/transform/scale-size.c | 59 ++++++++++++++++++++++++++++++++++++
operations/transform/scale.c | 3 ++
5 files changed, 122 insertions(+), 5 deletions(-)
---
diff --git a/operations/transform/Makefile.am b/operations/transform/Makefile.am
index 218f30c..90012d7 100644
--- a/operations/transform/Makefile.am
+++ b/operations/transform/Makefile.am
@@ -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 \
diff --git a/operations/transform/module.c b/operations/transform/module.c
index 4ebf301..1833e95 100644
--- a/operations/transform/module.c
+++ b/operations/transform/module.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 ();
diff --git a/operations/transform/scale-ratio.c b/operations/transform/scale-ratio.c
new file mode 100644
index 0000000..28d82d5
--- /dev/null
+++ b/operations/transform/scale-ratio.c
@@ -0,0 +1,49 @@
+/* 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
diff --git a/operations/transform/scale-size.c b/operations/transform/scale-size.c
new file mode 100644
index 0000000..a0395bd
--- /dev/null
+++ b/operations/transform/scale-size.c
@@ -0,0 +1,59 @@
+/* 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
diff --git a/operations/transform/scale.c b/operations/transform/scale.c
index acfe787..4aa064d 100644
--- a/operations/transform/scale.c
+++ b/operations/transform/scale.c
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]