diff options
author | Einar Johan Trøan Sømåen | 2012-06-13 20:17:59 +0200 |
---|---|---|
committer | Einar Johan Trøan Sømåen | 2012-06-13 20:18:11 +0200 |
commit | d4ac01148f54f0320657d7e29092be8893c6c9fc (patch) | |
tree | eb238347bbdfb5d45536b8e83a05c7f37d518459 | |
parent | c081d40c961ef61549b4485d79fcb62fc2e2ad73 (diff) | |
download | scummvm-rg350-d4ac01148f54f0320657d7e29092be8893c6c9fc.tar.gz scummvm-rg350-d4ac01148f54f0320657d7e29092be8893c6c9fc.tar.bz2 scummvm-rg350-d4ac01148f54f0320657d7e29092be8893c6c9fc.zip |
WINTERMUTE: Add support for alpha-images in Theora-player.
-rw-r--r-- | engines/wintermute/video/VidTheoraPlayer.cpp | 54 | ||||
-rw-r--r-- | engines/wintermute/video/VidTheoraPlayer.h | 5 |
2 files changed, 48 insertions, 11 deletions
diff --git a/engines/wintermute/video/VidTheoraPlayer.cpp b/engines/wintermute/video/VidTheoraPlayer.cpp index fd1b7cea2b..9877a67bdc 100644 --- a/engines/wintermute/video/VidTheoraPlayer.cpp +++ b/engines/wintermute/video/VidTheoraPlayer.cpp @@ -60,7 +60,7 @@ void CVidTheoraPlayer::SetDefaults() { _texture = NULL; _alphaImage = NULL; - _alphaFilename = NULL; + _alphaFilename = ""; _frameRendered = false; @@ -589,13 +589,38 @@ HRESULT CVidTheoraPlayer::WriteVideo() { if (!_texture) return E_FAIL; _texture->startPixelOp(); + + writeAlpha(); + if (_alphaImage) { + _texture->putSurface(_surface, true); + } else { + _texture->putSurface(_surface, false); + } + //RenderFrame(_texture, &yuv); - _texture->putSurface(_surface); + _texture->endPixelOp(); return S_OK; } +void CVidTheoraPlayer::writeAlpha() { + if (_alphaImage && _surface.w == _alphaImage->getSurface()->w && _surface.h == _alphaImage->getSurface()->h) { + assert(_alphaImage->getSurface()->format.bytesPerPixel == 4); + assert(_surface.format.bytesPerPixel == 4); + const byte *alphaData = (byte*)_alphaImage->getSurface()->getBasePtr(0, 0); + int alphaPlace = (_alphaImage->getSurface()->format.aShift / 8); + alphaData += alphaPlace; + byte *imgData = (byte*)_surface.getBasePtr(0,0); + imgData += (_surface.format.aShift / 8); + for (int i = 0; i < _surface.w * _surface.h; i++) { + *imgData = *alphaData; + alphaData += 4; + imgData += 4; + } + } +} + ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::display(uint32 Alpha) { RECT rc; @@ -613,8 +638,22 @@ HRESULT CVidTheoraPlayer::display(uint32 Alpha) { } ////////////////////////////////////////////////////////////////////////// -HRESULT CVidTheoraPlayer::setAlphaImage(const char *filename) { - warning("CVidTheoraPlayer::SetAlphaImage(%s) - Not implemented", filename); +HRESULT CVidTheoraPlayer::setAlphaImage(const Common::String &filename) { + warning("CVidTheoraPlayer::SetAlphaImage(%s) - Not implemented", filename.c_str()); + + delete _alphaImage; + _alphaImage = new CBImage(Game); + if (!_alphaImage || FAILED(_alphaImage->loadFile(filename))) { + delete _alphaImage; + _alphaImage = NULL; + _alphaFilename = ""; + return E_FAIL; + } + + if (_alphaFilename != filename) { + _alphaFilename = filename; + } + //TODO: Conversion. #if 0 SAFE_DELETE(m_AlphaImage); m_AlphaImage = new CBImage(Game); @@ -631,11 +670,8 @@ HRESULT CVidTheoraPlayer::setAlphaImage(const char *filename) { ////////////////////////////////////////////////////////////////////////// byte CVidTheoraPlayer::getAlphaAt(int X, int Y) { -#if 0 - if (_alphaImage) return _alphaImage->GetAlphaAt(X, Y); + if (_alphaImage) return _alphaImage->getAlphaAt(X, Y); else return 0xFF; -#endif - return 0; } @@ -770,7 +806,7 @@ HRESULT CVidTheoraPlayer::resume() { ////////////////////////////////////////////////////////////////////////// HRESULT CVidTheoraPlayer::initializeSimple() { if (SUCCEEDED(initialize(_filename))) { - if (_alphaFilename) setAlphaImage(_alphaFilename); + if (_alphaFilename != "") setAlphaImage(_alphaFilename); play(_playbackType, _posX, _posY, false, false, _looping, _savedPos, _playZoom); } else _state = THEORA_STATE_FINISHED; diff --git a/engines/wintermute/video/VidTheoraPlayer.h b/engines/wintermute/video/VidTheoraPlayer.h index 50a94667fd..fc89b07c53 100644 --- a/engines/wintermute/video/VidTheoraPlayer.h +++ b/engines/wintermute/video/VidTheoraPlayer.h @@ -115,9 +115,10 @@ public: // alpha related CBImage *_alphaImage; - char *_alphaFilename; - HRESULT setAlphaImage(const char *Filename); + Common::String _alphaFilename; + HRESULT setAlphaImage(const Common::String &filename); __inline byte getAlphaAt(int X, int Y); + void writeAlpha(); HRESULT SeekToTime(uint32 Time); |