[gegl/soc-2011-warp] map-relative: add a scaling factor property



commit e1f5de036bfea101275981fa404fcbf64bca973e
Author: �yvind Kolås <pippin gimp org>
Date:   Thu May 26 18:31:02 2011 +0100

    map-relative: add a scaling factor property

 operations/common/map_relative.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/operations/common/map_relative.c b/operations/common/map_relative.c
index b9c03f0..b79fe16 100644
--- a/operations/common/map_relative.c
+++ b/operations/common/map_relative.c
@@ -30,6 +30,10 @@
 
 #ifdef GEGL_CHANT_PROPERTIES
 
+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."))
+
 #else
 
 #define GEGL_CHANT_TYPE_COMPOSER
@@ -99,13 +103,15 @@ process (GeglOperation       *operation,
           gint        n_pixels = it->length;
           gint        x = it->roi->x; /* initial x                   */
           gint        y = it->roi->y; /*           and y coordinates */
+          gdouble     scaling = GEGL_CHANT_PROPERTIES (operation)->scaling;
           gfloat     *in = it->data[index_in];
           gfloat     *out = it->data[index_out];
           gfloat     *coords = it->data[index_coords];
 
           for (i=0; i<n_pixels; i++)
             {
-              /* if the coordinate asked is an exact pixel, we fetch it directly, to avoid the blur of sampling */
+              /* if the coordinate asked is an exact pixel, we fetch it
+               * directly, to avoid the blur of sampling */
               if (coords[0] == 0 && coords[1] == 0)
                 {
                   out[0] = in[0];
@@ -115,7 +121,8 @@ process (GeglOperation       *operation,
                 }
               else
                 {
-                  gegl_sampler_get (sampler, x+coords[0], y+coords[1], out);
+                  gegl_sampler_get (sampler, x+coords[0] * scaling,
+                                             y+coords[1] * scaling, out);
                 }
 
               coords += 2;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]