From 6ae97cdfbe88fa34363aabc46847b0c9a32eefe5 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 26 Jan 2013 11:33:30 -0500 Subject: GRAPHICS: Modify the JFIF version warning v1.02 images should only differ with the thumbnail from v1.01, and should be handled correctly by our decoder. --- graphics/decoders/jpeg.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'graphics/decoders') diff --git a/graphics/decoders/jpeg.cpp b/graphics/decoders/jpeg.cpp index 08bc1f7a3d..5e926e60a0 100644 --- a/graphics/decoders/jpeg.cpp +++ b/graphics/decoders/jpeg.cpp @@ -215,28 +215,34 @@ bool JPEGDecoder::loadStream(Common::SeekableReadStream &stream) { bool JPEGDecoder::readJFIF() { uint16 length = _stream->readUint16BE(); uint32 tag = _stream->readUint32BE(); + if (tag != MKTAG('J', 'F', 'I', 'F')) { warning("JPEGDecoder::readJFIF() tag mismatch"); return false; } + if (_stream->readByte() != 0) { // NULL warning("JPEGDecoder::readJFIF() NULL mismatch"); return false; } + byte majorVersion = _stream->readByte(); byte minorVersion = _stream->readByte(); - if (majorVersion != 1 || minorVersion != 1) - warning("JPEGDecoder::readJFIF() Non-v1.1 JPEGs may not be handled correctly"); + if (majorVersion != 1 || minorVersion > 2) + warning("JPEGDecoder::readJFIF(): v%d.%02d JPEGs may not be handled correctly", majorVersion, minorVersion); + /* byte densityUnits = */_stream->readByte(); /* uint16 xDensity = */_stream->readUint16BE(); /* uint16 yDensity = */_stream->readUint16BE(); byte thumbW = _stream->readByte(); byte thumbH = _stream->readByte(); + _stream->seek(thumbW * thumbH * 3, SEEK_CUR); // Ignore thumbnail if (length != (thumbW * thumbH * 3) + 16) { warning("JPEGDecoder::readJFIF() length mismatch"); return false; } + return true; } -- cgit v1.2.3