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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 /* 24 * PNG decoder used in engines: 25 * - sword25 26 * - wintermute 27 * Dependencies: 28 * - libpng 29 */ 30 31 #ifndef IMAGE_PNG_H 32 #define IMAGE_PNG_H 33 34 #include "common/scummsys.h" 35 #include "common/textconsole.h" 36 #include "image/image_decoder.h" 37 38 namespace Common { 39 class SeekableReadStream; 40 class WriteStream; 41 } 42 43 namespace Graphics { 44 struct Surface; 45 } 46 47 namespace Image { 48 49 class PNGDecoder : public ImageDecoder { 50 public: 51 PNGDecoder(); 52 ~PNGDecoder(); 53 54 bool loadStream(Common::SeekableReadStream &stream); 55 void destroy(); getSurface()56 const Graphics::Surface *getSurface() const { return _outputSurface; } getPalette()57 const byte *getPalette() const { return _palette; } getPaletteColorCount()58 uint16 getPaletteColorCount() const { return _paletteColorCount; } setSkipSignature(bool skip)59 void setSkipSignature(bool skip) { _skipSignature = skip; } 60 private: 61 byte *_palette; 62 uint16 _paletteColorCount; 63 64 // flag to skip the png signature check for headless png files 65 bool _skipSignature; 66 67 Graphics::Surface *_outputSurface; 68 }; 69 70 /** 71 * Outputs a compressed PNG stream of the given input surface. 72 * 73 * @param bottomUp Flip the vertical axis so pixel data is drawn from the 74 * bottom up, instead of from the top down. 75 */ 76 bool writePNG(Common::WriteStream &out, const Graphics::Surface &input, const bool bottomUp = false); 77 78 } // End of namespace Image 79 80 #endif 81