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

sev- sev at scummvm.org
Sat Jun 4 00:17:05 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:
c76dfb031e IMAGE: Added support for 1bpp BMPs


Commit: c76dfb031e31ef68d59aa1a9c2cf418151a009eb
    https://github.com/scummvm/scummvm/commit/c76dfb031e31ef68d59aa1a9c2cf418151a009eb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-06-04T00:16:35+02:00

Commit Message:
IMAGE: Added support for 1bpp BMPs

Changed paths:
    image/codecs/bmp_raw.cpp



diff --git a/image/codecs/bmp_raw.cpp b/image/codecs/bmp_raw.cpp
index b47d5a1..f810678 100644
--- a/image/codecs/bmp_raw.cpp
+++ b/image/codecs/bmp_raw.cpp
@@ -46,9 +46,30 @@ const Graphics::Surface *BitmapRawDecoder::decodeFrame(Common::SeekableReadStrea
 	_surface->create(_width, _height, format);
 
 	int srcPitch = _width * (_bitsPerPixel >> 3);
-	const int extraDataLength = (srcPitch % 4) ? 4 - (srcPitch % 4) : 0;
+	int extraDataLength = (srcPitch % 4) ? 4 - (srcPitch % 4) : 0;
 
-	if (_bitsPerPixel == 4) {
+	if (_bitsPerPixel == 1) {
+		srcPitch = (_width + 7) / 8;
+		extraDataLength = (srcPitch % 2) ? 2 - (srcPitch % 4) : 0;
+	}
+
+	if (_bitsPerPixel == 1) {
+		for (int i = _height - 1; i >= 0; i--) {
+			byte *dst = (byte *)_surface->getBasePtr(0, i);
+			for (int j = 0; j != _width;) {
+				byte color = stream.readByte();
+				for (int k = 0; k < 8; k++) {
+					*dst++ = (color & 0x80) ? 0x01 : 0x00;
+					color <<= 1;
+					j++;
+					if (j == _width) {
+						break;
+					}
+				}
+			}
+			stream.skip(extraDataLength);
+		}
+	} else 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++) {
@@ -117,6 +138,7 @@ const Graphics::Surface *BitmapRawDecoder::decodeFrame(Common::SeekableReadStrea
 
 Graphics::PixelFormat BitmapRawDecoder::getPixelFormat() const {
 	switch (_bitsPerPixel) {
+	case 1:
 	case 4:
 	case 8:
 		return Graphics::PixelFormat::createFormatCLUT8();






More information about the Scummvm-git-logs mailing list