diff options
author | Paul Gilbert | 2018-12-05 19:17:48 -0800 |
---|---|---|
committer | Paul Gilbert | 2018-12-08 19:05:59 -0800 |
commit | ab8ff73453005f55acdf13ebbc39cb3acb7aa74a (patch) | |
tree | 3782a617d9368323dd55d60d221ed3b0bc8f43b9 /engines/glk | |
parent | 7fda941302358b55d05005837e7719d33bf6ede7 (diff) | |
download | scummvm-rg350-ab8ff73453005f55acdf13ebbc39cb3acb7aa74a.tar.gz scummvm-rg350-ab8ff73453005f55acdf13ebbc39cb3acb7aa74a.tar.bz2 scummvm-rg350-ab8ff73453005f55acdf13ebbc39cb3acb7aa74a.zip |
GLK: FROTZ: Fix handling of empty rect picture resources
Diffstat (limited to 'engines/glk')
-rw-r--r-- | engines/glk/frotz/pics.cpp | 26 | ||||
-rw-r--r-- | engines/glk/picture.cpp | 9 |
2 files changed, 25 insertions, 10 deletions
diff --git a/engines/glk/frotz/pics.cpp b/engines/glk/frotz/pics.cpp index 4953f047b9..2d05fc95a2 100644 --- a/engines/glk/frotz/pics.cpp +++ b/engines/glk/frotz/pics.cpp @@ -24,6 +24,7 @@ #include "glk/frotz/pics_decoder.h" #include "glk/glk.h" #include "common/algorithm.h" +#include "common/memstream.h" namespace Glk { namespace Frotz { @@ -68,7 +69,10 @@ Pics::Pics() : Common::Archive(), _filename(getFilename()) { } } - e._filename = Common::String::format("pic%u.raw", e._number); + if (e._dataOffset) + e._filename = Common::String::format("pic%u.raw", e._number); + else + e._filename = Common::String::format("pic%u.rect", e._number); } // Further processing of index to calculate data sizes @@ -128,6 +132,8 @@ const Common::ArchiveMemberPtr Pics::getMember(const Common::String &name) const } Common::SeekableReadStream *Pics::createReadStreamForMember(const Common::String &name) const { + PictureDecoder decoder; + for (uint idx = 0; idx < _index.size(); ++idx) { const Entry &e = _index[idx]; if (e._filename.equalsIgnoreCase(name)) { @@ -137,19 +143,21 @@ Common::SeekableReadStream *Pics::createReadStreamForMember(const Common::String if (!f.open(_filename)) error("Reading failed"); - // Read in the image's palette - assert(e._paletteOffset); - f.seek(e._paletteOffset); - palette.resize(f.readByte() * 3); - f.read(&palette[0], palette.size()); - - PictureDecoder decoder; if (e._dataSize) { + // Read in the image's palette + assert(e._paletteOffset); + f.seek(e._paletteOffset); + palette.resize(f.readByte() * 3); + f.read(&palette[0], palette.size()); + Common::SeekableReadStream *src = f.readStream(e._dataSize); dest = decoder.decode(*src, e._flags, palette, MCGA, e._width, e._height); delete src; } else { - error("TODO: Empty rect renderings"); + byte *rect = (byte *)malloc(2 * sizeof(uint16)); + WRITE_LE_UINT16(rect, e._width); + WRITE_LE_UINT16(rect + 2, e._height); + dest = new Common::MemoryReadStream(rect, 2 * sizeof(uint16), DisposeAfterUse::YES); } f.close(); diff --git a/engines/glk/picture.cpp b/engines/glk/picture.cpp index 631f9bed6c..c7c8f70b6d 100644 --- a/engines/glk/picture.cpp +++ b/engines/glk/picture.cpp @@ -103,6 +103,7 @@ Picture *Pictures::retrieve(uint id, bool scaled) { Picture *Pictures::load(uint32 id) { ::Image::PNGDecoder png; ::Image::JPEGDecoder jpg; + Graphics::Surface rectImg; RawDecoder raw; const Graphics::Surface *img; const byte *palette = nullptr; @@ -128,6 +129,10 @@ Picture *Pictures::load(uint32 id) { img = raw.getSurface(); palette = raw.getPalette(); palCount = raw.getPaletteColorCount(); + } else if (f.open(Common::String::format("pic%u.rect", id))) { + rectImg.w = f.readUint16LE(); + rectImg.h = f.readUint16LE(); + img = &rectImg; } else { // No such picture return nullptr; @@ -138,7 +143,9 @@ Picture *Pictures::load(uint32 id) { pic->_id = id; pic->_scaled = false; - if (!palette) { + if (!img->getPixels()) { + // Area definition without any content + } else if (!palette) { pic->blitFrom(*img); } else { uint pal[256]; |