[gimp] app: GimpRectangleTool: Rounding error when moving/resizing with keyboard



commit 074e2c088a4a59ca7d744a131745a869bb1017d7
Author: Enrico Schröder <enni schroeder gmail com>
Date:   Wed Mar 30 18:22:21 2011 +0200

    app: GimpRectangleTool: Rounding error when moving/resizing with keyboard
    
    Fix for bug #653186: When a rectangle selection is created or moved by
    mouse at certain zoom-levels (200%, 400%, 800%), its coordinates can
    become exactly .500. By then using the keyboard to move/resize in
    steps of one pixel, a rounding error occurs in
    gimp_rectangle_tool_update_int_rect(). This leads to the coordinate
    either not beeing changed at all or changed by 2 pixels at a time. The
    patch changes the function from using RINT() to ROUND() for the
    calculations, which prevents the rounding error from happening.

 app/tools/gimprectangletool.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/app/tools/gimprectangletool.c b/app/tools/gimprectangletool.c
index 63c61a1..ba976ed 100644
--- a/app/tools/gimprectangletool.c
+++ b/app/tools/gimprectangletool.c
@@ -4297,13 +4297,13 @@ gimp_rectangle_tool_update_int_rect (GimpRectangleTool *rect_tool)
 {
   GimpRectangleToolPrivate *priv = GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool);
 
-  priv->x1_int = RINT (priv->x1);
-  priv->y1_int = RINT (priv->y1);
+  priv->x1_int = ROUND (priv->x1);
+  priv->y1_int = ROUND (priv->y1);
 
   if (gimp_rectangle_tool_rect_rubber_banding_func (rect_tool))
     {
-      priv->width_int  = (gint) RINT (priv->x2) - priv->x1_int;
-      priv->height_int = (gint) RINT (priv->y2) - priv->y1_int;
+      priv->width_int  = (gint) ROUND (priv->x2) - priv->x1_int;
+      priv->height_int = (gint) ROUND (priv->y2) - priv->y1_int;
     }
 }
 



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