aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--graphics/png.cpp4
-rw-r--r--graphics/png.h13
-rw-r--r--gui/ThemeEngine.cpp31
-rwxr-xr-xgui/themes/scummtheme.py2
4 files changed, 27 insertions, 23 deletions
diff --git a/graphics/png.cpp b/graphics/png.cpp
index 2189fd333f..cea8b575ad 100644
--- a/graphics/png.cpp
+++ b/graphics/png.cpp
@@ -22,8 +22,6 @@
#include "graphics/png.h"
-#ifdef GRAPHICS_PNG_H
-
#include "graphics/pixelformat.h"
#include "graphics/surface.h"
@@ -487,5 +485,3 @@ void PNG::readTransparencyChunk(uint32 chunkLength) {
}
} // End of Graphics namespace
-
-#endif // GRAPHICS_PNG_H
diff --git a/graphics/png.h b/graphics/png.h
index 3f8ea85320..25f9c1e7bc 100644
--- a/graphics/png.h
+++ b/graphics/png.h
@@ -23,20 +23,11 @@
/*
* PNG decoder used in engines:
* - sword25
+ * - ScummVM GUI
* Dependencies:
* - zlib
*/
-// Currently, only the sword25 engine uses the PNG decoder, so skip compiling
-// it if sword25 is not enabled, or if zlib (a required dependency) is not
-// enabled.
-
-#if !(defined(ENABLE_SWORD25) || defined(USE_ZLIB))
-
-// Do not compile the PNG decoder code
-
-#else
-
#ifndef GRAPHICS_PNG_H
#define GRAPHICS_PNG_H
@@ -176,5 +167,3 @@ private:
} // End of Graphics namespace
#endif // GRAPHICS_PNG_H
-
-#endif // Engine and zlib guard
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index cf16eec238..a8780bdc1c 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -31,6 +31,7 @@
#include "graphics/cursorman.h"
#include "graphics/fontman.h"
#include "graphics/imagedec.h"
+#include "graphics/png.h"
#include "graphics/surface.h"
#include "graphics/VectorRenderer.h"
#include "graphics/fonts/bdf.h"
@@ -620,14 +621,32 @@ bool ThemeEngine::addBitmap(const Common::String &filename) {
Graphics::Surface *surf = _bitmaps[filename];
if (surf)
return true;
+ if (filename.hasSuffix(".png") || filename.hasSuffix(".PNG")) {
+ Graphics::PNG png;
+ Common::SeekableReadStream *stream;
+ Common::File file;
+
+ if (!file.open(filename)) {
+ stream = _themeArchive->createReadStreamForMember(filename);
+ } else {
+ stream = &file;
+ }
- // If not, try to load the bitmap via the ImageDecoder class.
- surf = Graphics::ImageDecoder::loadFile(filename, _overlayFormat);
- if (!surf && _themeArchive) {
- Common::SeekableReadStream *stream = _themeArchive->createReadStreamForMember(filename);
if (stream) {
- surf = Graphics::ImageDecoder::loadFile(*stream, _overlayFormat);
- delete stream;
+ if (png.read(stream))
+ surf = png.getSurface(_overlayFormat);
+ else
+ error("Cannot read png image: %s", filename.c_str());
+ }
+ } else {
+ // If not, try to load the bitmap via the ImageDecoder class.
+ surf = Graphics::ImageDecoder::loadFile(filename, _overlayFormat);
+ if (!surf && _themeArchive) {
+ Common::SeekableReadStream *stream = _themeArchive->createReadStreamForMember(filename);
+ if (stream) {
+ surf = Graphics::ImageDecoder::loadFile(*stream, _overlayFormat);
+ delete stream;
+ }
}
}
diff --git a/gui/themes/scummtheme.py b/gui/themes/scummtheme.py
index e4e9549265..874df03017 100755
--- a/gui/themes/scummtheme.py
+++ b/gui/themes/scummtheme.py
@@ -5,7 +5,7 @@ import re
import os
import zipfile
-THEME_FILE_EXTENSIONS = ('.stx', '.bmp', '.fcc')
+THEME_FILE_EXTENSIONS = ('.stx', '.bmp', '.fcc', '.png')
def buildTheme(themeName):
if not os.path.isdir(themeName) or not os.path.isfile(os.path.join(themeName, "THEMERC")):