[Scummvm-cvs-logs] SF.net SVN: scummvm:[36026] scummvm/trunk
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Sat Jan 24 00:50:55 CET 2009
Revision: 36026
http://scummvm.svn.sourceforge.net/scummvm/?rev=36026&view=rev
Author: fingolfin
Date: 2009-01-23 23:50:54 +0000 (Fri, 23 Jan 2009)
Log Message:
-----------
Changed Graphics::ImageDecoder to allow custom PixelFormats
Modified Paths:
--------------
scummvm/trunk/backends/vkeybd/virtual-keyboard-parser.cpp
scummvm/trunk/graphics/imagedec.cpp
scummvm/trunk/graphics/imagedec.h
scummvm/trunk/gui/ThemeEngine.cpp
Modified: scummvm/trunk/backends/vkeybd/virtual-keyboard-parser.cpp
===================================================================
--- scummvm/trunk/backends/vkeybd/virtual-keyboard-parser.cpp 2009-01-23 22:56:14 UTC (rev 36025)
+++ scummvm/trunk/backends/vkeybd/virtual-keyboard-parser.cpp 2009-01-23 23:50:54 UTC (rev 36026)
@@ -256,13 +256,14 @@
if (!file)
return parserError("Bitmap '%s' not found", _mode->bitmapName.c_str());
- _mode->image = Graphics::ImageDecoder::loadFile(*file);
+ const Graphics::PixelFormat format = g_system->getOverlayFormat();
+
+ _mode->image = Graphics::ImageDecoder::loadFile(*file, format);
delete file;
if (!_mode->image)
return parserError("Error loading bitmap '%s'", _mode->bitmapName.c_str());
- const Graphics::PixelFormat format = g_system->getOverlayFormat();
int r, g, b;
if (node->values.contains("transparent_color")) {
if (!parseIntegerKey(node->values["transparent_color"].c_str(), 3, &r, &g, &b))
Modified: scummvm/trunk/graphics/imagedec.cpp
===================================================================
--- scummvm/trunk/graphics/imagedec.cpp 2009-01-23 22:56:14 UTC (rev 36025)
+++ scummvm/trunk/graphics/imagedec.cpp 2009-01-23 23:50:54 UTC (rev 36026)
@@ -24,7 +24,6 @@
#include "graphics/imagedec.h"
-#include "common/system.h"
#include "common/file.h"
namespace Graphics {
@@ -37,7 +36,7 @@
virtual ~BMPDecoder() {}
bool decodeable(Common::SeekableReadStream &stream);
- Surface *decodeImage(Common::SeekableReadStream &stream);
+ Surface *decodeImage(Common::SeekableReadStream &stream, const PixelFormat &format);
struct BitmapHeader {
uint16 type;
@@ -75,7 +74,7 @@
return true;
}
-Surface *BMPDecoder::decodeImage(Common::SeekableReadStream &stream) {
+Surface *BMPDecoder::decodeImage(Common::SeekableReadStream &stream, const PixelFormat &format) {
if (!decodeable(stream)) {
return 0;
}
@@ -120,14 +119,13 @@
newSurf->create(info.width, info.height, sizeof(OverlayColor));
assert(newSurf->pixels);
OverlayColor *curPixel = (OverlayColor*)newSurf->pixels + (newSurf->h-1) * newSurf->w;
- PixelFormat overlayFormat = g_system->getOverlayFormat();
int pitchAdd = info.width % 4;
for (int i = 0; i < newSurf->h; ++i) {
for (int i2 = 0; i2 < newSurf->w; ++i2) {
b = stream.readByte();
g = stream.readByte();
r = stream.readByte();
- *curPixel = overlayFormat.RGBToColor(r, g, b);
+ *curPixel = format.RGBToColor(r, g, b);
++curPixel;
}
stream.seek(pitchAdd, SEEK_CUR);
@@ -140,18 +138,18 @@
#pragma mark -
-Surface *ImageDecoder::loadFile(const Common::String &name) {
+Surface *ImageDecoder::loadFile(const Common::String &name, const PixelFormat &format) {
Surface *newSurf = 0;
Common::File imageFile;
if (imageFile.open(name)) {
- newSurf = loadFile(imageFile);
+ newSurf = loadFile(imageFile, format);
}
return newSurf;
}
-Surface *ImageDecoder::loadFile(Common::SeekableReadStream &stream) {
+Surface *ImageDecoder::loadFile(Common::SeekableReadStream &stream, const PixelFormat &format) {
// TODO: implement support for bzipped memory
// FIXME: this is not a very nice solution but it should work
@@ -174,6 +172,6 @@
if (!decoder)
return 0;
- return decoder->decodeImage(stream);
+ return decoder->decodeImage(stream, format);
}
} // end of namespace Graphics
Modified: scummvm/trunk/graphics/imagedec.h
===================================================================
--- scummvm/trunk/graphics/imagedec.h 2009-01-23 22:56:14 UTC (rev 36025)
+++ scummvm/trunk/graphics/imagedec.h 2009-01-23 23:50:54 UTC (rev 36026)
@@ -30,15 +30,17 @@
#include "common/stream.h"
#include "graphics/surface.h"
+#include "graphics/pixelformat.h"
namespace Graphics {
+
class ImageDecoder {
public:
ImageDecoder() {}
virtual ~ImageDecoder() {}
- static Surface *loadFile(const Common::String &name);
- static Surface *loadFile(Common::SeekableReadStream &stream);
+ static Surface *loadFile(const Common::String &name, const PixelFormat &format);
+ static Surface *loadFile(Common::SeekableReadStream &stream, const PixelFormat &format);
/**
* checks if the data can be decoded by this decoder
@@ -54,9 +56,10 @@
* with delete;
*
* @param stream the memory stream which should be decoded
+ * @param format the pixel format used to generate the surface
* @return returns a new surface if the image could be decoded, otherwise 0
*/
- virtual Surface *decodeImage(Common::SeekableReadStream &stream) = 0;
+ virtual Surface *decodeImage(Common::SeekableReadStream &stream, const PixelFormat &format) = 0;
};
} // end of namespace Graphics
Modified: scummvm/trunk/gui/ThemeEngine.cpp
===================================================================
--- scummvm/trunk/gui/ThemeEngine.cpp 2009-01-23 22:56:14 UTC (rev 36025)
+++ scummvm/trunk/gui/ThemeEngine.cpp 2009-01-23 23:50:54 UTC (rev 36026)
@@ -578,11 +578,11 @@
return true;
// If not, try to load the bitmap via the ImageDecoder class.
- surf = Graphics::ImageDecoder::loadFile(filename);
+ surf = Graphics::ImageDecoder::loadFile(filename, _overlayFormat);
if (!surf && _themeArchive) {
Common::SeekableReadStream *stream = _themeArchive->createReadStreamForMember(filename);
if (stream) {
- surf = Graphics::ImageDecoder::loadFile(*stream);
+ surf = Graphics::ImageDecoder::loadFile(*stream, _overlayFormat);
delete stream;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list