From 4516b5ea24e6c0056984a65fe4fff33553931487 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 2 Jul 2011 21:02:58 -0400 Subject: GRAPHICS: Convert PictDecoder to the ImageDecoder API --- engines/sci/graphics/maciconbar.cpp | 18 ++++++++++-------- engines/sci/graphics/maciconbar.h | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/graphics/maciconbar.cpp b/engines/sci/graphics/maciconbar.cpp index bff145ad53..7ecba5a24d 100644 --- a/engines/sci/graphics/maciconbar.cpp +++ b/engines/sci/graphics/maciconbar.cpp @@ -31,8 +31,8 @@ #include "common/memstream.h" #include "common/system.h" -#include "graphics/pict.h" #include "graphics/surface.h" +#include "graphics/decoders/pict.h" namespace Sci { @@ -201,18 +201,20 @@ void GfxMacIconBar::setInventoryIcon(int16 icon) { } Graphics::Surface *GfxMacIconBar::loadPict(ResourceId id) { - Graphics::PictDecoder pictDecoder(Graphics::PixelFormat::createFormatCLUT8()); + Graphics::PICTDecoder pictDecoder; Resource *res = g_sci->getResMan()->findResource(id, false); if (!res || res->size == 0) return 0; - byte palette[256 * 3]; - Common::SeekableReadStream *stream = new Common::MemoryReadStream(res->data, res->size); - Graphics::Surface *surface = pictDecoder.decodeImage(stream, palette); - remapColors(surface, palette); + Common::MemoryReadStream stream(res->data, res->size); + if (!pictDecoder.loadStream(stream)) + return 0; + + Graphics::Surface *surface = new Graphics::Surface(); + surface->copyFrom(*pictDecoder.getSurface()); + remapColors(surface, pictDecoder.getPalette()); - delete stream; return surface; } @@ -221,7 +223,7 @@ Graphics::Surface *GfxMacIconBar::createImage(uint32 iconIndex, bool isSelected) return loadPict(ResourceId(type, iconIndex + 1)); } -void GfxMacIconBar::remapColors(Graphics::Surface *surf, byte *palette) { +void GfxMacIconBar::remapColors(Graphics::Surface *surf, const byte *palette) { byte *pixels = (byte *)surf->pixels; // Remap to the screen palette diff --git a/engines/sci/graphics/maciconbar.h b/engines/sci/graphics/maciconbar.h index 43de37a904..eca10b804c 100644 --- a/engines/sci/graphics/maciconbar.h +++ b/engines/sci/graphics/maciconbar.h @@ -61,7 +61,7 @@ private: Graphics::Surface *loadPict(ResourceId id); Graphics::Surface *createImage(uint32 iconIndex, bool isSelected); - void remapColors(Graphics::Surface *surf, byte *palette); + void remapColors(Graphics::Surface *surf, const byte *palette); void drawIcon(uint16 index, bool selected); void drawSelectedImage(uint16 index); -- cgit v1.2.3