[Scummvm-git-logs] scummvm master -> b458cedca493bcfdfba81bb66554251245489762
sev-
noreply at scummvm.org
Sun May 14 20:53:37 UTC 2023
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:
b458cedca4 IMAGE: Speed up 16/24/32bpp BMP decoding
Commit: b458cedca493bcfdfba81bb66554251245489762
https://github.com/scummvm/scummvm/commit/b458cedca493bcfdfba81bb66554251245489762
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-05-14T22:53:33+02:00
Commit Message:
IMAGE: Speed up 16/24/32bpp BMP decoding
Changed paths:
image/codecs/bmp_raw.cpp
diff --git a/image/codecs/bmp_raw.cpp b/image/codecs/bmp_raw.cpp
index f39644eff51..9f4cdeb7195 100644
--- a/image/codecs/bmp_raw.cpp
+++ b/image/codecs/bmp_raw.cpp
@@ -91,6 +91,7 @@ const Graphics::Surface *BitmapRawDecoder::decodeFrame(Common::SeekableReadStrea
stream.read(dst + (_flip ? i : _height - i - 1) * _width, _width);
stream.skip(extraDataLength);
}
+#ifndef SCUMM_LITTLE_ENDIAN
} else if (_bitsPerPixel == 16) {
byte *dst = (byte *)_surface.getBasePtr(0, _height - 1);
@@ -105,47 +106,15 @@ const Graphics::Surface *BitmapRawDecoder::decodeFrame(Common::SeekableReadStrea
stream.skip(extraDataLength);
dst -= _surface.pitch * 2;
}
- } else if (_bitsPerPixel == 24) {
+#endif
+ } else {
byte *dst = (byte *)_surface.getBasePtr(0, _height - 1);
+ uint bpp = format.bytesPerPixel;
for (int i = 0; i < _height; i++) {
- for (int j = 0; j < _width; j++) {
- byte b = stream.readByte();
- byte g = stream.readByte();
- byte r = stream.readByte();
- uint32 color = format.RGBToColor(r, g, b);
-
- *((uint32 *)dst) = color;
- dst += format.bytesPerPixel;
- }
-
- stream.skip(extraDataLength);
- dst -= _surface.pitch * 2;
- }
- } else { // 32 bpp
- byte *dst = (byte *)_surface.getBasePtr(0, _height - 1);
-
- for (int i = 0; i < _height; i++) {
- for (int j = 0; j < _width; j++) {
- byte b = stream.readByte();
- byte g = stream.readByte();
- byte r = stream.readByte();
-
- uint32 color;
- if (_ignoreAlpha) {
- stream.readByte();
- color = format.RGBToColor(r, g, b);
- } else {
- byte a = stream.readByte();
- color = format.ARGBToColor(a, r, g, b);
- }
-
- *((uint32 *)dst) = color;
- dst += format.bytesPerPixel;
- }
-
+ stream.read(dst, _width * bpp);
stream.skip(extraDataLength);
- dst -= _surface.pitch * 2;
+ dst -= _surface.pitch;
}
}
@@ -160,9 +129,17 @@ Graphics::PixelFormat BitmapRawDecoder::getPixelFormat() const {
return Graphics::PixelFormat::createFormatCLUT8();
case 16:
return Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
+#ifdef SCUMM_LITTLE_ENDIAN
+ case 24:
+ return Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0);
+ case 32:
+ return Graphics::PixelFormat(4, 8, 8, 8, _ignoreAlpha ? 0 : 8, 16, 8, 0, 24);
+#else
case 24:
+ return Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 8, 16, 0);
case 32:
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0);
+ return Graphics::PixelFormat(4, 8, 8, 8, _ignoreAlpha ? 0 : 8, 8, 16, 24, 0);
+#endif
default:
break;
}
More information about the Scummvm-git-logs
mailing list