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
31namespace Common {
32class SeekableReadStream;
33class WriteStream;
34}
35
36namespace Graphics {
37struct Surface;
38}
39
40namespace Image {
41
57class PNGDecoder : public ImageDecoder {
58public:
59 PNGDecoder();
61
62 bool loadStream(Common::SeekableReadStream &stream) override;
63 void destroy() override;
64 const Graphics::Surface *getSurface() const override { return _outputSurface; }
65 const Graphics::Palette &getPalette() const override { return _palette; }
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; }
70private:
71 Graphics::PixelFormat getByteOrderRgbaPixelFormat(bool isAlpha) const;
72
73 Graphics::Palette _palette;
74
75 // flag to skip the png signature check for headless png files
76 bool _skipSignature;
77
78 // Flag to keep paletted images paletted, even when the image has transparency
79 bool _keepTransparencyPaletted;
80 bool _hasTransparentColor;
81 uint32 _transparentColor;
82
83 Graphics::Surface *_outputSurface;
84};
85
94bool writePNG(Common::WriteStream &out, const Graphics::Surface &input, const byte *palette = nullptr, uint paletteCount = 256);
95
103bool writePNG(Common::WriteStream &out, const Graphics::Surface &input, const Graphics::Palette &palette);
105} // End of namespace Image
106
107#endif
Definition: stream.h:745
Definition: stream.h:77
Simple class for handling a palette data.
Definition: palette.h:61
Definition: image_decoder.h:53
Definition: png.h:57
const Graphics::Palette & getPalette() const override
Definition: png.h:65
bool hasTransparentColor() const override
Definition: png.h:66
uint32 getTransparentColor() const override
Definition: png.h:67
const Graphics::Surface * getSurface() const override
Definition: png.h:64
void destroy() override
bool loadStream(Common::SeekableReadStream &stream) override
bool isAlpha(int c)
bool writePNG(Common::WriteStream &out, const Graphics::Surface &input, const Graphics::Palette &palette)
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: pixelformat.h:138
Definition: surface.h:67