summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2012-03-07 14:16:26 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2012-03-07 14:16:26 (GMT)
commit1315c522b0ca1b7e4ebb733c2bfbf4290ac3ecb6 (patch)
treef8212c5e60edf4d0f1cd2de335836b8c83dad5a2 /generic
parentc7743f2ce4ec3fec9d6ea18f1edb649f89085448 (diff)
downloadtk-1315c522b0ca1b7e4ebb733c2bfbf4290ac3ecb6.zip
tk-1315c522b0ca1b7e4ebb733c2bfbf4290ac3ecb6.tar.gz
tk-1315c522b0ca1b7e4ebb733c2bfbf4290ac3ecb6.tar.bz2
* generic/tkObj.c (GetPixelsFromObjEx): [Bug 3497848]: Better rounding
of pixel values to integers.
Diffstat (limited to 'generic')
-rw-r--r--generic/tkObj.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/generic/tkObj.c b/generic/tkObj.c
index 4c8516e..b9c4f02 100644
--- a/generic/tkObj.c
+++ b/generic/tkObj.c
@@ -211,7 +211,7 @@ GetPixelsFromObjEx(
if (dblPtr != NULL) {
*dblPtr = d;
}
- *intPtr = (int) d;
+ *intPtr = (int) (d<0 ? d-0.5 : d+0.5);
return TCL_OK;
} else if (objPtr->typePtr == tsdPtr->intTypePtr) {
(void) Tcl_GetIntFromObj(interp, objPtr, intPtr);
@@ -255,11 +255,7 @@ GetPixelsFromObjEx(
d *= bias[pixelPtr->units] * WidthOfScreen(Tk_Screen(tkwin));
d /= WidthMMOfScreen(Tk_Screen(tkwin));
}
- if (d < 0) {
- pixelPtr->returnValue = (int) (d - 0.5);
- } else {
- pixelPtr->returnValue = (int) (d + 0.5);
- }
+ pixelPtr->returnValue = (int) (d<0 ? d-0.5 : d+0.5);
pixelPtr->tkwin = tkwin;
if (dblPtr) {
*dblPtr=(double)d;