aboutsummaryrefslogtreecommitdiff
path: root/graphics/decoders/png.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/decoders/png.cpp')
-rw-r--r--graphics/decoders/png.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/graphics/decoders/png.cpp b/graphics/decoders/png.cpp
index 505475213f..c4fee46fec 100644
--- a/graphics/decoders/png.cpp
+++ b/graphics/decoders/png.cpp
@@ -38,7 +38,7 @@
namespace Graphics {
-PNGDecoder::PNGDecoder() : _outputSurface(0), _palette(0), _paletteColorCount(0) {
+PNGDecoder::PNGDecoder() : _outputSurface(0), _palette(0), _paletteColorCount(0), _stream(0) {
}
PNGDecoder::~PNGDecoder() {
@@ -163,7 +163,13 @@ bool PNGDecoder::loadStream(Common::SeekableReadStream &stream) {
_outputSurface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
png_set_packing(pngPtr);
} else {
- _outputSurface->create(width, height, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
+ 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, Graphics::PixelFormat(4,
+ 8, 8, 8, isAlpha ? 8 : 0, 24, 16, 8, 0));
if (!_outputSurface->getPixels()) {
error("Could not allocate memory for output image.");
}
@@ -171,8 +177,6 @@ bool PNGDecoder::loadStream(Common::SeekableReadStream &stream) {
png_set_strip_16(pngPtr);
if (bitDepth < 8)
png_set_expand(pngPtr);
- if (png_get_valid(pngPtr, infoPtr, PNG_INFO_tRNS))
- png_set_expand(pngPtr);
if (colorType == PNG_COLOR_TYPE_GRAY ||
colorType == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(pngPtr);