DIRECTOR: Clip Matte sprites properly

This commit is contained in:
Eugene Sandulenko 2019-12-27 13:30:53 +01:00
parent 38c488f2ca
commit a9f8af5400

View File

@ -973,6 +973,10 @@ void Frame::drawMatteSprite(Graphics::ManagedSurface &target, const Graphics::Su
// Like background trans, but all white pixels NOT ENCLOSED by coloured pixels are transparent // Like background trans, but all white pixels NOT ENCLOSED by coloured pixels are transparent
Graphics::Surface tmp; Graphics::Surface tmp;
tmp.copyFrom(sprite); tmp.copyFrom(sprite);
Common::Rect srcRect(sprite.w, sprite.h);
if (!target.clip(srcRect, drawRect))
return; // Out of screen
// Searching white color in the corners // Searching white color in the corners
int whiteColor = -1; int whiteColor = -1;
@ -994,8 +998,8 @@ void Frame::drawMatteSprite(Graphics::ManagedSurface &target, const Graphics::Su
if (whiteColor == -1) { if (whiteColor == -1) {
debugC(1, kDebugImages, "Frame::drawMatteSprite(): No white color for Matte image"); debugC(1, kDebugImages, "Frame::drawMatteSprite(): No white color for Matte image");
for (int yy = 0; yy < tmp.h; yy++) { for (int yy = 0; yy < srcRect.height(); yy++) {
const byte *src = (const byte *)tmp.getBasePtr(0, yy); const byte *src = (const byte *)tmp.getBasePtr(srcRect.left, srcRect.top + yy);
byte *dst = (byte *)target.getBasePtr(drawRect.left, drawRect.top + yy); byte *dst = (byte *)target.getBasePtr(drawRect.left, drawRect.top + yy);
for (int xx = 0; xx < drawRect.width(); xx++, src++, dst++) for (int xx = 0; xx < drawRect.width(); xx++, src++, dst++)
@ -1015,9 +1019,9 @@ void Frame::drawMatteSprite(Graphics::ManagedSurface &target, const Graphics::Su
} }
ff.fillMask(); ff.fillMask();
for (int yy = 0; yy < tmp.h; yy++) { for (int yy = 0; yy < srcRect.height(); yy++) {
const byte *src = (const byte *)tmp.getBasePtr(0, yy); const byte *src = (const byte *)tmp.getBasePtr(srcRect.left, srcRect.top + yy);
const byte *mask = (const byte *)ff.getMask()->getBasePtr(0, yy); const byte *mask = (const byte *)ff.getMask()->getBasePtr(srcRect.left, srcRect.top + yy);
byte *dst = (byte *)target.getBasePtr(drawRect.left, drawRect.top + yy); byte *dst = (byte *)target.getBasePtr(drawRect.left, drawRect.top + yy);
for (int xx = 0; xx < drawRect.width(); xx++, src++, dst++, mask++) for (int xx = 0; xx < drawRect.width(); xx++, src++, dst++, mask++)