diff options
author | Paul Gilbert | 2013-11-30 20:44:23 -0500 |
---|---|---|
committer | Paul Gilbert | 2013-11-30 20:44:23 -0500 |
commit | ede418b67a0f14e4f17a2b03f5362741badd5532 (patch) | |
tree | 07de039fac5c303f1b9fce372afe5fa19854f547 /graphics/decoders/png.cpp | |
parent | 66d1f7a8de2ff5a21ad013f45924c406f4833e9a (diff) | |
parent | 3e859768770a0b385e21c4528cd546b33ed9a55d (diff) | |
download | scummvm-rg350-ede418b67a0f14e4f17a2b03f5362741badd5532.tar.gz scummvm-rg350-ede418b67a0f14e4f17a2b03f5362741badd5532.tar.bz2 scummvm-rg350-ede418b67a0f14e4f17a2b03f5362741badd5532.zip |
VOYEUR: Merge of upstream
Diffstat (limited to 'graphics/decoders/png.cpp')
-rw-r--r-- | graphics/decoders/png.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/graphics/decoders/png.cpp b/graphics/decoders/png.cpp index 11e26162eb..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,16 +163,20 @@ 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)); - if (!_outputSurface->pixels) { + 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."); } if (bitDepth == 16) 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); |