diff options
Diffstat (limited to 'image')
-rw-r--r-- | image/codecs/bmp_raw.cpp | 26 | ||||
-rw-r--r-- | image/codecs/cinepak.cpp | 2 | ||||
-rw-r--r-- | image/pict.cpp | 2 |
3 files changed, 27 insertions, 3 deletions
diff --git a/image/codecs/bmp_raw.cpp b/image/codecs/bmp_raw.cpp index b47d5a178d..68d70f25f6 100644 --- a/image/codecs/bmp_raw.cpp +++ b/image/codecs/bmp_raw.cpp @@ -46,9 +46,30 @@ const Graphics::Surface *BitmapRawDecoder::decodeFrame(Common::SeekableReadStrea _surface->create(_width, _height, format); int srcPitch = _width * (_bitsPerPixel >> 3); - const int extraDataLength = (srcPitch % 4) ? 4 - (srcPitch % 4) : 0; + int extraDataLength = (srcPitch % 4) ? 4 - (srcPitch % 4) : 0; - if (_bitsPerPixel == 4) { + if (_bitsPerPixel == 1) { + srcPitch = (_width + 7) / 8; + extraDataLength = (srcPitch % 2) ? 2 - (srcPitch % 2) : 0; + } + + if (_bitsPerPixel == 1) { + for (int i = 0; i < _height; i++) { + byte *dst = (byte *)_surface->getBasePtr(0, i); + for (int j = 0; j != _width;) { + byte color = stream.readByte(); + for (int k = 0; k < 8; k++) { + *dst++ = (color & 0x80) ? 0x0f : 0x00; + color <<= 1; + j++; + if (j == _width) { + break; + } + } + } + stream.skip(extraDataLength); + } + } else if (_bitsPerPixel == 4) { for (int i = 0; i < _height; i++) { byte *dst = (byte *)_surface->getBasePtr(0, _height - i - 1); for (int j = 0; j < _width; j++) { @@ -117,6 +138,7 @@ const Graphics::Surface *BitmapRawDecoder::decodeFrame(Common::SeekableReadStrea Graphics::PixelFormat BitmapRawDecoder::getPixelFormat() const { switch (_bitsPerPixel) { + case 1: case 4: case 8: return Graphics::PixelFormat::createFormatCLUT8(); diff --git a/image/codecs/cinepak.cpp b/image/codecs/cinepak.cpp index 4e858921ee..2b02fc8127 100644 --- a/image/codecs/cinepak.cpp +++ b/image/codecs/cinepak.cpp @@ -260,7 +260,7 @@ private: } static inline byte getRGBLookupEntry(const byte *colorMap, uint16 index) { - return colorMap[s_defaultPaletteLookup[CLIP<int>(index, 0, 1024)]]; + return colorMap[s_defaultPaletteLookup[CLIP<int>(index, 0, 1023)]]; } }; diff --git a/image/pict.cpp b/image/pict.cpp index 89f115dc90..4f4f0396bf 100644 --- a/image/pict.cpp +++ b/image/pict.cpp @@ -340,6 +340,8 @@ void PICTDecoder::unpackBitsRect(Common::SeekableReadStream &stream, bool withPa uint32 lineSize = MAX<int>(width * bytesPerPixel + (8 * 2 / packBitsData.pixMap.pixelSize), packBitsData.pixMap.rowBytes); byte *buffer = new byte[lineSize * height]; + memset(buffer, 0, lineSize * height); + // Read in amount of data per row for (uint16 i = 0; i < packBitsData.pixMap.bounds.height(); i++) { // NOTE: Compression 0 is "default". The format in SCI games is packed when 0. |