Comment out x86 asm.
[AROS.git] / compiler / libpng / libpng.3
blobecc42777bf489587d2d4edc71d4526b9bf6e48ac
1 .TH LIBPNG 3 "February 3, 2011"
2 .SH NAME
3 libpng \- Portable Network Graphics (PNG) Reference Library 1.5.1
4 .SH SYNOPSIS
5 \fI\fB
7 \fB#include <png.h>\fP
9 \fI\fB
11 \fBpng_uint_32 png_access_version_number \fI(void\fP\fB);\fP
13 \fI\fB
15 \fBvoid png_benign_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP
17 \fI\fB
19 \fBvoid png_build_grayscale_palette (int \fP\fIbit_depth\fP\fB, png_colorp \fIpalette\fP\fB);\fP
21 \fI\fB
23 \fBpng_voidp png_calloc (png_structp \fP\fIpng_ptr\fP\fB, png_alloc_size_t \fIsize\fP\fB);\fP
25 \fI\fB
27 \fBvoid png_chunk_benign_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP
29 \fI\fB
31 \fBvoid png_chunk_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP
33 \fI\fB
35 \fBvoid png_chunk_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP
37 \fI\fB
39 \fBvoid png_convert_from_struct_tm (png_timep \fP\fIptime\fP\fB, struct tm FAR * \fIttime\fP\fB);\fP
41 \fI\fB
43 \fBvoid png_convert_from_time_t (png_timep \fP\fIptime\fP\fB, time_t \fIttime\fP\fB);\fP
45 \fI\fB
47 \fBpng_charp png_convert_to_rfc1123 (png_structp \fP\fIpng_ptr\fP\fB, png_timep \fIptime\fP\fB);\fP
49 \fI\fB
51 \fBpng_infop png_create_info_struct (png_structp \fIpng_ptr\fP\fB);\fP
53 \fI\fB
55 \fBpng_structp png_create_read_struct (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarn_fn\fP\fB);\fP
57 \fI\fB
59 \fBpng_structp png_create_read_struct_2 (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fP\fIwarn_fn\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP
61 \fI\fB
63 \fBpng_structp png_create_write_struct (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarn_fn\fP\fB);\fP
65 \fI\fB
67 \fBpng_structp png_create_write_struct_2 (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fP\fIwarn_fn\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP
69 \fI\fB
71 \fBvoid png_data_freer (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIfreer\fP\fB, png_uint_32 \fImask)\fP\fB);\fP
73 \fI\fB
75 \fBvoid png_destroy_info_struct (png_structp \fP\fIpng_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP
77 \fI\fB
79 \fBvoid png_destroy_read_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fP\fIinfo_ptr_ptr\fP\fB, png_infopp \fIend_info_ptr_ptr\fP\fB);\fP
81 \fI\fB
83 \fBvoid png_destroy_write_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP
85 \fI\fB
87 \fBvoid png_err (png_structp \fIpng_ptr\fP\fB);\fP
89 \fI\fB
91 \fBvoid png_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP
93 \fI\fB
95 \fBvoid png_free (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP
97 \fI\fB
99 \fBvoid png_free_chunk_list (png_structp \fIpng_ptr\fP\fB);\fP
101 \fI\fB
103 \fBvoid png_free_default (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP
105 \fI\fB
107 \fBvoid png_free_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fInum\fP\fB);\fP
109 \fI\fB
111 \fBpng_byte png_get_bit_depth (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
113 \fI\fB
115 \fBpng_uint_32 png_get_bKGD (png_const_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fI*background\fP\fB);\fP
117 \fI\fB
119 \fBpng_byte png_get_channels (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
121 \fI\fB
123 \fBpng_uint_32 png_get_cHRM (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, double \fP\fI*white_x\fP\fB, double \fP\fI*white_y\fP\fB, double \fP\fI*red_x\fP\fB, double \fP\fI*red_y\fP\fB, double \fP\fI*green_x\fP\fB, double \fP\fI*green_y\fP\fB, double \fP\fI*blue_x\fP\fB, double \fI*blue_y\fP\fB);\fP
125 \fI\fB
127 \fBpng_uint_32 png_get_cHRM_fixed (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*white_x\fP\fB, png_uint_32 \fP\fI*white_y\fP\fB, png_uint_32 \fP\fI*red_x\fP\fB, png_uint_32 \fP\fI*red_y\fP\fB, png_uint_32 \fP\fI*green_x\fP\fB, png_uint_32 \fP\fI*green_y\fP\fB, png_uint_32 \fP\fI*blue_x\fP\fB, png_uint_32 \fI*blue_y\fP\fB);\fP
129 \fI\fB
131 \fBpng_uint_32 png_get_chunk_cache_max (png_const_structp \fIpng_ptr\fP\fB);\fP
133 \fI\fB
135 \fI\fB
137 \fBpng_alloc_size_t png_get_chunk_malloc_max (png_const_structp \fIpng_ptr\fP\fB);\fP
139 \fI\fB
141 \fBpng_byte png_get_color_type (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
143 \fI\fB
145 \fBpng_uint_32 png_get_compression_buffer_size (png_const_structp \fIpng_ptr\fP\fB);\fP
147 \fI\fB
149 \fBpng_byte png_get_compression_type (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
151 \fI\fB
153 \fBpng_byte png_get_copyright (png_const_structp \fIpng_ptr\fP\fB);\fP
155 \fI\fB
157 \fBpng_uint_32 png_get_current_row_number \fI(png_const_structp\fP\fB);\fP
159 \fI\fB
161 \fBpng_byte png_get_current_pass_number \fI(png_const_structp\fP\fB);\fP
163 \fI\fB
165 \fBpng_voidp png_get_error_ptr (png_const_structp \fIpng_ptr\fP\fB);\fP
167 \fI\fB
169 \fBpng_byte png_get_filter_type (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
171 \fI\fB
173 \fBpng_uint_32 png_get_gAMA (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, double \fI*file_gamma\fP\fB);\fP
175 \fI\fB
177 \fBpng_uint_32 png_get_gAMA_fixed (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fI*int_file_gamma\fP\fB);\fP
179 \fI\fB
181 \fBpng_byte png_get_header_ver (png_const_structp \fIpng_ptr\fP\fB);\fP
183 \fI\fB
185 \fBpng_byte png_get_header_version (png_const_structp \fIpng_ptr\fP\fB);\fP
187 \fI\fB
189 \fBpng_uint_32 png_get_hIST (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fI*hist\fP\fB);\fP
191 \fI\fB
193 \fBpng_uint_32 png_get_iCCP (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_charpp \fP\fIname\fP\fB, int \fP\fI*compression_type\fP\fB, png_bytepp \fP\fIprofile\fP\fB, png_uint_32 \fI*proflen\fP\fB);\fP
195 \fI\fB
197 \fBpng_uint_32 png_get_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*width\fP\fB, png_uint_32 \fP\fI*height\fP\fB, int \fP\fI*bit_depth\fP\fB, int \fP\fI*color_type\fP\fB, int \fP\fI*interlace_type\fP\fB, int \fP\fI*compression_type\fP\fB, int \fI*filter_type\fP\fB);\fP
199 \fI\fB
201 \fBpng_uint_32 png_get_image_height (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
203 \fI\fB
205 \fBpng_uint_32 png_get_image_width (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
207 \fI\fB
209 \fBpng_int_32 png_get_int_32 (png_bytep \fIbuf\fP\fB);\fP
211 \fI\fB
213 \fBpng_byte png_get_interlace_type (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
215 \fI\fB
217 \fBpng_const_bytep png_get_io_chunk_name (png_structp \fIpng_ptr\fP\fB);\fP
219 \fI\fB
221 \fBpng_uint_32 png_get_io_chunk_type (png_const_structp \fIpng_ptr\fP\fB);\fP
223 \fI\fB
225 \fBpng_voidp png_get_io_ptr (png_structp \fIpng_ptr\fP\fB);\fP
227 \fI\fB
229 \fBpng_uint_32 png_get_io_state (png_structp \fIpng_ptr\fP\fB);\fP
231 \fI\fB
233 \fBpng_byte png_get_libpng_ver (png_const_structp \fIpng_ptr\fP\fB);\fP
235 \fI\fB
237 \fBpng_voidp png_get_mem_ptr (png_const_structp \fIpng_ptr\fP\fB);\fP
239 \fI\fB
241 \fBpng_uint_32 png_get_oFFs (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*offset_x\fP\fB, png_uint_32 \fP\fI*offset_y\fP\fB, int \fI*unit_type\fP\fB);\fP
243 \fI\fB
245 \fBpng_uint_32 png_get_pCAL (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fI*purpose\fP\fB, png_int_32 \fP\fI*X0\fP\fB, png_int_32 \fP\fI*X1\fP\fB, int \fP\fI*type\fP\fB, int \fP\fI*nparams\fP\fB, png_charp \fP\fI*units\fP\fB, png_charpp \fI*params\fP\fB);\fP
247 \fI\fB
249 \fBpng_uint_32 png_get_pHYs (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*res_x\fP\fB, png_uint_32 \fP\fI*res_y\fP\fB, int \fI*unit_type\fP\fB);\fP
251 \fI\fB
253 \fBfloat png_get_pixel_aspect_ratio (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
255 \fI\fB
257 \fBpng_uint_32 png_get_pHYs_dpi (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*res_x\fP\fB, png_uint_32 \fP\fI*res_y\fP\fB, int \fI*unit_type\fP\fB);\fP
259 \fI\fB
261 \fBpng_fixed_point png_get_pixel_aspect_ratio_fixed (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
263 \fI\fB
265 \fBpng_uint_32 png_get_pixels_per_inch (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
267 \fI\fB
269 \fBpng_uint_32 png_get_pixels_per_meter (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
271 \fI\fB
273 \fBpng_voidp png_get_progressive_ptr (png_const_structp \fIpng_ptr\fP\fB);\fP
275 \fI\fB
277 \fBpng_uint_32 png_get_PLTE (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_colorp \fP\fI*palette\fP\fB, int \fI*num_palette\fP\fB);\fP
279 \fI\fB
281 \fBpng_byte png_get_rgb_to_gray_status (png_const_structp \fIpng_ptr)
283 \fBpng_uint_32 png_get_rowbytes (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
285 \fI\fB
287 \fBpng_bytepp png_get_rows (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
289 \fI\fB
291 \fBpng_uint_32 png_get_sBIT (png_const_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_8p \fI*sig_bit\fP\fB);\fP
293 \fI\fB
295 \fBvoid png_get_sCAL (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, int* \fP\fIunit\fP\fB, double* \fP\fIwidth\fP\fB, double* \fIheight\fP\fB);\fP
297 \fI\fB
299 \fBvoid png_get_sCAL_fixed (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, int* \fP\fIunit\fP\fB, png_fixed_pointp \fP\fIwidth\fP\fB, png_fixed_pointp \fIheight\fP\fB);\fP
301 \fI\fB
303 \fBvoid png_get_sCAL_s (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, int* \fP\fIunit\fP\fB, png_charpp \fP\fIwidth\fP\fB, png_charpp \fIheight\fP\fB);\fP
305 \fI\fB
307 \fBpng_bytep png_get_signature (png_const_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
309 \fI\fB
311 \fBpng_uint_32 png_get_sPLT (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fI*splt_ptr\fP\fB);\fP
313 \fI\fB
315 \fBpng_uint_32 png_get_sRGB (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, int \fI*file_srgb_intent\fP\fB);\fP
317 \fI\fB
319 \fBpng_uint_32 png_get_text (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fI*text_ptr\fP\fB, int \fI*num_text\fP\fB);\fP
321 \fI\fB
323 \fBpng_uint_32 png_get_tIME (png_const_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fI*mod_time\fP\fB);\fP
325 \fI\fB
327 \fBpng_uint_32 png_get_tRNS (png_const_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fI*trans_alpha\fP\fB, int \fP\fI*num_trans\fP\fB, png_color_16p \fI*trans_color\fP\fB);\fP
329 \fI\fB
331 \fB/* This function is really an inline macro. \fI*/
333 \fBpng_uint_16 png_get_uint_16 (png_bytep \fIbuf\fP\fB);\fP
335 \fI\fB
337 \fBpng_uint_32 png_get_uint_31 (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIbuf\fP\fB);\fP
339 \fI\fB
341 \fB/* This function is really an inline macro. \fI*/
343 \fBpng_uint_32 png_get_uint_32 (png_bytep \fIbuf\fP\fB);\fP
345 \fI\fB
347 \fBpng_uint_32 png_get_unknown_chunks (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkpp \fIunknowns\fP\fB);\fP
349 \fI\fB
351 \fBpng_voidp png_get_user_chunk_ptr (png_const_structp \fIpng_ptr\fP\fB);\fP
353 \fI\fB
355 \fBpng_uint_32 png_get_user_height_max (png_const_structp \fIpng_ptr\fP\fB);\fP
357 \fI\fB
359 \fBpng_voidp png_get_user_transform_ptr (png_const_structp \fIpng_ptr\fP\fB);\fP
361 \fI\fB
363 \fBpng_uint_32 png_get_user_width_max (png_const_structp \fIpng_ptr\fP\fB);\fP
365 \fI\fB
367 \fBpng_uint_32 png_get_valid (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIflag\fP\fB);\fP
369 \fI\fB
371 \fBfloat png_get_x_offset_inches (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
373 \fI\fB
375 \fBpng_fixed_point png_get_x_offset_inches_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
377 \fI\fB
379 \fBpng_int_32 png_get_x_offset_microns (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
381 \fI\fB
383 \fBpng_int_32 png_get_x_offset_pixels (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
385 \fI\fB
387 \fBpng_uint_32 png_get_x_pixels_per_inch (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
389 \fI\fB
391 \fBpng_uint_32 png_get_x_pixels_per_meter (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
393 \fI\fB
395 \fBfloat png_get_y_offset_inches (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
397 \fI\fB
399 \fBpng_fixed_point png_get_y_offset_inches_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
401 \fI\fB
403 \fBpng_int_32 png_get_y_offset_microns (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
405 \fI\fB
407 \fBpng_int_32 png_get_y_offset_pixels (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
409 \fI\fB
411 \fBpng_uint_32 png_get_y_pixels_per_inch (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
413 \fI\fB
415 \fBpng_uint_32 png_get_y_pixels_per_meter (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
417 \fI\fB
419 \fBint png_handle_as_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP
421 \fI\fB
423 \fBvoid png_info_init_3 (png_infopp \fP\fIinfo_ptr\fP\fB, png_size_t \fIpng_info_struct_size\fP\fB);\fP
425 \fI\fB
427 \fBvoid png_init_io (png_structp \fP\fIpng_ptr\fP\fB, FILE \fI*fp\fP\fB);\fP
429 \fI\fB
431 \fBvoid png_longjmp (png_structp \fP\fIpng_ptr\fP\fB, int \fIval\fP\fB);\fP
433 \fI\fB
435 \fBpng_voidp png_malloc (png_structp \fP\fIpng_ptr\fP\fB, png_alloc_size_t \fIsize\fP\fB);\fP
437 \fI\fB
439 \fBpng_voidp png_malloc_default (png_structp \fP\fIpng_ptr\fP\fB, png_alloc_size_t \fIsize\fP\fB);\fP
441 \fI\fB
443 \fBpng_voidp png_malloc_warn (png_structp \fP\fIpng_ptr\fP\fB, png_alloc_size_t \fIsize\fP\fB);\fP
445 \fI\fB
447 \fBpng_uint_32 png_permit_mng_features (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fImng_features_permitted\fP\fB);\fP
449 \fI\fB
451 \fBvoid png_process_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_size\fP\fB);\fP
453 \fI\fB
455 \fBpng_size_t png_process_data_pause \fP\fI(png_structp\fP\fB, int \fIsave\fP\fB);\fP
457 \fI\fB
459 \fBpng_uint_32 png_process_data_skip \fI(png_structp\fP\fB);\fP
461 \fI\fB
463 \fBvoid png_progressive_combine_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIold_row\fP\fB, png_bytep \fInew_row\fP\fB);\fP
465 \fI\fB
467 \fBvoid png_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
469 \fI\fB
471 \fBvoid png_read_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP
473 \fI\fB
475 \fBvoid png_read_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
477 \fI\fB
479 \fBvoid png_read_png (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fItransforms\fP\fB, png_voidp \fIparams\fP\fB);\fP
481 \fI\fB
483 \fBvoid png_read_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fIdisplay_row\fP\fB);\fP
485 \fI\fB
487 \fBvoid png_read_rows (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fP\fIrow\fP\fB, png_bytepp \fP\fIdisplay_row\fP\fB, png_uint_32 \fInum_rows\fP\fB);\fP
489 \fI\fB
491 \fBvoid png_read_update_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
493 \fI\fB
495 \fBint png_reset_zstream (png_structp \fIpng_ptr\fP\fB);\fP
497 \fI\fB
499 \fBvoid png_save_int_32 (png_bytep \fP\fIbuf\fP\fB, png_int_32 \fIi\fP\fB);\fP
501 \fI\fB
503 \fBvoid png_save_uint_16 (png_bytep \fP\fIbuf\fP\fB, unsigned int \fIi\fP\fB);\fP
505 \fI\fB
507 \fBvoid png_save_uint_32 (png_bytep \fP\fIbuf\fP\fB, png_uint_32 \fIi\fP\fB);\fP
509 \fI\fB
511 \fBvoid png_set_add_alpha (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP
513 \fI\fB
515 \fBvoid png_set_background (png_structp \fP\fIpng_ptr\fP\fB, png_color_16p \fP\fIbackground_color\fP\fB, int \fP\fIbackground_gamma_code\fP\fB, int \fP\fIneed_expand\fP\fB, double \fIbackground_gamma\fP\fB);\fP
517 \fI\fB
519 \fBvoid png_set_background_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_color_16p \fP\fIbackground_color\fP\fB, int \fP\fIbackground_gamma_code\fP\fB, int \fP\fIneed_expand\fP\fB, png_uint_32 \fIbackground_gamma\fP\fB);\fP
521 \fI\fB
523 \fBvoid png_set_benign_errors (png_structp \fP\fIpng_ptr\fP\fB, int \fIallowed\fP\fB);\fP
525 \fI\fB
527 \fBvoid png_set_bgr (png_structp \fIpng_ptr\fP\fB);\fP
529 \fI\fB
531 \fBvoid png_set_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fIbackground\fP\fB);\fP
533 \fI\fB
535 \fBvoid png_set_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP
537 \fI\fB
539 \fBvoid png_set_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIwhite_x\fP\fB, png_uint_32 \fP\fIwhite_y\fP\fB, png_uint_32 \fP\fIred_x\fP\fB, png_uint_32 \fP\fIred_y\fP\fB, png_uint_32 \fP\fIgreen_x\fP\fB, png_uint_32 \fP\fIgreen_y\fP\fB, png_uint_32 \fP\fIblue_x\fP\fB, png_uint_32 \fIblue_y\fP\fB);\fP
541 \fI\fB
543 \fBvoid png_set_chunk_cache_max (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIuser_chunk_cache_max\fP\fB);\fP
545 \fI\fB
547 \fBvoid png_set_compression_level (png_structp \fP\fIpng_ptr\fP\fB, int \fIlevel\fP\fB);\fP
549 \fI\fB
551 \fBvoid png_set_compression_mem_level (png_structp \fP\fIpng_ptr\fP\fB, int \fImem_level\fP\fB);\fP
553 \fI\fB
555 \fBvoid png_set_compression_method (png_structp \fP\fIpng_ptr\fP\fB, int \fImethod\fP\fB);\fP
557 \fI\fB
559 \fBvoid png_set_compression_strategy (png_structp \fP\fIpng_ptr\fP\fB, int \fIstrategy\fP\fB);\fP
561 \fI\fB
563 \fBvoid png_set_compression_window_bits (png_structp \fP\fIpng_ptr\fP\fB, int \fIwindow_bits\fP\fB);\fP
565 \fI\fB
567 \fBvoid png_set_crc_action (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcrit_action\fP\fB, int \fIancil_action\fP\fB);\fP
569 \fI\fB
571 \fBvoid png_set_error_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarning_fn\fP\fB);\fP
573 \fI\fB
575 \fBvoid png_set_expand (png_structp \fIpng_ptr\fP\fB);\fP
577 \fI\fB
579 \fBvoid png_set_expand_gray_1_2_4_to_8 (png_structp \fIpng_ptr\fP\fB);\fP
581 \fI\fB
583 \fBvoid png_set_filler (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP
585 \fI\fB
587 \fBvoid png_set_filter (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fImethod\fP\fB, int \fIfilters\fP\fB);\fP
589 \fI\fB
591 \fBvoid png_set_filter_heuristics (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIheuristic_method\fP\fB, int \fP\fInum_weights\fP\fB, png_doublep \fP\fIfilter_weights\fP\fB, png_doublep \fIfilter_costs\fP\fB);\fP
593 \fI\fB
595 \fBvoid png_set_filter_heuristics_fixed (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIheuristic_method\fP\fB, int \fP\fInum_weights\fP\fB, png_fixed_point_p \fP\fIfilter_weights\fP\fB, png_fixed_point_p \fIfilter_costs\fP\fB);\fP
597 \fI\fB
599 \fBvoid png_set_flush (png_structp \fP\fIpng_ptr\fP\fB, int \fInrows\fP\fB);\fP
601 \fI\fB
603 \fBvoid png_set_gamma (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIscreen_gamma\fP\fB, double \fIdefault_file_gamma\fP\fB);\fP
605 \fI\fB
607 \fBvoid png_set_gamma_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIscreen_gamma\fP\fB, png_uint_32 \fIdefault_file_gamma\fP\fB);\fP
609 \fI\fB
611 \fBvoid png_set_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fIfile_gamma\fP\fB);\fP
613 \fI\fB
615 \fBvoid png_set_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIfile_gamma\fP\fB);\fP
617 \fI\fB
619 \fBvoid png_set_gray_1_2_4_to_8 (png_structp \fIpng_ptr\fP\fB);\fP
621 \fI\fB
623 \fBvoid png_set_gray_to_rgb (png_structp \fIpng_ptr\fP\fB);\fP
625 \fI\fB
627 \fBvoid png_set_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fIhist\fP\fB);\fP
629 \fI\fB
631 \fBvoid png_set_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_const_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_const_bytep \fP\fIprofile\fP\fB, png_uint_32 \fIproflen\fP\fB);\fP
633 \fI\fB
635 \fBint png_set_interlace_handling (png_structp \fIpng_ptr\fP\fB);\fP
637 \fI\fB
639 \fBvoid png_set_invalid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fImask\fP\fB);\fP
641 \fI\fB
643 \fBvoid png_set_invert_alpha (png_structp \fIpng_ptr\fP\fB);\fP
645 \fI\fB
647 \fBvoid png_set_invert_mono (png_structp \fIpng_ptr\fP\fB);\fP
649 \fI\fB
651 \fBvoid png_set_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIwidth\fP\fB, png_uint_32 \fP\fIheight\fP\fB, int \fP\fIbit_depth\fP\fB, int \fP\fIcolor_type\fP\fB, int \fP\fIinterlace_type\fP\fB, int \fP\fIcompression_type\fP\fB, int \fIfilter_type\fP\fB);\fP
653 \fI\fB
655 \fBvoid png_set_keep_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIkeep\fP\fB, png_bytep \fP\fIchunk_list\fP\fB, int \fInum_chunks\fP\fB);\fP
657 \fI\fB
659 \fBjmp_buf* png_set_longjmp_fn (png_structp \fP\fIpng_ptr\fP\fB, png_longjmp_ptr \fP\fIlongjmp_fn\fP\fB, size_t \fIjmp_buf_size\fP\fB);\fP
661 \fI\fB
663 \fBvoid png_set_chunk_malloc_max (png_structp \fP\fIpng_ptr\fP\fB, png_alloc_size_t \fIuser_chunk_cache_max\fP\fB);\fP
665 \fI\fB
667 \fBvoid png_set_compression_buffer_size (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
669 \fI\fB
671 \fBvoid png_set_mem_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP
673 \fI\fB
675 \fBvoid png_set_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIoffset_x\fP\fB, png_uint_32 \fP\fIoffset_y\fP\fB, int \fIunit_type\fP\fB);\fP
677 \fI\fB
679 \fBvoid png_set_packing (png_structp \fIpng_ptr\fP\fB);\fP
681 \fI\fB
683 \fBvoid png_set_packswap (png_structp \fIpng_ptr\fP\fB);\fP
685 \fI\fB
687 \fBvoid png_set_palette_to_rgb (png_structp \fIpng_ptr\fP\fB);\fP
689 \fI\fB
691 \fBvoid png_set_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIpurpose\fP\fB, png_int_32 \fP\fIX0\fP\fB, png_int_32 \fP\fIX1\fP\fB, int \fP\fItype\fP\fB, int \fP\fInparams\fP\fB, png_charp \fP\fIunits\fP\fB, png_charpp \fIparams\fP\fB);\fP
693 \fI\fB
695 \fBvoid png_set_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIres_x\fP\fB, png_uint_32 \fP\fIres_y\fP\fB, int \fIunit_type\fP\fB);\fP
697 \fI\fB
699 \fBvoid png_set_progressive_read_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIprogressive_ptr\fP\fB, png_progressive_info_ptr \fP\fIinfo_fn\fP\fB, png_progressive_row_ptr \fP\fIrow_fn\fP\fB, png_progressive_end_ptr \fIend_fn\fP\fB);\fP
701 \fI\fB
703 \fBvoid png_set_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fInum_palette\fP\fB);\fP
705 \fI\fB
707 \fBvoid png_set_quantize (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fP\fInum_palette\fP\fB, int \fP\fImaximum_colors\fP\fB, png_uint_16p \fP\fIhistogram\fP\fB, int \fIfull_quantize\fP\fB);\fP
709 \fI\fB
711 \fBvoid png_set_read_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIio_ptr\fP\fB, png_rw_ptr \fIread_data_fn\fP\fB);\fP
713 \fI\fB
715 \fBvoid png_set_read_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_read_status_ptr \fIread_row_fn\fP\fB);\fP
717 \fI\fB
719 \fBvoid png_set_read_user_chunk_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIuser_chunk_ptr\fP\fB, png_user_chunk_ptr \fIread_user_chunk_fn\fP\fB);\fP
721 \fI\fB
723 \fBvoid png_set_read_user_transform_fn (png_structp \fP\fIpng_ptr\fP\fB, png_user_transform_ptr \fIread_user_transform_fn\fP\fB);\fP
725 \fI\fB
727 \fBvoid png_set_rgb_to_gray (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIerror_action\fP\fB, double \fP\fIred\fP\fB, double \fIgreen\fP\fB);\fP
729 \fI\fB
731 \fBvoid png_set_rgb_to_gray_fixed (png_structp \fP\fIpng_ptr\fP\fB, int error_action png_uint_32 \fP\fIred\fP\fB, png_uint_32 \fIgreen\fP\fB);\fP
733 \fI\fB
735 \fBvoid png_set_rows (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytepp \fIrow_pointers\fP\fB);\fP
737 \fI\fB
739 \fBvoid png_set_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_8p \fIsig_bit\fP\fB);\fP
741 \fI\fB
743 \fBvoid png_set_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIunit\fP\fB, double \fP\fIwidth\fP\fB, double \fIheight\fP\fB);\fP
745 \fI\fB
747 \fBvoid png_set_sCAL_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIunit\fP\fB, png_fixed_point \fP\fIwidth\fP\fB, png_fixed_point \fIheight\fP\fB);\fP
749 \fI\fB
751 \fBvoid png_set_sCAL_s (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIunit\fP\fB, png_charp \fP\fIwidth\fP\fB, png_charp \fIheight\fP\fB);\fP
753 \fI\fB
755 \fBvoid png_set_shift (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fItrue_bits\fP\fB);\fP
757 \fI\fB
759 \fBvoid png_set_sig_bytes (png_structp \fP\fIpng_ptr\fP\fB, int \fInum_bytes\fP\fB);\fP
761 \fI\fB
763 \fBvoid png_set_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fP\fIsplt_ptr\fP\fB, int \fInum_spalettes\fP\fB);\fP
765 \fI\fB
767 \fBvoid png_set_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIsrgb_intent\fP\fB);\fP
769 \fI\fB
771 \fBvoid png_set_sRGB_gAMA_and_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIsrgb_intent\fP\fB);\fP
773 \fI\fB
775 \fBvoid png_set_strip_16 (png_structp \fIpng_ptr\fP\fB);\fP
777 \fI\fB
779 \fBvoid png_set_strip_alpha (png_structp \fIpng_ptr\fP\fB);\fP
781 \fI\fB
783 \fBvoid png_set_strip_error_numbers (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIstrip_mode\fP\fB);\fP
785 \fI\fB
787 \fBvoid png_set_swap (png_structp \fIpng_ptr\fP\fB);\fP
789 \fI\fB
791 \fBvoid png_set_swap_alpha (png_structp \fIpng_ptr\fP\fB);\fP
793 \fI\fB
795 \fBvoid png_set_text (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fItext_ptr\fP\fB, int \fInum_text\fP\fB);\fP
797 \fI\fB
799 \fBvoid png_set_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fImod_time\fP\fB);\fP
801 \fI\fB
803 \fBvoid png_set_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fItrans_alpha\fP\fB, int \fP\fInum_trans\fP\fB, png_color_16p \fItrans_color\fP\fB);\fP
805 \fI\fB
807 \fBvoid png_set_tRNS_to_alpha (png_structp \fIpng_ptr\fP\fB);\fP
809 \fI\fB
811 \fBpng_uint_32 png_set_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkp \fP\fIunknowns\fP\fB, int \fP\fInum\fP\fB, int \fIlocation\fP\fB);\fP
813 \fI\fB
815 \fBvoid png_set_unknown_chunk_location (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIchunk\fP\fB, int \fIlocation\fP\fB);\fP
817 \fI\fB
819 \fBvoid png_set_user_limits (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIuser_width_max\fP\fB, png_uint_32 \fIuser_height_max\fP\fB);\fP
821 \fI\fB
823 \fBvoid png_set_user_transform_info (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIuser_transform_ptr\fP\fB, int \fP\fIuser_transform_depth\fP\fB, int \fIuser_transform_channels\fP\fB);\fP
825 \fI\fB
827 \fBvoid png_set_write_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIio_ptr\fP\fB, png_rw_ptr \fP\fIwrite_data_fn\fP\fB, png_flush_ptr \fIoutput_flush_fn\fP\fB);\fP
829 \fI\fB
831 \fBvoid png_set_write_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_write_status_ptr \fIwrite_row_fn\fP\fB);\fP
833 \fI\fB
835 \fBvoid png_set_write_user_transform_fn (png_structp \fP\fIpng_ptr\fP\fB, png_user_transform_ptr \fIwrite_user_transform_fn\fP\fB);\fP
837 \fI\fB
839 \fBint png_sig_cmp (png_bytep \fP\fIsig\fP\fB, png_size_t \fP\fIstart\fP\fB, png_size_t \fInum_to_check\fP\fB);\fP
841 \fI\fB
843 \fBvoid png_start_read_image (png_structp \fIpng_ptr\fP\fB);\fP
845 \fI\fB
847 \fBvoid png_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP
849 \fI\fB
851 \fBvoid png_write_chunk (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIchunk_name\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP
853 \fI\fB
855 \fBvoid png_write_chunk_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP
857 \fI\fB
859 \fBvoid png_write_chunk_end (png_structp \fIpng_ptr\fP\fB);\fP
861 \fI\fB
863 \fBvoid png_write_chunk_start (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIchunk_name\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
865 \fI\fB
867 \fBvoid png_write_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
869 \fI\fB
871 \fBvoid png_write_flush (png_structp \fIpng_ptr\fP\fB);\fP
873 \fI\fB
875 \fBvoid png_write_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP
877 \fI\fB
879 \fBvoid png_write_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
881 \fI\fB
883 \fBvoid png_write_info_before_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
885 \fI\fB
887 \fBvoid png_write_png (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fItransforms\fP\fB, png_voidp \fIparams\fP\fB);\fP
889 \fI\fB
891 \fBvoid png_write_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIrow\fP\fB);\fP
893 \fI\fB
895 \fBvoid png_write_rows (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fP\fIrow\fP\fB, png_uint_32 \fInum_rows\fP\fB);\fP
897 \fI\fB
899 \fBvoid png_write_sig (png_structp \fIpng_ptr\fP\fB);\fP
901 \fI\fB
903 \fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP
905 \fI\fB
907 \fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP
909 \fI\fB
911 .SH DESCRIPTION
913 .I libpng
914 library supports encoding, decoding, and various manipulations of
915 the Portable Network Graphics (PNG) format image files.  It uses the
916 .IR zlib(3)
917 compression library.
918 Following is a copy of the libpng-manual.txt file that accompanies libpng.
919 .SH LIBPNG.TXT
920 libpng-manual.txt - A description on how to use and modify libpng
922  libpng version 1.5.1 - February 3, 2011
923  Updated and distributed by Glenn Randers-Pehrson
924  <glennrp at users.sourceforge.net>
925  Copyright (c) 1998-2011 Glenn Randers-Pehrson
927  This document is released under the libpng license.
928  For conditions of distribution and use, see the disclaimer
929  and license in png.h
931  Based on:
933  libpng versions 0.97, January 1998, through 1.5.1 - February 3, 2011
934  Updated and distributed by Glenn Randers-Pehrson
935  Copyright (c) 1998-2011 Glenn Randers-Pehrson
937  libpng 1.0 beta 6  version 0.96 May 28, 1997
938  Updated and distributed by Andreas Dilger
939  Copyright (c) 1996, 1997 Andreas Dilger
941  libpng 1.0 beta 2 - version 0.88  January 26, 1996
942  For conditions of distribution and use, see copyright
943  notice in png.h. Copyright (c) 1995, 1996 Guy Eric
944  Schalnat, Group 42, Inc.
946  Updated/rewritten per request in the libpng FAQ
947  Copyright (c) 1995, 1996 Frank J. T. Wojcik
948  December 18, 1995 & January 20, 1996
950 .SH I. Introduction
952 This file describes how to use and modify the PNG reference library
953 (known as libpng) for your own use.  There are five sections to this
954 file: introduction, structures, reading, writing, and modification and
955 configuration notes for various special platforms.  In addition to this
956 file, example.c is a good starting point for using the library, as
957 it is heavily commented and should include everything most people
958 will need.  We assume that libpng is already installed; see the
959 INSTALL file for instructions on how to install libpng.
961 For examples of libpng usage, see the files "example.c", "pngtest.c",
962 and the files in the "contrib" directory, all of which are included in
963 the libpng distribution.
965 Libpng was written as a companion to the PNG specification, as a way
966 of reducing the amount of time and effort it takes to support the PNG
967 file format in application programs.
969 The PNG specification (second edition), November 2003, is available as
970 a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2003 (E)) at
971 <http://www.w3.org/TR/2003/REC-PNG-20031110/
972 The W3C and ISO documents have identical technical content.
974 The PNG-1.2 specification is available at
975 <http://www.libpng.org/pub/png/documents/>.  It is technically equivalent
976 to the PNG specification (second edition) but has some additional material.
978 The PNG-1.0 specification is available
979 as RFC 2083 <http://www.libpng.org/pub/png/documents/> and as a
980 W3C Recommendation <http://www.w3.org/TR/REC.png.html>.
982 Some additional chunks are described in the special-purpose public chunks
983 documents at <http://www.libpng.org/pub/png/documents/>.
985 Other information
986 about PNG, and the latest version of libpng, can be found at the PNG home
987 page, <http://www.libpng.org/pub/png/>.
989 Most users will not have to modify the library significantly; advanced
990 users may want to modify it more.  All attempts were made to make it as
991 complete as possible, while keeping the code easy to understand.
992 Currently, this library only supports C.  Support for other languages
993 is being considered.
995 Libpng has been designed to handle multiple sessions at one time,
996 to be easily modifiable, to be portable to the vast majority of
997 machines (ANSI, K&R, 16-, 32-, and 64-bit) available, and to be easy
998 to use.  The ultimate goal of libpng is to promote the acceptance of
999 the PNG file format in whatever way possible.  While there is still
1000 work to be done (see the TODO file), libpng should cover the
1001 majority of the needs of its users.
1003 Libpng uses zlib for its compression and decompression of PNG files.
1004 Further information about zlib, and the latest version of zlib, can
1005 be found at the zlib home page, <http://www.info-zip.org/pub/infozip/zlib/>.
1006 The zlib compression utility is a general purpose utility that is
1007 useful for more than PNG files, and can be used without libpng.
1008 See the documentation delivered with zlib for more details.
1009 You can usually find the source files for the zlib utility wherever you
1010 find the libpng source files.
1012 Libpng is thread safe, provided the threads are using different
1013 instances of the structures.  Each thread should have its own
1014 png_struct and png_info instances, and thus its own image.
1015 Libpng does not protect itself against two threads using the
1016 same instance of a structure.
1018 .SH II. Structures
1020 There are two main structures that are important to libpng, png_struct
1021 and png_info.  Both are internal structures that are no longer exposed
1022 in the libpng interface (as of libpng 1.5.0).
1024 The png_info structure is designed to provide information about the
1025 PNG file.  At one time, the fields of png_info were intended to be
1026 directly accessible to the user.  However, this tended to cause problems
1027 with applications using dynamically loaded libraries, and as a result
1028 a set of interface functions for png_info (the png_get_*() and png_set_*()
1029 functions) was developed.
1031 The png_struct structure is the object used by the library to decode a
1032 single image.  As of 1.5.0 this structure is also not exposed.
1034 Almost all libpng APIs require a pointer to a png_struct as the first argument.
1035 Many (in particular the png_set and png_get APIs) also require a pointer
1036 to png_info as the second argument.  Some application visible macros
1037 defined in png.h designed for basic data access (reading and writing
1038 integers in the PNG format) break this rule, but it's almost always safe
1039 to assume that a (png_struct*) has to be passed to call an API function.
1041 The png.h header file is an invaluable reference for programming with libpng.
1042 And while I'm on the topic, make sure you include the libpng header file:
1044 #include <png.h>
1046 .SS Types
1048 The png.h header file defines a number of integral types used by the
1049 APIs.  Most of these are fairly obvious; for example types corresponding
1050 to integers of particular sizes and types for passing color values.
1052 One exception is how non-integral numbers are handled.  For application
1053 convenience most APIs that take such numbers have C (double) arguments,
1054 however internally PNG, and libpng, use 32 bit signed integers and encode
1055 the value by multiplying by 100,000.  As of libpng 1.5.0 a convenience
1056 macro PNG_FP_1 is defined in png.h along with a type (png_fixed_point)
1057 which is simply (png_int_32).
1059 All APIs that take (double) arguments also have an matching API that
1060 takes the corresponding fixed point integer arguments.  The fixed point
1061 API has the same name as the floating point one with _fixed appended.
1062 The actual range of values permitted in the APIs is frequently less than
1063 the full range of (png_fixed_point) (-21474 to +21474).  When APIs require
1064 a non-negative argument the type is recorded as png_uint_32 above.  Consult
1065 the header file and the text below for more information.
1067 Special care must be take with sCAL chunk handling because the chunk itself
1068 uses non-integral values encoded as strings containing decimal floating point
1069 numbers.  See the comments in the header file.
1071 .SS Configuration
1073 The main header file function declarations are frequently protected by C
1074 preprocessing directives of the form:
1076     #ifdef PNG_feature_SUPPORTED
1077     declare-function
1078     #endif
1080 The library can be built without support for these APIs, although a
1081 standard build will have all implemented APIs.  Application programs
1082 should check the feature macros before using an API for maximum
1083 portability.  From libpng 1.5.0 the feature macros set during the build
1084 of libpng are recorded in the header file "pnglibconf.h" and this file
1085 is always included by png.h.
1087 If you don't need to change the library configuration from the default skip to
1088 the next section ("Reading").
1090 Notice that some of the makefiles in the 'scripts' directory and (in 1.5.0) all
1091 of the build project files in the 'projects' directory simply copy
1092 scripts/pnglibconf.h.prebuilt to pnglibconf.h.  This means that these build
1093 systems do not permit easy auto-configuration of the library - they only
1094 support the default configuration.
1096 The easiest way to make minor changes to the libpng configuration when
1097 auto-configuration is supported is to add definitions to the command line
1098 using (typically) CPPFLAGS.  For example:
1100 CPPFLAGS=-DPNG_NO_FLOATING_ARITHMETIC
1102 will change the internal libpng math implementation for gamma correction and
1103 other arithmetic calculations to fixed point, avoiding the need for fast
1104 floating point support.  The result can be seen in the generated pnglibconf.h -
1105 make sure it contains the changed feature macro setting.
1107 If you need to make more extensive configuration changes - more than one or two
1108 feature macro settings - you can either add -DPNG_USER_CONFIG to the build
1109 command line and put a list of feature macro settings in pngusr.h or you can set
1110 DFA_XTRA (a makefile variable) to a file containing the same information in the
1111 form of 'option' settings.
1113 A. Changing pnglibconf.h
1115 A variety of methods exist to build libpng.  Not all of these support
1116 reconfiguration of pnglibconf.h.  To reconfigure pnglibconf.h it must either be
1117 rebuilt from scripts/pnglibconf.dfa using awk or it must be edited by hand.
1119 Hand editing is achieved by copying scripts/pnglibconf.h.prebuilt and changing
1120 the lines defining the supported features, paying very close attention to the
1121 'option' information in scripts/pnglibconf.dfa that describes those features and
1122 their requirements.  This is easy to get wrong.
1124 B. Configuration using DFA_XTRA
1126 Rebuilding from pnglibconf.dfa is easy if a functioning 'awk', or a later
1127 variant such as 'nawk' or 'gawk', is available.  The configure build will
1128 automatically find an appropriate awk and build pnglibconf.h.
1129 scripts/pnglibconf.mak contains a set of make rules for doing the same thing if
1130 configure is not used, and many of the makefiles in the scripts directory use
1131 this approach.
1133 When rebuilding simply write new file containing changed options and set
1134 DFA_XTRA to the name of this file.  This causes the build to append the new file
1135 to the end of scripts/pnglibconf.dfa.  pngusr.dfa should contain lines of the
1136 following forms:
1138 everything = off
1140 This turns all optional features off.  Include it at the start of pngusr.dfa to
1141 make it easier to build a minimal configuration.  You will need to turn at least
1142 some features on afterward to enable either reading or writing code, or both.
1144 option feature on
1145 option feature off
1147 Enable or disable a single feature.  This will automatically enable other
1148 features required by a feature that is turned on or disable other features that
1149 require a feature which is turned off.  Conflicting settings will cause an error
1150 message to be emitted by awk.
1152 setting feature default value
1154 Changes the default value of setting 'feature' to 'value'.  There are a small
1155 number of settings listed at the top of pnglibconf.h, they are documented in the
1156 source code.  Most of these values have performance implications for the library
1157 but most of them have no visible effect on the API.  Some can also be overridden
1158 from the API.
1160 C. Configuration using PNG_USR_CONFIG
1162 If -DPNG_USR_CONFIG is added to the CFLAGS when pnglibconf.h is built the file
1163 pngusr.h will automatically be included before the options in
1164 scripts/pnglibconf.dfa are processed.  pngusr.h should contain only macro
1165 definitions turning features on or off or setting settings.
1167 Apart from the global setting "everything = off" all the options listed above
1168 can be set using macros in pngusr.h:
1170 #define PNG_feature_SUPPORTED
1172 is equivalent to:
1174 option feature on
1176 #define PNG_NO_feature
1178 is equivalent to:
1180 option feature off
1182 #define PNG_feature value
1184 is equivalent to:
1186 setting feature default value
1188 Notice that in both cases, pngusr.dfa and pngusr.h, the contents of the
1189 pngusr file you supply override the contents of scripts/pnglibconf.dfa
1191 If confusing or incomprehensible behavior results it is possible to
1192 examine the intermediate file pnglibconf.dfn to find the full set of
1193 dependency information for each setting and option.  Simply locate the
1194 feature in the file and read the C comments that precede it.
1196 .SH III. Reading
1198 We'll now walk you through the possible functions to call when reading
1199 in a PNG file sequentially, briefly explaining the syntax and purpose
1200 of each one.  See example.c and png.h for more detail.  While
1201 progressive reading is covered in the next section, you will still
1202 need some of the functions discussed in this section to read a PNG
1203 file.
1205 .SS Setup
1207 You will want to do the I/O initialization(*) before you get into libpng,
1208 so if it doesn't work, you don't have much to undo.  Of course, you
1209 will also want to insure that you are, in fact, dealing with a PNG
1210 file.  Libpng provides a simple check to see if a file is a PNG file.
1211 To use it, pass in the first 1 to 8 bytes of the file to the function
1212 png_sig_cmp(), and it will return 0 (false) if the bytes match the
1213 corresponding bytes of the PNG signature, or nonzero (true) otherwise.
1214 Of course, the more bytes you pass in, the greater the accuracy of the
1215 prediction.
1217 If you are intending to keep the file pointer open for use in libpng,
1218 you must ensure you don't read more than 8 bytes from the beginning
1219 of the file, and you also have to make a call to png_set_sig_bytes_read()
1220 with the number of bytes you read from the beginning.  Libpng will
1221 then only check the bytes (if any) that your program didn't read.
1223 (*): If you are not using the standard I/O functions, you will need
1224 to replace them with custom functions.  See the discussion under
1225 Customizing libpng.
1228     FILE *fp = fopen(file_name, "rb");
1229     if (!fp)
1230     {
1231        return (ERROR);
1232     }
1234     fread(header, 1, number, fp);
1235     is_png = !png_sig_cmp(header, 0, number);
1237     if (!is_png)
1238     {
1239        return (NOT_PNG);
1240     }
1243 Next, png_struct and png_info need to be allocated and initialized.  In
1244 order to ensure that the size of these structures is correct even with a
1245 dynamically linked libpng, there are functions to initialize and
1246 allocate the structures.  We also pass the library version, optional
1247 pointers to error handling functions, and a pointer to a data struct for
1248 use by the error functions, if necessary (the pointer and functions can
1249 be NULL if the default error handlers are to be used).  See the section
1250 on Changes to Libpng below regarding the old initialization functions.
1251 The structure allocation functions quietly return NULL if they fail to
1252 create the structure, so your application should check for that.
1254     png_structp png_ptr = png_create_read_struct
1255         (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
1256         user_error_fn, user_warning_fn);
1258     if (!png_ptr)
1259        return (ERROR);
1261     png_infop info_ptr = png_create_info_struct(png_ptr);
1263     if (!info_ptr)
1264     {
1265        png_destroy_read_struct(&png_ptr,
1266            (png_infopp)NULL, (png_infopp)NULL);
1267        return (ERROR);
1268     }
1270     png_infop end_info = png_create_info_struct(png_ptr);
1272     if (!end_info)
1273     {
1274        png_destroy_read_struct(&png_ptr, &info_ptr,
1275           (png_infopp)NULL);
1276        return (ERROR);
1277     }
1279 If you want to use your own memory allocation routines,
1280 use a libpng that was built with PNG_USER_MEM_SUPPORTED defined, and use
1281 png_create_read_struct_2() instead of png_create_read_struct():
1283     png_structp png_ptr = png_create_read_struct_2
1284        (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
1285         user_error_fn, user_warning_fn, (png_voidp)
1286         user_mem_ptr, user_malloc_fn, user_free_fn);
1288 The error handling routines passed to png_create_read_struct()
1289 and the memory alloc/free routines passed to png_create_struct_2()
1290 are only necessary if you are not using the libpng supplied error
1291 handling and memory alloc/free functions.
1293 When libpng encounters an error, it expects to longjmp back
1294 to your routine.  Therefore, you will need to call setjmp and pass
1295 your png_jmpbuf(png_ptr).  If you read the file from different
1296 routines, you will need to update the jmpbuf field every time you enter
1297 a new routine that will call a png_*() function.
1299 See your documentation of setjmp/longjmp for your compiler for more
1300 information on setjmp/longjmp.  See the discussion on libpng error
1301 handling in the Customizing Libpng section below for more information
1302 on the libpng error handling.  If an error occurs, and libpng longjmp's
1303 back to your setjmp, you will want to call png_destroy_read_struct() to
1304 free any memory.
1306     if (setjmp(png_jmpbuf(png_ptr)))
1307     {
1308        png_destroy_read_struct(&png_ptr, &info_ptr,
1309            &end_info);
1310        fclose(fp);
1311        return (ERROR);
1312     }
1314 If you would rather avoid the complexity of setjmp/longjmp issues,
1315 you can compile libpng with PNG_NO_SETJMP, in which case
1316 errors will result in a call to PNG_ABORT() which defaults to abort().
1318 You can #define PNG_ABORT() to a function that does something
1319 more useful than abort(), as long as your function does not
1320 return.
1322 Now you need to set up the input code.  The default for libpng is to
1323 use the C function fread().  If you use this, you will need to pass a
1324 valid FILE * in the function png_init_io().  Be sure that the file is
1325 opened in binary mode.  If you wish to handle reading data in another
1326 way, you need not call the png_init_io() function, but you must then
1327 implement the libpng I/O methods discussed in the Customizing Libpng
1328 section below.
1330     png_init_io(png_ptr, fp);
1332 If you had previously opened the file and read any of the signature from
1333 the beginning in order to see if this was a PNG file, you need to let
1334 libpng know that there are some bytes missing from the start of the file.
1336     png_set_sig_bytes(png_ptr, number);
1338 You can change the zlib compression buffer size to be used while
1339 reading compressed data with
1341     png_set_compression_buffer_size(png_ptr, buffer_size);
1343 where the default size is 8192 bytes.  Note that the buffer size
1344 is changed immediately and the buffer is reallocated immediately,
1345 instead of setting a flag to be acted upon later.
1347 If you want CRC errors to be handled in a different manner than
1348 the default, use
1350     png_set_crc_action(png_ptr, crit_action, ancil_action);
1352 The values for png_set_crc_action() say how libpng is to handle CRC errors in
1353 ancillary and critical chunks, and whether to use the data contained
1354 therein.  Note that it is impossible to "discard" data in a critical
1355 chunk.
1357 Choices for (int) crit_action are
1358    PNG_CRC_DEFAULT      0  error/quit
1359    PNG_CRC_ERROR_QUIT   1  error/quit
1360    PNG_CRC_WARN_USE     3  warn/use data
1361    PNG_CRC_QUIET_USE    4  quiet/use data
1362    PNG_CRC_NO_CHANGE    5  use the current value
1364 Choices for (int) ancil_action are
1365    PNG_CRC_DEFAULT      0  error/quit
1366    PNG_CRC_ERROR_QUIT   1  error/quit
1367    PNG_CRC_WARN_DISCARD 2  warn/discard data
1368    PNG_CRC_WARN_USE     3  warn/use data
1369    PNG_CRC_QUIET_USE    4  quiet/use data
1370    PNG_CRC_NO_CHANGE    5  use the current value
1372 .SS Setting up callback code
1374 You can set up a callback function to handle any unknown chunks in the
1375 input stream. You must supply the function
1377     read_chunk_callback(png_structp png_ptr,
1378          png_unknown_chunkp chunk);
1379     {
1380        /* The unknown chunk structure contains your
1381           chunk data, along with similar data for any other
1382           unknown chunks: */
1384            png_byte name[5];
1385            png_byte *data;
1386            png_size_t size;
1388        /* Note that libpng has already taken care of
1389           the CRC handling */
1391        /* put your code here.  Search for your chunk in the
1392           unknown chunk structure, process it, and return one
1393           of the following: */
1395        return (-n); /* chunk had an error */
1396        return (0); /* did not recognize */
1397        return (n); /* success */
1398     }
1400 (You can give your function another name that you like instead of
1401 "read_chunk_callback")
1403 To inform libpng about your function, use
1405     png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr,
1406         read_chunk_callback);
1408 This names not only the callback function, but also a user pointer that
1409 you can retrieve with
1411     png_get_user_chunk_ptr(png_ptr);
1413 If you call the png_set_read_user_chunk_fn() function, then all unknown
1414 chunks will be saved when read, in case your callback function will need
1415 one or more of them.  This behavior can be changed with the
1416 png_set_keep_unknown_chunks() function, described below.
1418 At this point, you can set up a callback function that will be
1419 called after each row has been read, which you can use to control
1420 a progress meter or the like.  It's demonstrated in pngtest.c.
1421 You must supply a function
1423     void read_row_callback(png_structp png_ptr,
1424        png_uint_32 row, int pass);
1425     {
1426       /* put your code here */
1427     }
1429 (You can give it another name that you like instead of "read_row_callback")
1431 To inform libpng about your function, use
1433     png_set_read_status_fn(png_ptr, read_row_callback);
1435 .SS Unknown-chunk handling
1437 Now you get to set the way the library processes unknown chunks in the
1438 input PNG stream. Both known and unknown chunks will be read.  Normal
1439 behavior is that known chunks will be parsed into information in
1440 various info_ptr members while unknown chunks will be discarded. This
1441 behavior can be wasteful if your application will never use some known
1442 chunk types. To change this, you can call:
1444     png_set_keep_unknown_chunks(png_ptr, keep,
1445         chunk_list, num_chunks);
1446     keep       - 0: default unknown chunk handling
1447                  1: ignore; do not keep
1448                  2: keep only if safe-to-copy
1449                  3: keep even if unsafe-to-copy
1451                You can use these definitions:
1452                  PNG_HANDLE_CHUNK_AS_DEFAULT   0
1453                  PNG_HANDLE_CHUNK_NEVER        1
1454                  PNG_HANDLE_CHUNK_IF_SAFE      2
1455                  PNG_HANDLE_CHUNK_ALWAYS       3
1457     chunk_list - list of chunks affected (a byte string,
1458                  five bytes per chunk, NULL or '\0' if
1459                  num_chunks is 0)
1461     num_chunks - number of chunks affected; if 0, all
1462                  unknown chunks are affected.  If nonzero,
1463                  only the chunks in the list are affected
1465 Unknown chunks declared in this way will be saved as raw data onto a
1466 list of png_unknown_chunk structures.  If a chunk that is normally
1467 known to libpng is named in the list, it will be handled as unknown,
1468 according to the "keep" directive.  If a chunk is named in successive
1469 instances of png_set_keep_unknown_chunks(), the final instance will
1470 take precedence.  The IHDR and IEND chunks should not be named in
1471 chunk_list; if they are, libpng will process them normally anyway.
1473 Here is an example of the usage of png_set_keep_unknown_chunks(),
1474 where the private "vpAg" chunk will later be processed by a user chunk
1475 callback function:
1477     png_byte vpAg[5]={118, 112,  65, 103, (png_byte) '\0'};
1479     #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
1480       png_byte unused_chunks[]=
1481       {
1482         104,  73,  83,  84, (png_byte) '\0',   /* hIST */
1483         105,  84,  88, 116, (png_byte) '\0',   /* iTXt */
1484         112,  67,  65,  76, (png_byte) '\0',   /* pCAL */
1485         115,  67,  65,  76, (png_byte) '\0',   /* sCAL */
1486         115,  80,  76,  84, (png_byte) '\0',   /* sPLT */
1487         116,  73,  77,  69, (png_byte) '\0',   /* tIME */
1488       };
1489     #endif
1491     ...
1493     #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
1494       /* ignore all unknown chunks: */
1495       png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0);
1497       /* except for vpAg: */
1498       png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1);
1500       /* also ignore unused known chunks: */
1501       png_set_keep_unknown_chunks(read_ptr, 1, unused_chunks,
1502          (int)sizeof(unused_chunks)/5);
1503     #endif
1505 .SS User limits
1507 The PNG specification allows the width and height of an image to be as
1508 large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns.
1509 Since very few applications really need to process such large images,
1510 we have imposed an arbitrary 1-million limit on rows and columns.
1511 Larger images will be rejected immediately with a png_error() call. If
1512 you wish to override this limit, you can use
1514    png_set_user_limits(png_ptr, width_max, height_max);
1516 to set your own limits, or use width_max = height_max = 0x7fffffffL
1517 to allow all valid dimensions (libpng may reject some very large images
1518 anyway because of potential buffer overflow conditions).
1520 You should put this statement after you create the PNG structure and
1521 before calling png_read_info(), png_read_png(), or png_process_data().
1522 If you need to retrieve the limits that are being applied, use
1524    width_max = png_get_user_width_max(png_ptr);
1525    height_max = png_get_user_height_max(png_ptr);
1527 The PNG specification sets no limit on the number of ancillary chunks
1528 allowed in a PNG datastream.  You can impose a limit on the total number
1529 of sPLT, tEXt, iTXt, zTXt, and unknown chunks that will be stored, with
1531    png_set_chunk_cache_max(png_ptr, user_chunk_cache_max);
1533 where 0x7fffffffL means unlimited.  You can retrieve this limit with
1535    chunk_cache_max = png_get_chunk_cache_max(png_ptr);
1537 This limit also applies to the number of buffers that can be allocated
1538 by png_decompress_chunk() while decompressing iTXt, zTXt, and iCCP chunks.
1540 You can also set a limit on the amount of memory that a compressed chunk
1541 other than IDAT can occupy, with
1543    png_set_chunk_malloc_max(png_ptr, user_chunk_malloc_max);
1545 and you can retrieve the limit with
1547    chunk_malloc_max = png_get_chunk_malloc_max(png_ptr);
1549 Any chunks that would cause either of these limits to be exceeded will
1550 be ignored.
1552 .SS The high-level read interface
1554 At this point there are two ways to proceed; through the high-level
1555 read interface, or through a sequence of low-level read operations.
1556 You can use the high-level interface if (a) you are willing to read
1557 the entire image into memory, and (b) the input transformations
1558 you want to do are limited to the following set:
1560     PNG_TRANSFORM_IDENTITY      No transformation
1561     PNG_TRANSFORM_STRIP_16      Strip 16-bit samples to
1562                                 8 bits
1563     PNG_TRANSFORM_STRIP_ALPHA   Discard the alpha channel
1564     PNG_TRANSFORM_PACKING       Expand 1, 2 and 4-bit
1565                                 samples to bytes
1566     PNG_TRANSFORM_PACKSWAP      Change order of packed
1567                                 pixels to LSB first
1568     PNG_TRANSFORM_EXPAND        Perform set_expand()
1569     PNG_TRANSFORM_INVERT_MONO   Invert monochrome images
1570     PNG_TRANSFORM_SHIFT         Normalize pixels to the
1571                                 sBIT depth
1572     PNG_TRANSFORM_BGR           Flip RGB to BGR, RGBA
1573                                 to BGRA
1574     PNG_TRANSFORM_SWAP_ALPHA    Flip RGBA to ARGB or GA
1575                                 to AG
1576     PNG_TRANSFORM_INVERT_ALPHA  Change alpha from opacity
1577                                 to transparency
1578     PNG_TRANSFORM_SWAP_ENDIAN   Byte-swap 16-bit samples
1579     PNG_TRANSFORM_GRAY_TO_RGB   Expand grayscale samples
1580                                 to RGB (or GA to RGBA)
1582 (This excludes setting a background color, doing gamma transformation,
1583 quantizing, and setting filler.)  If this is the case, simply do this:
1585     png_read_png(png_ptr, info_ptr, png_transforms, NULL)
1587 where png_transforms is an integer containing the bitwise OR of some
1588 set of transformation flags.  This call is equivalent to png_read_info(),
1589 followed the set of transformations indicated by the transform mask,
1590 then png_read_image(), and finally png_read_end().
1592 (The final parameter of this call is not yet used.  Someday it might point
1593 to transformation parameters required by some future input transform.)
1595 You must use png_transforms and not call any png_set_transform() functions
1596 when you use png_read_png().
1598 After you have called png_read_png(), you can retrieve the image data
1599 with
1601    row_pointers = png_get_rows(png_ptr, info_ptr);
1603 where row_pointers is an array of pointers to the pixel data for each row:
1605    png_bytep row_pointers[height];
1607 If you know your image size and pixel size ahead of time, you can allocate
1608 row_pointers prior to calling png_read_png() with
1610    if (height > PNG_UINT_32_MAX/png_sizeof(png_byte))
1611       png_error (png_ptr,
1612           "Image is too tall to process in memory");
1614    if (width > PNG_UINT_32_MAX/pixel_size)
1615       png_error (png_ptr,
1616           "Image is too wide to process in memory");
1618    row_pointers = png_malloc(png_ptr,
1619        height*png_sizeof(png_bytep));
1621    for (int i=0; i<height, i++)
1622       row_pointers[i]=NULL;  /* security precaution */
1624    for (int i=0; i<height, i++)
1625       row_pointers[i]=png_malloc(png_ptr,
1626           width*pixel_size);
1628    png_set_rows(png_ptr, info_ptr, &row_pointers);
1630 Alternatively you could allocate your image in one big block and define
1631 row_pointers[i] to point into the proper places in your block.
1633 If you use png_set_rows(), the application is responsible for freeing
1634 row_pointers (and row_pointers[i], if they were separately allocated).
1636 If you don't allocate row_pointers ahead of time, png_read_png() will
1637 do it, and it'll be free'ed by libpng when you call png_destroy_*().
1639 .SS The low-level read interface
1641 If you are going the low-level route, you are now ready to read all
1642 the file information up to the actual image data.  You do this with a
1643 call to png_read_info().
1645     png_read_info(png_ptr, info_ptr);
1647 This will process all chunks up to but not including the image data.
1649 .SS Querying the info structure
1651 Functions are used to get the information from the info_ptr once it
1652 has been read.  Note that these fields may not be completely filled
1653 in until png_read_end() has read the chunk data following the image.
1655     png_get_IHDR(png_ptr, info_ptr, &width, &height,
1656        &bit_depth, &color_type, &interlace_type,
1657        &compression_type, &filter_method);
1659     width          - holds the width of the image
1660                      in pixels (up to 2^31).
1662     height         - holds the height of the image
1663                      in pixels (up to 2^31).
1665     bit_depth      - holds the bit depth of one of the
1666                      image channels.  (valid values are
1667                      1, 2, 4, 8, 16 and depend also on
1668                      the color_type.  See also
1669                      significant bits (sBIT) below).
1671     color_type     - describes which color/alpha channels
1672                          are present.
1673                      PNG_COLOR_TYPE_GRAY
1674                         (bit depths 1, 2, 4, 8, 16)
1675                      PNG_COLOR_TYPE_GRAY_ALPHA
1676                         (bit depths 8, 16)
1677                      PNG_COLOR_TYPE_PALETTE
1678                         (bit depths 1, 2, 4, 8)
1679                      PNG_COLOR_TYPE_RGB
1680                         (bit_depths 8, 16)
1681                      PNG_COLOR_TYPE_RGB_ALPHA
1682                         (bit_depths 8, 16)
1684                      PNG_COLOR_MASK_PALETTE
1685                      PNG_COLOR_MASK_COLOR
1686                      PNG_COLOR_MASK_ALPHA
1688     interlace_type - (PNG_INTERLACE_NONE or
1689                      PNG_INTERLACE_ADAM7)
1691     compression_type - (must be PNG_COMPRESSION_TYPE_BASE
1692                      for PNG 1.0)
1694     filter_method  - (must be PNG_FILTER_TYPE_BASE
1695                      for PNG 1.0, and can also be
1696                      PNG_INTRAPIXEL_DIFFERENCING if
1697                      the PNG datastream is embedded in
1698                      a MNG-1.0 datastream)
1700     Any or all of interlace_type, compression_type, or
1701     filter_method can be NULL if you are
1702     not interested in their values.
1704     Note that png_get_IHDR() returns 32-bit data into
1705     the application's width and height variables.
1706     This is an unsafe situation if these are 16-bit
1707     variables.  In such situations, the
1708     png_get_image_width() and png_get_image_height()
1709     functions described below are safer.
1711     width            = png_get_image_width(png_ptr,
1712                          info_ptr);
1714     height           = png_get_image_height(png_ptr,
1715                          info_ptr);
1717     bit_depth        = png_get_bit_depth(png_ptr,
1718                          info_ptr);
1720     color_type       = png_get_color_type(png_ptr,
1721                          info_ptr);
1723     interlace_type   = png_get_interlace_type(png_ptr,
1724                          info_ptr);
1726     compression_type = png_get_compression_type(png_ptr,
1727                          info_ptr);
1729     filter_method    = png_get_filter_type(png_ptr,
1730                          info_ptr);
1732     channels = png_get_channels(png_ptr, info_ptr);
1734     channels       - number of channels of info for the
1735                      color type (valid values are 1 (GRAY,
1736                      PALETTE), 2 (GRAY_ALPHA), 3 (RGB),
1737                      4 (RGB_ALPHA or RGB + filler byte))
1739     rowbytes = png_get_rowbytes(png_ptr, info_ptr);
1741     rowbytes       - number of bytes needed to hold a row
1743     signature = png_get_signature(png_ptr, info_ptr);
1745     signature      - holds the signature read from the
1746                      file (if any).  The data is kept in
1747                      the same offset it would be if the
1748                      whole signature were read (i.e. if an
1749                      application had already read in 4
1750                      bytes of signature before starting
1751                      libpng, the remaining 4 bytes would
1752                      be in signature[4] through signature[7]
1753                      (see png_set_sig_bytes())).
1755 These are also important, but their validity depends on whether the chunk
1756 has been read.  The png_get_valid(png_ptr, info_ptr, PNG_INFO_<chunk>) and
1757 png_get_<chunk>(png_ptr, info_ptr, ...) functions return non-zero if the
1758 data has been read, or zero if it is missing.  The parameters to the
1759 png_get_<chunk> are set directly if they are simple data types, or a
1760 pointer into the info_ptr is returned for any complex types.
1762     png_get_PLTE(png_ptr, info_ptr, &palette,
1763                      &num_palette);
1765     palette        - the palette for the file
1766                      (array of png_color)
1768     num_palette    - number of entries in the palette
1770     png_get_gAMA(png_ptr, info_ptr, &file_gamma);
1771     png_get_gAMA_fixed(png_ptr, info_ptr, &int_file_gamma);
1773     file_gamma     - the gamma at which the file is
1774                      written (PNG_INFO_gAMA)
1776     int_file_gamma - 100,000 times the gamma at which the
1777                      file is written
1779     png_get_sRGB(png_ptr, info_ptr, &srgb_intent);
1781     file_srgb_intent - the rendering intent (PNG_INFO_sRGB)
1782                      The presence of the sRGB chunk
1783                      means that the pixel data is in the
1784                      sRGB color space.  This chunk also
1785                      implies specific values of gAMA and
1786                      cHRM.
1788     png_get_iCCP(png_ptr, info_ptr, &name,
1789        &compression_type, &profile, &proflen);
1791     name             - The profile name.
1793     compression_type - The compression type; always
1794                        PNG_COMPRESSION_TYPE_BASE for PNG 1.0.
1795                        You may give NULL to this argument to
1796                        ignore it.
1798     profile          - International Color Consortium color
1799                        profile data. May contain NULs.
1801     proflen          - length of profile data in bytes.
1803     png_get_sBIT(png_ptr, info_ptr, &sig_bit);
1805     sig_bit        - the number of significant bits for
1806                      (PNG_INFO_sBIT) each of the gray,
1807                      red, green, and blue channels,
1808                      whichever are appropriate for the
1809                      given color type (png_color_16)
1811     png_get_tRNS(png_ptr, info_ptr, &trans_alpha,
1812                      &num_trans, &trans_color);
1814     trans_alpha    - array of alpha (transparency)
1815                      entries for palette (PNG_INFO_tRNS)
1817     num_trans      - number of transparent entries
1818                      (PNG_INFO_tRNS)
1820     trans_color    - graylevel or color sample values of
1821                      the single transparent color for
1822                      non-paletted images (PNG_INFO_tRNS)
1824     png_get_hIST(png_ptr, info_ptr, &hist);
1825                      (PNG_INFO_hIST)
1827     hist           - histogram of palette (array of
1828                      png_uint_16)
1830     png_get_tIME(png_ptr, info_ptr, &mod_time);
1832     mod_time       - time image was last modified
1833                     (PNG_VALID_tIME)
1835     png_get_bKGD(png_ptr, info_ptr, &background);
1837     background     - background color (PNG_VALID_bKGD)
1838                      valid 16-bit red, green and blue
1839                      values, regardless of color_type
1841     num_comments   = png_get_text(png_ptr, info_ptr,
1842                      &text_ptr, &num_text);
1844     num_comments   - number of comments
1846     text_ptr       - array of png_text holding image
1847                      comments
1849     text_ptr[i].compression - type of compression used
1850                  on "text" PNG_TEXT_COMPRESSION_NONE
1851                            PNG_TEXT_COMPRESSION_zTXt
1852                            PNG_ITXT_COMPRESSION_NONE
1853                            PNG_ITXT_COMPRESSION_zTXt
1855     text_ptr[i].key   - keyword for comment.  Must contain
1856                          1-79 characters.
1858     text_ptr[i].text  - text comments for current
1859                          keyword.  Can be empty.
1861     text_ptr[i].text_length - length of text string,
1862                  after decompression, 0 for iTXt
1864     text_ptr[i].itxt_length - length of itxt string,
1865                  after decompression, 0 for tEXt/zTXt
1867     text_ptr[i].lang  - language of comment (empty
1868                          string for unknown).
1870     text_ptr[i].lang_key  - keyword in UTF-8
1871                          (empty string for unknown).
1873     Note that the itxt_length, lang, and lang_key
1874     members of the text_ptr structure only exist
1875     when the library is built with iTXt chunk support.
1877     num_text       - number of comments (same as
1878                      num_comments; you can put NULL here
1879                      to avoid the duplication)
1881     Note while png_set_text() will accept text, language,
1882     and translated keywords that can be NULL pointers, the
1883     structure returned by png_get_text will always contain
1884     regular zero-terminated C strings.  They might be
1885     empty strings but they will never be NULL pointers.
1887     num_spalettes = png_get_sPLT(png_ptr, info_ptr,
1888        &palette_ptr);
1890     num_spalettes  - number of sPLT chunks read.
1892     palette_ptr    - array of palette structures holding
1893                      contents of one or more sPLT chunks
1894                      read.
1896     png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y,
1897        &unit_type);
1899     offset_x       - positive offset from the left edge
1900                      of the screen
1902     offset_y       - positive offset from the top edge
1903                      of the screen
1905     unit_type      - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER
1907     png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y,
1908        &unit_type);
1910     res_x          - pixels/unit physical resolution in
1911                      x direction
1913     res_y          - pixels/unit physical resolution in
1914                      x direction
1916     unit_type      - PNG_RESOLUTION_UNKNOWN,
1917                      PNG_RESOLUTION_METER
1919     png_get_sCAL(png_ptr, info_ptr, &unit, &width,
1920        &height)
1922     unit        - physical scale units (an integer)
1924     width       - width of a pixel in physical scale units
1926     height      - height of a pixel in physical scale units
1927                  (width and height are doubles)
1929     png_get_sCAL_s(png_ptr, info_ptr, &unit, &width,
1930        &height)
1932     unit        - physical scale units (an integer)
1934     width       - width of a pixel in physical scale units
1936     height      - height of a pixel in physical scale units
1937                  (width and height are strings like "2.54")
1939     num_unknown_chunks = png_get_unknown_chunks(png_ptr,
1940        info_ptr, &unknowns)
1942     unknowns          - array of png_unknown_chunk
1943                         structures holding unknown chunks
1945     unknowns[i].name  - name of unknown chunk
1947     unknowns[i].data  - data of unknown chunk
1949     unknowns[i].size  - size of unknown chunk's data
1951     unknowns[i].location - position of chunk in file
1953     The value of "i" corresponds to the order in which the
1954     chunks were read from the PNG file or inserted with the
1955     png_set_unknown_chunks() function.
1957 The data from the pHYs chunk can be retrieved in several convenient
1958 forms:
1960     res_x = png_get_x_pixels_per_meter(png_ptr,
1961        info_ptr)
1963     res_y = png_get_y_pixels_per_meter(png_ptr,
1964        info_ptr)
1966     res_x_and_y = png_get_pixels_per_meter(png_ptr,
1967        info_ptr)
1969     res_x = png_get_x_pixels_per_inch(png_ptr,
1970        info_ptr)
1972     res_y = png_get_y_pixels_per_inch(png_ptr,
1973        info_ptr)
1975     res_x_and_y = png_get_pixels_per_inch(png_ptr,
1976        info_ptr)
1978     aspect_ratio = png_get_pixel_aspect_ratio(png_ptr,
1979        info_ptr)
1981     Each of these returns 0 [signifying "unknown"] if
1982        the data is not present or if res_x is 0;
1983        res_x_and_y is 0 if res_x != res_y
1985     Note that because of the way the resolutions are
1986        stored internally, the inch conversions won't
1987        come out to exactly even number.  For example,
1988        72 dpi is stored as 0.28346 pixels/meter, and
1989        when this is retrieved it is 71.9988 dpi, so
1990        be sure to round the returned value appropriately
1991        if you want to display a reasonable-looking result. 
1993 The data from the oFFs chunk can be retrieved in several convenient
1994 forms:
1996     x_offset = png_get_x_offset_microns(png_ptr, info_ptr);
1998     y_offset = png_get_y_offset_microns(png_ptr, info_ptr);
2000     x_offset = png_get_x_offset_inches(png_ptr, info_ptr);
2002     y_offset = png_get_y_offset_inches(png_ptr, info_ptr);
2004     Each of these returns 0 [signifying "unknown" if both
2005        x and y are 0] if the data is not present or if the
2006        chunk is present but the unit is the pixel.  The
2007        remark about inexact inch conversions applies here
2008        as well, because a value in inches can't always be
2009        converted to microns and back without some loss
2010        of precision.
2012 For more information, see the png_info definition in png.h and the
2013 PNG specification for chunk contents.  Be careful with trusting
2014 rowbytes, as some of the transformations could increase the space
2015 needed to hold a row (expand, filler, gray_to_rgb, etc.).
2016 See png_read_update_info(), below.
2018 A quick word about text_ptr and num_text.  PNG stores comments in
2019 keyword/text pairs, one pair per chunk, with no limit on the number
2020 of text chunks, and a 2^31 byte limit on their size.  While there are
2021 suggested keywords, there is no requirement to restrict the use to these
2022 strings.  It is strongly suggested that keywords and text be sensible
2023 to humans (that's the point), so don't use abbreviations.  Non-printing
2024 symbols are not allowed.  See the PNG specification for more details.
2025 There is also no requirement to have text after the keyword.
2027 Keywords should be limited to 79 Latin-1 characters without leading or
2028 trailing spaces, but non-consecutive spaces are allowed within the
2029 keyword.  It is possible to have the same keyword any number of times.
2030 The text_ptr is an array of png_text structures, each holding a
2031 pointer to a language string, a pointer to a keyword and a pointer to
2032 a text string.  The text string, language code, and translated
2033 keyword may be empty or NULL pointers.  The keyword/text
2034 pairs are put into the array in the order that they are received.
2035 However, some or all of the text chunks may be after the image, so, to
2036 make sure you have read all the text chunks, don't mess with these
2037 until after you read the stuff after the image.  This will be
2038 mentioned again below in the discussion that goes with png_read_end().
2040 .SS Input transformations
2042 After you've read the header information, you can set up the library
2043 to handle any special transformations of the image data.  The various
2044 ways to transform the data will be described in the order that they
2045 should occur.  This is important, as some of these change the color
2046 type and/or bit depth of the data, and some others only work on
2047 certain color types and bit depths.  Even though each transformation
2048 checks to see if it has data that it can do something with, you should
2049 make sure to only enable a transformation if it will be valid for the
2050 data.  For example, don't swap red and blue on grayscale data.
2052 The colors used for the background and transparency values should be
2053 supplied in the same format/depth as the current image data.  They
2054 are stored in the same format/depth as the image data in a bKGD or tRNS
2055 chunk, so this is what libpng expects for this data.  The colors are
2056 transformed to keep in sync with the image data when an application
2057 calls the png_read_update_info() routine (see below).
2059 Data will be decoded into the supplied row buffers packed into bytes
2060 unless the library has been told to transform it into another format.
2061 For example, 4 bit/pixel paletted or grayscale data will be returned
2062 2 pixels/byte with the leftmost pixel in the high-order bits of the
2063 byte, unless png_set_packing() is called.  8-bit RGB data will be stored
2064 in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha()
2065 is called to insert filler bytes, either before or after each RGB triplet.
2066 16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant
2067 byte of the color value first, unless png_set_strip_16() is called to
2068 transform it to regular RGB RGB triplets, or png_set_filler() or
2069 png_set_add alpha() is called to insert filler bytes, either before or
2070 after each RRGGBB triplet.  Similarly, 8-bit or 16-bit grayscale data can
2071 be modified with
2072 png_set_filler(), png_set_add_alpha(), or png_set_strip_16().
2074 The following code transforms grayscale images of less than 8 to 8 bits,
2075 changes paletted images to RGB, and adds a full alpha channel if there is
2076 transparency information in a tRNS chunk.  This is most useful on
2077 grayscale images with bit depths of 2 or 4 or if there is a multiple-image
2078 viewing application that wishes to treat all images in the same way.
2080     if (color_type == PNG_COLOR_TYPE_PALETTE)
2081         png_set_palette_to_rgb(png_ptr);
2083     if (color_type == PNG_COLOR_TYPE_GRAY &&
2084         bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr);
2086     if (png_get_valid(png_ptr, info_ptr,
2087         PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr);
2089 These three functions are actually aliases for png_set_expand(), added
2090 in libpng version 1.0.4, with the function names expanded to improve code
2091 readability.  In some future version they may actually do different
2092 things.
2094 As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was
2095 added.  It expands the sample depth without changing tRNS to alpha.
2097 As of libpng version 1.5.1, not all possible expansions are supported.
2099 In the following table, the 01 means grayscale with depth<8, 31 means
2100 indexed with depth<8, other numerals represent the color type, "T" means
2101 the tRNS chunk is present, A means an alpha channel is present, and O
2102 means tRNS or alpha is present but all pixels in the image are opaque.
2104   FROM  01  31   0  0T  0O   2  2T  2O   3  3T  3O  4A  4O  6A  6O 
2105    TO
2106    01    -                   
2107    31        -
2108     0    1       -           
2109    0T                -
2110    0O                    -
2111     2           GX           -
2112    2T                            -
2113    2O                                -
2114     3        1                           -
2115    3T                                        -
2116    3O                                            -
2117    4A                T                               -
2118    4O                                                    -
2119    6A               GX         TX           TX               -
2120    6O                   GX                      TX               -
2122 Within the matrix,
2123      "-" means the transformation is not supported.
2124      "X" means the transformation is obtained by png_set_expand().
2125      "1" means the transformation is obtained by
2126          png_set_expand_gray_1_2_4_to_8
2127      "G" means the transformation is obtained by
2128          png_set_gray_to_rgb().
2129      "P" means the transformation is obtained by
2130          png_set_expand_palette_to_rgb().
2131      "T" means the transformation is obtained by
2132          png_set_tRNS_to_alpha().
2134 PNG can have files with 16 bits per channel.  If you only can handle
2135 8 bits per channel, this will strip the pixels down to 8 bit.
2137     if (bit_depth == 16)
2138        png_set_strip_16(png_ptr);
2140 If, for some reason, you don't need the alpha channel on an image,
2141 and you want to remove it rather than combining it with the background
2142 (but the image author certainly had in mind that you *would* combine
2143 it with the background, so that's what you should probably do):
2145     if (color_type & PNG_COLOR_MASK_ALPHA)
2146        png_set_strip_alpha(png_ptr);
2148 In PNG files, the alpha channel in an image
2149 is the level of opacity.  If you need the alpha channel in an image to
2150 be the level of transparency instead of opacity, you can invert the
2151 alpha channel (or the tRNS chunk data) after it's read, so that 0 is
2152 fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit
2153 images) is fully transparent, with
2155     png_set_invert_alpha(png_ptr);
2157 PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
2158 they can, resulting in, for example, 8 pixels per byte for 1 bit
2159 files.  This code expands to 1 pixel per byte without changing the
2160 values of the pixels:
2162     if (bit_depth < 8)
2163        png_set_packing(png_ptr);
2165 PNG files have possible bit depths of 1, 2, 4, 8, and 16.  All pixels
2166 stored in a PNG image have been "scaled" or "shifted" up to the next
2167 higher possible bit depth (e.g. from 5 bits/sample in the range [0,31]
2168 to 8 bits/sample in the range [0, 255]).  However, it is also possible
2169 to convert the PNG pixel data back to the original bit depth of the
2170 image.  This call reduces the pixels back down to the original bit depth:
2172     png_color_8p sig_bit;
2174     if (png_get_sBIT(png_ptr, info_ptr, &sig_bit))
2175        png_set_shift(png_ptr, sig_bit);
2177 PNG files store 3-color pixels in red, green, blue order.  This code
2178 changes the storage of the pixels to blue, green, red:
2180     if (color_type == PNG_COLOR_TYPE_RGB ||
2181         color_type == PNG_COLOR_TYPE_RGB_ALPHA)
2182        png_set_bgr(png_ptr);
2184 PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them
2185 into 4 or 8 bytes for windowing systems that need them in this format:
2187     if (color_type == PNG_COLOR_TYPE_RGB)
2188        png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE);
2190 where "filler" is the 8 or 16-bit number to fill with, and the location is
2191 either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether
2192 you want the filler before the RGB or after.  This transformation
2193 does not affect images that already have full alpha channels.  To add an
2194 opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which
2195 will generate RGBA pixels.
2197 Note that png_set_filler() does not change the color type.  If you want
2198 to do that, you can add a true alpha channel with
2200     if (color_type == PNG_COLOR_TYPE_RGB ||
2201        color_type == PNG_COLOR_TYPE_GRAY)
2202        png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER);
2204 where "filler" contains the alpha value to assign to each pixel.
2205 This function was added in libpng-1.2.7.
2207 If you are reading an image with an alpha channel, and you need the
2208 data as ARGB instead of the normal PNG format RGBA:
2210     if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
2211        png_set_swap_alpha(png_ptr);
2213 For some uses, you may want a grayscale image to be represented as
2214 RGB.  This code will do that conversion:
2216     if (color_type == PNG_COLOR_TYPE_GRAY ||
2217         color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
2218        png_set_gray_to_rgb(png_ptr);
2220 Conversely, you can convert an RGB or RGBA image to grayscale or grayscale
2221 with alpha.
2223     if (color_type == PNG_COLOR_TYPE_RGB ||
2224         color_type == PNG_COLOR_TYPE_RGB_ALPHA)
2225        png_set_rgb_to_gray_fixed(png_ptr, error_action,
2226            int red_weight, int green_weight);
2228     error_action = 1: silently do the conversion
2230     error_action = 2: issue a warning if the original
2231                       image has any pixel where
2232                       red != green or red != blue
2234     error_action = 3: issue an error and abort the
2235                       conversion if the original
2236                       image has any pixel where
2237                       red != green or red != blue
2239     red_weight:       weight of red component times 100000
2241     green_weight:     weight of green component times 100000
2242                       If either weight is negative, default
2243                       weights (21268, 71514) are used.
2245 If you have set error_action = 1 or 2, you can
2246 later check whether the image really was gray, after processing
2247 the image rows, with the png_get_rgb_to_gray_status(png_ptr) function.
2248 It will return a png_byte that is zero if the image was gray or
2249 1 if there were any non-gray pixels.  bKGD and sBIT data
2250 will be silently converted to grayscale, using the green channel
2251 data, regardless of the error_action setting.
2253 With red_weight+green_weight<=100000,
2254 the normalized graylevel is computed:
2256     int rw = red_weight * 65536;
2257     int gw = green_weight * 65536;
2258     int bw = 65536 - (rw + gw);
2259     gray = (rw*red + gw*green + bw*blue)/65536;
2261 The default values approximate those recommended in the Charles
2262 Poynton's Color FAQ, <http://www.inforamp.net/~poynton/>
2263 Copyright (c) 1998-01-04 Charles Poynton <poynton at inforamp.net>
2265     Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
2267 Libpng approximates this with integers scaled by 32768:
2269     Y = (6968 * R + 23434 * G + 2366 * B)/32768
2271 The calculation is done in a linear colorspace, if the image gamma
2272 can be determined.
2274 If you have a grayscale and you are using png_set_expand_depth(),
2275 png_set_expand(), or png_set_gray_to_rgb to change to truecolor or to
2276 a higher bit-depth, you must either supply the background color as a gray
2277 value at the original file bit-depth (need_expand = 1) or else supply the
2278 background color as an RGB triplet at the final, expanded bit depth
2279 (need_expand = 0).  Similarly, if you are reading a paletted image, you
2280 must either supply the background color as a palette index (need_expand = 1)
2281 or as an RGB triplet that may or may not be in the palette (need_expand = 0).
2283     png_color_16 my_background;
2284     png_color_16p image_background;
2286     if (png_get_bKGD(png_ptr, info_ptr, &image_background))
2287        png_set_background(png_ptr, image_background,
2288            PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
2289     else
2290        png_set_background(png_ptr, &my_background,
2291            PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
2293 The png_set_background() function tells libpng to composite images
2294 with alpha or simple transparency against the supplied background
2295 color.  If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid),
2296 you may use this color, or supply another color more suitable for
2297 the current display (e.g., the background color from a web page).  You
2298 need to tell libpng whether the color is in the gamma space of the
2299 display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file
2300 (PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one
2301 that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't
2302 know why anyone would use this, but it's here).
2304 To properly display PNG images on any kind of system, the application needs
2305 to know what the display gamma is.  Ideally, the user will know this, and
2306 the application will allow them to set it.  One method of allowing the user
2307 to set the display gamma separately for each system is to check for a
2308 SCREEN_GAMMA or DISPLAY_GAMMA environment variable, which will hopefully be
2309 correctly set.
2311 Note that display_gamma is the overall gamma correction required to produce
2312 pleasing results, which depends on the lighting conditions in the surrounding
2313 environment.  In a dim or brightly lit room, no compensation other than
2314 the physical gamma exponent of the monitor is needed, while in a dark room
2315 a slightly smaller exponent is better.
2317    double gamma, screen_gamma;
2319    if (/* We have a user-defined screen
2320        gamma value */)
2321    {
2322       screen_gamma = user_defined_screen_gamma;
2323    }
2325    /* One way that applications can share the same
2326       screen gamma value */
2327    else if ((gamma_str = getenv("SCREEN_GAMMA"))
2328       != NULL)
2329    {
2330       screen_gamma = (double)atof(gamma_str);
2331    }
2333    /* If we don't have another value */
2334    else
2335    {
2336       screen_gamma = 2.2; /* A good guess for a
2337            PC monitor in a bright office or a dim room */
2339       screen_gamma = 2.0; /* A good guess for a
2340            PC monitor in a dark room */
2342       screen_gamma = 1.7 or 1.0;  /* A good
2343            guess for Mac systems */
2344    }
2346 The functions png_set_gamma() and its fixed point equivalent
2347 png_set_gamma_fixed() handle gamma transformations of the data.
2348 Pass both the file gamma and the current screen_gamma.  If the file does
2349 not have a gamma value, you can pass one anyway if you have an idea what
2350 it is (usually 0.45455 is a good guess for GIF images on PCs).  Note
2351 that file gammas are inverted from screen gammas.  See the discussions
2352 on gamma in the PNG specification for an excellent description of what
2353 gamma is, and why all applications should support it.  It is strongly
2354 recommended that PNG viewers support gamma correction.
2356    if (png_get_gAMA(png_ptr, info_ptr, &file_gamma))
2357       png_set_gamma(png_ptr, screen_gamma, file_gamma);
2359    else
2360       png_set_gamma(png_ptr, screen_gamma, 0.45455);
2362 If you need to reduce an RGB file to a paletted file, or if a paletted
2363 file has more entries then will fit on your screen, png_set_quantize()
2364 will do that.  Note that this is a simple match quantization that merely
2365 finds the closest color available.  This should work fairly well with
2366 optimized palettes, but fairly badly with linear color cubes.  If you
2367 pass a palette that is larger then maximum_colors, the file will
2368 reduce the number of colors in the palette so it will fit into
2369 maximum_colors.  If there is a histogram, it will use it to make
2370 more intelligent choices when reducing the palette.  If there is no
2371 histogram, it may not do as good a job.
2373    if (color_type & PNG_COLOR_MASK_COLOR)
2374    {
2375       if (png_get_valid(png_ptr, info_ptr,
2376           PNG_INFO_PLTE))
2377       {
2378          png_uint_16p histogram = NULL;
2380          png_get_hIST(png_ptr, info_ptr,
2381              &histogram);
2382          png_set_quantize(png_ptr, palette, num_palette,
2383             max_screen_colors, histogram, 1);
2384       }
2386       else
2387       {
2388          png_color std_color_cube[MAX_SCREEN_COLORS] =
2389             { ... colors ... };
2391          png_set_quantize(png_ptr, std_color_cube,
2392             MAX_SCREEN_COLORS, MAX_SCREEN_COLORS,
2393             NULL,0);
2394       }
2395    }
2397 PNG files describe monochrome as black being zero and white being one.
2398 The following code will reverse this (make black be one and white be
2399 zero):
2401    if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY)
2402       png_set_invert_mono(png_ptr);
2404 This function can also be used to invert grayscale and gray-alpha images:
2406    if (color_type == PNG_COLOR_TYPE_GRAY ||
2407        color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
2408       png_set_invert_mono(png_ptr);
2410 PNG files store 16 bit pixels in network byte order (big-endian,
2411 ie. most significant bits first).  This code changes the storage to the
2412 other way (little-endian, i.e. least significant bits first, the
2413 way PCs store them):
2415     if (bit_depth == 16)
2416        png_set_swap(png_ptr);
2418 If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you
2419 need to change the order the pixels are packed into bytes, you can use:
2421     if (bit_depth < 8)
2422        png_set_packswap(png_ptr);
2424 Finally, you can write your own transformation function if none of
2425 the existing ones meets your needs.  This is done by setting a callback
2426 with
2428     png_set_read_user_transform_fn(png_ptr,
2429         read_transform_fn);
2431 You must supply the function
2433     void read_transform_fn(png_structp png_ptr, row_info_ptr
2434         row_info, png_bytep data)
2436 See pngtest.c for a working example.  Your function will be called
2437 after all of the other transformations have been processed.  Take care with
2438 interlaced images if you do the interlace yourself - the width of the row is the
2439 width in 'row_info', not the overall image width.
2441 If supported libpng provides two information routines that you can use to find
2442 where you are in processing the image:
2444    png_get_current_pass_number(png_structp png_ptr);
2445    png_get_current_row_number(png_structp png_ptr);
2447 Don't try using these outside a transform callback - firstly they are only
2448 supported if user transforms are supported, secondly they may well return
2449 unexpected results unless the row is actually being processed at the moment they
2450 are called.
2452 You can also set up a pointer to a user structure for use by your
2453 callback function, and you can inform libpng that your transform
2454 function will change the number of channels or bit depth with the
2455 function
2457     png_set_user_transform_info(png_ptr, user_ptr,
2458         user_depth, user_channels);
2460 The user's application, not libpng, is responsible for allocating and
2461 freeing any memory required for the user structure.
2463 You can retrieve the pointer via the function
2464 png_get_user_transform_ptr().  For example:
2466     voidp read_user_transform_ptr =
2467         png_get_user_transform_ptr(png_ptr);
2469 The last thing to handle is interlacing; this is covered in detail below,
2470 but you must call the function here if you want libpng to handle expansion
2471 of the interlaced image.
2473     number_of_passes = png_set_interlace_handling(png_ptr);
2475 After setting the transformations, libpng can update your png_info
2476 structure to reflect any transformations you've requested with this
2477 call.  This is most useful to update the info structure's rowbytes
2478 field so you can use it to allocate your image memory.  This function
2479 will also update your palette with the correct screen_gamma and
2480 background if these have been given with the calls above.
2482     png_read_update_info(png_ptr, info_ptr);
2484 After you call png_read_update_info(), you can allocate any
2485 memory you need to hold the image.  The row data is simply
2486 raw byte data for all forms of images.  As the actual allocation
2487 varies among applications, no example will be given.  If you
2488 are allocating one large chunk, you will need to build an
2489 array of pointers to each row, as it will be needed for some
2490 of the functions below.
2492 Remember: Before you call png_read_update_info(), the png_get_
2493 functions return the values corresponding to the original PNG image.
2494 After you call png_read_update_info the values refer to the image
2495 that libpng will output.  Consequently you must call all the png_set_
2496 functions before you call png_read_update_info().  This is particularly
2497 important for png_set_interlace_handling() - if you are going to call
2498 png_read_update_info() you must call png_set_interlace_handling() before
2499 it unless you want to receive interlaced output.
2501 .SS Reading image data
2503 After you've allocated memory, you can read the image data.
2504 The simplest way to do this is in one function call.  If you are
2505 allocating enough memory to hold the whole image, you can just
2506 call png_read_image() and libpng will read in all the image data
2507 and put it in the memory area supplied.  You will need to pass in
2508 an array of pointers to each row.
2510 This function automatically handles interlacing, so you don't
2511 need to call png_set_interlace_handling() (unless you call
2512 png_read_update_info()) or call this function multiple times, or any
2513 of that other stuff necessary with png_read_rows().
2515    png_read_image(png_ptr, row_pointers);
2517 where row_pointers is:
2519    png_bytep row_pointers[height];
2521 You can point to void or char or whatever you use for pixels.
2523 If you don't want to read in the whole image at once, you can
2524 use png_read_rows() instead.  If there is no interlacing (check
2525 interlace_type == PNG_INTERLACE_NONE), this is simple:
2527     png_read_rows(png_ptr, row_pointers, NULL,
2528         number_of_rows);
2530 where row_pointers is the same as in the png_read_image() call.
2532 If you are doing this just one row at a time, you can do this with
2533 a single row_pointer instead of an array of row_pointers:
2535     png_bytep row_pointer = row;
2536     png_read_row(png_ptr, row_pointer, NULL);
2538 If the file is interlaced (interlace_type != 0 in the IHDR chunk), things
2539 get somewhat harder.  The only current (PNG Specification version 1.2)
2540 interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7);
2541 a somewhat complicated 2D interlace scheme, known as Adam7, that
2542 breaks down an image into seven smaller images of varying size, based
2543 on an 8x8 grid.  This number is defined (from libpng 1.5) as
2544 PNG_INTERLACE_ADAM7_PASSES in png.h
2546 libpng can fill out those images or it can give them to you "as is".
2547 It is almost always better to have libpng handle the interlacing for you.
2548 If you want the images filled out, there are two ways to do that.  The one
2549 mentioned in the PNG specification is to expand each pixel to cover
2550 those pixels that have not been read yet (the "rectangle" method).
2551 This results in a blocky image for the first pass, which gradually
2552 smooths out as more pixels are read.  The other method is the "sparkle"
2553 method, where pixels are drawn only in their final locations, with the
2554 rest of the image remaining whatever colors they were initialized to
2555 before the start of the read.  The first method usually looks better,
2556 but tends to be slower, as there are more pixels to put in the rows.
2558 If, as is likely, you want libpng to expand the images, call this before
2559 calling png_start_read_image() or png_read_update_info():
2561     if (interlace_type == PNG_INTERLACE_ADAM7)
2562        number_of_passes
2563            = png_set_interlace_handling(png_ptr);
2565 This will return the number of passes needed.  Currently, this is seven,
2566 but may change if another interlace type is added.  This function can be
2567 called even if the file is not interlaced, where it will return one pass.
2568 You then need to read the whole image 'number_of_passes' times.  Each time
2569 will distribute the pixels from the current pass to the correct place in
2570 the output image, so you need to supply the same rows to png_read_rows in
2571 each pass.
2573 If you are not going to display the image after each pass, but are
2574 going to wait until the entire image is read in, use the sparkle
2575 effect.  This effect is faster and the end result of either method
2576 is exactly the same.  If you are planning on displaying the image
2577 after each pass, the "rectangle" effect is generally considered the
2578 better looking one.
2580 If you only want the "sparkle" effect, just call png_read_rows() as
2581 normal, with the third parameter NULL.  Make sure you make pass over
2582 the image number_of_passes times, and you don't change the data in the
2583 rows between calls.  You can change the locations of the data, just
2584 not the data.  Each pass only writes the pixels appropriate for that
2585 pass, and assumes the data from previous passes is still valid.
2587     png_read_rows(png_ptr, row_pointers, NULL,
2588         number_of_rows);
2590 If you only want the first effect (the rectangles), do the same as
2591 before except pass the row buffer in the third parameter, and leave
2592 the second parameter NULL.
2594     png_read_rows(png_ptr, NULL, row_pointers,
2595         number_of_rows);
2597 If you don't want libpng to handle the interlacing details, just call
2598 png_read_rows() PNG_INTERLACE_ADAM7_PASSES times to read in all the images.
2599 Each of the images is a valid image by itself, however you will almost
2600 certainly need to distribute the pixels from each sub-image to the
2601 correct place.  This is where everything gets very tricky.
2603 If you want to retrieve the separate images you must pass the correct
2604 number of rows to each successive call of png_read_rows().  The calculation
2605 gets pretty complicated for small images, where some sub-images may
2606 not even exist because either their width or height ends up zero.
2607 libpng provides two macros to help you in 1.5 and later versions:
2609    png_uint_32 width = PNG_PASS_COLS(image_width, pass_number);
2610    png_uint_32 height = PNG_PASS_ROWS(image_height, pass_number);
2612 Respectively these tell you the width and height of the sub-image
2613 corresponding to the numbered pass.  'pass' is in in the range 0 to 6 -
2614 this can be confusing because the specification refers to the same passes
2615 as 1 to 7!  Be careful, you must check both the width and height before
2616 calling png_read_rows() and not call it for that pass if either is zero.
2618 You can, of course, read each sub-image row by row.  If you want to
2619 produce optimal code to make a pixel-by-pixel transformation of an
2620 interlaced image this is the best approach; read each row of each pass,
2621 transform it, and write it out to a new interlaced image.
2623 If you want to de-interlace the image yourself libpng provides further
2624 macros to help that tell you where to place the pixels in the output image.
2625 Because the interlacing scheme is rectangular - sub-image pixels are always
2626 arranged on a rectangular grid - all you need to know for each pass is the
2627 starting column and row in the output image of the first pixel plus the
2628 spacing between each pixel.  As of libpng 1.5 there are four macros to
2629 retrieve this information:
2631    png_uint_32 x = PNG_PASS_START_COL(pass);
2632    png_uint_32 y = PNG_PASS_START_ROW(pass);
2633    png_uint_32 xStep = 1U << PNG_PASS_COL_SHIFT(pass);
2634    png_uint_32 yStep = 1U << PNG_PASS_ROW_SHIFT(pass);
2636 These allow you to write the obvious loop:
2638    png_uint_32 input_y = 0;
2639    png_uint_32 output_y = PNG_PASS_START_ROW(pass);
2641    while (output_y < output_image_height)
2642    {
2643       png_uint_32 input_x = 0;
2644       png_uint_32 output_x = PNG_PASS_START_COL(pass);
2646       while (output_x < output_image_width)
2647       {
2648          image[output_y][output_x] =
2649              subimage[pass][input_y][input_x++];
2651          output_x += xStep;
2652       }
2654       ++input_y;
2655       output_y += yStep;
2656    }
2658 Notice that the steps between successive output rows and columns are
2659 returned as shifts.  This is possible because the pixels in the subimages
2660 are always a power of 2 apart - 1, 2, 4 or 8 pixels - in the original
2661 image.  In practice you may need to directly calculate the output coordinate
2662 given an input coordinate.  libpng provides two further macros for this
2663 purpose:
2665    png_uint_32 output_x = PNG_COL_FROM_PASS_COL(input_x, pass);
2666    png_uint_32 output_y = PNG_ROW_FROM_PASS_ROW(input_y, pass);
2668 Finally a pair of macros are provided to tell you if a particular image
2669 row or column appears in a given pass:
2671    int col_in_pass = PNG_COL_IN_INTERLACE_PASS(output_x, pass);
2672    int row_in_pass = PNG_ROW_IN_INTERLACE_PASS(output_y, pass);
2674 Bear in mind that you will probably also need to check the width and height
2675 of the pass in addition to the above to be sure the pass even exists!
2677 With any luck you are convinced by now that you don't want to do your own
2678 interlace handling.  In reality normally the only good reason for doing this
2679 is if you are processing PNG files on a pixel-by-pixel basis and don't want
2680 to load the whole file into memory when it is interlaced.
2682 libpng includes a test program, pngvalid, that illustrates reading and
2683 writing of interlaced images.  If you can't get interlacing to work in your
2684 code and don't want to leave it to libpng (the recommended approach) see
2685 how pngvalid.c does it.
2687 .SS Finishing a sequential read
2689 After you are finished reading the image through the
2690 low-level interface, you can finish reading the file.  If you are
2691 interested in comments or time, which may be stored either before or
2692 after the image data, you should pass the separate png_info struct if
2693 you want to keep the comments from before and after the image
2694 separate.  If you are not interested, you can pass NULL.
2696    png_read_end(png_ptr, end_info);
2698 When you are done, you can free all memory allocated by libpng like this:
2700    png_destroy_read_struct(&png_ptr, &info_ptr,
2701        &end_info);
2703 It is also possible to individually free the info_ptr members that
2704 point to libpng-allocated storage with the following function:
2706     png_free_data(png_ptr, info_ptr, mask, seq)
2708     mask - identifies data to be freed, a mask
2709            containing the bitwise OR of one or
2710            more of
2711              PNG_FREE_PLTE, PNG_FREE_TRNS,
2712              PNG_FREE_HIST, PNG_FREE_ICCP,
2713              PNG_FREE_PCAL, PNG_FREE_ROWS,
2714              PNG_FREE_SCAL, PNG_FREE_SPLT,
2715              PNG_FREE_TEXT, PNG_FREE_UNKN,
2716            or simply PNG_FREE_ALL
2718     seq  - sequence number of item to be freed
2719            (-1 for all items)
2721 This function may be safely called when the relevant storage has
2722 already been freed, or has not yet been allocated, or was allocated
2723 by the user and not by libpng,  and will in those cases do nothing.
2724 The "seq" parameter is ignored if only one item of the selected data
2725 type, such as PLTE, is allowed.  If "seq" is not -1, and multiple items
2726 are allowed for the data type identified in the mask, such as text or
2727 sPLT, only the n'th item in the structure is freed, where n is "seq".
2729 The default behavior is only to free data that was allocated internally
2730 by libpng.  This can be changed, so that libpng will not free the data,
2731 or so that it will free data that was allocated by the user with png_malloc()
2732 or png_zalloc() and passed in via a png_set_*() function, with
2734     png_data_freer(png_ptr, info_ptr, freer, mask)
2736     freer  - one of
2737                PNG_DESTROY_WILL_FREE_DATA
2738                PNG_SET_WILL_FREE_DATA
2739                PNG_USER_WILL_FREE_DATA
2741     mask   - which data elements are affected
2742              same choices as in png_free_data()
2744 This function only affects data that has already been allocated.
2745 You can call this function after reading the PNG data but before calling
2746 any png_set_*() functions, to control whether the user or the png_set_*()
2747 function is responsible for freeing any existing data that might be present,
2748 and again after the png_set_*() functions to control whether the user
2749 or png_destroy_*() is supposed to free the data.  When the user assumes
2750 responsibility for libpng-allocated data, the application must use
2751 png_free() to free it, and when the user transfers responsibility to libpng
2752 for data that the user has allocated, the user must have used png_malloc()
2753 or png_zalloc() to allocate it.
2755 If you allocated your row_pointers in a single block, as suggested above in
2756 the description of the high level read interface, you must not transfer
2757 responsibility for freeing it to the png_set_rows or png_read_destroy function,
2758 because they would also try to free the individual row_pointers[i].
2760 If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword
2761 separately, do not transfer responsibility for freeing text_ptr to libpng,
2762 because when libpng fills a png_text structure it combines these members with
2763 the key member, and png_free_data() will free only text_ptr.key.  Similarly,
2764 if you transfer responsibility for free'ing text_ptr from libpng to your
2765 application, your application must not separately free those members.
2767 The png_free_data() function will turn off the "valid" flag for anything
2768 it frees.  If you need to turn the flag off for a chunk that was freed by
2769 your application instead of by libpng, you can use
2771     png_set_invalid(png_ptr, info_ptr, mask);
2773     mask - identifies the chunks to be made invalid,
2774            containing the bitwise OR of one or
2775            more of
2776              PNG_INFO_gAMA, PNG_INFO_sBIT,
2777              PNG_INFO_cHRM, PNG_INFO_PLTE,
2778              PNG_INFO_tRNS, PNG_INFO_bKGD,
2779              PNG_INFO_hIST, PNG_INFO_pHYs,
2780              PNG_INFO_oFFs, PNG_INFO_tIME,
2781              PNG_INFO_pCAL, PNG_INFO_sRGB,
2782              PNG_INFO_iCCP, PNG_INFO_sPLT,
2783              PNG_INFO_sCAL, PNG_INFO_IDAT
2785 For a more compact example of reading a PNG image, see the file example.c.
2787 .SS Reading PNG files progressively
2789 The progressive reader is slightly different then the non-progressive
2790 reader.  Instead of calling png_read_info(), png_read_rows(), and
2791 png_read_end(), you make one call to png_process_data(), which calls
2792 callbacks when it has the info, a row, or the end of the image.  You
2793 set up these callbacks with png_set_progressive_read_fn().  You don't
2794 have to worry about the input/output functions of libpng, as you are
2795 giving the library the data directly in png_process_data().  I will
2796 assume that you have read the section on reading PNG files above,
2797 so I will only highlight the differences (although I will show
2798 all of the code).
2800 png_structp png_ptr;
2801 png_infop info_ptr;
2803  /*  An example code fragment of how you would
2804      initialize the progressive reader in your
2805      application. */
2806  int
2807  initialize_png_reader()
2809     png_ptr = png_create_read_struct
2810         (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
2811          user_error_fn, user_warning_fn);
2813     if (!png_ptr)
2814         return (ERROR);
2816     info_ptr = png_create_info_struct(png_ptr);
2818     if (!info_ptr)
2819     {
2820        png_destroy_read_struct(&png_ptr,
2821           (png_infopp)NULL, (png_infopp)NULL);
2822        return (ERROR);
2823     }
2825     if (setjmp(png_jmpbuf(png_ptr)))
2826     {
2827        png_destroy_read_struct(&png_ptr, &info_ptr,
2828           (png_infopp)NULL);
2829        return (ERROR);
2830     }
2832     /* This one's new.  You can provide functions
2833        to be called when the header info is valid,
2834        when each row is completed, and when the image
2835        is finished.  If you aren't using all functions,
2836        you can specify NULL parameters.  Even when all
2837        three functions are NULL, you need to call
2838        png_set_progressive_read_fn().  You can use
2839        any struct as the user_ptr (cast to a void pointer
2840        for the function call), and retrieve the pointer
2841        from inside the callbacks using the function
2843           png_get_progressive_ptr(png_ptr);
2845        which will return a void pointer, which you have
2846        to cast appropriately.
2847      */
2848     png_set_progressive_read_fn(png_ptr, (void *)user_ptr,
2849         info_callback, row_callback, end_callback);
2851     return 0;
2854  /* A code fragment that you call as you receive blocks
2855    of data */
2856  int
2857  process_data(png_bytep buffer, png_uint_32 length)
2859     if (setjmp(png_jmpbuf(png_ptr)))
2860     {
2861        png_destroy_read_struct(&png_ptr, &info_ptr,
2862            (png_infopp)NULL);
2863        return (ERROR);
2864     }
2866     /* This one's new also.  Simply give it a chunk
2867        of data from the file stream (in order, of
2868        course).  On machines with segmented memory
2869        models machines, don't give it any more than
2870        64K.  The library seems to run fine with sizes
2871        of 4K. Although you can give it much less if
2872        necessary (I assume you can give it chunks of
2873        1 byte, I haven't tried less then 256 bytes
2874        yet).  When this function returns, you may
2875        want to display any rows that were generated
2876        in the row callback if you don't already do
2877        so there.
2878      */
2879     png_process_data(png_ptr, info_ptr, buffer, length);
2881     /* At this point you can call png_process_data_skip if
2882        you want to handle data the library will skip yourself;
2883        it simply returns the number of bytes to skip (and stops
2884        libpng skipping that number of bytes on the next
2885        png_process_data call).
2886     return 0;
2889  /* This function is called (as set by
2890     png_set_progressive_read_fn() above) when enough data
2891     has been supplied so all of the header has been
2892     read.
2893  */
2894  void
2895  info_callback(png_structp png_ptr, png_infop info)
2897     /* Do any setup here, including setting any of
2898        the transformations mentioned in the Reading
2899        PNG files section.  For now, you _must_ call
2900        either png_start_read_image() or
2901        png_read_update_info() after all the
2902        transformations are set (even if you don't set
2903        any).  You may start getting rows before
2904        png_process_data() returns, so this is your
2905        last chance to prepare for that.
2907        This is where you turn on interlace handling,
2908        assuming you don't want to do it yourself.
2910        If you need to you can stop the processing of
2911        your original input data at this point by calling
2912        png_process_data_pause.  This returns the number
2913        of unprocessed bytes from the last png_process_data
2914        call - it is up to you to ensure that the next call
2915        sees these bytes again.  If you don't want to bother
2916        with this you can get libpng to cache the unread
2917        bytes by setting the 'save' parameter (see png.h) but
2918        then libpng will have to copy the data internally.
2919      */
2922  /* This function is called when each row of image
2923     data is complete */
2924  void
2925  row_callback(png_structp png_ptr, png_bytep new_row,
2926     png_uint_32 row_num, int pass)
2928     /* If the image is interlaced, and you turned
2929        on the interlace handler, this function will
2930        be called for every row in every pass.  Some
2931        of these rows will not be changed from the
2932        previous pass.  When the row is not changed,
2933        the new_row variable will be NULL.  The rows
2934        and passes are called in order, so you don't
2935        really need the row_num and pass, but I'm
2936        supplying them because it may make your life
2937        easier.
2939        If you did not turn on interlace handling then
2940        the callback is called for each row of each
2941        sub-image when the image is interlaced.  In this
2942        case 'row_num' is the row in the sub-image, not
2943        the row in the output image as it is in all other
2944        cases.
2946        For the non-NULL rows of interlaced images when
2947        you have switched on libpng interlace handling,
2948        you must call png_progressive_combine_row()
2949        passing in the row and the old row.  You can
2950        call this function for NULL rows (it will just
2951        return) and for non-interlaced images (it just
2952        does the memcpy for you) if it will make the
2953        code easier.  Thus, you can just do this for
2954        all cases if you switch on interlace handling;
2955      */
2957         png_progressive_combine_row(png_ptr, old_row,
2958           new_row);
2960     /* where old_row is what was displayed for
2961        previously for the row.  Note that the first
2962        pass (pass == 0, really) will completely cover
2963        the old row, so the rows do not have to be
2964        initialized.  After the first pass (and only
2965        for interlaced images), you will have to pass
2966        the current row, and the function will combine
2967        the old row and the new row.
2969        You can also call png_process_data_pause in this
2970        callback - see above.
2971     */
2974  void
2975  end_callback(png_structp png_ptr, png_infop info)
2977     /* This function is called after the whole image
2978        has been read, including any chunks after the
2979        image (up to and including the IEND).  You
2980        will usually have the same info chunk as you
2981        had in the header, although some data may have
2982        been added to the comments and time fields.
2984        Most people won't do much here, perhaps setting
2985        a flag that marks the image as finished.
2986      */
2991 .SH IV. Writing
2993 Much of this is very similar to reading.  However, everything of
2994 importance is repeated here, so you won't have to constantly look
2995 back up in the reading section to understand writing.
2997 .SS Setup
2999 You will want to do the I/O initialization before you get into libpng,
3000 so if it doesn't work, you don't have anything to undo. If you are not
3001 using the standard I/O functions, you will need to replace them with
3002 custom writing functions.  See the discussion under Customizing libpng.
3004     FILE *fp = fopen(file_name, "wb");
3006     if (!fp)
3007        return (ERROR);
3009 Next, png_struct and png_info need to be allocated and initialized.
3010 As these can be both relatively large, you may not want to store these
3011 on the stack, unless you have stack space to spare.  Of course, you
3012 will want to check if they return NULL.  If you are also reading,
3013 you won't want to name your read structure and your write structure
3014 both "png_ptr"; you can call them anything you like, such as
3015 "read_ptr" and "write_ptr".  Look at pngtest.c, for example.
3017     png_structp png_ptr = png_create_write_struct
3018        (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
3019         user_error_fn, user_warning_fn);
3021     if (!png_ptr)
3022        return (ERROR);
3024     png_infop info_ptr = png_create_info_struct(png_ptr);
3025     if (!info_ptr)
3026     {
3027        png_destroy_write_struct(&png_ptr,
3028            (png_infopp)NULL);
3029        return (ERROR);
3030     }
3032 If you want to use your own memory allocation routines,
3033 define PNG_USER_MEM_SUPPORTED and use
3034 png_create_write_struct_2() instead of png_create_write_struct():
3036     png_structp png_ptr = png_create_write_struct_2
3037        (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
3038         user_error_fn, user_warning_fn, (png_voidp)
3039         user_mem_ptr, user_malloc_fn, user_free_fn);
3041 After you have these structures, you will need to set up the
3042 error handling.  When libpng encounters an error, it expects to
3043 longjmp() back to your routine.  Therefore, you will need to call
3044 setjmp() and pass the png_jmpbuf(png_ptr).  If you
3045 write the file from different routines, you will need to update
3046 the png_jmpbuf(png_ptr) every time you enter a new routine that will
3047 call a png_*() function.  See your documentation of setjmp/longjmp
3048 for your compiler for more information on setjmp/longjmp.  See
3049 the discussion on libpng error handling in the Customizing Libpng
3050 section below for more information on the libpng error handling.
3052     if (setjmp(png_jmpbuf(png_ptr)))
3053     {
3054     png_destroy_write_struct(&png_ptr, &info_ptr);
3055        fclose(fp);
3056        return (ERROR);
3057     }
3058     ...
3059     return;
3061 If you would rather avoid the complexity of setjmp/longjmp issues,
3062 you can compile libpng with PNG_NO_SETJMP, in which case
3063 errors will result in a call to PNG_ABORT() which defaults to abort().
3065 You can #define PNG_ABORT() to a function that does something
3066 more useful than abort(), as long as your function does not
3067 return.
3069 Now you need to set up the output code.  The default for libpng is to
3070 use the C function fwrite().  If you use this, you will need to pass a
3071 valid FILE * in the function png_init_io().  Be sure that the file is
3072 opened in binary mode.  Again, if you wish to handle writing data in
3073 another way, see the discussion on libpng I/O handling in the Customizing
3074 Libpng section below.
3076     png_init_io(png_ptr, fp);
3078 If you are embedding your PNG into a datastream such as MNG, and don't
3079 want libpng to write the 8-byte signature, or if you have already
3080 written the signature in your application, use
3082     png_set_sig_bytes(png_ptr, 8);
3084 to inform libpng that it should not write a signature.
3086 .SS Write callbacks
3088 At this point, you can set up a callback function that will be
3089 called after each row has been written, which you can use to control
3090 a progress meter or the like.  It's demonstrated in pngtest.c.
3091 You must supply a function
3093     void write_row_callback(png_structp png_ptr, png_uint_32 row,
3094        int pass);
3095     {
3096       /* put your code here */
3097     }
3099 (You can give it another name that you like instead of "write_row_callback")
3101 To inform libpng about your function, use
3103     png_set_write_status_fn(png_ptr, write_row_callback);
3105 You now have the option of modifying how the compression library will
3106 run.  The following functions are mainly for testing, but may be useful
3107 in some cases, like if you need to write PNG files extremely fast and
3108 are willing to give up some compression, or if you want to get the
3109 maximum possible compression at the expense of slower writing.  If you
3110 have no special needs in this area, let the library do what it wants by
3111 not calling this function at all, as it has been tuned to deliver a good
3112 speed/compression ratio. The second parameter to png_set_filter() is
3113 the filter method, for which the only valid values are 0 (as of the
3114 July 1999 PNG specification, version 1.2) or 64 (if you are writing
3115 a PNG datastream that is to be embedded in a MNG datastream).  The third
3116 parameter is a flag that indicates which filter type(s) are to be tested
3117 for each scanline.  See the PNG specification for details on the specific
3118 filter types.
3121     /* turn on or off filtering, and/or choose
3122        specific filters.  You can use either a single
3123        PNG_FILTER_VALUE_NAME or the bitwise OR of one
3124        or more PNG_FILTER_NAME masks.
3125      */
3126     png_set_filter(png_ptr, 0,
3127        PNG_FILTER_NONE  | PNG_FILTER_VALUE_NONE |
3128        PNG_FILTER_SUB   | PNG_FILTER_VALUE_SUB  |
3129        PNG_FILTER_UP    | PNG_FILTER_VALUE_UP   |
3130        PNG_FILTER_AVG   | PNG_FILTER_VALUE_AVG  |
3131        PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH|
3132        PNG_ALL_FILTERS);
3134 If an application wants to start and stop using particular filters during
3135 compression, it should start out with all of the filters (to ensure that
3136 the previous row of pixels will be stored in case it's needed later),
3137 and then add and remove them after the start of compression.
3139 If you are writing a PNG datastream that is to be embedded in a MNG
3140 datastream, the second parameter can be either 0 or 64.
3142 The png_set_compression_*() functions interface to the zlib compression
3143 library, and should mostly be ignored unless you really know what you are
3144 doing.  The only generally useful call is png_set_compression_level()
3145 which changes how much time zlib spends on trying to compress the image
3146 data.  See the Compression Library (zlib.h and algorithm.txt, distributed
3147 with zlib) for details on the compression levels.
3149     /* set the zlib compression level */
3150     png_set_compression_level(png_ptr,
3151         Z_BEST_COMPRESSION);
3153     /* set other zlib parameters */
3154     png_set_compression_mem_level(png_ptr, 8);
3155     png_set_compression_strategy(png_ptr,
3156         Z_DEFAULT_STRATEGY);
3157     png_set_compression_window_bits(png_ptr, 15);
3158     png_set_compression_method(png_ptr, 8);
3159     png_set_compression_buffer_size(png_ptr, 8192)
3161 extern PNG_EXPORT(void,png_set_zbuf_size)
3163 .SS Setting the contents of info for output
3165 You now need to fill in the png_info structure with all the data you
3166 wish to write before the actual image.  Note that the only thing you
3167 are allowed to write after the image is the text chunks and the time
3168 chunk (as of PNG Specification 1.2, anyway).  See png_write_end() and
3169 the latest PNG specification for more information on that.  If you
3170 wish to write them before the image, fill them in now, and flag that
3171 data as being valid.  If you want to wait until after the data, don't
3172 fill them until png_write_end().  For all the fields in png_info and
3173 their data types, see png.h.  For explanations of what the fields
3174 contain, see the PNG specification.
3176 Some of the more important parts of the png_info are:
3178     png_set_IHDR(png_ptr, info_ptr, width, height,
3179        bit_depth, color_type, interlace_type,
3180        compression_type, filter_method)
3182     width          - holds the width of the image
3183                      in pixels (up to 2^31).
3185     height         - holds the height of the image
3186                      in pixels (up to 2^31).
3188     bit_depth      - holds the bit depth of one of the
3189                      image channels.
3190                      (valid values are 1, 2, 4, 8, 16
3191                      and depend also on the
3192                      color_type.  See also significant
3193                      bits (sBIT) below).
3195     color_type     - describes which color/alpha
3196                      channels are present.
3197                      PNG_COLOR_TYPE_GRAY
3198                         (bit depths 1, 2, 4, 8, 16)
3199                      PNG_COLOR_TYPE_GRAY_ALPHA
3200                         (bit depths 8, 16)
3201                      PNG_COLOR_TYPE_PALETTE
3202                         (bit depths 1, 2, 4, 8)
3203                      PNG_COLOR_TYPE_RGB
3204                         (bit_depths 8, 16)
3205                      PNG_COLOR_TYPE_RGB_ALPHA
3206                         (bit_depths 8, 16)
3208                      PNG_COLOR_MASK_PALETTE
3209                      PNG_COLOR_MASK_COLOR
3210                      PNG_COLOR_MASK_ALPHA
3212     interlace_type - PNG_INTERLACE_NONE or
3213                      PNG_INTERLACE_ADAM7
3215     compression_type - (must be
3216                      PNG_COMPRESSION_TYPE_DEFAULT)
3218     filter_method  - (must be PNG_FILTER_TYPE_DEFAULT
3219                      or, if you are writing a PNG to
3220                      be embedded in a MNG datastream,
3221                      can also be
3222                      PNG_INTRAPIXEL_DIFFERENCING)
3224 If you call png_set_IHDR(), the call must appear before any of the
3225 other png_set_*() functions, because they might require access to some of
3226 the IHDR settings.  The remaining png_set_*() functions can be called
3227 in any order.
3229 If you wish, you can reset the compression_type, interlace_type, or
3230 filter_method later by calling png_set_IHDR() again; if you do this, the
3231 width, height, bit_depth, and color_type must be the same in each call.
3233     png_set_PLTE(png_ptr, info_ptr, palette,
3234        num_palette);
3236     palette        - the palette for the file
3237                      (array of png_color)
3238     num_palette    - number of entries in the palette
3240     png_set_gAMA(png_ptr, info_ptr, file_gamma);
3241     png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma);
3243     file_gamma     - the gamma at which the image was
3244                      created (PNG_INFO_gAMA)
3246     int_file_gamma - 100,000 times the gamma at which
3247                      the image was created
3249     png_set_sRGB(png_ptr, info_ptr, srgb_intent);
3251     srgb_intent    - the rendering intent
3252                      (PNG_INFO_sRGB) The presence of
3253                      the sRGB chunk means that the pixel
3254                      data is in the sRGB color space.
3255                      This chunk also implies specific
3256                      values of gAMA and cHRM.  Rendering
3257                      intent is the CSS-1 property that
3258                      has been defined by the International
3259                      Color Consortium
3260                      (http://www.color.org).
3261                      It can be one of
3262                      PNG_sRGB_INTENT_SATURATION,
3263                      PNG_sRGB_INTENT_PERCEPTUAL,
3264                      PNG_sRGB_INTENT_ABSOLUTE, or
3265                      PNG_sRGB_INTENT_RELATIVE.
3268     png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr,
3269        srgb_intent);
3271     srgb_intent    - the rendering intent
3272                      (PNG_INFO_sRGB) The presence of the
3273                      sRGB chunk means that the pixel
3274                      data is in the sRGB color space.
3275                      This function also causes gAMA and
3276                      cHRM chunks with the specific values
3277                      that are consistent with sRGB to be
3278                      written.
3280     png_set_iCCP(png_ptr, info_ptr, name, compression_type,
3281                        profile, proflen);
3283     name             - The profile name.
3285     compression_type - The compression type; always
3286                        PNG_COMPRESSION_TYPE_BASE for PNG 1.0.
3287                        You may give NULL to this argument to
3288                        ignore it.
3290     profile          - International Color Consortium color
3291                        profile data. May contain NULs.
3293     proflen          - length of profile data in bytes.
3295     png_set_sBIT(png_ptr, info_ptr, sig_bit);
3297     sig_bit        - the number of significant bits for
3298                      (PNG_INFO_sBIT) each of the gray, red,
3299                      green, and blue channels, whichever are
3300                      appropriate for the given color type
3301                      (png_color_16)
3303     png_set_tRNS(png_ptr, info_ptr, trans_alpha,
3304        num_trans, trans_color);
3306     trans_alpha    - array of alpha (transparency)
3307                      entries for palette (PNG_INFO_tRNS)
3309     trans_color    - graylevel or color sample values
3310                      (in order red, green, blue) of the
3311                      single transparent color for
3312                      non-paletted images (PNG_INFO_tRNS)
3314     num_trans      - number of transparent entries
3315                      (PNG_INFO_tRNS)
3317     png_set_hIST(png_ptr, info_ptr, hist);
3319     hist           - histogram of palette (array of
3320                      png_uint_16) (PNG_INFO_hIST)
3322     png_set_tIME(png_ptr, info_ptr, mod_time);
3324     mod_time       - time image was last modified
3325                      (PNG_VALID_tIME)
3327     png_set_bKGD(png_ptr, info_ptr, background);
3329     background     - background color (PNG_VALID_bKGD)
3331     png_set_text(png_ptr, info_ptr, text_ptr, num_text);
3333     text_ptr       - array of png_text holding image
3334                      comments
3336     text_ptr[i].compression - type of compression used
3337                  on "text" PNG_TEXT_COMPRESSION_NONE
3338                            PNG_TEXT_COMPRESSION_zTXt
3339                            PNG_ITXT_COMPRESSION_NONE
3340                            PNG_ITXT_COMPRESSION_zTXt
3341     text_ptr[i].key   - keyword for comment.  Must contain
3342                  1-79 characters.
3343     text_ptr[i].text  - text comments for current
3344                          keyword.  Can be NULL or empty.
3345     text_ptr[i].text_length - length of text string,
3346                  after decompression, 0 for iTXt
3347     text_ptr[i].itxt_length - length of itxt string,
3348                  after decompression, 0 for tEXt/zTXt
3349     text_ptr[i].lang  - language of comment (NULL or
3350                          empty for unknown).
3351     text_ptr[i].translated_keyword  - keyword in UTF-8 (NULL
3352                          or empty for unknown).
3353     Note that the itxt_length, lang, and lang_key
3354     members of the text_ptr structure only exist
3355     when the library is built with iTXt chunk support.
3357     num_text       - number of comments
3359     png_set_sPLT(png_ptr, info_ptr, &palette_ptr,
3360        num_spalettes);
3362     palette_ptr    - array of png_sPLT_struct structures
3363                      to be added to the list of palettes
3364                      in the info structure.
3365     num_spalettes  - number of palette structures to be
3366                      added.
3368     png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y,
3369         unit_type);
3371     offset_x  - positive offset from the left
3372                      edge of the screen
3374     offset_y  - positive offset from the top
3375                      edge of the screen
3377     unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER
3379     png_set_pHYs(png_ptr, info_ptr, res_x, res_y,
3380         unit_type);
3382     res_x       - pixels/unit physical resolution
3383                   in x direction
3385     res_y       - pixels/unit physical resolution
3386                   in y direction
3388     unit_type   - PNG_RESOLUTION_UNKNOWN,
3389                   PNG_RESOLUTION_METER
3391     png_set_sCAL(png_ptr, info_ptr, unit, width, height)
3393     unit        - physical scale units (an integer)
3395     width       - width of a pixel in physical scale units
3397     height      - height of a pixel in physical scale units
3398                   (width and height are doubles)
3400     png_set_sCAL_s(png_ptr, info_ptr, unit, width, height)
3402     unit        - physical scale units (an integer)
3404     width       - width of a pixel in physical scale units
3406     height      - height of a pixel in physical scale units
3407                  (width and height are strings like "2.54")
3409     png_set_unknown_chunks(png_ptr, info_ptr, &unknowns,
3410        num_unknowns)
3412     unknowns          - array of png_unknown_chunk
3413                         structures holding unknown chunks
3414     unknowns[i].name  - name of unknown chunk
3415     unknowns[i].data  - data of unknown chunk
3416     unknowns[i].size  - size of unknown chunk's data
3417     unknowns[i].location - position to write chunk in file
3418                            0: do not write chunk
3419                            PNG_HAVE_IHDR: before PLTE
3420                            PNG_HAVE_PLTE: before IDAT
3421                            PNG_AFTER_IDAT: after IDAT
3423 The "location" member is set automatically according to
3424 what part of the output file has already been written.
3425 You can change its value after calling png_set_unknown_chunks()
3426 as demonstrated in pngtest.c.  Within each of the "locations",
3427 the chunks are sequenced according to their position in the
3428 structure (that is, the value of "i", which is the order in which
3429 the chunk was either read from the input file or defined with
3430 png_set_unknown_chunks).
3432 A quick word about text and num_text.  text is an array of png_text
3433 structures.  num_text is the number of valid structures in the array.
3434 Each png_text structure holds a language code, a keyword, a text value,
3435 and a compression type.
3437 The compression types have the same valid numbers as the compression
3438 types of the image data.  Currently, the only valid number is zero.
3439 However, you can store text either compressed or uncompressed, unlike
3440 images, which always have to be compressed.  So if you don't want the
3441 text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE.
3442 Because tEXt and zTXt chunks don't have a language field, if you
3443 specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt
3444 any language code or translated keyword will not be written out.
3446 Until text gets around 1000 bytes, it is not worth compressing it.
3447 After the text has been written out to the file, the compression type
3448 is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR,
3449 so that it isn't written out again at the end (in case you are calling
3450 png_write_end() with the same struct).
3452 The keywords that are given in the PNG Specification are:
3454     Title            Short (one line) title or
3455                      caption for image
3457     Author           Name of image's creator
3459     Description      Description of image (possibly long)
3461     Copyright        Copyright notice
3463     Creation Time    Time of original image creation
3464                      (usually RFC 1123 format, see below)
3466     Software         Software used to create the image
3468     Disclaimer       Legal disclaimer
3470     Warning          Warning of nature of content
3472     Source           Device used to create the image
3474     Comment          Miscellaneous comment; conversion
3475                      from other image format
3477 The keyword-text pairs work like this.  Keywords should be short
3478 simple descriptions of what the comment is about.  Some typical
3479 keywords are found in the PNG specification, as is some recommendations
3480 on keywords.  You can repeat keywords in a file.  You can even write
3481 some text before the image and some after.  For example, you may want
3482 to put a description of the image before the image, but leave the
3483 disclaimer until after, so viewers working over modem connections
3484 don't have to wait for the disclaimer to go over the modem before
3485 they start seeing the image.  Finally, keywords should be full
3486 words, not abbreviations.  Keywords and text are in the ISO 8859-1
3487 (Latin-1) character set (a superset of regular ASCII) and can not
3488 contain NUL characters, and should not contain control or other
3489 unprintable characters.  To make the comments widely readable, stick
3490 with basic ASCII, and avoid machine specific character set extensions
3491 like the IBM-PC character set.  The keyword must be present, but
3492 you can leave off the text string on non-compressed pairs.
3493 Compressed pairs must have a text string, as only the text string
3494 is compressed anyway, so the compression would be meaningless.
3496 PNG supports modification time via the png_time structure.  Two
3497 conversion routines are provided, png_convert_from_time_t() for
3498 time_t and png_convert_from_struct_tm() for struct tm.  The
3499 time_t routine uses gmtime().  You don't have to use either of
3500 these, but if you wish to fill in the png_time structure directly,
3501 you should provide the time in universal time (GMT) if possible
3502 instead of your local time.  Note that the year number is the full
3503 year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and
3504 that months start with 1.
3506 If you want to store the time of the original image creation, you should
3507 use a plain tEXt chunk with the "Creation Time" keyword.  This is
3508 necessary because the "creation time" of a PNG image is somewhat vague,
3509 depending on whether you mean the PNG file, the time the image was
3510 created in a non-PNG format, a still photo from which the image was
3511 scanned, or possibly the subject matter itself.  In order to facilitate
3512 machine-readable dates, it is recommended that the "Creation Time"
3513 tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"),
3514 although this isn't a requirement.  Unlike the tIME chunk, the
3515 "Creation Time" tEXt chunk is not expected to be automatically changed
3516 by the software.  To facilitate the use of RFC 1123 dates, a function
3517 png_convert_to_rfc1123(png_timep) is provided to convert from PNG
3518 time to an RFC 1123 format string.
3520 .SS Writing unknown chunks
3522 You can use the png_set_unknown_chunks function to queue up chunks
3523 for writing.  You give it a chunk name, raw data, and a size; that's
3524 all there is to it.  The chunks will be written by the next following
3525 png_write_info_before_PLTE, png_write_info, or png_write_end function.
3526 Any chunks previously read into the info structure's unknown-chunk
3527 list will also be written out in a sequence that satisfies the PNG
3528 specification's ordering rules.
3530 .SS The high-level write interface
3532 At this point there are two ways to proceed; through the high-level
3533 write interface, or through a sequence of low-level write operations.
3534 You can use the high-level interface if your image data is present
3535 in the info structure.  All defined output
3536 transformations are permitted, enabled by the following masks.
3538     PNG_TRANSFORM_IDENTITY      No transformation
3539     PNG_TRANSFORM_PACKING       Pack 1, 2 and 4-bit samples
3540     PNG_TRANSFORM_PACKSWAP      Change order of packed
3541                                 pixels to LSB first
3542     PNG_TRANSFORM_INVERT_MONO   Invert monochrome images
3543     PNG_TRANSFORM_SHIFT         Normalize pixels to the
3544                                 sBIT depth
3545     PNG_TRANSFORM_BGR           Flip RGB to BGR, RGBA
3546                                 to BGRA
3547     PNG_TRANSFORM_SWAP_ALPHA    Flip RGBA to ARGB or GA
3548                                 to AG
3549     PNG_TRANSFORM_INVERT_ALPHA  Change alpha from opacity
3550                                 to transparency
3551     PNG_TRANSFORM_SWAP_ENDIAN   Byte-swap 16-bit samples
3552     PNG_TRANSFORM_STRIP_FILLER        Strip out filler
3553                                       bytes (deprecated).
3554     PNG_TRANSFORM_STRIP_FILLER_BEFORE Strip out leading
3555                                       filler bytes
3556     PNG_TRANSFORM_STRIP_FILLER_AFTER  Strip out trailing
3557                                       filler bytes
3559 If you have valid image data in the info structure (you can use
3560 png_set_rows() to put image data in the info structure), simply do this:
3562     png_write_png(png_ptr, info_ptr, png_transforms, NULL)
3564 where png_transforms is an integer containing the bitwise OR of some set of
3565 transformation flags.  This call is equivalent to png_write_info(),
3566 followed the set of transformations indicated by the transform mask,
3567 then png_write_image(), and finally png_write_end().
3569 (The final parameter of this call is not yet used.  Someday it might point
3570 to transformation parameters required by some future output transform.)
3572 You must use png_transforms and not call any png_set_transform() functions
3573 when you use png_write_png().
3575 .SS The low-level write interface
3577 If you are going the low-level route instead, you are now ready to
3578 write all the file information up to the actual image data.  You do
3579 this with a call to png_write_info().
3581     png_write_info(png_ptr, info_ptr);
3583 Note that there is one transformation you may need to do before
3584 png_write_info().  In PNG files, the alpha channel in an image is the
3585 level of opacity.  If your data is supplied as a level of transparency,
3586 you can invert the alpha channel before you write it, so that 0 is
3587 fully transparent and 255 (in 8-bit or paletted images) or 65535
3588 (in 16-bit images) is fully opaque, with
3590     png_set_invert_alpha(png_ptr);
3592 This must appear before png_write_info() instead of later with the
3593 other transformations because in the case of paletted images the tRNS
3594 chunk data has to be inverted before the tRNS chunk is written.  If
3595 your image is not a paletted image, the tRNS data (which in such cases
3596 represents a single color to be rendered as transparent) won't need to
3597 be changed, and you can safely do this transformation after your
3598 png_write_info() call.
3600 If you need to write a private chunk that you want to appear before
3601 the PLTE chunk when PLTE is present, you can write the PNG info in
3602 two steps, and insert code to write your own chunk between them:
3604     png_write_info_before_PLTE(png_ptr, info_ptr);
3605     png_set_unknown_chunks(png_ptr, info_ptr, ...);
3606     png_write_info(png_ptr, info_ptr);
3608 After you've written the file information, you can set up the library
3609 to handle any special transformations of the image data.  The various
3610 ways to transform the data will be described in the order that they
3611 should occur.  This is important, as some of these change the color
3612 type and/or bit depth of the data, and some others only work on
3613 certain color types and bit depths.  Even though each transformation
3614 checks to see if it has data that it can do something with, you should
3615 make sure to only enable a transformation if it will be valid for the
3616 data.  For example, don't swap red and blue on grayscale data.
3618 PNG files store RGB pixels packed into 3 or 6 bytes.  This code tells
3619 the library to strip input data that has 4 or 8 bytes per pixel down
3620 to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2
3621 bytes per pixel).
3623     png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
3625 where the 0 is unused, and the location is either PNG_FILLER_BEFORE or
3626 PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel
3627 is stored XRGB or RGBX.
3629 PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
3630 they can, resulting in, for example, 8 pixels per byte for 1 bit files.
3631 If the data is supplied at 1 pixel per byte, use this code, which will
3632 correctly pack the pixels into a single byte:
3634     png_set_packing(png_ptr);
3636 PNG files reduce possible bit depths to 1, 2, 4, 8, and 16.  If your
3637 data is of another bit depth, you can write an sBIT chunk into the
3638 file so that decoders can recover the original data if desired.
3640     /* Set the true bit depth of the image data */
3641     if (color_type & PNG_COLOR_MASK_COLOR)
3642     {
3643        sig_bit.red = true_bit_depth;
3644        sig_bit.green = true_bit_depth;
3645        sig_bit.blue = true_bit_depth;
3646     }
3648     else
3649     {
3650        sig_bit.gray = true_bit_depth;
3651     }
3653     if (color_type & PNG_COLOR_MASK_ALPHA)
3654     {
3655        sig_bit.alpha = true_bit_depth;
3656     }
3658     png_set_sBIT(png_ptr, info_ptr, &sig_bit);
3660 If the data is stored in the row buffer in a bit depth other than
3661 one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG),
3662 this will scale the values to appear to be the correct bit depth as
3663 is required by PNG.
3665     png_set_shift(png_ptr, &sig_bit);
3667 PNG files store 16 bit pixels in network byte order (big-endian,
3668 ie. most significant bits first).  This code would be used if they are
3669 supplied the other way (little-endian, i.e. least significant bits
3670 first, the way PCs store them):
3672     if (bit_depth > 8)
3673        png_set_swap(png_ptr);
3675 If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you
3676 need to change the order the pixels are packed into bytes, you can use:
3678     if (bit_depth < 8)
3679        png_set_packswap(png_ptr);
3681 PNG files store 3 color pixels in red, green, blue order.  This code
3682 would be used if they are supplied as blue, green, red:
3684     png_set_bgr(png_ptr);
3686 PNG files describe monochrome as black being zero and white being
3687 one. This code would be used if the pixels are supplied with this reversed
3688 (black being one and white being zero):
3690     png_set_invert_mono(png_ptr);
3692 Finally, you can write your own transformation function if none of
3693 the existing ones meets your needs.  This is done by setting a callback
3694 with
3696     png_set_write_user_transform_fn(png_ptr,
3697        write_transform_fn);
3699 You must supply the function
3701     void write_transform_fn(png_structp png_ptr ptr,
3702        row_info_ptr row_info, png_bytep data)
3704 See pngtest.c for a working example.  Your function will be called
3705 before any of the other transformations are processed.  If supported
3706 libpng also supplies an information routine that may be called from
3707 your callback:
3709    png_get_current_row_number(png_ptr);
3711 This returns the current row passed to the transform.  Even with interlaced
3712 images the value returned is the row in the final output image.
3714 You can also set up a pointer to a user structure for use by your
3715 callback function.
3717     png_set_user_transform_info(png_ptr, user_ptr, 0, 0);
3719 The user_channels and user_depth parameters of this function are ignored
3720 when writing; you can set them to zero as shown.
3722 You can retrieve the pointer via the function png_get_user_transform_ptr().
3723 For example:
3725     voidp write_user_transform_ptr =
3726        png_get_user_transform_ptr(png_ptr);
3728 It is possible to have libpng flush any pending output, either manually,
3729 or automatically after a certain number of lines have been written.  To
3730 flush the output stream a single time call:
3732     png_write_flush(png_ptr);
3734 and to have libpng flush the output stream periodically after a certain
3735 number of scanlines have been written, call:
3737     png_set_flush(png_ptr, nrows);
3739 Note that the distance between rows is from the last time png_write_flush()
3740 was called, or the first row of the image if it has never been called.
3741 So if you write 50 lines, and then png_set_flush 25, it will flush the
3742 output on the next scanline, and every 25 lines thereafter, unless
3743 png_write_flush() is called before 25 more lines have been written.
3744 If nrows is too small (less than about 10 lines for a 640 pixel wide
3745 RGB image) the image compression may decrease noticeably (although this
3746 may be acceptable for real-time applications).  Infrequent flushing will
3747 only degrade the compression performance by a few percent over images
3748 that do not use flushing.
3750 .SS Writing the image data
3752 That's it for the transformations.  Now you can write the image data.
3753 The simplest way to do this is in one function call.  If you have the
3754 whole image in memory, you can just call png_write_image() and libpng
3755 will write the image.  You will need to pass in an array of pointers to
3756 each row.  This function automatically handles interlacing, so you don't
3757 need to call png_set_interlace_handling() or call this function multiple
3758 times, or any of that other stuff necessary with png_write_rows().
3760     png_write_image(png_ptr, row_pointers);
3762 where row_pointers is:
3764     png_byte *row_pointers[height];
3766 You can point to void or char or whatever you use for pixels.
3768 If you don't want to write the whole image at once, you can
3769 use png_write_rows() instead.  If the file is not interlaced,
3770 this is simple:
3772     png_write_rows(png_ptr, row_pointers,
3773        number_of_rows);
3775 row_pointers is the same as in the png_write_image() call.
3777 If you are just writing one row at a time, you can do this with
3778 a single row_pointer instead of an array of row_pointers:
3780     png_bytep row_pointer = row;
3782     png_write_row(png_ptr, row_pointer);
3784 When the file is interlaced, things can get a good deal more complicated.
3785 The only currently (as of the PNG Specification version 1.2, dated July
3786 1999) defined interlacing scheme for PNG files is the "Adam7" interlace
3787 scheme, that breaks down an image into seven smaller images of varying
3788 size.  libpng will build these images for you, or you can do them
3789 yourself.  If you want to build them yourself, see the PNG specification
3790 for details of which pixels to write when.
3792 If you don't want libpng to handle the interlacing details, just
3793 use png_set_interlace_handling() and call png_write_rows() the
3794 correct number of times to write all the sub-images
3795 (png_set_interlace_handling() returns the number of sub-images.)
3797 If you want libpng to build the sub-images, call this before you start
3798 writing any rows:
3800     number_of_passes = png_set_interlace_handling(png_ptr);
3802 This will return the number of passes needed.  Currently, this is seven,
3803 but may change if another interlace type is added.
3805 Then write the complete image number_of_passes times.
3807     png_write_rows(png_ptr, row_pointers, number_of_rows);
3809 Think carefully before you write an interlaced image.  Typically code that
3810 reads such images reads all the image data into memory, uncompressed, before
3811 doing any processing.  Only code that can display an image on the fly can
3812 take advantage of the interlacing and even then the image has to be exactly
3813 the correct size for the output device, because scaling an image requires
3814 adjacent pixels and these are not available until all the passes have been
3815 read.
3817 If you do write an interlaced image you will hardly ever need to handle
3818 the interlacing yourself.  Call png_set_interlace_handling() and use the
3819 approach described above.
3821 The only time it is conceivable that you will really need to write an
3822 interlaced image pass-by-pass is when you have read one pass by pass and
3823 made some pixel-by-pixel transformation to it, as described in the read
3824 code above.  In this case use the PNG_PASS_ROWS and PNG_PASS_COLS macros
3825 to determine the size of each sub-image in turn and simply write the rows
3826 you obtained from the read code.
3828 .SS Finishing a sequential write
3830 After you are finished writing the image, you should finish writing
3831 the file.  If you are interested in writing comments or time, you should
3832 pass an appropriately filled png_info pointer.  If you are not interested,
3833 you can pass NULL.
3835     png_write_end(png_ptr, info_ptr);
3837 When you are done, you can free all memory used by libpng like this:
3839     png_destroy_write_struct(&png_ptr, &info_ptr);
3841 It is also possible to individually free the info_ptr members that
3842 point to libpng-allocated storage with the following function:
3844     png_free_data(png_ptr, info_ptr, mask, seq)
3846     mask  - identifies data to be freed, a mask
3847             containing the bitwise OR of one or
3848             more of
3849               PNG_FREE_PLTE, PNG_FREE_TRNS,
3850               PNG_FREE_HIST, PNG_FREE_ICCP,
3851               PNG_FREE_PCAL, PNG_FREE_ROWS,
3852               PNG_FREE_SCAL, PNG_FREE_SPLT,
3853               PNG_FREE_TEXT, PNG_FREE_UNKN,
3854             or simply PNG_FREE_ALL
3856     seq   - sequence number of item to be freed
3857             (-1 for all items)
3859 This function may be safely called when the relevant storage has
3860 already been freed, or has not yet been allocated, or was allocated
3861 by the user  and not by libpng,  and will in those cases do nothing.
3862 The "seq" parameter is ignored if only one item of the selected data
3863 type, such as PLTE, is allowed.  If "seq" is not -1, and multiple items
3864 are allowed for the data type identified in the mask, such as text or
3865 sPLT, only the n'th item in the structure is freed, where n is "seq".
3867 If you allocated data such as a palette that you passed in to libpng
3868 with png_set_*, you must not free it until just before the call to
3869 png_destroy_write_struct().
3871 The default behavior is only to free data that was allocated internally
3872 by libpng.  This can be changed, so that libpng will not free the data,
3873 or so that it will free data that was allocated by the user with png_malloc()
3874 or png_zalloc() and passed in via a png_set_*() function, with
3876     png_data_freer(png_ptr, info_ptr, freer, mask)
3878     freer  - one of
3879                PNG_DESTROY_WILL_FREE_DATA
3880                PNG_SET_WILL_FREE_DATA
3881                PNG_USER_WILL_FREE_DATA
3883     mask   - which data elements are affected
3884              same choices as in png_free_data()
3886 For example, to transfer responsibility for some data from a read structure
3887 to a write structure, you could use
3889     png_data_freer(read_ptr, read_info_ptr,
3890        PNG_USER_WILL_FREE_DATA,
3891        PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST)
3893     png_data_freer(write_ptr, write_info_ptr,
3894        PNG_DESTROY_WILL_FREE_DATA,
3895        PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST)
3897 thereby briefly reassigning responsibility for freeing to the user but
3898 immediately afterwards reassigning it once more to the write_destroy
3899 function.  Having done this, it would then be safe to destroy the read
3900 structure and continue to use the PLTE, tRNS, and hIST data in the write
3901 structure.
3903 This function only affects data that has already been allocated.
3904 You can call this function before calling after the png_set_*() functions
3905 to control whether the user or png_destroy_*() is supposed to free the data.
3906 When the user assumes responsibility for libpng-allocated data, the
3907 application must use
3908 png_free() to free it, and when the user transfers responsibility to libpng
3909 for data that the user has allocated, the user must have used png_malloc()
3910 or png_zalloc() to allocate it.
3912 If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword
3913 separately, do not transfer responsibility for freeing text_ptr to libpng,
3914 because when libpng fills a png_text structure it combines these members with
3915 the key member, and png_free_data() will free only text_ptr.key.  Similarly,
3916 if you transfer responsibility for free'ing text_ptr from libpng to your
3917 application, your application must not separately free those members.
3918 For a more compact example of writing a PNG image, see the file example.c.
3920 .SH V. Modifying/Customizing libpng:
3922 There are two issues here.  The first is changing how libpng does
3923 standard things like memory allocation, input/output, and error handling.
3924 The second deals with more complicated things like adding new chunks,
3925 adding new transformations, and generally changing how libpng works.
3926 Both of those are compile-time issues; that is, they are generally
3927 determined at the time the code is written, and there is rarely a need
3928 to provide the user with a means of changing them.
3930 Memory allocation, input/output, and error handling
3932 All of the memory allocation, input/output, and error handling in libpng
3933 goes through callbacks that are user-settable.  The default routines are
3934 in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively.  To change
3935 these functions, call the appropriate png_set_*_fn() function.
3937 Memory allocation is done through the functions png_malloc(), png_calloc(),
3938 and png_free().  These currently just call the standard C functions.
3939 png_calloc() calls png_malloc() and then clears the newly
3940 allocated memory to zero.  There is limited support for certain systems
3941 with segmented memory architectures and the types of pointers declared by
3942 png.h match this; you will have to use appropriate pointers in your
3943 application.  Since it is
3944 unlikely that the method of handling memory allocation on a platform
3945 will change between applications, these functions must be modified in
3946 the library at compile time.  If you prefer to use a different method
3947 of allocating and freeing data, you can use png_create_read_struct_2() or
3948 png_create_write_struct_2() to register your own functions as described
3949 above.  These functions also provide a void pointer that can be retrieved
3952     mem_ptr=png_get_mem_ptr(png_ptr);
3954 Your replacement memory functions must have prototypes as follows:
3956     png_voidp malloc_fn(png_structp png_ptr,
3957        png_alloc_size_t size);
3959     void free_fn(png_structp png_ptr, png_voidp ptr);
3961 Your malloc_fn() must return NULL in case of failure.  The png_malloc()
3962 function will normally call png_error() if it receives a NULL from the
3963 system memory allocator or from your replacement malloc_fn().
3965 Your free_fn() will never be called with a NULL ptr, since libpng's
3966 png_free() checks for NULL before calling free_fn().
3968 Input/Output in libpng is done through png_read() and png_write(),
3969 which currently just call fread() and fwrite().  The FILE * is stored in
3970 png_struct and is initialized via png_init_io().  If you wish to change
3971 the method of I/O, the library supplies callbacks that you can set
3972 through the function png_set_read_fn() and png_set_write_fn() at run
3973 time, instead of calling the png_init_io() function.  These functions
3974 also provide a void pointer that can be retrieved via the function
3975 png_get_io_ptr().  For example:
3977     png_set_read_fn(png_structp read_ptr,
3978         voidp read_io_ptr, png_rw_ptr read_data_fn)
3980     png_set_write_fn(png_structp write_ptr,
3981         voidp write_io_ptr, png_rw_ptr write_data_fn,
3982         png_flush_ptr output_flush_fn);
3984     voidp read_io_ptr = png_get_io_ptr(read_ptr);
3985     voidp write_io_ptr = png_get_io_ptr(write_ptr);
3987 The replacement I/O functions must have prototypes as follows:
3989     void user_read_data(png_structp png_ptr,
3990         png_bytep data, png_size_t length);
3992     void user_write_data(png_structp png_ptr,
3993         png_bytep data, png_size_t length);
3995     void user_flush_data(png_structp png_ptr);
3997 The user_read_data() function is responsible for detecting and
3998 handling end-of-data errors.
4000 Supplying NULL for the read, write, or flush functions sets them back
4001 to using the default C stream functions, which expect the io_ptr to
4002 point to a standard *FILE structure.  It is probably a mistake
4003 to use NULL for one of write_data_fn and output_flush_fn but not both
4004 of them, unless you have built libpng with PNG_NO_WRITE_FLUSH defined.
4005 It is an error to read from a write stream, and vice versa.
4007 Error handling in libpng is done through png_error() and png_warning().
4008 Errors handled through png_error() are fatal, meaning that png_error()
4009 should never return to its caller.  Currently, this is handled via
4010 setjmp() and longjmp() (unless you have compiled libpng with
4011 PNG_NO_SETJMP, in which case it is handled via PNG_ABORT()),
4012 but you could change this to do things like exit() if you should wish,
4013 as long as your function does not return.
4015 On non-fatal errors, png_warning() is called
4016 to print a warning message, and then control returns to the calling code.
4017 By default png_error() and png_warning() print a message on stderr via
4018 fprintf() unless the library is compiled with PNG_NO_CONSOLE_IO defined
4019 (because you don't want the messages) or PNG_NO_STDIO defined (because
4020 fprintf() isn't available).  If you wish to change the behavior of the error
4021 functions, you will need to set up your own message callbacks.  These
4022 functions are normally supplied at the time that the png_struct is created.
4023 It is also possible to redirect errors and warnings to your own replacement
4024 functions after png_create_*_struct() has been called by calling:
4026     png_set_error_fn(png_structp png_ptr,
4027         png_voidp error_ptr, png_error_ptr error_fn,
4028         png_error_ptr warning_fn);
4030     png_voidp error_ptr = png_get_error_ptr(png_ptr);
4032 If NULL is supplied for either error_fn or warning_fn, then the libpng
4033 default function will be used, calling fprintf() and/or longjmp() if a
4034 problem is encountered.  The replacement error functions should have
4035 parameters as follows:
4037     void user_error_fn(png_structp png_ptr,
4038         png_const_charp error_msg);
4040     void user_warning_fn(png_structp png_ptr,
4041         png_const_charp warning_msg);
4043 The motivation behind using setjmp() and longjmp() is the C++ throw and
4044 catch exception handling methods.  This makes the code much easier to write,
4045 as there is no need to check every return code of every function call.
4046 However, there are some uncertainties about the status of local variables
4047 after a longjmp, so the user may want to be careful about doing anything
4048 after setjmp returns non-zero besides returning itself.  Consult your
4049 compiler documentation for more details.  For an alternative approach, you
4050 may wish to use the "cexcept" facility (see http://cexcept.sourceforge.net).
4052 .SS Custom chunks
4054 If you need to read or write custom chunks, you may need to get deeper
4055 into the libpng code.  The library now has mechanisms for storing
4056 and writing chunks of unknown type; you can even declare callbacks
4057 for custom chunks.  However, this may not be good enough if the
4058 library code itself needs to know about interactions between your
4059 chunk and existing `intrinsic' chunks.
4061 If you need to write a new intrinsic chunk, first read the PNG
4062 specification. Acquire a first level of understanding of how it works.
4063 Pay particular attention to the sections that describe chunk names,
4064 and look at how other chunks were designed, so you can do things
4065 similarly.  Second, check out the sections of libpng that read and
4066 write chunks.  Try to find a chunk that is similar to yours and use
4067 it as a template.  More details can be found in the comments inside
4068 the code.  It is best to handle unknown chunks in a generic method,
4069 via callback functions, instead of by modifying libpng functions.
4071 If you wish to write your own transformation for the data, look through
4072 the part of the code that does the transformations, and check out some of
4073 the simpler ones to get an idea of how they work.  Try to find a similar
4074 transformation to the one you want to add and copy off of it.  More details
4075 can be found in the comments inside the code itself.
4077 .SS Configuring for 16 bit platforms
4079 You will want to look into zconf.h to tell zlib (and thus libpng) that
4080 it cannot allocate more then 64K at a time.  Even if you can, the memory
4081 won't be accessible.  So limit zlib and libpng to 64K by defining MAXSEG_64K.
4083 .SS Configuring for DOS
4085 For DOS users who only have access to the lower 640K, you will
4086 have to limit zlib's memory usage via a png_set_compression_mem_level()
4087 call.  See zlib.h or zconf.h in the zlib library for more information.
4089 .SS Configuring for Medium Model
4091 Libpng's support for medium model has been tested on most of the popular
4092 compilers.  Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
4093 defined, and FAR gets defined to far in pngconf.h, and you should be
4094 all set.  Everything in the library (except for zlib's structure) is
4095 expecting far data.  You must use the typedefs with the p or pp on
4096 the end for pointers (or at least look at them and be careful).  Make
4097 note that the rows of data are defined as png_bytepp, which is an
4098 unsigned char far * far *.
4100 .SS Configuring for gui/windowing platforms:
4102 You will need to write new error and warning functions that use the GUI
4103 interface, as described previously, and set them to be the error and
4104 warning functions at the time that png_create_*_struct() is called,
4105 in order to have them available during the structure initialization.
4106 They can be changed later via png_set_error_fn().  On some compilers,
4107 you may also have to change the memory allocators (png_malloc, etc.).
4109 .SS Configuring for compiler xxx:
4111 All includes for libpng are in pngconf.h.  If you need to add, change
4112 or delete an include, this is the place to do it.
4113 The includes that are not needed outside libpng are placed in pngpriv.h,
4114 which is only used by the routines inside libpng itself.
4115 The files in libpng proper only include pngpriv.h and png.h, which
4116 in turn includes pngconf.h.
4118 .SS Configuring zlib:
4120 There are special functions to configure the compression.  Perhaps the
4121 most useful one changes the compression level, which currently uses
4122 input compression values in the range 0 - 9.  The library normally
4123 uses the default compression level (Z_DEFAULT_COMPRESSION = 6).  Tests
4124 have shown that for a large majority of images, compression values in
4125 the range 3-6 compress nearly as well as higher levels, and do so much
4126 faster.  For online applications it may be desirable to have maximum speed
4127 (Z_BEST_SPEED = 1).  With versions of zlib after v0.99, you can also
4128 specify no compression (Z_NO_COMPRESSION = 0), but this would create
4129 files larger than just storing the raw bitmap.  You can specify the
4130 compression level by calling:
4132     png_set_compression_level(png_ptr, level);
4134 Another useful one is to reduce the memory level used by the library.
4135 The memory level defaults to 8, but it can be lowered if you are
4136 short on memory (running DOS, for example, where you only have 640K).
4137 Note that the memory level does have an effect on compression; among
4138 other things, lower levels will result in sections of incompressible
4139 data being emitted in smaller stored blocks, with a correspondingly
4140 larger relative overhead of up to 15% in the worst case.
4142     png_set_compression_mem_level(png_ptr, level);
4144 The other functions are for configuring zlib.  They are not recommended
4145 for normal use and may result in writing an invalid PNG file.  See
4146 zlib.h for more information on what these mean.
4148     png_set_compression_strategy(png_ptr,
4149         strategy);
4151     png_set_compression_window_bits(png_ptr,
4152         window_bits);
4154     png_set_compression_method(png_ptr, method);
4155     png_set_compression_buffer_size(png_ptr, size);
4157 .SS Controlling row filtering
4159 If you want to control whether libpng uses filtering or not, which
4160 filters are used, and how it goes about picking row filters, you
4161 can call one of these functions.  The selection and configuration
4162 of row filters can have a significant impact on the size and
4163 encoding speed and a somewhat lesser impact on the decoding speed
4164 of an image.  Filtering is enabled by default for RGB and grayscale
4165 images (with and without alpha), but not for paletted images nor
4166 for any images with bit depths less than 8 bits/pixel.
4168 The 'method' parameter sets the main filtering method, which is
4169 currently only '0' in the PNG 1.2 specification.  The 'filters'
4170 parameter sets which filter(s), if any, should be used for each
4171 scanline.  Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS
4172 to turn filtering on and off, respectively.
4174 Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB,
4175 PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise
4176 ORed together with '|' to specify one or more filters to use.
4177 These filters are described in more detail in the PNG specification.
4178 If you intend to change the filter type during the course of writing
4179 the image, you should start with flags set for all of the filters
4180 you intend to use so that libpng can initialize its internal
4181 structures appropriately for all of the filter types.  (Note that this
4182 means the first row must always be adaptively filtered, because libpng
4183 currently does not allocate the filter buffers until png_write_row()
4184 is called for the first time.)
4186     filters = PNG_FILTER_NONE | PNG_FILTER_SUB
4187               PNG_FILTER_UP | PNG_FILTER_AVG |
4188               PNG_FILTER_PAETH | PNG_ALL_FILTERS;
4190     png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE,
4191        filters);
4192               The second parameter can also be
4193               PNG_INTRAPIXEL_DIFFERENCING if you are
4194               writing a PNG to be embedded in a MNG
4195               datastream.  This parameter must be the
4196               same as the value of filter_method used
4197               in png_set_IHDR().
4199 It is also possible to influence how libpng chooses from among the
4200 available filters.  This is done in one or both of two ways - by
4201 telling it how important it is to keep the same filter for successive
4202 rows, and by telling it the relative computational costs of the filters.
4204     double weights[3] = {1.5, 1.3, 1.1},
4205        costs[PNG_FILTER_VALUE_LAST] =
4206        {1.0, 1.3, 1.3, 1.5, 1.7};
4208     png_set_filter_heuristics(png_ptr,
4209        PNG_FILTER_HEURISTIC_WEIGHTED, 3,
4210        weights, costs);
4212 The weights are multiplying factors that indicate to libpng that the
4213 row filter should be the same for successive rows unless another row filter
4214 is that many times better than the previous filter.  In the above example,
4215 if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a
4216 "sum of absolute differences" 1.5 x 1.3 times higher than other filters
4217 and still be chosen, while the NONE filter could have a sum 1.1 times
4218 higher than other filters and still be chosen.  Unspecified weights are
4219 taken to be 1.0, and the specified weights should probably be declining
4220 like those above in order to emphasize recent filters over older filters.
4222 The filter costs specify for each filter type a relative decoding cost
4223 to be considered when selecting row filters.  This means that filters
4224 with higher costs are less likely to be chosen over filters with lower
4225 costs, unless their "sum of absolute differences" is that much smaller.
4226 The costs do not necessarily reflect the exact computational speeds of
4227 the various filters, since this would unduly influence the final image
4228 size.
4230 Note that the numbers above were invented purely for this example and
4231 are given only to help explain the function usage.  Little testing has
4232 been done to find optimum values for either the costs or the weights.
4234 .SS Removing unwanted object code
4236 There are a bunch of #define's in pngconf.h that control what parts of
4237 libpng are compiled.  All the defines end in _SUPPORTED.  If you are
4238 never going to use a capability, you can change the #define to #undef
4239 before recompiling libpng and save yourself code and data space, or
4240 you can turn off individual capabilities with defines that begin with
4241 PNG_NO_.
4243 In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead.
4245 You can also turn all of the transforms and ancillary chunk capabilities
4246 off en masse with compiler directives that define
4247 PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
4248 or all four,
4249 along with directives to turn on any of the capabilities that you do
4250 want.  The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the extra
4251 transformations but still leave the library fully capable of reading
4252 and writing PNG files with all known public chunks. Use of the
4253 PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library
4254 that is incapable of reading or writing ancillary chunks.  If you are
4255 not using the progressive reading capability, you can turn that off
4256 with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING
4257 capability, which you'll still have).
4259 All the reading and writing specific code are in separate files, so the
4260 linker should only grab the files it needs.  However, if you want to
4261 make sure, or if you are building a stand alone library, all the
4262 reading files start with pngr and all the writing files start with
4263 pngw.  The files that don't match either (like png.c, pngtrans.c, etc.)
4264 are used for both reading and writing, and always need to be included.
4265 The progressive reader is in pngpread.c
4267 If you are creating or distributing a dynamically linked library (a .so
4268 or DLL file), you should not remove or disable any parts of the library,
4269 as this will cause applications linked with different versions of the
4270 library to fail if they call functions not available in your library.
4271 The size of the library itself should not be an issue, because only
4272 those sections that are actually used will be loaded into memory.
4274 .SS Requesting debug printout
4276 The macro definition PNG_DEBUG can be used to request debugging
4277 printout.  Set it to an integer value in the range 0 to 3.  Higher
4278 numbers result in increasing amounts of debugging information.  The
4279 information is printed to the "stderr" file, unless another file
4280 name is specified in the PNG_DEBUG_FILE macro definition.
4282 When PNG_DEBUG > 0, the following functions (macros) become available:
4284    png_debug(level, message)
4285    png_debug1(level, message, p1)
4286    png_debug2(level, message, p1, p2)
4288 in which "level" is compared to PNG_DEBUG to decide whether to print
4289 the message, "message" is the formatted string to be printed,
4290 and p1 and p2 are parameters that are to be embedded in the string
4291 according to printf-style formatting directives.  For example,
4293    png_debug1(2, "foo=%d\n", foo);
4295 is expanded to
4297    if (PNG_DEBUG > 2)
4298       fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo);
4300 When PNG_DEBUG is defined but is zero, the macros aren't defined, but you
4301 can still use PNG_DEBUG to control your own debugging:
4303    #ifdef PNG_DEBUG
4304        fprintf(stderr, ...
4305    #endif
4307 When PNG_DEBUG = 1, the macros are defined, but only png_debug statements
4308 having level = 0 will be printed.  There aren't any such statements in
4309 this version of libpng, but if you insert some they will be printed.
4311 .SH VI.  MNG support
4313 The MNG specification (available at http://www.libpng.org/pub/mng) allows
4314 certain extensions to PNG for PNG images that are embedded in MNG datastreams.
4315 Libpng can support some of these extensions.  To enable them, use the
4316 png_permit_mng_features() function:
4318    feature_set = png_permit_mng_features(png_ptr, mask)
4320    mask is a png_uint_32 containing the bitwise OR of the
4321         features you want to enable.  These include
4322         PNG_FLAG_MNG_EMPTY_PLTE
4323         PNG_FLAG_MNG_FILTER_64
4324         PNG_ALL_MNG_FEATURES
4326    feature_set is a png_uint_32 that is the bitwise AND of
4327       your mask with the set of MNG features that is
4328       supported by the version of libpng that you are using.
4330 It is an error to use this function when reading or writing a standalone
4331 PNG file with the PNG 8-byte signature.  The PNG datastream must be wrapped
4332 in a MNG datastream.  As a minimum, it must have the MNG 8-byte signature
4333 and the MHDR and MEND chunks.  Libpng does not provide support for these
4334 or any other MNG chunks; your application must provide its own support for
4335 them.  You may wish to consider using libmng (available at
4336 http://www.libmng.com) instead.
4338 .SH VII.  Changes to Libpng from version 0.88
4340 It should be noted that versions of libpng later than 0.96 are not
4341 distributed by the original libpng author, Guy Schalnat, nor by
4342 Andreas Dilger, who had taken over from Guy during 1996 and 1997, and
4343 distributed versions 0.89 through 0.96, but rather by another member
4344 of the original PNG Group, Glenn Randers-Pehrson.  Guy and Andreas are
4345 still alive and well, but they have moved on to other things.
4347 The old libpng functions png_read_init(), png_write_init(),
4348 png_info_init(), png_read_destroy(), and png_write_destroy() have been
4349 moved to PNG_INTERNAL in version 0.95 to discourage their use.  These
4350 functions will be removed from libpng version 1.4.0.
4352 The preferred method of creating and initializing the libpng structures is
4353 via the png_create_read_struct(), png_create_write_struct(), and
4354 png_create_info_struct() because they isolate the size of the structures
4355 from the application, allow version error checking, and also allow the
4356 use of custom error handling routines during the initialization, which
4357 the old functions do not.  The functions png_read_destroy() and
4358 png_write_destroy() do not actually free the memory that libpng
4359 allocated for these structs, but just reset the data structures, so they
4360 can be used instead of png_destroy_read_struct() and
4361 png_destroy_write_struct() if you feel there is too much system overhead
4362 allocating and freeing the png_struct for each image read.
4364 Setting the error callbacks via png_set_message_fn() before
4365 png_read_init() as was suggested in libpng-0.88 is no longer supported
4366 because this caused applications that do not use custom error functions
4367 to fail if the png_ptr was not initialized to zero.  It is still possible
4368 to set the error callbacks AFTER png_read_init(), or to change them with
4369 png_set_error_fn(), which is essentially the same function, but with a new
4370 name to force compilation errors with applications that try to use the old
4371 method.
4373 Starting with version 1.0.7, you can find out which version of the library
4374 you are using at run-time:
4376    png_uint_32 libpng_vn = png_access_version_number();
4378 The number libpng_vn is constructed from the major version, minor
4379 version with leading zero, and release number with leading zero,
4380 (e.g., libpng_vn for version 1.0.7 is 10007).
4382 You can also check which version of png.h you used when compiling your
4383 application:
4385    png_uint_32 application_vn = PNG_LIBPNG_VER;
4387 .SH VIII.  Changes to Libpng from version 1.0.x to 1.2.x
4389 Support for user memory management was enabled by default.  To
4390 accomplish this, the functions png_create_read_struct_2(),
4391 png_create_write_struct_2(), png_set_mem_fn(), png_get_mem_ptr(),
4392 png_malloc_default(), and png_free_default() were added.
4394 Support for the iTXt chunk has been enabled by default as of
4395 version 1.2.41.
4397 Support for certain MNG features was enabled.
4399 Support for numbered error messages was added.  However, we never got
4400 around to actually numbering the error messages.  The function
4401 png_set_strip_error_numbers() was added (Note: the prototype for this
4402 function was inadvertently removed from png.h in PNG_NO_ASSEMBLER_CODE
4403 builds of libpng-1.2.15.  It was restored in libpng-1.2.36).
4405 The png_malloc_warn() function was added at libpng-1.2.3.  This issues
4406 a png_warning and returns NULL instead of aborting when it fails to
4407 acquire the requested memory allocation.
4409 Support for setting user limits on image width and height was enabled
4410 by default.  The functions png_set_user_limits(), png_get_user_width_max(),
4411 and png_get_user_height_max() were added at libpng-1.2.6.
4413 The png_set_add_alpha() function was added at libpng-1.2.7.
4415 The function png_set_expand_gray_1_2_4_to_8() was added at libpng-1.2.9.
4416 Unlike png_set_gray_1_2_4_to_8(), the new function does not expand the
4417 tRNS chunk to alpha. The png_set_gray_1_2_4_to_8() function is
4418 deprecated.
4420 A number of macro definitions in support of runtime selection of
4421 assembler code features (especially Intel MMX code support) were
4422 added at libpng-1.2.0:
4424     PNG_ASM_FLAG_MMX_SUPPORT_COMPILED
4425     PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU
4426     PNG_ASM_FLAG_MMX_READ_COMBINE_ROW
4427     PNG_ASM_FLAG_MMX_READ_INTERLACE
4428     PNG_ASM_FLAG_MMX_READ_FILTER_SUB
4429     PNG_ASM_FLAG_MMX_READ_FILTER_UP
4430     PNG_ASM_FLAG_MMX_READ_FILTER_AVG
4431     PNG_ASM_FLAG_MMX_READ_FILTER_PAETH
4432     PNG_ASM_FLAGS_INITIALIZED
4433     PNG_MMX_READ_FLAGS
4434     PNG_MMX_FLAGS
4435     PNG_MMX_WRITE_FLAGS
4436     PNG_MMX_FLAGS
4438 We added the following functions in support of runtime
4439 selection of assembler code features:
4441     png_get_mmx_flagmask()
4442     png_set_mmx_thresholds()
4443     png_get_asm_flags()
4444     png_get_mmx_bitdepth_threshold()
4445     png_get_mmx_rowbytes_threshold()
4446     png_set_asm_flags()
4448 We replaced all of these functions with simple stubs in libpng-1.2.20,
4449 when the Intel assembler code was removed due to a licensing issue.
4451 These macros are deprecated:
4453     PNG_READ_TRANSFORMS_NOT_SUPPORTED
4454     PNG_PROGRESSIVE_READ_NOT_SUPPORTED
4455     PNG_NO_SEQUENTIAL_READ_SUPPORTED
4456     PNG_WRITE_TRANSFORMS_NOT_SUPPORTED
4457     PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED
4458     PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED
4460 They have been replaced, respectively, by:
4462     PNG_NO_READ_TRANSFORMS
4463     PNG_NO_PROGRESSIVE_READ
4464     PNG_NO_SEQUENTIAL_READ
4465     PNG_NO_WRITE_TRANSFORMS
4466     PNG_NO_READ_ANCILLARY_CHUNKS
4467     PNG_NO_WRITE_ANCILLARY_CHUNKS
4469 PNG_MAX_UINT was replaced with PNG_UINT_31_MAX.  It has been
4470 deprecated since libpng-1.0.16 and libpng-1.2.6.
4472 The function
4473     png_check_sig(sig, num)
4474 was replaced with
4475     !png_sig_cmp(sig, 0, num)
4476 It has been deprecated since libpng-0.90.
4478 The function
4479     png_set_gray_1_2_4_to_8()
4480 which also expands tRNS to alpha was replaced with
4481     png_set_expand_gray_1_2_4_to_8()
4482 which does not. It has been deprecated since libpng-1.0.18 and 1.2.9.
4484 .SH IX.  Changes to Libpng from version 1.0.x/1.2.x to 1.4.x
4486 Private libpng prototypes and macro definitions were moved from
4487 png.h and pngconf.h into a new pngpriv.h header file.
4489 Functions png_set_benign_errors(), png_benign_error(), and
4490 png_chunk_benign_error() were added.
4492 Support for setting the maximum amount of memory that the application
4493 will allocate for reading chunks was added, as a security measure.
4494 The functions png_set_chunk_cache_max() and png_get_chunk_cache_max()
4495 were added to the library.
4497 We implemented support for I/O states by adding png_ptr member io_state
4498 and functions png_get_io_chunk_name() and png_get_io_state() in pngget.c
4500 We added PNG_TRANSFORM_GRAY_TO_RGB to the available high-level
4501 input transforms.
4503 Checking for and reporting of errors in the IHDR chunk is more thorough.
4505 Support for global arrays was removed, to improve thread safety.
4507 Some obsolete/deprecated macros and functions have been removed.
4509 Typecasted NULL definitions such as
4510    #define png_voidp_NULL            (png_voidp)NULL
4511 were eliminated.  If you used these in your application, just use
4512 NULL instead.
4514 The png_struct and info_struct members "trans" and "trans_values" were
4515 changed to "trans_alpha" and "trans_color", respectively.
4517 The obsolete, unused pnggccrd.c and pngvcrd.c files and related makefiles
4518 were removed.
4520 The PNG_1_0_X and PNG_1_2_X macros were eliminated.
4522 The PNG_LEGACY_SUPPORTED macro was eliminated.
4524 Many WIN32_WCE #ifdefs were removed.
4526 The functions png_read_init(info_ptr), png_write_init(info_ptr),
4527 png_info_init(info_ptr), png_read_destroy(), and png_write_destroy()
4528 have been removed.  They have been deprecated since libpng-0.95.
4530 The png_permit_empty_plte() was removed. It has been deprecated
4531 since libpng-1.0.9.  Use png_permit_mng_features() instead.
4533 We removed the obsolete stub functions png_get_mmx_flagmask(),
4534 png_set_mmx_thresholds(), png_get_asm_flags(),
4535 png_get_mmx_bitdepth_threshold(), png_get_mmx_rowbytes_threshold(),
4536 png_set_asm_flags(), and png_mmx_supported()
4538 We removed the obsolete png_check_sig(), png_memcpy_check(), and
4539 png_memset_check() functions.  Instead use !png_sig_cmp(), memcpy(),
4540 and memset(), respectively.
4542 The function png_set_gray_1_2_4_to_8() was removed. It has been
4543 deprecated since libpng-1.0.18 and 1.2.9, when it was replaced with
4544 png_set_expand_gray_1_2_4_to_8() because the former function also
4545 expanded palette images.
4547 Macros for png_get_uint_16, png_get_uint_32, and png_get_int_32
4548 were added and are used by default instead of the corresponding
4549 functions. Unfortunately,
4550 from libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the  
4551 function) incorrectly returned a value of type png_uint_32.
4553 We changed the prototype for png_malloc() from
4554     png_malloc(png_structp png_ptr, png_uint_32 size)
4556     png_malloc(png_structp png_ptr, png_alloc_size_t size)
4558 This also applies to the prototype for the user replacement malloc_fn().
4560 The png_calloc() function was added and is used in place of
4561 of "png_malloc(); memset();" except in the case in png_read_png()
4562 where the array consists of pointers; in this case a "for" loop is used
4563 after the png_malloc() to set the pointers to NULL, to give robust.
4564 behavior in case the application runs out of memory part-way through
4565 the process.
4567 We changed the prototypes of png_get_compression_buffer_size() and
4568 png_set_compression_buffer_size() to work with png_size_t instead of
4569 png_uint_32.
4571 Support for numbered error messages was removed by default, since we
4572 never got around to actually numbering the error messages. The function
4573 png_set_strip_error_numbers() was removed from the library by default.
4575 The png_zalloc() and png_zfree() functions are no longer exported.
4576 The png_zalloc() function no longer zeroes out the memory that it
4577 allocates.
4579 Support for dithering was disabled by default in libpng-1.4.0, because
4580 been well tested and doesn't actually "dither".  The code was not
4581 removed, however, and could be enabled by building libpng with
4582 PNG_READ_DITHER_SUPPORTED defined.  In libpng-1.4.2, this support
4583 was reenabled, but the function was renamed png_set_quantize() to
4584 reflect more accurately what it actually does.  At the same time,
4585 the PNG_DITHER_[RED,GREEN_BLUE]_BITS macros were also renamed to
4586 PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS, and PNG_READ_DITHER_SUPPORTED
4587 was renamed to PNG_READ_QUANTIZE_SUPPORTED.
4589 We removed the trailing '.' from the warning and error messages.
4591 .SH X.  Changes to Libpng from version 1.4.x to 1.5.x
4593 From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the  
4594 function) incorrectly returned a value of type png_uint_32.
4596 A. Changes that affect users of libpng
4598 There are no substantial API changes between the non-deprecated parts of
4599 the 1.4.5 API and the 1.5.0 API, however the ability to directly access
4600 the main libpng control structures, png_struct and png_info, deprecated
4601 in earlier versions of libpng, has been completely removed from
4602 libpng 1.5.
4604 We no longer include zlib.h in png.h.  Applications that need access
4605 to information in zlib.h will need to add the '#include "zlib.h"'
4606 directive.  It does not matter whether it is placed prior to or after
4607 the '"#include png.h"' directive.
4609 We moved the png_strcpy(), png_strncpy(), png_strlen(), png_memcpy(),
4610 png_memcmp(), png_sprintf, and png_memcpy() macros into a private
4611 header file (pngpriv.h) that is not accessible to applications.
4613 In png_get_iCCP, the type of "profile" was changed from png_charpp
4614 to png_bytepp, and in png_set_iCCP, from png_charp to png_const_bytep.
4616 There are changes of form in png.h, including new and changed macros to
4617 declare
4618 parts of the API.  Some API functions with arguments that are pointers to
4619 data not modified within the function have been corrected to declare
4620 these arguments with PNG_CONST.
4622 Much of the internal use of C macros to control the library build has also
4623 changed and some of this is visible in the exported header files, in
4624 particular the use of macros to control data and API elements visible
4625 during application compilation may require significant revision to
4626 application code.  (It is extremely rare for an application to do this.)
4628 Any program that compiled against libpng 1.4 and did not use deprecated
4629 features or access internal library structures should compile and work
4630 against libpng 1.5.
4632 libpng 1.5.0 adds PNG_ PASS macros to help in the reading and writing of
4633 interlaced images.  The macros return the number of rows and columns in
4634 each pass and information that can be used to de-interlace and (if
4635 absolutely necessary) interlace an image.
4637 libpng 1.5.0 adds an API png_longjmp(png_ptr, value).  This API calls
4638 the application provided png_longjmp_ptr on the internal, but application
4639 initialized, jmpbuf.  It is provided as a convenience to avoid the need
4640 to use the png_jmpbuf macro, which had the unnecessary side effect of
4641 resetting the internal png_longjmp_ptr value.
4643 libpng 1.5.0 includes a complete fixed point API.  By default this is
4644 present along with the corresponding floating point API.  In general the
4645 fixed point API is faster and smaller than the floating point one because
4646 the PNG file format used fixed point, not floating point.  This applies
4647 even if the library uses floating point in internal calculations.  A new
4648 macro, PNG_FLOATING_ARITHMETIC_SUPPORTED, reveals whether the library
4649 uses floating point arithmetic (the default) or fixed point arithmetic
4650 internally for performance critical calculations such as gamma correction.
4651 In some cases, the gamma calculations may produce slightly different
4652 results.  This has changed the results in png_rgb_to_gray and in alpha
4653 composition (png_set_background for example). This applies even if the
4654 original image was already linear (gamma == 1.0) and, therefore, it is
4655 not necessary to linearize the image.  This is because libpng has *not*
4656 been changed to optimize that case correctly, yet.
4658 Fixed point support for the sCAL chunk comes with an important caveat;
4659 the sCAL specification uses a decimal encoding of floating point values
4660 and the accuracy of PNG fixed point values is insufficient for
4661 representation of these values. Consequently a "string" API
4662 (png_get_sCAL_s and png_set_sCAL_s) is the only reliable way of reading
4663 arbitrary sCAL chunks in the absence of either the floating point API or
4664 internal floating point calculations.
4666 Applications no longer need to include the optional distribution header
4667 file pngusr.h or define the corresponding macros during application
4668 build in order to see the correct variant of the libpng API.  From 1.5.0
4669 application code can check for the corresponding _SUPPORTED macro:
4671 #ifdef PNG_INCH_CONVERSIONS_SUPPORTED
4672    /* code that uses the inch conversion APIs. */
4673 #endif
4675 This macro will only be defined if the inch conversion functions have been
4676 compiled into libpng.  The full set of macros, and whether or not support
4677 has been compiled in, are available in the header file pnglibconf.h.
4678 This header file is specific to the libpng build.  Notice that prior to
4679 1.5.0 the _SUPPORTED macros would always have the default definition unless
4680 reset by pngusr.h or by explicit settings on the compiler command line.
4681 These settings may produce compiler warnings or errors in 1.5.0 because
4682 of macro redefinition.
4684 From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the  
4685 function) incorrectly returned a value of type png_uint_32.  libpng 1.5.0
4686 is consistent with the implementation in 1.4.5 and 1.2.x (where the macro
4687 did not exist.)
4689 Applications can now choose whether to use these macros or to call the
4690 corresponding function by defining PNG_USE_READ_MACROS or
4691 PNG_NO_USE_READ_MACROS before including png.h.  Notice that this is
4692 only supported from 1.5.0 -defining PNG_NO_USE_READ_MACROS prior to 1.5.0
4693  will lead to a link failure.
4695 B. Changes to the build and configuration of libpng
4697 Details of internal changes to the library code can be found in the CHANGES
4698 file.  These will be of no concern to the vast majority of library users or
4699 builders, however the few who configure libpng to a non-default feature
4700 set may need to change how this is done.
4702 There should be no need for library builders to alter build scripts if
4703 these use the distributed build support - configure or the makefiles -
4704 however users of the makefiles may care to update their build scripts
4705 to build pnglibconf.h where the corresponding makefile does not do so.
4707 Building libpng with a non-default configuration has changed completely.
4708 The old method using pngusr.h should still work correctly even though the
4709 way pngusr.h is used in the build has been changed, however library
4710 builders will probably want to examine the changes to take advantage of
4711 new capabilities and to simplify their build system.
4713 B.1 Specific changes to library configuration capabilities
4715 The library now supports a complete fixed point implementation and can
4716 thus be used on systems which have no floating point support or very
4717 limited or slow support.  Previously gamma correction, an essential part
4718 of complete PNG support, required reasonably fast floating point.
4720 As part of this the choice of internal implementation has been made
4721 independent of the choice of fixed versus floating point APIs and all the
4722 missing fixed point APIs have been implemented.
4724 The exact mechanism used to control attributes of API functions has
4725 changed.  A single set of operating system independent macro definitions
4726 is used and operating system specific directives are defined in
4727 pnglibconf.h
4729 As part of this the mechanism used to choose procedure call standards on
4730 those systems that allow a choice has been changed.  At present this only
4731 affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems
4732 running on Intel processors.  As before PNGAPI is defined where required
4733 to control the exported API functions; however, two new macros, PNGCBAPI
4734 and PNGCAPI, are used instead for callback functions (PNGCBAPI) and
4735 (PNGCAPI) for functions that must match a C library prototype (currently
4736 only png_longjmp_ptr, which must match the C longjmp function.)  The new
4737 approach is documented in pngconf.h
4739 Despite these changes libpng 1.5.0 only supports the native C function
4740 calling standard on those platforms tested so far (__cdecl on Microsoft
4741 Windows).  This is because the support requirements for alternative
4742 calling conventions seem to no longer exist.  Developers who find it
4743 necessary to set PNG_API_RULE to 1 should advise the mailing list
4744 (png-mng-implement) of this and library builders who use Openwatcom and
4745 therefore set PNG_API_RULE to 2 should also contact the mailing list.
4747 A new test program, pngvalid, is provided in addition to pngtest.
4748 pngvalid validates the arithmetic accuracy of the gamma correction
4749 calculations and includes a number of validations of the file format.
4750 A subset of the full range of tests is run when "make check" is done
4751 (in the 'configure' build.)  pngvalid also allows total allocated memory
4752 usage to be evaluated and performs additional memory overwrite validation.
4754 Many changes to individual feature macros have been made. The following
4755 are the changes most likely to be noticed by library builders who
4756 configure libpng:
4758 1) All feature macros now have consistent naming:
4760 #define PNG_NO_feature turns the feature off
4761 #define PNG_feature_SUPPORTED turns the feature on
4763 pnglibconf.h contains one line for each feature macro which is either:
4765 #define PNG_feature_SUPPORTED
4767 if the feature is supported or:
4769 /*#undef PNG_feature_SUPPORTED*/
4771 if it is not.  Library code consistently checks for the 'SUPPORTED' macro.
4772 It does not, and should not, check for the 'NO' macro which will not
4773 normally be defined even if the feature is not supported.
4775 Compatibility with the old names is provided as follows:
4777 PNG_INCH_CONVERSIONS turns on PNG_INCH_CONVERSIONS_SUPPORTED
4779 And the following definitions disable the corresponding feature:
4781 PNG_SETJMP_NOT_SUPPORTED disables SETJMP
4782 PNG_READ_TRANSFORMS_NOT_SUPPORTED disables READ_TRANSFORMS
4783 PNG_NO_READ_COMPOSITED_NODIV disables READ_COMPOSITE_NODIV
4784 PNG_WRITE_TRANSFORMS_NOT_SUPPORTED disables WRITE_TRANSFORMS
4785 PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED disables READ_ANCILLARY_CHUNKS
4786 PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED disables WRITE_ANCILLARY_CHUNKS
4788 Library builders should remove use of the above, inconsistent, names.
4790 2) Warning and error message formatting was previously conditional on
4791 the STDIO feature. The library has been changed to use the
4792 CONSOLE_IO feature instead. This means that if CONSOLE_IO is disabled
4793 the library no longer uses the printf(3) functions, even though the
4794 default read/write implementations use (FILE) style stdio.h functions.
4796 3) Three feature macros now control the fixed/floating point decisions:
4798 PNG_FLOATING_POINT_SUPPORTED enables the floating point APIs
4800 PNG_FIXED_POINT_SUPPORTED enables the fixed point APIs; however, in
4801 practice these are normally required internally anyway (because the PNG
4802 file format is fixed point), therefore in most cases PNG_NO_FIXED_POINT
4803 merely stops the function from being exported.
4805 PNG_FLOATING_ARITHMETIC_SUPPORTED chooses between the internal floating
4806 point implementation or the fixed point one.  Typically the fixed point
4807 implementation is larger and slower than the floating point implementation
4808 on a system that supports floating point, however it may be faster on a
4809 system which lacks floating point hardware and therefore uses a software
4810 emulation.
4812 4) Added PNG_{READ,WRITE}_INT_FUNCTIONS_SUPPORTED.  This allows the
4813 functions to read and write ints to be disabled independently of
4814 PNG_USE_READ_MACROS, which allows libpng to be built with the functions
4815 even though the default is to use the macros - this allows applications
4816 to choose at app buildtime whether or not to use macros (previously
4817 impossible because the functions weren't in the default build.)
4819 B.2 Changes to the configuration mechanism
4821 Prior to libpng-1.5.0 library builders who needed to configure libpng
4822 had either to modify the exported pngconf.h header file to add system
4823 specific configuration or had to write feature selection macros into
4824 pngusr.h and cause this to be included into pngconf.h by defining
4825 PNG_USER_CONFIG. The latter mechanism had the disadvantage that an
4826 application built without PNG_USER_CONFIG defined would see the
4827 unmodified, default, libpng API and thus would probably fail to link.
4829 These mechanisms still work in the configure build and in any makefile
4830 build that builds pnglibconf.h although the feature selection macros
4831 have changed somewhat as described above.  In 1.5.0, however, pngusr.h is
4832 processed only once, when the exported header file pnglibconf.h is built.
4833 pngconf.h no longer includes pngusr.h, therefore it is ignored after the
4834 build of pnglibconf.h and it is never included in an application build.
4836 The rarely used alternative of adding a list of feature macros to the
4837 CFLAGS setting in the build also still works, however the macros will be
4838 copied to pnglibconf.h and this may produce macro redefinition warnings
4839 when the individual C files are compiled.
4841 All configuration now only works if pnglibconf.h is built from
4842 scripts/pnglibconf.dfa.  This requires the program awk.  Brian Kernighan
4843 (the original author of awk) maintains C source code of that awk and this
4844 and all known later implementations (often called by subtly different
4845 names - nawk and gawk for example) are adequate to build pnglibconf.h.
4846 The Sun Microsystems (now Oracle) program 'awk' is an earlier version
4847 and does not work, this may also apply to other systems that have a
4848 functioning awk called 'nawk'.
4850 Configuration options are now documented in scripts/pnglibconf.dfa.  This
4851 file also includes dependency information that ensures a configuration is
4852 consistent; that is, if a feature is switched off dependent features are
4853 also removed.  As a recommended alternative to using feature macros in
4854 pngusr.h a system builder may also define equivalent options in pngusr.dfa
4855 (or, indeed, any file) and add that to the configuration by setting
4856 DFA_XTRA to the file name.  The makefiles in contrib/pngminim illustrate
4857 how to do this, and a case where pngusr.h is still required.
4859 .SH XI. Detecting libpng
4861 The png_get_io_ptr() function has been present since libpng-0.88, has never
4862 changed, and is unaffected by conditional compilation macros.  It is the
4863 best choice for use in configure scripts for detecting the presence of any
4864 libpng version since 0.88.  In an autoconf "configure.in" you could use
4866     AC_CHECK_LIB(png, png_get_io_ptr, ...
4868 .SH XII. Source code repository
4870 Since about February 2009, version 1.2.34, libpng has been under "git" source
4871 control.  The git repository was built from old libpng-x.y.z.tar.gz files
4872 going back to version 0.70.  You can access the git repository (read only)
4875     git://libpng.git.sourceforge.net/gitroot/libpng
4877 or you can browse it via "gitweb" at
4879     http://libpng.git.sourceforge.net/git/gitweb.cgi?p=libpng
4881 Patches can be sent to glennrp at users.sourceforge.net or to
4882 png-mng-implement at lists.sourceforge.net or you can upload them to
4883 the libpng bug tracker at
4885     http://libpng.sourceforge.net
4887 We also accept patches built from the tar or zip distributions, and
4888 simple verbal discriptions of bug fixes, reported either to the
4889 SourceForge bug tracker or to the png-mng-implement at lists.sf.net
4890 mailing list.
4892 .SH XIII. Coding style
4894 Our coding style is similar to the "Allman" style, with curly
4895 braces on separate lines:
4897     if (condition)
4898     {
4899        action;
4900     }
4902     else if (another condition)
4903     {
4904        another action;
4905     }
4907 The braces can be omitted from simple one-line actions:
4909     if (condition)
4910        return (0);
4912 We use 3-space indentation, except for continued statements which
4913 are usually indented the same as the first line of the statement
4914 plus four more spaces.
4916 For macro definitions we use 2-space indentation, always leaving the "#"
4917 in the first column.
4919     #ifndef PNG_NO_FEATURE
4920     #  ifndef PNG_FEATURE_SUPPORTED
4921     #    define PNG_FEATURE_SUPPORTED
4922     #  endif
4923     #endif
4925 Comments appear with the leading "/*" at the same indentation as
4926 the statement that follows the comment:
4928     /* Single-line comment */
4929     statement;
4931     /* This is a multiple-line
4932      * comment.
4933      */
4934     statement;
4936 Very short comments can be placed after the end of the statement
4937 to which they pertain:
4939     statement;    /* comment */
4941 We don't use C++ style ("//") comments. We have, however,
4942 used them in the past in some now-abandoned MMX assembler
4943 code.
4945 Functions and their curly braces are not indented, and
4946 exported functions are marked with PNGAPI:
4948  /* This is a public function that is visible to
4949   * application programmers. It does thus-and-so.
4950   */
4951  void PNGAPI
4952  png_exported_function(png_ptr, png_info, foo)
4954     body;
4957 The prototypes for all exported functions appear in png.h,
4958 above the comment that says
4960     /* Maintainer: Put new public prototypes here ... */
4962 We mark all non-exported functions with "/* PRIVATE */"":
4964  void /* PRIVATE */
4965  png_non_exported_function(png_ptr, png_info, foo)
4967     body;
4970 The prototypes for non-exported functions (except for those in
4971 pngtest) appear in
4972 pngpriv.h
4973 above the comment that says
4975   /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
4977 To avoid polluting the global namespace, the names of all exported
4978 functions and variables begin with  "png_", and all publicly visible C
4979 preprocessor macros begin with "PNG_".  We request that applications that
4980 use libpng *not* begin any of their own symbols with either of these strings.
4982 We put a space after each comma and after each semicolon
4983 in "for" statements, and we put spaces before and after each
4984 C binary operator and after "for" or "while", and before
4985 "?".  We don't put a space between a typecast and the expression
4986 being cast, nor do we put one between a function name and the
4987 left parenthesis that follows it:
4989     for (i = 2; i > 0; --i)
4990        y[i] = a(x) + (int)b;
4992 We prefer #ifdef and #ifndef to #if defined() and if !defined()
4993 when there is only one macro being tested.
4995 We do not use the TAB character for indentation in the C sources.
4997 Lines do not exceed 80 characters.
4999 Other rules can be inferred by inspecting the libpng source.
5001 .SH XIV. Y2K Compliance in libpng
5003 February 3, 2011
5005 Since the PNG Development group is an ad-hoc body, we can't make
5006 an official declaration.
5008 This is your unofficial assurance that libpng from version 0.71 and
5009 upward through 1.5.1 are Y2K compliant.  It is my belief that earlier
5010 versions were also Y2K compliant.
5012 Libpng only has three year fields.  One is a 2-byte unsigned integer that
5013 will hold years up to 65535.  The other two hold the date in text
5014 format, and will hold years up to 9999.
5016 The integer is
5017     "png_uint_16 year" in png_time_struct.
5019 The strings are
5020     "png_charp time_buffer" in png_struct and
5021     "near_time_buffer", which is a local character string in png.c.
5023 There are seven time-related functions:
5025     png_convert_to_rfc_1123() in png.c
5026       (formerly png_convert_to_rfc_1152() in error)
5027     png_convert_from_struct_tm() in pngwrite.c, called
5028       in pngwrite.c
5029     png_convert_from_time_t() in pngwrite.c
5030     png_get_tIME() in pngget.c
5031     png_handle_tIME() in pngrutil.c, called in pngread.c
5032     png_set_tIME() in pngset.c
5033     png_write_tIME() in pngwutil.c, called in pngwrite.c
5035 All appear to handle dates properly in a Y2K environment.  The
5036 png_convert_from_time_t() function calls gmtime() to convert from system
5037 clock time, which returns (year - 1900), which we properly convert to
5038 the full 4-digit year.  There is a possibility that applications using
5039 libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
5040 function, or that they are incorrectly passing only a 2-digit year
5041 instead of "year - 1900" into the png_convert_from_struct_tm() function,
5042 but this is not under our control.  The libpng documentation has always
5043 stated that it works with 4-digit years, and the APIs have been
5044 documented as such.
5046 The tIME chunk itself is also Y2K compliant.  It uses a 2-byte unsigned
5047 integer to hold the year, and can hold years as large as 65535.
5049 zlib, upon which libpng depends, is also Y2K compliant.  It contains
5050 no date-related code.
5053    Glenn Randers-Pehrson
5054    libpng maintainer
5055    PNG Development Group
5057 .SH NOTE
5059 Note about libpng version numbers:
5061 Due to various miscommunications, unforeseen code incompatibilities
5062 and occasional factors outside the authors' control, version numbering
5063 on the library has not always been consistent and straightforward.
5064 The following table summarizes matters since version 0.89c, which was
5065 the first widely used release:
5067  source             png.h  png.h  shared-lib
5068  version            string   int  version
5069  -------            ------  ----- ----------
5070  0.89c ("beta 3")  0.89       89  1.0.89
5071  0.90  ("beta 4")  0.90       90  0.90
5072  0.95  ("beta 5")  0.95       95  0.95
5073  0.96  ("beta 6")  0.96       96  0.96
5074  0.97b ("beta 7")  1.00.97    97  1.0.1
5075  0.97c             0.97       97  2.0.97
5076  0.98              0.98       98  2.0.98
5077  0.99              0.99       98  2.0.99
5078  0.99a-m           0.99       99  2.0.99
5079  1.00              1.00      100  2.1.0
5080  1.0.0             1.0.0     100  2.1.0
5081  1.0.0   (from here on, the  100  2.1.0
5082  1.0.1    png.h string is  10001  2.1.0
5083  1.0.1a-e identical to the 10002  from here on, the
5084  1.0.2    source version)  10002  shared library is 2.V
5085  1.0.2a-b                  10003  where V is the source
5086  1.0.1                     10001  code version except as
5087  1.0.1a-e                  10002  2.1.0.1a-e   noted.
5088  1.0.2                     10002  2.1.0.2
5089  1.0.2a-b                  10003  2.1.0.2a-b
5090  1.0.3                     10003  2.1.0.3
5091  1.0.3a-d                  10004  2.1.0.3a-d
5092  1.0.4                     10004  2.1.0.4
5093  1.0.4a-f                  10005  2.1.0.4a-f
5094  1.0.5 (+ 2 patches)       10005  2.1.0.5
5095  1.0.5a-d                  10006  2.1.0.5a-d
5096  1.0.5e-r                  10100  2.1.0.5e-r
5097  1.0.5s-v                  10006  2.1.0.5s-v
5098  1.0.6 (+ 3 patches)       10006  2.1.0.6
5099  1.0.6d-g                  10007  2.1.0.6d-g
5100  1.0.6h                    10007  10.6h
5101  1.0.6i                    10007  10.6i
5102  1.0.6j                    10007  2.1.0.6j
5103  1.0.7beta11-14    DLLNUM  10007  2.1.0.7beta11-14
5104  1.0.7beta15-18       1    10007  2.1.0.7beta15-18
5105  1.0.7rc1-2           1    10007  2.1.0.7rc1-2
5106  1.0.7                1    10007  2.1.0.7
5107  1.0.8beta1-4         1    10008  2.1.0.8beta1-4
5108  1.0.8rc1             1    10008  2.1.0.8rc1
5109  1.0.8                1    10008  2.1.0.8
5110  1.0.9beta1-6         1    10009  2.1.0.9beta1-6
5111  1.0.9rc1             1    10009  2.1.0.9rc1
5112  1.0.9beta7-10        1    10009  2.1.0.9beta7-10
5113  1.0.9rc2             1    10009  2.1.0.9rc2
5114  1.0.9                1    10009  2.1.0.9
5115  1.0.10beta1          1    10010  2.1.0.10beta1
5116  1.0.10rc1            1    10010  2.1.0.10rc1
5117  1.0.10               1    10010  2.1.0.10
5118  1.0.11beta1-3        1    10011  2.1.0.11beta1-3
5119  1.0.11rc1            1    10011  2.1.0.11rc1
5120  1.0.11               1    10011  2.1.0.11
5121  1.0.12beta1-2        2    10012  2.1.0.12beta1-2
5122  1.0.12rc1            2    10012  2.1.0.12rc1
5123  1.0.12               2    10012  2.1.0.12
5124  1.1.0a-f             -    10100  2.1.1.0a-f abandoned
5125  1.2.0beta1-2         2    10200  2.1.2.0beta1-2
5126  1.2.0beta3-5         3    10200  3.1.2.0beta3-5
5127  1.2.0rc1             3    10200  3.1.2.0rc1
5128  1.2.0                3    10200  3.1.2.0
5129  1.2.1beta-4          3    10201  3.1.2.1beta1-4
5130  1.2.1rc1-2           3    10201  3.1.2.1rc1-2
5131  1.2.1                3    10201  3.1.2.1
5132  1.2.2beta1-6        12    10202  12.so.0.1.2.2beta1-6
5133  1.0.13beta1         10    10013  10.so.0.1.0.13beta1
5134  1.0.13rc1           10    10013  10.so.0.1.0.13rc1
5135  1.2.2rc1            12    10202  12.so.0.1.2.2rc1
5136  1.0.13              10    10013  10.so.0.1.0.13
5137  1.2.2               12    10202  12.so.0.1.2.2
5138  1.2.3rc1-6          12    10203  12.so.0.1.2.3rc1-6
5139  1.2.3               12    10203  12.so.0.1.2.3
5140  1.2.4beta1-3        13    10204  12.so.0.1.2.4beta1-3
5141  1.2.4rc1            13    10204  12.so.0.1.2.4rc1
5142  1.0.14              10    10014  10.so.0.1.0.14
5143  1.2.4               13    10204  12.so.0.1.2.4
5144  1.2.5beta1-2        13    10205  12.so.0.1.2.5beta1-2
5145  1.0.15rc1           10    10015  10.so.0.1.0.15rc1
5146  1.0.15              10    10015  10.so.0.1.0.15
5147  1.2.5               13    10205  12.so.0.1.2.5
5148  1.2.6beta1-4        13    10206  12.so.0.1.2.6beta1-4
5149  1.2.6rc1-5          13    10206  12.so.0.1.2.6rc1-5
5150  1.0.16              10    10016  10.so.0.1.0.16
5151  1.2.6               13    10206  12.so.0.1.2.6
5152  1.2.7beta1-2        13    10207  12.so.0.1.2.7beta1-2
5153  1.0.17rc1           10    10017  12.so.0.1.0.17rc1
5154  1.2.7rc1            13    10207  12.so.0.1.2.7rc1
5155  1.0.17              10    10017  12.so.0.1.0.17
5156  1.2.7               13    10207  12.so.0.1.2.7
5157  1.2.8beta1-5        13    10208  12.so.0.1.2.8beta1-5
5158  1.0.18rc1-5         10    10018  12.so.0.1.0.18rc1-5
5159  1.2.8rc1-5          13    10208  12.so.0.1.2.8rc1-5
5160  1.0.18              10    10018  12.so.0.1.0.18
5161  1.2.8               13    10208  12.so.0.1.2.8
5162  1.2.9beta1-3        13    10209  12.so.0.1.2.9beta1-3
5163  1.2.9beta4-11       13    10209  12.so.0.9[.0]
5164  1.2.9rc1            13    10209  12.so.0.9[.0]
5165  1.2.9               13    10209  12.so.0.9[.0]
5166  1.2.10beta1-7       13    10210  12.so.0.10[.0]
5167  1.2.10rc1-2         13    10210  12.so.0.10[.0]
5168  1.2.10              13    10210  12.so.0.10[.0]
5169  1.4.0beta1-6        14    10400  14.so.0.0[.0]
5170  1.2.11beta1-4       13    10210  12.so.0.11[.0]
5171  1.4.0beta7-8        14    10400  14.so.0.0[.0]
5172  1.2.11              13    10211  12.so.0.11[.0]
5173  1.2.12              13    10212  12.so.0.12[.0]
5174  1.4.0beta9-14       14    10400  14.so.0.0[.0]
5175  1.2.13              13    10213  12.so.0.13[.0]
5176  1.4.0beta15-36      14    10400  14.so.0.0[.0]
5177  1.4.0beta37-87      14    10400  14.so.14.0[.0]
5178  1.4.0rc01           14    10400  14.so.14.0[.0]
5179  1.4.0beta88-109     14    10400  14.so.14.0[.0]
5180  1.4.0rc02-08        14    10400  14.so.14.0[.0]
5181  1.4.0               14    10400  14.so.14.0[.0]
5182  1.4.1beta01-03      14    10401  14.so.14.1[.0]
5183  1.4.1rc01           14    10401  14.so.14.1[.0]
5184  1.4.1beta04-12      14    10401  14.so.14.1[.0]
5185  1.4.1               14    10401  14.so.14.1[.0]
5186  1.4.2               14    10402  14.so.14.2[.0]
5187  1.4.3               14    10403  14.so.14.3[.0]
5188  1.4.4               14    10404  14.so.14.4[.0]
5189  1.5.0beta01-58      15    10500  15.so.15.0[.0]
5190  1.5.0rc01-07        15    10500  15.so.15.0[.0]
5191  1.5.0               15    10500  15.so.15.0[.0]
5192  1.5.1beta01-11      15    10501  15.so.15.1[.0]
5193  1.5.1rc01-02        15    10501  15.so.15.1[.0]
5194  1.5.1               15    10501  15.so.15.1[.0]
5196 Henceforth the source version will match the shared-library minor
5197 and patch numbers; the shared-library major version number will be
5198 used for changes in backward compatibility, as it is intended.  The
5199 PNG_PNGLIB_VER macro, which is not used within libpng but is available
5200 for applications, is an unsigned integer of the form xyyzz corresponding
5201 to the source version x.y.z (leading zeros in y and z).  Beta versions
5202 were given the previous public release number plus a letter, until
5203 version 1.0.6j; from then on they were given the upcoming public
5204 release number plus "betaNN" or "rcN".
5206 .SH "SEE ALSO"
5207 .BR "png"(5), " libpngpf"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5)
5210 .IR libpng :
5212 http://libpng.sourceforge.net (follow the [DOWNLOAD] link)
5213 http://www.libpng.org/pub/png
5216 .IR zlib :
5218 (generally) at the same location as
5219 .I libpng
5220 or at
5222 ftp://ftp.info-zip.org/pub/infozip/zlib
5225 .IR PNG specification: RFC 2083
5227 (generally) at the same location as
5228 .I libpng
5229 or at
5231 ftp://ds.internic.net/rfc/rfc2083.txt
5233 or (as a W3C Recommendation) at
5235 http://www.w3.org/TR/REC-png.html
5238 In the case of any inconsistency between the PNG specification
5239 and this library, the specification takes precedence.
5241 .SH AUTHORS
5242 This man page: Glenn Randers-Pehrson
5243 <glennrp at users.sourceforge.net>
5245 The contributing authors would like to thank all those who helped
5246 with testing, bug fixes, and patience.  This wouldn't have been
5247 possible without all of you.
5249 Thanks to Frank J. T. Wojcik for helping with the documentation.
5251 Libpng version 1.5.1 - February 3, 2011:
5252 Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
5253 Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
5255 Supported by the PNG development group
5257 png-mng-implement at lists.sf.net
5258 (subscription required; visit
5259 png-mng-implement at lists.sourceforge.net (subscription required; visit
5260 https://lists.sourceforge.net/lists/listinfo/png-mng-implement
5261 to subscribe).
5263 .SH COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
5265 (This copy of the libpng notices is provided for your convenience.  In case of
5266 any discrepancy between this copy and the notices in the file png.h that is
5267 included in the libpng distribution, the latter shall prevail.)
5269 If you modify libpng you may insert additional notices immediately following
5270 this sentence.
5272 This code is released under the libpng license.
5274 libpng versions 1.2.6, August 15, 2004, through 1.5.1, February 3, 2011, are
5275 Copyright (c) 2004,2006-2007 Glenn Randers-Pehrson, and are
5276 distributed according to the same disclaimer and license as libpng-1.2.5
5277 with the following individual added to the list of Contributing Authors
5279    Cosmin Truta
5281 libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
5282 Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
5283 distributed according to the same disclaimer and license as libpng-1.0.6
5284 with the following individuals added to the list of Contributing Authors
5286    Simon-Pierre Cadieux
5287    Eric S. Raymond
5288    Gilles Vollant
5290 and with the following additions to the disclaimer:
5292    There is no warranty against interference with your
5293    enjoyment of the library or against infringement.
5294    There is no warranty that our efforts or the library
5295    will fulfill any of your particular purposes or needs.
5296    This library is provided with all faults, and the entire
5297    risk of satisfactory quality, performance, accuracy, and
5298    effort is with the user.
5300 libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
5301 Copyright (c) 1998, 1999 Glenn Randers-Pehrson
5302 Distributed according to the same disclaimer and license as libpng-0.96,
5303 with the following individuals added to the list of Contributing Authors:
5305    Tom Lane
5306    Glenn Randers-Pehrson
5307    Willem van Schaik
5309 libpng versions 0.89, June 1996, through 0.96, May 1997, are
5310 Copyright (c) 1996, 1997 Andreas Dilger
5311 Distributed according to the same disclaimer and license as libpng-0.88,
5312 with the following individuals added to the list of Contributing Authors:
5314    John Bowler
5315    Kevin Bracey
5316    Sam Bushell
5317    Magnus Holmgren
5318    Greg Roelofs
5319    Tom Tanner
5321 libpng versions 0.5, May 1995, through 0.88, January 1996, are
5322 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
5324 For the purposes of this copyright and license, "Contributing Authors"
5325 is defined as the following set of individuals:
5327    Andreas Dilger
5328    Dave Martindale
5329    Guy Eric Schalnat
5330    Paul Schmidt
5331    Tim Wegner
5333 The PNG Reference Library is supplied "AS IS".  The Contributing Authors
5334 and Group 42, Inc. disclaim all warranties, expressed or implied,
5335 including, without limitation, the warranties of merchantability and of
5336 fitness for any purpose.  The Contributing Authors and Group 42, Inc.
5337 assume no liability for direct, indirect, incidental, special, exemplary,
5338 or consequential damages, which may result from the use of the PNG
5339 Reference Library, even if advised of the possibility of such damage.
5341 Permission is hereby granted to use, copy, modify, and distribute this
5342 source code, or portions hereof, for any purpose, without fee, subject
5343 to the following restrictions:
5345 1. The origin of this source code must not be misrepresented.
5347 2. Altered versions must be plainly marked as such and
5348    must not be misrepresented as being the original source.
5350 3. This Copyright notice may not be removed or altered from
5351    any source or altered source distribution.
5353 The Contributing Authors and Group 42, Inc. specifically permit, without
5354 fee, and encourage the use of this source code as a component to
5355 supporting the PNG file format in commercial products.  If you use this
5356 source code in a product, acknowledgment is not required but would be
5357 appreciated.
5360 A "png_get_copyright" function is available, for convenient use in "about"
5361 boxes and the like:
5363    printf("%s",png_get_copyright(NULL));
5365 Also, the PNG logo (in PNG format, of course) is supplied in the
5366 files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
5368 Libpng is OSI Certified Open Source Software.  OSI Certified Open Source is a
5369 certification mark of the Open Source Initiative.
5371 Glenn Randers-Pehrson
5372 glennrp at users.sourceforge.net
5373 February 3, 2011
5375 .\" end of man page