ScummVM API documentation
png_loader.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 PSP_PNG_IMAGE_H
23 #define PSP_PNG_IMAGE_H
24 
25 #include <png.h>
26 
27 class PngLoader {
28 private:
29  bool basicImageLoad(); // common operation
30  bool findImageDimensions(); // find dimensions of a given PNG file
31  bool loadImageIntoBuffer();
32 
33  static void warningFn(png_structp png_ptr, png_const_charp warning_msg);
34  static void libReadFunc(png_structp pngPtr, png_bytep data, png_size_t length);
35 
37  Buffer *_buffer;
38  Palette *_palette;
39 
40  uint32 _width;
41  uint32 _height;
42  uint32 _paletteSize;
43  Buffer::HowToSize _sizeBy;
44 
45  // PNG lib values
46  int _bitDepth;
47  png_structp _pngPtr;
48  png_infop _infoPtr;
49  int _colorType;
50  uint32 _channels;
51 
52 public:
53  enum Status {
54  OK,
55  OUT_OF_MEMORY,
56  BAD_FILE
57  };
58 
59  PngLoader(Common::SeekableReadStream &file, Buffer &buffer, Palette &palette,
60  Buffer::HowToSize sizeBy = Buffer::kSizeByTextureSize) :
61  _file(file), _buffer(&buffer), _palette(&palette),
62  _width(0), _height(0), _paletteSize(0),
63  _bitDepth(0), _sizeBy(sizeBy), _pngPtr(0),
64  _infoPtr(0), _colorType(0), _channels(0) {}
65 
66  PngLoader::Status allocate();
67  bool load();
68 };
69 
70 #endif /* PSP_PNG_IMAGE_H */
Definition: stream.h:745
Definition: display_client.h:113
Definition: png_loader.h:27
Definition: atari-screen.h:44