aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk
diff options
context:
space:
mode:
authorMatthew Hoops2011-07-02 21:02:58 -0400
committerJohannes Schickel2012-03-20 01:06:48 +0100
commit4516b5ea24e6c0056984a65fe4fff33553931487 (patch)
tree96f303d33ed30fef9e3d39aff8e973a1225557fc /engines/mohawk
parent270f8077c2fa4f226a693d95c7653b5d358b9556 (diff)
downloadscummvm-rg350-4516b5ea24e6c0056984a65fe4fff33553931487.tar.gz
scummvm-rg350-4516b5ea24e6c0056984a65fe4fff33553931487.tar.bz2
scummvm-rg350-4516b5ea24e6c0056984a65fe4fff33553931487.zip
GRAPHICS: Convert PictDecoder to the ImageDecoder API
Diffstat (limited to 'engines/mohawk')
-rw-r--r--engines/mohawk/graphics.cpp17
-rw-r--r--engines/mohawk/myst_graphics.cpp24
-rw-r--r--engines/mohawk/myst_graphics.h2
3 files changed, 17 insertions, 26 deletions
diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp
index a08d034ef7..0f9a62c891 100644
--- a/engines/mohawk/graphics.cpp
+++ b/engines/mohawk/graphics.cpp
@@ -58,22 +58,7 @@ void MohawkSurface::convertToTrueColor() {
assert(_palette);
- Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
- Graphics::Surface *surface = new Graphics::Surface();
- surface->create(_surface->w, _surface->h, pixelFormat);
-
- for (uint16 i = 0; i < _surface->h; i++) {
- for (uint16 j = 0; j < _surface->w; j++) {
- byte palIndex = *((byte *)_surface->pixels + i * _surface->pitch + j);
- byte r = _palette[palIndex * 3 + 0];
- byte g = _palette[palIndex * 3 + 1];
- byte b = _palette[palIndex * 3 + 2];
- if (pixelFormat.bytesPerPixel == 2)
- *((uint16 *)surface->getBasePtr(j, i)) = pixelFormat.RGBToColor(r, g, b);
- else
- *((uint32 *)surface->getBasePtr(j, i)) = pixelFormat.RGBToColor(r, g, b);
- }
- }
+ Graphics::Surface *surface = _surface->convertTo(g_system->getScreenFormat(), _palette);
// Free everything and set the new surface as the converted surface
_surface->free();
diff --git a/engines/mohawk/myst_graphics.cpp b/engines/mohawk/myst_graphics.cpp
index 151390580f..86eb4f2b1b 100644
--- a/engines/mohawk/myst_graphics.cpp
+++ b/engines/mohawk/myst_graphics.cpp
@@ -29,7 +29,7 @@
#include "common/textconsole.h"
#include "engines/util.h"
#include "graphics/jpeg.h"
-#include "graphics/pict.h"
+#include "graphics/decoders/pict.h"
namespace Mohawk {
@@ -51,10 +51,8 @@ MystGraphics::MystGraphics(MohawkEngine_Myst* vm) : GraphicsManager(), _vm(vm) {
if (_vm->getFeatures() & GF_ME) {
_jpegDecoder = new Graphics::JPEG();
- _pictDecoder = new Graphics::PictDecoder(_pixelFormat);
} else {
_jpegDecoder = NULL;
- _pictDecoder = NULL;
}
_pictureFile.entries = NULL;
@@ -70,7 +68,6 @@ MystGraphics::MystGraphics(MohawkEngine_Myst* vm) : GraphicsManager(), _vm(vm) {
MystGraphics::~MystGraphics() {
delete _bmpDecoder;
delete _jpegDecoder;
- delete _pictDecoder;
delete[] _pictureFile.entries;
_backBuffer->free();
@@ -138,7 +135,13 @@ MohawkSurface *MystGraphics::decodeImage(uint16 id) {
mhkSurface = new MohawkSurface(_jpegDecoder->getSurface(_pixelFormat));
delete stream;
} else if (_pictureFile.entries[i].type == 1) {
- mhkSurface = new MohawkSurface(_pictDecoder->decodeImage(new Common::SeekableSubReadStream(&_pictureFile.picFile, _pictureFile.entries[i].offset, _pictureFile.entries[i].offset + _pictureFile.entries[i].size)));
+ Graphics::PICTDecoder pict;
+ Common::SeekableSubReadStream subStream(&_pictureFile.picFile, _pictureFile.entries[i].offset, _pictureFile.entries[i].offset + _pictureFile.entries[i].size);
+
+ if (!pict.loadStream(subStream))
+ error("Could not decode Myst ME Mac PICT");
+
+ mhkSurface = new MohawkSurface(pict.getSurface()->convertTo(_pixelFormat));
} else
error ("Unknown Picture File type %d", _pictureFile.entries[i].type);
break;
@@ -170,9 +173,14 @@ MohawkSurface *MystGraphics::decodeImage(uint16 id) {
dataStream->seek(0);
}
- if (isPict)
- mhkSurface = new MohawkSurface(_pictDecoder->decodeImage(dataStream));
- else {
+ if (isPict) {
+ Graphics::PICTDecoder pict;
+
+ if (!pict.loadStream(*dataStream))
+ error("Could not decode Myst ME PICT");
+
+ mhkSurface = new MohawkSurface(pict.getSurface()->convertTo(_pixelFormat));
+ } else {
mhkSurface = _bmpDecoder->decodeImage(dataStream);
mhkSurface->convertToTrueColor();
}
diff --git a/engines/mohawk/myst_graphics.h b/engines/mohawk/myst_graphics.h
index e2b02db5fc..8074c9828b 100644
--- a/engines/mohawk/myst_graphics.h
+++ b/engines/mohawk/myst_graphics.h
@@ -29,7 +29,6 @@
namespace Graphics {
class JPEG;
-class PictDecoder;
}
namespace Mohawk {
@@ -70,7 +69,6 @@ protected:
private:
MohawkEngine_Myst *_vm;
MystBitmap *_bmpDecoder;
- Graphics::PictDecoder *_pictDecoder;
Graphics::JPEG *_jpegDecoder;
struct PictureFile {