ScummVM API documentation
jpeg.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef IMAGE_JPEG_H
23 #define IMAGE_JPEG_H
24 
25 #include "graphics/palette.h"
26 #include "graphics/surface.h"
27 #include "image/image_decoder.h"
28 #include "image/codecs/codec.h"
29 
30 namespace Common {
31 class SeekableReadStream;
32 }
33 
34 namespace Image {
35 
50 class JPEGDecoder : public ImageDecoder, public Codec {
51 public:
52  JPEGDecoder();
53  ~JPEGDecoder();
54 
55  // ImageDecoder API
56  void destroy() override;
57  bool loadStream(Common::SeekableReadStream &str) override;
58  const Graphics::Surface *getSurface() const override;
59  const Graphics::Palette &getPalette() const override { return _palette; }
60 
61  // Codec API
62  const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream) override;
63  void setCodecAccuracy(CodecAccuracy accuracy) override;
64  Graphics::PixelFormat getPixelFormat() const override;
65  bool setOutputPixelFormat(const Graphics::PixelFormat &format) override {
66  if (format.isCLUT8())
67  return false;
68  _requestedPixelFormat = format;
69  return true;
70  }
71 
72  // Special API for JPEG
73  enum ColorSpace {
80 
94  kColorSpaceYUV
95  };
96 
105  void setOutputColorSpace(ColorSpace outSpace) { _colorSpace = outSpace; }
106 
107 private:
108  // TODO: Avoid inheriting from multiple superclasses that have identical member functions.
109  using Codec::getPalette;
110  Graphics::Surface _surface;
111  Graphics::Palette _palette;
112  ColorSpace _colorSpace;
113  Graphics::PixelFormat _requestedPixelFormat;
114  CodecAccuracy _accuracy;
115 
116  Graphics::PixelFormat getByteOrderRgbPixelFormat() const;
117 };
119 } // End of namespace Image
120 
121 #endif
Definition: image_decoder.h:53
Definition: surface.h:67
Definition: pixelformat.h:138
ColorSpace
Definition: jpeg.h:73
Definition: stream.h:745
bool isCLUT8() const
Definition: pixelformat.h:430
const Graphics::Palette & getPalette() const override
Definition: jpeg.h:59
Definition: codec.h:57
void setOutputColorSpace(ColorSpace outSpace)
Definition: jpeg.h:105
Definition: algorithm.h:29
bool setOutputPixelFormat(const Graphics::PixelFormat &format) override
Definition: jpeg.h:65
Definition: jpeg.h:50
Simple class for handling a palette data.
Definition: palette.h:55
Definition: movie_decoder.h:32