diff options
author | dkf <dkf@noemail.net> | 2012-03-07 14:25:24 (GMT) |
---|---|---|
committer | dkf <dkf@noemail.net> | 2012-03-07 14:25:24 (GMT) |
commit | 9b36fa71170c445ee91a8c912d650d1f50ffb277 (patch) | |
tree | 9e54688720c5829660d87bab64646b8ff3db701e /generic | |
parent | 4021a011b4f7cf0ee48d5a471913ff60a57485d9 (diff) | |
parent | 5120982080e27f176d764b44810bee30f2fa5c40 (diff) | |
download | tk-9b36fa71170c445ee91a8c912d650d1f50ffb277.zip tk-9b36fa71170c445ee91a8c912d650d1f50ffb277.tar.gz tk-9b36fa71170c445ee91a8c912d650d1f50ffb277.tar.bz2 |
* generic/tkObj.c (GetPixelsFromObjEx): [Bug 3497848]: Better rounding
of pixel values to integers.
FossilOrigin-Name: 8ab83fec6d3e2e52b2e4de9607982930e4c0af9a
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkObj.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/generic/tkObj.c b/generic/tkObj.c index 7affac4..2e45e0e 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 == typeCache->intTypePtr) { (void) Tcl_GetIntFromObj(interp, objPtr, intPtr); @@ -253,11 +253,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 = d; |