[Scummvm-cvs-logs] scummvm master -> a7e73e5785783fa0417a401a51d8cf809e4add11

m-kiewitz m_kiewitz at users.sourceforge.net
Sun Jun 14 11:49:20 CEST 2015


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
a7e73e5785 SHERLOCK: improve image palette detection


Commit: a7e73e5785783fa0417a401a51d8cf809e4add11
    https://github.com/scummvm/scummvm/commit/a7e73e5785783fa0417a401a51d8cf809e4add11
Author: Martin Kiewitz (m_kiewitz at users.sourceforge.net)
Date: 2015-06-14T11:49:32+02:00

Commit Message:
SHERLOCK: improve image palette detection

fixes German+Spanish menu bars. The first menu bar of those versions
is the exact same size as a palette.

Changed paths:
    engines/sherlock/image_file.cpp



diff --git a/engines/sherlock/image_file.cpp b/engines/sherlock/image_file.cpp
index 512018b..f071ea8 100644
--- a/engines/sherlock/image_file.cpp
+++ b/engines/sherlock/image_file.cpp
@@ -104,20 +104,33 @@ void ImageFile::load(Common::SeekableReadStream &stream, bool skipPalette, bool
 
 void ImageFile::loadPalette(Common::SeekableReadStream &stream) {
 	// Check for palette
-	int v1 = stream.readUint16LE() + 1;
-	int v2 = stream.readUint16LE() + 1;
-	stream.skip(1);		// Skip paletteBase byte
-	bool rleEncoded = stream.readByte() == 1;
-	int palSize = v1 * v2;
-
-	if ((palSize - 12) == PALETTE_SIZE && !rleEncoded) {
+	uint16 width        = stream.readUint16LE() + 1;
+	uint16 height       = stream.readUint16LE() + 1;
+	byte   paletteBase  = stream.readByte();
+	byte   rleEncoded   = stream.readByte();
+	byte   offsetX      = stream.readByte();
+	byte   offsetY      = stream.readByte();
+	uint32 palSignature = 0;
+
+	if ((width == 390) && (height == 2) && (!paletteBase) && (!rleEncoded) && (!offsetX) && (!offsetY)) {
+		// We check for these specific values
+		// We can't do "width * height", because at least the first German+Spanish menu bar is 60 x 13
+		// which is 780, which is the size of the palette. We obviously don't want to detect it as palette.
+
+		// As another security measure, we also check for the signature text
+		palSignature = stream.readUint32BE();
+		if (palSignature != MKTAG('V', 'G', 'A', ' ')) {
+			// signature mismatch, rewind
+			stream.seek(-12, SEEK_CUR);
+			return;
+		}
 		// Found palette, so read it in
-		stream.seek(2 + 12, SEEK_CUR);
+		stream.seek(8, SEEK_CUR); // Skip over the rest of the signature text "VGA palette"
 		for (int idx = 0; idx < PALETTE_SIZE; ++idx)
 			_palette[idx] = VGA_COLOR_TRANS(stream.readByte());
 	} else {
 		// Not a palette, so rewind to start of frame data for normal frame processing
-		stream.seek(-6, SEEK_CUR);
+		stream.seek(-8, SEEK_CUR);
 	}
 }
 






More information about the Scummvm-git-logs mailing list