diff options
Diffstat (limited to 'engines/mohawk/bitmap.h')
-rw-r--r-- | engines/mohawk/bitmap.h | 72 |
1 files changed, 53 insertions, 19 deletions
diff --git a/engines/mohawk/bitmap.h b/engines/mohawk/bitmap.h index f1fde92f33..8f3f6af436 100644 --- a/engines/mohawk/bitmap.h +++ b/engines/mohawk/bitmap.h @@ -34,7 +34,7 @@ namespace Mohawk { -class ImageData; +class MohawkSurface; enum BitmapFormat { kBitsPerPixel1 = 0x0000, @@ -60,6 +60,11 @@ enum BitmapFormat { kFlag24_MAC = 0x1000 // 24 bit pixel data has been converted to MAC 32 bit format }; +enum OldBitmapFormat { + kOldPackLZ = 0x0020, + kOldDrawRLE8 = 0x0100 +}; + struct BitmapHeader { uint16 width; uint16 height; @@ -79,34 +84,57 @@ public: MohawkBitmap(); virtual ~MohawkBitmap(); - virtual ImageData *decodeImage(Common::SeekableReadStream *stream); - - // Unpack Functions - void unpackRaw(); - void unpackLZ(); - void unpackLZ1(); - void unpackRiven(); - - // Draw Functions - void drawRaw(); - void drawRLE8(); - void drawRLE(); + virtual MohawkSurface *decodeImage(Common::SeekableReadStream *stream); protected: BitmapHeader _header; - byte getBitsPerPixel(); + virtual byte getBitsPerPixel(); // The actual LZ decoder static Common::SeekableReadStream *decompressLZ(Common::SeekableReadStream *stream, uint32 uncompressedSize); -private: + // The current data stream Common::SeekableReadStream *_data; - Graphics::Surface *_surface; + // Create the output surface + Graphics::Surface *createSurface(uint16 width, uint16 height); + + // Draw Functions + void drawRLE8(Graphics::Surface *surface, bool isLE); + void drawRaw(Graphics::Surface *surface); + void drawRLE8(Graphics::Surface *surface) { return drawRLE8(surface, false); } + +private: + // Unpack Functions + void unpackRaw(); + void unpackLZ(); + void unpackRiven(); + + // An unpacker + struct PackFunction { + uint16 flag; + const char *name; + void (MohawkBitmap::*func)(); + }; + + // A drawer + struct DrawFunction { + uint16 flag; + const char *name; + void (MohawkBitmap::*func)(Graphics::Surface *surface); + }; + + // Unpack/Draw maps + const PackFunction *_packTable; + int _packTableSize; + const DrawFunction *_drawTable; + int _drawTableSize; + + // Unpack/Draw helpers const char *getPackName(); void unpackImage(); const char *getDrawName(); - void drawImage(); + void drawImage(Graphics::Surface *surface); // Riven Decoding void handleRivenSubcommandStream(byte count, byte *&dst); @@ -120,7 +148,10 @@ public: MystBitmap() : MohawkBitmap() {} ~MystBitmap() {} - ImageData *decodeImage(Common::SeekableReadStream *stream); + MohawkSurface *decodeImage(Common::SeekableReadStream *stream); + +protected: + byte getBitsPerPixel() { return _info.bitsPerPixel; } private: struct BitmapHeader { @@ -151,7 +182,10 @@ public: OldMohawkBitmap() : MohawkBitmap() {} ~OldMohawkBitmap() {} - ImageData *decodeImage(Common::SeekableReadStream *stream); + MohawkSurface *decodeImage(Common::SeekableReadStream *stream); + +protected: + byte getBitsPerPixel() { return 8; } }; } // End of namespace Mohawk |