blob: f5a8228c3b4f78fe5afde1c102d92b87d1ffb6e8 [file] [log] [blame]
The Android Open Source Project4215dd12009-03-09 11:52:12 -07001.TH LIBPNG 3 "February 14, 2009"
The Android Open Source Project893912b2009-03-03 19:30:05 -08002.SH NAME
The Android Open Source Project4215dd12009-03-09 11:52:12 -07003libpng \- Portable Network Graphics (PNG) Reference Library 1.2.35
The Android Open Source Project893912b2009-03-03 19:30:05 -08004.SH SYNOPSIS
The Android Open Source Project4215dd12009-03-09 11:52:12 -07005\fI\fB
6
7\fB#include <png.h>\fP
8
9\fI\fB
The Android Open Source Project893912b2009-03-03 19:30:05 -080010
11\fBpng_uint_32 png_access_version_number \fI(void\fP\fB);\fP
12
The Android Open Source Project4215dd12009-03-09 11:52:12 -070013\fI\fB
14
The Android Open Source Project893912b2009-03-03 19:30:05 -080015\fBint png_check_sig (png_bytep \fP\fIsig\fP\fB, int \fInum\fP\fB);\fP
16
The Android Open Source Project4215dd12009-03-09 11:52:12 -070017\fI\fB
18
The Android Open Source Project893912b2009-03-03 19:30:05 -080019\fBvoid png_chunk_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP
20
The Android Open Source Project4215dd12009-03-09 11:52:12 -070021\fI\fB
22
The Android Open Source Project893912b2009-03-03 19:30:05 -080023\fBvoid png_chunk_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP
24
The Android Open Source Project4215dd12009-03-09 11:52:12 -070025\fI\fB
26
The Android Open Source Project893912b2009-03-03 19:30:05 -080027\fBvoid png_convert_from_struct_tm (png_timep \fP\fIptime\fP\fB, struct tm FAR * \fIttime\fP\fB);\fP
28
The Android Open Source Project4215dd12009-03-09 11:52:12 -070029\fI\fB
30
The Android Open Source Project893912b2009-03-03 19:30:05 -080031\fBvoid png_convert_from_time_t (png_timep \fP\fIptime\fP\fB, time_t \fIttime\fP\fB);\fP
32
The Android Open Source Project4215dd12009-03-09 11:52:12 -070033\fI\fB
34
The Android Open Source Project893912b2009-03-03 19:30:05 -080035\fBpng_charp png_convert_to_rfc1123 (png_structp \fP\fIpng_ptr\fP\fB, png_timep \fIptime\fP\fB);\fP
36
The Android Open Source Project4215dd12009-03-09 11:52:12 -070037\fI\fB
38
The Android Open Source Project893912b2009-03-03 19:30:05 -080039\fBpng_infop png_create_info_struct (png_structp \fIpng_ptr\fP\fB);\fP
40
The Android Open Source Project4215dd12009-03-09 11:52:12 -070041\fI\fB
42
The Android Open Source Project893912b2009-03-03 19:30:05 -080043\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
44
The Android Open Source Project4215dd12009-03-09 11:52:12 -070045\fI\fB
46
The Android Open Source Project893912b2009-03-03 19:30:05 -080047\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
48
The Android Open Source Project4215dd12009-03-09 11:52:12 -070049\fI\fB
50
The Android Open Source Project893912b2009-03-03 19:30:05 -080051\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
52
The Android Open Source Project4215dd12009-03-09 11:52:12 -070053\fI\fB
54
The Android Open Source Project893912b2009-03-03 19:30:05 -080055\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
56
The Android Open Source Project4215dd12009-03-09 11:52:12 -070057\fI\fB
58
The Android Open Source Project893912b2009-03-03 19:30:05 -080059\fBint png_debug(int \fP\fIlevel\fP\fB, png_const_charp \fImessage\fP\fB);\fP
60
The Android Open Source Project4215dd12009-03-09 11:52:12 -070061\fI\fB
62
The Android Open Source Project893912b2009-03-03 19:30:05 -080063\fBint png_debug1(int \fP\fIlevel\fP\fB, png_const_charp \fP\fImessage\fP\fB, \fIp1\fP\fB);\fP
64
The Android Open Source Project4215dd12009-03-09 11:52:12 -070065\fI\fB
66
The Android Open Source Project893912b2009-03-03 19:30:05 -080067\fBint png_debug2(int \fP\fIlevel\fP\fB, png_const_charp \fP\fImessage\fP\fB, \fP\fIp1\fP\fB, \fIp2\fP\fB);\fP
68
The Android Open Source Project4215dd12009-03-09 11:52:12 -070069\fI\fB
70
The Android Open Source Project893912b2009-03-03 19:30:05 -080071\fBvoid png_destroy_info_struct (png_structp \fP\fIpng_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP
72
The Android Open Source Project4215dd12009-03-09 11:52:12 -070073\fI\fB
74
The Android Open Source Project893912b2009-03-03 19:30:05 -080075\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
76
The Android Open Source Project4215dd12009-03-09 11:52:12 -070077\fI\fB
78
The Android Open Source Project893912b2009-03-03 19:30:05 -080079\fBvoid png_destroy_write_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP
80
The Android Open Source Project4215dd12009-03-09 11:52:12 -070081\fI\fB
82
The Android Open Source Project893912b2009-03-03 19:30:05 -080083\fBvoid png_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP
84
The Android Open Source Project4215dd12009-03-09 11:52:12 -070085\fI\fB
86
The Android Open Source Project893912b2009-03-03 19:30:05 -080087\fBvoid png_free (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP
88
The Android Open Source Project4215dd12009-03-09 11:52:12 -070089\fI\fB
90
The Android Open Source Project893912b2009-03-03 19:30:05 -080091\fBvoid png_free_chunk_list (png_structp \fIpng_ptr\fP\fB);\fP
92
The Android Open Source Project4215dd12009-03-09 11:52:12 -070093\fI\fB
94
The Android Open Source Project893912b2009-03-03 19:30:05 -080095\fBvoid png_free_default(png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP
96
The Android Open Source Project4215dd12009-03-09 11:52:12 -070097\fI\fB
98
The Android Open Source Project893912b2009-03-03 19:30:05 -080099\fBvoid png_free_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fInum\fP\fB);\fP
100
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700101\fI\fB
102
The Android Open Source Project893912b2009-03-03 19:30:05 -0800103\fBpng_byte png_get_bit_depth (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
104
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700105\fI\fB
106
The Android Open Source Project893912b2009-03-03 19:30:05 -0800107\fBpng_uint_32 png_get_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fI*background\fP\fB);\fP
108
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700109\fI\fB
110
The Android Open Source Project893912b2009-03-03 19:30:05 -0800111\fBpng_byte png_get_channels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
112
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700113\fI\fB
114
The Android Open Source Project893912b2009-03-03 19:30:05 -0800115\fBpng_uint_32 png_get_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_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
116
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700117\fI\fB
118
The Android Open Source Project893912b2009-03-03 19:30:05 -0800119\fBpng_uint_32 png_get_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_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
120
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700121\fI\fB
122
The Android Open Source Project893912b2009-03-03 19:30:05 -0800123\fBpng_byte png_get_color_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
124
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700125\fI\fB
126
The Android Open Source Project893912b2009-03-03 19:30:05 -0800127\fBpng_byte png_get_compression_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
128
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700129\fI\fB
130
The Android Open Source Project893912b2009-03-03 19:30:05 -0800131\fBpng_byte png_get_copyright (png_structp \fIpng_ptr\fP\fB);\fP
132
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700133\fI\fB
134
The Android Open Source Project893912b2009-03-03 19:30:05 -0800135\fBpng_voidp png_get_error_ptr (png_structp \fIpng_ptr\fP\fB);\fP
136
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700137\fI\fB
138
The Android Open Source Project893912b2009-03-03 19:30:05 -0800139\fBpng_byte png_get_filter_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
140
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700141\fI\fB
142
The Android Open Source Project893912b2009-03-03 19:30:05 -0800143\fBpng_uint_32 png_get_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fI*file_gamma\fP\fB);\fP
144
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700145\fI\fB
146
The Android Open Source Project893912b2009-03-03 19:30:05 -0800147\fBpng_uint_32 png_get_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fI*int_file_gamma\fP\fB);\fP
148
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700149\fI\fB
150
The Android Open Source Project893912b2009-03-03 19:30:05 -0800151\fBpng_byte png_get_header_ver (png_structp \fIpng_ptr\fP\fB);\fP
152
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700153\fI\fB
154
The Android Open Source Project893912b2009-03-03 19:30:05 -0800155\fBpng_byte png_get_header_version (png_structp \fIpng_ptr\fP\fB);\fP
156
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700157\fI\fB
158
The Android Open Source Project893912b2009-03-03 19:30:05 -0800159\fBpng_uint_32 png_get_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fI*hist\fP\fB);\fP
160
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700161\fI\fB
162
The Android Open Source Project893912b2009-03-03 19:30:05 -0800163\fBpng_uint_32 png_get_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charpp \fP\fIname\fP\fB, int \fP\fI*compression_type\fP\fB, png_charpp \fP\fIprofile\fP\fB, png_uint_32 \fI*proflen\fP\fB);\fP
164
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700165\fI\fB
166
The Android Open Source Project893912b2009-03-03 19:30:05 -0800167\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
168
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700169\fI\fB
170
The Android Open Source Project893912b2009-03-03 19:30:05 -0800171\fBpng_uint_32 png_get_image_height (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
172
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700173\fI\fB
174
The Android Open Source Project893912b2009-03-03 19:30:05 -0800175\fBpng_uint_32 png_get_image_width (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
176
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700177\fI\fB
178
179\fB#if \fI!defined(PNG_1_0_X)
180
181\fBpng_int_32 png_get_int_32 (png_bytep \fIbuf\fP\fB);\fP
182
183\fI\fB#endif
184
185\fI\fB
The Android Open Source Project893912b2009-03-03 19:30:05 -0800186
187\fBpng_byte png_get_interlace_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
188
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700189\fI\fB
190
The Android Open Source Project893912b2009-03-03 19:30:05 -0800191\fBpng_voidp png_get_io_ptr (png_structp \fIpng_ptr\fP\fB);\fP
192
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700193\fI\fB
194
The Android Open Source Project893912b2009-03-03 19:30:05 -0800195\fBpng_byte png_get_libpng_ver (png_structp \fIpng_ptr\fP\fB);\fP
196
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700197\fI\fB
198
The Android Open Source Project893912b2009-03-03 19:30:05 -0800199\fBpng_voidp png_get_mem_ptr(png_structp \fIpng_ptr\fP\fB);\fP
200
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700201\fI\fB
202
The Android Open Source Project893912b2009-03-03 19:30:05 -0800203\fBpng_uint_32 png_get_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_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
204
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700205\fI\fB
206
The Android Open Source Project893912b2009-03-03 19:30:05 -0800207\fBpng_uint_32 png_get_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_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
208
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700209\fI\fB
210
The Android Open Source Project893912b2009-03-03 19:30:05 -0800211\fBpng_uint_32 png_get_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_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
212
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700213\fI\fB
214
The Android Open Source Project893912b2009-03-03 19:30:05 -0800215\fBfloat png_get_pixel_aspect_ratio (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
216
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700217\fI\fB
218
The Android Open Source Project893912b2009-03-03 19:30:05 -0800219\fBpng_uint_32 png_get_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
220
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700221\fI\fB
222
The Android Open Source Project893912b2009-03-03 19:30:05 -0800223\fBpng_voidp png_get_progressive_ptr (png_structp \fIpng_ptr\fP\fB);\fP
224
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700225\fI\fB
226
The Android Open Source Project893912b2009-03-03 19:30:05 -0800227\fBpng_uint_32 png_get_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_colorp \fP\fI*palette\fP\fB, int \fI*num_palette\fP\fB);\fP
228
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700229\fI\fB
230
231\fBpng_byte png_get_rgb_to_gray_status (png_structp \fIpng_ptr)
232
233\fBpng_uint_32 png_get_rowbytes (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
234
235\fI\fB
The Android Open Source Project893912b2009-03-03 19:30:05 -0800236
237\fBpng_bytepp png_get_rows (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
238
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700239\fI\fB
240
The Android Open Source Project893912b2009-03-03 19:30:05 -0800241\fBpng_uint_32 png_get_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_8p \fI*sig_bit\fP\fB);\fP
242
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700243\fI\fB
244
The Android Open Source Project893912b2009-03-03 19:30:05 -0800245\fBpng_bytep png_get_signature (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
246
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700247\fI\fB
248
The Android Open Source Project893912b2009-03-03 19:30:05 -0800249\fBpng_uint_32 png_get_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fI*splt_ptr\fP\fB);\fP
250
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700251\fI\fB
252
The Android Open Source Project893912b2009-03-03 19:30:05 -0800253\fBpng_uint_32 png_get_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fI*intent\fP\fB);\fP
254
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700255\fI\fB
256
The Android Open Source Project893912b2009-03-03 19:30:05 -0800257\fBpng_uint_32 png_get_text (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fI*text_ptr\fP\fB, int \fI*num_text\fP\fB);\fP
258
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700259\fI\fB
260
The Android Open Source Project893912b2009-03-03 19:30:05 -0800261\fBpng_uint_32 png_get_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fI*mod_time\fP\fB);\fP
262
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700263\fI\fB
264
The Android Open Source Project893912b2009-03-03 19:30:05 -0800265\fBpng_uint_32 png_get_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fI*trans\fP\fB, int \fP\fI*num_trans\fP\fB, png_color_16p \fI*trans_values\fP\fB);\fP
266
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700267\fI\fB
268
269\fB#if \fI!defined(PNG_1_0_X)
270
271\fBpng_uint_16 png_get_uint_16 (png_bytep \fIbuf\fP\fB);\fP
272
273\fI\fB
The Android Open Source Project893912b2009-03-03 19:30:05 -0800274
275\fBpng_uint_32 png_get_uint_31 (png_bytep \fIbuf\fP\fB);\fP
276
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700277\fI\fB
278
279\fBpng_uint_32 png_get_uint_32 (png_bytep \fIbuf\fP\fB);\fP
280
281\fI\fB#endif
282
283\fI\fB
The Android Open Source Project893912b2009-03-03 19:30:05 -0800284
285\fBpng_uint_32 png_get_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkpp \fIunknowns\fP\fB);\fP
286
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700287\fI\fB
288
The Android Open Source Project893912b2009-03-03 19:30:05 -0800289\fBpng_voidp png_get_user_chunk_ptr (png_structp \fIpng_ptr\fP\fB);\fP
290
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700291\fI\fB
292
The Android Open Source Project893912b2009-03-03 19:30:05 -0800293\fBpng_uint_32 png_get_user_height_max( png_structp \fIpng_ptr\fP\fB);\fP
294
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700295\fI\fB
296
The Android Open Source Project893912b2009-03-03 19:30:05 -0800297\fBpng_voidp png_get_user_transform_ptr (png_structp \fIpng_ptr\fP\fB);\fP
298
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700299\fI\fB
300
The Android Open Source Project893912b2009-03-03 19:30:05 -0800301\fBpng_uint_32 png_get_user_width_max (png_structp \fIpng_ptr\fP\fB);\fP
302
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700303\fI\fB
304
The Android Open Source Project893912b2009-03-03 19:30:05 -0800305\fBpng_uint_32 png_get_valid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIflag\fP\fB);\fP
306
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700307\fI\fB
308
The Android Open Source Project893912b2009-03-03 19:30:05 -0800309\fBpng_int_32 png_get_x_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
310
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700311\fI\fB
312
The Android Open Source Project893912b2009-03-03 19:30:05 -0800313\fBpng_int_32 png_get_x_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
314
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700315\fI\fB
316
The Android Open Source Project893912b2009-03-03 19:30:05 -0800317\fBpng_uint_32 png_get_x_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
318
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700319\fI\fB
320
The Android Open Source Project893912b2009-03-03 19:30:05 -0800321\fBpng_int_32 png_get_y_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
322
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700323\fI\fB
324
The Android Open Source Project893912b2009-03-03 19:30:05 -0800325\fBpng_int_32 png_get_y_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
326
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700327\fI\fB
328
The Android Open Source Project893912b2009-03-03 19:30:05 -0800329\fBpng_uint_32 png_get_y_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
330
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700331\fI\fB
332
The Android Open Source Project893912b2009-03-03 19:30:05 -0800333\fBpng_uint_32 png_get_compression_buffer_size (png_structp \fIpng_ptr\fP\fB);\fP
334
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700335\fI\fB
336
The Android Open Source Project893912b2009-03-03 19:30:05 -0800337\fBint png_handle_as_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP
338
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700339\fI\fB
340
The Android Open Source Project893912b2009-03-03 19:30:05 -0800341\fBvoid png_init_io (png_structp \fP\fIpng_ptr\fP\fB, FILE \fI*fp\fP\fB);\fP
342
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700343\fI\fB
344
The Android Open Source Project893912b2009-03-03 19:30:05 -0800345\fBDEPRECATED: void png_info_init (png_infop \fIinfo_ptr\fP\fB);\fP
346
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700347\fI\fB
348
The Android Open Source Project893912b2009-03-03 19:30:05 -0800349\fBDEPRECATED: void png_info_init_2 (png_infopp \fP\fIptr_ptr\fP\fB, png_size_t \fIpng_info_struct_size\fP\fB);\fP
350
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700351\fI\fB
352
The Android Open Source Project893912b2009-03-03 19:30:05 -0800353\fBpng_voidp png_malloc (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
354
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700355\fI\fB
356
The Android Open Source Project893912b2009-03-03 19:30:05 -0800357\fBpng_voidp png_malloc_default(png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
358
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700359\fI\fB
360
The Android Open Source Project893912b2009-03-03 19:30:05 -0800361\fBvoidp png_memcpy (png_voidp \fP\fIs1\fP\fB, png_voidp \fP\fIs2\fP\fB, png_size_t \fIsize\fP\fB);\fP
362
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700363\fI\fB
364
The Android Open Source Project893912b2009-03-03 19:30:05 -0800365\fBpng_voidp png_memcpy_check (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIs1\fP\fB, png_voidp \fP\fIs2\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
366
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700367\fI\fB
368
The Android Open Source Project893912b2009-03-03 19:30:05 -0800369\fBvoidp png_memset (png_voidp \fP\fIs1\fP\fB, int \fP\fIvalue\fP\fB, png_size_t \fIsize\fP\fB);\fP
370
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700371\fI\fB
372
The Android Open Source Project893912b2009-03-03 19:30:05 -0800373\fBpng_voidp png_memset_check (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIs1\fP\fB, int \fP\fIvalue\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
374
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700375\fI\fB
376
The Android Open Source Project893912b2009-03-03 19:30:05 -0800377\fBDEPRECATED: void png_permit_empty_plte (png_structp \fP\fIpng_ptr\fP\fB, int \fIempty_plte_permitted\fP\fB);\fP
378
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700379\fI\fB
380
The Android Open Source Project893912b2009-03-03 19:30:05 -0800381\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
382
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700383\fI\fB
384
The Android Open Source Project893912b2009-03-03 19:30:05 -0800385\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
386
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700387\fI\fB
388
The Android Open Source Project893912b2009-03-03 19:30:05 -0800389\fBvoid png_read_destroy (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_infop \fIend_info_ptr\fP\fB);\fP
390
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700391\fI\fB
392
The Android Open Source Project893912b2009-03-03 19:30:05 -0800393\fBvoid png_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
394
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700395\fI\fB
396
The Android Open Source Project893912b2009-03-03 19:30:05 -0800397\fBvoid png_read_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP
398
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700399\fI\fB
400
The Android Open Source Project893912b2009-03-03 19:30:05 -0800401\fBDEPRECATED: void png_read_init (png_structp \fIpng_ptr\fP\fB);\fP
402
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700403\fI\fB
404
The Android Open Source Project893912b2009-03-03 19:30:05 -0800405\fBDEPRECATED: void png_read_init_2 (png_structpp \fP\fIptr_ptr\fP\fB, png_const_charp \fP\fIuser_png_ver\fP\fB, png_size_t \fP\fIpng_struct_size\fP\fB, png_size_t \fIpng_info_size\fP\fB);\fP
406
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700407\fI\fB
408
The Android Open Source Project893912b2009-03-03 19:30:05 -0800409\fBvoid png_read_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
410
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700411\fI\fB
412
The Android Open Source Project893912b2009-03-03 19:30:05 -0800413\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
414
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700415\fI\fB
416
The Android Open Source Project893912b2009-03-03 19:30:05 -0800417\fBvoid png_read_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fIdisplay_row\fP\fB);\fP
418
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700419\fI\fB
420
The Android Open Source Project893912b2009-03-03 19:30:05 -0800421\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
422
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700423\fI\fB
424
The Android Open Source Project893912b2009-03-03 19:30:05 -0800425\fBvoid png_read_update_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
426
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700427\fI\fB
428
429\fB#if \fI!defined(PNG_1_0_X)
430
431\fBpng_save_int_32 (png_bytep \fP\fIbuf\fP\fB, png_int_32 \fIi\fP\fB);\fP
432
433\fI\fB
The Android Open Source Project893912b2009-03-03 19:30:05 -0800434
435\fBvoid png_save_uint_16 (png_bytep \fP\fIbuf\fP\fB, unsigned int \fIi\fP\fB);\fP
436
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700437\fI\fB
438
The Android Open Source Project893912b2009-03-03 19:30:05 -0800439\fBvoid png_save_uint_32 (png_bytep \fP\fIbuf\fP\fB, png_uint_32 \fIi\fP\fB);\fP
440
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700441\fI\fB
442
443\fBvoid png_set_add_alpha (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP
444
445\fI\fB#endif
446
447\fI\fB
The Android Open Source Project893912b2009-03-03 19:30:05 -0800448
449\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
450
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700451\fI\fB
452
The Android Open Source Project893912b2009-03-03 19:30:05 -0800453\fBvoid png_set_bgr (png_structp \fIpng_ptr\fP\fB);\fP
454
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700455\fI\fB
456
The Android Open Source Project893912b2009-03-03 19:30:05 -0800457\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
458
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700459\fI\fB
460
The Android Open Source Project893912b2009-03-03 19:30:05 -0800461\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
462
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700463\fI\fB
464
The Android Open Source Project893912b2009-03-03 19:30:05 -0800465\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
466
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700467\fI\fB
468
The Android Open Source Project893912b2009-03-03 19:30:05 -0800469\fBvoid png_set_compression_level (png_structp \fP\fIpng_ptr\fP\fB, int \fIlevel\fP\fB);\fP
470
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700471\fI\fB
472
The Android Open Source Project893912b2009-03-03 19:30:05 -0800473\fBvoid png_set_compression_mem_level (png_structp \fP\fIpng_ptr\fP\fB, int \fImem_level\fP\fB);\fP
474
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700475\fI\fB
476
The Android Open Source Project893912b2009-03-03 19:30:05 -0800477\fBvoid png_set_compression_method (png_structp \fP\fIpng_ptr\fP\fB, int \fImethod\fP\fB);\fP
478
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700479\fI\fB
480
The Android Open Source Project893912b2009-03-03 19:30:05 -0800481\fBvoid png_set_compression_strategy (png_structp \fP\fIpng_ptr\fP\fB, int \fIstrategy\fP\fB);\fP
482
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700483\fI\fB
484
The Android Open Source Project893912b2009-03-03 19:30:05 -0800485\fBvoid png_set_compression_window_bits (png_structp \fP\fIpng_ptr\fP\fB, int \fIwindow_bits\fP\fB);\fP
486
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700487\fI\fB
488
The Android Open Source Project893912b2009-03-03 19:30:05 -0800489\fBvoid png_set_crc_action (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcrit_action\fP\fB, int \fIancil_action\fP\fB);\fP
490
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700491\fI\fB
492
The Android Open Source Project893912b2009-03-03 19:30:05 -0800493\fBvoid png_set_dither (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_dither\fP\fB);\fP
494
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700495\fI\fB
496
The Android Open Source Project893912b2009-03-03 19:30:05 -0800497\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
498
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700499\fI\fB
500
The Android Open Source Project893912b2009-03-03 19:30:05 -0800501\fBvoid png_set_expand (png_structp \fIpng_ptr\fP\fB);\fP
502
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700503\fI\fB
504
The Android Open Source Project893912b2009-03-03 19:30:05 -0800505\fBvoid png_set_expand_gray_1_2_4_to_8(png_structp \fIpng_ptr\fP\fB);\fP
506
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700507\fI\fB
508
The Android Open Source Project893912b2009-03-03 19:30:05 -0800509\fBvoid png_set_filler (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP
510
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700511\fI\fB
512
The Android Open Source Project893912b2009-03-03 19:30:05 -0800513\fBvoid png_set_filter (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fImethod\fP\fB, int \fIfilters\fP\fB);\fP
514
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700515\fI\fB
516
The Android Open Source Project893912b2009-03-03 19:30:05 -0800517\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
518
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700519\fI\fB
520
The Android Open Source Project893912b2009-03-03 19:30:05 -0800521\fBvoid png_set_flush (png_structp \fP\fIpng_ptr\fP\fB, int \fInrows\fP\fB);\fP
522
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700523\fI\fB
524
The Android Open Source Project893912b2009-03-03 19:30:05 -0800525\fBvoid png_set_gamma (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIscreen_gamma\fP\fB, double \fIdefault_file_gamma\fP\fB);\fP
526
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700527\fI\fB
528
The Android Open Source Project893912b2009-03-03 19:30:05 -0800529\fBvoid png_set_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fIfile_gamma\fP\fB);\fP
530
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700531\fI\fB
532
The Android Open Source Project893912b2009-03-03 19:30:05 -0800533\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
534
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700535\fI\fB
536
The Android Open Source Project893912b2009-03-03 19:30:05 -0800537\fBvoid png_set_gray_1_2_4_to_8(png_structp \fIpng_ptr\fP\fB);\fP
538
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700539\fI\fB
540
The Android Open Source Project893912b2009-03-03 19:30:05 -0800541\fBvoid png_set_gray_to_rgb (png_structp \fIpng_ptr\fP\fB);\fP
542
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700543\fI\fB
544
The Android Open Source Project893912b2009-03-03 19:30:05 -0800545\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
546
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700547\fI\fB
548
The Android Open Source Project893912b2009-03-03 19:30:05 -0800549\fBvoid png_set_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_charp \fP\fIprofile\fP\fB, png_uint_32 \fIproflen\fP\fB);\fP
550
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700551\fI\fB
552
The Android Open Source Project893912b2009-03-03 19:30:05 -0800553\fBint png_set_interlace_handling (png_structp \fIpng_ptr\fP\fB);\fP
554
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700555\fI\fB
556
The Android Open Source Project893912b2009-03-03 19:30:05 -0800557\fBvoid png_set_invalid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fImask\fP\fB);\fP
558
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700559\fI\fB
560
The Android Open Source Project893912b2009-03-03 19:30:05 -0800561\fBvoid png_set_invert_alpha (png_structp \fIpng_ptr\fP\fB);\fP
562
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700563\fI\fB
564
The Android Open Source Project893912b2009-03-03 19:30:05 -0800565\fBvoid png_set_invert_mono (png_structp \fIpng_ptr\fP\fB);\fP
566
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700567\fI\fB
568
The Android Open Source Project893912b2009-03-03 19:30:05 -0800569\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
570
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700571\fI\fB
572
The Android Open Source Project893912b2009-03-03 19:30:05 -0800573\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
574
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700575\fI\fB
576
The Android Open Source Project893912b2009-03-03 19:30:05 -0800577\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
578
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700579\fI\fB
580
The Android Open Source Project893912b2009-03-03 19:30:05 -0800581\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
582
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700583\fI\fB
584
The Android Open Source Project893912b2009-03-03 19:30:05 -0800585\fBvoid png_set_packing (png_structp \fIpng_ptr\fP\fB);\fP
586
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700587\fI\fB
588
The Android Open Source Project893912b2009-03-03 19:30:05 -0800589\fBvoid png_set_packswap (png_structp \fIpng_ptr\fP\fB);\fP
590
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700591\fI\fB
592
The Android Open Source Project893912b2009-03-03 19:30:05 -0800593\fBvoid png_set_palette_to_rgb(png_structp \fIpng_ptr\fP\fB);\fP
594
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700595\fI\fB
596
The Android Open Source Project893912b2009-03-03 19:30:05 -0800597\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
598
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700599\fI\fB
600
The Android Open Source Project893912b2009-03-03 19:30:05 -0800601\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
602
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700603\fI\fB
604
The Android Open Source Project893912b2009-03-03 19:30:05 -0800605\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
606
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700607\fI\fB
608
The Android Open Source Project893912b2009-03-03 19:30:05 -0800609\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
610
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700611\fI\fB
612
The Android Open Source Project893912b2009-03-03 19:30:05 -0800613\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
614
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700615\fI\fB
616
The Android Open Source Project893912b2009-03-03 19:30:05 -0800617\fBvoid png_set_read_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_read_status_ptr \fIread_row_fn\fP\fB);\fP
618
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700619\fI\fB
620
The Android Open Source Project893912b2009-03-03 19:30:05 -0800621\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
622
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700623\fI\fB
624
The Android Open Source Project893912b2009-03-03 19:30:05 -0800625\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
626
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700627\fI\fB
628
The Android Open Source Project893912b2009-03-03 19:30:05 -0800629\fBvoid png_set_rgb_to_gray_fixed (png_structp \fP\fIpng_ptr\fP\fB, int error_action png_fixed_point \fP\fIred\fP\fB, png_fixed_point \fIgreen\fP\fB);\fP
630
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700631\fI\fB
632
The Android Open Source Project893912b2009-03-03 19:30:05 -0800633\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
634
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700635\fI\fB
636
The Android Open Source Project893912b2009-03-03 19:30:05 -0800637\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
638
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700639\fI\fB
640
The Android Open Source Project893912b2009-03-03 19:30:05 -0800641\fBvoid png_set_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, double \fP\fIwidth\fP\fB, double \fIheight\fP\fB);\fP
642
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700643\fI\fB
644
The Android Open Source Project893912b2009-03-03 19:30:05 -0800645\fBvoid png_set_shift (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fItrue_bits\fP\fB);\fP
646
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700647\fI\fB
648
The Android Open Source Project893912b2009-03-03 19:30:05 -0800649\fBvoid png_set_sig_bytes (png_structp \fP\fIpng_ptr\fP\fB, int \fInum_bytes\fP\fB);\fP
650
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700651\fI\fB
652
The Android Open Source Project893912b2009-03-03 19:30:05 -0800653\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
654
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700655\fI\fB
656
The Android Open Source Project893912b2009-03-03 19:30:05 -0800657\fBvoid png_set_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIintent\fP\fB);\fP
658
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700659\fI\fB
660
The Android Open Source Project893912b2009-03-03 19:30:05 -0800661\fBvoid png_set_sRGB_gAMA_and_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIintent\fP\fB);\fP
662
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700663\fI\fB
664
The Android Open Source Project893912b2009-03-03 19:30:05 -0800665\fBvoid png_set_strip_16 (png_structp \fIpng_ptr\fP\fB);\fP
666
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700667\fI\fB
668
The Android Open Source Project893912b2009-03-03 19:30:05 -0800669\fBvoid png_set_strip_alpha (png_structp \fIpng_ptr\fP\fB);\fP
670
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700671\fI\fB
672
The Android Open Source Project893912b2009-03-03 19:30:05 -0800673\fBvoid png_set_swap (png_structp \fIpng_ptr\fP\fB);\fP
674
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700675\fI\fB
676
The Android Open Source Project893912b2009-03-03 19:30:05 -0800677\fBvoid png_set_swap_alpha (png_structp \fIpng_ptr\fP\fB);\fP
678
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700679\fI\fB
680
The Android Open Source Project893912b2009-03-03 19:30:05 -0800681\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
682
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700683\fI\fB
684
The Android Open Source Project893912b2009-03-03 19:30:05 -0800685\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
686
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700687\fI\fB
688
The Android Open Source Project893912b2009-03-03 19:30:05 -0800689\fBvoid png_set_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fItrans\fP\fB, int \fP\fInum_trans\fP\fB, png_color_16p \fItrans_values\fP\fB);\fP
690
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700691\fI\fB
692
The Android Open Source Project893912b2009-03-03 19:30:05 -0800693\fBvoid png_set_tRNS_to_alpha(png_structp \fIpng_ptr\fP\fB);\fP
694
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700695\fI\fB
696
The Android Open Source Project893912b2009-03-03 19:30:05 -0800697\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
698
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700699\fI\fB
700
The Android Open Source Project893912b2009-03-03 19:30:05 -0800701\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
702
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700703\fI\fB
704
The Android Open Source Project893912b2009-03-03 19:30:05 -0800705\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
706
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700707\fI\fB
708
The Android Open Source Project893912b2009-03-03 19:30:05 -0800709\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
710
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700711\fI\fB
712
The Android Open Source Project893912b2009-03-03 19:30:05 -0800713\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
714
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700715\fI\fB
716
The Android Open Source Project893912b2009-03-03 19:30:05 -0800717\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
718
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700719\fI\fB
720
The Android Open Source Project893912b2009-03-03 19:30:05 -0800721\fBvoid png_set_write_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_write_status_ptr \fIwrite_row_fn\fP\fB);\fP
722
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700723\fI\fB
724
The Android Open Source Project893912b2009-03-03 19:30:05 -0800725\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
726
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700727\fI\fB
728
The Android Open Source Project893912b2009-03-03 19:30:05 -0800729\fBvoid png_set_compression_buffer_size(png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
730
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700731\fI\fB
732
The Android Open Source Project893912b2009-03-03 19:30:05 -0800733\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
734
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700735\fI\fB
736
The Android Open Source Project893912b2009-03-03 19:30:05 -0800737\fBvoid png_start_read_image (png_structp \fIpng_ptr\fP\fB);\fP
738
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700739\fI\fB
740
The Android Open Source Project893912b2009-03-03 19:30:05 -0800741\fBvoid png_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP
742
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700743\fI\fB
744
The Android Open Source Project893912b2009-03-03 19:30:05 -0800745\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
746
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700747\fI\fB
748
The Android Open Source Project893912b2009-03-03 19:30:05 -0800749\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
750
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700751\fI\fB
752
The Android Open Source Project893912b2009-03-03 19:30:05 -0800753\fBvoid png_write_chunk_end (png_structp \fIpng_ptr\fP\fB);\fP
754
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700755\fI\fB
756
The Android Open Source Project893912b2009-03-03 19:30:05 -0800757\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
758
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700759\fI\fB
760
The Android Open Source Project893912b2009-03-03 19:30:05 -0800761\fBvoid png_write_destroy (png_structp \fIpng_ptr\fP\fB);\fP
762
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700763\fI\fB
764
The Android Open Source Project893912b2009-03-03 19:30:05 -0800765\fBvoid png_write_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
766
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700767\fI\fB
768
The Android Open Source Project893912b2009-03-03 19:30:05 -0800769\fBvoid png_write_flush (png_structp \fIpng_ptr\fP\fB);\fP
770
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700771\fI\fB
772
The Android Open Source Project893912b2009-03-03 19:30:05 -0800773\fBvoid png_write_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP
774
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700775\fI\fB
776
The Android Open Source Project893912b2009-03-03 19:30:05 -0800777\fBDEPRECATED: void png_write_init (png_structp \fIpng_ptr\fP\fB);\fP
778
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700779\fI\fB
780
The Android Open Source Project893912b2009-03-03 19:30:05 -0800781\fBDEPRECATED: void png_write_init_2 (png_structpp \fP\fIptr_ptr\fP\fB, png_const_charp \fP\fIuser_png_ver\fP\fB, png_size_t \fP\fIpng_struct_size\fP\fB, png_size_t \fIpng_info_size\fP\fB);\fP
782
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700783\fI\fB
784
The Android Open Source Project893912b2009-03-03 19:30:05 -0800785\fBvoid png_write_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
786
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700787\fI\fB
788
The Android Open Source Project893912b2009-03-03 19:30:05 -0800789\fBvoid png_write_info_before_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
790
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700791\fI\fB
792
The Android Open Source Project893912b2009-03-03 19:30:05 -0800793\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
794
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700795\fI\fB
796
The Android Open Source Project893912b2009-03-03 19:30:05 -0800797\fBvoid png_write_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIrow\fP\fB);\fP
798
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700799\fI\fB
800
The Android Open Source Project893912b2009-03-03 19:30:05 -0800801\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
802
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700803\fI\fB
804
The Android Open Source Project893912b2009-03-03 19:30:05 -0800805\fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP
806
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700807\fI\fB
808
The Android Open Source Project893912b2009-03-03 19:30:05 -0800809\fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP
810
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700811\fI\fB
812
The Android Open Source Project893912b2009-03-03 19:30:05 -0800813.SH DESCRIPTION
814The
815.I libpng
816library supports encoding, decoding, and various manipulations of
817the Portable Network Graphics (PNG) format image files. It uses the
818.IR zlib(3)
819compression library.
820Following is a copy of the libpng.txt file that accompanies libpng.
821.SH LIBPNG.TXT
822libpng.txt - A description on how to use and modify libpng
823
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700824 libpng version 1.2.35 - February 14, 2009
The Android Open Source Project893912b2009-03-03 19:30:05 -0800825 Updated and distributed by Glenn Randers-Pehrson
826 <glennrp at users.sourceforge.net>
827 Copyright (c) 1998-2008 Glenn Randers-Pehrson
828 For conditions of distribution and use, see copyright
829 notice in png.h.
830
831 Based on:
832
The Android Open Source Project4215dd12009-03-09 11:52:12 -0700833 libpng versions 0.97, January 1998, through 1.2.35 - February 14, 2009
The Android Open Source Project893912b2009-03-03 19:30:05 -0800834 Updated and distributed by Glenn Randers-Pehrson
835 Copyright (c) 1998-2008 Glenn Randers-Pehrson
836
837 libpng 1.0 beta 6 version 0.96 May 28, 1997
838 Updated and distributed by Andreas Dilger
839 Copyright (c) 1996, 1997 Andreas Dilger
840
841 libpng 1.0 beta 2 - version 0.88 January 26, 1996
842 For conditions of distribution and use, see copyright
843 notice in png.h. Copyright (c) 1995, 1996 Guy Eric
844 Schalnat, Group 42, Inc.
845
846 Updated/rewritten per request in the libpng FAQ
847 Copyright (c) 1995, 1996 Frank J. T. Wojcik
848 December 18, 1995 & January 20, 1996
849
850.SH I. Introduction
851
852This file describes how to use and modify the PNG reference library
853(known as libpng) for your own use. There are five sections to this
854file: introduction, structures, reading, writing, and modification and
855configuration notes for various special platforms. In addition to this
856file, example.c is a good starting point for using the library, as
857it is heavily commented and should include everything most people
858will need. We assume that libpng is already installed; see the
859INSTALL file for instructions on how to install libpng.
860
861For examples of libpng usage, see the files "example.c", "pngtest.c",
862and the files in the "contrib" directory, all of which are included in the
863libpng distribution.
864
865Libpng was written as a companion to the PNG specification, as a way
866of reducing the amount of time and effort it takes to support the PNG
867file format in application programs.
868
869The PNG specification (second edition), November 2003, is available as
870a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2003 (E)) at
871<http://www.w3.org/TR/2003/REC-PNG-20031110/
872The W3C and ISO documents have identical technical content.
873
874The PNG-1.2 specification is available at
875<http://www.libpng.org/pub/png/documents/>. It is technically equivalent
876to the PNG specification (second edition) but has some additional material.
877
878The PNG-1.0 specification is available
879as RFC 2083 <http://www.libpng.org/pub/png/documents/> and as a
880W3C Recommendation <http://www.w3.org/TR/REC.png.html>.
881
882Some additional chunks are described in the special-purpose public chunks
883documents at <http://www.libpng.org/pub/png/documents/>.
884
885Other information
886about PNG, and the latest version of libpng, can be found at the PNG home
887page, <http://www.libpng.org/pub/png/>.
888
889Most users will not have to modify the library significantly; advanced
890users may want to modify it more. All attempts were made to make it as
891complete as possible, while keeping the code easy to understand.
892Currently, this library only supports C. Support for other languages
893is being considered.
894
895Libpng has been designed to handle multiple sessions at one time,
896to be easily modifiable, to be portable to the vast majority of
897machines (ANSI, K&R, 16-, 32-, and 64-bit) available, and to be easy
898to use. The ultimate goal of libpng is to promote the acceptance of
899the PNG file format in whatever way possible. While there is still
900work to be done (see the TODO file), libpng should cover the
901majority of the needs of its users.
902
903Libpng uses zlib for its compression and decompression of PNG files.
904Further information about zlib, and the latest version of zlib, can
905be found at the zlib home page, <http://www.info-zip.org/pub/infozip/zlib/>.
906The zlib compression utility is a general purpose utility that is
907useful for more than PNG files, and can be used without libpng.
908See the documentation delivered with zlib for more details.
909You can usually find the source files for the zlib utility wherever you
910find the libpng source files.
911
912Libpng is thread safe, provided the threads are using different
913instances of the structures. Each thread should have its own
914png_struct and png_info instances, and thus its own image.
915Libpng does not protect itself against two threads using the
916same instance of a structure.
917
918.SH II. Structures
919
920There are two main structures that are important to libpng, png_struct
921and png_info. The first, png_struct, is an internal structure that
922will not, for the most part, be used by a user except as the first
923variable passed to every libpng function call.
924
925The png_info structure is designed to provide information about the
926PNG file. At one time, the fields of png_info were intended to be
927directly accessible to the user. However, this tended to cause problems
928with applications using dynamically loaded libraries, and as a result
929a set of interface functions for png_info (the png_get_*() and png_set_*()
930functions) was developed. The fields of png_info are still available for
931older applications, but it is suggested that applications use the new
932interfaces if at all possible.
933
934Applications that do make direct access to the members of png_struct (except
935for png_ptr->jmpbuf) must be recompiled whenever the library is updated,
936and applications that make direct access to the members of png_info must
937be recompiled if they were compiled or loaded with libpng version 1.0.6,
938in which the members were in a different order. In version 1.0.7, the
939members of the png_info structure reverted to the old order, as they were
940in versions 0.97c through 1.0.5. Starting with version 2.0.0, both
941structures are going to be hidden, and the contents of the structures will
942only be accessible through the png_get/png_set functions.
943
944The png.h header file is an invaluable reference for programming with libpng.
945And while I'm on the topic, make sure you include the libpng header file:
946
947#include <png.h>
948
949.SH III. Reading
950
951We'll now walk you through the possible functions to call when reading
952in a PNG file sequentially, briefly explaining the syntax and purpose
953of each one. See example.c and png.h for more detail. While
954progressive reading is covered in the next section, you will still
955need some of the functions discussed in this section to read a PNG
956file.
957
958.SS Setup
959
960You will want to do the I/O initialization(*) before you get into libpng,
961so if it doesn't work, you don't have much to undo. Of course, you
962will also want to insure that you are, in fact, dealing with a PNG
963file. Libpng provides a simple check to see if a file is a PNG file.
964To use it, pass in the first 1 to 8 bytes of the file to the function
965png_sig_cmp(), and it will return 0 if the bytes match the corresponding
966bytes of the PNG signature, or nonzero otherwise. Of course, the more bytes
967you pass in, the greater the accuracy of the prediction.
968
969If you are intending to keep the file pointer open for use in libpng,
970you must ensure you don't read more than 8 bytes from the beginning
971of the file, and you also have to make a call to png_set_sig_bytes_read()
972with the number of bytes you read from the beginning. Libpng will
973then only check the bytes (if any) that your program didn't read.
974
975(*): If you are not using the standard I/O functions, you will need
976to replace them with custom functions. See the discussion under
977Customizing libpng.
978
979
980 FILE *fp = fopen(file_name, "rb");
981 if (!fp)
982 {
983 return (ERROR);
984 }
985 fread(header, 1, number, fp);
986 is_png = !png_sig_cmp(header, 0, number);
987 if (!is_png)
988 {
989 return (NOT_PNG);
990 }
991
992
993Next, png_struct and png_info need to be allocated and initialized. In
994order to ensure that the size of these structures is correct even with a
995dynamically linked libpng, there are functions to initialize and
996allocate the structures. We also pass the library version, optional
997pointers to error handling functions, and a pointer to a data struct for
998use by the error functions, if necessary (the pointer and functions can
999be NULL if the default error handlers are to be used). See the section
1000on Changes to Libpng below regarding the old initialization functions.
1001The structure allocation functions quietly return NULL if they fail to
1002create the structure, so your application should check for that.
1003
1004 png_structp png_ptr = png_create_read_struct
1005 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
1006 user_error_fn, user_warning_fn);
1007 if (!png_ptr)
1008 return (ERROR);
1009
1010 png_infop info_ptr = png_create_info_struct(png_ptr);
1011 if (!info_ptr)
1012 {
1013 png_destroy_read_struct(&png_ptr,
1014 (png_infopp)NULL, (png_infopp)NULL);
1015 return (ERROR);
1016 }
1017
1018 png_infop end_info = png_create_info_struct(png_ptr);
1019 if (!end_info)
1020 {
1021 png_destroy_read_struct(&png_ptr, &info_ptr,
1022 (png_infopp)NULL);
1023 return (ERROR);
1024 }
1025
1026If you want to use your own memory allocation routines,
1027define PNG_USER_MEM_SUPPORTED and use
1028png_create_read_struct_2() instead of png_create_read_struct():
1029
1030 png_structp png_ptr = png_create_read_struct_2
1031 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
1032 user_error_fn, user_warning_fn, (png_voidp)
1033 user_mem_ptr, user_malloc_fn, user_free_fn);
1034
1035The error handling routines passed to png_create_read_struct()
1036and the memory alloc/free routines passed to png_create_struct_2()
1037are only necessary if you are not using the libpng supplied error
1038handling and memory alloc/free functions.
1039
1040When libpng encounters an error, it expects to longjmp back
1041to your routine. Therefore, you will need to call setjmp and pass
1042your png_jmpbuf(png_ptr). If you read the file from different
1043routines, you will need to update the jmpbuf field every time you enter
1044a new routine that will call a png_*() function.
1045
1046See your documentation of setjmp/longjmp for your compiler for more
1047information on setjmp/longjmp. See the discussion on libpng error
1048handling in the Customizing Libpng section below for more information
1049on the libpng error handling. If an error occurs, and libpng longjmp's
1050back to your setjmp, you will want to call png_destroy_read_struct() to
1051free any memory.
1052
1053 if (setjmp(png_jmpbuf(png_ptr)))
1054 {
1055 png_destroy_read_struct(&png_ptr, &info_ptr,
1056 &end_info);
1057 fclose(fp);
1058 return (ERROR);
1059 }
1060
1061If you would rather avoid the complexity of setjmp/longjmp issues,
1062you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case
1063errors will result in a call to PNG_ABORT() which defaults to abort().
1064
1065Now you need to set up the input code. The default for libpng is to
1066use the C function fread(). If you use this, you will need to pass a
1067valid FILE * in the function png_init_io(). Be sure that the file is
1068opened in binary mode. If you wish to handle reading data in another
1069way, you need not call the png_init_io() function, but you must then
1070implement the libpng I/O methods discussed in the Customizing Libpng
1071section below.
1072
1073 png_init_io(png_ptr, fp);
1074
1075If you had previously opened the file and read any of the signature from
1076the beginning in order to see if this was a PNG file, you need to let
1077libpng know that there are some bytes missing from the start of the file.
1078
1079 png_set_sig_bytes(png_ptr, number);
1080
1081.SS Setting up callback code
1082
1083You can set up a callback function to handle any unknown chunks in the
1084input stream. You must supply the function
1085
1086 read_chunk_callback(png_ptr ptr,
1087 png_unknown_chunkp chunk);
1088 {
1089 /* The unknown chunk structure contains your
1090 chunk data, along with similar data for any other
1091 unknown chunks: */
1092
1093 png_byte name[5];
1094 png_byte *data;
1095 png_size_t size;
1096
1097 /* Note that libpng has already taken care of
1098 the CRC handling */
1099
1100 /* put your code here. Search for your chunk in the
1101 unknown chunk structure, process it, and return one
1102 of the following: */
1103
1104 return (-n); /* chunk had an error */
1105 return (0); /* did not recognize */
1106 return (n); /* success */
1107 }
1108
1109(You can give your function another name that you like instead of
1110"read_chunk_callback")
1111
1112To inform libpng about your function, use
1113
1114 png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr,
1115 read_chunk_callback);
1116
1117This names not only the callback function, but also a user pointer that
1118you can retrieve with
1119
1120 png_get_user_chunk_ptr(png_ptr);
1121
1122If you call the png_set_read_user_chunk_fn() function, then all unknown
1123chunks will be saved when read, in case your callback function will need
1124one or more of them. This behavior can be changed with the
1125png_set_keep_unknown_chunks() function, described below.
1126
1127At this point, you can set up a callback function that will be
1128called after each row has been read, which you can use to control
1129a progress meter or the like. It's demonstrated in pngtest.c.
1130You must supply a function
1131
1132 void read_row_callback(png_ptr ptr, png_uint_32 row,
1133 int pass);
1134 {
1135 /* put your code here */
1136 }
1137
1138(You can give it another name that you like instead of "read_row_callback")
1139
1140To inform libpng about your function, use
1141
1142 png_set_read_status_fn(png_ptr, read_row_callback);
1143
1144.SS Width and height limits
1145
1146The PNG specification allows the width and height of an image to be as
1147large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns.
1148Since very few applications really need to process such large images,
1149we have imposed an arbitrary 1-million limit on rows and columns.
1150Larger images will be rejected immediately with a png_error() call. If
1151you wish to override this limit, you can use
1152
1153 png_set_user_limits(png_ptr, width_max, height_max);
1154
1155to set your own limits, or use width_max = height_max = 0x7fffffffL
1156to allow all valid dimensions (libpng may reject some very large images
1157anyway because of potential buffer overflow conditions).
1158
1159You should put this statement after you create the PNG structure and
1160before calling png_read_info(), png_read_png(), or png_process_data().
1161If you need to retrieve the limits that are being applied, use
1162
1163 width_max = png_get_user_width_max(png_ptr);
1164 height_max = png_get_user_height_max(png_ptr);
1165
1166.SS Unknown-chunk handling
1167
1168Now you get to set the way the library processes unknown chunks in the
1169input PNG stream. Both known and unknown chunks will be read. Normal
1170behavior is that known chunks will be parsed into information in
The Android Open Source Project4215dd12009-03-09 11:52:12 -07001171various info_ptr members while unknown chunks will be discarded. This
1172behavior can be wasteful if your application will never use some known
1173chunk types. To change this, you can call:
The Android Open Source Project893912b2009-03-03 19:30:05 -08001174
1175 png_set_keep_unknown_chunks(png_ptr, keep,
1176 chunk_list, num_chunks);
1177 keep - 0: default unknown chunk handling
1178 1: ignore; do not keep
1179 2: keep only if safe-to-copy
1180 3: keep even if unsafe-to-copy
1181 You can use these definitions:
1182 PNG_HANDLE_CHUNK_AS_DEFAULT 0
1183 PNG_HANDLE_CHUNK_NEVER 1
1184 PNG_HANDLE_CHUNK_IF_SAFE 2
1185 PNG_HANDLE_CHUNK_ALWAYS 3
1186 chunk_list - list of chunks affected (a byte string,
1187 five bytes per chunk, NULL or '\0' if
1188 num_chunks is 0)
1189 num_chunks - number of chunks affected; if 0, all
1190 unknown chunks are affected. If nonzero,
1191 only the chunks in the list are affected
1192
1193Unknown chunks declared in this way will be saved as raw data onto a
1194list of png_unknown_chunk structures. If a chunk that is normally
1195known to libpng is named in the list, it will be handled as unknown,
1196according to the "keep" directive. If a chunk is named in successive
1197instances of png_set_keep_unknown_chunks(), the final instance will
1198take precedence. The IHDR and IEND chunks should not be named in
1199chunk_list; if they are, libpng will process them normally anyway.
1200
1201Here is an example of the usage of png_set_keep_unknown_chunks(),
1202where the private "vpAg" chunk will later be processed by a user chunk
1203callback function:
1204
1205 png_byte vpAg[5]={118, 112, 65, 103, (png_byte) '\0'};
1206
1207 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
1208 png_byte unused_chunks[]=
1209 {
1210 104, 73, 83, 84, (png_byte) '\0', /* hIST */
1211 105, 84, 88, 116, (png_byte) '\0', /* iTXt */
1212 112, 67, 65, 76, (png_byte) '\0', /* pCAL */
1213 115, 67, 65, 76, (png_byte) '\0', /* sCAL */
1214 115, 80, 76, 84, (png_byte) '\0', /* sPLT */
1215 116, 73, 77, 69, (png_byte) '\0', /* tIME */
1216 };
1217 #endif
1218
1219 ...
1220
1221 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
1222 /* ignore all unknown chunks: */
1223 png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0);
1224 /* except for vpAg: */
1225 png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1);
1226 /* also ignore unused known chunks: */
1227 png_set_keep_unknown_chunks(read_ptr, 1, unused_chunks,
1228 (int)sizeof(unused_chunks)/5);
1229 #endif
1230
1231
1232.SS The high-level read interface
1233
1234At this point there are two ways to proceed; through the high-level
1235read interface, or through a sequence of low-level read operations.
1236You can use the high-level interface if (a) you are willing to read
1237the entire image into memory, and (b) the input transformations
1238you want to do are limited to the following set:
1239
1240 PNG_TRANSFORM_IDENTITY No transformation
1241 PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to
1242 8 bits
1243 PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel
1244 PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit
1245 samples to bytes
1246 PNG_TRANSFORM_PACKSWAP Change order of packed
1247 pixels to LSB first
1248 PNG_TRANSFORM_EXPAND Perform set_expand()
1249 PNG_TRANSFORM_INVERT_MONO Invert monochrome images
1250 PNG_TRANSFORM_SHIFT Normalize pixels to the
1251 sBIT depth
1252 PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA
1253 to BGRA
1254 PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA
1255 to AG
1256 PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity
1257 to transparency
1258 PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples
1259
1260(This excludes setting a background color, doing gamma transformation,
1261dithering, and setting filler.) If this is the case, simply do this:
1262
1263 png_read_png(png_ptr, info_ptr, png_transforms, NULL)
1264
1265where png_transforms is an integer containing the bitwise OR of
1266some set of transformation flags. This call is equivalent to png_read_info(),
1267followed the set of transformations indicated by the transform mask,
1268then png_read_image(), and finally png_read_end().
1269
1270(The final parameter of this call is not yet used. Someday it might point
1271to transformation parameters required by some future input transform.)
1272
1273You must use png_transforms and not call any png_set_transform() functions
1274when you use png_read_png().
1275
1276After you have called png_read_png(), you can retrieve the image data
1277with
1278
1279 row_pointers = png_get_rows(png_ptr, info_ptr);
1280
1281where row_pointers is an array of pointers to the pixel data for each row:
1282
1283 png_bytep row_pointers[height];
1284
1285If you know your image size and pixel size ahead of time, you can allocate
1286row_pointers prior to calling png_read_png() with
1287
1288 if (height > PNG_UINT_32_MAX/png_sizeof(png_byte))
1289 png_error (png_ptr,
1290 "Image is too tall to process in memory");
1291 if (width > PNG_UINT_32_MAX/pixel_size)
1292 png_error (png_ptr,
1293 "Image is too wide to process in memory");
1294 row_pointers = png_malloc(png_ptr,
1295 height*png_sizeof(png_bytep));
1296 for (int i=0; i<height, i++)
The Android Open Source Project4215dd12009-03-09 11:52:12 -07001297 row_pointers[i]=NULL; /* security precaution */
1298 for (int i=0; i<height, i++)
The Android Open Source Project893912b2009-03-03 19:30:05 -08001299 row_pointers[i]=png_malloc(png_ptr,
1300 width*pixel_size);
1301 png_set_rows(png_ptr, info_ptr, &row_pointers);
1302
1303Alternatively you could allocate your image in one big block and define
1304row_pointers[i] to point into the proper places in your block.
1305
1306If you use png_set_rows(), the application is responsible for freeing
1307row_pointers (and row_pointers[i], if they were separately allocated).
1308
1309If you don't allocate row_pointers ahead of time, png_read_png() will
1310do it, and it'll be free'ed when you call png_destroy_*().
1311
1312.SS The low-level read interface
1313
1314If you are going the low-level route, you are now ready to read all
1315the file information up to the actual image data. You do this with a
1316call to png_read_info().
1317
1318 png_read_info(png_ptr, info_ptr);
1319
1320This will process all chunks up to but not including the image data.
1321
1322.SS Querying the info structure
1323
1324Functions are used to get the information from the info_ptr once it
1325has been read. Note that these fields may not be completely filled
1326in until png_read_end() has read the chunk data following the image.
1327
1328 png_get_IHDR(png_ptr, info_ptr, &width, &height,
1329 &bit_depth, &color_type, &interlace_type,
1330 &compression_type, &filter_method);
1331
1332 width - holds the width of the image
1333 in pixels (up to 2^31).
1334 height - holds the height of the image
1335 in pixels (up to 2^31).
1336 bit_depth - holds the bit depth of one of the
1337 image channels. (valid values are
1338 1, 2, 4, 8, 16 and depend also on
1339 the color_type. See also
1340 significant bits (sBIT) below).
1341 color_type - describes which color/alpha channels
1342 are present.
1343 PNG_COLOR_TYPE_GRAY
1344 (bit depths 1, 2, 4, 8, 16)
1345 PNG_COLOR_TYPE_GRAY_ALPHA
1346 (bit depths 8, 16)
1347 PNG_COLOR_TYPE_PALETTE
1348 (bit depths 1, 2, 4, 8)
1349 PNG_COLOR_TYPE_RGB
1350 (bit_depths 8, 16)
1351 PNG_COLOR_TYPE_RGB_ALPHA
1352 (bit_depths 8, 16)
1353
1354 PNG_COLOR_MASK_PALETTE
1355 PNG_COLOR_MASK_COLOR
1356 PNG_COLOR_MASK_ALPHA
1357
1358 filter_method - (must be PNG_FILTER_TYPE_BASE
1359 for PNG 1.0, and can also be
1360 PNG_INTRAPIXEL_DIFFERENCING if
1361 the PNG datastream is embedded in
1362 a MNG-1.0 datastream)
1363 compression_type - (must be PNG_COMPRESSION_TYPE_BASE
1364 for PNG 1.0)
1365 interlace_type - (PNG_INTERLACE_NONE or
1366 PNG_INTERLACE_ADAM7)
1367 Any or all of interlace_type, compression_type, of
1368 filter_method can be NULL if you are
1369 not interested in their values.
1370
1371 channels = png_get_channels(png_ptr, info_ptr);
1372 channels - number of channels of info for the
1373 color type (valid values are 1 (GRAY,
1374 PALETTE), 2 (GRAY_ALPHA), 3 (RGB),
1375 4 (RGB_ALPHA or RGB + filler byte))
1376 rowbytes = png_get_rowbytes(png_ptr, info_ptr);
1377 rowbytes - number of bytes needed to hold a row
1378
1379 signature = png_get_signature(png_ptr, info_ptr);
1380 signature - holds the signature read from the
1381 file (if any). The data is kept in
1382 the same offset it would be if the
1383 whole signature were read (i.e. if an
1384 application had already read in 4
1385 bytes of signature before starting
1386 libpng, the remaining 4 bytes would
1387 be in signature[4] through signature[7]
1388 (see png_set_sig_bytes())).
1389
1390
1391 width = png_get_image_width(png_ptr,
1392 info_ptr);
1393 height = png_get_image_height(png_ptr,
1394 info_ptr);
1395 bit_depth = png_get_bit_depth(png_ptr,
1396 info_ptr);
1397 color_type = png_get_color_type(png_ptr,
1398 info_ptr);
1399 filter_method = png_get_filter_type(png_ptr,
1400 info_ptr);
1401 compression_type = png_get_compression_type(png_ptr,
1402 info_ptr);
1403 interlace_type = png_get_interlace_type(png_ptr,
1404 info_ptr);
1405
1406
1407These are also important, but their validity depends on whether the chunk
1408has been read. The png_get_valid(png_ptr, info_ptr, PNG_INFO_<chunk>) and
1409png_get_<chunk>(png_ptr, info_ptr, ...) functions return non-zero if the
1410data has been read, or zero if it is missing. The parameters to the
1411png_get_<chunk> are set directly if they are simple data types, or a pointer
1412into the info_ptr is returned for any complex types.
1413
1414 png_get_PLTE(png_ptr, info_ptr, &palette,
1415 &num_palette);
1416 palette - the palette for the file
1417 (array of png_color)
1418 num_palette - number of entries in the palette
1419
1420 png_get_gAMA(png_ptr, info_ptr, &gamma);
1421 gamma - the gamma the file is written
1422 at (PNG_INFO_gAMA)
1423
1424 png_get_sRGB(png_ptr, info_ptr, &srgb_intent);
1425 srgb_intent - the rendering intent (PNG_INFO_sRGB)
1426 The presence of the sRGB chunk
1427 means that the pixel data is in the
1428 sRGB color space. This chunk also
1429 implies specific values of gAMA and
1430 cHRM.
1431
1432 png_get_iCCP(png_ptr, info_ptr, &name,
1433 &compression_type, &profile, &proflen);
1434 name - The profile name.
1435 compression - The compression type; always
1436 PNG_COMPRESSION_TYPE_BASE for PNG 1.0.
1437 You may give NULL to this argument to
1438 ignore it.
1439 profile - International Color Consortium color
1440 profile data. May contain NULs.
1441 proflen - length of profile data in bytes.
1442
1443 png_get_sBIT(png_ptr, info_ptr, &sig_bit);
1444 sig_bit - the number of significant bits for
1445 (PNG_INFO_sBIT) each of the gray,
1446 red, green, and blue channels,
1447 whichever are appropriate for the
1448 given color type (png_color_16)
1449
1450 png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans,
1451 &trans_values);
1452 trans - array of transparent entries for
1453 palette (PNG_INFO_tRNS)
1454 trans_values - graylevel or color sample values of
1455 the single transparent color for
1456 non-paletted images (PNG_INFO_tRNS)
1457 num_trans - number of transparent entries
1458 (PNG_INFO_tRNS)
1459
1460 png_get_hIST(png_ptr, info_ptr, &hist);
1461 (PNG_INFO_hIST)
1462 hist - histogram of palette (array of
1463 png_uint_16)
1464
1465 png_get_tIME(png_ptr, info_ptr, &mod_time);
1466 mod_time - time image was last modified
1467 (PNG_VALID_tIME)
1468
1469 png_get_bKGD(png_ptr, info_ptr, &background);
1470 background - background color (PNG_VALID_bKGD)
1471 valid 16-bit red, green and blue
1472 values, regardless of color_type
1473
1474 num_comments = png_get_text(png_ptr, info_ptr,
1475 &text_ptr, &num_text);
1476 num_comments - number of comments
1477 text_ptr - array of png_text holding image
1478 comments
1479 text_ptr[i].compression - type of compression used
1480 on "text" PNG_TEXT_COMPRESSION_NONE
1481 PNG_TEXT_COMPRESSION_zTXt
1482 PNG_ITXT_COMPRESSION_NONE
1483 PNG_ITXT_COMPRESSION_zTXt
1484 text_ptr[i].key - keyword for comment. Must contain
1485 1-79 characters.
1486 text_ptr[i].text - text comments for current
1487 keyword. Can be empty.
1488 text_ptr[i].text_length - length of text string,
1489 after decompression, 0 for iTXt
1490 text_ptr[i].itxt_length - length of itxt string,
1491 after decompression, 0 for tEXt/zTXt
1492 text_ptr[i].lang - language of comment (empty
1493 string for unknown).
1494 text_ptr[i].lang_key - keyword in UTF-8
1495 (empty string for unknown).
1496 num_text - number of comments (same as
1497 num_comments; you can put NULL here
1498 to avoid the duplication)
1499 Note while png_set_text() will accept text, language,
1500 and translated keywords that can be NULL pointers, the
1501 structure returned by png_get_text will always contain
1502 regular zero-terminated C strings. They might be
1503 empty strings but they will never be NULL pointers.
1504
1505 num_spalettes = png_get_sPLT(png_ptr, info_ptr,
1506 &palette_ptr);
1507 palette_ptr - array of palette structures holding
1508 contents of one or more sPLT chunks
1509 read.
1510 num_spalettes - number of sPLT chunks read.
1511
1512 png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y,
1513 &unit_type);
1514 offset_x - positive offset from the left edge
1515 of the screen
1516 offset_y - positive offset from the top edge
1517 of the screen
1518 unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER
1519
1520 png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y,
1521 &unit_type);
1522 res_x - pixels/unit physical resolution in
1523 x direction
1524 res_y - pixels/unit physical resolution in
1525 x direction
1526 unit_type - PNG_RESOLUTION_UNKNOWN,
1527 PNG_RESOLUTION_METER
1528
1529 png_get_sCAL(png_ptr, info_ptr, &unit, &width,
1530 &height)
1531 unit - physical scale units (an integer)
1532 width - width of a pixel in physical scale units
1533 height - height of a pixel in physical scale units
1534 (width and height are doubles)
1535
1536 png_get_sCAL_s(png_ptr, info_ptr, &unit, &width,
1537 &height)
1538 unit - physical scale units (an integer)
1539 width - width of a pixel in physical scale units
1540 height - height of a pixel in physical scale units
1541 (width and height are strings like "2.54")
1542
1543 num_unknown_chunks = png_get_unknown_chunks(png_ptr,
1544 info_ptr, &unknowns)
1545 unknowns - array of png_unknown_chunk
1546 structures holding unknown chunks
1547 unknowns[i].name - name of unknown chunk
1548 unknowns[i].data - data of unknown chunk
1549 unknowns[i].size - size of unknown chunk's data
1550 unknowns[i].location - position of chunk in file
1551
1552 The value of "i" corresponds to the order in which the
1553 chunks were read from the PNG file or inserted with the
1554 png_set_unknown_chunks() function.
1555
1556The data from the pHYs chunk can be retrieved in several convenient
1557forms:
1558
1559 res_x = png_get_x_pixels_per_meter(png_ptr,
1560 info_ptr)
1561 res_y = png_get_y_pixels_per_meter(png_ptr,
1562 info_ptr)
1563 res_x_and_y = png_get_pixels_per_meter(png_ptr,
1564 info_ptr)
1565 res_x = png_get_x_pixels_per_inch(png_ptr,
1566 info_ptr)
1567 res_y = png_get_y_pixels_per_inch(png_ptr,
1568 info_ptr)
1569 res_x_and_y = png_get_pixels_per_inch(png_ptr,
1570 info_ptr)
1571 aspect_ratio = png_get_pixel_aspect_ratio(png_ptr,
1572 info_ptr)
1573
1574 (Each of these returns 0 [signifying "unknown"] if
1575 the data is not present or if res_x is 0;
1576 res_x_and_y is 0 if res_x != res_y)
1577
1578The data from the oFFs chunk can be retrieved in several convenient
1579forms:
1580
1581 x_offset = png_get_x_offset_microns(png_ptr, info_ptr);
1582 y_offset = png_get_y_offset_microns(png_ptr, info_ptr);
1583 x_offset = png_get_x_offset_inches(png_ptr, info_ptr);
1584 y_offset = png_get_y_offset_inches(png_ptr, info_ptr);
1585
1586 (Each of these returns 0 [signifying "unknown" if both
1587 x and y are 0] if the data is not present or if the
1588 chunk is present but the unit is the pixel)
1589
1590For more information, see the png_info definition in png.h and the
1591PNG specification for chunk contents. Be careful with trusting
1592rowbytes, as some of the transformations could increase the space
1593needed to hold a row (expand, filler, gray_to_rgb, etc.).
1594See png_read_update_info(), below.
1595
1596A quick word about text_ptr and num_text. PNG stores comments in
1597keyword/text pairs, one pair per chunk, with no limit on the number
1598of text chunks, and a 2^31 byte limit on their size. While there are
1599suggested keywords, there is no requirement to restrict the use to these
1600strings. It is strongly suggested that keywords and text be sensible
1601to humans (that's the point), so don't use abbreviations. Non-printing
1602symbols are not allowed. See the PNG specification for more details.
1603There is also no requirement to have text after the keyword.
1604
1605Keywords should be limited to 79 Latin-1 characters without leading or
1606trailing spaces, but non-consecutive spaces are allowed within the
1607keyword. It is possible to have the same keyword any number of times.
1608The text_ptr is an array of png_text structures, each holding a
1609pointer to a language string, a pointer to a keyword and a pointer to
1610a text string. The text string, language code, and translated
1611keyword may be empty or NULL pointers. The keyword/text
1612pairs are put into the array in the order that they are received.
1613However, some or all of the text chunks may be after the image, so, to
1614make sure you have read all the text chunks, don't mess with these
1615until after you read the stuff after the image. This will be
1616mentioned again below in the discussion that goes with png_read_end().
1617
1618.SS Input transformations
1619
1620After you've read the header information, you can set up the library
1621to handle any special transformations of the image data. The various
1622ways to transform the data will be described in the order that they
1623should occur. This is important, as some of these change the color
1624type and/or bit depth of the data, and some others only work on
1625certain color types and bit depths. Even though each transformation
1626checks to see if it has data that it can do something with, you should
1627make sure to only enable a transformation if it will be valid for the
1628data. For example, don't swap red and blue on grayscale data.
1629
1630The colors used for the background and transparency values should be
1631supplied in the same format/depth as the current image data. They
1632are stored in the same format/depth as the image data in a bKGD or tRNS
1633chunk, so this is what libpng expects for this data. The colors are
1634transformed to keep in sync with the image data when an application
1635calls the png_read_update_info() routine (see below).
1636
1637Data will be decoded into the supplied row buffers packed into bytes
1638unless the library has been told to transform it into another format.
1639For example, 4 bit/pixel paletted or grayscale data will be returned
16402 pixels/byte with the leftmost pixel in the high-order bits of the
1641byte, unless png_set_packing() is called. 8-bit RGB data will be stored
1642in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha()
1643is called to insert filler bytes, either before or after each RGB triplet.
164416-bit RGB data will be returned RRGGBB RRGGBB, with the most significant
1645byte of the color value first, unless png_set_strip_16() is called to
1646transform it to regular RGB RGB triplets, or png_set_filler() or
1647png_set_add alpha() is called to insert filler bytes, either before or
1648after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data can
1649be modified with
1650png_set_filler(), png_set_add_alpha(), or png_set_strip_16().
1651
1652The following code transforms grayscale images of less than 8 to 8 bits,
1653changes paletted images to RGB, and adds a full alpha channel if there is
1654transparency information in a tRNS chunk. This is most useful on
1655grayscale images with bit depths of 2 or 4 or if there is a multiple-image
1656viewing application that wishes to treat all images in the same way.
1657
1658 if (color_type == PNG_COLOR_TYPE_PALETTE)
1659 png_set_palette_to_rgb(png_ptr);
1660
1661 if (color_type == PNG_COLOR_TYPE_GRAY &&
1662 bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr);
1663
1664 if (png_get_valid(png_ptr, info_ptr,
1665 PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr);
1666
1667These three functions are actually aliases for png_set_expand(), added
1668in libpng version 1.0.4, with the function names expanded to improve code
1669readability. In some future version they may actually do different
1670things.
1671
1672As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was
1673added. It expands the sample depth without changing tRNS to alpha.
1674At the same time, png_set_gray_1_2_4_to_8() was deprecated, and it
1675will be removed from a future version.
1676
1677
1678PNG can have files with 16 bits per channel. If you only can handle
16798 bits per channel, this will strip the pixels down to 8 bit.
1680
1681 if (bit_depth == 16)
1682 png_set_strip_16(png_ptr);
1683
1684If, for some reason, you don't need the alpha channel on an image,
1685and you want to remove it rather than combining it with the background
1686(but the image author certainly had in mind that you *would* combine
1687it with the background, so that's what you should probably do):
1688
1689 if (color_type & PNG_COLOR_MASK_ALPHA)
1690 png_set_strip_alpha(png_ptr);
1691
1692In PNG files, the alpha channel in an image
1693is the level of opacity. If you need the alpha channel in an image to
1694be the level of transparency instead of opacity, you can invert the
1695alpha channel (or the tRNS chunk data) after it's read, so that 0 is
1696fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit
1697images) is fully transparent, with
1698
1699 png_set_invert_alpha(png_ptr);
1700
1701PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
1702they can, resulting in, for example, 8 pixels per byte for 1 bit
1703files. This code expands to 1 pixel per byte without changing the
1704values of the pixels:
1705
1706 if (bit_depth < 8)
1707 png_set_packing(png_ptr);
1708
1709PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels
1710stored in a PNG image have been "scaled" or "shifted" up to the next
1711higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to
17128 bits/sample in the range [0, 255]). However, it is also possible to
1713convert the PNG pixel data back to the original bit depth of the image.
1714This call reduces the pixels back down to the original bit depth:
1715
1716 png_color_8p sig_bit;
1717
1718 if (png_get_sBIT(png_ptr, info_ptr, &sig_bit))
1719 png_set_shift(png_ptr, sig_bit);
1720
1721PNG files store 3-color pixels in red, green, blue order. This code
1722changes the storage of the pixels to blue, green, red:
1723
1724 if (color_type == PNG_COLOR_TYPE_RGB ||
1725 color_type == PNG_COLOR_TYPE_RGB_ALPHA)
1726 png_set_bgr(png_ptr);
1727
1728PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them
1729into 4 or 8 bytes for windowing systems that need them in this format:
1730
1731 if (color_type == PNG_COLOR_TYPE_RGB)
1732 png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE);
1733
1734where "filler" is the 8 or 16-bit number to fill with, and the location is
1735either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether
1736you want the filler before the RGB or after. This transformation
1737does not affect images that already have full alpha channels. To add an
1738opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which
1739will generate RGBA pixels.
1740
1741Note that png_set_filler() does not change the color type. If you want
1742to do that, you can add a true alpha channel with
1743
1744 if (color_type == PNG_COLOR_TYPE_RGB ||
1745 color_type == PNG_COLOR_TYPE_GRAY)
1746 png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER);
1747
1748where "filler" contains the alpha value to assign to each pixel.
1749This function was added in libpng-1.2.7.
1750
1751If you are reading an image with an alpha channel, and you need the
1752data as ARGB instead of the normal PNG format RGBA:
1753
1754 if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
1755 png_set_swap_alpha(png_ptr);
1756
1757For some uses, you may want a grayscale image to be represented as
1758RGB. This code will do that conversion:
1759
1760 if (color_type == PNG_COLOR_TYPE_GRAY ||
1761 color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
1762 png_set_gray_to_rgb(png_ptr);
1763
1764Conversely, you can convert an RGB or RGBA image to grayscale or grayscale
1765with alpha.
1766
1767 if (color_type == PNG_COLOR_TYPE_RGB ||
1768 color_type == PNG_COLOR_TYPE_RGB_ALPHA)
1769 png_set_rgb_to_gray_fixed(png_ptr, error_action,
1770 int red_weight, int green_weight);
1771
1772 error_action = 1: silently do the conversion
1773 error_action = 2: issue a warning if the original
1774 image has any pixel where
1775 red != green or red != blue
1776 error_action = 3: issue an error and abort the
1777 conversion if the original
1778 image has any pixel where
1779 red != green or red != blue
1780
1781 red_weight: weight of red component times 100000
1782 green_weight: weight of green component times 100000
1783 If either weight is negative, default
1784 weights (21268, 71514) are used.
1785
1786If you have set error_action = 1 or 2, you can
1787later check whether the image really was gray, after processing
1788the image rows, with the png_get_rgb_to_gray_status(png_ptr) function.
1789It will return a png_byte that is zero if the image was gray or
17901 if there were any non-gray pixels. bKGD and sBIT data
1791will be silently converted to grayscale, using the green channel
1792data, regardless of the error_action setting.
1793
1794With red_weight+green_weight<=100000,
1795the normalized graylevel is computed:
1796
1797 int rw = red_weight * 65536;
1798 int gw = green_weight * 65536;
1799 int bw = 65536 - (rw + gw);
1800 gray = (rw*red + gw*green + bw*blue)/65536;
1801
1802The default values approximate those recommended in the Charles
1803Poynton's Color FAQ, <http://www.inforamp.net/~poynton/>
1804Copyright (c) 1998-01-04 Charles Poynton <poynton at inforamp.net>
1805
1806 Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
1807
1808Libpng approximates this with
1809
1810 Y = 0.21268 * R + 0.7151 * G + 0.07217 * B
1811
1812which can be expressed with integers as
1813
1814 Y = (6969 * R + 23434 * G + 2365 * B)/32768
1815
1816The calculation is done in a linear colorspace, if the image gamma
1817is known.
1818
1819If you have a grayscale and you are using png_set_expand_depth(),
1820png_set_expand(), or png_set_gray_to_rgb to change to truecolor or to
1821a higher bit-depth, you must either supply the background color as a gray
1822value at the original file bit-depth (need_expand = 1) or else supply the
1823background color as an RGB triplet at the final, expanded bit depth
1824(need_expand = 0). Similarly, if you are reading a paletted image, you
1825must either supply the background color as a palette index (need_expand = 1)
1826or as an RGB triplet that may or may not be in the palette (need_expand = 0).
1827
1828 png_color_16 my_background;
1829 png_color_16p image_background;
1830
1831 if (png_get_bKGD(png_ptr, info_ptr, &image_background))
1832 png_set_background(png_ptr, image_background,
1833 PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
1834 else
1835 png_set_background(png_ptr, &my_background,
1836 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
1837
1838The png_set_background() function tells libpng to composite images
1839with alpha or simple transparency against the supplied background
1840color. If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid),
1841you may use this color, or supply another color more suitable for
1842the current display (e.g., the background color from a web page). You
1843need to tell libpng whether the color is in the gamma space of the
1844display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file
1845(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one
1846that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't
1847know why anyone would use this, but it's here).
1848
1849To properly display PNG images on any kind of system, the application needs
1850to know what the display gamma is. Ideally, the user will know this, and
1851the application will allow them to set it. One method of allowing the user
1852to set the display gamma separately for each system is to check for a
1853SCREEN_GAMMA or DISPLAY_GAMMA environment variable, which will hopefully be
1854correctly set.
1855
1856Note that display_gamma is the overall gamma correction required to produce
1857pleasing results, which depends on the lighting conditions in the surrounding
1858environment. In a dim or brightly lit room, no compensation other than
1859the physical gamma exponent of the monitor is needed, while in a dark room
1860a slightly smaller exponent is better.
1861
1862 double gamma, screen_gamma;
1863
1864 if (/* We have a user-defined screen
1865 gamma value */)
1866 {
1867 screen_gamma = user_defined_screen_gamma;
1868 }
1869 /* One way that applications can share the same
1870 screen gamma value */
1871 else if ((gamma_str = getenv("SCREEN_GAMMA"))
1872 != NULL)
1873 {
1874 screen_gamma = (double)atof(gamma_str);
1875 }
1876 /* If we don't have another value */
1877 else
1878 {
1879 screen_gamma = 2.2; /* A good guess for a
1880 PC monitor in a bright office or a dim room */
1881 screen_gamma = 2.0; /* A good guess for a
1882 PC monitor in a dark room */
1883 screen_gamma = 1.7 or 1.0; /* A good
1884 guess for Mac systems */
1885 }
1886
1887The png_set_gamma() function handles gamma transformations of the data.
1888Pass both the file gamma and the current screen_gamma. If the file does
1889not have a gamma value, you can pass one anyway if you have an idea what
1890it is (usually 0.45455 is a good guess for GIF images on PCs). Note
1891that file gammas are inverted from screen gammas. See the discussions
1892on gamma in the PNG specification for an excellent description of what
1893gamma is, and why all applications should support it. It is strongly
1894recommended that PNG viewers support gamma correction.
1895
1896 if (png_get_gAMA(png_ptr, info_ptr, &gamma))
1897 png_set_gamma(png_ptr, screen_gamma, gamma);
1898 else
1899 png_set_gamma(png_ptr, screen_gamma, 0.45455);
1900
1901If you need to reduce an RGB file to a paletted file, or if a paletted
1902file has more entries then will fit on your screen, png_set_dither()
1903will do that. Note that this is a simple match dither that merely
1904finds the closest color available. This should work fairly well with
1905optimized palettes, and fairly badly with linear color cubes. If you
1906pass a palette that is larger then maximum_colors, the file will
1907reduce the number of colors in the palette so it will fit into
1908maximum_colors. If there is a histogram, it will use it to make
1909more intelligent choices when reducing the palette. If there is no
1910histogram, it may not do as good a job.
1911
1912 if (color_type & PNG_COLOR_MASK_COLOR)
1913 {
1914 if (png_get_valid(png_ptr, info_ptr,
1915 PNG_INFO_PLTE))
1916 {
1917 png_uint_16p histogram = NULL;
1918
1919 png_get_hIST(png_ptr, info_ptr,
1920 &histogram);
1921 png_set_dither(png_ptr, palette, num_palette,
1922 max_screen_colors, histogram, 1);
1923 }
1924 else
1925 {
1926 png_color std_color_cube[MAX_SCREEN_COLORS] =
1927 { ... colors ... };
1928
1929 png_set_dither(png_ptr, std_color_cube,
1930 MAX_SCREEN_COLORS, MAX_SCREEN_COLORS,
1931 NULL,0);
1932 }
1933 }
1934
1935PNG files describe monochrome as black being zero and white being one.
1936The following code will reverse this (make black be one and white be
1937zero):
1938
1939 if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY)
1940 png_set_invert_mono(png_ptr);
1941
1942This function can also be used to invert grayscale and gray-alpha images:
1943
1944 if (color_type == PNG_COLOR_TYPE_GRAY ||
1945 color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
1946 png_set_invert_mono(png_ptr);
1947
1948PNG files store 16 bit pixels in network byte order (big-endian,
1949ie. most significant bits first). This code changes the storage to the
1950other way (little-endian, i.e. least significant bits first, the
1951way PCs store them):
1952
1953 if (bit_depth == 16)
1954 png_set_swap(png_ptr);
1955
1956If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you
1957need to change the order the pixels are packed into bytes, you can use:
1958
1959 if (bit_depth < 8)
1960 png_set_packswap(png_ptr);
1961
1962Finally, you can write your own transformation function if none of
1963the existing ones meets your needs. This is done by setting a callback
1964with
1965
1966 png_set_read_user_transform_fn(png_ptr,
1967 read_transform_fn);
1968
1969You must supply the function
1970
1971 void read_transform_fn(png_ptr ptr, row_info_ptr
1972 row_info, png_bytep data)
1973
1974See pngtest.c for a working example. Your function will be called
1975after all of the other transformations have been processed.
1976
1977You can also set up a pointer to a user structure for use by your
1978callback function, and you can inform libpng that your transform
1979function will change the number of channels or bit depth with the
1980function
1981
1982 png_set_user_transform_info(png_ptr, user_ptr,
1983 user_depth, user_channels);
1984
1985The user's application, not libpng, is responsible for allocating and
1986freeing any memory required for the user structure.
1987
1988You can retrieve the pointer via the function
1989png_get_user_transform_ptr(). For example:
1990
1991 voidp read_user_transform_ptr =
1992 png_get_user_transform_ptr(png_ptr);
1993
1994The last thing to handle is interlacing; this is covered in detail below,
1995but you must call the function here if you want libpng to handle expansion
1996of the interlaced image.
1997
1998 number_of_passes = png_set_interlace_handling(png_ptr);
1999
2000After setting the transformations, libpng can update your png_info
2001structure to reflect any transformations you've requested with this
2002call. This is most useful to update the info structure's rowbytes
2003field so you can use it to allocate your image memory. This function
2004will also update your palette with the correct screen_gamma and
2005background if these have been given with the calls above.
2006
2007 png_read_update_info(png_ptr, info_ptr);
2008
2009After you call png_read_update_info(), you can allocate any
2010memory you need to hold the image. The row data is simply
2011raw byte data for all forms of images. As the actual allocation
2012varies among applications, no example will be given. If you
2013are allocating one large chunk, you will need to build an
2014array of pointers to each row, as it will be needed for some
2015of the functions below.
2016
2017.SS Reading image data
2018
2019After you've allocated memory, you can read the image data.
2020The simplest way to do this is in one function call. If you are
2021allocating enough memory to hold the whole image, you can just
2022call png_read_image() and libpng will read in all the image data
2023and put it in the memory area supplied. You will need to pass in
2024an array of pointers to each row.
2025
2026This function automatically handles interlacing, so you don't need
2027to call png_set_interlace_handling() or call this function multiple
2028times, or any of that other stuff necessary with png_read_rows().
2029
2030 png_read_image(png_ptr, row_pointers);
2031
2032where row_pointers is:
2033
2034 png_bytep row_pointers[height];
2035
2036You can point to void or char or whatever you use for pixels.
2037
2038If you don't want to read in the whole image at once, you can
2039use png_read_rows() instead. If there is no interlacing (check
2040interlace_type == PNG_INTERLACE_NONE), this is simple:
2041
2042 png_read_rows(png_ptr, row_pointers, NULL,
2043 number_of_rows);
2044
2045where row_pointers is the same as in the png_read_image() call.
2046
2047If you are doing this just one row at a time, you can do this with
2048a single row_pointer instead of an array of row_pointers:
2049
2050 png_bytep row_pointer = row;
2051 png_read_row(png_ptr, row_pointer, NULL);
2052
2053If the file is interlaced (interlace_type != 0 in the IHDR chunk), things
2054get somewhat harder. The only current (PNG Specification version 1.2)
2055interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7)
2056is a somewhat complicated 2D interlace scheme, known as Adam7, that
2057breaks down an image into seven smaller images of varying size, based
2058on an 8x8 grid.
2059
2060libpng can fill out those images or it can give them to you "as is".
2061If you want them filled out, there are two ways to do that. The one
2062mentioned in the PNG specification is to expand each pixel to cover
2063those pixels that have not been read yet (the "rectangle" method).
2064This results in a blocky image for the first pass, which gradually
2065smooths out as more pixels are read. The other method is the "sparkle"
2066method, where pixels are drawn only in their final locations, with the
2067rest of the image remaining whatever colors they were initialized to
2068before the start of the read. The first method usually looks better,
2069but tends to be slower, as there are more pixels to put in the rows.
2070
2071If you don't want libpng to handle the interlacing details, just call
2072png_read_rows() seven times to read in all seven images. Each of the
2073images is a valid image by itself, or they can all be combined on an
20748x8 grid to form a single image (although if you intend to combine them
2075you would be far better off using the libpng interlace handling).
2076
2077The first pass will return an image 1/8 as wide as the entire image
2078(every 8th column starting in column 0) and 1/8 as high as the original
2079(every 8th row starting in row 0), the second will be 1/8 as wide
2080(starting in column 4) and 1/8 as high (also starting in row 0). The
2081third pass will be 1/4 as wide (every 4th pixel starting in column 0) and
20821/8 as high (every 8th row starting in row 4), and the fourth pass will
2083be 1/4 as wide and 1/4 as high (every 4th column starting in column 2,
2084and every 4th row starting in row 0). The fifth pass will return an
2085image 1/2 as wide, and 1/4 as high (starting at column 0 and row 2),
2086while the sixth pass will be 1/2 as wide and 1/2 as high as the original
2087(starting in column 1 and row 0). The seventh and final pass will be as
2088wide as the original, and 1/2 as high, containing all of the odd
2089numbered scanlines. Phew!
2090
2091If you want libpng to expand the images, call this before calling
2092png_start_read_image() or png_read_update_info():
2093
2094 if (interlace_type == PNG_INTERLACE_ADAM7)
2095 number_of_passes
2096 = png_set_interlace_handling(png_ptr);
2097
2098This will return the number of passes needed. Currently, this
2099is seven, but may change if another interlace type is added.
2100This function can be called even if the file is not interlaced,
2101where it will return one pass.
2102
2103If you are not going to display the image after each pass, but are
2104going to wait until the entire image is read in, use the sparkle
2105effect. This effect is faster and the end result of either method
2106is exactly the same. If you are planning on displaying the image
2107after each pass, the "rectangle" effect is generally considered the
2108better looking one.
2109
2110If you only want the "sparkle" effect, just call png_read_rows() as
2111normal, with the third parameter NULL. Make sure you make pass over
2112the image number_of_passes times, and you don't change the data in the
2113rows between calls. You can change the locations of the data, just
2114not the data. Each pass only writes the pixels appropriate for that
2115pass, and assumes the data from previous passes is still valid.
2116
2117 png_read_rows(png_ptr, row_pointers, NULL,
2118 number_of_rows);
2119
2120If you only want the first effect (the rectangles), do the same as
2121before except pass the row buffer in the third parameter, and leave
2122the second parameter NULL.
2123
2124 png_read_rows(png_ptr, NULL, row_pointers,
2125 number_of_rows);
2126
2127.SS Finishing a sequential read
2128
2129After you are finished reading the image through the
2130low-level interface, you can finish reading the file. If you are
2131interested in comments or time, which may be stored either before or
2132after the image data, you should pass the separate png_info struct if
2133you want to keep the comments from before and after the image
2134separate. If you are not interested, you can pass NULL.
2135
2136 png_read_end(png_ptr, end_info);
2137
2138When you are done, you can free all memory allocated by libpng like this:
2139
2140 png_destroy_read_struct(&png_ptr, &info_ptr,
2141 &end_info);
2142
2143It is also possible to individually free the info_ptr members that
2144point to libpng-allocated storage with the following function:
2145
2146 png_free_data(png_ptr, info_ptr, mask, seq)
2147 mask - identifies data to be freed, a mask
2148 containing the bitwise OR of one or
2149 more of
2150 PNG_FREE_PLTE, PNG_FREE_TRNS,
2151 PNG_FREE_HIST, PNG_FREE_ICCP,
2152 PNG_FREE_PCAL, PNG_FREE_ROWS,
2153 PNG_FREE_SCAL, PNG_FREE_SPLT,
2154 PNG_FREE_TEXT, PNG_FREE_UNKN,
2155 or simply PNG_FREE_ALL
2156 seq - sequence number of item to be freed
2157 (-1 for all items)
2158
2159This function may be safely called when the relevant storage has
2160already been freed, or has not yet been allocated, or was allocated
2161by the user and not by libpng, and will in those
2162cases do nothing. The "seq" parameter is ignored if only one item
2163of the selected data type, such as PLTE, is allowed. If "seq" is not
2164-1, and multiple items are allowed for the data type identified in
2165the mask, such as text or sPLT, only the n'th item in the structure
2166is freed, where n is "seq".
2167
2168The default behavior is only to free data that was allocated internally
2169by libpng. This can be changed, so that libpng will not free the data,
2170or so that it will free data that was allocated by the user with png_malloc()
2171or png_zalloc() and passed in via a png_set_*() function, with
2172
2173 png_data_freer(png_ptr, info_ptr, freer, mask)
2174 mask - which data elements are affected
2175 same choices as in png_free_data()
2176 freer - one of
2177 PNG_DESTROY_WILL_FREE_DATA
2178 PNG_SET_WILL_FREE_DATA
2179 PNG_USER_WILL_FREE_DATA
2180
2181This function only affects data that has already been allocated.
2182You can call this function after reading the PNG data but before calling
2183any png_set_*() functions, to control whether the user or the png_set_*()
2184function is responsible for freeing any existing data that might be present,
2185and again after the png_set_*() functions to control whether the user
2186or png_destroy_*() is supposed to free the data. When the user assumes
2187responsibility for libpng-allocated data, the application must use
2188png_free() to free it, and when the user transfers responsibility to libpng
2189for data that the user has allocated, the user must have used png_malloc()
2190or png_zalloc() to allocate it.
2191
2192If you allocated your row_pointers in a single block, as suggested above in
2193the description of the high level read interface, you must not transfer
2194responsibility for freeing it to the png_set_rows or png_read_destroy function,
2195because they would also try to free the individual row_pointers[i].
2196
2197If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword
2198separately, do not transfer responsibility for freeing text_ptr to libpng,
2199because when libpng fills a png_text structure it combines these members with
2200the key member, and png_free_data() will free only text_ptr.key. Similarly,
2201if you transfer responsibility for free'ing text_ptr from libpng to your
2202application, your application must not separately free those members.
2203
2204The png_free_data() function will turn off the "valid" flag for anything
2205it frees. If you need to turn the flag off for a chunk that was freed by your
2206application instead of by libpng, you can use
2207
2208 png_set_invalid(png_ptr, info_ptr, mask);
2209 mask - identifies the chunks to be made invalid,
2210 containing the bitwise OR of one or
2211 more of
2212 PNG_INFO_gAMA, PNG_INFO_sBIT,
2213 PNG_INFO_cHRM, PNG_INFO_PLTE,
2214 PNG_INFO_tRNS, PNG_INFO_bKGD,
2215 PNG_INFO_hIST, PNG_INFO_pHYs,
2216 PNG_INFO_oFFs, PNG_INFO_tIME,
2217 PNG_INFO_pCAL, PNG_INFO_sRGB,
2218 PNG_INFO_iCCP, PNG_INFO_sPLT,
2219 PNG_INFO_sCAL, PNG_INFO_IDAT
2220
2221For a more compact example of reading a PNG image, see the file example.c.
2222
2223.SS Reading PNG files progressively
2224
2225The progressive reader is slightly different then the non-progressive
2226reader. Instead of calling png_read_info(), png_read_rows(), and
2227png_read_end(), you make one call to png_process_data(), which calls
2228callbacks when it has the info, a row, or the end of the image. You
2229set up these callbacks with png_set_progressive_read_fn(). You don't
2230have to worry about the input/output functions of libpng, as you are
2231giving the library the data directly in png_process_data(). I will
2232assume that you have read the section on reading PNG files above,
2233so I will only highlight the differences (although I will show
2234all of the code).
2235
2236png_structp png_ptr;
2237png_infop info_ptr;
2238
2239 /* An example code fragment of how you would
2240 initialize the progressive reader in your
2241 application. */
2242 int
2243 initialize_png_reader()
2244 {
2245 png_ptr = png_create_read_struct
2246 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
2247 user_error_fn, user_warning_fn);
2248 if (!png_ptr)
2249 return (ERROR);
2250 info_ptr = png_create_info_struct(png_ptr);
2251 if (!info_ptr)
2252 {
2253 png_destroy_read_struct(&png_ptr, (png_infopp)NULL,
2254 (png_infopp)NULL);
2255 return (ERROR);
2256 }
2257
2258 if (setjmp(png_jmpbuf(png_ptr)))
2259 {
2260 png_destroy_read_struct(&png_ptr, &info_ptr,
2261 (png_infopp)NULL);
2262 return (ERROR);
2263 }
2264
2265 /* This one's new. You can provide functions
2266 to be called when the header info is valid,
2267 when each row is completed, and when the image
2268 is finished. If you aren't using all functions,
2269 you can specify NULL parameters. Even when all
2270 three functions are NULL, you need to call
2271 png_set_progressive_read_fn(). You can use
2272 any struct as the user_ptr (cast to a void pointer
2273 for the function call), and retrieve the pointer
2274 from inside the callbacks using the function
2275
2276 png_get_progressive_ptr(png_ptr);
2277
2278 which will return a void pointer, which you have
2279 to cast appropriately.
2280 */
2281 png_set_progressive_read_fn(png_ptr, (void *)user_ptr,
2282 info_callback, row_callback, end_callback);
2283
2284 return 0;
2285 }
2286
2287 /* A code fragment that you call as you receive blocks
2288 of data */
2289 int
2290 process_data(png_bytep buffer, png_uint_32 length)
2291 {
2292 if (setjmp(png_jmpbuf(png_ptr)))
2293 {
2294 png_destroy_read_struct(&png_ptr, &info_ptr,
2295 (png_infopp)NULL);
2296 return (ERROR);
2297 }
2298
2299 /* This one's new also. Simply give it a chunk
2300 of data from the file stream (in order, of
2301 course). On machines with segmented memory
2302 models machines, don't give it any more than
2303 64K. The library seems to run fine with sizes
2304 of 4K. Although you can give it much less if
2305 necessary (I assume you can give it chunks of
2306 1 byte, I haven't tried less then 256 bytes
2307 yet). When this function returns, you may
2308 want to display any rows that were generated
2309 in the row callback if you don't already do
2310 so there.
2311 */
2312 png_process_data(png_ptr, info_ptr, buffer, length);
2313 return 0;
2314 }
2315
2316 /* This function is called (as set by
2317 png_set_progressive_read_fn() above) when enough data
2318 has been supplied so all of the header has been
2319 read.
2320 */
2321 void
2322 info_callback(png_structp png_ptr, png_infop info)
2323 {
2324 /* Do any setup here, including setting any of
2325 the transformations mentioned in the Reading
2326 PNG files section. For now, you _must_ call
2327 either png_start_read_image() or
2328 png_read_update_info() after all the
2329 transformations are set (even if you don't set
2330 any). You may start getting rows before
2331 png_process_data() returns, so this is your
2332 last chance to prepare for that.
2333 */
2334 }
2335
2336 /* This function is called when each row of image
2337 data is complete */
2338 void
2339 row_callback(png_structp png_ptr, png_bytep new_row,
2340 png_uint_32 row_num, int pass)
2341 {
2342 /* If the image is interlaced, and you turned
2343 on the interlace handler, this function will
2344 be called for every row in every pass. Some
2345 of these rows will not be changed from the
2346 previous pass. When the row is not changed,
2347 the new_row variable will be NULL. The rows
2348 and passes are called in order, so you don't
2349 really need the row_num and pass, but I'm
2350 supplying them because it may make your life
2351 easier.
2352
2353 For the non-NULL rows of interlaced images,
2354 you must call png_progressive_combine_row()
2355 passing in the row and the old row. You can
2356 call this function for NULL rows (it will just
2357 return) and for non-interlaced images (it just
2358 does the memcpy for you) if it will make the
2359 code easier. Thus, you can just do this for
2360 all cases:
2361 */
2362
2363 png_progressive_combine_row(png_ptr, old_row,
2364 new_row);
2365
2366 /* where old_row is what was displayed for
2367 previously for the row. Note that the first
2368 pass (pass == 0, really) will completely cover
2369 the old row, so the rows do not have to be
2370 initialized. After the first pass (and only
2371 for interlaced images), you will have to pass
2372 the current row, and the function will combine
2373 the old row and the new row.
2374 */
2375 }
2376
2377 void
2378 end_callback(png_structp png_ptr, png_infop info)
2379 {
2380 /* This function is called after the whole image
2381 has been read, including any chunks after the
2382 image (up to and including the IEND). You
2383 will usually have the same info chunk as you
2384 had in the header, although some data may have
2385 been added to the comments and time fields.
2386
2387 Most people won't do much here, perhaps setting
2388 a flag that marks the image as finished.
2389 */
2390 }
2391
2392
2393
2394.SH IV. Writing
2395
2396Much of this is very similar to reading. However, everything of
2397importance is repeated here, so you won't have to constantly look
2398back up in the reading section to understand writing.
2399
2400.SS Setup
2401
2402You will want to do the I/O initialization before you get into libpng,
2403so if it doesn't work, you don't have anything to undo. If you are not
2404using the standard I/O functions, you will need to replace them with
2405custom writing functions. See the discussion under Customizing libpng.
2406
2407 FILE *fp = fopen(file_name, "wb");
2408 if (!fp)
2409 {
2410 return (ERROR);
2411 }
2412
2413Next, png_struct and png_info need to be allocated and initialized.
2414As these can be both relatively large, you may not want to store these
2415on the stack, unless you have stack space to spare. Of course, you
2416will want to check if they return NULL. If you are also reading,
2417you won't want to name your read structure and your write structure
2418both "png_ptr"; you can call them anything you like, such as
2419"read_ptr" and "write_ptr". Look at pngtest.c, for example.
2420
2421 png_structp png_ptr = png_create_write_struct
2422 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
2423 user_error_fn, user_warning_fn);
2424 if (!png_ptr)
2425 return (ERROR);
2426
2427 png_infop info_ptr = png_create_info_struct(png_ptr);
2428 if (!info_ptr)
2429 {
2430 png_destroy_write_struct(&png_ptr,
2431 (png_infopp)NULL);
2432 return (ERROR);
2433 }
2434
2435If you want to use your own memory allocation routines,
2436define PNG_USER_MEM_SUPPORTED and use
2437png_create_write_struct_2() instead of png_create_write_struct():
2438
2439 png_structp png_ptr = png_create_write_struct_2
2440 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
2441 user_error_fn, user_warning_fn, (png_voidp)
2442 user_mem_ptr, user_malloc_fn, user_free_fn);
2443
2444After you have these structures, you will need to set up the
2445error handling. When libpng encounters an error, it expects to
2446longjmp() back to your routine. Therefore, you will need to call
2447setjmp() and pass the png_jmpbuf(png_ptr). If you
2448write the file from different routines, you will need to update
2449the png_jmpbuf(png_ptr) every time you enter a new routine that will
2450call a png_*() function. See your documentation of setjmp/longjmp
2451for your compiler for more information on setjmp/longjmp. See
2452the discussion on libpng error handling in the Customizing Libpng
2453section below for more information on the libpng error handling.
2454
2455 if (setjmp(png_jmpbuf(png_ptr)))
2456 {
2457 png_destroy_write_struct(&png_ptr, &info_ptr);
2458 fclose(fp);
2459 return (ERROR);
2460 }
2461 ...
2462 return;
2463
2464If you would rather avoid the complexity of setjmp/longjmp issues,
2465you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case
2466errors will result in a call to PNG_ABORT() which defaults to abort().
2467
2468Now you need to set up the output code. The default for libpng is to
2469use the C function fwrite(). If you use this, you will need to pass a
2470valid FILE * in the function png_init_io(). Be sure that the file is
2471opened in binary mode. Again, if you wish to handle writing data in
2472another way, see the discussion on libpng I/O handling in the Customizing
2473Libpng section below.
2474
2475 png_init_io(png_ptr, fp);
2476
2477If you are embedding your PNG into a datastream such as MNG, and don't
2478want libpng to write the 8-byte signature, or if you have already
2479written the signature in your application, use
2480
2481 png_set_sig_bytes(png_ptr, 8);
2482
2483to inform libpng that it should not write a signature.
2484
2485.SS Write callbacks
2486
2487At this point, you can set up a callback function that will be
2488called after each row has been written, which you can use to control
2489a progress meter or the like. It's demonstrated in pngtest.c.
2490You must supply a function
2491
2492 void write_row_callback(png_ptr, png_uint_32 row,
2493 int pass);
2494 {
2495 /* put your code here */
2496 }
2497
2498(You can give it another name that you like instead of "write_row_callback")
2499
2500To inform libpng about your function, use
2501
2502 png_set_write_status_fn(png_ptr, write_row_callback);
2503
2504You now have the option of modifying how the compression library will
2505run. The following functions are mainly for testing, but may be useful
2506in some cases, like if you need to write PNG files extremely fast and
2507are willing to give up some compression, or if you want to get the
2508maximum possible compression at the expense of slower writing. If you
2509have no special needs in this area, let the library do what it wants by
2510not calling this function at all, as it has been tuned to deliver a good
2511speed/compression ratio. The second parameter to png_set_filter() is
2512the filter method, for which the only valid values are 0 (as of the
2513July 1999 PNG specification, version 1.2) or 64 (if you are writing
2514a PNG datastream that is to be embedded in a MNG datastream). The third
2515parameter is a flag that indicates which filter type(s) are to be tested
2516for each scanline. See the PNG specification for details on the specific filter
2517types.
2518
2519
2520 /* turn on or off filtering, and/or choose
2521 specific filters. You can use either a single
2522 PNG_FILTER_VALUE_NAME or the bitwise OR of one
2523 or more PNG_FILTER_NAME masks. */
2524 png_set_filter(png_ptr, 0,
2525 PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE |
2526 PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB |
2527 PNG_FILTER_UP | PNG_FILTER_VALUE_UP |
2528 PNG_FILTER_AVE | PNG_FILTER_VALUE_AVE |
2529 PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH|
2530 PNG_ALL_FILTERS);
2531
2532If an application
2533wants to start and stop using particular filters during compression,
2534it should start out with all of the filters (to ensure that the previous
2535row of pixels will be stored in case it's needed later), and then add
2536and remove them after the start of compression.
2537
2538If you are writing a PNG datastream that is to be embedded in a MNG
2539datastream, the second parameter can be either 0 or 64.
2540
2541The png_set_compression_*() functions interface to the zlib compression
2542library, and should mostly be ignored unless you really know what you are
2543doing. The only generally useful call is png_set_compression_level()
2544which changes how much time zlib spends on trying to compress the image
2545data. See the Compression Library (zlib.h and algorithm.txt, distributed
2546with zlib) for details on the compression levels.
2547
2548 /* set the zlib compression level */
2549 png_set_compression_level(png_ptr,
2550 Z_BEST_COMPRESSION);
2551
2552 /* set other zlib parameters */
2553 png_set_compression_mem_level(png_ptr, 8);
2554 png_set_compression_strategy(png_ptr,
2555 Z_DEFAULT_STRATEGY);
2556 png_set_compression_window_bits(png_ptr, 15);
2557 png_set_compression_method(png_ptr, 8);
2558 png_set_compression_buffer_size(png_ptr, 8192)
2559
2560extern PNG_EXPORT(void,png_set_zbuf_size)
2561
2562.SS Setting the contents of info for output
2563
2564You now need to fill in the png_info structure with all the data you
2565wish to write before the actual image. Note that the only thing you
2566are allowed to write after the image is the text chunks and the time
2567chunk (as of PNG Specification 1.2, anyway). See png_write_end() and
2568the latest PNG specification for more information on that. If you
2569wish to write them before the image, fill them in now, and flag that
2570data as being valid. If you want to wait until after the data, don't
2571fill them until png_write_end(). For all the fields in png_info and
2572their data types, see png.h. For explanations of what the fields
2573contain, see the PNG specification.
2574
2575Some of the more important parts of the png_info are:
2576
2577 png_set_IHDR(png_ptr, info_ptr, width, height,
2578 bit_depth, color_type, interlace_type,
2579 compression_type, filter_method)
2580 width - holds the width of the image
2581 in pixels (up to 2^31).
2582 height - holds the height of the image
2583 in pixels (up to 2^31).
2584 bit_depth - holds the bit depth of one of the
2585 image channels.
2586 (valid values are 1, 2, 4, 8, 16
2587 and depend also on the
2588 color_type. See also significant
2589 bits (sBIT) below).
2590 color_type - describes which color/alpha
2591 channels are present.
2592 PNG_COLOR_TYPE_GRAY
2593 (bit depths 1, 2, 4, 8, 16)
2594 PNG_COLOR_TYPE_GRAY_ALPHA
2595 (bit depths 8, 16)
2596 PNG_COLOR_TYPE_PALETTE
2597 (bit depths 1, 2, 4, 8)
2598 PNG_COLOR_TYPE_RGB
2599 (bit_depths 8, 16)
2600 PNG_COLOR_TYPE_RGB_ALPHA
2601 (bit_depths 8, 16)
2602
2603 PNG_COLOR_MASK_PALETTE
2604 PNG_COLOR_MASK_COLOR
2605 PNG_COLOR_MASK_ALPHA
2606
2607 interlace_type - PNG_INTERLACE_NONE or
2608 PNG_INTERLACE_ADAM7
2609 compression_type - (must be
2610 PNG_COMPRESSION_TYPE_DEFAULT)
2611 filter_method - (must be PNG_FILTER_TYPE_DEFAULT
2612 or, if you are writing a PNG to
2613 be embedded in a MNG datastream,
2614 can also be
2615 PNG_INTRAPIXEL_DIFFERENCING)
2616
2617If you call png_set_IHDR(), the call must appear before any of the
2618other png_set_*() functions, which might require access to some of
2619the IHDR settings. The remaining png_set_*() functions can be called
2620in any order.
2621
2622 png_set_PLTE(png_ptr, info_ptr, palette,
2623 num_palette);
2624 palette - the palette for the file
2625 (array of png_color)
2626 num_palette - number of entries in the palette
2627
2628 png_set_gAMA(png_ptr, info_ptr, gamma);
2629 gamma - the gamma the image was created
2630 at (PNG_INFO_gAMA)
2631
2632 png_set_sRGB(png_ptr, info_ptr, srgb_intent);
2633 srgb_intent - the rendering intent
2634 (PNG_INFO_sRGB) The presence of
2635 the sRGB chunk means that the pixel
2636 data is in the sRGB color space.
2637 This chunk also implies specific
2638 values of gAMA and cHRM. Rendering
2639 intent is the CSS-1 property that
2640 has been defined by the International
2641 Color Consortium
2642 (http://www.color.org).
2643 It can be one of
2644 PNG_sRGB_INTENT_SATURATION,
2645 PNG_sRGB_INTENT_PERCEPTUAL,
2646 PNG_sRGB_INTENT_ABSOLUTE, or
2647 PNG_sRGB_INTENT_RELATIVE.
2648
2649
2650 png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr,
2651 srgb_intent);
2652 srgb_intent - the rendering intent
2653 (PNG_INFO_sRGB) The presence of the
2654 sRGB chunk means that the pixel
2655 data is in the sRGB color space.
2656 This function also causes gAMA and
2657 cHRM chunks with the specific values
2658 that are consistent with sRGB to be
2659 written.
2660
2661 png_set_iCCP(png_ptr, info_ptr, name, compression_type,
2662 profile, proflen);
2663 name - The profile name.
2664 compression - The compression type; always
2665 PNG_COMPRESSION_TYPE_BASE for PNG 1.0.
2666 You may give NULL to this argument to
2667 ignore it.
2668 profile - International Color Consortium color
2669 profile data. May contain NULs.
2670 proflen - length of profile data in bytes.
2671
2672 png_set_sBIT(png_ptr, info_ptr, sig_bit);
2673 sig_bit - the number of significant bits for
2674 (PNG_INFO_sBIT) each of the gray, red,
2675 green, and blue channels, whichever are
2676 appropriate for the given color type
2677 (png_color_16)
2678
2679 png_set_tRNS(png_ptr, info_ptr, trans, num_trans,
2680 trans_values);
2681 trans - array of transparent entries for
2682 palette (PNG_INFO_tRNS)
2683 trans_values - graylevel or color sample values of
2684 the single transparent color for
2685 non-paletted images (PNG_INFO_tRNS)
2686 num_trans - number of transparent entries
2687 (PNG_INFO_tRNS)
2688
2689 png_set_hIST(png_ptr, info_ptr, hist);
2690 (PNG_INFO_hIST)
2691 hist - histogram of palette (array of
2692 png_uint_16)
2693
2694 png_set_tIME(png_ptr, info_ptr, mod_time);
2695 mod_time - time image was last modified
2696 (PNG_VALID_tIME)
2697
2698 png_set_bKGD(png_ptr, info_ptr, background);
2699 background - background color (PNG_VALID_bKGD)
2700
2701 png_set_text(png_ptr, info_ptr, text_ptr, num_text);
2702 text_ptr - array of png_text holding image
2703 comments
2704 text_ptr[i].compression - type of compression used
2705 on "text" PNG_TEXT_COMPRESSION_NONE
2706 PNG_TEXT_COMPRESSION_zTXt
2707 PNG_ITXT_COMPRESSION_NONE
2708 PNG_ITXT_COMPRESSION_zTXt
2709 text_ptr[i].key - keyword for comment. Must contain
2710 1-79 characters.
2711 text_ptr[i].text - text comments for current
2712 keyword. Can be NULL or empty.
2713 text_ptr[i].text_length - length of text string,
2714 after decompression, 0 for iTXt
2715 text_ptr[i].itxt_length - length of itxt string,
2716 after decompression, 0 for tEXt/zTXt
2717 text_ptr[i].lang - language of comment (NULL or
2718 empty for unknown).
2719 text_ptr[i].translated_keyword - keyword in UTF-8 (NULL
2720 or empty for unknown).
2721 num_text - number of comments
2722
2723 png_set_sPLT(png_ptr, info_ptr, &palette_ptr,
2724 num_spalettes);
2725 palette_ptr - array of png_sPLT_struct structures
2726 to be added to the list of palettes
2727 in the info structure.
2728 num_spalettes - number of palette structures to be
2729 added.
2730
2731 png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y,
2732 unit_type);
2733 offset_x - positive offset from the left
2734 edge of the screen
2735 offset_y - positive offset from the top
2736 edge of the screen
2737 unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER
2738
2739 png_set_pHYs(png_ptr, info_ptr, res_x, res_y,
2740 unit_type);
2741 res_x - pixels/unit physical resolution
2742 in x direction
2743 res_y - pixels/unit physical resolution
2744 in y direction
2745 unit_type - PNG_RESOLUTION_UNKNOWN,
2746 PNG_RESOLUTION_METER
2747
2748 png_set_sCAL(png_ptr, info_ptr, unit, width, height)
2749 unit - physical scale units (an integer)
2750 width - width of a pixel in physical scale units
2751 height - height of a pixel in physical scale units
2752 (width and height are doubles)
2753
2754 png_set_sCAL_s(png_ptr, info_ptr, unit, width, height)
2755 unit - physical scale units (an integer)
2756 width - width of a pixel in physical scale units
2757 height - height of a pixel in physical scale units
2758 (width and height are strings like "2.54")
2759
2760 png_set_unknown_chunks(png_ptr, info_ptr, &unknowns,
2761 num_unknowns)
2762 unknowns - array of png_unknown_chunk
2763 structures holding unknown chunks
2764 unknowns[i].name - name of unknown chunk
2765 unknowns[i].data - data of unknown chunk
2766 unknowns[i].size - size of unknown chunk's data
2767 unknowns[i].location - position to write chunk in file
2768 0: do not write chunk
2769 PNG_HAVE_IHDR: before PLTE
2770 PNG_HAVE_PLTE: before IDAT
2771 PNG_AFTER_IDAT: after IDAT
2772
2773The "location" member is set automatically according to
2774what part of the output file has already been written.
2775You can change its value after calling png_set_unknown_chunks()
2776as demonstrated in pngtest.c. Within each of the "locations",
2777the chunks are sequenced according to their position in the
2778structure (that is, the value of "i", which is the order in which
2779the chunk was either read from the input file or defined with
2780png_set_unknown_chunks).
2781
2782A quick word about text and num_text. text is an array of png_text
2783structures. num_text is the number of valid structures in the array.
2784Each png_text structure holds a language code, a keyword, a text value,
2785and a compression type.
2786
2787The compression types have the same valid numbers as the compression
2788types of the image data. Currently, the only valid number is zero.
2789However, you can store text either compressed or uncompressed, unlike
2790images, which always have to be compressed. So if you don't want the
2791text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE.
2792Because tEXt and zTXt chunks don't have a language field, if you
2793specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt
2794any language code or translated keyword will not be written out.
2795
2796Until text gets around 1000 bytes, it is not worth compressing it.
2797After the text has been written out to the file, the compression type
2798is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR,
2799so that it isn't written out again at the end (in case you are calling
2800png_write_end() with the same struct.
2801
2802The keywords that are given in the PNG Specification are:
2803
2804 Title Short (one line) title or
2805 caption for image
2806 Author Name of image's creator
2807 Description Description of image (possibly long)
2808 Copyright Copyright notice
2809 Creation Time Time of original image creation
2810 (usually RFC 1123 format, see below)
2811 Software Software used to create the image
2812 Disclaimer Legal disclaimer
2813 Warning Warning of nature of content
2814 Source Device used to create the image
2815 Comment Miscellaneous comment; conversion
2816 from other image format
2817
2818The keyword-text pairs work like this. Keywords should be short
2819simple descriptions of what the comment is about. Some typical
2820keywords are found in the PNG specification, as is some recommendations
2821on keywords. You can repeat keywords in a file. You can even write
2822some text before the image and some after. For example, you may want
2823to put a description of the image before the image, but leave the
2824disclaimer until after, so viewers working over modem connections
2825don't have to wait for the disclaimer to go over the modem before
2826they start seeing the image. Finally, keywords should be full
2827words, not abbreviations. Keywords and text are in the ISO 8859-1
2828(Latin-1) character set (a superset of regular ASCII) and can not
2829contain NUL characters, and should not contain control or other
2830unprintable characters. To make the comments widely readable, stick
2831with basic ASCII, and avoid machine specific character set extensions
2832like the IBM-PC character set. The keyword must be present, but
2833you can leave off the text string on non-compressed pairs.
2834Compressed pairs must have a text string, as only the text string
2835is compressed anyway, so the compression would be meaningless.
2836
2837PNG supports modification time via the png_time structure. Two
2838conversion routines are provided, png_convert_from_time_t() for
2839time_t and png_convert_from_struct_tm() for struct tm. The
2840time_t routine uses gmtime(). You don't have to use either of
2841these, but if you wish to fill in the png_time structure directly,
2842you should provide the time in universal time (GMT) if possible
2843instead of your local time. Note that the year number is the full
2844year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and
2845that months start with 1.
2846
2847If you want to store the time of the original image creation, you should
2848use a plain tEXt chunk with the "Creation Time" keyword. This is
2849necessary because the "creation time" of a PNG image is somewhat vague,
2850depending on whether you mean the PNG file, the time the image was
2851created in a non-PNG format, a still photo from which the image was
2852scanned, or possibly the subject matter itself. In order to facilitate
2853machine-readable dates, it is recommended that the "Creation Time"
2854tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"),
2855although this isn't a requirement. Unlike the tIME chunk, the
2856"Creation Time" tEXt chunk is not expected to be automatically changed
2857by the software. To facilitate the use of RFC 1123 dates, a function
2858png_convert_to_rfc1123(png_timep) is provided to convert from PNG
2859time to an RFC 1123 format string.
2860
2861.SS Writing unknown chunks
2862
2863You can use the png_set_unknown_chunks function to queue up chunks
2864for writing. You give it a chunk name, raw data, and a size; that's
2865all there is to it. The chunks will be written by the next following
2866png_write_info_before_PLTE, png_write_info, or png_write_end function.
2867Any chunks previously read into the info structure's unknown-chunk
2868list will also be written out in a sequence that satisfies the PNG
2869specification's ordering rules.
2870
2871.SS The high-level write interface
2872
2873At this point there are two ways to proceed; through the high-level
2874write interface, or through a sequence of low-level write operations.
2875You can use the high-level interface if your image data is present
2876in the info structure. All defined output
2877transformations are permitted, enabled by the following masks.
2878
2879 PNG_TRANSFORM_IDENTITY No transformation
2880 PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples
2881 PNG_TRANSFORM_PACKSWAP Change order of packed
2882 pixels to LSB first
2883 PNG_TRANSFORM_INVERT_MONO Invert monochrome images
2884 PNG_TRANSFORM_SHIFT Normalize pixels to the
2885 sBIT depth
2886 PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA
2887 to BGRA
2888 PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA
2889 to AG
2890 PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity
2891 to transparency
2892 PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples
2893 PNG_TRANSFORM_STRIP_FILLER Strip out filler bytes.
2894
2895If you have valid image data in the info structure (you can use
2896png_set_rows() to put image data in the info structure), simply do this:
2897
2898 png_write_png(png_ptr, info_ptr, png_transforms, NULL)
2899
2900where png_transforms is an integer containing the bitwise OR of some set of
2901transformation flags. This call is equivalent to png_write_info(),
2902followed the set of transformations indicated by the transform mask,
2903then png_write_image(), and finally png_write_end().
2904
2905(The final parameter of this call is not yet used. Someday it might point
2906to transformation parameters required by some future output transform.)
2907
2908You must use png_transforms and not call any png_set_transform() functions
2909when you use png_write_png().
2910
2911.SS The low-level write interface
2912
2913If you are going the low-level route instead, you are now ready to
2914write all the file information up to the actual image data. You do
2915this with a call to png_write_info().
2916
2917 png_write_info(png_ptr, info_ptr);
2918
2919Note that there is one transformation you may need to do before
2920png_write_info(). In PNG files, the alpha channel in an image is the
2921level of opacity. If your data is supplied as a level of
2922transparency, you can invert the alpha channel before you write it, so
2923that 0 is fully transparent and 255 (in 8-bit or paletted images) or
292465535 (in 16-bit images) is fully opaque, with
2925
2926 png_set_invert_alpha(png_ptr);
2927
2928This must appear before png_write_info() instead of later with the
2929other transformations because in the case of paletted images the tRNS
2930chunk data has to be inverted before the tRNS chunk is written. If
2931your image is not a paletted image, the tRNS data (which in such cases
2932represents a single color to be rendered as transparent) won't need to
2933be changed, and you can safely do this transformation after your
2934png_write_info() call.
2935
2936If you need to write a private chunk that you want to appear before
2937the PLTE chunk when PLTE is present, you can write the PNG info in
2938two steps, and insert code to write your own chunk between them:
2939
2940 png_write_info_before_PLTE(png_ptr, info_ptr);
2941 png_set_unknown_chunks(png_ptr, info_ptr, ...);
2942 png_write_info(png_ptr, info_ptr);
2943
2944After you've written the file information, you can set up the library
2945to handle any special transformations of the image data. The various
2946ways to transform the data will be described in the order that they
2947should occur. This is important, as some of these change the color
2948type and/or bit depth of the data, and some others only work on
2949certain color types and bit depths. Even though each transformation
2950checks to see if it has data that it can do something with, you should
2951make sure to only enable a transformation if it will be valid for the
2952data. For example, don't swap red and blue on grayscale data.
2953
2954PNG files store RGB pixels packed into 3 or 6 bytes. This code tells
2955the library to strip input data that has 4 or 8 bytes per pixel down
2956to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2
2957bytes per pixel).
2958
2959 png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
2960
2961where the 0 is unused, and the location is either PNG_FILLER_BEFORE or
2962PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel
2963is stored XRGB or RGBX.
2964
2965PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
2966they can, resulting in, for example, 8 pixels per byte for 1 bit files.
2967If the data is supplied at 1 pixel per byte, use this code, which will
2968correctly pack the pixels into a single byte:
2969
2970 png_set_packing(png_ptr);
2971
2972PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your
2973data is of another bit depth, you can write an sBIT chunk into the
2974file so that decoders can recover the original data if desired.
2975
2976 /* Set the true bit depth of the image data */
2977 if (color_type & PNG_COLOR_MASK_COLOR)
2978 {
2979 sig_bit.red = true_bit_depth;
2980 sig_bit.green = true_bit_depth;
2981 sig_bit.blue = true_bit_depth;
2982 }
2983 else
2984 {
2985 sig_bit.gray = true_bit_depth;
2986 }
2987 if (color_type & PNG_COLOR_MASK_ALPHA)
2988 {
2989 sig_bit.alpha = true_bit_depth;
2990 }
2991
2992 png_set_sBIT(png_ptr, info_ptr, &sig_bit);
2993
2994If the data is stored in the row buffer in a bit depth other than
2995one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG),
2996this will scale the values to appear to be the correct bit depth as
2997is required by PNG.
2998
2999 png_set_shift(png_ptr, &sig_bit);
3000
3001PNG files store 16 bit pixels in network byte order (big-endian,
3002ie. most significant bits first). This code would be used if they are
3003supplied the other way (little-endian, i.e. least significant bits
3004first, the way PCs store them):
3005
3006 if (bit_depth > 8)
3007 png_set_swap(png_ptr);
3008
3009If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you
3010need to change the order the pixels are packed into bytes, you can use:
3011
3012 if (bit_depth < 8)
3013 png_set_packswap(png_ptr);
3014
3015PNG files store 3 color pixels in red, green, blue order. This code
3016would be used if they are supplied as blue, green, red:
3017
3018 png_set_bgr(png_ptr);
3019
3020PNG files describe monochrome as black being zero and white being
3021one. This code would be used if the pixels are supplied with this reversed
3022(black being one and white being zero):
3023
3024 png_set_invert_mono(png_ptr);
3025
3026Finally, you can write your own transformation function if none of
3027the existing ones meets your needs. This is done by setting a callback
3028with
3029
3030 png_set_write_user_transform_fn(png_ptr,
3031 write_transform_fn);
3032
3033You must supply the function
3034
3035 void write_transform_fn(png_ptr ptr, row_info_ptr
3036 row_info, png_bytep data)
3037
3038See pngtest.c for a working example. Your function will be called
3039before any of the other transformations are processed.
3040
3041You can also set up a pointer to a user structure for use by your
3042callback function.
3043
3044 png_set_user_transform_info(png_ptr, user_ptr, 0, 0);
3045
3046The user_channels and user_depth parameters of this function are ignored
3047when writing; you can set them to zero as shown.
3048
3049You can retrieve the pointer via the function png_get_user_transform_ptr().
3050For example:
3051
3052 voidp write_user_transform_ptr =
3053 png_get_user_transform_ptr(png_ptr);
3054
3055It is possible to have libpng flush any pending output, either manually,
3056or automatically after a certain number of lines have been written. To
3057flush the output stream a single time call:
3058
3059 png_write_flush(png_ptr);
3060
3061and to have libpng flush the output stream periodically after a certain
3062number of scanlines have been written, call:
3063
3064 png_set_flush(png_ptr, nrows);
3065
3066Note that the distance between rows is from the last time png_write_flush()
3067was called, or the first row of the image if it has never been called.
3068So if you write 50 lines, and then png_set_flush 25, it will flush the
3069output on the next scanline, and every 25 lines thereafter, unless
3070png_write_flush() is called before 25 more lines have been written.
3071If nrows is too small (less than about 10 lines for a 640 pixel wide
3072RGB image) the image compression may decrease noticeably (although this
3073may be acceptable for real-time applications). Infrequent flushing will
3074only degrade the compression performance by a few percent over images
3075that do not use flushing.
3076
3077.SS Writing the image data
3078
3079That's it for the transformations. Now you can write the image data.
3080The simplest way to do this is in one function call. If you have the
3081whole image in memory, you can just call png_write_image() and libpng
3082will write the image. You will need to pass in an array of pointers to
3083each row. This function automatically handles interlacing, so you don't
3084need to call png_set_interlace_handling() or call this function multiple
3085times, or any of that other stuff necessary with png_write_rows().
3086
3087 png_write_image(png_ptr, row_pointers);
3088
3089where row_pointers is:
3090
3091 png_byte *row_pointers[height];
3092
3093You can point to void or char or whatever you use for pixels.
3094
3095If you don't want to write the whole image at once, you can
3096use png_write_rows() instead. If the file is not interlaced,
3097this is simple:
3098
3099 png_write_rows(png_ptr, row_pointers,
3100 number_of_rows);
3101
3102row_pointers is the same as in the png_write_image() call.
3103
3104If you are just writing one row at a time, you can do this with
3105a single row_pointer instead of an array of row_pointers:
3106
3107 png_bytep row_pointer = row;
3108
3109 png_write_row(png_ptr, row_pointer);
3110
3111When the file is interlaced, things can get a good deal more
3112complicated. The only currently (as of the PNG Specification
3113version 1.2, dated July 1999) defined interlacing scheme for PNG files
3114is the "Adam7" interlace scheme, that breaks down an
3115image into seven smaller images of varying size. libpng will build
3116these images for you, or you can do them yourself. If you want to
3117build them yourself, see the PNG specification for details of which
3118pixels to write when.
3119
3120If you don't want libpng to handle the interlacing details, just
3121use png_set_interlace_handling() and call png_write_rows() the
3122correct number of times to write all seven sub-images.
3123
3124If you want libpng to build the sub-images, call this before you start
3125writing any rows:
3126
3127 number_of_passes =
3128 png_set_interlace_handling(png_ptr);
3129
3130This will return the number of passes needed. Currently, this
3131is seven, but may change if another interlace type is added.
3132
3133Then write the complete image number_of_passes times.
3134
3135 png_write_rows(png_ptr, row_pointers,
3136 number_of_rows);
3137
3138As some of these rows are not used, and thus return immediately,
3139you may want to read about interlacing in the PNG specification,
3140and only update the rows that are actually used.
3141
3142.SS Finishing a sequential write
3143
3144After you are finished writing the image, you should finish writing
3145the file. If you are interested in writing comments or time, you should
3146pass an appropriately filled png_info pointer. If you are not interested,
3147you can pass NULL.
3148
3149 png_write_end(png_ptr, info_ptr);
3150
3151When you are done, you can free all memory used by libpng like this:
3152
3153 png_destroy_write_struct(&png_ptr, &info_ptr);
3154
3155It is also possible to individually free the info_ptr members that
3156point to libpng-allocated storage with the following function:
3157
3158 png_free_data(png_ptr, info_ptr, mask, seq)
3159 mask - identifies data to be freed, a mask
3160 containing the bitwise OR of one or
3161 more of
3162 PNG_FREE_PLTE, PNG_FREE_TRNS,
3163 PNG_FREE_HIST, PNG_FREE_ICCP,
3164 PNG_FREE_PCAL, PNG_FREE_ROWS,
3165 PNG_FREE_SCAL, PNG_FREE_SPLT,
3166 PNG_FREE_TEXT, PNG_FREE_UNKN,
3167 or simply PNG_FREE_ALL
3168 seq - sequence number of item to be freed
3169 (-1 for all items)
3170
3171This function may be safely called when the relevant storage has
3172already been freed, or has not yet been allocated, or was allocated
3173by the user and not by libpng, and will in those
3174cases do nothing. The "seq" parameter is ignored if only one item
3175of the selected data type, such as PLTE, is allowed. If "seq" is not
3176-1, and multiple items are allowed for the data type identified in
3177the mask, such as text or sPLT, only the n'th item in the structure
3178is freed, where n is "seq".
3179
3180If you allocated data such as a palette that you passed
3181in to libpng with png_set_*, you must not free it until just before the call to
3182png_destroy_write_struct().
3183
3184The default behavior is only to free data that was allocated internally
3185by libpng. This can be changed, so that libpng will not free the data,
3186or so that it will free data that was allocated by the user with png_malloc()
3187or png_zalloc() and passed in via a png_set_*() function, with
3188
3189 png_data_freer(png_ptr, info_ptr, freer, mask)
3190 mask - which data elements are affected
3191 same choices as in png_free_data()
3192 freer - one of
3193 PNG_DESTROY_WILL_FREE_DATA
3194 PNG_SET_WILL_FREE_DATA
3195 PNG_USER_WILL_FREE_DATA
3196
3197For example, to transfer responsibility for some data from a read structure
3198to a write structure, you could use
3199
3200 png_data_freer(read_ptr, read_info_ptr,
3201 PNG_USER_WILL_FREE_DATA,
3202 PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST)
3203 png_data_freer(write_ptr, write_info_ptr,
3204 PNG_DESTROY_WILL_FREE_DATA,
3205 PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST)
3206
3207thereby briefly reassigning responsibility for freeing to the user but
3208immediately afterwards reassigning it once more to the write_destroy
3209function. Having done this, it would then be safe to destroy the read
3210structure and continue to use the PLTE, tRNS, and hIST data in the write
3211structure.
3212
3213This function only affects data that has already been allocated.
3214You can call this function before calling after the png_set_*() functions
3215to control whether the user or png_destroy_*() is supposed to free the data.
3216When the user assumes responsibility for libpng-allocated data, the
3217application must use
3218png_free() to free it, and when the user transfers responsibility to libpng
3219for data that the user has allocated, the user must have used png_malloc()
3220or png_zalloc() to allocate it.
3221
3222If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword
3223separately, do not transfer responsibility for freeing text_ptr to libpng,
3224because when libpng fills a png_text structure it combines these members with
3225the key member, and png_free_data() will free only text_ptr.key. Similarly,
3226if you transfer responsibility for free'ing text_ptr from libpng to your
3227application, your application must not separately free those members.
3228For a more compact example of writing a PNG image, see the file example.c.
3229
3230.SH V. Modifying/Customizing libpng:
3231
3232There are two issues here. The first is changing how libpng does
3233standard things like memory allocation, input/output, and error handling.
3234The second deals with more complicated things like adding new chunks,
3235adding new transformations, and generally changing how libpng works.
3236Both of those are compile-time issues; that is, they are generally
3237determined at the time the code is written, and there is rarely a need
3238to provide the user with a means of changing them.
3239
3240Memory allocation, input/output, and error handling
3241
3242All of the memory allocation, input/output, and error handling in libpng
3243goes through callbacks that are user-settable. The default routines are
3244in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change
3245these functions, call the appropriate png_set_*_fn() function.
3246
3247Memory allocation is done through the functions png_malloc()
3248and png_free(). These currently just call the standard C functions. If
3249your pointers can't access more then 64K at a time, you will want to set
3250MAXSEG_64K in zlib.h. Since it is unlikely that the method of handling
3251memory allocation on a platform will change between applications, these
3252functions must be modified in the library at compile time. If you prefer
3253to use a different method of allocating and freeing data, you can use
3254png_create_read_struct_2() or png_create_write_struct_2() to register
3255your own functions as described above.
3256These functions also provide a void pointer that can be retrieved via
3257
3258 mem_ptr=png_get_mem_ptr(png_ptr);
3259
3260Your replacement memory functions must have prototypes as follows:
3261
3262 png_voidp malloc_fn(png_structp png_ptr,
3263 png_size_t size);
3264 void free_fn(png_structp png_ptr, png_voidp ptr);
3265
3266Your malloc_fn() must return NULL in case of failure. The png_malloc()
3267function will normally call png_error() if it receives a NULL from the
3268system memory allocator or from your replacement malloc_fn().
3269
3270Your free_fn() will never be called with a NULL ptr, since libpng's
3271png_free() checks for NULL before calling free_fn().
3272
3273Input/Output in libpng is done through png_read() and png_write(),
3274which currently just call fread() and fwrite(). The FILE * is stored in
3275png_struct and is initialized via png_init_io(). If you wish to change
3276the method of I/O, the library supplies callbacks that you can set
3277through the function png_set_read_fn() and png_set_write_fn() at run
3278time, instead of calling the png_init_io() function. These functions
3279also provide a void pointer that can be retrieved via the function
3280png_get_io_ptr(). For example:
3281
3282 png_set_read_fn(png_structp read_ptr,
3283 voidp read_io_ptr, png_rw_ptr read_data_fn)
3284
3285 png_set_write_fn(png_structp write_ptr,
3286 voidp write_io_ptr, png_rw_ptr write_data_fn,
3287 png_flush_ptr output_flush_fn);
3288
3289 voidp read_io_ptr = png_get_io_ptr(read_ptr);
3290 voidp write_io_ptr = png_get_io_ptr(write_ptr);
3291
3292The replacement I/O functions must have prototypes as follows:
3293
3294 void user_read_data(png_structp png_ptr,
3295 png_bytep data, png_size_t length);
3296 void user_write_data(png_structp png_ptr,
3297 png_bytep data, png_size_t length);
3298 void user_flush_data(png_structp png_ptr);
3299
3300Supplying NULL for the read, write, or flush functions sets them back
3301to using the default C stream functions. It is an error to read from
3302a write stream, and vice versa.
3303
3304Error handling in libpng is done through png_error() and png_warning().
3305Errors handled through png_error() are fatal, meaning that png_error()
3306should never return to its caller. Currently, this is handled via
3307setjmp() and longjmp() (unless you have compiled libpng with
3308PNG_SETJMP_NOT_SUPPORTED, in which case it is handled via PNG_ABORT()),
3309but you could change this to do things like exit() if you should wish.
3310
3311On non-fatal errors, png_warning() is called
3312to print a warning message, and then control returns to the calling code.
3313By default png_error() and png_warning() print a message on stderr via
3314fprintf() unless the library is compiled with PNG_NO_CONSOLE_IO defined
3315(because you don't want the messages) or PNG_NO_STDIO defined (because
3316fprintf() isn't available). If you wish to change the behavior of the error
3317functions, you will need to set up your own message callbacks. These
3318functions are normally supplied at the time that the png_struct is created.
3319It is also possible to redirect errors and warnings to your own replacement
3320functions after png_create_*_struct() has been called by calling:
3321
3322 png_set_error_fn(png_structp png_ptr,
3323 png_voidp error_ptr, png_error_ptr error_fn,
3324 png_error_ptr warning_fn);
3325
3326 png_voidp error_ptr = png_get_error_ptr(png_ptr);
3327
3328If NULL is supplied for either error_fn or warning_fn, then the libpng
3329default function will be used, calling fprintf() and/or longjmp() if a
3330problem is encountered. The replacement error functions should have
3331parameters as follows:
3332
3333 void user_error_fn(png_structp png_ptr,
3334 png_const_charp error_msg);
3335 void user_warning_fn(png_structp png_ptr,
3336 png_const_charp warning_msg);
3337
3338The motivation behind using setjmp() and longjmp() is the C++ throw and
3339catch exception handling methods. This makes the code much easier to write,
3340as there is no need to check every return code of every function call.
3341However, there are some uncertainties about the status of local variables
3342after a longjmp, so the user may want to be careful about doing anything after
3343setjmp returns non-zero besides returning itself. Consult your compiler
3344documentation for more details. For an alternative approach, you may wish
3345to use the "cexcept" facility (see http://cexcept.sourceforge.net).
3346
3347.SS Custom chunks
3348
3349If you need to read or write custom chunks, you may need to get deeper
3350into the libpng code. The library now has mechanisms for storing
3351and writing chunks of unknown type; you can even declare callbacks
3352for custom chunks. However, this may not be good enough if the
3353library code itself needs to know about interactions between your
3354chunk and existing `intrinsic' chunks.
3355
3356If you need to write a new intrinsic chunk, first read the PNG
3357specification. Acquire a first level of
3358understanding of how it works. Pay particular attention to the
3359sections that describe chunk names, and look at how other chunks were
3360designed, so you can do things similarly. Second, check out the
3361sections of libpng that read and write chunks. Try to find a chunk
3362that is similar to yours and use it as a template. More details can
3363be found in the comments inside the code. It is best to handle unknown
3364chunks in a generic method, via callback functions, instead of by
3365modifying libpng functions.
3366
3367If you wish to write your own transformation for the data, look through
3368the part of the code that does the transformations, and check out some of
3369the simpler ones to get an idea of how they work. Try to find a similar
3370transformation to the one you want to add and copy off of it. More details
3371can be found in the comments inside the code itself.
3372
3373.SS Configuring for 16 bit platforms
3374
3375You will want to look into zconf.h to tell zlib (and thus libpng) that
3376it cannot allocate more then 64K at a time. Even if you can, the memory
3377won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
3378
3379.SS Configuring for DOS
3380
3381For DOS users who only have access to the lower 640K, you will
3382have to limit zlib's memory usage via a png_set_compression_mem_level()
3383call. See zlib.h or zconf.h in the zlib library for more information.
3384
3385.SS Configuring for Medium Model
3386
3387Libpng's support for medium model has been tested on most of the popular
3388compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
3389defined, and FAR gets defined to far in pngconf.h, and you should be
3390all set. Everything in the library (except for zlib's structure) is
3391expecting far data. You must use the typedefs with the p or pp on
3392the end for pointers (or at least look at them and be careful). Make
3393note that the rows of data are defined as png_bytepp, which is an
3394unsigned char far * far *.
3395
3396.SS Configuring for gui/windowing platforms:
3397
3398You will need to write new error and warning functions that use the GUI
3399interface, as described previously, and set them to be the error and
3400warning functions at the time that png_create_*_struct() is called,
3401in order to have them available during the structure initialization.
3402They can be changed later via png_set_error_fn(). On some compilers,
3403you may also have to change the memory allocators (png_malloc, etc.).
3404
3405.SS Configuring for compiler xxx:
3406
3407All includes for libpng are in pngconf.h. If you need to add/change/delete
3408an include, this is the place to do it. The includes that are not
3409needed outside libpng are protected by the PNG_INTERNAL definition,
3410which is only defined for those routines inside libpng itself. The
3411files in libpng proper only include png.h, which includes pngconf.h.
3412
3413.SS Configuring zlib:
3414
3415There are special functions to configure the compression. Perhaps the
3416most useful one changes the compression level, which currently uses
3417input compression values in the range 0 - 9. The library normally
3418uses the default compression level (Z_DEFAULT_COMPRESSION = 6). Tests
3419have shown that for a large majority of images, compression values in
3420the range 3-6 compress nearly as well as higher levels, and do so much
3421faster. For online applications it may be desirable to have maximum speed
3422(Z_BEST_SPEED = 1). With versions of zlib after v0.99, you can also
3423specify no compression (Z_NO_COMPRESSION = 0), but this would create
3424files larger than just storing the raw bitmap. You can specify the
3425compression level by calling:
3426
3427 png_set_compression_level(png_ptr, level);
3428
3429Another useful one is to reduce the memory level used by the library.
3430The memory level defaults to 8, but it can be lowered if you are
3431short on memory (running DOS, for example, where you only have 640K).
3432Note that the memory level does have an effect on compression; among
3433other things, lower levels will result in sections of incompressible
3434data being emitted in smaller stored blocks, with a correspondingly
3435larger relative overhead of up to 15% in the worst case.
3436
3437 png_set_compression_mem_level(png_ptr, level);
3438
3439The other functions are for configuring zlib. They are not recommended
3440for normal use and may result in writing an invalid PNG file. See
3441zlib.h for more information on what these mean.
3442
3443 png_set_compression_strategy(png_ptr,
3444 strategy);
3445 png_set_compression_window_bits(png_ptr,
3446 window_bits);
3447 png_set_compression_method(png_ptr, method);
3448 png_set_compression_buffer_size(png_ptr, size);
3449
3450.SS Controlling row filtering
3451
3452If you want to control whether libpng uses filtering or not, which
3453filters are used, and how it goes about picking row filters, you
3454can call one of these functions. The selection and configuration
3455of row filters can have a significant impact on the size and
3456encoding speed and a somewhat lesser impact on the decoding speed
3457of an image. Filtering is enabled by default for RGB and grayscale
3458images (with and without alpha), but not for paletted images nor
3459for any images with bit depths less than 8 bits/pixel.
3460
3461The 'method' parameter sets the main filtering method, which is
3462currently only '0' in the PNG 1.2 specification. The 'filters'
3463parameter sets which filter(s), if any, should be used for each
3464scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS
3465to turn filtering on and off, respectively.
3466
3467Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB,
3468PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise
3469ORed together with '|' to specify one or more filters to use.
3470These filters are described in more detail in the PNG specification.
3471If you intend to change the filter type during the course of writing
3472the image, you should start with flags set for all of the filters
3473you intend to use so that libpng can initialize its internal
3474structures appropriately for all of the filter types. (Note that this
3475means the first row must always be adaptively filtered, because libpng
3476currently does not allocate the filter buffers until png_write_row()
3477is called for the first time.)
3478
3479 filters = PNG_FILTER_NONE | PNG_FILTER_SUB
3480 PNG_FILTER_UP | PNG_FILTER_AVE |
3481 PNG_FILTER_PAETH | PNG_ALL_FILTERS;
3482
3483 png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE,
3484 filters);
3485 The second parameter can also be
3486 PNG_INTRAPIXEL_DIFFERENCING if you are
3487 writing a PNG to be embedded in a MNG
3488 datastream. This parameter must be the
3489 same as the value of filter_method used
3490 in png_set_IHDR().
3491
3492It is also possible to influence how libpng chooses from among the
3493available filters. This is done in one or both of two ways - by
3494telling it how important it is to keep the same filter for successive
3495rows, and by telling it the relative computational costs of the filters.
3496
3497 double weights[3] = {1.5, 1.3, 1.1},
3498 costs[PNG_FILTER_VALUE_LAST] =
3499 {1.0, 1.3, 1.3, 1.5, 1.7};
3500
3501 png_set_filter_heuristics(png_ptr,
3502 PNG_FILTER_HEURISTIC_WEIGHTED, 3,
3503 weights, costs);
3504
3505The weights are multiplying factors that indicate to libpng that the
3506row filter should be the same for successive rows unless another row filter
3507is that many times better than the previous filter. In the above example,
3508if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a
3509"sum of absolute differences" 1.5 x 1.3 times higher than other filters
3510and still be chosen, while the NONE filter could have a sum 1.1 times
3511higher than other filters and still be chosen. Unspecified weights are
3512taken to be 1.0, and the specified weights should probably be declining
3513like those above in order to emphasize recent filters over older filters.
3514
3515The filter costs specify for each filter type a relative decoding cost
3516to be considered when selecting row filters. This means that filters
3517with higher costs are less likely to be chosen over filters with lower
3518costs, unless their "sum of absolute differences" is that much smaller.
3519The costs do not necessarily reflect the exact computational speeds of
3520the various filters, since this would unduly influence the final image
3521size.
3522
3523Note that the numbers above were invented purely for this example and
3524are given only to help explain the function usage. Little testing has
3525been done to find optimum values for either the costs or the weights.
3526
3527.SS Removing unwanted object code
3528
3529There are a bunch of #define's in pngconf.h that control what parts of
3530libpng are compiled. All the defines end in _SUPPORTED. If you are
3531never going to use a capability, you can change the #define to #undef
3532before recompiling libpng and save yourself code and data space, or
3533you can turn off individual capabilities with defines that begin with
3534PNG_NO_.
3535
3536You can also turn all of the transforms and ancillary chunk capabilities
3537off en masse with compiler directives that define
3538PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
3539or all four,
3540along with directives to turn on any of the capabilities that you do
3541want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable
3542the extra transformations but still leave the library fully capable of reading
3543and writing PNG files with all known public chunks
3544Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive
3545produces a library that is incapable of reading or writing ancillary chunks.
3546If you are not using the progressive reading capability, you can
3547turn that off with PNG_NO_PROGRESSIVE_READ (don't confuse
3548this with the INTERLACING capability, which you'll still have).
3549
3550All the reading and writing specific code are in separate files, so the
3551linker should only grab the files it needs. However, if you want to
3552make sure, or if you are building a stand alone library, all the
3553reading files start with pngr and all the writing files start with
3554pngw. The files that don't match either (like png.c, pngtrans.c, etc.)
3555are used for both reading and writing, and always need to be included.
3556The progressive reader is in pngpread.c
3557
3558If you are creating or distributing a dynamically linked library (a .so
3559or DLL file), you should not remove or disable any parts of the library,
3560as this will cause applications linked with different versions of the
3561library to fail if they call functions not available in your library.
3562The size of the library itself should not be an issue, because only
3563those sections that are actually used will be loaded into memory.
3564
3565.SS Requesting debug printout
3566
3567The macro definition PNG_DEBUG can be used to request debugging
3568printout. Set it to an integer value in the range 0 to 3. Higher
3569numbers result in increasing amounts of debugging information. The
3570information is printed to the "stderr" file, unless another file
3571name is specified in the PNG_DEBUG_FILE macro definition.
3572
3573When PNG_DEBUG > 0, the following functions (macros) become available:
3574
3575 png_debug(level, message)
3576 png_debug1(level, message, p1)
3577 png_debug2(level, message, p1, p2)
3578
3579in which "level" is compared to PNG_DEBUG to decide whether to print
3580the message, "message" is the formatted string to be printed,
3581and p1 and p2 are parameters that are to be embedded in the string
3582according to printf-style formatting directives. For example,
3583
3584 png_debug1(2, "foo=%d\n", foo);
3585
3586is expanded to
3587
3588 if(PNG_DEBUG > 2)
3589 fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo);
3590
3591When PNG_DEBUG is defined but is zero, the macros aren't defined, but you
3592can still use PNG_DEBUG to control your own debugging:
3593
3594 #ifdef PNG_DEBUG
3595 fprintf(stderr, ...
3596 #endif
3597
3598When PNG_DEBUG = 1, the macros are defined, but only png_debug statements
3599having level = 0 will be printed. There aren't any such statements in
3600this version of libpng, but if you insert some they will be printed.
3601
3602.SH VII. MNG support
3603
3604The MNG specification (available at http://www.libpng.org/pub/mng) allows
3605certain extensions to PNG for PNG images that are embedded in MNG datastreams.
3606Libpng can support some of these extensions. To enable them, use the
3607png_permit_mng_features() function:
3608
3609 feature_set = png_permit_mng_features(png_ptr, mask)
3610 mask is a png_uint_32 containing the bitwise OR of the
3611 features you want to enable. These include
3612 PNG_FLAG_MNG_EMPTY_PLTE
3613 PNG_FLAG_MNG_FILTER_64
3614 PNG_ALL_MNG_FEATURES
3615 feature_set is a png_uint_32 that is the bitwise AND of
3616 your mask with the set of MNG features that is
3617 supported by the version of libpng that you are using.
3618
3619It is an error to use this function when reading or writing a standalone
3620PNG file with the PNG 8-byte signature. The PNG datastream must be wrapped
3621in a MNG datastream. As a minimum, it must have the MNG 8-byte signature
3622and the MHDR and MEND chunks. Libpng does not provide support for these
3623or any other MNG chunks; your application must provide its own support for
3624them. You may wish to consider using libmng (available at
3625http://www.libmng.com) instead.
3626
3627.SH VIII. Changes to Libpng from version 0.88
3628
3629It should be noted that versions of libpng later than 0.96 are not
3630distributed by the original libpng author, Guy Schalnat, nor by
3631Andreas Dilger, who had taken over from Guy during 1996 and 1997, and
3632distributed versions 0.89 through 0.96, but rather by another member
3633of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are
3634still alive and well, but they have moved on to other things.
3635
3636The old libpng functions png_read_init(), png_write_init(),
3637png_info_init(), png_read_destroy(), and png_write_destroy() have been
3638moved to PNG_INTERNAL in version 0.95 to discourage their use. These
3639functions will be removed from libpng version 2.0.0.
3640
3641The preferred method of creating and initializing the libpng structures is
3642via the png_create_read_struct(), png_create_write_struct(), and
3643png_create_info_struct() because they isolate the size of the structures
3644from the application, allow version error checking, and also allow the
3645use of custom error handling routines during the initialization, which
3646the old functions do not. The functions png_read_destroy() and
3647png_write_destroy() do not actually free the memory that libpng
3648allocated for these structs, but just reset the data structures, so they
3649can be used instead of png_destroy_read_struct() and
3650png_destroy_write_struct() if you feel there is too much system overhead
3651allocating and freeing the png_struct for each image read.
3652
3653Setting the error callbacks via png_set_message_fn() before
3654png_read_init() as was suggested in libpng-0.88 is no longer supported
3655because this caused applications that do not use custom error functions
3656to fail if the png_ptr was not initialized to zero. It is still possible
3657to set the error callbacks AFTER png_read_init(), or to change them with
3658png_set_error_fn(), which is essentially the same function, but with a new
3659name to force compilation errors with applications that try to use the old
3660method.
3661
3662Starting with version 1.0.7, you can find out which version of the library
3663you are using at run-time:
3664
3665 png_uint_32 libpng_vn = png_access_version_number();
3666
3667The number libpng_vn is constructed from the major version, minor
3668version with leading zero, and release number with leading zero,
3669(e.g., libpng_vn for version 1.0.7 is 10007).
3670
3671You can also check which version of png.h you used when compiling your
3672application:
3673
3674 png_uint_32 application_vn = PNG_LIBPNG_VER;
3675
3676.SH IX. Y2K Compliance in libpng
3677
The Android Open Source Project4215dd12009-03-09 11:52:12 -07003678February 14, 2009
The Android Open Source Project893912b2009-03-03 19:30:05 -08003679
3680Since the PNG Development group is an ad-hoc body, we can't make
3681an official declaration.
3682
3683This is your unofficial assurance that libpng from version 0.71 and
The Android Open Source Project4215dd12009-03-09 11:52:12 -07003684upward through 1.2.35 are Y2K compliant. It is my belief that earlier
The Android Open Source Project893912b2009-03-03 19:30:05 -08003685versions were also Y2K compliant.
3686
3687Libpng only has three year fields. One is a 2-byte unsigned integer that
3688will hold years up to 65535. The other two hold the date in text
3689format, and will hold years up to 9999.
3690
3691The integer is
3692 "png_uint_16 year" in png_time_struct.
3693
3694The strings are
3695 "png_charp time_buffer" in png_struct and
3696 "near_time_buffer", which is a local character string in png.c.
3697
3698There are seven time-related functions:
3699
3700 png_convert_to_rfc_1123() in png.c
3701 (formerly png_convert_to_rfc_1152() in error)
3702 png_convert_from_struct_tm() in pngwrite.c, called
3703 in pngwrite.c
3704 png_convert_from_time_t() in pngwrite.c
3705 png_get_tIME() in pngget.c
3706 png_handle_tIME() in pngrutil.c, called in pngread.c
3707 png_set_tIME() in pngset.c
3708 png_write_tIME() in pngwutil.c, called in pngwrite.c
3709
3710All appear to handle dates properly in a Y2K environment. The
3711png_convert_from_time_t() function calls gmtime() to convert from system
3712clock time, which returns (year - 1900), which we properly convert to
3713the full 4-digit year. There is a possibility that applications using
3714libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
3715function, or that they are incorrectly passing only a 2-digit year
3716instead of "year - 1900" into the png_convert_from_struct_tm() function,
3717but this is not under our control. The libpng documentation has always
3718stated that it works with 4-digit years, and the APIs have been
3719documented as such.
3720
3721The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
3722integer to hold the year, and can hold years as large as 65535.
3723
3724zlib, upon which libpng depends, is also Y2K compliant. It contains
3725no date-related code.
3726
3727
3728 Glenn Randers-Pehrson
3729 libpng maintainer
3730 PNG Development Group
3731
3732.SH NOTE
3733
3734Note about libpng version numbers:
3735
3736Due to various miscommunications, unforeseen code incompatibilities
3737and occasional factors outside the authors' control, version numbering
3738on the library has not always been consistent and straightforward.
3739The following table summarizes matters since version 0.89c, which was
3740the first widely used release:
3741
3742 source png.h png.h shared-lib
3743 version string int version
3744 ------- ------ ----- ----------
3745 0.89c ("beta 3") 0.89 89 1.0.89
3746 0.90 ("beta 4") 0.90 90 0.90
3747 0.95 ("beta 5") 0.95 95 0.95
3748 0.96 ("beta 6") 0.96 96 0.96
3749 0.97b ("beta 7") 1.00.97 97 1.0.1
3750 0.97c 0.97 97 2.0.97
3751 0.98 0.98 98 2.0.98
3752 0.99 0.99 98 2.0.99
3753 0.99a-m 0.99 99 2.0.99
3754 1.00 1.00 100 2.1.0
3755 1.0.0 1.0.0 100 2.1.0
3756 1.0.0 (from here on, the 100 2.1.0
3757 1.0.1 png.h string is 10001 2.1.0
3758 1.0.1a-e identical to the 10002 from here on, the
3759 1.0.2 source version) 10002 shared library is 2.V
3760 1.0.2a-b 10003 where V is the source
3761 1.0.1 10001 code version except as
3762 1.0.1a-e 10002 2.1.0.1a-e noted.
3763 1.0.2 10002 2.1.0.2
3764 1.0.2a-b 10003 2.1.0.2a-b
3765 1.0.3 10003 2.1.0.3
3766 1.0.3a-d 10004 2.1.0.3a-d
3767 1.0.4 10004 2.1.0.4
3768 1.0.4a-f 10005 2.1.0.4a-f
3769 1.0.5 (+ 2 patches) 10005 2.1.0.5
3770 1.0.5a-d 10006 2.1.0.5a-d
3771 1.0.5e-r 10100 2.1.0.5e-r
3772 1.0.5s-v 10006 2.1.0.5s-v
3773 1.0.6 (+ 3 patches) 10006 2.1.0.6
3774 1.0.6d-g 10007 2.1.0.6d-g
3775 1.0.6h 10007 10.6h
3776 1.0.6i 10007 10.6i
3777 1.0.6j 10007 2.1.0.6j
3778 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14
3779 1.0.7beta15-18 1 10007 2.1.0.7beta15-18
3780 1.0.7rc1-2 1 10007 2.1.0.7rc1-2
3781 1.0.7 1 10007 2.1.0.7
3782 1.0.8beta1-4 1 10008 2.1.0.8beta1-4
3783 1.0.8rc1 1 10008 2.1.0.8rc1
3784 1.0.8 1 10008 2.1.0.8
3785 1.0.9beta1-6 1 10009 2.1.0.9beta1-6
3786 1.0.9rc1 1 10009 2.1.0.9rc1
3787 1.0.9beta7-10 1 10009 2.1.0.9beta7-10
3788 1.0.9rc2 1 10009 2.1.0.9rc2
3789 1.0.9 1 10009 2.1.0.9
3790 1.0.10beta1 1 10010 2.1.0.10beta1
3791 1.0.10rc1 1 10010 2.1.0.10rc1
3792 1.0.10 1 10010 2.1.0.10
3793 1.0.11beta1-3 1 10011 2.1.0.11beta1-3
3794 1.0.11rc1 1 10011 2.1.0.11rc1
3795 1.0.11 1 10011 2.1.0.11
3796 1.0.12beta1-2 2 10012 2.1.0.12beta1-2
3797 1.0.12rc1 2 10012 2.1.0.12rc1
3798 1.0.12 2 10012 2.1.0.12
3799 1.1.0a-f - 10100 2.1.1.0a-f abandoned
3800 1.2.0beta1-2 2 10200 2.1.2.0beta1-2
3801 1.2.0beta3-5 3 10200 3.1.2.0beta3-5
3802 1.2.0rc1 3 10200 3.1.2.0rc1
3803 1.2.0 3 10200 3.1.2.0
3804 1.2.1beta-4 3 10201 3.1.2.1beta1-4
3805 1.2.1rc1-2 3 10201 3.1.2.1rc1-2
3806 1.2.1 3 10201 3.1.2.1
3807 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6
3808 1.0.13beta1 10 10013 10.so.0.1.0.13beta1
3809 1.0.13rc1 10 10013 10.so.0.1.0.13rc1
3810 1.2.2rc1 12 10202 12.so.0.1.2.2rc1
3811 1.0.13 10 10013 10.so.0.1.0.13
3812 1.2.2 12 10202 12.so.0.1.2.2
3813 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6
3814 1.2.3 12 10203 12.so.0.1.2.3
3815 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3
3816 1.2.4rc1 13 10204 12.so.0.1.2.4rc1
3817 1.0.14 10 10014 10.so.0.1.0.14
3818 1.2.4 13 10204 12.so.0.1.2.4
3819 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2
3820 1.0.15rc1 10 10015 10.so.0.1.0.15rc1
3821 1.0.15 10 10015 10.so.0.1.0.15
3822 1.2.5 13 10205 12.so.0.1.2.5
3823 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4
3824 1.2.6rc1-5 13 10206 12.so.0.1.2.6rc1-5
3825 1.0.16 10 10016 10.so.0.1.0.16
3826 1.2.6 13 10206 12.so.0.1.2.6
3827 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2
3828 1.0.17rc1 10 10017 10.so.0.1.0.17rc1
3829 1.2.7rc1 13 10207 12.so.0.1.2.7rc1
3830 1.0.17 10 10017 10.so.0.1.0.17
3831 1.2.7 13 10207 12.so.0.1.2.7
3832 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5
3833 1.0.18rc1-5 10 10018 10.so.0.1.0.18rc1-5
3834 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5
3835 1.0.18 10 10018 10.so.0.1.0.18
3836 1.2.8 13 10208 12.so.0.1.2.8
3837 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3
3838 1.2.9beta4-11 13 10209 12.so.0.9[.0]
3839 1.2.9rc1 13 10209 12.so.0.9[.0]
3840 1.2.9 13 10209 12.so.0.9[.0]
3841 1.2.10beta1-8 13 10210 12.so.0.10[.0]
3842 1.2.10rc1-3 13 10210 12.so.0.10[.0]
3843 1.2.10 13 10210 12.so.0.10[.0]
3844 1.2.11beta1-4 13 10211 12.so.0.11[.0]
3845 1.0.19rc1-5 10 10019 10.so.0.19[.0]
3846 1.2.11rc1-5 13 10211 12.so.0.11[.0]
3847 1.0.19 10 10019 10.so.0.19[.0]
3848 1.2.11 13 10211 12.so.0.11[.0]
3849 1.0.20 10 10020 10.so.0.20[.0]
3850 1.2.12 13 10212 12.so.0.12[.0]
3851 1.2.13beta1 13 10213 12.so.0.13[.0]
3852 1.0.21 10 10021 10.so.0.21[.0]
3853 1.2.13 13 10213 12.so.0.13[.0]
3854 1.2.14beta1-2 13 10214 12.so.0.14[.0]
3855 1.0.22rc1 10 10022 10.so.0.22[.0]
3856 1.2.14rc1 13 10214 12.so.0.14[.0]
3857 1.2.15beta1-6 13 10215 12.so.0.15[.0]
3858 1.0.23rc1-5 10 10023 10.so.0.23[.0]
3859 1.2.15rc1-5 13 10215 12.so.0.15[.0]
3860 1.0.23 10 10023 10.so.0.23[.0]
3861 1.2.15 13 10215 12.so.0.15[.0]
3862 1.2.16beta1-2 13 10216 12.so.0.16[.0]
3863 1.2.16rc1 13 10216 12.so.0.16[.0]
3864 1.0.24 10 10024 10.so.0.24[.0]
3865 1.2.16 13 10216 12.so.0.16[.0]
3866 1.2.17beta1-2 13 10217 12.so.0.17[.0]
3867 1.0.25rc1 10 10025 10.so.0.25[.0]
3868 1.2.17rc1-3 13 10217 12.so.0.17[.0]
3869 1.0.25 10 10025 10.so.0.25[.0]
3870 1.2.17 13 10217 12.so.0.17[.0]
3871 1.0.26 10 10026 10.so.0.26[.0]
3872 1.2.18 13 10218 12.so.0.18[.0]
3873 1.2.19beta1-31 13 10219 12.so.0.19[.0]
3874 1.0.27rc1-6 10 10027 10.so.0.27[.0]
3875 1.2.19rc1-6 13 10219 12.so.0.19[.0]
3876 1.0.27 10 10027 10.so.0.27[.0]
3877 1.2.19 13 10219 12.so.0.19[.0]
3878 1.2.20beta01-04 13 10220 12.so.0.20[.0]
3879 1.0.28rc1-6 10 10028 10.so.0.28[.0]
3880 1.2.20rc1-6 13 10220 12.so.0.20[.0]
3881 1.0.28 10 10028 10.so.0.28[.0]
3882 1.2.20 13 10220 12.so.0.20[.0]
3883 1.2.21beta1-2 13 10221 12.so.0.21[.0]
3884 1.2.21rc1-3 13 10221 12.so.0.21[.0]
3885 1.0.29 10 10029 10.so.0.29[.0]
3886 1.2.21 13 10221 12.so.0.21[.0]
3887 1.2.22beta1-4 13 10222 12.so.0.22[.0]
3888 1.0.30rc1 13 10030 10.so.0.30[.0]
3889 1.2.22rc1 13 10222 12.so.0.22[.0]
3890 1.0.30 10 10030 10.so.0.30[.0]
3891 1.2.22 13 10222 12.so.0.22[.0]
3892 1.2.23beta01-05 13 10223 12.so.0.23[.0]
3893 1.2.23rc01 13 10223 12.so.0.23[.0]
3894 1.2.23 13 10223 12.so.0.23[.0]
3895 1.2.24beta01-02 13 10224 12.so.0.24[.0]
3896 1.2.24rc01 13 10224 12.so.0.24[.0]
3897 1.2.24 13 10224 12.so.0.24[.0]
3898 1.2.25beta01-06 13 10225 12.so.0.25[.0]
3899 1.2.25rc01-02 13 10225 12.so.0.25[.0]
3900 1.0.31 10 10031 10.so.0.31[.0]
3901 1.2.25 13 10225 12.so.0.25[.0]
3902 1.2.26beta01-06 13 10226 12.so.0.26[.0]
3903 1.2.26rc01 13 10226 12.so.0.26[.0]
3904 1.2.26 13 10226 12.so.0.26[.0]
3905 1.0.32 10 10032 10.so.0.32[.0]
3906 1.2.27beta01-06 13 10227 12.so.0.27[.0]
3907 1.2.27rc01 13 10227 12.so.0.27[.0]
3908 1.0.33 10 10033 10.so.0.33[.0]
3909 1.2.27 13 10227 12.so.0.27[.0]
3910 1.0.34 10 10034 10.so.0.34[.0]
3911 1.2.28 13 10228 12.so.0.28[.0]
3912 1.2.29beta01-03 13 10229 12.so.0.29[.0]
3913 1.2.29rc01 13 10229 12.so.0.29[.0]
3914 1.0.35 10 10035 10.so.0.35[.0]
3915 1.2.29 13 10229 12.so.0.29[.0]
The Android Open Source Project4215dd12009-03-09 11:52:12 -07003916 1.0.37 10 10037 10.so.0.37[.0]
3917 1.2.30beta01-04 13 10230 12.so.0.30[.0]
3918 1.0.38rc01-08 10 10038 10.so.0.38[.0]
3919 1.2.30rc01-08 13 10230 12.so.0.30[.0]
3920 1.0.38 10 10038 10.so.0.38[.0]
3921 1.2.30 13 10230 12.so.0.30[.0]
3922 1.0.39rc01-03 10 10039 10.so.0.39[.0]
3923 1.2.31rc01-03 13 10231 12.so.0.31[.0]
3924 1.0.39 10 10039 10.so.0.39[.0]
3925 1.2.31 13 10231 12.so.0.31[.0]
3926 1.2.32beta01-02 13 10232 12.so.0.32[.0]
3927 1.0.40rc01 10 10040 10.so.0.40[.0]
3928 1.2.32rc01 13 10232 12.so.0.32[.0]
3929 1.0.40 10 10040 10.so.0.40[.0]
3930 1.2.32 13 10232 12.so.0.32[.0]
3931 1.2.33beta01-02 13 10233 12.so.0.33[.0]
3932 1.2.33rc01-02 13 10233 12.so.0.33[.0]
3933 1.0.41rc01 10 10041 10.so.0.41[.0]
3934 1.2.33 13 10233 12.so.0.33[.0]
3935 1.0.41 10 10041 10.so.0.41[.0]
3936 1.2.34beta01-07 13 10234 12.so.0.34[.0]
3937 1.0.42rc01 10 10042 10.so.0.42[.0]
3938 1.2.34rc01 13 10234 12.so.0.34[.0]
3939 1.0.42 10 10042 10.so.0.42[.0]
3940 1.2.34 13 10234 12.so.0.34[.0]
3941 1.2.35beta01-03 13 10235 12.so.0.35[.0]
3942 1.0.43rc01-02 10 10043 10.so.0.43[.0]
3943 1.2.35rc01-02 13 10235 12.so.0.35[.0]
3944 1.0.43 10 10043 10.so.0.43[.0]
3945 1.2.35 13 10235 12.so.0.35[.0]
The Android Open Source Project893912b2009-03-03 19:30:05 -08003946
3947Henceforth the source version will match the shared-library minor
3948and patch numbers; the shared-library major version number will be
3949used for changes in backward compatibility, as it is intended. The
3950PNG_PNGLIB_VER macro, which is not used within libpng but is available
3951for applications, is an unsigned integer of the form xyyzz corresponding
3952to the source version x.y.z (leading zeros in y and z). Beta versions
3953were given the previous public release number plus a letter, until
3954version 1.0.6j; from then on they were given the upcoming public
3955release number plus "betaNN" or "rcN".
3956
3957.SH "SEE ALSO"
3958.IR libpngpf(3) ", " png(5)
3959.LP
3960.IR libpng :
3961.IP
3962http://libpng.sourceforge.net (follow the [DOWNLOAD] link)
3963http://www.libpng.org/pub/png
3964
3965.LP
3966.IR zlib :
3967.IP
3968(generally) at the same location as
3969.I libpng
3970or at
3971.br
3972ftp://ftp.info-zip.org/pub/infozip/zlib
3973
3974.LP
3975.IR PNG specification: RFC 2083
3976.IP
3977(generally) at the same location as
3978.I libpng
3979or at
3980.br
3981ftp://ftp.rfc-editor.org:/in-notes/rfc2083.txt
3982.br
3983or (as a W3C Recommendation) at
3984.br
3985http://www.w3.org/TR/REC-png.html
3986
3987.LP
3988In the case of any inconsistency between the PNG specification
3989and this library, the specification takes precedence.
3990
3991.SH AUTHORS
3992This man page: Glenn Randers-Pehrson
3993<glennrp at users.sourceforge.net>
3994
3995The contributing authors would like to thank all those who helped
3996with testing, bug fixes, and patience. This wouldn't have been
3997possible without all of you.
3998
3999Thanks to Frank J. T. Wojcik for helping with the documentation.
4000
The Android Open Source Project4215dd12009-03-09 11:52:12 -07004001Libpng version 1.2.35 - February 14, 2009:
The Android Open Source Project893912b2009-03-03 19:30:05 -08004002Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
4003Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
4004
4005Supported by the PNG development group
4006.br
4007png-mng-implement at lists.sf.net
4008(subscription required; visit
4009png-mng-implement at lists.sourceforge.net (subscription required; visit
4010https://lists.sourceforge.net/lists/listinfo/png-mng-implement
4011to subscribe).
4012
4013.SH COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
4014
4015(This copy of the libpng notices is provided for your convenience. In case of
4016any discrepancy between this copy and the notices in the file png.h that is
4017included in the libpng distribution, the latter shall prevail.)
4018
4019If you modify libpng you may insert additional notices immediately following
4020this sentence.
4021
The Android Open Source Project4215dd12009-03-09 11:52:12 -07004022libpng versions 1.2.6, August 15, 2004, through 1.2.35, February 14, 2009, are
The Android Open Source Project893912b2009-03-03 19:30:05 -08004023Copyright (c) 2004,2006-2008 Glenn Randers-Pehrson, and are
4024distributed according to the same disclaimer and license as libpng-1.2.5
4025with the following individual added to the list of Contributing Authors
4026
4027 Cosmin Truta
4028
4029libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
4030Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
4031distributed according to the same disclaimer and license as libpng-1.0.6
4032with the following individuals added to the list of Contributing Authors
4033
4034 Simon-Pierre Cadieux
4035 Eric S. Raymond
4036 Gilles Vollant
4037
4038and with the following additions to the disclaimer:
4039
4040 There is no warranty against interference with your
4041 enjoyment of the library or against infringement.
4042 There is no warranty that our efforts or the library
4043 will fulfill any of your particular purposes or needs.
4044 This library is provided with all faults, and the entire
4045 risk of satisfactory quality, performance, accuracy, and
4046 effort is with the user.
4047
4048libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
4049Copyright (c) 1998, 1999 Glenn Randers-Pehrson
4050Distributed according to the same disclaimer and license as libpng-0.96,
4051with the following individuals added to the list of Contributing Authors:
4052
4053 Tom Lane
4054 Glenn Randers-Pehrson
4055 Willem van Schaik
4056
4057libpng versions 0.89, June 1996, through 0.96, May 1997, are
4058Copyright (c) 1996, 1997 Andreas Dilger
4059Distributed according to the same disclaimer and license as libpng-0.88,
4060with the following individuals added to the list of Contributing Authors:
4061
4062 John Bowler
4063 Kevin Bracey
4064 Sam Bushell
4065 Magnus Holmgren
4066 Greg Roelofs
4067 Tom Tanner
4068
4069libpng versions 0.5, May 1995, through 0.88, January 1996, are
4070Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
4071
4072For the purposes of this copyright and license, "Contributing Authors"
4073is defined as the following set of individuals:
4074
4075 Andreas Dilger
4076 Dave Martindale
4077 Guy Eric Schalnat
4078 Paul Schmidt
4079 Tim Wegner
4080
4081The PNG Reference Library is supplied "AS IS". The Contributing Authors
4082and Group 42, Inc. disclaim all warranties, expressed or implied,
4083including, without limitation, the warranties of merchantability and of
4084fitness for any purpose. The Contributing Authors and Group 42, Inc.
4085assume no liability for direct, indirect, incidental, special, exemplary,
4086or consequential damages, which may result from the use of the PNG
4087Reference Library, even if advised of the possibility of such damage.
4088
4089Permission is hereby granted to use, copy, modify, and distribute this
4090source code, or portions hereof, for any purpose, without fee, subject
4091to the following restrictions:
4092
40931. The origin of this source code must not be misrepresented.
4094
40952. Altered versions must be plainly marked as such and
4096 must not be misrepresented as being the original source.
4097
40983. This Copyright notice may not be removed or altered from
4099 any source or altered source distribution.
4100
4101The Contributing Authors and Group 42, Inc. specifically permit, without
4102fee, and encourage the use of this source code as a component to
4103supporting the PNG file format in commercial products. If you use this
4104source code in a product, acknowledgment is not required but would be
4105appreciated.
4106
4107
4108A "png_get_copyright" function is available, for convenient use in "about"
4109boxes and the like:
4110
4111 printf("%s",png_get_copyright(NULL));
4112
4113Also, the PNG logo (in PNG format, of course) is supplied in the
4114files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
4115
4116Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
4117certification mark of the Open Source Initiative.
4118
4119Glenn Randers-Pehrson
4120glennrp at users.sourceforge.net
The Android Open Source Project4215dd12009-03-09 11:52:12 -07004121February 14, 2009
The Android Open Source Project893912b2009-03-03 19:30:05 -08004122
4123.\" end of man page
4124