[Scummvm-git-logs] scummvm master -> 75b8735b576e5c0c116eb49a1d1ab60057ea1a8a
sev-
sev at scummvm.org
Mon Nov 1 14:26:51 UTC 2021
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
5d093e725f IMAGE: Extend raw decoder to support BMP with alpha channel
236be25624 IMAGE: Parse 4bpp BMP files
75b8735b57 IMAGE: Load BMPs with any v1-v5 header
Commit: 5d093e725fd6832280d0865abdb685e41bf3efda
https://github.com/scummvm/scummvm/commit/5d093e725fd6832280d0865abdb685e41bf3efda
Author: lb_ii (lolbot_iichan at mail.ru)
Date: 2021-11-01T16:25:43+02:00
Commit Message:
IMAGE: Extend raw decoder to support BMP with alpha channel
Changed paths:
image/codecs/bmp_raw.cpp
image/codecs/bmp_raw.h
image/codecs/codec.cpp
diff --git a/image/codecs/bmp_raw.cpp b/image/codecs/bmp_raw.cpp
index 7c769f7183..753daec888 100644
--- a/image/codecs/bmp_raw.cpp
+++ b/image/codecs/bmp_raw.cpp
@@ -28,8 +28,8 @@
namespace Image {
-BitmapRawDecoder::BitmapRawDecoder(int width, int height, int bitsPerPixel, bool flip) : Codec(),
- _width(width), _height(height), _bitsPerPixel(bitsPerPixel), _flip(flip) {
+BitmapRawDecoder::BitmapRawDecoder(int width, int height, int bitsPerPixel, bool flip, bool ignoreAlpha) : Codec(),
+ _width(width), _height(height), _bitsPerPixel(bitsPerPixel), _flip(flip), _ignoreAlpha(ignoreAlpha) {
_surface.create(_width, _height, getPixelFormat());
}
@@ -114,11 +114,15 @@ const Graphics::Surface *BitmapRawDecoder::decodeFrame(Common::SeekableReadStrea
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 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;
diff --git a/image/codecs/bmp_raw.h b/image/codecs/bmp_raw.h
index f4eb856b81..50273ddd21 100644
--- a/image/codecs/bmp_raw.h
+++ b/image/codecs/bmp_raw.h
@@ -34,7 +34,7 @@ namespace Image {
*/
class BitmapRawDecoder : public Codec {
public:
- BitmapRawDecoder(int width, int height, int bitsPerPixel, bool _flip = false);
+ BitmapRawDecoder(int width, int height, int bitsPerPixel, bool ignoreAlpha, bool _flip = false);
~BitmapRawDecoder();
const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream);
@@ -44,6 +44,7 @@ private:
Graphics::Surface _surface;
int _width, _height;
int _bitsPerPixel;
+ bool _ignoreAlpha;
// this flag indicates whether bitmapRawDecoder is created to decode QTvideo or raw images.
// because we need to flip the image when we are dealing with QTvideo
diff --git a/image/codecs/codec.cpp b/image/codecs/codec.cpp
index e083a2f3fb..47480c5a90 100644
--- a/image/codecs/codec.cpp
+++ b/image/codecs/codec.cpp
@@ -207,11 +207,14 @@ Codec *createBitmapCodec(uint32 tag, uint32 streamTag, int width, int height, in
switch (tag) {
case SWAP_CONSTANT_32(0):
- return new BitmapRawDecoder(width, height, bitsPerPixel);
+ return new BitmapRawDecoder(width, height, bitsPerPixel, true);
case SWAP_CONSTANT_32(1):
return new MSRLEDecoder(width, height, bitsPerPixel);
case SWAP_CONSTANT_32(2):
return new MSRLE4Decoder(width, height, bitsPerPixel);
+ case SWAP_CONSTANT_32(3):
+ // Used with v4-v5 BMP headers to produce transparent BMPs
+ return new BitmapRawDecoder(width, height, bitsPerPixel, false);
case MKTAG('C','R','A','M'):
case MKTAG('m','s','v','c'):
case MKTAG('W','H','A','M'):
@@ -278,7 +281,7 @@ Codec *createQuickTimeCodec(uint32 tag, int width, int height, int bitsPerPixel)
return new CDToonsDecoder(width, height);
case MKTAG('r','a','w',' '):
// Used my L-Zone-mac (Director game)
- return new BitmapRawDecoder(width, height, bitsPerPixel, true);
+ return new BitmapRawDecoder(width, height, bitsPerPixel, true, true);
default:
warning("Unsupported QuickTime codec \'%s\'", tag2str(tag));
}
Commit: 236be2562490eefe8aa8ea5bdcbca96ee022e817
https://github.com/scummvm/scummvm/commit/236be2562490eefe8aa8ea5bdcbca96ee022e817
Author: lb_ii (lolbot_iichan at mail.ru)
Date: 2021-11-01T16:26:19+02:00
Commit Message:
IMAGE: Parse 4bpp BMP files
Changed paths:
image/bmp.cpp
image/codecs/bmp_raw.cpp
diff --git a/image/bmp.cpp b/image/bmp.cpp
index 5b3e98159d..7b5b99e4f3 100644
--- a/image/bmp.cpp
+++ b/image/bmp.cpp
@@ -97,7 +97,7 @@ bool BitmapDecoder::loadStream(Common::SeekableReadStream &stream) {
/* uint16 planes = */ stream.readUint16LE();
uint16 bitsPerPixel = stream.readUint16LE();
- if (bitsPerPixel != 8 && bitsPerPixel != 24 && bitsPerPixel != 32) {
+ if (bitsPerPixel != 4 && bitsPerPixel != 8 && bitsPerPixel != 24 && bitsPerPixel != 32) {
warning("%dbpp bitmaps not supported", bitsPerPixel);
return false;
}
@@ -109,9 +109,9 @@ bool BitmapDecoder::loadStream(Common::SeekableReadStream &stream) {
_paletteColorCount = stream.readUint32LE();
/* uint32 colorsImportant = */ stream.readUint32LE();
- if (bitsPerPixel == 8) {
+ if (bitsPerPixel == 4 || bitsPerPixel == 8) {
if (_paletteColorCount == 0)
- _paletteColorCount = 256;
+ _paletteColorCount = bitsPerPixel == 8 ? 256 : 16;
// Read the palette
_palette = new byte[_paletteColorCount * 3];
diff --git a/image/codecs/bmp_raw.cpp b/image/codecs/bmp_raw.cpp
index 753daec888..d8943e15f6 100644
--- a/image/codecs/bmp_raw.cpp
+++ b/image/codecs/bmp_raw.cpp
@@ -46,6 +46,9 @@ const Graphics::Surface *BitmapRawDecoder::decodeFrame(Common::SeekableReadStrea
if (_bitsPerPixel == 1) {
srcPitch = (_width + 7) / 8;
extraDataLength = (srcPitch % 2) ? 2 - (srcPitch % 2) : 0;
+ } else if (_bitsPerPixel == 4) {
+ srcPitch = (_width + 1) / 2;
+ extraDataLength = (srcPitch % 4) ? 4 - (srcPitch % 4) : 0;
}
if (_bitsPerPixel == 1) {
Commit: 75b8735b576e5c0c116eb49a1d1ab60057ea1a8a
https://github.com/scummvm/scummvm/commit/75b8735b576e5c0c116eb49a1d1ab60057ea1a8a
Author: lb_ii (lolbot_iichan at mail.ru)
Date: 2021-11-01T16:26:23+02:00
Commit Message:
IMAGE: Load BMPs with any v1-v5 header
Changed paths:
image/bmp.cpp
diff --git a/image/bmp.cpp b/image/bmp.cpp
index 7b5b99e4f3..6313a154d3 100644
--- a/image/bmp.cpp
+++ b/image/bmp.cpp
@@ -78,8 +78,8 @@ bool BitmapDecoder::loadStream(Common::SeekableReadStream &stream) {
}
uint32 infoSize = stream.readUint32LE();
- if (infoSize != 40 && infoSize != 108) {
- warning("Only Windows v3 & v4 bitmaps are supported");
+ if (infoSize != 40 && infoSize != 52 && infoSize != 56 && infoSize != 108 && infoSize != 124) {
+ warning("Only Windows v1-v5 bitmaps are supported, unknown header: %d", infoSize);
return false;
}
@@ -109,6 +109,8 @@ bool BitmapDecoder::loadStream(Common::SeekableReadStream &stream) {
_paletteColorCount = stream.readUint32LE();
/* uint32 colorsImportant = */ stream.readUint32LE();
+ stream.seek(infoSize - 40, SEEK_CUR);
+
if (bitsPerPixel == 4 || bitsPerPixel == 8) {
if (_paletteColorCount == 0)
_paletteColorCount = bitsPerPixel == 8 ? 256 : 16;
More information about the Scummvm-git-logs
mailing list