ScummVM API documentation
png.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_PNG_H
23 #define IMAGE_PNG_H
24 
25 #include "common/scummsys.h"
26 #include "common/textconsole.h"
27 #include "graphics/palette.h"
28 #include "graphics/pixelformat.h"
29 #include "image/image_decoder.h"
30 
31 namespace Common {
32 class SeekableReadStream;
33 class WriteStream;
34 }
35 
36 namespace Graphics {
37 struct Surface;
38 }
39 
40 namespace Image {
41 
57 class PNGDecoder : public ImageDecoder {
58 public:
59  PNGDecoder();
60  ~PNGDecoder();
61 
62  bool loadStream(Common::SeekableReadStream &stream) override;
63  void destroy() override;
64  const Graphics::Surface *getSurface() const override { return _outputSurface; }
65  const byte *getPalette() const override { return _palette.data(); }
66  uint16 getPaletteColorCount() const override { return _palette.size(); }
67  bool hasTransparentColor() const override { return _hasTransparentColor; }
68  uint32 getTransparentColor() const override { return _transparentColor; }
69  void setSkipSignature(bool skip) { _skipSignature = skip; }
70  void setKeepTransparencyPaletted(bool keep) { _keepTransparencyPaletted = keep; }
71 private:
72  Graphics::PixelFormat getByteOrderRgbaPixelFormat(bool isAlpha) const;
73 
74  Graphics::Palette _palette;
75 
76  // flag to skip the png signature check for headless png files
77  bool _skipSignature;
78 
79  // Flag to keep paletted images paletted, even when the image has transparency
80  bool _keepTransparencyPaletted;
81  bool _hasTransparentColor;
82  uint32 _transparentColor;
83 
84  Graphics::Surface *_outputSurface;
85 };
86 
94 bool writePNG(Common::WriteStream &out, const Graphics::Surface &input, const byte *palette = nullptr);
96 } // End of namespace Image
97 
98 #endif
Definition: image_decoder.h:52
bool hasTransparentColor() const override
Definition: png.h:67
Definition: surface.h:67
Definition: stream.h:77
bool isAlpha(int c)
Definition: pixelformat.h:138
uint32 getTransparentColor() const override
Definition: png.h:68
Definition: stream.h:745
uint16 getPaletteColorCount() const override
Definition: png.h:66
Definition: algorithm.h:29
Definition: formatinfo.h:28
bool writePNG(Common::WriteStream &out, const Graphics::Surface &input, const byte *palette=nullptr)
const byte * getPalette() const override
Definition: png.h:65
const Graphics::Surface * getSurface() const override
Definition: png.h:64
Simple class for handling a palette data.
Definition: palette.h:51
Definition: movie_decoder.h:32
Definition: png.h:57