Permalink
Browse files

GRAPHICS: Fix rounding error when using non-integral scaling

When a non-integral scaling was being used, x and/or y cursor position would be
one less than what it should be.

Fixes Trac#10401

Thanks snover!
  • Loading branch information...
tsoliman committed Jan 13, 2018
1 parent 5314675 commit f285e384da6efb992bfc705c32eba44cf3255564
Showing with 4 additions and 4 deletions.
  1. +4 −4 backends/graphics/windowed.h
@@ -94,8 +94,8 @@ class WindowedGraphicsManager : virtual public GraphicsManager {
error("convertVirtualToWindow called without a valid draw rect");
}
return Common::Point(targetX + x * targetWidth / sourceWidth,
targetY + y * targetHeight / sourceHeight);
return Common::Point(targetX + (x * targetWidth + sourceWidth / 2) / sourceWidth,
targetY + (y * targetHeight + sourceHeight / 2) / sourceHeight);
}
/**
@@ -120,8 +120,8 @@ class WindowedGraphicsManager : virtual public GraphicsManager {
x = CLIP<int>(x, sourceX, sourceMaxX);
y = CLIP<int>(y, sourceY, sourceMaxY);
return Common::Point(((x - sourceX) * targetWidth) / sourceWidth,
((y - sourceY) * targetHeight) / sourceHeight);
return Common::Point(((x - sourceX) * targetWidth + sourceWidth / 2) / sourceWidth,
((y - sourceY) * targetHeight + sourceHeight / 2) / sourceHeight);
}
/**

0 comments on commit f285e38

Please sign in to comment.