Bug 684330 - Rectangle tool's "fixed size" option is off-by-one
ROUND() is consistent only on positive values, and bad rounding creates an offset when negative values are involved. Introduce SIGNED_ROUND() and use it in gimprectangletool.c. It should probably be used in much more places.
This commit is contained in:

committed by
Michael Natterer

parent
a907741d8a
commit
4a5a6ef914
@ -74,10 +74,18 @@ G_BEGIN_DECLS
|
||||
* ROUND:
|
||||
* @x: the value to be rounded.
|
||||
*
|
||||
* This macro rounds its argument @x to the nearest integer.
|
||||
* This macro rounds its positive argument @x to the nearest integer.
|
||||
**/
|
||||
#define ROUND(x) ((int) ((x) + 0.5))
|
||||
|
||||
/**
|
||||
* SIGNED_ROUND:
|
||||
* @x: the value to be rounded.
|
||||
*
|
||||
* This macro rounds its argument @x to the nearest integer.
|
||||
**/
|
||||
#define SIGNED_ROUND(x) ((int) ((((x) < 0) ? (x) - 0.5 : (x) + 0.5)))
|
||||
|
||||
/**
|
||||
* SQR:
|
||||
* @x: the value to be squared.
|
||||
|
Reference in New Issue
Block a user