Skip to content

Commit

Permalink
GRAPHICS: Fix PICT lines with large pitches
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Hoops committed Dec 19, 2011
1 parent 96face8 commit bdf14ed
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions graphics/pict.cpp
Expand Up @@ -338,10 +338,9 @@ void PictDecoder::unpackBitsRect(Common::SeekableReadStream *stream, bool hasPal
_outputSurface = new Graphics::Surface();
_outputSurface->create(width, height, (bytesPerPixel == 1) ? PixelFormat::createFormatCLUT8() : _pixelFormat);

// Create an temporary buffer, but allocate a bit more than we need to avoid overflow
// (align it to the next highest two-byte packed boundary, which may be more unpacked,
// as m68k and therefore QuickDraw is word-aligned)
byte *buffer = new byte[width * height * bytesPerPixel + (8 * 2 / packBitsData.pixMap.pixelSize)];
// Ensure we have enough space in the buffer to hold an entire line's worth of pixels
uint32 lineSize = MAX<int>(width * bytesPerPixel + (8 * 2 / packBitsData.pixMap.pixelSize), packBitsData.pixMap.rowBytes);
byte *buffer = new byte[lineSize * height];

// Read in amount of data per row
for (uint16 i = 0; i < packBitsData.pixMap.bounds.height(); i++) {
Expand Down

0 comments on commit bdf14ed

Please sign in to comment.