[gegl] transform-core.c: using ceil in bounding box misses one pixel with integer max



commit 5c2276565ad5cdff7ab891dd5ff0d7ba4b364550
Author: Nicolas Robidoux <nrobidoux git gnome org>
Date:   Wed Dec 5 10:11:49 2012 -0500

    transform-core.c: using ceil in bounding box misses one pixel with integer max

 operations/transform/transform-core.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/operations/transform/transform-core.c b/operations/transform/transform-core.c
index 580b000..30bdcb9 100644
--- a/operations/transform/transform-core.c
+++ b/operations/transform/transform-core.c
@@ -377,8 +377,12 @@ gegl_transform_bounding_box (const gdouble *points,
 
   output->x = (gint) floor ((double) min_x);
   output->y = (gint) floor ((double) min_y);
-  output->width  = (gint) ceil ((double) max_x) - output->x;
-  output->height = (gint) ceil ((double) max_y) - output->y;
+  /*
+   * floor + 1 is used instead of ceil to get the correct number of
+   * pixels when min and max are integers.
+   */
+  output->width  = (gint) floor ((double) max_x) + (gint) 1 - output->x;
+  output->height = (gint) floor ((double) max_y) + (gint) 1 - output->y;
 }
 
 static gboolean



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