[Scummvm-cvs-logs] SF.net SVN: scummvm:[54345] scummvm/trunk/engines/mohawk
mthreepwood at users.sourceforge.net
mthreepwood at users.sourceforge.net
Thu Nov 18 21:40:48 CET 2010
Revision: 54345
http://scummvm.svn.sourceforge.net/scummvm/?rev=54345&view=rev
Author: mthreepwood
Date: 2010-11-18 20:40:48 +0000 (Thu, 18 Nov 2010)
Log Message:
-----------
MOHAWK: Add support for Riven 24bpp images (not yet used)
Modified Paths:
--------------
scummvm/trunk/engines/mohawk/bitmap.cpp
scummvm/trunk/engines/mohawk/bitmap.h
Modified: scummvm/trunk/engines/mohawk/bitmap.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/bitmap.cpp 2010-11-18 20:27:15 UTC (rev 54344)
+++ scummvm/trunk/engines/mohawk/bitmap.cpp 2010-11-18 20:40:48 UTC (rev 54345)
@@ -70,7 +70,7 @@
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());
// Read in the palette if it's here.
@@ -88,8 +88,7 @@
}
}
- Graphics::Surface *surface = new Graphics::Surface();
- surface->create(_header.width, _header.height, getBitsPerPixel() >> 3);
+ Graphics::Surface *surface = createSurface(_header.width, _header.height);
unpackImage();
drawImage(surface);
@@ -98,6 +97,13 @@
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() {
switch (_header.format & kBitsPerPixelMask) {
case kBitsPerPixel1:
@@ -111,7 +117,7 @@
case kBitsPerPixel24:
return 24;
default:
- error ("Unknown bits per pixel");
+ error("Unknown bits per pixel");
}
return 0;
@@ -132,7 +138,7 @@
return;
}
- warning("Unknown Pack Compression");
+ error("Unknown Pack Compression");
}
const char *MohawkBitmap::getDrawName() {
@@ -150,7 +156,7 @@
return;
}
- warning("Unknown Draw Compression");
+ error("Unknown Draw Compression");
}
//////////////////////////////////////////
@@ -520,8 +526,24 @@
assert(surface);
for (uint16 y = 0; y < _header.height; y++) {
- _data->read((byte *)surface->pixels + y * _header.width, _header.width);
- _data->skip(_header.bytesPerRow - _header.width);
+ if (getBitsPerPixel() == 24) {
+ 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 @@
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);
const int extraDataLength = (srcPitch % 4) ? 4 - (srcPitch % 4) : 0;
if (_info.bitsPerPixel == 8) {
- surface->create(_info.width, _info.height, 1);
byte *dst = (byte *)surface->pixels;
for (uint32 i = 0; i < _info.height; i++) {
@@ -641,7 +662,6 @@
}
} else {
Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
- surface->create(_info.width, _info.height, pixelFormat.bytesPerPixel);
byte *dst = (byte *)surface->pixels + (surface->h - 1) * surface->pitch;
@@ -706,8 +726,7 @@
if (endianStream->pos() != endianStream->size())
error("OldMohawkBitmap decompression failed");
- Graphics::Surface *surface = new Graphics::Surface();
- surface->create(_header.width, _header.height, 1);
+ Graphics::Surface *surface = createSurface(_header.width, _header.height);
if ((_header.format & 0xf00) == kOldDrawRLE8)
drawRLE8(surface);
Modified: scummvm/trunk/engines/mohawk/bitmap.h
===================================================================
--- scummvm/trunk/engines/mohawk/bitmap.h 2010-11-18 20:27:15 UTC (rev 54344)
+++ scummvm/trunk/engines/mohawk/bitmap.h 2010-11-18 20:40:48 UTC (rev 54345)
@@ -88,7 +88,7 @@
protected:
BitmapHeader _header;
- byte getBitsPerPixel();
+ virtual byte getBitsPerPixel();
// The actual LZ decoder
static Common::SeekableReadStream *decompressLZ(Common::SeekableReadStream *stream, uint32 uncompressedSize);
@@ -96,6 +96,9 @@
// The current data stream
Common::SeekableReadStream *_data;
+ // Create the output surface
+ Graphics::Surface *createSurface(uint16 width, uint16 height);
+
// Draw Functions
void drawRaw(Graphics::Surface *surface);
void drawRLE8(Graphics::Surface *surface);
@@ -146,6 +149,9 @@
ImageData *decodeImage(Common::SeekableReadStream *stream);
+protected:
+ byte getBitsPerPixel() { return _info.bitsPerPixel; }
+
private:
struct BitmapHeader {
uint16 type;
@@ -176,6 +182,9 @@
~OldMohawkBitmap() {}
ImageData *decodeImage(Common::SeekableReadStream *stream);
+
+protected:
+ byte getBitsPerPixel() { return 8; }
};
} // End of namespace Mohawk
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list