[gegl/soc-2011-warp: 23/24] map-absolute, map-relative: add a property to choose the sampler
- From: Michael Murà <mmure src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl/soc-2011-warp: 23/24] map-absolute, map-relative: add a property to choose the sampler
- Date: Sun, 3 Jul 2011 22:13:06 +0000 (UTC)
commit 6a71205cba242371bc56ffff8472c5695ec8611c
Author: Michael Murà <batolettre gmail com>
Date: Sun Jul 3 11:51:15 2011 +0200
map-absolute, map-relative: add a property to choose the sampler
gegl/gegl-chant.h | 4 +-
gegl/gegl-types.c | 39 ++++++++++++++++++++++++++++++++++++++
operations/common/map-absolute.c | 9 +++++--
operations/common/map-relative.c | 7 +++--
4 files changed, 51 insertions(+), 8 deletions(-)
---
diff --git a/gegl/gegl-chant.h b/gegl/gegl-chant.h
index 1dd1a24..c455ada 100644
--- a/gegl/gegl-chant.h
+++ b/gegl/gegl-chant.h
@@ -353,7 +353,7 @@ struct _GeglChantO
#define gegl_chant_curve(name, nick, blurb) GeglCurve *name;
#define gegl_chant_path(name, nick, blurb) GeglPath *name;\
guint path_changed_handler;
-#define gegl_chant_interpolation(name, nick, def, blurb) GeglInterpolation name;
+#define gegl_chant_interpolation(name, nick, def, blurb) GeglSamplerType name;
#include GEGL_CHANT_C_FILE
@@ -816,7 +816,7 @@ gegl_chant_class_intern_init (gpointer klass)
#define gegl_chant_interpolation(name, nick, def, blurb) \
g_object_class_install_property (object_class, PROP_##name, \
g_param_spec_enum (#name, nick, blurb, \
- GEGL_TYPE_INTERPOLATION,\
+ GEGL_TYPE_SAMPLER_TYPE,\
def, \
(GParamFlags) ( \
G_PARAM_READWRITE | \
diff --git a/gegl/gegl-types.c b/gegl/gegl-types.c
new file mode 100644
index 0000000..bc63235
--- /dev/null
+++ b/gegl/gegl-types.c
@@ -0,0 +1,39 @@
+/* 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 2011 Michael Murà <batolettre gmail com>
+ */
+
+#include "config.h"
+#include <glib-object.h>
+#include "gegl-types.h"
+
+GType
+gegl_sampler_type_get_type (void)
+{
+ static GType etype = 0;
+ if (etype == 0) {
+ static const GEnumValue values[] = {
+ { GEGL_INTERPOLATION_NEAREST, "GEGL_INTERPOLATION_NEAREST", "nearest" },
+ { GEGL_INTERPOLATION_LINEAR, "GEGL_INTERPOLATION_LINEAR", "linear" },
+ { GEGL_INTERPOLATION_CUBIC, "GEGL_INTERPOLATION_CUBIC", "cubic" },
+ { GEGL_INTERPOLATION_LANCZOS, "GEGL_INTERPOLATION_LANCZOS", "lanczos" },
+ { GEGL_INTERPOLATION_LOHALO, "GEGL_INTERPOLATION_LOHALO", "lohalo" },
+ { 0, NULL, NULL }
+ };
+ etype = g_enum_register_static ("GeglSamplerTypeType", values);
+ }
+ return etype;
+}
diff --git a/operations/common/map-absolute.c b/operations/common/map-absolute.c
index 5b1bf26..389960d 100644
--- a/operations/common/map-absolute.c
+++ b/operations/common/map-absolute.c
@@ -18,6 +18,10 @@
*/
#ifdef GEGL_CHANT_PROPERTIES
+
+gegl_chant_interpolation (interpolation, _("Interpolation"),
+ GEGL_INTERPOLATION_CUBIC, _("Sampler used internaly"))
+
#else
#define GEGL_CHANT_TYPE_COMPOSER
@@ -55,17 +59,16 @@ process (GeglOperation *operation,
GeglBuffer *output,
const GeglRectangle *result)
{
+ GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
Babl *format_io, *format_coords;
GeglSampler *sampler;
- GeglSamplerType sampler_type;
GeglBufferIterator *it;
gint index_in, index_out, index_coords;
format_io = babl_format ("RGBA float");
format_coords = babl_format_n (babl_type ("float"), 2);
- sampler_type = gegl_sampler_type_from_string ("cubic");
- sampler = gegl_buffer_sampler_new (input, format_io, sampler_type);
+ sampler = gegl_buffer_sampler_new (input, format_io, o->interpolation);
if (aux != NULL)
{
diff --git a/operations/common/map-relative.c b/operations/common/map-relative.c
index bd0c4b3..15e4d04 100644
--- a/operations/common/map-relative.c
+++ b/operations/common/map-relative.c
@@ -23,6 +23,8 @@
gegl_chant_double (scaling, _("Scaling"), 0.0, 5000.0, 1.0,
_("scaling factor of displacement, indicates how large spatial"
" displacement a relative mapping value of 1.0 corresponds to."))
+gegl_chant_interpolation (interpolation, _("Interpolation"),
+ GEGL_INTERPOLATION_CUBIC, _("Sampler used internaly"))
#else
@@ -61,17 +63,16 @@ process (GeglOperation *operation,
GeglBuffer *output,
const GeglRectangle *result)
{
+ GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
Babl *format_io, *format_coords;
GeglSampler *sampler;
- GeglSamplerType sampler_type;
GeglBufferIterator *it;
gint index_in, index_out, index_coords;
format_io = babl_format ("RGBA float");
format_coords = babl_format_n (babl_type ("float"), 2);
- sampler_type = gegl_sampler_type_from_string ("cubic");
- sampler = gegl_buffer_sampler_new (input, format_io, sampler_type);
+ sampler = gegl_buffer_sampler_new (input, format_io, o->interpolation);
if (aux != NULL)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]