aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25/gfx/image/renderedimage.cpp
diff options
context:
space:
mode:
authormd52011-05-26 12:29:51 +0300
committermd52011-05-26 12:29:51 +0300
commit62c026d3b6a17ab3e7634cf3d4e5b63bbf0aa7eb (patch)
treeeedcb53d6c996a5d91fd996b70a3039a02d6e4e8 /engines/sword25/gfx/image/renderedimage.cpp
parenta654115f1a9a1497ee7d73a3c861e4f37ab1e081 (diff)
downloadscummvm-rg350-62c026d3b6a17ab3e7634cf3d4e5b63bbf0aa7eb.tar.gz
scummvm-rg350-62c026d3b6a17ab3e7634cf3d4e5b63bbf0aa7eb.tar.bz2
scummvm-rg350-62c026d3b6a17ab3e7634cf3d4e5b63bbf0aa7eb.zip
SWORD25: Merged the PNG and thumbnail decoding code into a common class
Diffstat (limited to 'engines/sword25/gfx/image/renderedimage.cpp')
-rw-r--r--engines/sword25/gfx/image/renderedimage.cpp30
1 files changed, 3 insertions, 27 deletions
diff --git a/engines/sword25/gfx/image/renderedimage.cpp b/engines/sword25/gfx/image/renderedimage.cpp
index 476d293779..a9c9de4f0c 100644
--- a/engines/sword25/gfx/image/renderedimage.cpp
+++ b/engines/sword25/gfx/image/renderedimage.cpp
@@ -35,7 +35,7 @@
#include "common/savefile.h"
#include "sword25/package/packagemanager.h"
-#include "sword25/gfx/image/pngloader.h"
+#include "sword25/gfx/image/imgloader.h"
#include "sword25/gfx/image/renderedimage.h"
#include "common/system.h"
@@ -93,30 +93,6 @@ static byte *readSavegameThumbnail(const Common::String &filename, uint &fileSiz
return pFileData;
}
-// TODO: Move this method into a more generic image loading class, together with the PNG reading code
-static bool decodeThumbnail(const byte *pFileData, uint fileSize, byte *&pUncompressedData, int &width, int &height, int &pitch) {
- const byte *src = pFileData + 4; // skip header
- width = READ_LE_UINT16(src); src += 2;
- height = READ_LE_UINT16(src); src += 2;
- src++; // version, ignored for now
- pitch = width * 4;
-
- uint32 totalSize = pitch * height;
- pUncompressedData = new byte[totalSize];
- uint32 *dst = (uint32 *)pUncompressedData; // treat as uint32, for pixelformat output
- const Graphics::PixelFormat format = Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24);
- byte r, g, b;
-
- for (uint32 i = 0; i < totalSize / 4; i++) {
- r = *src++;
- g = *src++;
- b = *src++;
- *dst++ = format.RGBToColor(r, g, b);
- }
-
- return true;
-}
-
RenderedImage::RenderedImage(const Common::String &filename, bool &result) :
_data(0),
_width(0),
@@ -148,9 +124,9 @@ RenderedImage::RenderedImage(const Common::String &filename, bool &result) :
// Uncompress the image
int pitch;
if (isPNG)
- result = PNGLoader::decodeImage(pFileData, fileSize, _data, _width, _height, pitch);
+ result = ImgLoader::decodePNGImage(pFileData, fileSize, _data, _width, _height, pitch);
else
- result = decodeThumbnail(pFileData, fileSize, _data, _width, _height, pitch);
+ result = ImgLoader::decodeThumbnailImage(pFileData, fileSize, _data, _width, _height, pitch);
if (!result) {
error("Could not decode image.");