[gegl/soc-2012-ops: 2/29] Shift Operation: Make sure the pixels on each line are shifted consistently.



commit 5f8ff82efddb799795e81b629a2ff686d3183f71
Author: Hans Lo <hansshulo gmail com>
Date:   Wed May 30 20:01:28 2012 -0400

    Shift Operation: Make sure the pixels on each line are shifted consistently.

 operations/common/shift.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/operations/common/shift.c b/operations/common/shift.c
index 844c268..8a9bf00 100644
--- a/operations/common/shift.c
+++ b/operations/common/shift.c
@@ -89,6 +89,7 @@ process (GeglOperation       *operation,
 
   gint n_pixels = result->width * result->height;
   gint i;
+  gint j;
 
   GRand *gr;
   gint shift; /* random shift amount */
@@ -111,6 +112,17 @@ process (GeglOperation       *operation,
   gr = g_rand_new ();
   g_rand_set_seed (gr, o->seed);
   shift = g_rand_int_range(gr, -s, s);
+
+  if (o->direction == GEGL_HORIZONTAL)
+    j = result->y;
+  else
+    j = result->x;
+
+  /* run through the random numbers until we reach the one for the first line */
+  for(i = 0; i < j; i++) 
+    {
+      g_rand_int_range(gr, -s, s);
+    }
   
   while (n_pixels--)
     {



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