2011-02-02 15:43:45 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
2021-12-26 17:47:58 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2014-02-18 01:34:20 +00:00
|
|
|
*
|
2011-02-02 15:43:45 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2014-02-18 01:34:20 +00:00
|
|
|
*
|
2011-02-02 15:43:45 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-12-26 17:47:58 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-02-02 15:43:45 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-02-28 02:27:23 +00:00
|
|
|
#ifndef IMAGE_PNG_H
|
|
|
|
#define IMAGE_PNG_H
|
2011-02-02 15:43:45 +00:00
|
|
|
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/textconsole.h"
|
2019-01-31 17:47:29 +00:00
|
|
|
#include "graphics/pixelformat.h"
|
2014-02-28 02:27:23 +00:00
|
|
|
#include "image/image_decoder.h"
|
2011-04-24 08:34:27 +00:00
|
|
|
|
2011-02-02 15:43:45 +00:00
|
|
|
namespace Common {
|
|
|
|
class SeekableReadStream;
|
2017-05-12 17:44:44 +00:00
|
|
|
class WriteStream;
|
2011-02-02 15:43:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace Graphics {
|
2011-04-24 08:34:27 +00:00
|
|
|
struct Surface;
|
2014-02-28 02:27:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace Image {
|
2011-02-02 15:43:45 +00:00
|
|
|
|
2020-11-29 20:41:07 +00:00
|
|
|
/**
|
|
|
|
* @defgroup image_png PNG decoder
|
|
|
|
* @ingroup image
|
|
|
|
*
|
|
|
|
* @brief Decoder for PNG images.
|
|
|
|
*
|
|
|
|
* This decoder has a dependency on the libpng library.
|
|
|
|
*
|
|
|
|
* Used in engines:
|
|
|
|
* - Sword25
|
2023-01-17 05:28:45 +00:00
|
|
|
* - TwinE
|
2020-11-29 20:41:07 +00:00
|
|
|
* - Wintermute
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2012-01-28 22:55:56 +00:00
|
|
|
class PNGDecoder : public ImageDecoder {
|
2011-02-02 15:43:45 +00:00
|
|
|
public:
|
2012-01-28 22:55:56 +00:00
|
|
|
PNGDecoder();
|
|
|
|
~PNGDecoder();
|
|
|
|
|
2021-04-04 11:05:03 +00:00
|
|
|
bool loadStream(Common::SeekableReadStream &stream) override;
|
|
|
|
void destroy() override;
|
|
|
|
const Graphics::Surface *getSurface() const override { return _outputSurface; }
|
|
|
|
const byte *getPalette() const override { return _palette; }
|
|
|
|
uint16 getPaletteColorCount() const override { return _paletteColorCount; }
|
2023-02-22 18:09:10 +00:00
|
|
|
bool hasTransparentColor() const override { return _hasTransparentColor; }
|
|
|
|
uint32 getTransparentColor() const override { return _transparentColor; }
|
2017-07-01 11:41:42 +00:00
|
|
|
void setSkipSignature(bool skip) { _skipSignature = skip; }
|
2019-08-02 05:00:29 +00:00
|
|
|
void setKeepTransparencyPaletted(bool keep) { _keepTransparencyPaletted = keep; }
|
2011-02-02 15:43:45 +00:00
|
|
|
private:
|
2021-06-27 18:16:43 +00:00
|
|
|
Graphics::PixelFormat getByteOrderRgbaPixelFormat(bool isAlpha) const;
|
2019-01-31 17:47:29 +00:00
|
|
|
|
2012-08-12 21:50:25 +00:00
|
|
|
byte *_palette;
|
|
|
|
uint16 _paletteColorCount;
|
2011-02-02 15:43:45 +00:00
|
|
|
|
2017-07-01 11:41:42 +00:00
|
|
|
// flag to skip the png signature check for headless png files
|
|
|
|
bool _skipSignature;
|
|
|
|
|
2019-08-02 05:00:29 +00:00
|
|
|
// Flag to keep paletted images paletted, even when the image has transparency
|
|
|
|
bool _keepTransparencyPaletted;
|
2023-02-22 18:09:10 +00:00
|
|
|
bool _hasTransparentColor;
|
|
|
|
uint32 _transparentColor;
|
2019-08-02 05:00:29 +00:00
|
|
|
|
2012-01-28 22:55:56 +00:00
|
|
|
Graphics::Surface *_outputSurface;
|
2011-02-02 15:43:45 +00:00
|
|
|
};
|
|
|
|
|
2017-05-12 17:44:44 +00:00
|
|
|
/**
|
|
|
|
* Outputs a compressed PNG stream of the given input surface.
|
2021-03-15 00:46:00 +00:00
|
|
|
*
|
|
|
|
* @param out Stream to which to write the PNG image.
|
|
|
|
* @param input The surface to save as a PNG image..
|
|
|
|
* @param palette The palette (in RGB888), if the source format has a bpp of 1.
|
2017-05-12 17:44:44 +00:00
|
|
|
*/
|
2021-03-15 00:46:00 +00:00
|
|
|
bool writePNG(Common::WriteStream &out, const Graphics::Surface &input, const byte *palette = nullptr);
|
2020-11-29 20:41:07 +00:00
|
|
|
/** @} */
|
2014-02-28 02:27:23 +00:00
|
|
|
} // End of namespace Image
|
2011-02-02 15:43:45 +00:00
|
|
|
|
2014-02-28 02:27:23 +00:00
|
|
|
#endif
|