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/pixelformat.h"
28 #include "image/image_decoder.h"
29 
30 namespace Common {
31 class SeekableReadStream;
32 class WriteStream;
33 }
34 
35 namespace Graphics {
36 struct Surface;
37 }
38 
39 namespace Image {
40 
56 class PNGDecoder : public ImageDecoder {
57 public:
58  PNGDecoder();
59  ~PNGDecoder();
60 
61  bool loadStream(Common::SeekableReadStream &stream) override;
62  void destroy() override;
63  const Graphics::Surface *getSurface() const override { return _outputSurface; }
64  const byte *getPalette() const override { return _palette; }
65  uint16 getPaletteColorCount() const override { return _paletteColorCount; }
66  bool hasTransparentColor() const override { return _hasTransparentColor; }
67  uint32 getTransparentColor() const override { return _transparentColor; }
68  void setSkipSignature(bool skip) { _skipSignature = skip; }
69  void setKeepTransparencyPaletted(bool keep) { _keepTransparencyPaletted = keep; }
70 private:
71  Graphics::PixelFormat getByteOrderRgbaPixelFormat(bool isAlpha) const;
72 
73  byte *_palette;
74  uint16 _paletteColorCount;
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:66
Definition: surface.h:66
Definition: stream.h:77
bool isAlpha(int c)
Definition: pixelformat.h:138
uint32 getTransparentColor() const override
Definition: png.h:67
Definition: stream.h:745
uint16 getPaletteColorCount() const override
Definition: png.h:65
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:64
const Graphics::Surface * getSurface() const override
Definition: png.h:63
Definition: movie_decoder.h:32
Definition: png.h:56