diff options
author | Paul Gilbert | 2016-07-26 19:48:14 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-26 19:48:14 -0400 |
commit | 504cf6ecb688a3f1c65a857bffd527d8b0e6ba63 (patch) | |
tree | 0c0d96d4061c11850c851f0fc981c75a58c20515 /image/codecs/bmp_raw.cpp | |
parent | d8c28d15ae553d047b7e571f98727fa79ee143f3 (diff) | |
parent | e19922d181e775791f9105b8be7ff410770ede51 (diff) | |
download | scummvm-rg350-504cf6ecb688a3f1c65a857bffd527d8b0e6ba63.tar.gz scummvm-rg350-504cf6ecb688a3f1c65a857bffd527d8b0e6ba63.tar.bz2 scummvm-rg350-504cf6ecb688a3f1c65a857bffd527d8b0e6ba63.zip |
Merge branch 'master' into xeen
Diffstat (limited to 'image/codecs/bmp_raw.cpp')
-rw-r--r-- | image/codecs/bmp_raw.cpp | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/image/codecs/bmp_raw.cpp b/image/codecs/bmp_raw.cpp index 83aedc84e6..68d70f25f6 100644 --- a/image/codecs/bmp_raw.cpp +++ b/image/codecs/bmp_raw.cpp @@ -46,9 +46,47 @@ 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 == 8) { + 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++) { + byte color = stream.readByte(); + + *dst++ = (color & 0xf0) >> 4; + j++; + + if (j ==_width) + break; + + *dst++ = color & 0x0f; + } + + stream.skip(extraDataLength); + } + } else if (_bitsPerPixel == 8) { byte *dst = (byte *)_surface->getPixels(); for (int i = 0; i < _height; i++) { @@ -100,6 +138,8 @@ const Graphics::Surface *BitmapRawDecoder::decodeFrame(Common::SeekableReadStrea Graphics::PixelFormat BitmapRawDecoder::getPixelFormat() const { switch (_bitsPerPixel) { + case 1: + case 4: case 8: return Graphics::PixelFormat::createFormatCLUT8(); case 24: |