aboutsummaryrefslogtreecommitdiff
path: root/image/png.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'image/png.cpp')
-rw-r--r--image/png.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/image/png.cpp b/image/png.cpp
index d8351711d9..e854651da6 100644
--- a/image/png.cpp
+++ b/image/png.cpp
@@ -43,7 +43,9 @@ PNGDecoder::PNGDecoder() :
_outputSurface(0),
_palette(0),
_paletteColorCount(0),
- _skipSignature(false) {
+ _skipSignature(false),
+ _keepTransparencyPaletted(false),
+ _transparentColor(-1) {
}
PNGDecoder::~PNGDecoder() {
@@ -159,7 +161,7 @@ bool PNGDecoder::loadStream(Common::SeekableReadStream &stream) {
// Images of all color formats except PNG_COLOR_TYPE_PALETTE
// will be transformed into ARGB images
- if (colorType == PNG_COLOR_TYPE_PALETTE && !png_get_valid(pngPtr, infoPtr, PNG_INFO_tRNS)) {
+ if (colorType == PNG_COLOR_TYPE_PALETTE && (_keepTransparencyPaletted || !png_get_valid(pngPtr, infoPtr, PNG_INFO_tRNS))) {
int numPalette = 0;
png_colorp palette = NULL;
uint32 success = png_get_PLTE(pngPtr, infoPtr, &palette, &numPalette);
@@ -175,6 +177,16 @@ bool PNGDecoder::loadStream(Common::SeekableReadStream &stream) {
_palette[(i * 3) + 2] = palette[i].blue;
}
+
+ if (png_get_valid(pngPtr, infoPtr, PNG_INFO_tRNS)) {
+ png_bytep trans;
+ int numTrans;
+ png_color_16p transColor;
+ png_get_tRNS(pngPtr, infoPtr, &trans, &numTrans, &transColor);
+ assert(numTrans == 1);
+ _transparentColor = *trans;
+ }
+
_outputSurface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
png_set_packing(pngPtr);
} else {