diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/groovie/groovie.cpp | 32 | ||||
-rw-r--r-- | engines/groovie/roq.cpp | 6 | ||||
-rw-r--r-- | engines/hugo/dialogs.cpp | 15 | ||||
-rw-r--r-- | engines/mohawk/bitmap.cpp | 101 | ||||
-rw-r--r-- | engines/mohawk/bitmap.h | 24 | ||||
-rw-r--r-- | engines/mohawk/graphics.cpp | 17 | ||||
-rw-r--r-- | engines/mohawk/myst_graphics.cpp | 41 | ||||
-rw-r--r-- | engines/mohawk/myst_graphics.h | 7 | ||||
-rw-r--r-- | engines/mohawk/video.cpp | 20 | ||||
-rw-r--r-- | engines/sci/graphics/maciconbar.cpp | 18 | ||||
-rw-r--r-- | engines/sci/graphics/maciconbar.h | 2 | ||||
-rw-r--r-- | engines/sword25/gfx/image/imgloader.cpp | 13 |
12 files changed, 98 insertions, 198 deletions
diff --git a/engines/groovie/groovie.cpp b/engines/groovie/groovie.cpp index f5f02b5cdd..726e7cbede 100644 --- a/engines/groovie/groovie.cpp +++ b/engines/groovie/groovie.cpp @@ -152,20 +152,26 @@ Common::Error GroovieEngine::run() { break; } - // Create the music player - switch (getPlatform()) { - case Common::kPlatformMacintosh: - // TODO: The 11th Hour Mac uses QuickTime MIDI files - // Right now, since the XMIDI are present and it is still detected as - // the DOS version, we don't have to do anything here. - _musicPlayer = new MusicPlayerMac(this); - break; - case Common::kPlatformIOS: + // Detect ScummVM Music Enhancement Project presence (T7G only) + if (Common::File::exists("gu16.ogg") && _gameDescription->version == kGroovieT7G) { + // Load player for external files _musicPlayer = new MusicPlayerIOS(this); - break; - default: - _musicPlayer = new MusicPlayerXMI(this, _gameDescription->version == kGroovieT7G ? "fat" : "sample"); - break; + } else { + // Create the music player + switch (getPlatform()) { + case Common::kPlatformMacintosh: + // TODO: The 11th Hour Mac uses QuickTime MIDI files + // Right now, since the XMIDI are present and it is still detected as + // the DOS version, we don't have to do anything here. + _musicPlayer = new MusicPlayerMac(this); + break; + case Common::kPlatformIOS: + _musicPlayer = new MusicPlayerIOS(this); + break; + default: + _musicPlayer = new MusicPlayerXMI(this, _gameDescription->version == kGroovieT7G ? "fat" : "sample"); + break; + } } // Load volume levels diff --git a/engines/groovie/roq.cpp b/engines/groovie/roq.cpp index 53f335ce68..8da8671b5d 100644 --- a/engines/groovie/roq.cpp +++ b/engines/groovie/roq.cpp @@ -30,8 +30,8 @@ #include "common/debug.h" #include "common/textconsole.h" -#include "graphics/jpeg.h" #include "graphics/palette.h" +#include "graphics/decoders/jpeg.h" #ifdef USE_RGB_COLOR // Required for the YUV to RGB conversion @@ -435,8 +435,8 @@ bool ROQPlayer::processBlockStill(ROQBlockHeader &blockHeader) { warning("Groovie::ROQ: JPEG frame (unfinshed)"); - Graphics::JPEG *jpg = new Graphics::JPEG(); - jpg->read(_file); + Graphics::JPEGDecoder *jpg = new Graphics::JPEGDecoder(); + jpg->loadStream(*_file); byte *y = (byte *)jpg->getComponent(1)->getBasePtr(0, 0); byte *u = (byte *)jpg->getComponent(2)->getBasePtr(0, 0); byte *v = (byte *)jpg->getComponent(3)->getBasePtr(0, 0); diff --git a/engines/hugo/dialogs.cpp b/engines/hugo/dialogs.cpp index c43cdd7b46..e0b0198470 100644 --- a/engines/hugo/dialogs.cpp +++ b/engines/hugo/dialogs.cpp @@ -21,7 +21,7 @@ */ #include "common/substream.h" -#include "graphics/imagedec.h" +#include "graphics/decoders/bmp.h" #include "gui/gui-manager.h" #include "gui/ThemeEval.h" @@ -128,7 +128,16 @@ void TopMenu::loadBmpArr(Common::SeekableReadStream &in) { uint16 bmpSize = in.readUint16BE(); uint32 filPos = in.pos(); Common::SeekableSubReadStream stream(&in, filPos, filPos + bmpSize); - arrayBmp[i * 2] = Graphics::ImageDecoder::loadFile(stream, g_system->getOverlayFormat()); + + Graphics::BitmapDecoder bitmapDecoder; + if (!bitmapDecoder.loadStream(stream)) + error("TopMenu::loadBmpArr(): Could not load bitmap"); + + const Graphics::Surface *bitmapSrc = bitmapDecoder.getSurface(); + if (bitmapSrc->format.bytesPerPixel == 1) + error("TopMenu::loadBmpArr(): Unhandled paletted image"); + + arrayBmp[i * 2] = bitmapSrc->convertTo(g_system->getOverlayFormat()); arrayBmp[i * 2 + 1] = new Graphics::Surface(); arrayBmp[i * 2 + 1]->create(arrayBmp[i * 2]->w * 2, arrayBmp[i * 2]->h * 2, g_system->getOverlayFormat()); byte *src = (byte *)arrayBmp[i * 2]->pixels; @@ -154,7 +163,7 @@ void TopMenu::loadBmpArr(Common::SeekableReadStream &in) { } } - in.skip(bmpSize); + in.seek(filPos + bmpSize); } } diff --git a/engines/mohawk/bitmap.cpp b/engines/mohawk/bitmap.cpp index 4edde31236..952b6daec2 100644 --- a/engines/mohawk/bitmap.cpp +++ b/engines/mohawk/bitmap.cpp @@ -29,6 +29,7 @@ #include "common/substream.h" #include "common/system.h" #include "common/textconsole.h" +#include "graphics/decoders/bmp.h" namespace Mohawk { @@ -631,97 +632,37 @@ void MohawkBitmap::drawRLE8(Graphics::Surface *surface, bool isLE) { MohawkSurface *MystBitmap::decodeImage(Common::SeekableReadStream* stream) { uint32 uncompressedSize = stream->readUint32LE(); - Common::SeekableReadStream* bmpStream = decompressLZ(stream, uncompressedSize); + Common::SeekableReadStream *bmpStream = decompressLZ(stream, uncompressedSize); delete stream; - _header.type = bmpStream->readUint16BE(); + Graphics::BitmapDecoder bitmapDecoder; + if (!bitmapDecoder.loadStream(*bmpStream)) + error("Could not decode Myst bitmap"); - if (_header.type != 'BM') - error("BMP header not detected"); + const Graphics::Surface *bmpSurface = bitmapDecoder.getSurface(); + Graphics::Surface *newSurface = 0; - _header.size = bmpStream->readUint32LE(); - assert (_header.size > 0); - _header.res1 = bmpStream->readUint16LE(); - _header.res2 = bmpStream->readUint16LE(); - _header.imageOffset = bmpStream->readUint32LE(); - - _info.size = bmpStream->readUint32LE(); - - if (_info.size != 40) - error("Only Windows v3 BMP's are supported"); - - _info.width = bmpStream->readUint32LE(); - _info.height = bmpStream->readUint32LE(); - _info.planes = bmpStream->readUint16LE(); - _info.bitsPerPixel = bmpStream->readUint16LE(); - _info.compression = bmpStream->readUint32LE(); - _info.imageSize = bmpStream->readUint32LE(); - _info.pixelsPerMeterX = bmpStream->readUint32LE(); - _info.pixelsPerMeterY = bmpStream->readUint32LE(); - _info.colorsUsed = bmpStream->readUint32LE(); - _info.colorsImportant = bmpStream->readUint32LE(); - - if (_info.compression != 0) - error("Unhandled BMP compression %d", _info.compression); - - if (_info.colorsUsed == 0) - _info.colorsUsed = 256; - - if (_info.bitsPerPixel != 8 && _info.bitsPerPixel != 24) - error("%dbpp Bitmaps not supported", _info.bitsPerPixel); - - byte *palData = NULL; - - if (_info.bitsPerPixel == 8) { - palData = (byte *)malloc(256 * 3); - for (uint16 i = 0; i < _info.colorsUsed; i++) { - palData[i * 3 + 2] = bmpStream->readByte(); - palData[i * 3 + 1] = bmpStream->readByte(); - palData[i * 3 + 0] = bmpStream->readByte(); - bmpStream->readByte(); - } - } - - bmpStream->seek(_header.imageOffset); - - Graphics::Surface *surface = createSurface(_info.width, _info.height); - int srcPitch = _info.width * (_info.bitsPerPixel >> 3); - const int extraDataLength = (srcPitch % 4) ? 4 - (srcPitch % 4) : 0; - - if (_info.bitsPerPixel == 8) { - byte *dst = (byte *)surface->pixels; - - for (uint32 i = 0; i < _info.height; i++) { - bmpStream->read(dst + (_info.height - i - 1) * _info.width, _info.width); - bmpStream->skip(extraDataLength); - } + if (bmpSurface->format.bytesPerPixel == 1) { + _bitsPerPixel = 8; + newSurface = new Graphics::Surface(); + newSurface->copyFrom(*bmpSurface); } else { - Graphics::PixelFormat pixelFormat = g_system->getScreenFormat(); - - byte *dst = (byte *)surface->pixels + (surface->h - 1) * surface->pitch; - - for (uint32 i = 0; i < _info.height; i++) { - for (uint32 j = 0; j < _info.width; j++) { - byte b = bmpStream->readByte(); - byte g = bmpStream->readByte(); - byte r = bmpStream->readByte(); + _bitsPerPixel = 24; + newSurface = bmpSurface->convertTo(g_system->getScreenFormat()); + } - if (pixelFormat.bytesPerPixel == 2) - *((uint16 *)dst) = pixelFormat.RGBToColor(r, g, b); - else - *((uint32 *)dst) = pixelFormat.RGBToColor(r, g, b); + // Copy the palette to one of our own + const byte *palette = bitmapDecoder.getPalette(); + byte *newPal = 0; - dst += pixelFormat.bytesPerPixel; - } - - bmpStream->skip(extraDataLength); - dst -= surface->pitch * 2; - } + if (palette) { + newPal = (byte *)malloc(256 * 3); + memcpy(newPal, palette, 256 * 3); } delete bmpStream; - return new MohawkSurface(surface, palData); + return new MohawkSurface(newSurface, newPal); } #endif diff --git a/engines/mohawk/bitmap.h b/engines/mohawk/bitmap.h index 74218882e8..73c117b5c7 100644 --- a/engines/mohawk/bitmap.h +++ b/engines/mohawk/bitmap.h @@ -154,30 +154,10 @@ public: MohawkSurface *decodeImage(Common::SeekableReadStream *stream); protected: - byte getBitsPerPixel() { return _info.bitsPerPixel; } + byte getBitsPerPixel() { return _bitsPerPixel; } private: - struct BitmapHeader { - uint16 type; - uint32 size; - uint16 res1; - uint16 res2; - uint32 imageOffset; - } _header; - - struct InfoHeader { - uint32 size; - uint32 width; - uint32 height; - uint16 planes; - uint16 bitsPerPixel; - uint32 compression; - uint32 imageSize; - uint32 pixelsPerMeterX; - uint32 pixelsPerMeterY; - uint32 colorsUsed; - uint32 colorsImportant; - } _info; + uint16 _bitsPerPixel; }; #endif 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..484e49d529 100644 --- a/engines/mohawk/myst_graphics.cpp +++ b/engines/mohawk/myst_graphics.cpp @@ -28,8 +28,8 @@ #include "common/system.h" #include "common/textconsole.h" #include "engines/util.h" -#include "graphics/jpeg.h" -#include "graphics/pict.h" +#include "graphics/decoders/jpeg.h" +#include "graphics/decoders/pict.h" namespace Mohawk { @@ -49,14 +49,6 @@ MystGraphics::MystGraphics(MohawkEngine_Myst* vm) : GraphicsManager(), _vm(vm) { if (_pixelFormat.bytesPerPixel == 1) error("Myst requires greater than 256 colors to run"); - if (_vm->getFeatures() & GF_ME) { - _jpegDecoder = new Graphics::JPEG(); - _pictDecoder = new Graphics::PictDecoder(_pixelFormat); - } else { - _jpegDecoder = NULL; - _pictDecoder = NULL; - } - _pictureFile.entries = NULL; // Initialize our buffer @@ -69,8 +61,6 @@ MystGraphics::MystGraphics(MohawkEngine_Myst* vm) : GraphicsManager(), _vm(vm) { MystGraphics::~MystGraphics() { delete _bmpDecoder; - delete _jpegDecoder; - delete _pictDecoder; delete[] _pictureFile.entries; _backBuffer->free(); @@ -130,15 +120,21 @@ MohawkSurface *MystGraphics::decodeImage(uint16 id) { for (uint32 i = 0; i < _pictureFile.pictureCount; i++) if (_pictureFile.entries[i].id == id) { if (_pictureFile.entries[i].type == 0) { - Common::SeekableReadStream *stream = new Common::SeekableSubReadStream(&_pictureFile.picFile, _pictureFile.entries[i].offset, _pictureFile.entries[i].offset + _pictureFile.entries[i].size); + Graphics::JPEGDecoder jpeg; + Common::SeekableSubReadStream subStream(&_pictureFile.picFile, _pictureFile.entries[i].offset, _pictureFile.entries[i].offset + _pictureFile.entries[i].size); - if (!_jpegDecoder->read(stream)) + if (!jpeg.loadStream(subStream)) error("Could not decode Myst ME Mac JPEG"); - mhkSurface = new MohawkSurface(_jpegDecoder->getSurface(_pixelFormat)); - delete stream; + mhkSurface = new MohawkSurface(jpeg.getSurface()->convertTo(_pixelFormat)); } 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 +166,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..20fd46c5b9 100644 --- a/engines/mohawk/myst_graphics.h +++ b/engines/mohawk/myst_graphics.h @@ -27,11 +27,6 @@ #include "common/file.h" -namespace Graphics { -class JPEG; -class PictDecoder; -} - namespace Mohawk { class MystBitmap; @@ -70,8 +65,6 @@ protected: private: MohawkEngine_Myst *_vm; MystBitmap *_bmpDecoder; - Graphics::PictDecoder *_pictDecoder; - Graphics::JPEG *_jpegDecoder; struct PictureFile { uint32 pictureCount; diff --git a/engines/mohawk/video.cpp b/engines/mohawk/video.cpp index 8d72fa3f72..80fa4bf9a0 100644 --- a/engines/mohawk/video.cpp +++ b/engines/mohawk/video.cpp @@ -235,25 +235,7 @@ bool VideoManager::updateMovies() { if (_videoStreams[i]->hasDirtyPalette()) _videoStreams[i]->setSystemPalette(); } else { - convertedFrame = new Graphics::Surface(); - const byte *palette = _videoStreams[i]->getPalette(); - assert(palette); - - convertedFrame->create(frame->w, frame->h, pixelFormat); - - for (uint16 j = 0; j < frame->h; j++) { - for (uint16 k = 0; k < frame->w; k++) { - byte palIndex = *((const byte *)frame->getBasePtr(k, j)); - byte r = palette[palIndex * 3]; - byte g = palette[palIndex * 3 + 1]; - byte b = palette[palIndex * 3 + 2]; - if (pixelFormat.bytesPerPixel == 2) - *((uint16 *)convertedFrame->getBasePtr(k, j)) = pixelFormat.RGBToColor(r, g, b); - else - *((uint32 *)convertedFrame->getBasePtr(k, j)) = pixelFormat.RGBToColor(r, g, b); - } - } - + convertedFrame = frame->convertTo(pixelFormat, _videoStreams[i]->getPalette()); frame = convertedFrame; } } 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); diff --git a/engines/sword25/gfx/image/imgloader.cpp b/engines/sword25/gfx/image/imgloader.cpp index 1df0fba70c..e103626416 100644 --- a/engines/sword25/gfx/image/imgloader.cpp +++ b/engines/sword25/gfx/image/imgloader.cpp @@ -33,18 +33,19 @@ #include "sword25/gfx/image/image.h" #include "sword25/gfx/image/imgloader.h" #include "graphics/pixelformat.h" -#include "graphics/png.h" +#include "graphics/decoders/png.h" namespace Sword25 { bool ImgLoader::decodePNGImage(const byte *fileDataPtr, uint fileSize, byte *&uncompressedDataPtr, int &width, int &height, int &pitch) { Common::MemoryReadStream *fileStr = new Common::MemoryReadStream(fileDataPtr, fileSize, DisposeAfterUse::NO); - Graphics::PNG *png = new Graphics::PNG(); - if (!png->read(fileStr)) // the fileStr pointer, and thus pFileData will be deleted after this is done + + Graphics::PNGDecoder png; + if (!png.loadStream(*fileStr)) // the fileStr pointer, and thus pFileData will be deleted after this is done error("Error while reading PNG image"); - Graphics::PixelFormat format = Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24); - Graphics::Surface *pngSurface = png->getSurface(format); + const Graphics::Surface *sourceSurface = png.getSurface(); + Graphics::Surface *pngSurface = sourceSurface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24), png.getPalette()); width = pngSurface->w; height = pngSurface->h; @@ -53,7 +54,7 @@ bool ImgLoader::decodePNGImage(const byte *fileDataPtr, uint fileSize, byte *&un pngSurface->free(); delete pngSurface; - delete png; + delete fileStr; // Signal success return true; |