GRAPHICS: Add a function for scaling a standard Graphics::Surface

This also makes use of it in the SCI and Wintermute engines
This commit is contained in:
Cameron Cawley 2020-07-05 22:17:03 +01:00 committed by Eugene Sandulenko
parent ff1474591f
commit 352653b8a2
8 changed files with 40 additions and 37 deletions

View file

@ -368,6 +368,21 @@ void Surface::flipVertical(const Common::Rect &r) {
delete[] temp;
}
Graphics::Surface *Surface::scale(uint16 newWidth, uint16 newHeight, bool filtering) const {
Graphics::Surface *target = new Graphics::Surface();
target->create(newWidth, newHeight, format);
if (filtering) {
scaleBlitBilinear((byte *)target->getPixels(), (const byte *)getPixels(), target->pitch, pitch, target->w, target->h, w, h, format);
} else {
scaleBlit((byte *)target->getPixels(), (const byte *)getPixels(), target->pitch, pitch, target->w, target->h, w, h, format);
}
return target;
}
void Surface::convertToInPlace(const PixelFormat &dstFormat, const byte *palette) {
// Do not convert to the same format and ignore empty surfaces.
if (format == dstFormat || pixels == 0) {