[Scummvm-cvs-logs] SF.net SVN: scummvm:[54989] scummvm/trunk/engines/mohawk

fuzzie at users.sourceforge.net fuzzie at users.sourceforge.net
Tue Dec 21 19:16:38 CET 2010


Revision: 54989
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54989&view=rev
Author:   fuzzie
Date:     2010-12-21 18:16:37 +0000 (Tue, 21 Dec 2010)

Log Message:
-----------
MOHAWK: Support compound images (subimages)

These are images embedded in the bitmap data of another image; they
are used in CSTime and Zoombinis, at least. Thanks to clone2727 for
helping me puzzle this out.

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-12-21 18:16:20 UTC (rev 54988)
+++ scummvm/trunk/engines/mohawk/bitmap.cpp	2010-12-21 18:16:37 UTC (rev 54989)
@@ -59,7 +59,7 @@
 MohawkBitmap::~MohawkBitmap() {
 }
 
-MohawkSurface *MohawkBitmap::decodeImage(Common::SeekableReadStream *stream) {
+void MohawkBitmap::decodeImageData(Common::SeekableReadStream *stream) {
 	_data = stream;
 	_header.colorTable.palette = NULL;
 
@@ -90,15 +90,50 @@
 		}
 	}
 
+	unpackImage();
+}
+
+MohawkSurface *MohawkBitmap::decodeImage(Common::SeekableReadStream *stream) {
+	decodeImageData(stream);
+
 	Graphics::Surface *surface = createSurface(_header.width, _header.height);
-
-	unpackImage();
 	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;

Modified: scummvm/trunk/engines/mohawk/bitmap.h
===================================================================
--- scummvm/trunk/engines/mohawk/bitmap.h	2010-12-21 18:16:20 UTC (rev 54988)
+++ scummvm/trunk/engines/mohawk/bitmap.h	2010-12-21 18:16:37 UTC (rev 54989)
@@ -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 @@
 	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);
 


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