From 0d5d04ca3a5473f24f45112bb40a009679024acc Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Tue, 22 Jan 2019 15:02:05 +0100 Subject: IMAGE: Allow setting the output pixel format to the JPEG decoder --- image/jpeg.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'image/jpeg.h') diff --git a/image/jpeg.h b/image/jpeg.h index ac0d22d129..08b5c01dc4 100644 --- a/image/jpeg.h +++ b/image/jpeg.h @@ -60,11 +60,11 @@ public: // Special API for JPEG enum ColorSpace { /** - * Output 32bit RGBA data. + * Output RGB data in the pixel format specified using `setOutputPixelFormat`. * * This is the default output. */ - kColorSpaceRGBA, + kColorSpaceRGB, /** * Output (interleaved) YUV data. @@ -86,15 +86,25 @@ public: * 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. + * The decoder itself defaults to RGB. * * @param outSpace The color space to output. */ void setOutputColorSpace(ColorSpace outSpace) { _colorSpace = outSpace; } + /** + * Request the output pixel format. The JPEG decoder provides high performance + * color conversion routines for some pixel formats. This setting allows to use + * them and avoid costly subsequent color conversion. + */ + void setOutputPixelFormat(const Graphics::PixelFormat &format) { _requestedPixelFormat = format; } + private: Graphics::Surface _surface; ColorSpace _colorSpace; + Graphics::PixelFormat _requestedPixelFormat; + + Graphics::PixelFormat getByteOrderRgbPixelFormat() const; }; } // End of namespace Image -- cgit v1.2.3