aboutsummaryrefslogtreecommitdiff
path: root/graphics/decoders/jpeg.h
diff options
context:
space:
mode:
authorJohannes Schickel2013-08-12 00:53:34 +0200
committerJohannes Schickel2013-09-16 19:54:19 +0200
commit4809294b43e1c43957874bdfcdadfc299fd7ace4 (patch)
treea4f314e1b8011cdbc654ab7cfe2ee874350aae75 /graphics/decoders/jpeg.h
parentac66cc921904387518f2e0b2a14670e9598defe4 (diff)
downloadscummvm-rg350-4809294b43e1c43957874bdfcdadfc299fd7ace4.tar.gz
scummvm-rg350-4809294b43e1c43957874bdfcdadfc299fd7ace4.tar.bz2
scummvm-rg350-4809294b43e1c43957874bdfcdadfc299fd7ace4.zip
GRAPHICS: Make JPEGDecoder request RGB output from libjpeg by default.
This fixes loading of JPEG files which contain RGB color space instead of YUV. It is a pretty odd extension of JPEG files by Adobe which is indicated by this: http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html#Adobe To still support Groovie's need for YUV data I added some possibility to request direct YUV output.
Diffstat (limited to 'graphics/decoders/jpeg.h')
-rw-r--r--graphics/decoders/jpeg.h53
1 files changed, 39 insertions, 14 deletions
diff --git a/graphics/decoders/jpeg.h b/graphics/decoders/jpeg.h
index 53e7bb10c8..8460bc2698 100644
--- a/graphics/decoders/jpeg.h
+++ b/graphics/decoders/jpeg.h
@@ -46,23 +46,48 @@ public:
~JPEGDecoder();
// ImageDecoder API
- void destroy();
- bool loadStream(Common::SeekableReadStream &str);
- const Surface *getSurface() const;
+ virtual void destroy();
+ virtual bool loadStream(Common::SeekableReadStream &str);
+ virtual const Surface *getSurface() const;
- const Surface &getYComponent() const { return _yComponent; }
- const Surface &getUComponent() const { return _uComponent; }
- const Surface &getVComponent() const { return _vComponent; }
+ // Special API for JPEG
+ enum ColorSpace {
+ /**
+ * Output 32bit RGBA data.
+ *
+ * This is the default output.
+ */
+ kColorSpaceRGBA,
-private:
- // mutable so that we can convert to RGB only during
- // a getSurface() call while still upholding the
- // const requirement in other ImageDecoders
- mutable Graphics::Surface *_rgbSurface;
+ /**
+ * Output (interleaved) YUV data.
+ *
+ * Be aware that some images cannot be output in YUV mode.
+ * These are (non-standard) JPEG images which are in RGB colorspace.
+ *
+ * The resulting Surface will have a PixelFormat with 3 bytes per
+ * pixel and the remaining entries are completely zeroed. This works
+ * around the fact that PixelFormat can only describe RGB formats.
+ *
+ * You should only use this when you are really aware of what you are
+ * doing!
+ */
+ kColorSpaceYUV
+ };
+
+ /**
+ * Request the output color space. This can be used to obtain raw YUV
+ * data from the JPEG file. But this might not work for all files!
+ *
+ * The decoder itself defaults to RGBA.
+ *
+ * @param outSpace The color space to output.
+ */
+ void setOutputColorSpace(ColorSpace outSpace) { _colorSpace = outSpace; }
- Graphics::Surface _yComponent;
- Graphics::Surface _uComponent;
- Graphics::Surface _vComponent;
+private:
+ Graphics::Surface _surface;
+ ColorSpace _colorSpace;
};
} // End of Graphics namespace