aboutsummaryrefslogtreecommitdiff
path: root/graphics/decoders
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-08-13 00:30:02 +0200
committerEinar Johan Trøan Sømåen2012-08-13 02:31:34 +0200
commit8982026661c5f64f67cb8565946d25f620dfb73c (patch)
tree23e56e80cf9205a66520e2359d77e6009821937e /graphics/decoders
parentc839fd50b5ddfcceada8cbbd3046ce219df248a0 (diff)
downloadscummvm-rg350-8982026661c5f64f67cb8565946d25f620dfb73c.tar.gz
scummvm-rg350-8982026661c5f64f67cb8565946d25f620dfb73c.tar.bz2
scummvm-rg350-8982026661c5f64f67cb8565946d25f620dfb73c.zip
GRAPHICS: Add support for 32bpp BMPs
Diffstat (limited to 'graphics/decoders')
-rw-r--r--graphics/decoders/bmp.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/graphics/decoders/bmp.cpp b/graphics/decoders/bmp.cpp
index 5f764e1bd3..f15d4e2519 100644
--- a/graphics/decoders/bmp.cpp
+++ b/graphics/decoders/bmp.cpp
@@ -82,7 +82,7 @@ bool BitmapDecoder::loadStream(Common::SeekableReadStream &stream) {
/* uint16 planes = */ stream.readUint16LE();
uint16 bitsPerPixel = stream.readUint16LE();
- if (bitsPerPixel != 8 && bitsPerPixel != 24) {
+ if (bitsPerPixel != 8 && bitsPerPixel != 24 && bitsPerPixel != 32) {
warning("%dbpp bitmaps not supported", bitsPerPixel);
return false;
}
@@ -119,8 +119,8 @@ bool BitmapDecoder::loadStream(Common::SeekableReadStream &stream) {
Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8();
- // BGRA for 24bpp
- if (bitsPerPixel == 24)
+ // BGRA for 24bpp and 32 bpp
+ if (bitsPerPixel == 24 || bitsPerPixel == 32)
format = Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0);
_surface = new Graphics::Surface();
@@ -136,7 +136,7 @@ bool BitmapDecoder::loadStream(Common::SeekableReadStream &stream) {
stream.read(dst + (height - i - 1) * width, width);
stream.skip(extraDataLength);
}
- } else {
+ } else if (bitsPerPixel == 24) {
byte *dst = (byte *)_surface->pixels + (height - 1) * _surface->pitch;
for (int32 i = 0; i < height; i++) {
@@ -153,6 +153,27 @@ bool BitmapDecoder::loadStream(Common::SeekableReadStream &stream) {
stream.skip(extraDataLength);
dst -= _surface->pitch * 2;
}
+ } else { // 32 bpp
+ byte *dst = (byte *)_surface->pixels + (height - 1) * _surface->pitch;
+
+ for (int32 i = 0; i < height; i++) {
+ for (uint32 j = 0; j < width; j++) {
+ byte b = stream.readByte();
+ byte g = stream.readByte();
+ byte r = stream.readByte();
+ // Ignore the last byte, as in v3 it is unused
+ // and should thus NOT be used as alpha.
+ // ref: http://msdn.microsoft.com/en-us/library/windows/desktop/dd183376%28v=vs.85%29.aspx
+ stream.readByte();
+ uint32 color = format.RGBToColor(r, g, b);
+
+ *((uint32 *)dst) = color;
+ dst += format.bytesPerPixel;
+ }
+
+ stream.skip(extraDataLength);
+ dst -= _surface->pitch * 2;
+ }
}
return true;