aboutsummaryrefslogtreecommitdiff
path: root/video/codecs
diff options
context:
space:
mode:
authorMatthew Hoops2011-07-02 22:05:45 -0400
committerJohannes Schickel2012-03-20 01:06:48 +0100
commit765a8704454d705acc9ce5aa7a90c1c3079fb989 (patch)
treeffb665cb56dc0b28b208ef13f5e0e75ed477fa7e /video/codecs
parent4516b5ea24e6c0056984a65fe4fff33553931487 (diff)
downloadscummvm-rg350-765a8704454d705acc9ce5aa7a90c1c3079fb989.tar.gz
scummvm-rg350-765a8704454d705acc9ce5aa7a90c1c3079fb989.tar.bz2
scummvm-rg350-765a8704454d705acc9ce5aa7a90c1c3079fb989.zip
GRAPHICS: Convert JPEG to the ImageDecoder API
Diffstat (limited to 'video/codecs')
-rw-r--r--video/codecs/mjpeg.cpp25
-rw-r--r--video/codecs/mjpeg.h3
2 files changed, 10 insertions, 18 deletions
diff --git a/video/codecs/mjpeg.cpp b/video/codecs/mjpeg.cpp
index 248a80d714..10fd9d7c50 100644
--- a/video/codecs/mjpeg.cpp
+++ b/video/codecs/mjpeg.cpp
@@ -22,8 +22,8 @@
#include "common/system.h"
#include "common/textconsole.h"
-#include "graphics/jpeg.h"
#include "graphics/surface.h"
+#include "graphics/decoders/jpeg.h"
#include "video/codecs/mjpeg.h"
@@ -34,38 +34,31 @@ class SeekableReadStream;
namespace Video {
JPEGDecoder::JPEGDecoder() : Codec() {
- _jpeg = new Graphics::JPEG();
_pixelFormat = g_system->getScreenFormat();
_surface = NULL;
}
JPEGDecoder::~JPEGDecoder() {
- delete _jpeg;
-
if (_surface) {
_surface->free();
delete _surface;
}
}
-const Graphics::Surface *JPEGDecoder::decodeImage(Common::SeekableReadStream* stream) {
- if (!_jpeg->read(stream)) {
+const Graphics::Surface *JPEGDecoder::decodeImage(Common::SeekableReadStream *stream) {
+ Graphics::JPEGDecoder jpeg;
+
+ if (!jpeg.loadStream(*stream)) {
warning("Failed to decode JPEG frame");
return 0;
}
- if (!_surface) {
- _surface = new Graphics::Surface();
- _surface->create(_jpeg->getWidth(), _jpeg->getHeight(), _pixelFormat);
+ if (_surface) {
+ _surface->free();
+ delete _surface;
}
- Graphics::Surface *frame = _jpeg->getSurface(_pixelFormat);
- assert(frame);
-
- _surface->copyFrom(*frame);
-
- frame->free();
- delete frame;
+ _surface = jpeg.getSurface()->convertTo(_pixelFormat);
return _surface;
}
diff --git a/video/codecs/mjpeg.h b/video/codecs/mjpeg.h
index 45cb57dea2..0c3b668a74 100644
--- a/video/codecs/mjpeg.h
+++ b/video/codecs/mjpeg.h
@@ -31,7 +31,7 @@ class SeekableReadStream;
}
namespace Graphics {
-class JPEG;
+struct Surface;
}
namespace Video {
@@ -50,7 +50,6 @@ public:
private:
Graphics::PixelFormat _pixelFormat;
- Graphics::JPEG *_jpeg;
Graphics::Surface *_surface;
};