diff options
author | Iskrich | 2016-05-17 01:34:55 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | 75a01e0ea096c17bb6809140c3c69026362ccbe2 (patch) | |
tree | 8ad673c3272bf18d1af5928e434152056b839469 /engines/director/dib.cpp | |
parent | acc0d70054f34f8acd2cc2e4647156c238cd2181 (diff) | |
download | scummvm-rg350-75a01e0ea096c17bb6809140c3c69026362ccbe2.tar.gz scummvm-rg350-75a01e0ea096c17bb6809140c3c69026362ccbe2.tar.bz2 scummvm-rg350-75a01e0ea096c17bb6809140c3c69026362ccbe2.zip |
DIRECTOR: Refactoring palette loading
Diffstat (limited to 'engines/director/dib.cpp')
-rw-r--r-- | engines/director/dib.cpp | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/engines/director/dib.cpp b/engines/director/dib.cpp index 3cf23d6982..af7ef6c966 100644 --- a/engines/director/dib.cpp +++ b/engines/director/dib.cpp @@ -28,6 +28,7 @@ #include "graphics/pixelformat.h" #include "graphics/surface.h" #include "image/codecs/codec.h" +#include "common/util.h" #include "common/debug.h" namespace Director { @@ -48,7 +49,6 @@ void DIBDecoder::destroy() { delete[] _palette; _palette = 0; - _paletteColorCount = 0; delete _codec; @@ -56,31 +56,28 @@ void DIBDecoder::destroy() { } void DIBDecoder::loadPalette(Common::SeekableReadStream &stream) { - uint16 palentries = 256; _palette = new byte[1024]; - uint16 size = stream.size(); - uint16 index = 0; - for (int i = 6; i < stream.size() + 6; i+=6) { - uint16 n = size - i; - if (i >= palentries) { - break; - } - stream.seek(n + 4); - _palette[index] = stream.readByte(); - ++index; - stream.seek(n + 2); - _palette[index] = stream.readByte(); - ++index; - stream.seek(n); - _palette[index] = stream.readByte(); - ++index; - _palette[index] = 0; - ++index; + uint16 steps = stream.size()/6; + uint16 index = (steps * 4) - 1; + + for (uint8 i = 0; i < steps; i++) { + _palette[index--] = 0; + + _palette[index--] = stream.readByte(); + stream.readByte(); + + _palette[index--] = stream.readByte(); + stream.readByte(); + + _palette[index--] = stream.readByte(); + stream.readByte(); } + + index = (steps * 4) - 1; + while (index < 1024) { - _palette[index] = 0; - ++index; + _palette[index++] = 0; } } |