diff options
| author | Eugene Sandulenko | 2011-10-23 23:31:23 +0100 |
|---|---|---|
| committer | Eugene Sandulenko | 2011-10-23 23:44:14 +0100 |
| commit | 4c08fccf589e9c2eab87c53bae912b3f0d23b323 (patch) | |
| tree | 46292fcab85f52ea673ac9a2db0df561ac525629 /gui | |
| parent | f1165b0b6ead53b68443c649cc544016ad119b1d (diff) | |
| download | scummvm-rg350-4c08fccf589e9c2eab87c53bae912b3f0d23b323.tar.gz scummvm-rg350-4c08fccf589e9c2eab87c53bae912b3f0d23b323.tar.bz2 scummvm-rg350-4c08fccf589e9c2eab87c53bae912b3f0d23b323.zip | |
GUI: Add support for PNG images in themes
Diffstat (limited to 'gui')
| -rw-r--r-- | gui/ThemeEngine.cpp | 31 | ||||
| -rwxr-xr-x | gui/themes/scummtheme.py | 2 |
2 files changed, 26 insertions, 7 deletions
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")): |
