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

sev- sev at scummvm.org
Wed May 18 02:23:35 CEST 2016


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:
c18945e991 GRAPHICS: Add support for 4bpp BMPs


Commit: c18945e9918d10a8a9a6f403a64f9fdad2d5cc4a
    https://github.com/scummvm/scummvm/commit/c18945e9918d10a8a9a6f403a64f9fdad2d5cc4a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-05-18T02:23:11+02:00

Commit Message:
GRAPHICS: Add support for 4bpp BMPs

Changed paths:
    image/codecs/bmp_raw.cpp



diff --git a/image/codecs/bmp_raw.cpp b/image/codecs/bmp_raw.cpp
index 83aedc8..b47d5a1 100644
--- a/image/codecs/bmp_raw.cpp
+++ b/image/codecs/bmp_raw.cpp
@@ -48,7 +48,24 @@ const Graphics::Surface *BitmapRawDecoder::decodeFrame(Common::SeekableReadStrea
 	int srcPitch = _width * (_bitsPerPixel >> 3);
 	const int extraDataLength = (srcPitch % 4) ? 4 - (srcPitch % 4) : 0;
 
-	if (_bitsPerPixel == 8) {
+	if (_bitsPerPixel == 4) {
+		for (int i = 0; i < _height; i++) {
+			byte *dst = (byte *)_surface->getBasePtr(0, _height - i - 1);
+			for (int j = 0; j < _width; j++) {
+				byte color = stream.readByte();
+
+				*dst++ = (color & 0xf0) >> 4;
+				j++;
+
+				if (j ==_width)
+					break;
+
+				*dst++ = color & 0x0f;
+			}
+
+			stream.skip(extraDataLength);
+		}
+	} else if (_bitsPerPixel == 8) {
 		byte *dst = (byte *)_surface->getPixels();
 
 		for (int i = 0; i < _height; i++) {
@@ -100,6 +117,7 @@ const Graphics::Surface *BitmapRawDecoder::decodeFrame(Common::SeekableReadStrea
 
 Graphics::PixelFormat BitmapRawDecoder::getPixelFormat() const {
 	switch (_bitsPerPixel) {
+	case 4:
 	case 8:
 		return Graphics::PixelFormat::createFormatCLUT8();
 	case 24:






More information about the Scummvm-git-logs mailing list