[gegl] Bug 648693 - Checkerboard rendered incorrectly



commit 8ad98ebfa6ed7ba3a75967b475e0f0e24d6d6e3a
Author: Michael Murà <batolettre gmail com>
Date:   Thu Sep 1 23:23:31 2011 +0200

    Bug 648693 - Checkerboard rendered incorrectly
    
    use a fully defined function to divide (rounding is undefined for negative argument in C) and fix the pattern when crossing zero.

 operations/common/checkerboard.c |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/operations/common/checkerboard.c b/operations/common/checkerboard.c
index 0896d0e..a0f9174 100644
--- a/operations/common/checkerboard.c
+++ b/operations/common/checkerboard.c
@@ -18,6 +18,7 @@
 
 #include "config.h"
 #include <glib/gi18n-lib.h>
+#include <stdlib.h>
 
 #ifdef GEGL_CHANT_PROPERTIES
 
@@ -73,9 +74,25 @@ process (GeglOperation       *operation,
     {
       gint nx,ny;
 
-      nx = (x - o->x_offset)/o->x;
-      ny = (y - o->y_offset)/o->y;
-      /* shift negative cell indices, because / rounds towards zero. */
+      if ((x - o->x_offset) < 0)
+        {
+          nx = div (x - o->x_offset + 1, o->x).quot;
+        }
+      else
+        {
+          nx = div (x - o->x_offset, o->x).quot;
+        }
+
+      if ((y - o->y_offset) < 0)
+        {
+          ny = div (y - o->y_offset + 1, o->y).quot;
+        }
+      else
+        {
+          ny = div (y - o->y_offset, o->y).quot;
+        }
+
+      /* shift negative cell indices */
       nx -= (x - o->x_offset) < 0 ? 1 : 0;
       ny -= (y - o->y_offset) < 0 ? 1 : 0;
 



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