[Scummvm-git-logs] scummvm master -> 84a17ad9aea0c5cb438d529f2aa21108f9787fda
lephilousophe
noreply at scummvm.org
Sun Jan 23 20:38:36 UTC 2022
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:
84a17ad9ae IMAGE: Added support for 16 bit bitmap images, and check for RGB555
Commit: 84a17ad9aea0c5cb438d529f2aa21108f9787fda
https://github.com/scummvm/scummvm/commit/84a17ad9aea0c5cb438d529f2aa21108f9787fda
Author: kevinlaurier (kevinlaurier at gmail.com)
Date: 2022-01-23T21:38:33+01:00
Commit Message:
IMAGE: Added support for 16 bit bitmap images, and check for RGB555
format
Changed paths:
image/bmp.cpp
image/codecs/bmp_raw.cpp
diff --git a/image/bmp.cpp b/image/bmp.cpp
index 55bbae0bd03..113bb63bf86 100644
--- a/image/bmp.cpp
+++ b/image/bmp.cpp
@@ -96,12 +96,18 @@ bool BitmapDecoder::loadStream(Common::SeekableReadStream &stream) {
/* uint16 planes = */ stream.readUint16LE();
uint16 bitsPerPixel = stream.readUint16LE();
- if (bitsPerPixel != 4 && bitsPerPixel != 8 && bitsPerPixel != 24 && bitsPerPixel != 32) {
+ if (bitsPerPixel != 4 && bitsPerPixel != 8 && bitsPerPixel != 16 && bitsPerPixel != 24 && bitsPerPixel != 32) {
warning("%dbpp bitmaps not supported", bitsPerPixel);
return false;
}
uint32 compression = stream.readUint32BE();
+
+ if (bitsPerPixel == 16 && compression != SWAP_CONSTANT_32(0)) {
+ warning("only RGB555 raw mode supported for %dbpp bitmaps", bitsPerPixel);
+ return false;
+ }
+
uint32 imageSize = stream.readUint32LE();
/* uint32 pixelsPerMeterX = */ stream.readUint32LE();
/* uint32 pixelsPerMeterY = */ stream.readUint32LE();
diff --git a/image/codecs/bmp_raw.cpp b/image/codecs/bmp_raw.cpp
index c347f18a2d5..f39644eff51 100644
--- a/image/codecs/bmp_raw.cpp
+++ b/image/codecs/bmp_raw.cpp
@@ -91,6 +91,20 @@ const Graphics::Surface *BitmapRawDecoder::decodeFrame(Common::SeekableReadStrea
stream.read(dst + (_flip ? i : _height - i - 1) * _width, _width);
stream.skip(extraDataLength);
}
+ } else if (_bitsPerPixel == 16) {
+ byte *dst = (byte *)_surface.getBasePtr(0, _height - 1);
+
+ for (int i = 0; i < _height; i++) {
+ for (int j = 0; j < _width; j++) {
+ uint16 color = stream.readUint16LE();
+
+ *(uint16 *)dst = color;
+ dst += format.bytesPerPixel;
+ }
+
+ stream.skip(extraDataLength);
+ dst -= _surface.pitch * 2;
+ }
} else if (_bitsPerPixel == 24) {
byte *dst = (byte *)_surface.getBasePtr(0, _height - 1);
@@ -144,6 +158,8 @@ Graphics::PixelFormat BitmapRawDecoder::getPixelFormat() const {
case 4:
case 8:
return Graphics::PixelFormat::createFormatCLUT8();
+ case 16:
+ return Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
case 24:
case 32:
return Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0);
More information about the Scummvm-git-logs
mailing list