diff options
author | Matthew Hoops | 2014-02-27 21:27:23 -0500 |
---|---|---|
committer | Matthew Hoops | 2014-02-28 00:27:36 -0500 |
commit | c432b96cf667a1b7f1386cc4c97fcf5411690f7d (patch) | |
tree | d4cdab5ce30eb4c014b5445a8895059da7ef8cf3 /image | |
parent | b568ac73b9d2e063eb04693e4610a9932035b696 (diff) | |
download | scummvm-rg350-c432b96cf667a1b7f1386cc4c97fcf5411690f7d.tar.gz scummvm-rg350-c432b96cf667a1b7f1386cc4c97fcf5411690f7d.tar.bz2 scummvm-rg350-c432b96cf667a1b7f1386cc4c97fcf5411690f7d.zip |
IMAGE: Merge the JPEG codec into the ImageDecoder
Diffstat (limited to 'image')
-rw-r--r-- | image/codecs/jpeg.cpp | 66 | ||||
-rw-r--r-- | image/codecs/jpeg.h | 60 | ||||
-rw-r--r-- | image/jpeg.cpp | 13 | ||||
-rw-r--r-- | image/jpeg.h | 17 | ||||
-rw-r--r-- | image/module.mk | 1 |
5 files changed, 26 insertions, 131 deletions
diff --git a/image/codecs/jpeg.cpp b/image/codecs/jpeg.cpp deleted file mode 100644 index 9e8ba5a7d3..0000000000 --- a/image/codecs/jpeg.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "common/system.h" -#include "common/textconsole.h" -#include "graphics/surface.h" -#include "image/jpeg.h" - -#include "image/codecs/jpeg.h" - -namespace Common { -class SeekableReadStream; -} - -namespace Image { - -JPEGCodec::JPEGCodec() : Codec() { - _pixelFormat = g_system->getScreenFormat(); - _surface = NULL; -} - -JPEGCodec::~JPEGCodec() { - if (_surface) { - _surface->free(); - delete _surface; - } -} - -const Graphics::Surface *JPEGCodec::decodeImage(Common::SeekableReadStream *stream) { - JPEGDecoder jpeg; - - if (!jpeg.loadStream(*stream)) { - warning("Failed to decode JPEG frame"); - return 0; - } - - if (_surface) { - _surface->free(); - delete _surface; - } - - _surface = jpeg.getSurface()->convertTo(_pixelFormat); - - return _surface; -} - -} // End of namespace Image diff --git a/image/codecs/jpeg.h b/image/codecs/jpeg.h deleted file mode 100644 index d48604b067..0000000000 --- a/image/codecs/jpeg.h +++ /dev/null @@ -1,60 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef IMAGE_CODECS_JPEG_H -#define IMAGE_CODECS_JPEG_H - -#include "image/codecs/codec.h" -#include "graphics/pixelformat.h" - -namespace Common { -class SeekableReadStream; -} - -namespace Graphics { -struct Surface; -} - -namespace Image { - -/** - * JPEG decoder. - * - * Used in video: - * - QuickTimeDecoder - */ -class JPEGCodec : public Codec { -public: - JPEGCodec(); - ~JPEGCodec(); - - const Graphics::Surface *decodeImage(Common::SeekableReadStream *stream); - Graphics::PixelFormat getPixelFormat() const { return _pixelFormat; } - -private: - Graphics::PixelFormat _pixelFormat; - Graphics::Surface *_surface; -}; - -} // End of namespace Image - -#endif diff --git a/image/jpeg.cpp b/image/jpeg.cpp index 9d4b0a7cfe..3602d501be 100644 --- a/image/jpeg.cpp +++ b/image/jpeg.cpp @@ -44,7 +44,7 @@ extern "C" { namespace Image { -JPEGDecoder::JPEGDecoder() : ImageDecoder(), _surface(), _colorSpace(kColorSpaceRGBA) { +JPEGDecoder::JPEGDecoder() : _surface(), _colorSpace(kColorSpaceRGBA) { } JPEGDecoder::~JPEGDecoder() { @@ -59,6 +59,17 @@ void JPEGDecoder::destroy() { _surface.free(); } +const Graphics::Surface *JPEGDecoder::decodeImage(Common::SeekableReadStream *stream) { + if (!loadStream(*stream)) + return 0; + + return getSurface(); +} + +Graphics::PixelFormat JPEGDecoder::getPixelFormat() const { + return _surface.format; +} + #ifdef USE_JPEG namespace { diff --git a/image/jpeg.h b/image/jpeg.h index f578170517..1bf76ecfca 100644 --- a/image/jpeg.h +++ b/image/jpeg.h @@ -26,6 +26,12 @@ * - groovie * - mohawk * - wintermute + * + * Used in image: + * - PICTDecoder + * + * Used in video: + * - QuickTimeDecoder */ #ifndef IMAGE_JPEG_H @@ -33,6 +39,7 @@ #include "graphics/surface.h" #include "image/image_decoder.h" +#include "image/codecs/codec.h" namespace Common { class SeekableReadStream; @@ -40,7 +47,7 @@ class SeekableReadStream; namespace Image { -class JPEGDecoder : public ImageDecoder { +class JPEGDecoder : public ImageDecoder, public Codec { public: JPEGDecoder(); ~JPEGDecoder(); @@ -50,6 +57,10 @@ public: virtual bool loadStream(Common::SeekableReadStream &str); virtual const Graphics::Surface *getSurface() const; + // Codec API + const Graphics::Surface *decodeImage(Common::SeekableReadStream *stream); + Graphics::PixelFormat getPixelFormat() const; + // Special API for JPEG enum ColorSpace { /** @@ -90,6 +101,6 @@ private: ColorSpace _colorSpace; }; -} // End of Graphics namespace +} // End of namespace Image -#endif // GRAPHICS_JPEG_H +#endif diff --git a/image/module.mk b/image/module.mk index 28d750358d..46129cbde4 100644 --- a/image/module.mk +++ b/image/module.mk @@ -11,7 +11,6 @@ MODULE_OBJS := \ codecs/cdtoons.o \ codecs/cinepak.o \ codecs/indeo3.o \ - codecs/jpeg.o \ codecs/mjpeg.o \ codecs/msrle.o \ codecs/msvideo1.o \ |