diff options
author | Iskrich | 2016-05-18 04:07:14 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | c2414ae3815e92b768f194c8e353405e6b532919 (patch) | |
tree | da12a49bfef4075e2140fa48612c1f5d50133c57 | |
parent | 75a01e0ea096c17bb6809140c3c69026362ccbe2 (diff) | |
download | scummvm-rg350-c2414ae3815e92b768f194c8e353405e6b532919.tar.gz scummvm-rg350-c2414ae3815e92b768f194c8e353405e6b532919.tar.bz2 scummvm-rg350-c2414ae3815e92b768f194c8e353405e6b532919.zip |
DIRECTOR: Display test bitmap resource
-rw-r--r-- | engines/director/dib.cpp | 50 | ||||
-rw-r--r-- | engines/director/dib.h | 4 | ||||
-rw-r--r-- | engines/director/director.cpp | 9 |
3 files changed, 43 insertions, 20 deletions
diff --git a/engines/director/dib.cpp b/engines/director/dib.cpp index af7ef6c966..30c32349a6 100644 --- a/engines/director/dib.cpp +++ b/engines/director/dib.cpp @@ -27,10 +27,13 @@ #include "common/textconsole.h" #include "graphics/pixelformat.h" #include "graphics/surface.h" + #include "graphics/palette.h" #include "image/codecs/codec.h" #include "common/util.h" #include "common/debug.h" - +#include "image/codecs/bmp_raw.h" +#include "common/system.h" +#include "common/events.h" namespace Director { DIBDecoder::DIBDecoder() { @@ -56,14 +59,11 @@ void DIBDecoder::destroy() { } void DIBDecoder::loadPalette(Common::SeekableReadStream &stream) { - _palette = new byte[1024]; - + _palette = new byte[768]; uint16 steps = stream.size()/6; - uint16 index = (steps * 4) - 1; + uint16 index = (steps * 3) - 1; for (uint8 i = 0; i < steps; i++) { - _palette[index--] = 0; - _palette[index--] = stream.readByte(); stream.readByte(); @@ -74,15 +74,19 @@ void DIBDecoder::loadPalette(Common::SeekableReadStream &stream) { stream.readByte(); } - index = (steps * 4) - 1; - - while (index < 1024) { + index = (steps * 3) - 1; + while (index < 768) { _palette[index++] = 0; } } bool DIBDecoder::loadStream(Common::SeekableReadStream &stream) { - destroy(); + + byte *buf = (byte *)malloc(stream.size()); + stream.read(buf, stream.size()); + Common::hexdump(buf, stream.size()); + stream.seek(0); + if (stream.readByte() != 40) return false; if (stream.readByte() != 0) @@ -91,14 +95,28 @@ bool DIBDecoder::loadStream(Common::SeekableReadStream &stream) { stream.seek(4); uint16 width = stream.readUint32LE(); uint16 height = stream.readUint32LE(); - _paletteColorCount = (stream.readUint32LE() + stream.readUint32LE()) << 8; + stream.seek(32); + _paletteColorCount = stream.readByte() + (stream.readByte() << 8); _paletteColorCount = (_paletteColorCount == 0) ? 255: _paletteColorCount; - uint16 totalsize = 14 + stream.size() + sizeof(_palette)/sizeof(byte); + uint16 totalsize = 14 + stream.size() + 1024; + uint16 imageRawSize = stream.size() - 40; + Common::SeekableSubReadStream subStream(&stream, 40, imageRawSize); + + _codec = new Image::BitmapRawDecoder(width, height, 4); + _surface = _codec->decodeFrame(subStream); + + //FIXME + g_system->getPaletteManager()->setPalette(_palette, 0, _paletteColorCount - 1); + g_system->copyRectToScreen(_surface->getPixels(), _surface->pitch, 100, 100, 24, 24); + g_system->updateScreen(); - debug("%d", _paletteColorCount); - debug("%d", width); - debug("%d", height); - debug("%d", totalsize); + int stop = 0; + + while (stop < 100) { + g_system->delayMillis(50); + g_system->updateScreen(); + stop++; + } return true; } diff --git a/engines/director/dib.h b/engines/director/dib.h index c22b205e8b..c3243dfd26 100644 --- a/engines/director/dib.h +++ b/engines/director/dib.h @@ -34,7 +34,7 @@ #include "common/scummsys.h" #include "common/str.h" #include "image/image_decoder.h" - +#include "image/codecs/bmp_raw.h" namespace Common { class SeekableReadStream; } @@ -63,7 +63,7 @@ public: uint16 getPaletteColorCount() const { return _paletteColorCount; } private: - Image::Codec *_codec; + Image::BitmapRawDecoder *_codec; const Graphics::Surface *_surface; byte *_palette; uint8 _paletteColorCount; diff --git a/engines/director/director.cpp b/engines/director/director.cpp index 0ddb8a7350..f64af75cea 100644 --- a/engines/director/director.cpp +++ b/engines/director/director.cpp @@ -34,6 +34,7 @@ #include "director/director.h" #include "director/resource.h" +#include "graphics/surface.h" namespace Director { @@ -55,10 +56,14 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam RIFFArchive riff; riff.openFile("bookshelf_example.mmm"); Director::DIBDecoder img; - Common::SeekableReadStream *dib = riff.getResource(MKTAG('D', 'I', 'B', ' '), 1103); - img.loadStream(*dib); + Common::SeekableReadStream *pal = riff.getResource(MKTAG('C', 'L', 'U', 'T'), 1025); img.loadPalette(*pal); + + Common::SeekableReadStream *dib = riff.getResource(MKTAG('D', 'I', 'B', ' '), 1103); + img.loadStream(*dib); + + } DirectorEngine::~DirectorEngine() { |