[Scummvm-cvs-logs] scummvm master -> 882989f5c3a29cf560ca8cb27d09edde7fda5e7e

sev- sev at scummvm.org
Fri Nov 13 00:04:48 CET 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:
882989f5c3 SWORD25: Fix thumbnail generation and make it portable


Commit: 882989f5c3a29cf560ca8cb27d09edde7fda5e7e
    https://github.com/scummvm/scummvm/commit/882989f5c3a29cf560ca8cb27d09edde7fda5e7e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-11-13T00:03:42+01:00

Commit Message:
SWORD25: Fix thumbnail generation and make it portable

Changed paths:
    engines/sword25/gfx/screenshot.cpp



diff --git a/engines/sword25/gfx/screenshot.cpp b/engines/sword25/gfx/screenshot.cpp
index 4b4f967..eeaece9 100644
--- a/engines/sword25/gfx/screenshot.cpp
+++ b/engines/sword25/gfx/screenshot.cpp
@@ -40,7 +40,7 @@ namespace Sword25 {
 
 bool Screenshot::saveToFile(Graphics::Surface *data, Common::WriteStream *stream) {
 	// Convert the RGBA data to RGB
-	const byte *pSrc = (const byte *)data->getPixels();
+	const uint32 *pSrc = (const uint32 *)data->getPixels();
 
 	// Write our own custom header
 	stream->writeUint32BE(MKTAG('S','C','R','N'));	// SCRN, short for "Screenshot"
@@ -52,11 +52,12 @@ bool Screenshot::saveToFile(Graphics::Surface *data, Common::WriteStream *stream
 		for (uint x = 0; x < data->w; x++) {
 			// This is only called by createThumbnail below, which
 			// provides a fake 'surface' with LE data in it.
-			uint32 srcPixel = READ_LE_UINT32(pSrc);
-			pSrc += sizeof(uint32);
-			stream->writeByte((srcPixel >> 16) & 0xff); // R
-			stream->writeByte((srcPixel >> 8) & 0xff);  // G
-			stream->writeByte(srcPixel & 0xff);         // B
+			byte a, r, g, b;
+
+			data->format.colorToARGB(*pSrc++, a, r, g, b);
+			stream->writeByte(r);
+			stream->writeByte(g);
+			stream->writeByte(b);
 		}
 	}
 
@@ -81,30 +82,27 @@ Common::SeekableReadStream *Screenshot::createThumbnail(Graphics::Surface *data)
 	Graphics::Surface thumbnail;
 	thumbnail.create(200, 125, g_system->getScreenFormat());
 
-	// Über das Zielbild iterieren und einen Pixel zur Zeit berechnen.
+	// Uber das Zielbild iterieren und einen Pixel zur Zeit berechnen.
 	uint x, y;
 	x = y = 0;
 
-	for (byte *pDest = (byte *)thumbnail.getPixels(); pDest < ((byte *)thumbnail.getBasePtr(0, thumbnail.h)); ) {
+	for (uint32 *pDest = (uint32 *)thumbnail.getPixels(); pDest < thumbnail.getBasePtr(0, thumbnail.h); ) {
 		// Get an average over a 4x4 pixel block in the source image
 		int alpha, red, green, blue;
 		alpha = red = green = blue = 0;
 		for (int j = 0; j < 4; ++j) {
 			const uint32 *srcP = (const uint32 *)data->getBasePtr(x * 4, y * 4 + j + 50);
 			for (int i = 0; i < 4; ++i) {
-				uint32 pixel = READ_UINT32(srcP + i);
-				alpha += (pixel >> 24);
-				red += (pixel >> 16) & 0xff;
-				green += (pixel >> 8) & 0xff;
-				blue += pixel & 0xff;
+				byte a, r, g, b;
+				data->format.colorToARGB(*(srcP + i), a, r, g, b);
+				alpha += a;
+				red += r;
+				green += g;
+				blue += b;
 			}
 		}
 
-		// Write target pixel
-		*pDest++ = blue / 16;
-		*pDest++ = green / 16;
-		*pDest++ = red / 16;
-		*pDest++ = alpha / 16;
+		*pDest++ = thumbnail.format.ARGBToColor(alpha / 16, red / 16, green / 16, blue / 16);
 
 		// Move to next block
 		++x;






More information about the Scummvm-git-logs mailing list