Skip to content

Commit

Permalink
GRAPHICS: Fix 32-bit DirectBits images
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Hoops committed May 5, 2012
1 parent 5a1f458 commit e5808c7
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions graphics/decoders/pict.cpp
Expand Up @@ -361,14 +361,14 @@ void PICTDecoder::unpackBitsRect(Common::SeekableReadStream &stream, bool hasPal
memcpy(_outputSurface->pixels, buffer, _outputSurface->w * _outputSurface->h);
break;
case 2:
// Convert from 16-bit to whatever surface we need
// We have a 16-bit surface
_outputSurface->create(width, height, PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0));
for (uint16 y = 0; y < _outputSurface->h; y++)
for (uint16 x = 0; x < _outputSurface->w; x++)
WRITE_UINT16(_outputSurface->getBasePtr(x, y), READ_UINT16(buffer + (y * _outputSurface->w + x) * 2));
break;
case 3:
// Convert from 24-bit (planar!) to whatever surface we need
// We have a planar 24-bit surface
_outputSurface->create(width, height, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
for (uint16 y = 0; y < _outputSurface->h; y++) {
for (uint16 x = 0; x < _outputSurface->w; x++) {
Expand All @@ -380,15 +380,18 @@ void PICTDecoder::unpackBitsRect(Common::SeekableReadStream &stream, bool hasPal
}
break;
case 4:
// Convert from 32-bit (planar!) to whatever surface we need
// We have a planar 32-bit surface
// Note that we ignore the alpha channel since it seems to not be correct
// Mac OS X does not ignore it, but then displays it incorrectly. Photoshop
// does ignore it and displays it correctly.
_outputSurface->create(width, height, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
for (uint16 y = 0; y < _outputSurface->h; y++) {
for (uint16 x = 0; x < _outputSurface->w; x++) {
byte r = *(buffer + y * _outputSurface->w * 4 + x);
byte g = *(buffer + y * _outputSurface->w * 4 + _outputSurface->w + x);
byte b = *(buffer + y * _outputSurface->w * 4 + _outputSurface->w * 2 + x);
byte a = *(buffer + y * _outputSurface->w * 4 + _outputSurface->w * 3 + x);
*((uint32 *)_outputSurface->getBasePtr(x, y)) = _outputSurface->format.ARGBToColor(r, g, b, a);
byte a = 0xFF;
byte r = *(buffer + y * _outputSurface->w * 4 + _outputSurface->w + x);
byte g = *(buffer + y * _outputSurface->w * 4 + _outputSurface->w * 2 + x);
byte b = *(buffer + y * _outputSurface->w * 4 + _outputSurface->w * 3 + x);
*((uint32 *)_outputSurface->getBasePtr(x, y)) = _outputSurface->format.ARGBToColor(a, r, g, b);
}
}
break;
Expand Down

0 comments on commit e5808c7

Please sign in to comment.