SHERLOCK: Reverse scaling factor in transBlitFrom to match original

Original uses scale amounts > 256 for image reduction, and values
less than that for image expansion
This commit is contained in:
Paul Gilbert 2015-06-06 15:36:23 -04:00
parent e28aa3af79
commit 2ac05321aa
3 changed files with 20 additions and 19 deletions

View file

@ -514,11 +514,11 @@ int ImageFrame::sDrawXSize(int scaleVal) const {
int width = _width; int width = _width;
int scale = scaleVal == 0 ? 1 : scaleVal; int scale = scaleVal == 0 ? 1 : scaleVal;
if (scaleVal >= 256) if (scaleVal >= SCALE_THRESHOLD)
--width; --width;
int result = width * 256 / scale; int result = width * SCALE_THRESHOLD / scale;
if (scaleVal >= 256) if (scaleVal >= SCALE_THRESHOLD)
++result; ++result;
return result; return result;
@ -528,11 +528,11 @@ int ImageFrame::sDrawYSize(int scaleVal) const {
int height = _height; int height = _height;
int scale = scaleVal == 0 ? 1 : scaleVal; int scale = scaleVal == 0 ? 1 : scaleVal;
if (scaleVal >= 256) if (scaleVal >= SCALE_THRESHOLD)
--height; --height;
int result = height * 256 / scale; int result = height * SCALE_THRESHOLD / scale;
if (scaleVal >= 256) if (scaleVal >= SCALE_THRESHOLD)
++result; ++result;
return result; return result;
@ -542,11 +542,11 @@ int ImageFrame::sDrawXOffset(int scaleVal) const {
int width = _offset.x; int width = _offset.x;
int scale = scaleVal == 0 ? 1 : scaleVal; int scale = scaleVal == 0 ? 1 : scaleVal;
if (scaleVal >= 256) if (scaleVal >= SCALE_THRESHOLD)
--width; --width;
int result = width * 256 / scale; int result = width * SCALE_THRESHOLD / scale;
if (scaleVal >= 256) if (scaleVal >= SCALE_THRESHOLD)
++result; ++result;
return result; return result;
@ -556,11 +556,11 @@ int ImageFrame::sDrawYOffset(int scaleVal) const {
int height = _offset.y; int height = _offset.y;
int scale = scaleVal == 0 ? 1 : scaleVal; int scale = scaleVal == 0 ? 1 : scaleVal;
if (scaleVal >= 256) if (scaleVal >= SCALE_THRESHOLD)
--height; --height;
int result = height * 256 / scale; int result = height * SCALE_THRESHOLD / scale;
if (scaleVal >= 256) if (scaleVal >= SCALE_THRESHOLD)
++result; ++result;
return result; return result;

View file

@ -111,17 +111,16 @@ void Surface::transBlitFrom(const Graphics::Surface &src, const Common::Point &p
return; return;
} }
const int SCALE_LIMIT = 0x100; int scaleX = SCALE_THRESHOLD * SCALE_THRESHOLD / scaleVal;
int scaleX = scaleVal; int scaleY = scaleX;
int scaleY = scaleVal;
int scaleXCtr = 0, scaleYCtr = 0; int scaleXCtr = 0, scaleYCtr = 0;
for (int yCtr = 0, destY = pt.y; yCtr < src.h && destY < this->h(); ++yCtr) { for (int yCtr = 0, destY = pt.y; yCtr < src.h && destY < this->h(); ++yCtr) {
// Handle skipping lines if Y scaling // Handle skipping lines if Y scaling
scaleYCtr += scaleY; scaleYCtr += scaleY;
while (scaleYCtr >= SCALE_LIMIT && destY < this->h()) { while (scaleYCtr >= SCALE_THRESHOLD && destY < this->h()) {
scaleYCtr -= SCALE_LIMIT; scaleYCtr -= SCALE_THRESHOLD;
if (destY >= 0) { if (destY >= 0) {
// Handle drawing the line // Handle drawing the line
@ -133,8 +132,8 @@ void Surface::transBlitFrom(const Graphics::Surface &src, const Common::Point &p
// Handle horizontal scaling // Handle horizontal scaling
scaleXCtr += scaleX; scaleXCtr += scaleX;
while (scaleXCtr >= SCALE_LIMIT && destX < this->w()) { while (scaleXCtr >= SCALE_THRESHOLD && destX < this->w()) {
scaleXCtr -= SCALE_LIMIT; scaleXCtr -= SCALE_THRESHOLD;
// Only handle on-screen pixels // Only handle on-screen pixels
if (destX >= 0 && *pSrc != TRANSPARENCY) if (destX >= 0 && *pSrc != TRANSPARENCY)

View file

@ -28,6 +28,8 @@
namespace Sherlock { namespace Sherlock {
#define SCALE_THRESHOLD 0x100
struct ImageFrame; struct ImageFrame;
class Surface { class Surface {