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.
This commit is contained in:
Enrico Schröder 2011-03-30 18:22:21 +02:00 committed by Michael Natterer
parent aae8787ee3
commit 074e2c088a
1 changed files with 4 additions and 4 deletions

View File

@ -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;
}
}