IMAGE: Move all ImageDecoders to image/

This commit is contained in:
Matthew Hoops 2014-02-27 21:27:23 -05:00
parent cbf085287c
commit 740b6e8fbd
46 changed files with 199 additions and 188 deletions

View file

@ -25,6 +25,7 @@ MODULES += \
engines \ engines \
video \ video \
graphics \ graphics \
image \
audio \ audio \
common \ common \
po po

View file

@ -34,7 +34,7 @@
#include "common/tokenizer.h" #include "common/tokenizer.h"
#include "common/stream.h" #include "common/stream.h"
#include "graphics/decoders/bmp.h" #include "image/bmp.h"
namespace Common { namespace Common {
@ -267,7 +267,7 @@ bool VirtualKeyboardParser::parserCallback_layout(ParserNode *node) {
const Graphics::PixelFormat format = g_system->getOverlayFormat(); const Graphics::PixelFormat format = g_system->getOverlayFormat();
{ {
Graphics::BitmapDecoder bmp; Image::BitmapDecoder bmp;
if (!bmp.loadStream(*file)) if (!bmp.loadStream(*file))
return parserError("Error loading bitmap '" + _mode->bitmapName + "'"); return parserError("Error loading bitmap '" + _mode->bitmapName + "'");

View file

@ -1305,6 +1305,7 @@ void ProjectProvider::createProject(BuildSetup &setup) {
createModuleList(setup.srcDir + "/audio", setup.defines, setup.testDirs, in, ex); createModuleList(setup.srcDir + "/audio", setup.defines, setup.testDirs, in, ex);
createModuleList(setup.srcDir + "/audio/softsynth/mt32", setup.defines, setup.testDirs, in, ex); createModuleList(setup.srcDir + "/audio/softsynth/mt32", setup.defines, setup.testDirs, in, ex);
createModuleList(setup.srcDir + "/video", setup.defines, setup.testDirs, in, ex); createModuleList(setup.srcDir + "/video", setup.defines, setup.testDirs, in, ex);
createModuleList(setup.srcDir + "/image", setup.defines, setup.testDirs, in, ex);
// Resource files // Resource files
in.push_back(setup.srcDir + "/icons/" + setup.projectName + ".ico"); in.push_back(setup.srcDir + "/icons/" + setup.projectName + ".ico");

View file

@ -23,7 +23,7 @@
#include "dreamweb/dreamweb.h" #include "dreamweb/dreamweb.h"
#include "engines/util.h" #include "engines/util.h"
#include "graphics/surface.h" #include "graphics/surface.h"
#include "graphics/decoders/pcx.h" #include "image/pcx.h"
namespace DreamWeb { namespace DreamWeb {
@ -161,7 +161,7 @@ void DreamWebEngine::showPCX(const Common::String &suffix) {
return; return;
} }
Graphics::PCXDecoder pcx; Image::PCXDecoder pcx;
if (!pcx.loadStream(pcxFile)) { if (!pcx.loadStream(pcxFile)) {
warning("showpcx: Could not process '%s'", name.c_str()); warning("showpcx: Could not process '%s'", name.c_str());
return; return;

View file

@ -27,7 +27,8 @@
#include "graphics/cursorman.h" #include "graphics/cursorman.h"
#include "graphics/wincursor.h" #include "graphics/wincursor.h"
#include "graphics/decoders/iff.h"
#include "image/iff.h"
#include "gob/gob.h" #include "gob/gob.h"
#include "gob/global.h" #include "gob/global.h"
@ -547,7 +548,7 @@ void Inter_v7::o7_loadIFFPalette() {
return; return;
} }
Graphics::IFFDecoder decoder; Image::IFFDecoder decoder;
decoder.loadStream(*iffFile); decoder.loadStream(*iffFile);
if (!decoder.getPalette() || decoder.getPaletteColorCount() != 256) { if (!decoder.getPalette() || decoder.getPaletteColorCount() != 256) {
warning("o7_loadIFFPalette(): Failed reading palette from IFF \"%s\"", file.c_str()); warning("o7_loadIFFPalette(): Failed reading palette from IFF \"%s\"", file.c_str());

View file

@ -31,7 +31,8 @@
#include "graphics/primitives.h" #include "graphics/primitives.h"
#include "graphics/pixelformat.h" #include "graphics/pixelformat.h"
#include "graphics/surface.h" #include "graphics/surface.h"
#include "graphics/decoders/iff.h"
#include "image/iff.h"
namespace Gob { namespace Gob {
@ -814,7 +815,7 @@ bool Surface::loadTGA(Common::SeekableReadStream &stream) {
} }
bool Surface::loadIFF(Common::SeekableReadStream &stream) { bool Surface::loadIFF(Common::SeekableReadStream &stream) {
Graphics::IFFDecoder decoder; Image::IFFDecoder decoder;
decoder.loadStream(stream); decoder.loadStream(stream);
if (!decoder.getSurface()) if (!decoder.getSurface())

View file

@ -32,7 +32,7 @@
#include "common/textconsole.h" #include "common/textconsole.h"
#include "graphics/palette.h" #include "graphics/palette.h"
#include "graphics/decoders/jpeg.h" #include "image/jpeg.h"
#ifdef USE_RGB_COLOR #ifdef USE_RGB_COLOR
// Required for the YUV to RGB conversion // Required for the YUV to RGB conversion
@ -435,20 +435,18 @@ bool ROQPlayer::processBlockStill(ROQBlockHeader &blockHeader) {
warning("Groovie::ROQ: JPEG frame (unfinished)"); warning("Groovie::ROQ: JPEG frame (unfinished)");
Graphics::JPEGDecoder *jpg = new Graphics::JPEGDecoder(); Image::JPEGDecoder jpg;
jpg->setOutputColorSpace(Graphics::JPEGDecoder::kColorSpaceYUV); jpg.setOutputColorSpace(Image::JPEGDecoder::kColorSpaceYUV);
uint32 startPos = _file->pos(); uint32 startPos = _file->pos();
Common::SeekableSubReadStream subStream(_file, startPos, startPos + blockHeader.size, DisposeAfterUse::NO); Common::SeekableSubReadStream subStream(_file, startPos, startPos + blockHeader.size, DisposeAfterUse::NO);
jpg->loadStream(subStream); jpg.loadStream(subStream);
const Graphics::Surface *srcSurf = jpg->getSurface(); const Graphics::Surface *srcSurf = jpg.getSurface();
const byte *src = (const byte *)srcSurf->getPixels(); const byte *src = (const byte *)srcSurf->getPixels();
byte *ptr = (byte *)_currBuf->getPixels(); byte *ptr = (byte *)_currBuf->getPixels();
memcpy(ptr, src, _currBuf->w * _currBuf->h * srcSurf->format.bytesPerPixel); memcpy(ptr, src, _currBuf->w * _currBuf->h * srcSurf->format.bytesPerPixel);
delete jpg;
_file->seek(startPos + blockHeader.size); _file->seek(startPos + blockHeader.size);
return true; return true;
} }

View file

@ -28,7 +28,7 @@
#include "common/system.h" #include "common/system.h"
#include "graphics/palette.h" #include "graphics/palette.h"
#include "graphics/decoders/pcx.h" #include "image/pcx.h"
#include "common/file.h" #include "common/file.h"
#include "common/rect.h" #include "common/rect.h"
#include "engines/util.h" #include "engines/util.h"
@ -301,7 +301,7 @@ void GraphicsManager::fillSurface(byte *surface, byte *col, int size) {
void GraphicsManager::loadPCX640(byte *surface, const Common::String &file, byte *palette, bool typeFlag) { void GraphicsManager::loadPCX640(byte *surface, const Common::String &file, byte *palette, bool typeFlag) {
Common::File f; Common::File f;
Graphics::PCXDecoder pcxDecoder; Image::PCXDecoder pcxDecoder;
// Clear the passed surface // Clear the passed surface
memset(surface, 0, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); memset(surface, 0, SCREEN_WIDTH * 2 * SCREEN_HEIGHT);

View file

@ -21,9 +21,9 @@
*/ */
#include "common/substream.h" #include "common/substream.h"
#include "graphics/decoders/bmp.h"
#include "gui/gui-manager.h" #include "gui/gui-manager.h"
#include "gui/ThemeEval.h" #include "gui/ThemeEval.h"
#include "image/bmp.h"
#include "hugo/hugo.h" #include "hugo/hugo.h"
#include "hugo/display.h" #include "hugo/display.h"
@ -130,7 +130,7 @@ void TopMenu::loadBmpArr(Common::SeekableReadStream &in) {
uint32 filPos = in.pos(); uint32 filPos = in.pos();
Common::SeekableSubReadStream stream(&in, filPos, filPos + bmpSize); Common::SeekableSubReadStream stream(&in, filPos, filPos + bmpSize);
Graphics::BitmapDecoder bitmapDecoder; Image::BitmapDecoder bitmapDecoder;
if (!bitmapDecoder.loadStream(stream)) if (!bitmapDecoder.loadStream(stream))
error("TopMenu::loadBmpArr(): Could not load bitmap"); error("TopMenu::loadBmpArr(): Could not load bitmap");

View file

@ -34,11 +34,12 @@
#include "common/config-manager.h" #include "common/config-manager.h"
#include "graphics/surface.h" #include "graphics/surface.h"
#include "graphics/decoders/pcx.h"
#include "graphics/thumbnail.h" #include "graphics/thumbnail.h"
#include "gui/saveload.h" #include "gui/saveload.h"
#include "image/pcx.h"
#include "hugo/hugo.h" #include "hugo/hugo.h"
#include "hugo/file.h" #include "hugo/file.h"
#include "hugo/schedule.h" #include "hugo/schedule.h"
@ -110,7 +111,7 @@ Seq *FileManager::readPCX(Common::SeekableReadStream &f, Seq *seqPtr, byte *imag
error("Insufficient memory to run game."); error("Insufficient memory to run game.");
} }
Graphics::PCXDecoder pcx; Image::PCXDecoder pcx;
if (!pcx.loadStream(f)) if (!pcx.loadStream(f))
error("Error while reading PCX image"); error("Error while reading PCX image");

View file

@ -29,7 +29,7 @@
#include "common/substream.h" #include "common/substream.h"
#include "common/system.h" #include "common/system.h"
#include "common/textconsole.h" #include "common/textconsole.h"
#include "graphics/decoders/bmp.h" #include "image/bmp.h"
namespace Mohawk { namespace Mohawk {
@ -635,7 +635,7 @@ MohawkSurface *MystBitmap::decodeImage(Common::SeekableReadStream *stream) {
Common::SeekableReadStream *bmpStream = decompressLZ(stream, uncompressedSize); Common::SeekableReadStream *bmpStream = decompressLZ(stream, uncompressedSize);
delete stream; delete stream;
Graphics::BitmapDecoder bitmapDecoder; Image::BitmapDecoder bitmapDecoder;
if (!bitmapDecoder.loadStream(*bmpStream)) if (!bitmapDecoder.loadStream(*bmpStream))
error("Could not decode Myst bitmap"); error("Could not decode Myst bitmap");

View file

@ -28,8 +28,7 @@
#include "common/system.h" #include "common/system.h"
#include "common/textconsole.h" #include "common/textconsole.h"
#include "engines/util.h" #include "engines/util.h"
#include "graphics/decoders/jpeg.h" #include "image/pict.h"
#include "graphics/decoders/pict.h"
namespace Mohawk { namespace Mohawk {
@ -94,7 +93,7 @@ MohawkSurface *MystGraphics::decodeImage(uint16 id) {
MohawkSurface *mhkSurface = 0; MohawkSurface *mhkSurface = 0;
if (isPict) { if (isPict) {
Graphics::PICTDecoder pict; Image::PICTDecoder pict;
if (!pict.loadStream(*dataStream)) if (!pict.loadStream(*dataStream))
error("Could not decode Myst ME PICT"); error("Could not decode Myst ME PICT");

View file

@ -23,7 +23,7 @@
#include "common/config-manager.h" #include "common/config-manager.h"
#include "common/fs.h" #include "common/fs.h"
#include "common/textconsole.h" #include "common/textconsole.h"
#include "graphics/decoders/iff.h" #include "image/iff.h"
#include "parallaction/parallaction.h" #include "parallaction/parallaction.h"
#include "parallaction/parser.h" #include "parallaction/parser.h"
@ -460,7 +460,7 @@ void AmigaDisk_br::loadBackground(BackgroundInfo& info, const char *filename) {
byte r,g,b; byte r,g,b;
const byte *p; const byte *p;
Common::SeekableReadStream *stream; Common::SeekableReadStream *stream;
Graphics::IFFDecoder decoder; Image::IFFDecoder decoder;
uint i; uint i;
stream = tryOpenFile("backs/" + Common::String(filename), ".ap"); stream = tryOpenFile("backs/" + Common::String(filename), ".ap");
@ -544,7 +544,7 @@ MaskBuffer *AmigaDisk_br::loadMask(const char *name, uint32 w, uint32 h) {
return 0; return 0;
} }
Graphics::IFFDecoder decoder; Image::IFFDecoder decoder;
decoder.setNumRelevantPlanes(2); // use only 2 first bits from each pixels decoder.setNumRelevantPlanes(2); // use only 2 first bits from each pixels
decoder.setPixelPacking(true); // pack 4 2bit pixels into 1 byte decoder.setPixelPacking(true); // pack 4 2bit pixels into 1 byte
decoder.loadStream(*stream); decoder.loadStream(*stream);
@ -583,7 +583,7 @@ GfxObj* AmigaDisk_br::loadStatic(const char* name) {
Common::String sName = name; Common::String sName = name;
Common::SeekableReadStream *stream = openFile("ras/" + sName, ".ras"); Common::SeekableReadStream *stream = openFile("ras/" + sName, ".ras");
Graphics::IFFDecoder decoder; Image::IFFDecoder decoder;
decoder.loadStream(*stream); decoder.loadStream(*stream);
Graphics::Surface *surf = new Graphics::Surface; Graphics::Surface *surf = new Graphics::Surface;
@ -720,7 +720,7 @@ GfxObj* AmigaDisk_br::loadObjects(const char *name, uint8 part) {
debugC(5, kDebugDisk, "AmigaDisk_br::loadObjects"); debugC(5, kDebugDisk, "AmigaDisk_br::loadObjects");
Common::SeekableReadStream *stream = openFile(name); Common::SeekableReadStream *stream = openFile(name);
Graphics::IFFDecoder decoder; Image::IFFDecoder decoder;
decoder.loadStream(*stream); decoder.loadStream(*stream);
uint16 max = objectsMax[part]; uint16 max = objectsMax[part];

View file

@ -26,7 +26,7 @@
#include "common/memstream.h" #include "common/memstream.h"
#include "common/substream.h" #include "common/substream.h"
#include "common/textconsole.h" #include "common/textconsole.h"
#include "graphics/decoders/iff.h" #include "image/iff.h"
#include "parallaction/parser.h" #include "parallaction/parser.h"
#include "parallaction/parallaction.h" #include "parallaction/parallaction.h"
@ -917,7 +917,7 @@ void AmigaDisk_ns::buildMask(byte* buf) {
void AmigaDisk_ns::loadBackground(BackgroundInfo& info, const char *name) { void AmigaDisk_ns::loadBackground(BackgroundInfo& info, const char *name) {
Common::SeekableReadStream *s = openFile(name); Common::SeekableReadStream *s = openFile(name);
Graphics::IFFDecoder decoder; Image::IFFDecoder decoder;
decoder.loadStream(*s); decoder.loadStream(*s);
info.bg.copyFrom(*decoder.getSurface()); info.bg.copyFrom(*decoder.getSurface());
@ -935,7 +935,7 @@ void AmigaDisk_ns::loadBackground(BackgroundInfo& info, const char *name) {
info.palette.setEntry(i, r, g, b); info.palette.setEntry(i, r, g, b);
} }
const Common::Array<Graphics::IFFDecoder::PaletteRange> &paletteRanges = decoder.getPaletteRanges(); const Common::Array<Image::IFFDecoder::PaletteRange> &paletteRanges = decoder.getPaletteRanges();
for (uint j = 0; j < 6 && j < paletteRanges.size(); j++) { for (uint j = 0; j < 6 && j < paletteRanges.size(); j++) {
PaletteFxRange range; PaletteFxRange range;
range._timer = paletteRanges[j].timer; range._timer = paletteRanges[j].timer;
@ -959,7 +959,7 @@ void AmigaDisk_ns::loadMask_internal(BackgroundInfo& info, const char *name) {
return; // no errors if missing mask files: not every location has one return; // no errors if missing mask files: not every location has one
} }
Graphics::IFFDecoder decoder; Image::IFFDecoder decoder;
decoder.setNumRelevantPlanes(2); // use only 2 first bits from each pixel decoder.setNumRelevantPlanes(2); // use only 2 first bits from each pixel
decoder.setPixelPacking(true); // pack 4 2bit pixels into 1 byte decoder.setPixelPacking(true); // pack 4 2bit pixels into 1 byte
decoder.loadStream(*s); decoder.loadStream(*s);
@ -990,7 +990,7 @@ void AmigaDisk_ns::loadPath_internal(BackgroundInfo& info, const char *name) {
return; // no errors if missing path files: not every location has one return; // no errors if missing path files: not every location has one
} }
Graphics::IFFDecoder decoder; Image::IFFDecoder decoder;
decoder.setNumRelevantPlanes(1); // use only first bit from each pixel decoder.setNumRelevantPlanes(1); // use only first bit from each pixel
decoder.setPixelPacking(true); // pack 8 1bit pixels into 1 byte decoder.setPixelPacking(true); // pack 8 1bit pixels into 1 byte
decoder.loadStream(*s); decoder.loadStream(*s);

View file

@ -28,7 +28,7 @@
#include "common/system.h" #include "common/system.h"
#include "graphics/cursorman.h" #include "graphics/cursorman.h"
#include "graphics/surface.h" #include "graphics/surface.h"
#include "graphics/decoders/pict.h" #include "image/pict.h"
#include "pegasus/cursor.h" #include "pegasus/cursor.h"
#include "pegasus/graphics.h" #include "pegasus/graphics.h"
@ -148,7 +148,7 @@ void Cursor::loadCursorImage(CursorInfo &cursorInfo) {
Common::SeekableReadStream *pictStream = vm->_resFork->getResource(MKTAG('P', 'I', 'C', 'T'), cursorInfo.tag + 1000); Common::SeekableReadStream *pictStream = vm->_resFork->getResource(MKTAG('P', 'I', 'C', 'T'), cursorInfo.tag + 1000);
if (pictStream) { if (pictStream) {
Graphics::PICTDecoder pict; Image::PICTDecoder pict;
if (!pict.loadStream(*pictStream)) if (!pict.loadStream(*pictStream))
error("Failed to decode cursor PICT %d", cursorInfo.tag + 1000); error("Failed to decode cursor PICT %d", cursorInfo.tag + 1000);
@ -166,7 +166,7 @@ void Cursor::loadCursorImage(CursorInfo &cursorInfo) {
error("Failed to find color icon %d", cursorInfo.tag); error("Failed to find color icon %d", cursorInfo.tag);
// PixMap section // PixMap section
Graphics::PICTDecoder::PixMap pixMap = Graphics::PICTDecoder::readPixMap(*cicnStream); Image::PICTDecoder::PixMap pixMap = Image::PICTDecoder::readPixMap(*cicnStream);
// Mask section // Mask section
cicnStream->readUint32BE(); // mask baseAddr cicnStream->readUint32BE(); // mask baseAddr

View file

@ -28,7 +28,7 @@
#include "common/stream.h" #include "common/stream.h"
#include "common/system.h" #include "common/system.h"
#include "graphics/surface.h" #include "graphics/surface.h"
#include "graphics/decoders/pict.h" #include "image/pict.h"
#include "video/video_decoder.h" #include "video/video_decoder.h"
#include "pegasus/pegasus.h" #include "pegasus/pegasus.h"
@ -101,7 +101,7 @@ void Surface::getImageFromPICTResource(Common::MacResManager *resFork, uint16 id
} }
bool Surface::getImageFromPICTStream(Common::SeekableReadStream *stream) { bool Surface::getImageFromPICTStream(Common::SeekableReadStream *stream) {
Graphics::PICTDecoder pict; Image::PICTDecoder pict;
if (!pict.loadStream(*stream)) if (!pict.loadStream(*stream))
return false; return false;

View file

@ -29,8 +29,9 @@
#include "graphics/cursorman.h" #include "graphics/cursorman.h"
#include "graphics/palette.h" #include "graphics/palette.h"
#include "graphics/surface.h" #include "graphics/surface.h"
#include "graphics/decoders/iff.h"
#include "graphics/decoders/pcx.h" #include "image/iff.h"
#include "image/pcx.h"
#include "queen/display.h" #include "queen/display.h"
#include "queen/input.h" #include "queen/input.h"
@ -813,7 +814,7 @@ void Display::fill(uint8 *dstBuf, uint16 dstPitch, uint16 x, uint16 y, uint16 w,
void Display::decodePCX(const uint8 *src, uint32 srcSize, uint8 *dst, uint16 dstPitch, uint16 *w, uint16 *h, uint8 *pal, uint16 palStart, uint16 palEnd) { void Display::decodePCX(const uint8 *src, uint32 srcSize, uint8 *dst, uint16 dstPitch, uint16 *w, uint16 *h, uint8 *pal, uint16 palStart, uint16 palEnd) {
Common::MemoryReadStream str(src, srcSize); Common::MemoryReadStream str(src, srcSize);
::Graphics::PCXDecoder pcx; Image::PCXDecoder pcx;
if (!pcx.loadStream(str)) if (!pcx.loadStream(str))
error("Error while reading PCX image"); error("Error while reading PCX image");
@ -832,7 +833,7 @@ void Display::decodePCX(const uint8 *src, uint32 srcSize, uint8 *dst, uint16 dst
void Display::decodeIFF(const uint8 *src, uint32 srcSize, uint8 *dst, uint16 dstPitch, uint16 *w, uint16 *h, uint8 *pal, uint16 palStart, uint16 palEnd, uint8 colorBase) { void Display::decodeIFF(const uint8 *src, uint32 srcSize, uint8 *dst, uint16 dstPitch, uint16 *w, uint16 *h, uint8 *pal, uint16 palStart, uint16 palEnd, uint8 colorBase) {
Common::MemoryReadStream str(src, srcSize); Common::MemoryReadStream str(src, srcSize);
::Graphics::IFFDecoder iff; Image::IFFDecoder iff;
if (!iff.loadStream(str)) if (!iff.loadStream(str))
error("Error while reading IFF image"); error("Error while reading IFF image");

View file

@ -43,7 +43,7 @@
#include "common/util.h" #include "common/util.h"
#include "graphics/decoders/iff.h" #include "image/iff.h"
namespace Saga { namespace Saga {
@ -463,7 +463,7 @@ void Scene::changeScene(int16 sceneNumber, int actorsEntrance, SceneTransitionTy
_vm->_interface->setMode(kPanelSceneSubstitute); _vm->_interface->setMode(kPanelSceneSubstitute);
if (file.open(sceneSubstitutes[i].image)) { if (file.open(sceneSubstitutes[i].image)) {
Graphics::IFFDecoder decoder; Image::IFFDecoder decoder;
decoder.loadStream(file); decoder.loadStream(file);
pal = decoder.getPalette(); pal = decoder.getPalette();
rect.setWidth(decoder.getSurface()->w); rect.setWidth(decoder.getSurface()->w);

View file

@ -32,7 +32,7 @@
#include "common/memstream.h" #include "common/memstream.h"
#include "common/system.h" #include "common/system.h"
#include "graphics/surface.h" #include "graphics/surface.h"
#include "graphics/decoders/pict.h" #include "image/pict.h"
namespace Sci { namespace Sci {
@ -201,12 +201,12 @@ void GfxMacIconBar::setInventoryIcon(int16 icon) {
} }
Graphics::Surface *GfxMacIconBar::loadPict(ResourceId id) { Graphics::Surface *GfxMacIconBar::loadPict(ResourceId id) {
Graphics::PICTDecoder pictDecoder;
Resource *res = g_sci->getResMan()->findResource(id, false); Resource *res = g_sci->getResMan()->findResource(id, false);
if (!res || res->size == 0) if (!res || res->size == 0)
return 0; return 0;
Image::PICTDecoder pictDecoder;
Common::MemoryReadStream stream(res->data, res->size); Common::MemoryReadStream stream(res->data, res->size);
if (!pictDecoder.loadStream(stream)) if (!pictDecoder.loadStream(stream))
return 0; return 0;

View file

@ -33,14 +33,14 @@
#include "sword25/gfx/image/image.h" #include "sword25/gfx/image/image.h"
#include "sword25/gfx/image/imgloader.h" #include "sword25/gfx/image/imgloader.h"
#include "graphics/pixelformat.h" #include "graphics/pixelformat.h"
#include "graphics/decoders/png.h" #include "image/png.h"
namespace Sword25 { namespace Sword25 {
bool ImgLoader::decodePNGImage(const byte *fileDataPtr, uint fileSize, byte *&uncompressedDataPtr, int &width, int &height, int &pitch) { 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); Common::MemoryReadStream *fileStr = new Common::MemoryReadStream(fileDataPtr, fileSize, DisposeAfterUse::NO);
Graphics::PNGDecoder png; ::Image::PNGDecoder png;
if (!png.loadStream(*fileStr)) // the fileStr pointer, and thus pFileData will be deleted after this is done if (!png.loadStream(*fileStr)) // the fileStr pointer, and thus pFileData will be deleted after this is done
error("Error while reading PNG image"); error("Error while reading PNG image");

View file

@ -30,7 +30,8 @@
#include "audio/decoders/wave.h" #include "audio/decoders/wave.h"
#include "graphics/surface.h" #include "graphics/surface.h"
#include "graphics/decoders/pcx.h"
#include "image/pcx.h"
#include "tucker/tucker.h" #include "tucker/tucker.h"
#include "tucker/graphics.h" #include "tucker/graphics.h"
@ -302,7 +303,7 @@ void TuckerEngine::loadImage(const char *fname, uint8 *dst, int type) {
} }
} }
::Graphics::PCXDecoder pcx; Image::PCXDecoder pcx;
if (!pcx.loadStream(f)) if (!pcx.loadStream(f))
error("Error while reading PCX image"); error("Error while reading PCX image");

View file

@ -38,8 +38,8 @@
#include "engines/wintermute/base/sound/base_sound.h" #include "engines/wintermute/base/sound/base_sound.h"
#include "engines/wintermute/graphics/transparent_surface.h" #include "engines/wintermute/graphics/transparent_surface.h"
#include "engines/wintermute/wintermute.h" #include "engines/wintermute/wintermute.h"
#include "graphics/decoders/bmp.h"
#include "graphics/scaler.h" #include "graphics/scaler.h"
#include "image/bmp.h"
#include "common/memstream.h" #include "common/memstream.h"
#include "common/str.h" #include "common/str.h"
#include "common/system.h" #include "common/system.h"
@ -170,7 +170,7 @@ void BasePersistenceManager::getSaveStateDesc(int slot, SaveStateDescriptor &des
if (thumbSize > 0) { if (thumbSize > 0) {
Common::MemoryReadStream thumbStream(thumbData, thumbSize, DisposeAfterUse::NO); Common::MemoryReadStream thumbStream(thumbData, thumbSize, DisposeAfterUse::NO);
Graphics::BitmapDecoder bmpDecoder; Image::BitmapDecoder bmpDecoder;
if (bmpDecoder.loadStream(thumbStream)) { if (bmpDecoder.loadStream(thumbStream)) {
const Graphics::Surface *bmpSurface = bmpDecoder.getSurface(); const Graphics::Surface *bmpSurface = bmpDecoder.getSurface();
TransparentSurface *scaleableSurface = new TransparentSurface(*bmpSurface, false); TransparentSurface *scaleableSurface = new TransparentSurface(*bmpSurface, false);

View file

@ -29,11 +29,11 @@
#include "engines/wintermute/base/gfx/base_image.h" #include "engines/wintermute/base/gfx/base_image.h"
#include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/base/base_file_manager.h"
#include "engines/wintermute/graphics/transparent_surface.h" #include "engines/wintermute/graphics/transparent_surface.h"
#include "graphics/decoders/png.h"
#include "graphics/decoders/jpeg.h"
#include "graphics/decoders/bmp.h"
#include "graphics/decoders/tga.h"
#include "graphics/surface.h" #include "graphics/surface.h"
#include "image/png.h"
#include "image/jpeg.h"
#include "image/bmp.h"
#include "image/tga.h"
#include "common/textconsole.h" #include "common/textconsole.h"
#include "common/stream.h" #include "common/stream.h"
#include "common/system.h" #include "common/system.h"
@ -62,16 +62,14 @@ BaseImage::~BaseImage() {
bool BaseImage::loadFile(const Common::String &filename) { bool BaseImage::loadFile(const Common::String &filename) {
_filename = filename; _filename = filename;
_filename.toLowercase(); _filename.toLowercase();
if (filename.hasPrefix("savegame:")) { if (filename.hasPrefix("savegame:") || _filename.hasSuffix(".bmp")) {
_decoder = new Graphics::BitmapDecoder(); _decoder = new Image::BitmapDecoder();
} else if (_filename.hasSuffix(".png")) { } else if (_filename.hasSuffix(".png")) {
_decoder = new Graphics::PNGDecoder(); _decoder = new Image::PNGDecoder();
} else if (_filename.hasSuffix(".bmp")) {
_decoder = new Graphics::BitmapDecoder();
} else if (_filename.hasSuffix(".tga")) { } else if (_filename.hasSuffix(".tga")) {
_decoder = new Graphics::TGADecoder(); _decoder = new Image::TGADecoder();
} else if (_filename.hasSuffix(".jpg")) { } else if (_filename.hasSuffix(".jpg")) {
_decoder = new Graphics::JPEGDecoder(); _decoder = new Image::JPEGDecoder();
} else { } else {
error("BaseImage::loadFile : Unsupported fileformat %s", filename.c_str()); error("BaseImage::loadFile : Unsupported fileformat %s", filename.c_str());
} }

View file

@ -31,11 +31,14 @@
#include "graphics/surface.h" #include "graphics/surface.h"
#include "graphics/pixelformat.h" #include "graphics/pixelformat.h"
#include "graphics/decoders/image_decoder.h"
#include "common/endian.h" #include "common/endian.h"
#include "common/str.h" #include "common/str.h"
#include "common/stream.h" #include "common/stream.h"
namespace Image {
class ImageDecoder;
}
namespace Wintermute { namespace Wintermute {
class BaseSurface; class BaseSurface;
class BaseFileManager; class BaseFileManager;
@ -60,7 +63,7 @@ public:
void copyFrom(const Graphics::Surface *surface); void copyFrom(const Graphics::Surface *surface);
private: private:
Common::String _filename; Common::String _filename;
Graphics::ImageDecoder *_decoder; Image::ImageDecoder *_decoder;
const Graphics::Surface *_surface; const Graphics::Surface *_surface;
Graphics::Surface *_deletableSurface; Graphics::Surface *_deletableSurface;
const byte *_palette; const byte *_palette;

View file

@ -32,10 +32,6 @@
#include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" #include "engines/wintermute/base/gfx/osystem/base_render_osystem.h"
#include "engines/wintermute/base/gfx/base_image.h" #include "engines/wintermute/base/gfx/base_image.h"
#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/platform_osystem.h"
#include "graphics/decoders/png.h"
#include "graphics/decoders/bmp.h"
#include "graphics/decoders/jpeg.h"
#include "graphics/decoders/tga.h"
#include "engines/wintermute/graphics/transparent_surface.h" #include "engines/wintermute/graphics/transparent_surface.h"
#include "engines/wintermute/graphics/transform_tools.h" #include "engines/wintermute/graphics/transform_tools.h"
#include "graphics/pixelformat.h" #include "graphics/pixelformat.h"

View file

@ -32,7 +32,7 @@
#include "engines/util.h" #include "engines/util.h"
#include "graphics/decoders/tga.h" #include "image/tga.h"
namespace ZVision { namespace ZVision {
@ -238,7 +238,7 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics:
uint32 imageWidth; uint32 imageWidth;
uint32 imageHeight; uint32 imageHeight;
Graphics::TGADecoder tga; Image::TGADecoder tga;
uint16 *buffer; uint16 *buffer;
bool isTransposed = _renderTable.getRenderState() == RenderTable::PANORAMA; bool isTransposed = _renderTable.getRenderState() == RenderTable::PANORAMA;
// All ZVision images are in RGB 555 // All ZVision images are in RGB 555

View file

@ -21,14 +21,7 @@ MODULE_OBJS := \
VectorRenderer.o \ VectorRenderer.o \
VectorRendererSpec.o \ VectorRendererSpec.o \
wincursor.o \ wincursor.o \
yuv_to_rgb.o \ yuv_to_rgb.o
decoders/bmp.o \
decoders/iff.o \
decoders/jpeg.o \
decoders/pcx.o \
decoders/pict.o \
decoders/png.o \
decoders/tga.o
ifdef USE_SCALERS ifdef USE_SCALERS
MODULE_OBJS += \ MODULE_OBJS += \

View file

@ -34,7 +34,8 @@
#include "graphics/VectorRenderer.h" #include "graphics/VectorRenderer.h"
#include "graphics/fonts/bdf.h" #include "graphics/fonts/bdf.h"
#include "graphics/fonts/ttf.h" #include "graphics/fonts/ttf.h"
#include "graphics/decoders/bmp.h"
#include "image/bmp.h"
#include "gui/widget.h" #include "gui/widget.h"
#include "gui/ThemeEngine.h" #include "gui/ThemeEngine.h"
@ -638,7 +639,7 @@ bool ThemeEngine::addBitmap(const Common::String &filename) {
return true; return true;
// If not, try to load the bitmap via the BitmapDecoder class. // If not, try to load the bitmap via the BitmapDecoder class.
Graphics::BitmapDecoder bitmapDecoder; Image::BitmapDecoder bitmapDecoder;
const Graphics::Surface *srcSurface = 0; const Graphics::Surface *srcSurface = 0;
Common::ArchiveMemberList members; Common::ArchiveMemberList members;
_themeFiles.listMatchingMembers(members, filename); _themeFiles.listMatchingMembers(members, filename);

View file

@ -20,14 +20,14 @@
* *
*/ */
#include "image/bmp.h"
#include "common/stream.h" #include "common/stream.h"
#include "common/textconsole.h" #include "common/textconsole.h"
#include "graphics/pixelformat.h" #include "graphics/pixelformat.h"
#include "graphics/surface.h" #include "graphics/surface.h"
#include "graphics/decoders/bmp.h"
namespace Graphics { namespace Image {
BitmapDecoder::BitmapDecoder() { BitmapDecoder::BitmapDecoder() {
_surface = 0; _surface = 0;
@ -180,4 +180,4 @@ bool BitmapDecoder::loadStream(Common::SeekableReadStream &stream) {
return true; return true;
} }
} // End of namespace Graphics } // End of namespace Image

View file

@ -28,21 +28,22 @@
* - wintermute * - wintermute
*/ */
#ifndef GRAPHICS_DECODERS_BMP_H #ifndef IMAGE_BMP_H
#define GRAPHICS_DECODERS_BMP_H #define IMAGE_BMP_H
#include "common/scummsys.h" #include "common/scummsys.h"
#include "common/str.h" #include "common/str.h"
#include "graphics/decoders/image_decoder.h" #include "image/image_decoder.h"
namespace Common{ namespace Common {
class SeekableReadStream; class SeekableReadStream;
} }
namespace Graphics { namespace Graphics {
struct PixelFormat;
struct Surface; struct Surface;
}
namespace Image {
class BitmapDecoder : public ImageDecoder { class BitmapDecoder : public ImageDecoder {
public: public:
@ -52,16 +53,16 @@ public:
// ImageDecoder API // ImageDecoder API
void destroy(); void destroy();
virtual bool loadStream(Common::SeekableReadStream &stream); virtual bool loadStream(Common::SeekableReadStream &stream);
virtual const Surface *getSurface() const { return _surface; } virtual const Graphics::Surface *getSurface() const { return _surface; }
const byte *getPalette() const { return _palette; } const byte *getPalette() const { return _palette; }
uint16 getPaletteColorCount() const { return _paletteColorCount; } uint16 getPaletteColorCount() const { return _paletteColorCount; }
private: private:
Surface *_surface; Graphics::Surface *_surface;
byte *_palette; byte *_palette;
uint16 _paletteColorCount; uint16 _paletteColorCount;
}; };
} // End of namespace Graphics } // End of namespace Image
#endif #endif

View file

@ -20,13 +20,13 @@
* *
*/ */
#include "image/iff.h"
#include "common/iff_container.h" #include "common/iff_container.h"
#include "common/stream.h" #include "common/stream.h"
#include "common/util.h" #include "common/util.h"
#include "graphics/decoders/iff.h" namespace Image {
namespace Graphics {
IFFDecoder::IFFDecoder() { IFFDecoder::IFFDecoder() {
_surface = 0; _surface = 0;
@ -241,4 +241,4 @@ void IFFDecoder::packPixels(byte *scanlines, byte *data, const uint16 scanlinePi
} }
} }
} // End of namespace Graphics } // End of namespace Image

View file

@ -29,22 +29,24 @@
* - saga * - saga
*/ */
#ifndef GRAPHICS_DECODERS_IFF_H #ifndef IMAGE_IFF_H
#define GRAPHICS_DECODERS_IFF_H #define IMAGE_IFF_H
#include "common/array.h" #include "common/array.h"
#include "common/endian.h" #include "common/endian.h"
#include "graphics/surface.h" #include "graphics/surface.h"
#include "graphics/decoders/image_decoder.h"
#include "image/image_decoder.h"
namespace Common { namespace Common {
class SeekableReadStream; class SeekableReadStream;
} }
namespace Graphics { namespace Graphics {
struct Surface; struct Surface;
}
namespace Image {
class IFFDecoder : public ImageDecoder { class IFFDecoder : public ImageDecoder {
public: public:
@ -78,7 +80,7 @@ public:
void destroy(); void destroy();
bool loadStream(Common::SeekableReadStream &stream); bool loadStream(Common::SeekableReadStream &stream);
const Header *getHeader() const { return &_header; } const Header *getHeader() const { return &_header; }
const Surface *getSurface() const { return _surface; } const Graphics::Surface *getSurface() const { return _surface; }
const byte *getPalette() const { return _palette; } const byte *getPalette() const { return _palette; }
const Common::Array<PaletteRange> &getPaletteRanges() const { return _paletteRanges; } const Common::Array<PaletteRange> &getPaletteRanges() const { return _paletteRanges; }
uint16 getPaletteColorCount() const { return _paletteColorCount; } uint16 getPaletteColorCount() const { return _paletteColorCount; }
@ -104,7 +106,7 @@ public:
private: private:
Header _header; Header _header;
Surface *_surface; Graphics::Surface *_surface;
byte *_palette; byte *_palette;
Common::Array<PaletteRange> _paletteRanges; Common::Array<PaletteRange> _paletteRanges;
Type _type; Type _type;
@ -119,6 +121,6 @@ private:
void packPixels(byte *scanlines, byte *data, const uint16 scanlinePitch, const uint16 outPitch); void packPixels(byte *scanlines, byte *data, const uint16 scanlinePitch, const uint16 outPitch);
}; };
} // End of namespace Graphics } // End of namespace Image
#endif // GRAPHICS_DECODERS_IFF_H #endif

View file

@ -20,20 +20,21 @@
* *
*/ */
#ifndef GRAPHICS_DECODERS_IMAGEDECODER_H #ifndef IMAGE_IMAGEDECODER_H
#define GRAPHICS_DECODERS_IMAGEDECODER_H #define IMAGE_IMAGEDECODER_H
#include "common/scummsys.h" #include "common/scummsys.h"
#include "common/str.h" #include "common/str.h"
namespace Common{ namespace Common {
class SeekableReadStream; class SeekableReadStream;
} }
namespace Graphics { namespace Graphics {
struct PixelFormat;
struct Surface; struct Surface;
}
namespace Image {
/** /**
* A representation of an image decoder that maintains ownership of the surface * A representation of an image decoder that maintains ownership of the surface
@ -73,7 +74,7 @@ public:
* *
* @return the decoded surface, or 0 if no surface is present * @return the decoded surface, or 0 if no surface is present
*/ */
virtual const Surface *getSurface() const = 0; virtual const Graphics::Surface *getSurface() const = 0;
/** /**
* Get the decoded palette * Get the decoded palette
@ -100,6 +101,6 @@ public:
virtual uint16 getPaletteColorCount() const { return 0; } virtual uint16 getPaletteColorCount() const { return 0; }
}; };
} // End of namespace Graphics } // End of namespace Image
#endif #endif

View file

@ -24,13 +24,13 @@
// here. // here.
#define FORBIDDEN_SYMBOL_ALLOW_ALL #define FORBIDDEN_SYMBOL_ALLOW_ALL
#include "graphics/pixelformat.h" #include "image/jpeg.h"
#include "graphics/decoders/jpeg.h"
#include "common/debug.h" #include "common/debug.h"
#include "common/endian.h" #include "common/endian.h"
#include "common/stream.h" #include "common/stream.h"
#include "common/textconsole.h" #include "common/textconsole.h"
#include "graphics/pixelformat.h"
#ifdef USE_JPEG #ifdef USE_JPEG
// The original release of libjpeg v6b did not contain any extern "C" in case // The original release of libjpeg v6b did not contain any extern "C" in case
@ -42,7 +42,7 @@ extern "C" {
} }
#endif #endif
namespace Graphics { namespace Image {
JPEGDecoder::JPEGDecoder() : ImageDecoder(), _surface(), _colorSpace(kColorSpaceRGBA) { JPEGDecoder::JPEGDecoder() : ImageDecoder(), _surface(), _colorSpace(kColorSpaceRGBA) {
} }
@ -51,7 +51,7 @@ JPEGDecoder::~JPEGDecoder() {
destroy(); destroy();
} }
const Surface *JPEGDecoder::getSurface() const { const Graphics::Surface *JPEGDecoder::getSurface() const {
return &_surface; return &_surface;
} }

View file

@ -28,17 +28,17 @@
* - wintermute * - wintermute
*/ */
#ifndef GRAPHICS_JPEG_H #ifndef IMAGE_JPEG_H
#define GRAPHICS_JPEG_H #define IMAGE_JPEG_H
#include "graphics/surface.h" #include "graphics/surface.h"
#include "graphics/decoders/image_decoder.h" #include "image/image_decoder.h"
namespace Common { namespace Common {
class SeekableReadStream; class SeekableReadStream;
} }
namespace Graphics { namespace Image {
class JPEGDecoder : public ImageDecoder { class JPEGDecoder : public ImageDecoder {
public: public:
@ -48,7 +48,7 @@ public:
// ImageDecoder API // ImageDecoder API
virtual void destroy(); virtual void destroy();
virtual bool loadStream(Common::SeekableReadStream &str); virtual bool loadStream(Common::SeekableReadStream &str);
virtual const Surface *getSurface() const; virtual const Graphics::Surface *getSurface() const;
// Special API for JPEG // Special API for JPEG
enum ColorSpace { enum ColorSpace {

13
image/module.mk Normal file
View file

@ -0,0 +1,13 @@
MODULE := image
MODULE_OBJS := \
bmp.o \
iff.o \
jpeg.o \
pcx.o \
pict.o \
png.o \
tga.o
# Include common rules
include $(srcdir)/rules.mk

View file

@ -20,12 +20,12 @@
* *
*/ */
#include "image/pcx.h"
#include "common/stream.h" #include "common/stream.h"
#include "common/textconsole.h" #include "common/textconsole.h"
#include "graphics/pixelformat.h" #include "graphics/pixelformat.h"
#include "graphics/surface.h" #include "graphics/surface.h"
#include "graphics/decoders/pcx.h"
/** /**
* Based on the PCX specs: * Based on the PCX specs:
@ -34,7 +34,7 @@
* http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavcodec/pcx.c * http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavcodec/pcx.c
*/ */
namespace Graphics { namespace Image {
PCXDecoder::PCXDecoder() { PCXDecoder::PCXDecoder() {
_surface = 0; _surface = 0;
@ -211,4 +211,4 @@ void PCXDecoder::decodeRLE(Common::SeekableReadStream &stream, byte *dst, uint32
} }
} }
} // End of namespace Graphics } // End of namespace Image

View file

@ -28,21 +28,18 @@
* - tucker * - tucker
*/ */
#ifndef GRAPHICS_DECODERS_PCX_H #ifndef IMAGE_PCX_H
#define GRAPHICS_DECODERS_PCX_H #define IMAGE_PCX_H
#include "common/scummsys.h" #include "common/scummsys.h"
#include "common/str.h" #include "common/str.h"
#include "graphics/decoders/image_decoder.h" #include "image/image_decoder.h"
namespace Common{ namespace Common{
class SeekableReadStream; class SeekableReadStream;
} }
namespace Graphics { namespace Image {
struct PixelFormat;
struct Surface;
class PCXDecoder : public ImageDecoder { class PCXDecoder : public ImageDecoder {
public: public:
@ -52,18 +49,18 @@ public:
// ImageDecoder API // ImageDecoder API
void destroy(); void destroy();
virtual bool loadStream(Common::SeekableReadStream &stream); virtual bool loadStream(Common::SeekableReadStream &stream);
virtual const Surface *getSurface() const { return _surface; } virtual const Graphics::Surface *getSurface() const { return _surface; }
const byte *getPalette() const { return _palette; } const byte *getPalette() const { return _palette; }
uint16 getPaletteColorCount() const { return _paletteColorCount; } uint16 getPaletteColorCount() const { return _paletteColorCount; }
private: private:
void decodeRLE(Common::SeekableReadStream &stream, byte *dst, uint32 bytesPerScanline, bool compressed); void decodeRLE(Common::SeekableReadStream &stream, byte *dst, uint32 bytesPerScanline, bool compressed);
Surface *_surface; Graphics::Surface *_surface;
byte *_palette; byte *_palette;
uint16 _paletteColorCount; uint16 _paletteColorCount;
}; };
} // End of namespace Graphics } // End of namespace Image
#endif #endif

View file

@ -20,17 +20,17 @@
* *
*/ */
#include "image/jpeg.h"
#include "image/pict.h"
#include "common/debug.h" #include "common/debug.h"
#include "common/endian.h" #include "common/endian.h"
#include "common/stream.h" #include "common/stream.h"
#include "common/substream.h" #include "common/substream.h"
#include "common/textconsole.h" #include "common/textconsole.h"
#include "graphics/surface.h" #include "graphics/surface.h"
#include "graphics/decoders/jpeg.h"
#include "graphics/decoders/pict.h"
namespace Graphics { namespace Image {
// The PICT code is based off of the QuickDraw specs: // The PICT code is based off of the QuickDraw specs:
// http://developer.apple.com/legacy/mac/library/documentation/mac/QuickDraw/QuickDraw-461.html // http://developer.apple.com/legacy/mac/library/documentation/mac/QuickDraw/QuickDraw-461.html
@ -363,12 +363,12 @@ void PICTDecoder::unpackBitsRect(Common::SeekableReadStream &stream, bool withPa
switch (bytesPerPixel) { switch (bytesPerPixel) {
case 1: case 1:
// Just copy to the image // Just copy to the image
_outputSurface->create(width, height, PixelFormat::createFormatCLUT8()); _outputSurface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
memcpy(_outputSurface->getPixels(), buffer, _outputSurface->w * _outputSurface->h); memcpy(_outputSurface->getPixels(), buffer, _outputSurface->w * _outputSurface->h);
break; break;
case 2: case 2:
// We have a 16-bit surface // We have a 16-bit surface
_outputSurface->create(width, height, PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)); _outputSurface->create(width, height, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0));
for (uint16 y = 0; y < _outputSurface->h; y++) for (uint16 y = 0; y < _outputSurface->h; y++)
for (uint16 x = 0; x < _outputSurface->w; x++) for (uint16 x = 0; x < _outputSurface->w; x++)
WRITE_UINT16(_outputSurface->getBasePtr(x, y), READ_UINT16(buffer + (y * _outputSurface->w + x) * 2)); WRITE_UINT16(_outputSurface->getBasePtr(x, y), READ_UINT16(buffer + (y * _outputSurface->w + x) * 2));
@ -577,4 +577,4 @@ void PICTDecoder::decodeCompressedQuickTime(Common::SeekableReadStream &stream)
stream.seek(startPos + dataSize); stream.seek(startPos + dataSize);
} }
} // End of namespace Graphics } // End of namespace Image

View file

@ -28,23 +28,24 @@
* - sci * - sci
*/ */
#ifndef GRAPHICS_PICT_H #ifndef IMAGE_PICT_H
#define GRAPHICS_PICT_H #define IMAGE_PICT_H
#include "common/array.h" #include "common/array.h"
#include "common/rect.h" #include "common/rect.h"
#include "common/scummsys.h" #include "common/scummsys.h"
#include "graphics/decoders/image_decoder.h" #include "image/image_decoder.h"
#include "graphics/pixelformat.h"
namespace Common { namespace Common {
class SeekableReadStream; class SeekableReadStream;
} }
namespace Graphics { namespace Graphics {
struct Surface; struct Surface;
}
namespace Image {
#define DECLARE_OPCODE(x) void x(Common::SeekableReadStream &stream) #define DECLARE_OPCODE(x) void x(Common::SeekableReadStream &stream)
@ -56,7 +57,7 @@ public:
// ImageDecoder API // ImageDecoder API
bool loadStream(Common::SeekableReadStream &stream); bool loadStream(Common::SeekableReadStream &stream);
void destroy(); void destroy();
const Surface *getSurface() const { return _outputSurface; } const Graphics::Surface *getSurface() const { return _outputSurface; }
const byte *getPalette() const { return _palette; } const byte *getPalette() const { return _palette; }
uint16 getPaletteColorCount() const { return _paletteColorCount; } uint16 getPaletteColorCount() const { return _paletteColorCount; }
@ -135,6 +136,6 @@ private:
#undef DECLARE_OPCODE #undef DECLARE_OPCODE
} // End of namespace Graphics } // End of namespace Image
#endif #endif

View file

@ -29,14 +29,14 @@
#include <png.h> #include <png.h>
#endif #endif
#include "graphics/decoders/png.h" #include "image/png.h"
#include "graphics/pixelformat.h" #include "graphics/pixelformat.h"
#include "graphics/surface.h" #include "graphics/surface.h"
#include "common/stream.h" #include "common/stream.h"
namespace Graphics { namespace Image {
PNGDecoder::PNGDecoder() : _outputSurface(0), _palette(0), _paletteColorCount(0), _stream(0) { PNGDecoder::PNGDecoder() : _outputSurface(0), _palette(0), _paletteColorCount(0), _stream(0) {
} }
@ -242,4 +242,4 @@ bool PNGDecoder::loadStream(Common::SeekableReadStream &stream) {
#endif #endif
} }
} // End of Graphics namespace } // End of namespace Image

View file

@ -28,21 +28,22 @@
* - libpng * - libpng
*/ */
#ifndef GRAPHICS_PNG_H #ifndef IMAGE_PNG_H
#define GRAPHICS_PNG_H #define IMAGE_PNG_H
#include "common/scummsys.h" #include "common/scummsys.h"
#include "common/textconsole.h" #include "common/textconsole.h"
#include "graphics/decoders/image_decoder.h" #include "image/image_decoder.h"
namespace Common { namespace Common {
class SeekableReadStream; class SeekableReadStream;
} }
namespace Graphics { namespace Graphics {
struct Surface; struct Surface;
struct PixelFormat; }
namespace Image {
class PNGDecoder : public ImageDecoder { class PNGDecoder : public ImageDecoder {
public: public:
@ -62,6 +63,6 @@ private:
Graphics::Surface *_outputSurface; Graphics::Surface *_outputSurface;
}; };
} // End of namespace Graphics } // End of namespace Image
#endif // GRAPHICS_PNG_H #endif

View file

@ -24,14 +24,14 @@
* relicensed under GPLv2+ with permission from DrMcCoy and clone2727 * relicensed under GPLv2+ with permission from DrMcCoy and clone2727
*/ */
#include "image/tga.h"
#include "common/util.h" #include "common/util.h"
#include "common/stream.h" #include "common/stream.h"
#include "common/textconsole.h" #include "common/textconsole.h"
#include "common/error.h" #include "common/error.h"
#include "graphics/decoders/tga.h" namespace Image {
namespace Graphics {
TGADecoder::TGADecoder() { TGADecoder::TGADecoder() {
_colorMapSize = 0; _colorMapSize = 0;
@ -139,29 +139,29 @@ bool TGADecoder::readHeader(Common::SeekableReadStream &tga, byte &imageType, by
//int interleave = (imgDesc & 0xC); //int interleave = (imgDesc & 0xC);
if (imageType == TYPE_CMAP || imageType == TYPE_RLE_CMAP) { if (imageType == TYPE_CMAP || imageType == TYPE_RLE_CMAP) {
if (pixelDepth == 8) { if (pixelDepth == 8) {
_format = PixelFormat::createFormatCLUT8(); _format = Graphics::PixelFormat::createFormatCLUT8();
} else { } else {
warning("Unsupported index-depth: %d", pixelDepth); warning("Unsupported index-depth: %d", pixelDepth);
return false; return false;
} }
} else if (imageType == TYPE_TRUECOLOR || imageType == TYPE_RLE_TRUECOLOR) { } else if (imageType == TYPE_TRUECOLOR || imageType == TYPE_RLE_TRUECOLOR) {
if (pixelDepth == 24) { if (pixelDepth == 24) {
_format = PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0); _format = Graphics::PixelFormat(3, 8, 8, 8, 0, 16, 8, 0, 0);
} else if (pixelDepth == 32) { } else if (pixelDepth == 32) {
// HACK: According to the spec, attributeBits should determine the amount // HACK: According to the spec, attributeBits should determine the amount
// of alpha-bits, however, as the game files that use this decoder seems // of alpha-bits, however, as the game files that use this decoder seems
// to ignore that fact, we force the amount to 8 for 32bpp files for now. // to ignore that fact, we force the amount to 8 for 32bpp files for now.
_format = PixelFormat(4, 8, 8, 8, /* attributeBits */ 8, 16, 8, 0, 24); _format = Graphics::PixelFormat(4, 8, 8, 8, /* attributeBits */ 8, 16, 8, 0, 24);
} else if (pixelDepth == 16 && imageType == TYPE_TRUECOLOR) { } else if (pixelDepth == 16 && imageType == TYPE_TRUECOLOR) {
// 16bpp TGA is ARGB1555 // 16bpp TGA is ARGB1555
_format = PixelFormat(2, 5, 5, 5, attributeBits, 10, 5, 0, 15); _format = Graphics::PixelFormat(2, 5, 5, 5, attributeBits, 10, 5, 0, 15);
} else { } else {
warning("Unsupported pixel depth: %d, %d", imageType, pixelDepth); warning("Unsupported pixel depth: %d, %d", imageType, pixelDepth);
return false; return false;
} }
} else if (imageType == TYPE_BW || TYPE_RLE_BW) { } else if (imageType == TYPE_BW || TYPE_RLE_BW) {
if (pixelDepth == 8) { if (pixelDepth == 8) {
_format = PixelFormat(4, 8, 8, 8, 0, 16, 8, 0, 0); _format = Graphics::PixelFormat(4, 8, 8, 8, 0, 16, 8, 0, 0);
} else { } else {
warning("Unsupported pixel depth: %d, %d", imageType, pixelDepth); warning("Unsupported pixel depth: %d, %d", imageType, pixelDepth);
return false; return false;
@ -187,7 +187,7 @@ bool TGADecoder::readColorMap(Common::SeekableReadStream &tga, byte imageType, b
byte r, g, b; byte r, g, b;
if (_colorMapEntryLength == 32) { if (_colorMapEntryLength == 32) {
byte a; byte a;
PixelFormat format(4, 8, 8, 8, 0, 16, 8, 0, 24); Graphics::PixelFormat format(4, 8, 8, 8, 0, 16, 8, 0, 24);
uint32 color = tga.readUint32LE(); uint32 color = tga.readUint32LE();
format.colorToARGB(color, a, r, g, b); format.colorToARGB(color, a, r, g, b);
} else if (_colorMapEntryLength == 24) { } else if (_colorMapEntryLength == 24) {
@ -196,7 +196,7 @@ bool TGADecoder::readColorMap(Common::SeekableReadStream &tga, byte imageType, b
b = tga.readByte(); b = tga.readByte();
} else if (_colorMapEntryLength == 16) { } else if (_colorMapEntryLength == 16) {
byte a; byte a;
PixelFormat format(2, 5, 5, 5, 0, 10, 5, 0, 15); Graphics::PixelFormat format(2, 5, 5, 5, 0, 10, 5, 0, 15);
uint16 color = tga.readUint16LE(); uint16 color = tga.readUint16LE();
format.colorToARGB(color, a, r, g, b); format.colorToARGB(color, a, r, g, b);
} else { } else {
@ -427,4 +427,4 @@ bool TGADecoder::readDataRLE(Common::SeekableReadStream &tga, byte imageType, by
return true; return true;
} }
} // End of namespace Graphics } // End of namespace Image

View file

@ -30,17 +30,17 @@
* - zvision * - zvision
*/ */
#ifndef GRAPHICS_DECODERS_TGA_H #ifndef IMAGE_TGA_H
#define GRAPHICS_DECODERS_TGA_H #define IMAGE_TGA_H
#include "graphics/surface.h" #include "graphics/surface.h"
#include "graphics/decoders/image_decoder.h" #include "image/image_decoder.h"
namespace Common { namespace Common {
class SeekableReadStream; class SeekableReadStream;
} }
namespace Graphics { namespace Image {
/** TarGa image-decoder /** TarGa image-decoder
* The following variations of TGA are supported: * The following variations of TGA are supported:
@ -59,7 +59,7 @@ public:
TGADecoder(); TGADecoder();
virtual ~TGADecoder(); virtual ~TGADecoder();
virtual void destroy(); virtual void destroy();
virtual const Surface *getSurface() const { return &_surface; } virtual const Graphics::Surface *getSurface() const { return &_surface; }
virtual const byte *getPalette() const { return _colorMap; } virtual const byte *getPalette() const { return _colorMap; }
virtual uint16 getPaletteColorCount() const { return _colorMapLength; } virtual uint16 getPaletteColorCount() const { return _colorMapLength; }
virtual bool loadStream(Common::SeekableReadStream &stream); virtual bool loadStream(Common::SeekableReadStream &stream);
@ -85,8 +85,8 @@ private:
// Origin may be at the top, or bottom // Origin may be at the top, or bottom
bool _originTop; bool _originTop;
PixelFormat _format; Graphics::PixelFormat _format;
Surface _surface; Graphics::Surface _surface;
// Loading helpers // Loading helpers
bool readHeader(Common::SeekableReadStream &tga, byte &imageType, byte &pixelDepth); bool readHeader(Common::SeekableReadStream &tga, byte &imageType, byte &pixelDepth);
bool readData(Common::SeekableReadStream &tga, byte imageType, byte pixelDepth); bool readData(Common::SeekableReadStream &tga, byte imageType, byte pixelDepth);
@ -95,6 +95,6 @@ private:
bool readColorMap(Common::SeekableReadStream &tga, byte imageType, byte pixelDepth); bool readColorMap(Common::SeekableReadStream &tga, byte imageType, byte pixelDepth);
}; };
} // End of namespace Graphics } // End of namespace Image
#endif // GRAPHICS_DECODERS_TGA_H #endif

View file

@ -23,7 +23,7 @@
#include "common/system.h" #include "common/system.h"
#include "common/textconsole.h" #include "common/textconsole.h"
#include "graphics/surface.h" #include "graphics/surface.h"
#include "graphics/decoders/jpeg.h" #include "image/jpeg.h"
#include "video/codecs/jpeg.h" #include "video/codecs/jpeg.h"
@ -46,7 +46,7 @@ JPEGDecoder::~JPEGDecoder() {
} }
const Graphics::Surface *JPEGDecoder::decodeImage(Common::SeekableReadStream *stream) { const Graphics::Surface *JPEGDecoder::decodeImage(Common::SeekableReadStream *stream) {
Graphics::JPEGDecoder jpeg; Image::JPEGDecoder jpeg;
if (!jpeg.loadStream(*stream)) { if (!jpeg.loadStream(*stream)) {
warning("Failed to decode JPEG frame"); warning("Failed to decode JPEG frame");

View file

@ -29,7 +29,7 @@
#include "common/system.h" #include "common/system.h"
#include "common/textconsole.h" #include "common/textconsole.h"
#include "graphics/surface.h" #include "graphics/surface.h"
#include "graphics/decoders/jpeg.h" #include "image/jpeg.h"
#include "video/codecs/mjpeg.h" #include "video/codecs/mjpeg.h"
@ -197,7 +197,7 @@ const Graphics::Surface *MJPEGDecoder::decodeImage(Common::SeekableReadStream *s
stream->read(data + dataOffset, stream->size() - inputSkip); stream->read(data + dataOffset, stream->size() - inputSkip);
Common::MemoryReadStream convertedStream(data, outputSize, DisposeAfterUse::YES); Common::MemoryReadStream convertedStream(data, outputSize, DisposeAfterUse::YES);
Graphics::JPEGDecoder jpeg; Image::JPEGDecoder jpeg;
if (!jpeg.loadStream(convertedStream)) { if (!jpeg.loadStream(convertedStream)) {
warning("Failed to decode MJPEG frame"); warning("Failed to decode MJPEG frame");