aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25/gfx
diff options
context:
space:
mode:
authorMatthew Hoops2012-01-28 17:55:56 -0500
committerJohannes Schickel2012-03-20 01:06:48 +0100
commita658fc660e5932410b91c00d3eef81963ed02972 (patch)
treef48e61b2e0ab3c2a460330842e31ef95950182a7 /engines/sword25/gfx
parentdd9790c1c8a10c8a9ffdef4d45a30ce078f0f939 (diff)
downloadscummvm-rg350-a658fc660e5932410b91c00d3eef81963ed02972.tar.gz
scummvm-rg350-a658fc660e5932410b91c00d3eef81963ed02972.tar.bz2
scummvm-rg350-a658fc660e5932410b91c00d3eef81963ed02972.zip
GRAPHICS: Move PNG to the ImageDecoder interface
Diffstat (limited to 'engines/sword25/gfx')
-rw-r--r--engines/sword25/gfx/image/imgloader.cpp13
1 files changed, 7 insertions, 6 deletions
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;