mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-02 23:26:44 +00:00
IMAGE: Use 0-bit alpha for non-transparent PNGs
This commit is contained in:
parent
6a6d681990
commit
dd75517d61
@ -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.");
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user