mirror of
https://github.com/libretro/scummvm.git
synced 2025-05-13 17:46:22 +00:00
MOHAWK: Add support for Riven 24bpp images (not yet used)
svn-id: r54345
This commit is contained in:
parent
9fb1e2b17e
commit
d94844f205
@ -70,7 +70,7 @@ ImageData *MohawkBitmap::decodeImage(Common::SeekableReadStream *stream) {
|
|||||||
|
|
||||||
debug (2, "Decoding Mohawk Bitmap (%dx%d, %dbpp, %s Packing + %s Drawing)", _header.width, _header.height, getBitsPerPixel(), getPackName(), getDrawName());
|
debug (2, "Decoding Mohawk Bitmap (%dx%d, %dbpp, %s Packing + %s Drawing)", _header.width, _header.height, getBitsPerPixel(), getPackName(), getDrawName());
|
||||||
|
|
||||||
if (getBitsPerPixel() != 8)
|
if (getBitsPerPixel() != 8 && getBitsPerPixel() != 24)
|
||||||
error ("Unhandled bpp %d", getBitsPerPixel());
|
error ("Unhandled bpp %d", getBitsPerPixel());
|
||||||
|
|
||||||
// Read in the palette if it's here.
|
// Read in the palette if it's here.
|
||||||
@ -88,8 +88,7 @@ ImageData *MohawkBitmap::decodeImage(Common::SeekableReadStream *stream) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Graphics::Surface *surface = new Graphics::Surface();
|
Graphics::Surface *surface = createSurface(_header.width, _header.height);
|
||||||
surface->create(_header.width, _header.height, getBitsPerPixel() >> 3);
|
|
||||||
|
|
||||||
unpackImage();
|
unpackImage();
|
||||||
drawImage(surface);
|
drawImage(surface);
|
||||||
@ -98,6 +97,13 @@ ImageData *MohawkBitmap::decodeImage(Common::SeekableReadStream *stream) {
|
|||||||
return new ImageData(surface, _header.colorTable.palette);
|
return new ImageData(surface, _header.colorTable.palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Graphics::Surface *MohawkBitmap::createSurface(uint16 width, uint16 height) {
|
||||||
|
Graphics::Surface *surface = new Graphics::Surface();
|
||||||
|
byte bytesPerPixel = (getBitsPerPixel() <= 8) ? 1 : g_system->getScreenFormat().bytesPerPixel;
|
||||||
|
surface->create(width, height, bytesPerPixel);
|
||||||
|
return surface;
|
||||||
|
}
|
||||||
|
|
||||||
byte MohawkBitmap::getBitsPerPixel() {
|
byte MohawkBitmap::getBitsPerPixel() {
|
||||||
switch (_header.format & kBitsPerPixelMask) {
|
switch (_header.format & kBitsPerPixelMask) {
|
||||||
case kBitsPerPixel1:
|
case kBitsPerPixel1:
|
||||||
@ -111,7 +117,7 @@ byte MohawkBitmap::getBitsPerPixel() {
|
|||||||
case kBitsPerPixel24:
|
case kBitsPerPixel24:
|
||||||
return 24;
|
return 24;
|
||||||
default:
|
default:
|
||||||
error ("Unknown bits per pixel");
|
error("Unknown bits per pixel");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -132,7 +138,7 @@ void MohawkBitmap::unpackImage() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
warning("Unknown Pack Compression");
|
error("Unknown Pack Compression");
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *MohawkBitmap::getDrawName() {
|
const char *MohawkBitmap::getDrawName() {
|
||||||
@ -150,7 +156,7 @@ void MohawkBitmap::drawImage(Graphics::Surface *surface) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
warning("Unknown Draw Compression");
|
error("Unknown Draw Compression");
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////
|
//////////////////////////////////////////
|
||||||
@ -520,8 +526,24 @@ void MohawkBitmap::drawRaw(Graphics::Surface *surface) {
|
|||||||
assert(surface);
|
assert(surface);
|
||||||
|
|
||||||
for (uint16 y = 0; y < _header.height; y++) {
|
for (uint16 y = 0; y < _header.height; y++) {
|
||||||
_data->read((byte *)surface->pixels + y * _header.width, _header.width);
|
if (getBitsPerPixel() == 24) {
|
||||||
_data->skip(_header.bytesPerRow - _header.width);
|
Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
|
||||||
|
|
||||||
|
for (uint16 x = 0; x < _header.width; x++) {
|
||||||
|
byte b = _data->readByte();
|
||||||
|
byte g = _data->readByte();
|
||||||
|
byte r = _data->readByte();
|
||||||
|
if (surface->bytesPerPixel == 2)
|
||||||
|
*((uint16 *)surface->getBasePtr(x, y)) = pixelFormat.RGBToColor(r, g, b);
|
||||||
|
else
|
||||||
|
*((uint32 *)surface->getBasePtr(x, y)) = pixelFormat.RGBToColor(r, g, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
_data->skip(_header.bytesPerRow - _header.width * 3);
|
||||||
|
} else {
|
||||||
|
_data->read((byte *)surface->pixels + y * _header.width, _header.width);
|
||||||
|
_data->skip(_header.bytesPerRow - _header.width);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -627,12 +649,11 @@ ImageData* MystBitmap::decodeImage(Common::SeekableReadStream* stream) {
|
|||||||
|
|
||||||
bmpStream->seek(_header.imageOffset);
|
bmpStream->seek(_header.imageOffset);
|
||||||
|
|
||||||
Graphics::Surface *surface = new Graphics::Surface();
|
Graphics::Surface *surface = createSurface(_info.width, _info.height);
|
||||||
int srcPitch = _info.width * (_info.bitsPerPixel >> 3);
|
int srcPitch = _info.width * (_info.bitsPerPixel >> 3);
|
||||||
const int extraDataLength = (srcPitch % 4) ? 4 - (srcPitch % 4) : 0;
|
const int extraDataLength = (srcPitch % 4) ? 4 - (srcPitch % 4) : 0;
|
||||||
|
|
||||||
if (_info.bitsPerPixel == 8) {
|
if (_info.bitsPerPixel == 8) {
|
||||||
surface->create(_info.width, _info.height, 1);
|
|
||||||
byte *dst = (byte *)surface->pixels;
|
byte *dst = (byte *)surface->pixels;
|
||||||
|
|
||||||
for (uint32 i = 0; i < _info.height; i++) {
|
for (uint32 i = 0; i < _info.height; i++) {
|
||||||
@ -641,7 +662,6 @@ ImageData* MystBitmap::decodeImage(Common::SeekableReadStream* stream) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
|
Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
|
||||||
surface->create(_info.width, _info.height, pixelFormat.bytesPerPixel);
|
|
||||||
|
|
||||||
byte *dst = (byte *)surface->pixels + (surface->h - 1) * surface->pitch;
|
byte *dst = (byte *)surface->pixels + (surface->h - 1) * surface->pitch;
|
||||||
|
|
||||||
@ -706,8 +726,7 @@ ImageData *OldMohawkBitmap::decodeImage(Common::SeekableReadStream *stream) {
|
|||||||
if (endianStream->pos() != endianStream->size())
|
if (endianStream->pos() != endianStream->size())
|
||||||
error("OldMohawkBitmap decompression failed");
|
error("OldMohawkBitmap decompression failed");
|
||||||
|
|
||||||
Graphics::Surface *surface = new Graphics::Surface();
|
Graphics::Surface *surface = createSurface(_header.width, _header.height);
|
||||||
surface->create(_header.width, _header.height, 1);
|
|
||||||
|
|
||||||
if ((_header.format & 0xf00) == kOldDrawRLE8)
|
if ((_header.format & 0xf00) == kOldDrawRLE8)
|
||||||
drawRLE8(surface);
|
drawRLE8(surface);
|
||||||
|
@ -88,7 +88,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
BitmapHeader _header;
|
BitmapHeader _header;
|
||||||
byte getBitsPerPixel();
|
virtual byte getBitsPerPixel();
|
||||||
|
|
||||||
// The actual LZ decoder
|
// The actual LZ decoder
|
||||||
static Common::SeekableReadStream *decompressLZ(Common::SeekableReadStream *stream, uint32 uncompressedSize);
|
static Common::SeekableReadStream *decompressLZ(Common::SeekableReadStream *stream, uint32 uncompressedSize);
|
||||||
@ -96,6 +96,9 @@ protected:
|
|||||||
// The current data stream
|
// The current data stream
|
||||||
Common::SeekableReadStream *_data;
|
Common::SeekableReadStream *_data;
|
||||||
|
|
||||||
|
// Create the output surface
|
||||||
|
Graphics::Surface *createSurface(uint16 width, uint16 height);
|
||||||
|
|
||||||
// Draw Functions
|
// Draw Functions
|
||||||
void drawRaw(Graphics::Surface *surface);
|
void drawRaw(Graphics::Surface *surface);
|
||||||
void drawRLE8(Graphics::Surface *surface);
|
void drawRLE8(Graphics::Surface *surface);
|
||||||
@ -146,6 +149,9 @@ public:
|
|||||||
|
|
||||||
ImageData *decodeImage(Common::SeekableReadStream *stream);
|
ImageData *decodeImage(Common::SeekableReadStream *stream);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
byte getBitsPerPixel() { return _info.bitsPerPixel; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct BitmapHeader {
|
struct BitmapHeader {
|
||||||
uint16 type;
|
uint16 type;
|
||||||
@ -176,6 +182,9 @@ public:
|
|||||||
~OldMohawkBitmap() {}
|
~OldMohawkBitmap() {}
|
||||||
|
|
||||||
ImageData *decodeImage(Common::SeekableReadStream *stream);
|
ImageData *decodeImage(Common::SeekableReadStream *stream);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
byte getBitsPerPixel() { return 8; }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace Mohawk
|
} // End of namespace Mohawk
|
||||||
|
Loading…
x
Reference in New Issue
Block a user