diff options
author | Alyssa Milburn | 2013-11-12 10:26:03 +0100 |
---|---|---|
committer | Alyssa Milburn | 2013-11-12 10:57:25 +0100 |
commit | 575f81da5f11e7b73236beeca5518f4fd054516d (patch) | |
tree | c288f5c26a12ac4eddeb01827aca95add276bfdb /graphics/decoders/png.cpp | |
parent | 07d9e67ea43b127b6b498aaa8a0261c51867f7ba (diff) | |
download | scummvm-rg350-575f81da5f11e7b73236beeca5518f4fd054516d.tar.gz scummvm-rg350-575f81da5f11e7b73236beeca5518f4fd054516d.tar.bz2 scummvm-rg350-575f81da5f11e7b73236beeca5518f4fd054516d.zip |
GRAPHICS: Set PNG alpha bits to 0 if there's no alpha present.
This fixes the color-keying checks in Wintermute for PNG images.
Diffstat (limited to 'graphics/decoders/png.cpp')
-rw-r--r-- | graphics/decoders/png.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/graphics/decoders/png.cpp b/graphics/decoders/png.cpp index 5acb7b36f7..c4fee46fec 100644 --- a/graphics/decoders/png.cpp +++ b/graphics/decoders/png.cpp @@ -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); |