diff options
author | Filippos Karapetis | 2012-09-16 14:06:42 -0700 |
---|---|---|
committer | Filippos Karapetis | 2012-09-16 14:06:42 -0700 |
commit | c0babb010a7f803e54f3021e9560d77baf69fdb8 (patch) | |
tree | cb235ef01b6b51fc2ad526795dc71975591c92cf /engines/tucker/resource.cpp | |
parent | dc207979b384a8c67d3e4358a81e710486930c61 (diff) | |
parent | ef671f20b108de79c006cdc95fc6ee613e46ab98 (diff) | |
download | scummvm-rg350-c0babb010a7f803e54f3021e9560d77baf69fdb8.tar.gz scummvm-rg350-c0babb010a7f803e54f3021e9560d77baf69fdb8.tar.bz2 scummvm-rg350-c0babb010a7f803e54f3021e9560d77baf69fdb8.zip |
Merge pull request #278 from bluegr/pcxdecoder
GRAPHICS: Add a PCX decoder
Diffstat (limited to 'engines/tucker/resource.cpp')
-rw-r--r-- | engines/tucker/resource.cpp | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/engines/tucker/resource.cpp b/engines/tucker/resource.cpp index bee09f7391..1b04f3fae9 100644 --- a/engines/tucker/resource.cpp +++ b/engines/tucker/resource.cpp @@ -29,6 +29,9 @@ #include "audio/decoders/vorbis.h" #include "audio/decoders/wave.h" +#include "graphics/surface.h" +#include "graphics/decoders/pcx.h" + #include "tucker/tucker.h" #include "tucker/graphics.h" @@ -298,23 +301,21 @@ void TuckerEngine::loadImage(const char *fname, uint8 *dst, int type) { return; } } - f.seek(128, SEEK_SET); - int size = 0; - while (size < 64000) { - int code = f.readByte(); - if (code >= 0xC0) { - const int sz = code - 0xC0; - code = f.readByte(); - memset(dst + size, code, sz); - size += sz; - } else { - dst[size++] = code; - } - } + + ::Graphics::PCXDecoder pcx; + if (!pcx.loadStream(f)) + error("Error while reading PCX image"); + + const ::Graphics::Surface *pcxSurface = pcx.getSurface(); + if (pcxSurface->format.bytesPerPixel != 1) + error("Invalid bytes per pixel in PCX surface (%d)", pcxSurface->format.bytesPerPixel); + if (pcxSurface->w != 320 || pcxSurface->h != 200) + error("Invalid PCX surface size (%d x %d)", pcxSurface->w, pcxSurface->h); + for (uint16 y = 0; y < pcxSurface->h; y++) + memcpy(dst + y * 320, pcxSurface->getBasePtr(0, y), pcxSurface->w); + if (type != 0) { - if (f.readByte() != 12) - return; - f.read(_currentPalette, 768); + memcpy(_currentPalette, pcx.getPalette(), 3 * 256); setBlackPalette(); } } |