summaryrefslogtreecommitdiffstats
path: root/generic/tkObj.c
diff options
context:
space:
mode:
authordonal.k.fellows@manchester.ac.uk <dkf>2012-03-07 14:16:26 (GMT)
committerdonal.k.fellows@manchester.ac.uk <dkf>2012-03-07 14:16:26 (GMT)
commita73265b798a7abc72ed6076c1d8935235af6d8a9 (patch)
treef8212c5e60edf4d0f1cd2de335836b8c83dad5a2 /generic/tkObj.c
parent37294049ea0dcd44ef02a23957f4fae50c200393 (diff)
downloadtk-a73265b798a7abc72ed6076c1d8935235af6d8a9.zip
tk-a73265b798a7abc72ed6076c1d8935235af6d8a9.tar.gz
tk-a73265b798a7abc72ed6076c1d8935235af6d8a9.tar.bz2
* generic/tkObj.c (GetPixelsFromObjEx): [Bug 3497848]: Better rounding
of pixel values to integers.
Diffstat (limited to 'generic/tkObj.c')
-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;