diff options
author | Paul Gilbert | 2018-11-24 16:53:04 -0800 |
---|---|---|
committer | Paul Gilbert | 2018-12-08 19:05:59 -0800 |
commit | 77468312de507fcd7e01c95f1135afc33a6f4b24 (patch) | |
tree | d9ff037883a24a045c4079267d6854510f2e473f /engines/glk/picture.cpp | |
parent | 62af5ea8919a5148154413eaec80a9e686d64114 (diff) | |
download | scummvm-rg350-77468312de507fcd7e01c95f1135afc33a6f4b24.tar.gz scummvm-rg350-77468312de507fcd7e01c95f1135afc33a6f4b24.tar.bz2 scummvm-rg350-77468312de507fcd7e01c95f1135afc33a6f4b24.zip |
GLK: FROTZ: Beyond Zork title screen now showing
Diffstat (limited to 'engines/glk/picture.cpp')
-rw-r--r-- | engines/glk/picture.cpp | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/engines/glk/picture.cpp b/engines/glk/picture.cpp index c8dcbc5462..34043152a5 100644 --- a/engines/glk/picture.cpp +++ b/engines/glk/picture.cpp @@ -106,6 +106,7 @@ Picture *Pictures::load(uint32 id) { RawDecoder raw; const Graphics::Surface *img; const byte *palette = nullptr; + int palCount = 0; Picture *pic; // Check if the picture is already in the store @@ -114,30 +115,46 @@ Picture *Pictures::load(uint32 id) { return pic; Common::File f; - if (f.open(Common::String::format("PIC%u.png", id))) { + if (f.open(Common::String::format("pic%u.png", id))) { png.loadStream(f); img = png.getSurface(); palette = png.getPalette(); - } else if (f.open(Common::String::format("PIC%u.jpg", id))) { + palCount = png.getPaletteColorCount(); + } else if (f.open(Common::String::format("pic%u.jpg", id))) { jpg.loadStream(f); img = jpg.getSurface(); - } else if (f.open(Common::String::format("PIC%u.raw", id))) { + } else if (f.open(Common::String::format("pic%u.raw", id))) { raw.loadStream(f); img = raw.getSurface(); palette = raw.getPalette(); + palCount = raw.getPaletteColorCount(); } else { // No such picture return nullptr; } - pic = new Picture(img->w, img->h, img->format); + pic = new Picture(img->w, img->h, g_system->getScreenFormat()); pic->_refCount = 1; pic->_id = id; pic->_scaled = false; - pic->blitFrom(*img); - if (palette) - pic->convertToInPlace(g_system->getScreenFormat(), palette); + if (!palette) { + pic->blitFrom(*img); + } else { + uint pal[256]; + for (uint idx = 0; idx < palCount; ++idx) + pal[idx] = pic->format.RGBToColor(palette[idx * 3], + palette[idx * 3 + 1], palette[idx * 3 + 2]); + + byte *srcP = (byte *)img->getPixels(), *destP = (byte *)pic->getPixels(); + for (int idx = 0; idx < img->w * img->h; ++idx, srcP++, destP += pic->format.bytesPerPixel) { + uint val = (*srcP >= palCount) ? 0 : pal[*srcP]; + if (pic->format.bytesPerPixel == 2) + WRITE_LE_UINT16(destP, val); + else + WRITE_LE_UINT32(destP, val); + } + } store(pic); return pic; |