aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2019-08-01 22:04:36 -0700
committerPaul Gilbert2019-08-01 22:05:40 -0700
commitefdf96517072445c07f17fdef17efd86e2bdc68c (patch)
tree01fd8676a11c0692df96827e716c0b5c2e7acf1d /engines
parent8a8ac63636850e18043fb5314c570b672eba2d6e (diff)
downloadscummvm-rg350-efdf96517072445c07f17fdef17efd86e2bdc68c.tar.gz
scummvm-rg350-efdf96517072445c07f17fdef17efd86e2bdc68c.tar.bz2
scummvm-rg350-efdf96517072445c07f17fdef17efd86e2bdc68c.zip
GLK: Properly handle Blorb images that have an adaptive palette
Diffstat (limited to 'engines')
-rw-r--r--engines/glk/picture.cpp27
-rw-r--r--engines/glk/picture.h4
2 files changed, 30 insertions, 1 deletions
diff --git a/engines/glk/picture.cpp b/engines/glk/picture.cpp
index 1663fa43ef..5cb44c8857 100644
--- a/engines/glk/picture.cpp
+++ b/engines/glk/picture.cpp
@@ -30,6 +30,14 @@
namespace Glk {
+Pictures::Pictures() : _refCount(0) {
+ Common::File f;
+ if (f.open("apal")) {
+ while (f.pos() < f.size())
+ _adaptivePics.push_back(f.readUint32BE());
+ }
+}
+
void Pictures::clear() {
for (uint idx = 0; idx < _store.size(); ++idx) {
if (_store[idx]._picture)
@@ -120,10 +128,12 @@ Picture *Pictures::load(uint32 id) {
Common::File f;
if (f.open(Common::String::format("pic%u.png", id))) {
+ png.setKeepTransparencyPaletted(true);
png.loadStream(f);
img = png.getSurface();
palette = png.getPalette();
palCount = png.getPaletteColorCount();
+ transColor = png.getTransparentColor();
} else if (f.open(Common::String::format("pic%u.jpg", id))) {
jpg.setOutputPixelFormat(g_system->getScreenFormat());
jpg.loadStream(f);
@@ -143,6 +153,23 @@ Picture *Pictures::load(uint32 id) {
return nullptr;
}
+ // Also check if it's going to be an adaptive pic
+ bool isAdaptive = false;
+ for (uint idx = 0; idx < _adaptivePics.size() && !isAdaptive; ++idx)
+ isAdaptive = _adaptivePics[idx] == id;
+
+ if (isAdaptive) {
+ // It is, so used previously saved palette
+ assert(!_savedPalette.empty());
+ palette = &_savedPalette[0];
+ palCount = _savedPalette.size() / 3;
+ } else if (palette) {
+ // It's a picture with a valid palette, so save a copy of it for later
+ _savedPalette.resize(palCount * 3);
+ Common::copy(palette, palette + palCount * 3, &_savedPalette[0]);
+ }
+
+ // Create new picture based on the image
pic = new Picture(img->w, img->h, g_system->getScreenFormat());
pic->_refCount = 1;
pic->_id = id;
diff --git a/engines/glk/picture.h b/engines/glk/picture.h
index e3b65602a2..a8b7e0a9b2 100644
--- a/engines/glk/picture.h
+++ b/engines/glk/picture.h
@@ -90,6 +90,8 @@ class Pictures {
private:
int _refCount;
Common::Array<PictureEntry> _store;
+ Common::Array<uint> _adaptivePics;
+ Common::Array<byte> _savedPalette;
private:
/**
* Stores an original picture in the store
@@ -104,7 +106,7 @@ public:
/**
* Constructor
*/
- Pictures() : _refCount(0) {}
+ Pictures();
/**
* Destructor