From e79f0bf717c31fb599a28ffb3e210ba7b0a300b0 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Mon, 19 Mar 2012 23:29:58 -0400 Subject: GRAPHICS: Fix regression caused by a bad rebase --- graphics/decoders/pict.cpp | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'graphics/decoders') diff --git a/graphics/decoders/pict.cpp b/graphics/decoders/pict.cpp index 4c21cffe38..957342084e 100644 --- a/graphics/decoders/pict.cpp +++ b/graphics/decoders/pict.cpp @@ -512,18 +512,54 @@ void PICTDecoder::skipBitsRect(Common::SeekableReadStream &stream, bool hasPalet // http://developer.apple.com/legacy/mac/library/#documentation/QuickTime/Rm/CompressDecompress/ImageComprMgr/B-Chapter/2TheImageCompression.html // http://developer.apple.com/legacy/mac/library/#documentation/QuickTime/Rm/CompressDecompress/ImageComprMgr/F-Chapter/6WorkingwiththeImage.html void PICTDecoder::decodeCompressedQuickTime(Common::SeekableReadStream &stream) { - JPEGDecoder jpeg; - + // First, read all the fields from the opcode uint32 dataSize = stream.readUint32BE(); uint32 startPos = stream.pos(); - Common::SeekableSubReadStream jpegStream(&stream, stream.pos() + 156, stream.pos() + dataSize); + /* uint16 version = */ stream.readUint16BE(); + // Read in the display matrix + uint32 matrix[3][3]; + for (uint32 i = 0; i < 3; i++) + for (uint32 j = 0; j < 3; j++) + matrix[i][j] = stream.readUint32BE(); + + // We currently only support offseting images vertically from the matrix + uint16 xOffset = 0; + uint16 yOffset = matrix[2][1] >> 16; + + uint32 matteSize = stream.readUint32BE(); + stream.skip(8); // matte rect + /* uint16 transferMode = */ stream.readUint16BE(); + stream.skip(8); // src rect + /* uint32 accuracy = */ stream.readUint32BE(); + uint32 maskSize = stream.readUint32BE(); + + // Skip the matte and mask + stream.skip(matteSize + maskSize); + + // Now we've reached the image descriptor, so read the relevant data from that + uint32 idStart = stream.pos(); + uint32 idSize = stream.readUint32BE(); + stream.skip(40); // miscellaneous stuff + uint32 jpegSize = stream.readUint32BE(); + stream.skip(idSize - (stream.pos() - idStart)); // more useless stuff + + Common::SeekableSubReadStream jpegStream(&stream, stream.pos(), stream.pos() + jpegSize); + + JPEGDecoder jpeg; if (!jpeg.loadStream(jpegStream)) error("PICTDecoder::decodeCompressedQuickTime(): Could not decode JPEG data"); - _outputSurface = new Graphics::Surface(); - _outputSurface->copyFrom(*jpeg.getSurface()); + const Graphics::Surface *jpegSurface = jpeg.getSurface(); + + if (!_outputSurface) { + _outputSurface = new Graphics::Surface(); + _outputSurface->create(_imageRect.width(), _imageRect.height(), jpegSurface->format); + } + + for (uint16 y = 0; y < jpegSurface->h; y++) + memcpy(_outputSurface->getBasePtr(0 + xOffset, y + yOffset), jpegSurface->getBasePtr(0, y), jpegSurface->w * jpegSurface->format.bytesPerPixel); stream.seek(startPos + dataSize); } -- cgit v1.2.3