2 * pnglite.h - Interface for pnglite library
3 * Copyright (c) 2007 Daniel Karling
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
13 * 1. The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software
15 * in a product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
18 * 2. Altered source versions must be plainly marked as such, and must not
19 * be misrepresented as being the original software.
21 * 3. This notice may not be removed or altered from any source
25 * daniel.karling@gmail.com
39 * Enumerations for pnglite.
40 * Negative numbers are error codes and 0 and up are okay responses.
47 PNG_HEADER_ERROR = -2,
51 PNG_MEMORY_ERROR = -6,
53 PNG_UNKNOWN_FILTER = -8,
54 PNG_NOT_SUPPORTED = -9,
55 PNG_WRONG_ARGUMENTS = -10
59 * The five different kinds of color storage in PNG files.
66 PNG_GREYSCALE_ALPHA = 4,
67 PNG_TRUECOLOR_ALPHA = 6
71 void *zs; /* pointer to z_stream */
75 unsigned char *png_data;
81 unsigned char color_type;
82 unsigned char compression_method;
83 unsigned char filter_method;
84 unsigned char interlace_method;
87 unsigned char *readbuf;
95 * This function is used to open a png file with the internal file
99 * png - Empty png_t struct.
100 * filename - Filename of the file to be opened.
103 * PNG_NO_ERROR on success, otherwise an error code.
106 int png_open(png_t *png, const char *filename);
109 * Function: png_print_info
111 * This function prints some info about the opened png file to stdout.
114 * png - png struct to get info from.
117 void png_print_info(png_t *png);
120 * Function: png_error_string
122 * This function translates an error code to a human readable string.
125 * error - Error code.
131 char *png_error_string(int error);
134 * Function: png_get_data
136 * This function decodes the opened png file and stores the result in data.
137 * data should be big enough to hold the decoded png.
138 * Required size will be:
140 * > width*height*(bytes per pixel)
143 * data - Where to store result.
146 * PNG_NO_ERROR on success, otherwise an error code.
149 int png_get_data(png_t *png, uint8_t *data);
152 * Function: png_close
154 * Closes an open png file pointer.
157 * png - png to close.
163 int png_close(png_t *png);
169 #endif /* _PNGLITE_H_ */