diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/mohawk/bitmap.cpp | 41 | ||||
-rw-r--r-- | engines/mohawk/bitmap.h | 4 |
2 files changed, 42 insertions, 3 deletions
diff --git a/engines/mohawk/bitmap.cpp b/engines/mohawk/bitmap.cpp index d3d560b1a6..ac4f27619b 100644 --- a/engines/mohawk/bitmap.cpp +++ b/engines/mohawk/bitmap.cpp @@ -59,7 +59,7 @@ MohawkBitmap::MohawkBitmap() { MohawkBitmap::~MohawkBitmap() { } -MohawkSurface *MohawkBitmap::decodeImage(Common::SeekableReadStream *stream) { +void MohawkBitmap::decodeImageData(Common::SeekableReadStream *stream) { _data = stream; _header.colorTable.palette = NULL; @@ -90,15 +90,50 @@ MohawkSurface *MohawkBitmap::decodeImage(Common::SeekableReadStream *stream) { } } - Graphics::Surface *surface = createSurface(_header.width, _header.height); - unpackImage(); +} + +MohawkSurface *MohawkBitmap::decodeImage(Common::SeekableReadStream *stream) { + decodeImageData(stream); + + Graphics::Surface *surface = createSurface(_header.width, _header.height); drawImage(surface); delete _data; return new MohawkSurface(surface, _header.colorTable.palette); } +Common::Array<MohawkSurface *> MohawkBitmap::decodeImages(Common::SeekableReadStream *stream) { + decodeImageData(stream); + + // Some Mohawk games (CSTime, Zoombinis) store 'compound shapes' by + // packing several sub-images inside the data portion of an image. + // We take a copy of what we need (since it will be overwritten), + // and then decodeImage() all these sub-images. + Common::SeekableReadStream *data = _data; + int32 startPos = data->pos(); + uint16 count = _header.width; + + Common::Array<uint32> offsets; + for (uint i = 0; i < count; i++) + offsets.push_back(data->readUint32BE()); + + Common::Array<MohawkSurface *> surfaces; + for (uint i = 0; i < count; i++) { + uint32 start = startPos + offsets[i] - 8; + uint32 end; + if (i != (uint)count - 1) + end = startPos + offsets[i + 1] - 8; + else + end = data->size(); + Common::SeekableSubReadStream *substream = new Common::SeekableSubReadStream(data, start, end); + surfaces.push_back(decodeImage(substream)); + } + + delete data; + return surfaces; +} + Graphics::Surface *MohawkBitmap::createSurface(uint16 width, uint16 height) { Graphics::Surface *surface = new Graphics::Surface(); byte bytesPerPixel = (getBitsPerPixel() <= 8) ? 1 : g_system->getScreenFormat().bytesPerPixel; diff --git a/engines/mohawk/bitmap.h b/engines/mohawk/bitmap.h index 6dd6b1115d..14b8e75327 100644 --- a/engines/mohawk/bitmap.h +++ b/engines/mohawk/bitmap.h @@ -30,6 +30,7 @@ #include "common/scummsys.h" #include "common/stream.h" +#include "common/array.h" #include "graphics/surface.h" namespace Mohawk { @@ -85,11 +86,14 @@ public: virtual ~MohawkBitmap(); virtual MohawkSurface *decodeImage(Common::SeekableReadStream *stream); + Common::Array<MohawkSurface *> decodeImages(Common::SeekableReadStream *stream); protected: BitmapHeader _header; virtual byte getBitsPerPixel(); + void decodeImageData(Common::SeekableReadStream *stream); + // The actual LZ decoder static Common::SeekableReadStream *decompressLZ(Common::SeekableReadStream *stream, uint32 uncompressedSize); |