diff options
Diffstat (limited to 'src/zoom.hpp')
-rw-r--r-- | src/zoom.hpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/zoom.hpp b/src/zoom.hpp index c80f094bf..500182d71 100644 --- a/src/zoom.hpp +++ b/src/zoom.hpp @@ -37,14 +37,14 @@ static inline int ScaleByZoom(int value, ZoomLevel zoom) { if (zoom == ZOOM_LVL_NORMAL) return value; int izoom = (int)zoom - (int)ZOOM_LVL_NORMAL; - return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : value >> -izoom; + return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : (value + (1 << -izoom)) >> -izoom; } static inline int UnScaleByZoom(int value, ZoomLevel zoom) { if (zoom == ZOOM_LVL_NORMAL) return value; int izoom = (int)zoom - (int)ZOOM_LVL_NORMAL; - return (zoom > ZOOM_LVL_NORMAL) ? value >> izoom : value << -izoom; + return (zoom > ZOOM_LVL_NORMAL) ? (value + (1 << izoom) - 1) >> izoom : value << -izoom; } #endif /* ZOOM_HPP */ |