diff options
author | Paul Gilbert | 2016-07-22 21:46:32 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-22 21:56:16 -0400 |
commit | 21e4d6686f515e70fce1ee177388b5d3bc7a4d61 (patch) | |
tree | 6f16f68103b768ffbff435de46c18c15dda1dbe5 /engines/titanic/support | |
parent | 7f05cfad13fbce82326542d9bdd0dd0473565baf (diff) | |
download | scummvm-rg350-21e4d6686f515e70fce1ee177388b5d3bc7a4d61.tar.gz scummvm-rg350-21e4d6686f515e70fce1ee177388b5d3bc7a4d61.tar.bz2 scummvm-rg350-21e4d6686f515e70fce1ee177388b5d3bc7a4d61.zip |
TITANIC: Beginnings of Continue Save dialog
Diffstat (limited to 'engines/titanic/support')
-rw-r--r-- | engines/titanic/support/image.cpp | 113 | ||||
-rw-r--r-- | engines/titanic/support/image.h | 49 |
2 files changed, 29 insertions, 133 deletions
diff --git a/engines/titanic/support/image.cpp b/engines/titanic/support/image.cpp index cabdd64cf3..1e936b6940 100644 --- a/engines/titanic/support/image.cpp +++ b/engines/titanic/support/image.cpp @@ -20,102 +20,37 @@ * */ -#include "common/file.h" #include "titanic/support/image.h" +#include "titanic/titanic.h" +#include "image/bmp.h" namespace Titanic { -BITMAPINFOHEADER::BITMAPINFOHEADER() { - _biSize = 0; - _biWidth = 0; - _biHeight = 0; - _biPlanes = 0; - _biBitCount = 0; - _biCompression = 0; - _biSizeImage = 0; - _biXPelsPerMeter = 0; - _biYPelsPerMeter = 0; - _biClrUsed = 0; - _biClrImportant = 0; -} - -/*------------------------------------------------------------------------*/ - -RGBQuad::RGBQuad() : _rgbRed(0), _rgbGreen(0), _rgbBlue(0), _rgbReserved(0) {} - -/*------------------------------------------------------------------------*/ - -Image::Image() { - _bitmapInfo = nullptr; - _bits = nullptr; - _flag = true; - - set(16, 16); -} - -void Image::proc6() { - -} - -void Image::set(int width, int height) { - delete _bitmapInfo; - if (_flag && _bitmapInfo) - delete[] _bits; - - _bitmapInfo = new tagBITMAPINFO; - _bits = new byte[(width + 3) & 0xFFFC * height]; - - tagBITMAPINFO &bi = *_bitmapInfo; - bi._bmiHeader._biWidth = width; - bi._bmiHeader._biHeight = height; - bi._bmiHeader._biPlanes = 1; - bi._bmiHeader._biBitCount = 8; -} - -void Image::proc8() { - -} - -bool Image::loadResource(const Common::String &name) { - // This method is hardcoded for the Titanic splash screen resource - assert(name == "TITANIC"); - - Common::File f; - if (!f.open("ST.exe")) - return false; - - // The ST.exe executable has a bitmap called "TITANIC". Since we can't use - // the Windows FindResource function in ScummVM, this is hardcoded for now - f.seek(0x29B660); - uint size = f.readUint32LE(); - if (size != 40) - return false; - - loadBitmap(f); - - return true; -} - -void Image::proc10() { - -} - -void Image::draw() { - +void Image::load(const CString &resName) { + Common::SeekableReadStream *stream = g_vm->_filesManager->getResource(resName); + loadBitmap(*stream); + delete stream; } void Image::loadBitmap(Common::SeekableReadStream &s) { - _bitmapInfo->_bmiHeader._biWidth = s.readUint32LE(); - _bitmapInfo->_bmiHeader._biHeight = s.readUint32LE(); - _bitmapInfo->_bmiHeader._biPlanes = s.readUint16LE(); - _bitmapInfo->_bmiHeader._biBitCount = s.readUint16LE(); - _bitmapInfo->_bmiHeader._biCompression = s.readUint32LE(); - _bitmapInfo->_bmiHeader._biSizeImage = s.readUint32LE(); - _bitmapInfo->_bmiHeader._biXPelsPerMeter = s.readUint32LE(); - _bitmapInfo->_bmiHeader._biYPelsPerMeter = s.readUint32LE(); - _bitmapInfo->_bmiHeader._biClrUsed = s.readUint32LE(); - _bitmapInfo->_bmiHeader._biClrImportant = s.readUint32LE(); - + ::Image::BitmapDecoder decoder; + decoder.loadStream(s); + const Graphics::Surface *src = decoder.getSurface(); + Graphics::PixelFormat scrFormat = g_system->getScreenFormat(); + + if (src->format == scrFormat) { + create(src->w, src->h, scrFormat); + blitFrom(*src); + } else { + // Convert the loaded surface to the screen surface format + const byte *palette = decoder.getPalette(); + Graphics::Surface *surface = src->convertTo(scrFormat, palette); + create(surface->w, surface->h, scrFormat); + blitFrom(*surface); + + surface->free(); + delete surface; + } } } // End of namespace Titanic diff --git a/engines/titanic/support/image.h b/engines/titanic/support/image.h index 9030e81ad7..9876f15c40 100644 --- a/engines/titanic/support/image.h +++ b/engines/titanic/support/image.h @@ -23,58 +23,19 @@ #ifndef TITANIC_IMAGE_H #define TITANIC_IMAGE_H -#include "common/scummsys.h" -#include "common/array.h" +#include "common/stream.h" +#include "graphics/managed_surface.h" +#include "titanic/support/string.h" namespace Titanic { -struct BITMAPINFOHEADER { - int _biSize; - int _biWidth; - int _biHeight; - int _biPlanes; - int _biBitCount; - int _biCompression; - int _biSizeImage; - int _biXPelsPerMeter; - int _biYPelsPerMeter; - int _biClrUsed; - int _biClrImportant; - - BITMAPINFOHEADER(); -}; - -struct RGBQuad { - byte _rgbRed; - byte _rgbGreen; - byte _rgbBlue; - byte _rgbReserved; - - RGBQuad(); -}; - -struct tagBITMAPINFO { - BITMAPINFOHEADER _bmiHeader; - RGBQuad _bmiColors[256]; -}; - -class Image { +class Image : public Graphics::ManagedSurface { private: void loadBitmap(Common::SeekableReadStream &s); public: - tagBITMAPINFO *_bitmapInfo; - byte *_bits; - bool _flag; -public: - Image(); virtual ~Image() {} - virtual void proc6(); - virtual void set(int width, int height); - virtual void proc8(); - virtual bool loadResource(const Common::String &name); - virtual void proc10(); - virtual void draw(); + void load(const CString &resName); }; } // End of namespace Titanic |