diff options
author | Paul Gilbert | 2017-05-20 17:27:23 -0400 |
---|---|---|
committer | Paul Gilbert | 2017-05-20 17:27:23 -0400 |
commit | 1b10678898142b797242fd6ac735244fd0ce5b8a (patch) | |
tree | aadc10e3d48ca0e10eff89effcc12db36b461826 /engines/titanic/support/transparency_surface.cpp | |
parent | 779b8336b1227f010099f8faabe4d0c9b035832e (diff) | |
download | scummvm-rg350-1b10678898142b797242fd6ac735244fd0ce5b8a.tar.gz scummvm-rg350-1b10678898142b797242fd6ac735244fd0ce5b8a.tar.bz2 scummvm-rg350-1b10678898142b797242fd6ac735244fd0ce5b8a.zip |
TITANIC: Fix blitting of game objects with a transparency surface
Diffstat (limited to 'engines/titanic/support/transparency_surface.cpp')
-rw-r--r-- | engines/titanic/support/transparency_surface.cpp | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/engines/titanic/support/transparency_surface.cpp b/engines/titanic/support/transparency_surface.cpp index 8b5cbecc5f..505cd1ff6c 100644 --- a/engines/titanic/support/transparency_surface.cpp +++ b/engines/titanic/support/transparency_surface.cpp @@ -31,24 +31,25 @@ CTransparencySurface::CTransparencySurface(const Graphics::Surface *surface, _pitch = 0; _runLength = 0; _flag = false; - _flag1 = false; - _flag2 = true; + _opaqueColor = 0; + _transparentColor = 0xff; switch (transMode) { case TRANS_MASK0: case TRANS_ALPHA0: - _flag2 = false; - _flag1 = true; + _transparentColor = 0; + _opaqueColor = 0xff; break; case TRANS_MASK255: case TRANS_ALPHA255: - _flag2 = true; - _flag1 = false; + _transparentColor = 0xff; + _opaqueColor = 0; break; case TRANS_DEFAULT: + // If top left pixel is low, then 0 is the transparent color if (*(const byte *)surface->getPixels() < 0x80) { - _flag1 = true; - _flag2 = false; + _opaqueColor = 0xff; + _transparentColor = 0; } break; default: @@ -72,11 +73,23 @@ uint CTransparencySurface::getPixel() const { uint CTransparencySurface::getAlpha() const { byte pixel = getPixel(); - return _flag1 ? 0xFF - pixel : pixel; + return _opaqueColor ? 0xFF - pixel : pixel; } -bool CTransparencySurface::isPixelTransparent() { - return getAlpha() == 0xff; +bool CTransparencySurface::isPixelOpaque() const { + byte pixel = getPixel(); + if (_opaqueColor) + return pixel >= 0xf0; + else + return pixel < 0x10; +} + +bool CTransparencySurface::isPixelTransparent() const { + byte pixel = getPixel(); + if (_transparentColor) + return pixel >= 0xf0; + else + return pixel < 0x10; } } // End of namespace Titanic |