[Scummvm-git-logs] scummvm master -> c1dc522b35b9bb257e08df31668fd4f173f15d1c

ysj1173886760 42030331+ysj1173886760 at users.noreply.github.com
Sun Aug 8 09:27:03 UTC 2021


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

Summary:
1325c02252 DIRECTOR: store the original size for stretched sprite
db01ec1dbd DIRECTOR: fix 32-bit BITD decoding
dba8b245d4 DIRECTOR: fix 16-bit BITD decoding.
c1dc522b35 DIRECTOR: clean the code and add the comment.


Commit: 1325c022523b0369c340d1e6ee94ea746cfb4aa0
    https://github.com/scummvm/scummvm/commit/1325c022523b0369c340d1e6ee94ea746cfb4aa0
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-08-08T17:18:59+08:00

Commit Message:
DIRECTOR: store the original size for stretched sprite

Changed paths:
    engines/director/sprite.cpp


diff --git a/engines/director/sprite.cpp b/engines/director/sprite.cpp
index 7c0bd1aec9..4289740f6e 100644
--- a/engines/director/sprite.cpp
+++ b/engines/director/sprite.cpp
@@ -302,7 +302,11 @@ void Sprite::setCast(CastMemberID memberID) {
 		Common::Rect dims = _cast->getInitialRect();
 		// strange logic here, need to be fixed
 		if (_cast->_type == kCastBitmap) {
-			if (!(_inkData & 0x80)) {
+			// for the stretched sprites, we need the original size to get the correct bbox offset.
+			// there are two stretch situation here.
+			// 1. stretch happened when creating the widget, there is no lingo participated. we will use the original sprite size to create widget. check copyStretchImg
+			// 2. stretch set by lingo. this time we need to store the original dims because we will create the original sprite and stretch it when bliting. check inkBlitStretchSurface
+			if (!(_inkData & 0x80) || _stretch) {
 				_width = dims.width();
 				_height = dims.height();
 			}


Commit: db01ec1dbdbd8bcef7159a79f4b8c2054f7fd191
    https://github.com/scummvm/scummvm/commit/db01ec1dbdbd8bcef7159a79f4b8c2054f7fd191
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-08-08T17:18:59+08:00

Commit Message:
DIRECTOR: fix 32-bit BITD decoding

Changed paths:
    engines/director/images.cpp


diff --git a/engines/director/images.cpp b/engines/director/images.cpp
index 448aca9720..00071b6a3e 100644
--- a/engines/director/images.cpp
+++ b/engines/director/images.cpp
@@ -180,7 +180,7 @@ void BITDDecoder::convertPixelIntoSurface(void* surfacePointer, uint fromBpp, ui
 bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
 	int x = 0, y = 0;
 
-	Common::Array<int> pixels;
+	Common::Array<uint> pixels;
 	// If the stream has exactly the required number of bits for this image,
 	// we assume it is uncompressed.
 	// logic above does not fit the situation when _bitsPerPixel == 1, need to fix.
@@ -193,23 +193,18 @@ bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
 		while (!stream.eos()) {
 			// TODO: D3 32-bit bitmap casts seem to just be ARGB pixels in a row and not RLE.
 			// Determine how to distinguish these different types. Maybe stage version.
-			if (_bitsPerPixel == 32) {
-				int data = stream.readByte();
-				pixels.push_back(data);
+			int data = stream.readByte();
+			int len = data + 1;
+			if ((data & 0x80) != 0) {
+				len = ((data ^ 0xFF) & 0xff) + 2;
+				data = stream.readByte();
+				for (int p = 0; p < len; p++) {
+					pixels.push_back(data);
+				}
 			} else {
-				int data = stream.readByte();
-				int len = data + 1;
-				if ((data & 0x80) != 0) {
-					len = ((data ^ 0xFF) & 0xff) + 2;
+				for (int p = 0; p < len; p++) {
 					data = stream.readByte();
-					for (int p = 0; p < len; p++) {
-						pixels.push_back(data);
-					}
-				} else {
-					for (int p = 0; p < len; p++) {
-						data = stream.readByte();
-						pixels.push_back(data);
-					}
+					pixels.push_back(data);
 				}
 			}
 		}
@@ -274,9 +269,9 @@ bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
 					convertPixelIntoSurface(_surface->getBasePtr(x, y),
 						(_bitsPerPixel / 8),
 						_surface->format.bytesPerPixel,
-						pixels[(((y * (_surface->w * 4))) + ((x * 4) + 1))],
-						pixels[(((y * (_surface->w * 4))) + ((x * 4) + 2))],
-						pixels[(((y * (_surface->w * 4))) + ((x * 4) + 3))]);
+						pixels[(((y * _surface->w * 4)) + (x + _surface->w))],
+						pixels[(((y * _surface->w * 4)) + (x + 2 * _surface->w))],
+						pixels[(((y * _surface->w * 4)) + (x + 3 * _surface->w))]);
 					x++;
 					break;
 


Commit: dba8b245d454cb11baa2035d3a1308b755a5b653
    https://github.com/scummvm/scummvm/commit/dba8b245d454cb11baa2035d3a1308b755a5b653
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-08-08T17:19:00+08:00

Commit Message:
DIRECTOR: fix 16-bit BITD decoding.

Changed paths:
    engines/director/images.cpp


diff --git a/engines/director/images.cpp b/engines/director/images.cpp
index 00071b6a3e..cfc2a88739 100644
--- a/engines/director/images.cpp
+++ b/engines/director/images.cpp
@@ -170,6 +170,18 @@ void BITDDecoder::convertPixelIntoSurface(void* surfacePointer, uint fromBpp, ui
 		}
 		break;
 
+	case 2:
+		switch (toBpp) {
+		case 1:
+			*((byte*)surfacePointer) = g_director->_wm->findBestColor(red, blue, green);
+			break;
+
+		default:
+			warning("BITDDecoder::convertPixelIntoSurface(): conversion from %d to %d not implemented",
+					fromBpp, toBpp);
+		}
+		break;
+
 	default:
 		warning("BITDDecoder::convertPixelIntoSurface(): could not convert from %d to %d",
 			fromBpp, toBpp);
@@ -184,6 +196,7 @@ bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
 	// If the stream has exactly the required number of bits for this image,
 	// we assume it is uncompressed.
 	// logic above does not fit the situation when _bitsPerPixel == 1, need to fix.
+	debug("%d", _bitsPerPixel);
 	if ((stream.size() == _pitch * _surface->h * _bitsPerPixel / 8) || (_bitsPerPixel != 1 && _version < kFileVer400 && stream.size() >= _surface->h * _surface->w * _bitsPerPixel / 8)) {
 		debugC(6, kDebugImages, "Skipping compression");
 		for (int i = 0; i < stream.size(); i++) {
@@ -210,6 +223,7 @@ bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
 		}
 	}
 
+	debug("%d %d %d", pixels.size(), _surface->w, _surface->h);
 	if (pixels.size() < (uint32)_surface->w * _surface->h * (_bitsPerPixel / 8)) {
 		int tail = (_surface->w * _surface->h * _bitsPerPixel / 8) - pixels.size();
 
@@ -221,7 +235,7 @@ bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
 	}
 
 	int offset = 0;
-	if (_surface->w < (int)(pixels.size() / _surface->h))
+	if (_bitsPerPixel == 8 && _surface->w < (int)(pixels.size() / _surface->h))
 		offset = (pixels.size() / _surface->h) - _surface->w;
 	// looks like the data want to round up to 2, so we either got offset 1 or 0.
 	// but we may met situation when the pixel size is exactly equals to w * h, thus we add a check here.
@@ -257,7 +271,14 @@ bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
 					break;
 
 				case 16:
-					*((uint16*)_surface->getBasePtr(x, y)) = _surface->format.RGBToColor(
+//					*((uint16*)_surface->getBasePtr(x, y)) = _surface->format.RGBToColor(
+//						(pixels[((y * _surface->w) * 2) + x] & 0x7c) << 1,
+//						(pixels[((y * _surface->w) * 2) + x] & 0x03) << 6 |
+//						(pixels[((y * _surface->w) * 2) + (_surface->w) + x] & 0xe0) >> 2,
+//						(pixels[((y * _surface->w) * 2) + (_surface->w) + x] & 0x1f) << 3);
+					convertPixelIntoSurface(_surface->getBasePtr(x, y),
+						(_bitsPerPixel / 8),
+						_surface->format.bytesPerPixel,
 						(pixels[((y * _surface->w) * 2) + x] & 0x7c) << 1,
 						(pixels[((y * _surface->w) * 2) + x] & 0x03) << 6 |
 						(pixels[((y * _surface->w) * 2) + (_surface->w) + x] & 0xe0) >> 2,


Commit: c1dc522b35b9bb257e08df31668fd4f173f15d1c
    https://github.com/scummvm/scummvm/commit/c1dc522b35b9bb257e08df31668fd4f173f15d1c
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-08-08T17:26:31+08:00

Commit Message:
DIRECTOR: clean the code and add the comment.

Changed paths:
    engines/director/images.cpp


diff --git a/engines/director/images.cpp b/engines/director/images.cpp
index cfc2a88739..b299fb066c 100644
--- a/engines/director/images.cpp
+++ b/engines/director/images.cpp
@@ -149,6 +149,7 @@ void BITDDecoder::convertPixelIntoSurface(void* surfacePointer, uint fromBpp, ui
 	case 4:
 		switch (toBpp) {
 		case 1:
+			// maybe this parts should also calculated by wm->findBestColor
 			if (red == 255 && blue == 255 && green == 255) {
 				*((byte*)surfacePointer) = 255;
 			} else if (red == 0 && blue == 0 && green == 0) {
@@ -196,7 +197,6 @@ bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
 	// If the stream has exactly the required number of bits for this image,
 	// we assume it is uncompressed.
 	// logic above does not fit the situation when _bitsPerPixel == 1, need to fix.
-	debug("%d", _bitsPerPixel);
 	if ((stream.size() == _pitch * _surface->h * _bitsPerPixel / 8) || (_bitsPerPixel != 1 && _version < kFileVer400 && stream.size() >= _surface->h * _surface->w * _bitsPerPixel / 8)) {
 		debugC(6, kDebugImages, "Skipping compression");
 		for (int i = 0; i < stream.size(); i++) {
@@ -206,6 +206,8 @@ bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
 		while (!stream.eos()) {
 			// TODO: D3 32-bit bitmap casts seem to just be ARGB pixels in a row and not RLE.
 			// Determine how to distinguish these different types. Maybe stage version.
+			// for D4, 32-bit bitmap is RLE, and the encoding format is every line contains the a? r g b at the same line of the original image.
+			// i.e. for every line, we shall combine 4 parts to create the original image.
 			int data = stream.readByte();
 			int len = data + 1;
 			if ((data & 0x80) != 0) {
@@ -223,7 +225,6 @@ bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
 		}
 	}
 
-	debug("%d %d %d", pixels.size(), _surface->w, _surface->h);
 	if (pixels.size() < (uint32)_surface->w * _surface->h * (_bitsPerPixel / 8)) {
 		int tail = (_surface->w * _surface->h * _bitsPerPixel / 8) - pixels.size();
 
@@ -271,11 +272,6 @@ bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
 					break;
 
 				case 16:
-//					*((uint16*)_surface->getBasePtr(x, y)) = _surface->format.RGBToColor(
-//						(pixels[((y * _surface->w) * 2) + x] & 0x7c) << 1,
-//						(pixels[((y * _surface->w) * 2) + x] & 0x03) << 6 |
-//						(pixels[((y * _surface->w) * 2) + (_surface->w) + x] & 0xe0) >> 2,
-//						(pixels[((y * _surface->w) * 2) + (_surface->w) + x] & 0x1f) << 3);
 					convertPixelIntoSurface(_surface->getBasePtr(x, y),
 						(_bitsPerPixel / 8),
 						_surface->format.bytesPerPixel,




More information about the Scummvm-git-logs mailing list