[Scummvm-git-logs] scummvm master -> dd75517d61f93d6fcf31c7d83f5b2d89d3228756
sev-
sev at scummvm.org
Sun Jul 4 23:00:14 UTC 2021
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:
dd75517d61 IMAGE: Use 0-bit alpha for non-transparent PNGs
Commit: dd75517d61f93d6fcf31c7d83f5b2d89d3228756
https://github.com/scummvm/scummvm/commit/dd75517d61f93d6fcf31c7d83f5b2d89d3228756
Author: lb_ii (lolbot_iichan at mail.ru)
Date: 2021-07-05T01:00:11+02:00
Commit Message:
IMAGE: Use 0-bit alpha for non-transparent PNGs
Changed paths:
image/png.cpp
image/png.h
diff --git a/image/png.cpp b/image/png.cpp
index fc4134b2e6..b8ef5d3f96 100644
--- a/image/png.cpp
+++ b/image/png.cpp
@@ -63,11 +63,11 @@ void PNGDecoder::destroy() {
_palette = NULL;
}
-Graphics::PixelFormat PNGDecoder::getByteOrderRgbaPixelFormat() const {
+Graphics::PixelFormat PNGDecoder::getByteOrderRgbaPixelFormat(bool isAlpha) const {
#ifdef SCUMM_BIG_ENDIAN
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
+ return Graphics::PixelFormat(4, 8, 8, 8, isAlpha ? 8 : 0, 24, 16, 8, 0);
#else
- return Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
+ return Graphics::PixelFormat(4, 8, 8, 8, isAlpha ? 8 : 0, 0, 8, 16, 24);
#endif
}
@@ -201,7 +201,7 @@ bool PNGDecoder::loadStream(Common::SeekableReadStream &stream) {
}
_outputSurface->create(width, height,
- hasRgbaPalette ? getByteOrderRgbaPixelFormat() : Graphics::PixelFormat::createFormatCLUT8());
+ hasRgbaPalette ? getByteOrderRgbaPixelFormat(true) : Graphics::PixelFormat::createFormatCLUT8());
png_set_packing(pngPtr);
if (hasRgbaPalette) {
@@ -219,11 +219,13 @@ bool PNGDecoder::loadStream(Common::SeekableReadStream &stream) {
_palette = nullptr;
}
} else {
+ bool isAlpha = (colorType & PNG_COLOR_MASK_ALPHA);
if (png_get_valid(pngPtr, infoPtr, PNG_INFO_tRNS)) {
+ isAlpha = true;
png_set_expand(pngPtr);
}
- _outputSurface->create(width, height, getByteOrderRgbaPixelFormat());
+ _outputSurface->create(width, height, getByteOrderRgbaPixelFormat(isAlpha));
if (!_outputSurface->getPixels()) {
error("Could not allocate memory for output image.");
}
diff --git a/image/png.h b/image/png.h
index 59f0aa2dc6..f605758725 100644
--- a/image/png.h
+++ b/image/png.h
@@ -67,7 +67,7 @@ public:
void setSkipSignature(bool skip) { _skipSignature = skip; }
void setKeepTransparencyPaletted(bool keep) { _keepTransparencyPaletted = keep; }
private:
- Graphics::PixelFormat getByteOrderRgbaPixelFormat() const;
+ Graphics::PixelFormat getByteOrderRgbaPixelFormat(bool isAlpha) const;
byte *_palette;
uint16 _paletteColorCount;
More information about the Scummvm-git-logs
mailing list