2009-12-29 23:18:24 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MOHAWK_BITMAP_H
|
|
|
|
#define MOHAWK_BITMAP_H
|
|
|
|
|
|
|
|
#include "mohawk/graphics.h"
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/stream.h"
|
2010-12-21 18:16:37 +00:00
|
|
|
#include "common/array.h"
|
2009-12-29 23:18:24 +00:00
|
|
|
#include "graphics/surface.h"
|
|
|
|
|
|
|
|
namespace Mohawk {
|
|
|
|
|
2010-11-25 02:59:56 +00:00
|
|
|
class MohawkSurface;
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
enum BitmapFormat {
|
|
|
|
kBitsPerPixel1 = 0x0000,
|
|
|
|
kBitsPerPixel4 = 0x0001,
|
|
|
|
kBitsPerPixel8 = 0x0002,
|
|
|
|
kBitsPerPixel16 = 0x0003,
|
|
|
|
kBitsPerPixel24 = 0x0004,
|
|
|
|
kBitsPerPixelMask = 0x0007,
|
|
|
|
kBitmapHasCLUT = 0x0008,
|
|
|
|
kDrawMASK = 0x00f0,
|
|
|
|
kDrawRaw = 0x0000,
|
|
|
|
kDrawRLE8 = 0x0010,
|
|
|
|
kDrawMSRLE8 = 0x0020,
|
|
|
|
kDrawRLE = 0x0030,
|
|
|
|
kPackMASK = 0x0f00,
|
|
|
|
kPackNone = 0x0000,
|
|
|
|
kPackLZ = 0x0100,
|
|
|
|
kPackLZ1 = 0x0200,
|
|
|
|
kPackRiven = 0x0400,
|
|
|
|
kPackXDec = 0x0f00,
|
|
|
|
kFlagMASK = 0xf000,
|
|
|
|
kFlag16_80X86 = 0x1000, // 16 bit pixel data has been converted to 80X86 format
|
|
|
|
kFlag24_MAC = 0x1000 // 24 bit pixel data has been converted to MAC 32 bit format
|
|
|
|
};
|
|
|
|
|
2010-11-18 13:31:12 +00:00
|
|
|
enum OldBitmapFormat {
|
|
|
|
kOldPackLZ = 0x0020,
|
|
|
|
kOldDrawRLE8 = 0x0100
|
|
|
|
};
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
struct BitmapHeader {
|
|
|
|
uint16 width;
|
|
|
|
uint16 height;
|
|
|
|
int16 bytesPerRow;
|
|
|
|
uint16 format;
|
|
|
|
|
|
|
|
struct ColorTable {
|
|
|
|
uint16 tableSize;
|
|
|
|
byte rgbBits;
|
|
|
|
byte colorCount;
|
|
|
|
byte* palette; // In 8bpp only
|
|
|
|
} colorTable;
|
|
|
|
};
|
|
|
|
|
|
|
|
class MohawkBitmap {
|
|
|
|
public:
|
|
|
|
MohawkBitmap();
|
|
|
|
virtual ~MohawkBitmap();
|
|
|
|
|
2010-11-25 02:59:56 +00:00
|
|
|
virtual MohawkSurface *decodeImage(Common::SeekableReadStream *stream);
|
2010-12-21 18:16:37 +00:00
|
|
|
Common::Array<MohawkSurface *> decodeImages(Common::SeekableReadStream *stream);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
BitmapHeader _header;
|
2010-11-18 20:40:48 +00:00
|
|
|
virtual byte getBitsPerPixel();
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-12-21 18:16:37 +00:00
|
|
|
void decodeImageData(Common::SeekableReadStream *stream);
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
// The actual LZ decoder
|
|
|
|
static Common::SeekableReadStream *decompressLZ(Common::SeekableReadStream *stream, uint32 uncompressedSize);
|
|
|
|
|
2010-11-18 19:06:38 +00:00
|
|
|
// The current data stream
|
2009-12-29 23:18:24 +00:00
|
|
|
Common::SeekableReadStream *_data;
|
2010-11-18 19:06:38 +00:00
|
|
|
|
2010-11-18 20:40:48 +00:00
|
|
|
// Create the output surface
|
|
|
|
Graphics::Surface *createSurface(uint16 width, uint16 height);
|
|
|
|
|
2010-11-18 19:06:38 +00:00
|
|
|
// Draw Functions
|
2010-11-26 15:06:35 +00:00
|
|
|
void drawRLE8(Graphics::Surface *surface, bool isLE);
|
2010-11-18 19:06:38 +00:00
|
|
|
void drawRaw(Graphics::Surface *surface);
|
2010-11-26 15:06:35 +00:00
|
|
|
void drawRLE8(Graphics::Surface *surface) { return drawRLE8(surface, false); }
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-18 13:31:12 +00:00
|
|
|
private:
|
2010-11-18 19:06:38 +00:00
|
|
|
// 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
|
2009-12-29 23:18:24 +00:00
|
|
|
const char *getPackName();
|
|
|
|
void unpackImage();
|
|
|
|
const char *getDrawName();
|
2010-11-18 19:06:38 +00:00
|
|
|
void drawImage(Graphics::Surface *surface);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
// Riven Decoding
|
|
|
|
void handleRivenSubcommandStream(byte count, byte *&dst);
|
|
|
|
};
|
|
|
|
|
2011-03-28 19:20:30 +00:00
|
|
|
#ifdef ENABLE_MYST
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
// Myst uses a different image format than that of other Mohawk games.
|
|
|
|
// It essentially uses a Windows bitmap with the LZ encoding from the
|
|
|
|
// Mohawk Bitmap format.
|
|
|
|
class MystBitmap : public MohawkBitmap {
|
|
|
|
public:
|
|
|
|
MystBitmap() : MohawkBitmap() {}
|
|
|
|
~MystBitmap() {}
|
|
|
|
|
2010-11-25 02:59:56 +00:00
|
|
|
MohawkSurface *decodeImage(Common::SeekableReadStream *stream);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-18 20:40:48 +00:00
|
|
|
protected:
|
|
|
|
byte getBitsPerPixel() { return _info.bitsPerPixel; }
|
|
|
|
|
2010-01-25 01:39:44 +00:00
|
|
|
private:
|
2009-12-29 23:18:24 +00:00
|
|
|
struct BitmapHeader {
|
|
|
|
uint16 type;
|
|
|
|
uint32 size;
|
|
|
|
uint16 res1;
|
|
|
|
uint16 res2;
|
|
|
|
uint32 imageOffset;
|
|
|
|
} _header;
|
|
|
|
|
|
|
|
struct InfoHeader {
|
|
|
|
uint32 size;
|
|
|
|
uint32 width;
|
|
|
|
uint32 height;
|
|
|
|
uint16 planes;
|
|
|
|
uint16 bitsPerPixel;
|
|
|
|
uint32 compression;
|
|
|
|
uint32 imageSize;
|
|
|
|
uint32 pixelsPerMeterX;
|
|
|
|
uint32 pixelsPerMeterY;
|
|
|
|
uint32 colorsUsed;
|
|
|
|
uint32 colorsImportant;
|
|
|
|
} _info;
|
|
|
|
};
|
|
|
|
|
2011-03-28 19:20:30 +00:00
|
|
|
#endif
|
|
|
|
|
2011-03-23 00:54:24 +00:00
|
|
|
class LivingBooksBitmap_v1 : public MohawkBitmap {
|
2009-12-29 23:18:24 +00:00
|
|
|
public:
|
2011-03-23 00:54:24 +00:00
|
|
|
LivingBooksBitmap_v1() : MohawkBitmap() {}
|
|
|
|
~LivingBooksBitmap_v1() {}
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-25 02:59:56 +00:00
|
|
|
MohawkSurface *decodeImage(Common::SeekableReadStream *stream);
|
2010-11-18 20:40:48 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
byte getBitsPerPixel() { return 8; }
|
2009-12-29 23:18:24 +00:00
|
|
|
};
|
|
|
|
|
2010-12-14 22:59:39 +00:00
|
|
|
class DOSBitmap : public MohawkBitmap {
|
|
|
|
public:
|
|
|
|
DOSBitmap() : MohawkBitmap() {}
|
|
|
|
~DOSBitmap() {}
|
|
|
|
|
|
|
|
MohawkSurface *decodeImage(Common::SeekableReadStream *stream);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
byte getBitsPerPixel() { return ((_header.format & 0x30) >> 4) + 1; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
void expandMonochromePlane(Graphics::Surface *surface, Common::SeekableReadStream *rawStream);
|
|
|
|
void expandEGAPlanes(Graphics::Surface *surface, Common::SeekableReadStream *rawStream);
|
|
|
|
};
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
} // End of namespace Mohawk
|
|
|
|
|
|
|
|
#endif
|