mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-02 23:26:44 +00:00
IMAGE: add flag to skip signature check in png decoder
This commit is contained in:
parent
5469aaf8ec
commit
1a27d67123
@ -39,7 +39,7 @@
|
||||
|
||||
namespace Image {
|
||||
|
||||
PNGDecoder::PNGDecoder() : _outputSurface(0), _palette(0), _paletteColorCount(0) {
|
||||
PNGDecoder::PNGDecoder() : _outputSurface(0), _palette(0), _paletteColorCount(0), _skipSignature(false) {
|
||||
}
|
||||
|
||||
PNGDecoder::~PNGDecoder() {
|
||||
@ -99,12 +99,14 @@ bool PNGDecoder::loadStream(Common::SeekableReadStream &stream) {
|
||||
#ifdef USE_PNG
|
||||
destroy();
|
||||
|
||||
// First, check the PNG signature
|
||||
if (stream.readUint32BE() != MKTAG(0x89, 'P', 'N', 'G')) {
|
||||
return false;
|
||||
}
|
||||
if (stream.readUint32BE() != MKTAG(0x0d, 0x0a, 0x1a, 0x0a)) {
|
||||
return false;
|
||||
// First, check the PNG signature (if not set to skip it)
|
||||
if (!_skipSignature) {
|
||||
if (stream.readUint32BE() != MKTAG(0x89, 'P', 'N', 'G')) {
|
||||
return false;
|
||||
}
|
||||
if (stream.readUint32BE() != MKTAG(0x0d, 0x0a, 0x1a, 0x0a)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// The following is based on the guide provided in:
|
||||
|
@ -56,10 +56,14 @@ public:
|
||||
const Graphics::Surface *getSurface() const { return _outputSurface; }
|
||||
const byte *getPalette() const { return _palette; }
|
||||
uint16 getPaletteColorCount() const { return _paletteColorCount; }
|
||||
void setSkipSignature(bool skip) { _skipSignature = skip; }
|
||||
private:
|
||||
byte *_palette;
|
||||
uint16 _paletteColorCount;
|
||||
|
||||
// flag to skip the png signature check for headless png files
|
||||
bool _skipSignature;
|
||||
|
||||
Graphics::Surface *_outputSurface;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user