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!
This commit is contained in:
parent
531467581f
commit
f285e384da
1 changed files with 4 additions and 4 deletions
|
@ -94,8 +94,8 @@ protected:
|
||||||
error("convertVirtualToWindow called without a valid draw rect");
|
error("convertVirtualToWindow called without a valid draw rect");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Common::Point(targetX + x * targetWidth / sourceWidth,
|
return Common::Point(targetX + (x * targetWidth + sourceWidth / 2) / sourceWidth,
|
||||||
targetY + y * targetHeight / sourceHeight);
|
targetY + (y * targetHeight + sourceHeight / 2) / sourceHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -120,8 +120,8 @@ protected:
|
||||||
x = CLIP<int>(x, sourceX, sourceMaxX);
|
x = CLIP<int>(x, sourceX, sourceMaxX);
|
||||||
y = CLIP<int>(y, sourceY, sourceMaxY);
|
y = CLIP<int>(y, sourceY, sourceMaxY);
|
||||||
|
|
||||||
return Common::Point(((x - sourceX) * targetWidth) / sourceWidth,
|
return Common::Point(((x - sourceX) * targetWidth + sourceWidth / 2) / sourceWidth,
|
||||||
((y - sourceY) * targetHeight) / sourceHeight);
|
((y - sourceY) * targetHeight + sourceHeight / 2) / sourceHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue