blob: 7f685640b76bc5296c98f1324ffd34d916b4c7aa [file] [log] [blame]
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001.TH LIBPNG 3 "July 16, 2009"
The Android Open Source Project893912b2009-03-03 19:30:05 -08002.SH NAME
Patrick Scotta0bb96c2009-07-22 11:50:02 -04003libpng \- Portable Network Graphics (PNG) Reference Library 1.2.38
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
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400824 libpng version 1.2.38 - July 16, 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>
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400827 Copyright (c) 1998-2009 Glenn Randers-Pehrson
The Android Open Source Project893912b2009-03-03 19:30:05 -0800828 For conditions of distribution and use, see copyright
829 notice in png.h.
830
831 Based on:
832
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400833 libpng versions 0.97, January 1998, through 1.2.38 - July 16, 2009
The Android Open Source Project893912b2009-03-03 19:30:05 -0800834 Updated and distributed by Glenn Randers-Pehrson
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400835 Copyright (c) 1998-2009 Glenn Randers-Pehrson
The Android Open Source Project893912b2009-03-03 19:30:05 -0800836
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
Patrick Scotta0bb96c2009-07-22 11:50:02 -0400965png_sig_cmp(), and it will return 0 (false) if the bytes match the
966corresponding bytes of the PNG signature, or nonzero (true) otherwise.
967Of course, the more bytes you pass in, the greater the accuracy of the
968prediction.
The Android Open Source Project893912b2009-03-03 19:30:05 -0800969
970If you are intending to keep the file pointer open for use in libpng,
971you must ensure you don't read more than 8 bytes from the beginning
972of the file, and you also have to make a call to png_set_sig_bytes_read()
973with the number of bytes you read from the beginning. Libpng will
974then only check the bytes (if any) that your program didn't read.
975
976(*): If you are not using the standard I/O functions, you will need
977to replace them with custom functions. See the discussion under
978Customizing libpng.
979
980
981 FILE *fp = fopen(file_name, "rb");
982 if (!fp)
983 {
984 return (ERROR);
985 }
986 fread(header, 1, number, fp);
987 is_png = !png_sig_cmp(header, 0, number);
988 if (!is_png)
989 {
990 return (NOT_PNG);
991 }
992
993
994Next, png_struct and png_info need to be allocated and initialized. In
995order to ensure that the size of these structures is correct even with a
996dynamically linked libpng, there are functions to initialize and
997allocate the structures. We also pass the library version, optional
998pointers to error handling functions, and a pointer to a data struct for
999use by the error functions, if necessary (the pointer and functions can
1000be NULL if the default error handlers are to be used). See the section
1001on Changes to Libpng below regarding the old initialization functions.
1002The structure allocation functions quietly return NULL if they fail to
1003create the structure, so your application should check for that.
1004
1005 png_structp png_ptr = png_create_read_struct
1006 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
1007 user_error_fn, user_warning_fn);
1008 if (!png_ptr)
1009 return (ERROR);
1010
1011 png_infop info_ptr = png_create_info_struct(png_ptr);
1012 if (!info_ptr)
1013 {
1014 png_destroy_read_struct(&png_ptr,
1015 (png_infopp)NULL, (png_infopp)NULL);
1016 return (ERROR);
1017 }
1018
1019 png_infop end_info = png_create_info_struct(png_ptr);
1020 if (!end_info)
1021 {
1022 png_destroy_read_struct(&png_ptr, &info_ptr,
1023 (png_infopp)NULL);
1024 return (ERROR);
1025 }
1026
1027If you want to use your own memory allocation routines,
1028define PNG_USER_MEM_SUPPORTED and use
1029png_create_read_struct_2() instead of png_create_read_struct():
1030
1031 png_structp png_ptr = png_create_read_struct_2
1032 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
1033 user_error_fn, user_warning_fn, (png_voidp)
1034 user_mem_ptr, user_malloc_fn, user_free_fn);
1035
1036The error handling routines passed to png_create_read_struct()
1037and the memory alloc/free routines passed to png_create_struct_2()
1038are only necessary if you are not using the libpng supplied error
1039handling and memory alloc/free functions.
1040
1041When libpng encounters an error, it expects to longjmp back
1042to your routine. Therefore, you will need to call setjmp and pass
1043your png_jmpbuf(png_ptr). If you read the file from different
1044routines, you will need to update the jmpbuf field every time you enter
1045a new routine that will call a png_*() function.
1046
1047See your documentation of setjmp/longjmp for your compiler for more
1048information on setjmp/longjmp. See the discussion on libpng error
1049handling in the Customizing Libpng section below for more information
1050on the libpng error handling. If an error occurs, and libpng longjmp's
1051back to your setjmp, you will want to call png_destroy_read_struct() to
1052free any memory.
1053
1054 if (setjmp(png_jmpbuf(png_ptr)))
1055 {
1056 png_destroy_read_struct(&png_ptr, &info_ptr,
1057 &end_info);
1058 fclose(fp);
1059 return (ERROR);
1060 }
1061
1062If you would rather avoid the complexity of setjmp/longjmp issues,
1063you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case
1064errors will result in a call to PNG_ABORT() which defaults to abort().
1065
1066Now you need to set up the input code. The default for libpng is to
1067use the C function fread(). If you use this, you will need to pass a
1068valid FILE * in the function png_init_io(). Be sure that the file is
1069opened in binary mode. If you wish to handle reading data in another
1070way, you need not call the png_init_io() function, but you must then
1071implement the libpng I/O methods discussed in the Customizing Libpng
1072section below.
1073
1074 png_init_io(png_ptr, fp);
1075
1076If you had previously opened the file and read any of the signature from
1077the beginning in order to see if this was a PNG file, you need to let
1078libpng know that there are some bytes missing from the start of the file.
1079
1080 png_set_sig_bytes(png_ptr, number);
1081
1082.SS Setting up callback code
1083
1084You can set up a callback function to handle any unknown chunks in the
1085input stream. You must supply the function
1086
1087 read_chunk_callback(png_ptr ptr,
1088 png_unknown_chunkp chunk);
1089 {
1090 /* The unknown chunk structure contains your
1091 chunk data, along with similar data for any other
1092 unknown chunks: */
1093
1094 png_byte name[5];
1095 png_byte *data;
1096 png_size_t size;
1097
1098 /* Note that libpng has already taken care of
1099 the CRC handling */
1100
1101 /* put your code here. Search for your chunk in the
1102 unknown chunk structure, process it, and return one
1103 of the following: */
1104
1105 return (-n); /* chunk had an error */
1106 return (0); /* did not recognize */
1107 return (n); /* success */
1108 }
1109
1110(You can give your function another name that you like instead of
1111"read_chunk_callback")
1112
1113To inform libpng about your function, use
1114
1115 png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr,
1116 read_chunk_callback);
1117
1118This names not only the callback function, but also a user pointer that
1119you can retrieve with
1120
1121 png_get_user_chunk_ptr(png_ptr);
1122
1123If you call the png_set_read_user_chunk_fn() function, then all unknown
1124chunks will be saved when read, in case your callback function will need
1125one or more of them. This behavior can be changed with the
1126png_set_keep_unknown_chunks() function, described below.
1127
1128At this point, you can set up a callback function that will be
1129called after each row has been read, which you can use to control
1130a progress meter or the like. It's demonstrated in pngtest.c.
1131You must supply a function
1132
1133 void read_row_callback(png_ptr ptr, png_uint_32 row,
1134 int pass);
1135 {
1136 /* put your code here */
1137 }
1138
1139(You can give it another name that you like instead of "read_row_callback")
1140
1141To inform libpng about your function, use
1142
1143 png_set_read_status_fn(png_ptr, read_row_callback);
1144
The Android Open Source Project893912b2009-03-03 19:30:05 -08001145.SS Unknown-chunk handling
1146
1147Now you get to set the way the library processes unknown chunks in the
1148input PNG stream. Both known and unknown chunks will be read. Normal
1149behavior is that known chunks will be parsed into information in
The Android Open Source Project4215dd12009-03-09 11:52:12 -07001150various info_ptr members while unknown chunks will be discarded. This
1151behavior can be wasteful if your application will never use some known
1152chunk types. To change this, you can call:
The Android Open Source Project893912b2009-03-03 19:30:05 -08001153
1154 png_set_keep_unknown_chunks(png_ptr, keep,
1155 chunk_list, num_chunks);
1156 keep - 0: default unknown chunk handling
1157 1: ignore; do not keep
1158 2: keep only if safe-to-copy
1159 3: keep even if unsafe-to-copy
1160 You can use these definitions:
1161 PNG_HANDLE_CHUNK_AS_DEFAULT 0
1162 PNG_HANDLE_CHUNK_NEVER 1
1163 PNG_HANDLE_CHUNK_IF_SAFE 2
1164 PNG_HANDLE_CHUNK_ALWAYS 3
1165 chunk_list - list of chunks affected (a byte string,
1166 five bytes per chunk, NULL or '\0' if
1167 num_chunks is 0)
1168 num_chunks - number of chunks affected; if 0, all
1169 unknown chunks are affected. If nonzero,
1170 only the chunks in the list are affected
1171
1172Unknown chunks declared in this way will be saved as raw data onto a
1173list of png_unknown_chunk structures. If a chunk that is normally
1174known to libpng is named in the list, it will be handled as unknown,
1175according to the "keep" directive. If a chunk is named in successive
1176instances of png_set_keep_unknown_chunks(), the final instance will
1177take precedence. The IHDR and IEND chunks should not be named in
1178chunk_list; if they are, libpng will process them normally anyway.
1179
1180Here is an example of the usage of png_set_keep_unknown_chunks(),
1181where the private "vpAg" chunk will later be processed by a user chunk
1182callback function:
1183
1184 png_byte vpAg[5]={118, 112, 65, 103, (png_byte) '\0'};
1185
1186 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
1187 png_byte unused_chunks[]=
1188 {
1189 104, 73, 83, 84, (png_byte) '\0', /* hIST */
1190 105, 84, 88, 116, (png_byte) '\0', /* iTXt */
1191 112, 67, 65, 76, (png_byte) '\0', /* pCAL */
1192 115, 67, 65, 76, (png_byte) '\0', /* sCAL */
1193 115, 80, 76, 84, (png_byte) '\0', /* sPLT */
1194 116, 73, 77, 69, (png_byte) '\0', /* tIME */
1195 };
1196 #endif
1197
1198 ...
1199
1200 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
1201 /* ignore all unknown chunks: */
1202 png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0);
1203 /* except for vpAg: */
1204 png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1);
1205 /* also ignore unused known chunks: */
1206 png_set_keep_unknown_chunks(read_ptr, 1, unused_chunks,
1207 (int)sizeof(unused_chunks)/5);
1208 #endif
1209
Patrick Scotta0bb96c2009-07-22 11:50:02 -04001210.SS User limits
1211
1212The PNG specification allows the width and height of an image to be as
1213large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns.
1214Since very few applications really need to process such large images,
1215we have imposed an arbitrary 1-million limit on rows and columns.
1216Larger images will be rejected immediately with a png_error() call. If
1217you wish to override this limit, you can use
1218
1219 png_set_user_limits(png_ptr, width_max, height_max);
1220
1221to set your own limits, or use width_max = height_max = 0x7fffffffL
1222to allow all valid dimensions (libpng may reject some very large images
1223anyway because of potential buffer overflow conditions).
1224
1225You should put this statement after you create the PNG structure and
1226before calling png_read_info(), png_read_png(), or png_process_data().
1227If you need to retrieve the limits that are being applied, use
1228
1229 width_max = png_get_user_width_max(png_ptr);
1230 height_max = png_get_user_height_max(png_ptr);
The Android Open Source Project893912b2009-03-03 19:30:05 -08001231
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.
The Android Open Source Project893912b2009-03-03 19:30:05 -08001674
1675PNG can have files with 16 bits per channel. If you only can handle
16768 bits per channel, this will strip the pixels down to 8 bit.
1677
1678 if (bit_depth == 16)
1679 png_set_strip_16(png_ptr);
1680
1681If, for some reason, you don't need the alpha channel on an image,
1682and you want to remove it rather than combining it with the background
1683(but the image author certainly had in mind that you *would* combine
1684it with the background, so that's what you should probably do):
1685
1686 if (color_type & PNG_COLOR_MASK_ALPHA)
1687 png_set_strip_alpha(png_ptr);
1688
1689In PNG files, the alpha channel in an image
1690is the level of opacity. If you need the alpha channel in an image to
1691be the level of transparency instead of opacity, you can invert the
1692alpha channel (or the tRNS chunk data) after it's read, so that 0 is
1693fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit
1694images) is fully transparent, with
1695
1696 png_set_invert_alpha(png_ptr);
1697
1698PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
1699they can, resulting in, for example, 8 pixels per byte for 1 bit
1700files. This code expands to 1 pixel per byte without changing the
1701values of the pixels:
1702
1703 if (bit_depth < 8)
1704 png_set_packing(png_ptr);
1705
1706PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels
1707stored in a PNG image have been "scaled" or "shifted" up to the next
1708higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to
17098 bits/sample in the range [0, 255]). However, it is also possible to
1710convert the PNG pixel data back to the original bit depth of the image.
1711This call reduces the pixels back down to the original bit depth:
1712
1713 png_color_8p sig_bit;
1714
1715 if (png_get_sBIT(png_ptr, info_ptr, &sig_bit))
1716 png_set_shift(png_ptr, sig_bit);
1717
1718PNG files store 3-color pixels in red, green, blue order. This code
1719changes the storage of the pixels to blue, green, red:
1720
1721 if (color_type == PNG_COLOR_TYPE_RGB ||
1722 color_type == PNG_COLOR_TYPE_RGB_ALPHA)
1723 png_set_bgr(png_ptr);
1724
1725PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them
1726into 4 or 8 bytes for windowing systems that need them in this format:
1727
1728 if (color_type == PNG_COLOR_TYPE_RGB)
1729 png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE);
1730
1731where "filler" is the 8 or 16-bit number to fill with, and the location is
1732either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether
1733you want the filler before the RGB or after. This transformation
1734does not affect images that already have full alpha channels. To add an
1735opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which
1736will generate RGBA pixels.
1737
1738Note that png_set_filler() does not change the color type. If you want
1739to do that, you can add a true alpha channel with
1740
1741 if (color_type == PNG_COLOR_TYPE_RGB ||
1742 color_type == PNG_COLOR_TYPE_GRAY)
1743 png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER);
1744
1745where "filler" contains the alpha value to assign to each pixel.
1746This function was added in libpng-1.2.7.
1747
1748If you are reading an image with an alpha channel, and you need the
1749data as ARGB instead of the normal PNG format RGBA:
1750
1751 if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
1752 png_set_swap_alpha(png_ptr);
1753
1754For some uses, you may want a grayscale image to be represented as
1755RGB. This code will do that conversion:
1756
1757 if (color_type == PNG_COLOR_TYPE_GRAY ||
1758 color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
1759 png_set_gray_to_rgb(png_ptr);
1760
1761Conversely, you can convert an RGB or RGBA image to grayscale or grayscale
1762with alpha.
1763
1764 if (color_type == PNG_COLOR_TYPE_RGB ||
1765 color_type == PNG_COLOR_TYPE_RGB_ALPHA)
1766 png_set_rgb_to_gray_fixed(png_ptr, error_action,
1767 int red_weight, int green_weight);
1768
1769 error_action = 1: silently do the conversion
1770 error_action = 2: issue a warning if the original
1771 image has any pixel where
1772 red != green or red != blue
1773 error_action = 3: issue an error and abort the
1774 conversion if the original
1775 image has any pixel where
1776 red != green or red != blue
1777
1778 red_weight: weight of red component times 100000
1779 green_weight: weight of green component times 100000
1780 If either weight is negative, default
1781 weights (21268, 71514) are used.
1782
1783If you have set error_action = 1 or 2, you can
1784later check whether the image really was gray, after processing
1785the image rows, with the png_get_rgb_to_gray_status(png_ptr) function.
1786It will return a png_byte that is zero if the image was gray or
17871 if there were any non-gray pixels. bKGD and sBIT data
1788will be silently converted to grayscale, using the green channel
1789data, regardless of the error_action setting.
1790
1791With red_weight+green_weight<=100000,
1792the normalized graylevel is computed:
1793
1794 int rw = red_weight * 65536;
1795 int gw = green_weight * 65536;
1796 int bw = 65536 - (rw + gw);
1797 gray = (rw*red + gw*green + bw*blue)/65536;
1798
1799The default values approximate those recommended in the Charles
1800Poynton's Color FAQ, <http://www.inforamp.net/~poynton/>
1801Copyright (c) 1998-01-04 Charles Poynton <poynton at inforamp.net>
1802
1803 Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
1804
1805Libpng approximates this with
1806
1807 Y = 0.21268 * R + 0.7151 * G + 0.07217 * B
1808
1809which can be expressed with integers as
1810
1811 Y = (6969 * R + 23434 * G + 2365 * B)/32768
1812
1813The calculation is done in a linear colorspace, if the image gamma
1814is known.
1815
1816If you have a grayscale and you are using png_set_expand_depth(),
1817png_set_expand(), or png_set_gray_to_rgb to change to truecolor or to
1818a higher bit-depth, you must either supply the background color as a gray
1819value at the original file bit-depth (need_expand = 1) or else supply the
1820background color as an RGB triplet at the final, expanded bit depth
1821(need_expand = 0). Similarly, if you are reading a paletted image, you
1822must either supply the background color as a palette index (need_expand = 1)
1823or as an RGB triplet that may or may not be in the palette (need_expand = 0).
1824
1825 png_color_16 my_background;
1826 png_color_16p image_background;
1827
1828 if (png_get_bKGD(png_ptr, info_ptr, &image_background))
1829 png_set_background(png_ptr, image_background,
1830 PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
1831 else
1832 png_set_background(png_ptr, &my_background,
1833 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
1834
1835The png_set_background() function tells libpng to composite images
1836with alpha or simple transparency against the supplied background
1837color. If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid),
1838you may use this color, or supply another color more suitable for
1839the current display (e.g., the background color from a web page). You
1840need to tell libpng whether the color is in the gamma space of the
1841display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file
1842(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one
1843that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't
1844know why anyone would use this, but it's here).
1845
1846To properly display PNG images on any kind of system, the application needs
1847to know what the display gamma is. Ideally, the user will know this, and
1848the application will allow them to set it. One method of allowing the user
1849to set the display gamma separately for each system is to check for a
1850SCREEN_GAMMA or DISPLAY_GAMMA environment variable, which will hopefully be
1851correctly set.
1852
1853Note that display_gamma is the overall gamma correction required to produce
1854pleasing results, which depends on the lighting conditions in the surrounding
1855environment. In a dim or brightly lit room, no compensation other than
1856the physical gamma exponent of the monitor is needed, while in a dark room
1857a slightly smaller exponent is better.
1858
1859 double gamma, screen_gamma;
1860
1861 if (/* We have a user-defined screen
1862 gamma value */)
1863 {
1864 screen_gamma = user_defined_screen_gamma;
1865 }
1866 /* One way that applications can share the same
1867 screen gamma value */
1868 else if ((gamma_str = getenv("SCREEN_GAMMA"))
1869 != NULL)
1870 {
1871 screen_gamma = (double)atof(gamma_str);
1872 }
1873 /* If we don't have another value */
1874 else
1875 {
1876 screen_gamma = 2.2; /* A good guess for a
1877 PC monitor in a bright office or a dim room */
1878 screen_gamma = 2.0; /* A good guess for a
1879 PC monitor in a dark room */
1880 screen_gamma = 1.7 or 1.0; /* A good
1881 guess for Mac systems */
1882 }
1883
1884The png_set_gamma() function handles gamma transformations of the data.
1885Pass both the file gamma and the current screen_gamma. If the file does
1886not have a gamma value, you can pass one anyway if you have an idea what
1887it is (usually 0.45455 is a good guess for GIF images on PCs). Note
1888that file gammas are inverted from screen gammas. See the discussions
1889on gamma in the PNG specification for an excellent description of what
1890gamma is, and why all applications should support it. It is strongly
1891recommended that PNG viewers support gamma correction.
1892
1893 if (png_get_gAMA(png_ptr, info_ptr, &gamma))
1894 png_set_gamma(png_ptr, screen_gamma, gamma);
1895 else
1896 png_set_gamma(png_ptr, screen_gamma, 0.45455);
1897
1898If you need to reduce an RGB file to a paletted file, or if a paletted
1899file has more entries then will fit on your screen, png_set_dither()
1900will do that. Note that this is a simple match dither that merely
1901finds the closest color available. This should work fairly well with
1902optimized palettes, and fairly badly with linear color cubes. If you
1903pass a palette that is larger then maximum_colors, the file will
1904reduce the number of colors in the palette so it will fit into
1905maximum_colors. If there is a histogram, it will use it to make
1906more intelligent choices when reducing the palette. If there is no
1907histogram, it may not do as good a job.
1908
1909 if (color_type & PNG_COLOR_MASK_COLOR)
1910 {
1911 if (png_get_valid(png_ptr, info_ptr,
1912 PNG_INFO_PLTE))
1913 {
1914 png_uint_16p histogram = NULL;
1915
1916 png_get_hIST(png_ptr, info_ptr,
1917 &histogram);
1918 png_set_dither(png_ptr, palette, num_palette,
1919 max_screen_colors, histogram, 1);
1920 }
1921 else
1922 {
1923 png_color std_color_cube[MAX_SCREEN_COLORS] =
1924 { ... colors ... };
1925
1926 png_set_dither(png_ptr, std_color_cube,
1927 MAX_SCREEN_COLORS, MAX_SCREEN_COLORS,
1928 NULL,0);
1929 }
1930 }
1931
1932PNG files describe monochrome as black being zero and white being one.
1933The following code will reverse this (make black be one and white be
1934zero):
1935
1936 if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY)
1937 png_set_invert_mono(png_ptr);
1938
1939This function can also be used to invert grayscale and gray-alpha images:
1940
1941 if (color_type == PNG_COLOR_TYPE_GRAY ||
1942 color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
1943 png_set_invert_mono(png_ptr);
1944
1945PNG files store 16 bit pixels in network byte order (big-endian,
1946ie. most significant bits first). This code changes the storage to the
1947other way (little-endian, i.e. least significant bits first, the
1948way PCs store them):
1949
1950 if (bit_depth == 16)
1951 png_set_swap(png_ptr);
1952
1953If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you
1954need to change the order the pixels are packed into bytes, you can use:
1955
1956 if (bit_depth < 8)
1957 png_set_packswap(png_ptr);
1958
1959Finally, you can write your own transformation function if none of
1960the existing ones meets your needs. This is done by setting a callback
1961with
1962
1963 png_set_read_user_transform_fn(png_ptr,
1964 read_transform_fn);
1965
1966You must supply the function
1967
1968 void read_transform_fn(png_ptr ptr, row_info_ptr
1969 row_info, png_bytep data)
1970
1971See pngtest.c for a working example. Your function will be called
1972after all of the other transformations have been processed.
1973
1974You can also set up a pointer to a user structure for use by your
1975callback function, and you can inform libpng that your transform
1976function will change the number of channels or bit depth with the
1977function
1978
1979 png_set_user_transform_info(png_ptr, user_ptr,
1980 user_depth, user_channels);
1981
1982The user's application, not libpng, is responsible for allocating and
1983freeing any memory required for the user structure.
1984
1985You can retrieve the pointer via the function
1986png_get_user_transform_ptr(). For example:
1987
1988 voidp read_user_transform_ptr =
1989 png_get_user_transform_ptr(png_ptr);
1990
1991The last thing to handle is interlacing; this is covered in detail below,
1992but you must call the function here if you want libpng to handle expansion
1993of the interlaced image.
1994
1995 number_of_passes = png_set_interlace_handling(png_ptr);
1996
1997After setting the transformations, libpng can update your png_info
1998structure to reflect any transformations you've requested with this
1999call. This is most useful to update the info structure's rowbytes
2000field so you can use it to allocate your image memory. This function
2001will also update your palette with the correct screen_gamma and
2002background if these have been given with the calls above.
2003
2004 png_read_update_info(png_ptr, info_ptr);
2005
2006After you call png_read_update_info(), you can allocate any
2007memory you need to hold the image. The row data is simply
2008raw byte data for all forms of images. As the actual allocation
2009varies among applications, no example will be given. If you
2010are allocating one large chunk, you will need to build an
2011array of pointers to each row, as it will be needed for some
2012of the functions below.
2013
2014.SS Reading image data
2015
2016After you've allocated memory, you can read the image data.
2017The simplest way to do this is in one function call. If you are
2018allocating enough memory to hold the whole image, you can just
2019call png_read_image() and libpng will read in all the image data
2020and put it in the memory area supplied. You will need to pass in
2021an array of pointers to each row.
2022
2023This function automatically handles interlacing, so you don't need
2024to call png_set_interlace_handling() or call this function multiple
2025times, or any of that other stuff necessary with png_read_rows().
2026
2027 png_read_image(png_ptr, row_pointers);
2028
2029where row_pointers is:
2030
2031 png_bytep row_pointers[height];
2032
2033You can point to void or char or whatever you use for pixels.
2034
2035If you don't want to read in the whole image at once, you can
2036use png_read_rows() instead. If there is no interlacing (check
2037interlace_type == PNG_INTERLACE_NONE), this is simple:
2038
2039 png_read_rows(png_ptr, row_pointers, NULL,
2040 number_of_rows);
2041
2042where row_pointers is the same as in the png_read_image() call.
2043
2044If you are doing this just one row at a time, you can do this with
2045a single row_pointer instead of an array of row_pointers:
2046
2047 png_bytep row_pointer = row;
2048 png_read_row(png_ptr, row_pointer, NULL);
2049
2050If the file is interlaced (interlace_type != 0 in the IHDR chunk), things
2051get somewhat harder. The only current (PNG Specification version 1.2)
2052interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7)
2053is a somewhat complicated 2D interlace scheme, known as Adam7, that
2054breaks down an image into seven smaller images of varying size, based
2055on an 8x8 grid.
2056
2057libpng can fill out those images or it can give them to you "as is".
2058If you want them filled out, there are two ways to do that. The one
2059mentioned in the PNG specification is to expand each pixel to cover
2060those pixels that have not been read yet (the "rectangle" method).
2061This results in a blocky image for the first pass, which gradually
2062smooths out as more pixels are read. The other method is the "sparkle"
2063method, where pixels are drawn only in their final locations, with the
2064rest of the image remaining whatever colors they were initialized to
2065before the start of the read. The first method usually looks better,
2066but tends to be slower, as there are more pixels to put in the rows.
2067
2068If you don't want libpng to handle the interlacing details, just call
2069png_read_rows() seven times to read in all seven images. Each of the
2070images is a valid image by itself, or they can all be combined on an
20718x8 grid to form a single image (although if you intend to combine them
2072you would be far better off using the libpng interlace handling).
2073
2074The first pass will return an image 1/8 as wide as the entire image
2075(every 8th column starting in column 0) and 1/8 as high as the original
2076(every 8th row starting in row 0), the second will be 1/8 as wide
2077(starting in column 4) and 1/8 as high (also starting in row 0). The
2078third pass will be 1/4 as wide (every 4th pixel starting in column 0) and
20791/8 as high (every 8th row starting in row 4), and the fourth pass will
2080be 1/4 as wide and 1/4 as high (every 4th column starting in column 2,
2081and every 4th row starting in row 0). The fifth pass will return an
2082image 1/2 as wide, and 1/4 as high (starting at column 0 and row 2),
2083while the sixth pass will be 1/2 as wide and 1/2 as high as the original
2084(starting in column 1 and row 0). The seventh and final pass will be as
2085wide as the original, and 1/2 as high, containing all of the odd
2086numbered scanlines. Phew!
2087
2088If you want libpng to expand the images, call this before calling
2089png_start_read_image() or png_read_update_info():
2090
2091 if (interlace_type == PNG_INTERLACE_ADAM7)
2092 number_of_passes
2093 = png_set_interlace_handling(png_ptr);
2094
2095This will return the number of passes needed. Currently, this
2096is seven, but may change if another interlace type is added.
2097This function can be called even if the file is not interlaced,
2098where it will return one pass.
2099
2100If you are not going to display the image after each pass, but are
2101going to wait until the entire image is read in, use the sparkle
2102effect. This effect is faster and the end result of either method
2103is exactly the same. If you are planning on displaying the image
2104after each pass, the "rectangle" effect is generally considered the
2105better looking one.
2106
2107If you only want the "sparkle" effect, just call png_read_rows() as
2108normal, with the third parameter NULL. Make sure you make pass over
2109the image number_of_passes times, and you don't change the data in the
2110rows between calls. You can change the locations of the data, just
2111not the data. Each pass only writes the pixels appropriate for that
2112pass, and assumes the data from previous passes is still valid.
2113
2114 png_read_rows(png_ptr, row_pointers, NULL,
2115 number_of_rows);
2116
2117If you only want the first effect (the rectangles), do the same as
2118before except pass the row buffer in the third parameter, and leave
2119the second parameter NULL.
2120
2121 png_read_rows(png_ptr, NULL, row_pointers,
2122 number_of_rows);
2123
2124.SS Finishing a sequential read
2125
2126After you are finished reading the image through the
2127low-level interface, you can finish reading the file. If you are
2128interested in comments or time, which may be stored either before or
2129after the image data, you should pass the separate png_info struct if
2130you want to keep the comments from before and after the image
2131separate. If you are not interested, you can pass NULL.
2132
2133 png_read_end(png_ptr, end_info);
2134
2135When you are done, you can free all memory allocated by libpng like this:
2136
2137 png_destroy_read_struct(&png_ptr, &info_ptr,
2138 &end_info);
2139
2140It is also possible to individually free the info_ptr members that
2141point to libpng-allocated storage with the following function:
2142
2143 png_free_data(png_ptr, info_ptr, mask, seq)
2144 mask - identifies data to be freed, a mask
2145 containing the bitwise OR of one or
2146 more of
2147 PNG_FREE_PLTE, PNG_FREE_TRNS,
2148 PNG_FREE_HIST, PNG_FREE_ICCP,
2149 PNG_FREE_PCAL, PNG_FREE_ROWS,
2150 PNG_FREE_SCAL, PNG_FREE_SPLT,
2151 PNG_FREE_TEXT, PNG_FREE_UNKN,
2152 or simply PNG_FREE_ALL
2153 seq - sequence number of item to be freed
2154 (-1 for all items)
2155
2156This function may be safely called when the relevant storage has
2157already been freed, or has not yet been allocated, or was allocated
2158by the user and not by libpng, and will in those
2159cases do nothing. The "seq" parameter is ignored if only one item
2160of the selected data type, such as PLTE, is allowed. If "seq" is not
2161-1, and multiple items are allowed for the data type identified in
2162the mask, such as text or sPLT, only the n'th item in the structure
2163is freed, where n is "seq".
2164
2165The default behavior is only to free data that was allocated internally
2166by libpng. This can be changed, so that libpng will not free the data,
2167or so that it will free data that was allocated by the user with png_malloc()
2168or png_zalloc() and passed in via a png_set_*() function, with
2169
2170 png_data_freer(png_ptr, info_ptr, freer, mask)
2171 mask - which data elements are affected
2172 same choices as in png_free_data()
2173 freer - one of
2174 PNG_DESTROY_WILL_FREE_DATA
2175 PNG_SET_WILL_FREE_DATA
2176 PNG_USER_WILL_FREE_DATA
2177
2178This function only affects data that has already been allocated.
2179You can call this function after reading the PNG data but before calling
2180any png_set_*() functions, to control whether the user or the png_set_*()
2181function is responsible for freeing any existing data that might be present,
2182and again after the png_set_*() functions to control whether the user
2183or png_destroy_*() is supposed to free the data. When the user assumes
2184responsibility for libpng-allocated data, the application must use
2185png_free() to free it, and when the user transfers responsibility to libpng
2186for data that the user has allocated, the user must have used png_malloc()
2187or png_zalloc() to allocate it.
2188
2189If you allocated your row_pointers in a single block, as suggested above in
2190the description of the high level read interface, you must not transfer
2191responsibility for freeing it to the png_set_rows or png_read_destroy function,
2192because they would also try to free the individual row_pointers[i].
2193
2194If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword
2195separately, do not transfer responsibility for freeing text_ptr to libpng,
2196because when libpng fills a png_text structure it combines these members with
2197the key member, and png_free_data() will free only text_ptr.key. Similarly,
2198if you transfer responsibility for free'ing text_ptr from libpng to your
2199application, your application must not separately free those members.
2200
2201The png_free_data() function will turn off the "valid" flag for anything
2202it frees. If you need to turn the flag off for a chunk that was freed by your
2203application instead of by libpng, you can use
2204
2205 png_set_invalid(png_ptr, info_ptr, mask);
2206 mask - identifies the chunks to be made invalid,
2207 containing the bitwise OR of one or
2208 more of
2209 PNG_INFO_gAMA, PNG_INFO_sBIT,
2210 PNG_INFO_cHRM, PNG_INFO_PLTE,
2211 PNG_INFO_tRNS, PNG_INFO_bKGD,
2212 PNG_INFO_hIST, PNG_INFO_pHYs,
2213 PNG_INFO_oFFs, PNG_INFO_tIME,
2214 PNG_INFO_pCAL, PNG_INFO_sRGB,
2215 PNG_INFO_iCCP, PNG_INFO_sPLT,
2216 PNG_INFO_sCAL, PNG_INFO_IDAT
2217
2218For a more compact example of reading a PNG image, see the file example.c.
2219
2220.SS Reading PNG files progressively
2221
2222The progressive reader is slightly different then the non-progressive
2223reader. Instead of calling png_read_info(), png_read_rows(), and
2224png_read_end(), you make one call to png_process_data(), which calls
2225callbacks when it has the info, a row, or the end of the image. You
2226set up these callbacks with png_set_progressive_read_fn(). You don't
2227have to worry about the input/output functions of libpng, as you are
2228giving the library the data directly in png_process_data(). I will
2229assume that you have read the section on reading PNG files above,
2230so I will only highlight the differences (although I will show
2231all of the code).
2232
2233png_structp png_ptr;
2234png_infop info_ptr;
2235
2236 /* An example code fragment of how you would
2237 initialize the progressive reader in your
2238 application. */
2239 int
2240 initialize_png_reader()
2241 {
2242 png_ptr = png_create_read_struct
2243 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
2244 user_error_fn, user_warning_fn);
2245 if (!png_ptr)
2246 return (ERROR);
2247 info_ptr = png_create_info_struct(png_ptr);
2248 if (!info_ptr)
2249 {
2250 png_destroy_read_struct(&png_ptr, (png_infopp)NULL,
2251 (png_infopp)NULL);
2252 return (ERROR);
2253 }
2254
2255 if (setjmp(png_jmpbuf(png_ptr)))
2256 {
2257 png_destroy_read_struct(&png_ptr, &info_ptr,
2258 (png_infopp)NULL);
2259 return (ERROR);
2260 }
2261
2262 /* This one's new. You can provide functions
2263 to be called when the header info is valid,
2264 when each row is completed, and when the image
2265 is finished. If you aren't using all functions,
2266 you can specify NULL parameters. Even when all
2267 three functions are NULL, you need to call
2268 png_set_progressive_read_fn(). You can use
2269 any struct as the user_ptr (cast to a void pointer
2270 for the function call), and retrieve the pointer
2271 from inside the callbacks using the function
2272
2273 png_get_progressive_ptr(png_ptr);
2274
2275 which will return a void pointer, which you have
2276 to cast appropriately.
2277 */
2278 png_set_progressive_read_fn(png_ptr, (void *)user_ptr,
2279 info_callback, row_callback, end_callback);
2280
2281 return 0;
2282 }
2283
2284 /* A code fragment that you call as you receive blocks
2285 of data */
2286 int
2287 process_data(png_bytep buffer, png_uint_32 length)
2288 {
2289 if (setjmp(png_jmpbuf(png_ptr)))
2290 {
2291 png_destroy_read_struct(&png_ptr, &info_ptr,
2292 (png_infopp)NULL);
2293 return (ERROR);
2294 }
2295
2296 /* This one's new also. Simply give it a chunk
2297 of data from the file stream (in order, of
2298 course). On machines with segmented memory
2299 models machines, don't give it any more than
2300 64K. The library seems to run fine with sizes
2301 of 4K. Although you can give it much less if
2302 necessary (I assume you can give it chunks of
2303 1 byte, I haven't tried less then 256 bytes
2304 yet). When this function returns, you may
2305 want to display any rows that were generated
2306 in the row callback if you don't already do
2307 so there.
2308 */
2309 png_process_data(png_ptr, info_ptr, buffer, length);
2310 return 0;
2311 }
2312
2313 /* This function is called (as set by
2314 png_set_progressive_read_fn() above) when enough data
2315 has been supplied so all of the header has been
2316 read.
2317 */
2318 void
2319 info_callback(png_structp png_ptr, png_infop info)
2320 {
2321 /* Do any setup here, including setting any of
2322 the transformations mentioned in the Reading
2323 PNG files section. For now, you _must_ call
2324 either png_start_read_image() or
2325 png_read_update_info() after all the
2326 transformations are set (even if you don't set
2327 any). You may start getting rows before
2328 png_process_data() returns, so this is your
2329 last chance to prepare for that.
2330 */
2331 }
2332
2333 /* This function is called when each row of image
2334 data is complete */
2335 void
2336 row_callback(png_structp png_ptr, png_bytep new_row,
2337 png_uint_32 row_num, int pass)
2338 {
2339 /* If the image is interlaced, and you turned
2340 on the interlace handler, this function will
2341 be called for every row in every pass. Some
2342 of these rows will not be changed from the
2343 previous pass. When the row is not changed,
2344 the new_row variable will be NULL. The rows
2345 and passes are called in order, so you don't
2346 really need the row_num and pass, but I'm
2347 supplying them because it may make your life
2348 easier.
2349
2350 For the non-NULL rows of interlaced images,
2351 you must call png_progressive_combine_row()
2352 passing in the row and the old row. You can
2353 call this function for NULL rows (it will just
2354 return) and for non-interlaced images (it just
2355 does the memcpy for you) if it will make the
2356 code easier. Thus, you can just do this for
2357 all cases:
2358 */
2359
2360 png_progressive_combine_row(png_ptr, old_row,
2361 new_row);
2362
2363 /* where old_row is what was displayed for
2364 previously for the row. Note that the first
2365 pass (pass == 0, really) will completely cover
2366 the old row, so the rows do not have to be
2367 initialized. After the first pass (and only
2368 for interlaced images), you will have to pass
2369 the current row, and the function will combine
2370 the old row and the new row.
2371 */
2372 }
2373
2374 void
2375 end_callback(png_structp png_ptr, png_infop info)
2376 {
2377 /* This function is called after the whole image
2378 has been read, including any chunks after the
2379 image (up to and including the IEND). You
2380 will usually have the same info chunk as you
2381 had in the header, although some data may have
2382 been added to the comments and time fields.
2383
2384 Most people won't do much here, perhaps setting
2385 a flag that marks the image as finished.
2386 */
2387 }
2388
2389
2390
2391.SH IV. Writing
2392
2393Much of this is very similar to reading. However, everything of
2394importance is repeated here, so you won't have to constantly look
2395back up in the reading section to understand writing.
2396
2397.SS Setup
2398
2399You will want to do the I/O initialization before you get into libpng,
2400so if it doesn't work, you don't have anything to undo. If you are not
2401using the standard I/O functions, you will need to replace them with
2402custom writing functions. See the discussion under Customizing libpng.
2403
2404 FILE *fp = fopen(file_name, "wb");
2405 if (!fp)
2406 {
2407 return (ERROR);
2408 }
2409
2410Next, png_struct and png_info need to be allocated and initialized.
2411As these can be both relatively large, you may not want to store these
2412on the stack, unless you have stack space to spare. Of course, you
2413will want to check if they return NULL. If you are also reading,
2414you won't want to name your read structure and your write structure
2415both "png_ptr"; you can call them anything you like, such as
2416"read_ptr" and "write_ptr". Look at pngtest.c, for example.
2417
2418 png_structp png_ptr = png_create_write_struct
2419 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
2420 user_error_fn, user_warning_fn);
2421 if (!png_ptr)
2422 return (ERROR);
2423
2424 png_infop info_ptr = png_create_info_struct(png_ptr);
2425 if (!info_ptr)
2426 {
2427 png_destroy_write_struct(&png_ptr,
2428 (png_infopp)NULL);
2429 return (ERROR);
2430 }
2431
2432If you want to use your own memory allocation routines,
2433define PNG_USER_MEM_SUPPORTED and use
2434png_create_write_struct_2() instead of png_create_write_struct():
2435
2436 png_structp png_ptr = png_create_write_struct_2
2437 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
2438 user_error_fn, user_warning_fn, (png_voidp)
2439 user_mem_ptr, user_malloc_fn, user_free_fn);
2440
2441After you have these structures, you will need to set up the
2442error handling. When libpng encounters an error, it expects to
2443longjmp() back to your routine. Therefore, you will need to call
2444setjmp() and pass the png_jmpbuf(png_ptr). If you
2445write the file from different routines, you will need to update
2446the png_jmpbuf(png_ptr) every time you enter a new routine that will
2447call a png_*() function. See your documentation of setjmp/longjmp
2448for your compiler for more information on setjmp/longjmp. See
2449the discussion on libpng error handling in the Customizing Libpng
2450section below for more information on the libpng error handling.
2451
2452 if (setjmp(png_jmpbuf(png_ptr)))
2453 {
2454 png_destroy_write_struct(&png_ptr, &info_ptr);
2455 fclose(fp);
2456 return (ERROR);
2457 }
2458 ...
2459 return;
2460
2461If you would rather avoid the complexity of setjmp/longjmp issues,
2462you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case
2463errors will result in a call to PNG_ABORT() which defaults to abort().
2464
2465Now you need to set up the output code. The default for libpng is to
2466use the C function fwrite(). If you use this, you will need to pass a
2467valid FILE * in the function png_init_io(). Be sure that the file is
2468opened in binary mode. Again, if you wish to handle writing data in
2469another way, see the discussion on libpng I/O handling in the Customizing
2470Libpng section below.
2471
2472 png_init_io(png_ptr, fp);
2473
2474If you are embedding your PNG into a datastream such as MNG, and don't
2475want libpng to write the 8-byte signature, or if you have already
2476written the signature in your application, use
2477
2478 png_set_sig_bytes(png_ptr, 8);
2479
2480to inform libpng that it should not write a signature.
2481
2482.SS Write callbacks
2483
2484At this point, you can set up a callback function that will be
2485called after each row has been written, which you can use to control
2486a progress meter or the like. It's demonstrated in pngtest.c.
2487You must supply a function
2488
2489 void write_row_callback(png_ptr, png_uint_32 row,
2490 int pass);
2491 {
2492 /* put your code here */
2493 }
2494
2495(You can give it another name that you like instead of "write_row_callback")
2496
2497To inform libpng about your function, use
2498
2499 png_set_write_status_fn(png_ptr, write_row_callback);
2500
2501You now have the option of modifying how the compression library will
2502run. The following functions are mainly for testing, but may be useful
2503in some cases, like if you need to write PNG files extremely fast and
2504are willing to give up some compression, or if you want to get the
2505maximum possible compression at the expense of slower writing. If you
2506have no special needs in this area, let the library do what it wants by
2507not calling this function at all, as it has been tuned to deliver a good
2508speed/compression ratio. The second parameter to png_set_filter() is
2509the filter method, for which the only valid values are 0 (as of the
2510July 1999 PNG specification, version 1.2) or 64 (if you are writing
2511a PNG datastream that is to be embedded in a MNG datastream). The third
2512parameter is a flag that indicates which filter type(s) are to be tested
2513for each scanline. See the PNG specification for details on the specific filter
2514types.
2515
2516
2517 /* turn on or off filtering, and/or choose
2518 specific filters. You can use either a single
2519 PNG_FILTER_VALUE_NAME or the bitwise OR of one
2520 or more PNG_FILTER_NAME masks. */
2521 png_set_filter(png_ptr, 0,
2522 PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE |
2523 PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB |
2524 PNG_FILTER_UP | PNG_FILTER_VALUE_UP |
Patrick Scotta0bb96c2009-07-22 11:50:02 -04002525 PNG_FILTER_AVG | PNG_FILTER_VALUE_AVG |
The Android Open Source Project893912b2009-03-03 19:30:05 -08002526 PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH|
2527 PNG_ALL_FILTERS);
2528
2529If an application
2530wants to start and stop using particular filters during compression,
2531it should start out with all of the filters (to ensure that the previous
2532row of pixels will be stored in case it's needed later), and then add
2533and remove them after the start of compression.
2534
2535If you are writing a PNG datastream that is to be embedded in a MNG
2536datastream, the second parameter can be either 0 or 64.
2537
2538The png_set_compression_*() functions interface to the zlib compression
2539library, and should mostly be ignored unless you really know what you are
2540doing. The only generally useful call is png_set_compression_level()
2541which changes how much time zlib spends on trying to compress the image
2542data. See the Compression Library (zlib.h and algorithm.txt, distributed
2543with zlib) for details on the compression levels.
2544
2545 /* set the zlib compression level */
2546 png_set_compression_level(png_ptr,
2547 Z_BEST_COMPRESSION);
2548
2549 /* set other zlib parameters */
2550 png_set_compression_mem_level(png_ptr, 8);
2551 png_set_compression_strategy(png_ptr,
2552 Z_DEFAULT_STRATEGY);
2553 png_set_compression_window_bits(png_ptr, 15);
2554 png_set_compression_method(png_ptr, 8);
2555 png_set_compression_buffer_size(png_ptr, 8192)
2556
2557extern PNG_EXPORT(void,png_set_zbuf_size)
2558
2559.SS Setting the contents of info for output
2560
2561You now need to fill in the png_info structure with all the data you
2562wish to write before the actual image. Note that the only thing you
2563are allowed to write after the image is the text chunks and the time
2564chunk (as of PNG Specification 1.2, anyway). See png_write_end() and
2565the latest PNG specification for more information on that. If you
2566wish to write them before the image, fill them in now, and flag that
2567data as being valid. If you want to wait until after the data, don't
2568fill them until png_write_end(). For all the fields in png_info and
2569their data types, see png.h. For explanations of what the fields
2570contain, see the PNG specification.
2571
2572Some of the more important parts of the png_info are:
2573
2574 png_set_IHDR(png_ptr, info_ptr, width, height,
2575 bit_depth, color_type, interlace_type,
2576 compression_type, filter_method)
2577 width - holds the width of the image
2578 in pixels (up to 2^31).
2579 height - holds the height of the image
2580 in pixels (up to 2^31).
2581 bit_depth - holds the bit depth of one of the
2582 image channels.
2583 (valid values are 1, 2, 4, 8, 16
2584 and depend also on the
2585 color_type. See also significant
2586 bits (sBIT) below).
2587 color_type - describes which color/alpha
2588 channels are present.
2589 PNG_COLOR_TYPE_GRAY
2590 (bit depths 1, 2, 4, 8, 16)
2591 PNG_COLOR_TYPE_GRAY_ALPHA
2592 (bit depths 8, 16)
2593 PNG_COLOR_TYPE_PALETTE
2594 (bit depths 1, 2, 4, 8)
2595 PNG_COLOR_TYPE_RGB
2596 (bit_depths 8, 16)
2597 PNG_COLOR_TYPE_RGB_ALPHA
2598 (bit_depths 8, 16)
2599
2600 PNG_COLOR_MASK_PALETTE
2601 PNG_COLOR_MASK_COLOR
2602 PNG_COLOR_MASK_ALPHA
2603
2604 interlace_type - PNG_INTERLACE_NONE or
2605 PNG_INTERLACE_ADAM7
2606 compression_type - (must be
2607 PNG_COMPRESSION_TYPE_DEFAULT)
2608 filter_method - (must be PNG_FILTER_TYPE_DEFAULT
2609 or, if you are writing a PNG to
2610 be embedded in a MNG datastream,
2611 can also be
2612 PNG_INTRAPIXEL_DIFFERENCING)
2613
2614If you call png_set_IHDR(), the call must appear before any of the
Patrick Scotta0bb96c2009-07-22 11:50:02 -04002615other png_set_*() functions, because they might require access to some of
The Android Open Source Project893912b2009-03-03 19:30:05 -08002616the IHDR settings. The remaining png_set_*() functions can be called
2617in any order.
2618
Patrick Scotta0bb96c2009-07-22 11:50:02 -04002619If you wish, you can reset the compression_type, interlace_type, or
2620filter_method later by calling png_set_IHDR() again; if you do this, the
2621width, height, bit_depth, and color_type must be the same in each call.
2622
The Android Open Source Project893912b2009-03-03 19:30:05 -08002623 png_set_PLTE(png_ptr, info_ptr, palette,
2624 num_palette);
2625 palette - the palette for the file
2626 (array of png_color)
2627 num_palette - number of entries in the palette
2628
2629 png_set_gAMA(png_ptr, info_ptr, gamma);
2630 gamma - the gamma the image was created
2631 at (PNG_INFO_gAMA)
2632
2633 png_set_sRGB(png_ptr, info_ptr, srgb_intent);
2634 srgb_intent - the rendering intent
2635 (PNG_INFO_sRGB) The presence of
2636 the sRGB chunk means that the pixel
2637 data is in the sRGB color space.
2638 This chunk also implies specific
2639 values of gAMA and cHRM. Rendering
2640 intent is the CSS-1 property that
2641 has been defined by the International
2642 Color Consortium
2643 (http://www.color.org).
2644 It can be one of
2645 PNG_sRGB_INTENT_SATURATION,
2646 PNG_sRGB_INTENT_PERCEPTUAL,
2647 PNG_sRGB_INTENT_ABSOLUTE, or
2648 PNG_sRGB_INTENT_RELATIVE.
2649
2650
2651 png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr,
2652 srgb_intent);
2653 srgb_intent - the rendering intent
2654 (PNG_INFO_sRGB) The presence of the
2655 sRGB chunk means that the pixel
2656 data is in the sRGB color space.
2657 This function also causes gAMA and
2658 cHRM chunks with the specific values
2659 that are consistent with sRGB to be
2660 written.
2661
2662 png_set_iCCP(png_ptr, info_ptr, name, compression_type,
2663 profile, proflen);
2664 name - The profile name.
2665 compression - The compression type; always
2666 PNG_COMPRESSION_TYPE_BASE for PNG 1.0.
2667 You may give NULL to this argument to
2668 ignore it.
2669 profile - International Color Consortium color
2670 profile data. May contain NULs.
2671 proflen - length of profile data in bytes.
2672
2673 png_set_sBIT(png_ptr, info_ptr, sig_bit);
2674 sig_bit - the number of significant bits for
2675 (PNG_INFO_sBIT) each of the gray, red,
2676 green, and blue channels, whichever are
2677 appropriate for the given color type
2678 (png_color_16)
2679
2680 png_set_tRNS(png_ptr, info_ptr, trans, num_trans,
2681 trans_values);
2682 trans - array of transparent entries for
2683 palette (PNG_INFO_tRNS)
Patrick Scotta0bb96c2009-07-22 11:50:02 -04002684 trans_values - graylevel or color sample values
2685 (in order red, green, blue) of the
2686 single transparent color for
The Android Open Source Project893912b2009-03-03 19:30:05 -08002687 non-paletted images (PNG_INFO_tRNS)
2688 num_trans - number of transparent entries
2689 (PNG_INFO_tRNS)
2690
2691 png_set_hIST(png_ptr, info_ptr, hist);
2692 (PNG_INFO_hIST)
2693 hist - histogram of palette (array of
2694 png_uint_16)
2695
2696 png_set_tIME(png_ptr, info_ptr, mod_time);
2697 mod_time - time image was last modified
2698 (PNG_VALID_tIME)
2699
2700 png_set_bKGD(png_ptr, info_ptr, background);
2701 background - background color (PNG_VALID_bKGD)
2702
2703 png_set_text(png_ptr, info_ptr, text_ptr, num_text);
2704 text_ptr - array of png_text holding image
2705 comments
2706 text_ptr[i].compression - type of compression used
2707 on "text" PNG_TEXT_COMPRESSION_NONE
2708 PNG_TEXT_COMPRESSION_zTXt
2709 PNG_ITXT_COMPRESSION_NONE
2710 PNG_ITXT_COMPRESSION_zTXt
2711 text_ptr[i].key - keyword for comment. Must contain
2712 1-79 characters.
2713 text_ptr[i].text - text comments for current
2714 keyword. Can be NULL or empty.
2715 text_ptr[i].text_length - length of text string,
2716 after decompression, 0 for iTXt
2717 text_ptr[i].itxt_length - length of itxt string,
2718 after decompression, 0 for tEXt/zTXt
2719 text_ptr[i].lang - language of comment (NULL or
2720 empty for unknown).
2721 text_ptr[i].translated_keyword - keyword in UTF-8 (NULL
2722 or empty for unknown).
2723 num_text - number of comments
2724
2725 png_set_sPLT(png_ptr, info_ptr, &palette_ptr,
2726 num_spalettes);
2727 palette_ptr - array of png_sPLT_struct structures
2728 to be added to the list of palettes
2729 in the info structure.
2730 num_spalettes - number of palette structures to be
2731 added.
2732
2733 png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y,
2734 unit_type);
2735 offset_x - positive offset from the left
2736 edge of the screen
2737 offset_y - positive offset from the top
2738 edge of the screen
2739 unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER
2740
2741 png_set_pHYs(png_ptr, info_ptr, res_x, res_y,
2742 unit_type);
2743 res_x - pixels/unit physical resolution
2744 in x direction
2745 res_y - pixels/unit physical resolution
2746 in y direction
2747 unit_type - PNG_RESOLUTION_UNKNOWN,
2748 PNG_RESOLUTION_METER
2749
2750 png_set_sCAL(png_ptr, info_ptr, unit, width, height)
2751 unit - physical scale units (an integer)
2752 width - width of a pixel in physical scale units
2753 height - height of a pixel in physical scale units
2754 (width and height are doubles)
2755
2756 png_set_sCAL_s(png_ptr, info_ptr, unit, width, height)
2757 unit - physical scale units (an integer)
2758 width - width of a pixel in physical scale units
2759 height - height of a pixel in physical scale units
2760 (width and height are strings like "2.54")
2761
2762 png_set_unknown_chunks(png_ptr, info_ptr, &unknowns,
2763 num_unknowns)
2764 unknowns - array of png_unknown_chunk
2765 structures holding unknown chunks
2766 unknowns[i].name - name of unknown chunk
2767 unknowns[i].data - data of unknown chunk
2768 unknowns[i].size - size of unknown chunk's data
2769 unknowns[i].location - position to write chunk in file
2770 0: do not write chunk
2771 PNG_HAVE_IHDR: before PLTE
2772 PNG_HAVE_PLTE: before IDAT
2773 PNG_AFTER_IDAT: after IDAT
2774
2775The "location" member is set automatically according to
2776what part of the output file has already been written.
2777You can change its value after calling png_set_unknown_chunks()
2778as demonstrated in pngtest.c. Within each of the "locations",
2779the chunks are sequenced according to their position in the
2780structure (that is, the value of "i", which is the order in which
2781the chunk was either read from the input file or defined with
2782png_set_unknown_chunks).
2783
2784A quick word about text and num_text. text is an array of png_text
2785structures. num_text is the number of valid structures in the array.
2786Each png_text structure holds a language code, a keyword, a text value,
2787and a compression type.
2788
2789The compression types have the same valid numbers as the compression
2790types of the image data. Currently, the only valid number is zero.
2791However, you can store text either compressed or uncompressed, unlike
2792images, which always have to be compressed. So if you don't want the
2793text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE.
2794Because tEXt and zTXt chunks don't have a language field, if you
2795specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt
2796any language code or translated keyword will not be written out.
2797
2798Until text gets around 1000 bytes, it is not worth compressing it.
2799After the text has been written out to the file, the compression type
2800is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR,
2801so that it isn't written out again at the end (in case you are calling
2802png_write_end() with the same struct.
2803
2804The keywords that are given in the PNG Specification are:
2805
2806 Title Short (one line) title or
2807 caption for image
2808 Author Name of image's creator
2809 Description Description of image (possibly long)
2810 Copyright Copyright notice
2811 Creation Time Time of original image creation
2812 (usually RFC 1123 format, see below)
2813 Software Software used to create the image
2814 Disclaimer Legal disclaimer
2815 Warning Warning of nature of content
2816 Source Device used to create the image
2817 Comment Miscellaneous comment; conversion
2818 from other image format
2819
2820The keyword-text pairs work like this. Keywords should be short
2821simple descriptions of what the comment is about. Some typical
2822keywords are found in the PNG specification, as is some recommendations
2823on keywords. You can repeat keywords in a file. You can even write
2824some text before the image and some after. For example, you may want
2825to put a description of the image before the image, but leave the
2826disclaimer until after, so viewers working over modem connections
2827don't have to wait for the disclaimer to go over the modem before
2828they start seeing the image. Finally, keywords should be full
2829words, not abbreviations. Keywords and text are in the ISO 8859-1
2830(Latin-1) character set (a superset of regular ASCII) and can not
2831contain NUL characters, and should not contain control or other
2832unprintable characters. To make the comments widely readable, stick
2833with basic ASCII, and avoid machine specific character set extensions
2834like the IBM-PC character set. The keyword must be present, but
2835you can leave off the text string on non-compressed pairs.
2836Compressed pairs must have a text string, as only the text string
2837is compressed anyway, so the compression would be meaningless.
2838
2839PNG supports modification time via the png_time structure. Two
2840conversion routines are provided, png_convert_from_time_t() for
2841time_t and png_convert_from_struct_tm() for struct tm. The
2842time_t routine uses gmtime(). You don't have to use either of
2843these, but if you wish to fill in the png_time structure directly,
2844you should provide the time in universal time (GMT) if possible
2845instead of your local time. Note that the year number is the full
2846year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and
2847that months start with 1.
2848
2849If you want to store the time of the original image creation, you should
2850use a plain tEXt chunk with the "Creation Time" keyword. This is
2851necessary because the "creation time" of a PNG image is somewhat vague,
2852depending on whether you mean the PNG file, the time the image was
2853created in a non-PNG format, a still photo from which the image was
2854scanned, or possibly the subject matter itself. In order to facilitate
2855machine-readable dates, it is recommended that the "Creation Time"
2856tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"),
2857although this isn't a requirement. Unlike the tIME chunk, the
2858"Creation Time" tEXt chunk is not expected to be automatically changed
2859by the software. To facilitate the use of RFC 1123 dates, a function
2860png_convert_to_rfc1123(png_timep) is provided to convert from PNG
2861time to an RFC 1123 format string.
2862
2863.SS Writing unknown chunks
2864
2865You can use the png_set_unknown_chunks function to queue up chunks
2866for writing. You give it a chunk name, raw data, and a size; that's
2867all there is to it. The chunks will be written by the next following
2868png_write_info_before_PLTE, png_write_info, or png_write_end function.
2869Any chunks previously read into the info structure's unknown-chunk
2870list will also be written out in a sequence that satisfies the PNG
2871specification's ordering rules.
2872
2873.SS The high-level write interface
2874
2875At this point there are two ways to proceed; through the high-level
2876write interface, or through a sequence of low-level write operations.
2877You can use the high-level interface if your image data is present
2878in the info structure. All defined output
2879transformations are permitted, enabled by the following masks.
2880
2881 PNG_TRANSFORM_IDENTITY No transformation
2882 PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples
2883 PNG_TRANSFORM_PACKSWAP Change order of packed
2884 pixels to LSB first
2885 PNG_TRANSFORM_INVERT_MONO Invert monochrome images
2886 PNG_TRANSFORM_SHIFT Normalize pixels to the
2887 sBIT depth
2888 PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA
2889 to BGRA
2890 PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA
2891 to AG
2892 PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity
2893 to transparency
2894 PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples
Patrick Scotta0bb96c2009-07-22 11:50:02 -04002895 PNG_TRANSFORM_STRIP_FILLER Strip out filler
2896 bytes (deprecated).
2897 PNG_TRANSFORM_STRIP_FILLER_BEFORE Strip out leading
2898 filler bytes
2899 PNG_TRANSFORM_STRIP_FILLER_AFTER Strip out trailing
2900 filler bytes
The Android Open Source Project893912b2009-03-03 19:30:05 -08002901
2902If you have valid image data in the info structure (you can use
2903png_set_rows() to put image data in the info structure), simply do this:
2904
2905 png_write_png(png_ptr, info_ptr, png_transforms, NULL)
2906
2907where png_transforms is an integer containing the bitwise OR of some set of
2908transformation flags. This call is equivalent to png_write_info(),
2909followed the set of transformations indicated by the transform mask,
2910then png_write_image(), and finally png_write_end().
2911
2912(The final parameter of this call is not yet used. Someday it might point
2913to transformation parameters required by some future output transform.)
2914
2915You must use png_transforms and not call any png_set_transform() functions
2916when you use png_write_png().
2917
2918.SS The low-level write interface
2919
2920If you are going the low-level route instead, you are now ready to
2921write all the file information up to the actual image data. You do
2922this with a call to png_write_info().
2923
2924 png_write_info(png_ptr, info_ptr);
2925
2926Note that there is one transformation you may need to do before
2927png_write_info(). In PNG files, the alpha channel in an image is the
2928level of opacity. If your data is supplied as a level of
2929transparency, you can invert the alpha channel before you write it, so
2930that 0 is fully transparent and 255 (in 8-bit or paletted images) or
293165535 (in 16-bit images) is fully opaque, with
2932
2933 png_set_invert_alpha(png_ptr);
2934
2935This must appear before png_write_info() instead of later with the
2936other transformations because in the case of paletted images the tRNS
2937chunk data has to be inverted before the tRNS chunk is written. If
2938your image is not a paletted image, the tRNS data (which in such cases
2939represents a single color to be rendered as transparent) won't need to
2940be changed, and you can safely do this transformation after your
2941png_write_info() call.
2942
2943If you need to write a private chunk that you want to appear before
2944the PLTE chunk when PLTE is present, you can write the PNG info in
2945two steps, and insert code to write your own chunk between them:
2946
2947 png_write_info_before_PLTE(png_ptr, info_ptr);
2948 png_set_unknown_chunks(png_ptr, info_ptr, ...);
2949 png_write_info(png_ptr, info_ptr);
2950
2951After you've written the file information, you can set up the library
2952to handle any special transformations of the image data. The various
2953ways to transform the data will be described in the order that they
2954should occur. This is important, as some of these change the color
2955type and/or bit depth of the data, and some others only work on
2956certain color types and bit depths. Even though each transformation
2957checks to see if it has data that it can do something with, you should
2958make sure to only enable a transformation if it will be valid for the
2959data. For example, don't swap red and blue on grayscale data.
2960
2961PNG files store RGB pixels packed into 3 or 6 bytes. This code tells
2962the library to strip input data that has 4 or 8 bytes per pixel down
2963to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2
2964bytes per pixel).
2965
2966 png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
2967
2968where the 0 is unused, and the location is either PNG_FILLER_BEFORE or
2969PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel
2970is stored XRGB or RGBX.
2971
2972PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
2973they can, resulting in, for example, 8 pixels per byte for 1 bit files.
2974If the data is supplied at 1 pixel per byte, use this code, which will
2975correctly pack the pixels into a single byte:
2976
2977 png_set_packing(png_ptr);
2978
2979PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your
2980data is of another bit depth, you can write an sBIT chunk into the
2981file so that decoders can recover the original data if desired.
2982
2983 /* Set the true bit depth of the image data */
2984 if (color_type & PNG_COLOR_MASK_COLOR)
2985 {
2986 sig_bit.red = true_bit_depth;
2987 sig_bit.green = true_bit_depth;
2988 sig_bit.blue = true_bit_depth;
2989 }
2990 else
2991 {
2992 sig_bit.gray = true_bit_depth;
2993 }
2994 if (color_type & PNG_COLOR_MASK_ALPHA)
2995 {
2996 sig_bit.alpha = true_bit_depth;
2997 }
2998
2999 png_set_sBIT(png_ptr, info_ptr, &sig_bit);
3000
3001If the data is stored in the row buffer in a bit depth other than
3002one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG),
3003this will scale the values to appear to be the correct bit depth as
3004is required by PNG.
3005
3006 png_set_shift(png_ptr, &sig_bit);
3007
3008PNG files store 16 bit pixels in network byte order (big-endian,
3009ie. most significant bits first). This code would be used if they are
3010supplied the other way (little-endian, i.e. least significant bits
3011first, the way PCs store them):
3012
3013 if (bit_depth > 8)
3014 png_set_swap(png_ptr);
3015
3016If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you
3017need to change the order the pixels are packed into bytes, you can use:
3018
3019 if (bit_depth < 8)
3020 png_set_packswap(png_ptr);
3021
3022PNG files store 3 color pixels in red, green, blue order. This code
3023would be used if they are supplied as blue, green, red:
3024
3025 png_set_bgr(png_ptr);
3026
3027PNG files describe monochrome as black being zero and white being
3028one. This code would be used if the pixels are supplied with this reversed
3029(black being one and white being zero):
3030
3031 png_set_invert_mono(png_ptr);
3032
3033Finally, you can write your own transformation function if none of
3034the existing ones meets your needs. This is done by setting a callback
3035with
3036
3037 png_set_write_user_transform_fn(png_ptr,
3038 write_transform_fn);
3039
3040You must supply the function
3041
3042 void write_transform_fn(png_ptr ptr, row_info_ptr
3043 row_info, png_bytep data)
3044
3045See pngtest.c for a working example. Your function will be called
3046before any of the other transformations are processed.
3047
3048You can also set up a pointer to a user structure for use by your
3049callback function.
3050
3051 png_set_user_transform_info(png_ptr, user_ptr, 0, 0);
3052
3053The user_channels and user_depth parameters of this function are ignored
3054when writing; you can set them to zero as shown.
3055
3056You can retrieve the pointer via the function png_get_user_transform_ptr().
3057For example:
3058
3059 voidp write_user_transform_ptr =
3060 png_get_user_transform_ptr(png_ptr);
3061
3062It is possible to have libpng flush any pending output, either manually,
3063or automatically after a certain number of lines have been written. To
3064flush the output stream a single time call:
3065
3066 png_write_flush(png_ptr);
3067
3068and to have libpng flush the output stream periodically after a certain
3069number of scanlines have been written, call:
3070
3071 png_set_flush(png_ptr, nrows);
3072
3073Note that the distance between rows is from the last time png_write_flush()
3074was called, or the first row of the image if it has never been called.
3075So if you write 50 lines, and then png_set_flush 25, it will flush the
3076output on the next scanline, and every 25 lines thereafter, unless
3077png_write_flush() is called before 25 more lines have been written.
3078If nrows is too small (less than about 10 lines for a 640 pixel wide
3079RGB image) the image compression may decrease noticeably (although this
3080may be acceptable for real-time applications). Infrequent flushing will
3081only degrade the compression performance by a few percent over images
3082that do not use flushing.
3083
3084.SS Writing the image data
3085
3086That's it for the transformations. Now you can write the image data.
3087The simplest way to do this is in one function call. If you have the
3088whole image in memory, you can just call png_write_image() and libpng
3089will write the image. You will need to pass in an array of pointers to
3090each row. This function automatically handles interlacing, so you don't
3091need to call png_set_interlace_handling() or call this function multiple
3092times, or any of that other stuff necessary with png_write_rows().
3093
3094 png_write_image(png_ptr, row_pointers);
3095
3096where row_pointers is:
3097
3098 png_byte *row_pointers[height];
3099
3100You can point to void or char or whatever you use for pixels.
3101
3102If you don't want to write the whole image at once, you can
3103use png_write_rows() instead. If the file is not interlaced,
3104this is simple:
3105
3106 png_write_rows(png_ptr, row_pointers,
3107 number_of_rows);
3108
3109row_pointers is the same as in the png_write_image() call.
3110
3111If you are just writing one row at a time, you can do this with
3112a single row_pointer instead of an array of row_pointers:
3113
3114 png_bytep row_pointer = row;
3115
3116 png_write_row(png_ptr, row_pointer);
3117
3118When the file is interlaced, things can get a good deal more
3119complicated. The only currently (as of the PNG Specification
3120version 1.2, dated July 1999) defined interlacing scheme for PNG files
3121is the "Adam7" interlace scheme, that breaks down an
3122image into seven smaller images of varying size. libpng will build
3123these images for you, or you can do them yourself. If you want to
3124build them yourself, see the PNG specification for details of which
3125pixels to write when.
3126
3127If you don't want libpng to handle the interlacing details, just
3128use png_set_interlace_handling() and call png_write_rows() the
3129correct number of times to write all seven sub-images.
3130
3131If you want libpng to build the sub-images, call this before you start
3132writing any rows:
3133
3134 number_of_passes =
3135 png_set_interlace_handling(png_ptr);
3136
3137This will return the number of passes needed. Currently, this
3138is seven, but may change if another interlace type is added.
3139
3140Then write the complete image number_of_passes times.
3141
3142 png_write_rows(png_ptr, row_pointers,
3143 number_of_rows);
3144
3145As some of these rows are not used, and thus return immediately,
3146you may want to read about interlacing in the PNG specification,
3147and only update the rows that are actually used.
3148
3149.SS Finishing a sequential write
3150
3151After you are finished writing the image, you should finish writing
3152the file. If you are interested in writing comments or time, you should
3153pass an appropriately filled png_info pointer. If you are not interested,
3154you can pass NULL.
3155
3156 png_write_end(png_ptr, info_ptr);
3157
3158When you are done, you can free all memory used by libpng like this:
3159
3160 png_destroy_write_struct(&png_ptr, &info_ptr);
3161
3162It is also possible to individually free the info_ptr members that
3163point to libpng-allocated storage with the following function:
3164
3165 png_free_data(png_ptr, info_ptr, mask, seq)
3166 mask - identifies data to be freed, a mask
3167 containing the bitwise OR of one or
3168 more of
3169 PNG_FREE_PLTE, PNG_FREE_TRNS,
3170 PNG_FREE_HIST, PNG_FREE_ICCP,
3171 PNG_FREE_PCAL, PNG_FREE_ROWS,
3172 PNG_FREE_SCAL, PNG_FREE_SPLT,
3173 PNG_FREE_TEXT, PNG_FREE_UNKN,
3174 or simply PNG_FREE_ALL
3175 seq - sequence number of item to be freed
3176 (-1 for all items)
3177
3178This function may be safely called when the relevant storage has
3179already been freed, or has not yet been allocated, or was allocated
3180by the user and not by libpng, and will in those
3181cases do nothing. The "seq" parameter is ignored if only one item
3182of the selected data type, such as PLTE, is allowed. If "seq" is not
3183-1, and multiple items are allowed for the data type identified in
3184the mask, such as text or sPLT, only the n'th item in the structure
3185is freed, where n is "seq".
3186
3187If you allocated data such as a palette that you passed
3188in to libpng with png_set_*, you must not free it until just before the call to
3189png_destroy_write_struct().
3190
3191The default behavior is only to free data that was allocated internally
3192by libpng. This can be changed, so that libpng will not free the data,
3193or so that it will free data that was allocated by the user with png_malloc()
3194or png_zalloc() and passed in via a png_set_*() function, with
3195
3196 png_data_freer(png_ptr, info_ptr, freer, mask)
3197 mask - which data elements are affected
3198 same choices as in png_free_data()
3199 freer - one of
3200 PNG_DESTROY_WILL_FREE_DATA
3201 PNG_SET_WILL_FREE_DATA
3202 PNG_USER_WILL_FREE_DATA
3203
3204For example, to transfer responsibility for some data from a read structure
3205to a write structure, you could use
3206
3207 png_data_freer(read_ptr, read_info_ptr,
3208 PNG_USER_WILL_FREE_DATA,
3209 PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST)
3210 png_data_freer(write_ptr, write_info_ptr,
3211 PNG_DESTROY_WILL_FREE_DATA,
3212 PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST)
3213
3214thereby briefly reassigning responsibility for freeing to the user but
3215immediately afterwards reassigning it once more to the write_destroy
3216function. Having done this, it would then be safe to destroy the read
3217structure and continue to use the PLTE, tRNS, and hIST data in the write
3218structure.
3219
3220This function only affects data that has already been allocated.
3221You can call this function before calling after the png_set_*() functions
3222to control whether the user or png_destroy_*() is supposed to free the data.
3223When the user assumes responsibility for libpng-allocated data, the
3224application must use
3225png_free() to free it, and when the user transfers responsibility to libpng
3226for data that the user has allocated, the user must have used png_malloc()
3227or png_zalloc() to allocate it.
3228
3229If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword
3230separately, do not transfer responsibility for freeing text_ptr to libpng,
3231because when libpng fills a png_text structure it combines these members with
3232the key member, and png_free_data() will free only text_ptr.key. Similarly,
3233if you transfer responsibility for free'ing text_ptr from libpng to your
3234application, your application must not separately free those members.
3235For a more compact example of writing a PNG image, see the file example.c.
3236
3237.SH V. Modifying/Customizing libpng:
3238
3239There are two issues here. The first is changing how libpng does
3240standard things like memory allocation, input/output, and error handling.
3241The second deals with more complicated things like adding new chunks,
3242adding new transformations, and generally changing how libpng works.
3243Both of those are compile-time issues; that is, they are generally
3244determined at the time the code is written, and there is rarely a need
3245to provide the user with a means of changing them.
3246
3247Memory allocation, input/output, and error handling
3248
3249All of the memory allocation, input/output, and error handling in libpng
3250goes through callbacks that are user-settable. The default routines are
3251in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change
3252these functions, call the appropriate png_set_*_fn() function.
3253
3254Memory allocation is done through the functions png_malloc()
3255and png_free(). These currently just call the standard C functions. If
3256your pointers can't access more then 64K at a time, you will want to set
3257MAXSEG_64K in zlib.h. Since it is unlikely that the method of handling
3258memory allocation on a platform will change between applications, these
3259functions must be modified in the library at compile time. If you prefer
3260to use a different method of allocating and freeing data, you can use
3261png_create_read_struct_2() or png_create_write_struct_2() to register
3262your own functions as described above.
3263These functions also provide a void pointer that can be retrieved via
3264
3265 mem_ptr=png_get_mem_ptr(png_ptr);
3266
3267Your replacement memory functions must have prototypes as follows:
3268
3269 png_voidp malloc_fn(png_structp png_ptr,
3270 png_size_t size);
3271 void free_fn(png_structp png_ptr, png_voidp ptr);
3272
3273Your malloc_fn() must return NULL in case of failure. The png_malloc()
3274function will normally call png_error() if it receives a NULL from the
3275system memory allocator or from your replacement malloc_fn().
3276
3277Your free_fn() will never be called with a NULL ptr, since libpng's
3278png_free() checks for NULL before calling free_fn().
3279
3280Input/Output in libpng is done through png_read() and png_write(),
3281which currently just call fread() and fwrite(). The FILE * is stored in
3282png_struct and is initialized via png_init_io(). If you wish to change
3283the method of I/O, the library supplies callbacks that you can set
3284through the function png_set_read_fn() and png_set_write_fn() at run
3285time, instead of calling the png_init_io() function. These functions
3286also provide a void pointer that can be retrieved via the function
3287png_get_io_ptr(). For example:
3288
3289 png_set_read_fn(png_structp read_ptr,
3290 voidp read_io_ptr, png_rw_ptr read_data_fn)
3291
3292 png_set_write_fn(png_structp write_ptr,
3293 voidp write_io_ptr, png_rw_ptr write_data_fn,
3294 png_flush_ptr output_flush_fn);
3295
3296 voidp read_io_ptr = png_get_io_ptr(read_ptr);
3297 voidp write_io_ptr = png_get_io_ptr(write_ptr);
3298
3299The replacement I/O functions must have prototypes as follows:
3300
3301 void user_read_data(png_structp png_ptr,
3302 png_bytep data, png_size_t length);
3303 void user_write_data(png_structp png_ptr,
3304 png_bytep data, png_size_t length);
3305 void user_flush_data(png_structp png_ptr);
3306
Patrick Scotta0bb96c2009-07-22 11:50:02 -04003307The user_read_data() function is responsible for detecting and
3308handling end-of-data errors.
3309
The Android Open Source Project893912b2009-03-03 19:30:05 -08003310Supplying NULL for the read, write, or flush functions sets them back
Patrick Scotta0bb96c2009-07-22 11:50:02 -04003311to using the default C stream functions, which expect the io_ptr to
3312point to a standard *FILE structure. It is probably a mistake
3313to use NULL for one of write_data_fn and output_flush_fn but not both
3314of them, unless you have built libpng with PNG_NO_WRITE_FLUSH defined.
3315It is an error to read from a write stream, and vice versa.
The Android Open Source Project893912b2009-03-03 19:30:05 -08003316
3317Error handling in libpng is done through png_error() and png_warning().
3318Errors handled through png_error() are fatal, meaning that png_error()
3319should never return to its caller. Currently, this is handled via
3320setjmp() and longjmp() (unless you have compiled libpng with
3321PNG_SETJMP_NOT_SUPPORTED, in which case it is handled via PNG_ABORT()),
3322but you could change this to do things like exit() if you should wish.
3323
3324On non-fatal errors, png_warning() is called
3325to print a warning message, and then control returns to the calling code.
3326By default png_error() and png_warning() print a message on stderr via
3327fprintf() unless the library is compiled with PNG_NO_CONSOLE_IO defined
3328(because you don't want the messages) or PNG_NO_STDIO defined (because
3329fprintf() isn't available). If you wish to change the behavior of the error
3330functions, you will need to set up your own message callbacks. These
3331functions are normally supplied at the time that the png_struct is created.
3332It is also possible to redirect errors and warnings to your own replacement
3333functions after png_create_*_struct() has been called by calling:
3334
3335 png_set_error_fn(png_structp png_ptr,
3336 png_voidp error_ptr, png_error_ptr error_fn,
3337 png_error_ptr warning_fn);
3338
3339 png_voidp error_ptr = png_get_error_ptr(png_ptr);
3340
3341If NULL is supplied for either error_fn or warning_fn, then the libpng
3342default function will be used, calling fprintf() and/or longjmp() if a
3343problem is encountered. The replacement error functions should have
3344parameters as follows:
3345
3346 void user_error_fn(png_structp png_ptr,
3347 png_const_charp error_msg);
3348 void user_warning_fn(png_structp png_ptr,
3349 png_const_charp warning_msg);
3350
3351The motivation behind using setjmp() and longjmp() is the C++ throw and
3352catch exception handling methods. This makes the code much easier to write,
3353as there is no need to check every return code of every function call.
3354However, there are some uncertainties about the status of local variables
3355after a longjmp, so the user may want to be careful about doing anything after
3356setjmp returns non-zero besides returning itself. Consult your compiler
3357documentation for more details. For an alternative approach, you may wish
3358to use the "cexcept" facility (see http://cexcept.sourceforge.net).
3359
3360.SS Custom chunks
3361
3362If you need to read or write custom chunks, you may need to get deeper
3363into the libpng code. The library now has mechanisms for storing
3364and writing chunks of unknown type; you can even declare callbacks
3365for custom chunks. However, this may not be good enough if the
3366library code itself needs to know about interactions between your
3367chunk and existing `intrinsic' chunks.
3368
3369If you need to write a new intrinsic chunk, first read the PNG
3370specification. Acquire a first level of
3371understanding of how it works. Pay particular attention to the
3372sections that describe chunk names, and look at how other chunks were
3373designed, so you can do things similarly. Second, check out the
3374sections of libpng that read and write chunks. Try to find a chunk
3375that is similar to yours and use it as a template. More details can
3376be found in the comments inside the code. It is best to handle unknown
3377chunks in a generic method, via callback functions, instead of by
3378modifying libpng functions.
3379
3380If you wish to write your own transformation for the data, look through
3381the part of the code that does the transformations, and check out some of
3382the simpler ones to get an idea of how they work. Try to find a similar
3383transformation to the one you want to add and copy off of it. More details
3384can be found in the comments inside the code itself.
3385
3386.SS Configuring for 16 bit platforms
3387
3388You will want to look into zconf.h to tell zlib (and thus libpng) that
3389it cannot allocate more then 64K at a time. Even if you can, the memory
3390won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
3391
3392.SS Configuring for DOS
3393
3394For DOS users who only have access to the lower 640K, you will
3395have to limit zlib's memory usage via a png_set_compression_mem_level()
3396call. See zlib.h or zconf.h in the zlib library for more information.
3397
3398.SS Configuring for Medium Model
3399
3400Libpng's support for medium model has been tested on most of the popular
3401compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
3402defined, and FAR gets defined to far in pngconf.h, and you should be
3403all set. Everything in the library (except for zlib's structure) is
3404expecting far data. You must use the typedefs with the p or pp on
3405the end for pointers (or at least look at them and be careful). Make
3406note that the rows of data are defined as png_bytepp, which is an
3407unsigned char far * far *.
3408
3409.SS Configuring for gui/windowing platforms:
3410
3411You will need to write new error and warning functions that use the GUI
3412interface, as described previously, and set them to be the error and
3413warning functions at the time that png_create_*_struct() is called,
3414in order to have them available during the structure initialization.
3415They can be changed later via png_set_error_fn(). On some compilers,
3416you may also have to change the memory allocators (png_malloc, etc.).
3417
3418.SS Configuring for compiler xxx:
3419
Patrick Scotta0bb96c2009-07-22 11:50:02 -04003420All includes for libpng are in pngconf.h. If you need to add, change
3421or delete an include, this is the place to do it.
3422The includes that are not needed outside libpng are protected by the
3423PNG_INTERNAL definition, which is only defined for those routines inside
3424libpng itself. The files in libpng proper only include png.h, which
3425includes pngconf.h.
The Android Open Source Project893912b2009-03-03 19:30:05 -08003426
3427.SS Configuring zlib:
3428
3429There are special functions to configure the compression. Perhaps the
3430most useful one changes the compression level, which currently uses
3431input compression values in the range 0 - 9. The library normally
3432uses the default compression level (Z_DEFAULT_COMPRESSION = 6). Tests
3433have shown that for a large majority of images, compression values in
3434the range 3-6 compress nearly as well as higher levels, and do so much
3435faster. For online applications it may be desirable to have maximum speed
3436(Z_BEST_SPEED = 1). With versions of zlib after v0.99, you can also
3437specify no compression (Z_NO_COMPRESSION = 0), but this would create
3438files larger than just storing the raw bitmap. You can specify the
3439compression level by calling:
3440
3441 png_set_compression_level(png_ptr, level);
3442
3443Another useful one is to reduce the memory level used by the library.
3444The memory level defaults to 8, but it can be lowered if you are
3445short on memory (running DOS, for example, where you only have 640K).
3446Note that the memory level does have an effect on compression; among
3447other things, lower levels will result in sections of incompressible
3448data being emitted in smaller stored blocks, with a correspondingly
3449larger relative overhead of up to 15% in the worst case.
3450
3451 png_set_compression_mem_level(png_ptr, level);
3452
3453The other functions are for configuring zlib. They are not recommended
3454for normal use and may result in writing an invalid PNG file. See
3455zlib.h for more information on what these mean.
3456
3457 png_set_compression_strategy(png_ptr,
3458 strategy);
3459 png_set_compression_window_bits(png_ptr,
3460 window_bits);
3461 png_set_compression_method(png_ptr, method);
3462 png_set_compression_buffer_size(png_ptr, size);
3463
3464.SS Controlling row filtering
3465
3466If you want to control whether libpng uses filtering or not, which
3467filters are used, and how it goes about picking row filters, you
3468can call one of these functions. The selection and configuration
3469of row filters can have a significant impact on the size and
3470encoding speed and a somewhat lesser impact on the decoding speed
3471of an image. Filtering is enabled by default for RGB and grayscale
3472images (with and without alpha), but not for paletted images nor
3473for any images with bit depths less than 8 bits/pixel.
3474
3475The 'method' parameter sets the main filtering method, which is
3476currently only '0' in the PNG 1.2 specification. The 'filters'
3477parameter sets which filter(s), if any, should be used for each
3478scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS
3479to turn filtering on and off, respectively.
3480
3481Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB,
3482PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise
3483ORed together with '|' to specify one or more filters to use.
3484These filters are described in more detail in the PNG specification.
3485If you intend to change the filter type during the course of writing
3486the image, you should start with flags set for all of the filters
3487you intend to use so that libpng can initialize its internal
3488structures appropriately for all of the filter types. (Note that this
3489means the first row must always be adaptively filtered, because libpng
3490currently does not allocate the filter buffers until png_write_row()
3491is called for the first time.)
3492
3493 filters = PNG_FILTER_NONE | PNG_FILTER_SUB
Patrick Scotta0bb96c2009-07-22 11:50:02 -04003494 PNG_FILTER_UP | PNG_FILTER_AVG |
The Android Open Source Project893912b2009-03-03 19:30:05 -08003495 PNG_FILTER_PAETH | PNG_ALL_FILTERS;
3496
3497 png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE,
3498 filters);
3499 The second parameter can also be
3500 PNG_INTRAPIXEL_DIFFERENCING if you are
3501 writing a PNG to be embedded in a MNG
3502 datastream. This parameter must be the
3503 same as the value of filter_method used
3504 in png_set_IHDR().
3505
3506It is also possible to influence how libpng chooses from among the
3507available filters. This is done in one or both of two ways - by
3508telling it how important it is to keep the same filter for successive
3509rows, and by telling it the relative computational costs of the filters.
3510
3511 double weights[3] = {1.5, 1.3, 1.1},
3512 costs[PNG_FILTER_VALUE_LAST] =
3513 {1.0, 1.3, 1.3, 1.5, 1.7};
3514
3515 png_set_filter_heuristics(png_ptr,
3516 PNG_FILTER_HEURISTIC_WEIGHTED, 3,
3517 weights, costs);
3518
3519The weights are multiplying factors that indicate to libpng that the
3520row filter should be the same for successive rows unless another row filter
3521is that many times better than the previous filter. In the above example,
3522if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a
3523"sum of absolute differences" 1.5 x 1.3 times higher than other filters
3524and still be chosen, while the NONE filter could have a sum 1.1 times
3525higher than other filters and still be chosen. Unspecified weights are
3526taken to be 1.0, and the specified weights should probably be declining
3527like those above in order to emphasize recent filters over older filters.
3528
3529The filter costs specify for each filter type a relative decoding cost
3530to be considered when selecting row filters. This means that filters
3531with higher costs are less likely to be chosen over filters with lower
3532costs, unless their "sum of absolute differences" is that much smaller.
3533The costs do not necessarily reflect the exact computational speeds of
3534the various filters, since this would unduly influence the final image
3535size.
3536
3537Note that the numbers above were invented purely for this example and
3538are given only to help explain the function usage. Little testing has
3539been done to find optimum values for either the costs or the weights.
3540
3541.SS Removing unwanted object code
3542
3543There are a bunch of #define's in pngconf.h that control what parts of
3544libpng are compiled. All the defines end in _SUPPORTED. If you are
3545never going to use a capability, you can change the #define to #undef
3546before recompiling libpng and save yourself code and data space, or
3547you can turn off individual capabilities with defines that begin with
3548PNG_NO_.
3549
3550You can also turn all of the transforms and ancillary chunk capabilities
3551off en masse with compiler directives that define
3552PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
3553or all four,
3554along with directives to turn on any of the capabilities that you do
3555want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable
3556the extra transformations but still leave the library fully capable of reading
3557and writing PNG files with all known public chunks
3558Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive
3559produces a library that is incapable of reading or writing ancillary chunks.
3560If you are not using the progressive reading capability, you can
3561turn that off with PNG_NO_PROGRESSIVE_READ (don't confuse
3562this with the INTERLACING capability, which you'll still have).
3563
3564All the reading and writing specific code are in separate files, so the
3565linker should only grab the files it needs. However, if you want to
3566make sure, or if you are building a stand alone library, all the
3567reading files start with pngr and all the writing files start with
3568pngw. The files that don't match either (like png.c, pngtrans.c, etc.)
3569are used for both reading and writing, and always need to be included.
3570The progressive reader is in pngpread.c
3571
3572If you are creating or distributing a dynamically linked library (a .so
3573or DLL file), you should not remove or disable any parts of the library,
3574as this will cause applications linked with different versions of the
3575library to fail if they call functions not available in your library.
3576The size of the library itself should not be an issue, because only
3577those sections that are actually used will be loaded into memory.
3578
3579.SS Requesting debug printout
3580
3581The macro definition PNG_DEBUG can be used to request debugging
3582printout. Set it to an integer value in the range 0 to 3. Higher
3583numbers result in increasing amounts of debugging information. The
3584information is printed to the "stderr" file, unless another file
3585name is specified in the PNG_DEBUG_FILE macro definition.
3586
3587When PNG_DEBUG > 0, the following functions (macros) become available:
3588
3589 png_debug(level, message)
3590 png_debug1(level, message, p1)
3591 png_debug2(level, message, p1, p2)
3592
3593in which "level" is compared to PNG_DEBUG to decide whether to print
3594the message, "message" is the formatted string to be printed,
3595and p1 and p2 are parameters that are to be embedded in the string
3596according to printf-style formatting directives. For example,
3597
3598 png_debug1(2, "foo=%d\n", foo);
3599
3600is expanded to
3601
3602 if(PNG_DEBUG > 2)
3603 fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo);
3604
3605When PNG_DEBUG is defined but is zero, the macros aren't defined, but you
3606can still use PNG_DEBUG to control your own debugging:
3607
3608 #ifdef PNG_DEBUG
3609 fprintf(stderr, ...
3610 #endif
3611
3612When PNG_DEBUG = 1, the macros are defined, but only png_debug statements
3613having level = 0 will be printed. There aren't any such statements in
3614this version of libpng, but if you insert some they will be printed.
3615
Patrick Scotta0bb96c2009-07-22 11:50:02 -04003616.SH VI. MNG support
The Android Open Source Project893912b2009-03-03 19:30:05 -08003617
3618The MNG specification (available at http://www.libpng.org/pub/mng) allows
3619certain extensions to PNG for PNG images that are embedded in MNG datastreams.
3620Libpng can support some of these extensions. To enable them, use the
3621png_permit_mng_features() function:
3622
3623 feature_set = png_permit_mng_features(png_ptr, mask)
3624 mask is a png_uint_32 containing the bitwise OR of the
3625 features you want to enable. These include
3626 PNG_FLAG_MNG_EMPTY_PLTE
3627 PNG_FLAG_MNG_FILTER_64
3628 PNG_ALL_MNG_FEATURES
3629 feature_set is a png_uint_32 that is the bitwise AND of
3630 your mask with the set of MNG features that is
3631 supported by the version of libpng that you are using.
3632
3633It is an error to use this function when reading or writing a standalone
3634PNG file with the PNG 8-byte signature. The PNG datastream must be wrapped
3635in a MNG datastream. As a minimum, it must have the MNG 8-byte signature
3636and the MHDR and MEND chunks. Libpng does not provide support for these
3637or any other MNG chunks; your application must provide its own support for
3638them. You may wish to consider using libmng (available at
3639http://www.libmng.com) instead.
3640
Patrick Scotta0bb96c2009-07-22 11:50:02 -04003641.SH VII. Changes to Libpng from version 0.88
The Android Open Source Project893912b2009-03-03 19:30:05 -08003642
3643It should be noted that versions of libpng later than 0.96 are not
3644distributed by the original libpng author, Guy Schalnat, nor by
3645Andreas Dilger, who had taken over from Guy during 1996 and 1997, and
3646distributed versions 0.89 through 0.96, but rather by another member
3647of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are
3648still alive and well, but they have moved on to other things.
3649
3650The old libpng functions png_read_init(), png_write_init(),
3651png_info_init(), png_read_destroy(), and png_write_destroy() have been
3652moved to PNG_INTERNAL in version 0.95 to discourage their use. These
3653functions will be removed from libpng version 2.0.0.
3654
3655The preferred method of creating and initializing the libpng structures is
3656via the png_create_read_struct(), png_create_write_struct(), and
3657png_create_info_struct() because they isolate the size of the structures
3658from the application, allow version error checking, and also allow the
3659use of custom error handling routines during the initialization, which
3660the old functions do not. The functions png_read_destroy() and
3661png_write_destroy() do not actually free the memory that libpng
3662allocated for these structs, but just reset the data structures, so they
3663can be used instead of png_destroy_read_struct() and
3664png_destroy_write_struct() if you feel there is too much system overhead
3665allocating and freeing the png_struct for each image read.
3666
3667Setting the error callbacks via png_set_message_fn() before
3668png_read_init() as was suggested in libpng-0.88 is no longer supported
3669because this caused applications that do not use custom error functions
3670to fail if the png_ptr was not initialized to zero. It is still possible
3671to set the error callbacks AFTER png_read_init(), or to change them with
3672png_set_error_fn(), which is essentially the same function, but with a new
3673name to force compilation errors with applications that try to use the old
3674method.
3675
3676Starting with version 1.0.7, you can find out which version of the library
3677you are using at run-time:
3678
3679 png_uint_32 libpng_vn = png_access_version_number();
3680
3681The number libpng_vn is constructed from the major version, minor
3682version with leading zero, and release number with leading zero,
3683(e.g., libpng_vn for version 1.0.7 is 10007).
3684
3685You can also check which version of png.h you used when compiling your
3686application:
3687
3688 png_uint_32 application_vn = PNG_LIBPNG_VER;
3689
Patrick Scotta0bb96c2009-07-22 11:50:02 -04003690.SH VIII. Changes to Libpng from version 1.0.x to 1.2.x
The Android Open Source Project893912b2009-03-03 19:30:05 -08003691
Patrick Scotta0bb96c2009-07-22 11:50:02 -04003692Support for user memory management was enabled by default. To
3693accomplish this, the functions png_create_read_struct_2(),
3694png_create_write_struct_2(), png_set_mem_fn(), png_get_mem_ptr(),
3695png_malloc_default(), and png_free_default() were added.
3696
3697Support for certain MNG features was enabled.
3698
3699Support for numbered error messages was added. However, we never got
3700around to actually numbering the error messages. The function
3701png_set_strip_error_numbers() was added (Note: the prototype for this
3702function was inadvertently removed from png.h in PNG_NO_ASSEMBLER_CODE
3703builds of libpng-1.2.15. It was restored in libpng-1.2.36).
3704
3705The png_malloc_warn() function was added at libpng-1.2.3. This issues
3706a png_warning and returns NULL instead of aborting when it fails to
3707acquire the requested memory allocation.
3708
3709Support for setting user limits on image width and height was enabled
3710by default. The functions png_set_user_limits(), png_get_user_width_max(),
3711and png_get_user_height_max() were added at libpng-1.2.6.
3712
3713The png_set_add_alpha() function was added at libpng-1.2.7.
3714
3715The function png_set_expand_gray_1_2_4_to_8() was added at libpng-1.2.9.
3716Unlike png_set_gray_1_2_4_to_8(), the new function does not expand the
3717tRNS chunk to alpha. The png_set_gray_1_2_4_to_8() function is
3718deprecated.
3719
3720A number of macro definitions in support of runtime selection of
3721assembler code features (especially Intel MMX code support) were
3722added at libpng-1.2.0:
3723
3724 PNG_ASM_FLAG_MMX_SUPPORT_COMPILED
3725 PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU
3726 PNG_ASM_FLAG_MMX_READ_COMBINE_ROW
3727 PNG_ASM_FLAG_MMX_READ_INTERLACE
3728 PNG_ASM_FLAG_MMX_READ_FILTER_SUB
3729 PNG_ASM_FLAG_MMX_READ_FILTER_UP
3730 PNG_ASM_FLAG_MMX_READ_FILTER_AVG
3731 PNG_ASM_FLAG_MMX_READ_FILTER_PAETH
3732 PNG_ASM_FLAGS_INITIALIZED
3733 PNG_MMX_READ_FLAGS
3734 PNG_MMX_FLAGS
3735 PNG_MMX_WRITE_FLAGS
3736 PNG_MMX_FLAGS
3737
3738We added the following functions in support of runtime
3739selection of assembler code features:
3740
3741 png_get_mmx_flagmask()
3742 png_set_mmx_thresholds()
3743 png_get_asm_flags()
3744 png_get_mmx_bitdepth_threshold()
3745 png_get_mmx_rowbytes_threshold()
3746 png_set_asm_flags()
3747
3748We replaced all of these functions with simple stubs in libpng-1.2.20,
3749when the Intel assembler code was removed due to a licensing issue.
3750
3751.SH IX. (Omitted)
3752
3753.SH X. Detecting libpng
3754
3755The png_get_io_ptr() function has been present since libpng-0.88, has never
3756changed, and is unaffected by conditional compilation macros. It is the
3757best choice for use in configure scripts for detecting the presence of any
3758libpng version since 0.88.
3759
3760.SH XI. Source code repository
3761
3762Since about February 2009, version 1.2.34, libpng has been under "git" source
3763control. The git repository was built from old libpng-x.y.z.tar.gz files
3764going back to version 0.70. You can access the git repository (read only)
3765at
3766
3767 git://libpng.git.sourceforge.net/gitroot/libpng
3768
3769or you can browse it via "gitweb" at
3770
3771 http://libpng.git.sourceforge.net/git/gitweb.cgi?p=libpng
3772
3773Patches can be sent to glennrp at users.sourceforge.net or to
3774png-mng-implement at lists.sourceforge.net or you can upload them to
3775the libpng bug tracker at
3776
3777 http://libpng.sourceforge.net
3778
3779.SH XII. Coding style
3780
3781Our coding style is similar to the "Allman" style, with curly
3782braces on separate lines:
3783
3784 if (condition)
3785 {
3786 action;
3787 }
3788
3789 else if (another condition)
3790 {
3791 another action;
3792 }
3793
3794The braces can be omitted from simple one-line actions:
3795
3796 if (condition)
3797 return (0);
3798
3799We use 3-space indentation, except for continued statements which
3800are usually indented the same as the first line of the statement
3801plus four more spaces.
3802
3803Comments appear with the leading "/*" at the same indentation as
3804the statement that follows the comment:
3805
3806 /* Single-line comment */
3807 statement;
3808
3809 /* Multiple-line
3810 * comment
3811 */
3812 statement;
3813
3814Very short comments can be placed at the end of the statement
3815to which they pertain:
3816
3817 statement; /* comment */
3818
3819We don't use C++ style ("//") comments. We have, however,
3820used them in the past in some now-abandoned MMX assembler
3821code.
3822
3823Functions and their curly braces are not indented, and
3824exported functions are marked with PNGAPI:
3825
3826 /* This is a public function that is visible to
3827 * application programers. It does thus-and-so.
3828 */
3829 void PNGAPI
3830 png_exported_function(png_ptr, png_info, foo)
3831 {
3832 body;
3833 }
3834
3835The prototypes for all exported functions appear in png.h.
3836
3837We mark all non-exported functions with "/* PRIVATE */"":
3838
3839 void /* PRIVATE */
3840 png_non_exported_function(png_ptr, png_info, foo)
3841 {
3842 body;
3843 }
3844
3845The prototypes for non-exported functions can appear in
3846the PNG_INTERNAL section of png.h
3847or in the file where the function is located.
3848
3849The names of all exported functions and variables begin
3850with "png_", and all publicly visible C preprocessor
3851macros begin with "PNG_".
3852
3853We put a space after each comma and after each semicolon
3854in "for" statments, and we put spaces before and after each
3855C binary operator and after "for" or "while". We don't
3856put a space between a typecast and the expression being
3857cast, nor do we put one between a function name and the
3858left parenthesis that follows it:
3859
3860 for (i = 2; i > 0; --i)
3861 x[i] = a(x) + (int)b;
3862
3863We prefer #ifdef and #ifndef to #if defined() and if !defined()
3864when there is only one macro being tested.
3865
3866Other rules can be inferred by inspecting the libpng
3867source.
3868
3869.SH XIII. Y2K Compliance in libpng
3870
3871July 16, 2009
The Android Open Source Project893912b2009-03-03 19:30:05 -08003872
3873Since the PNG Development group is an ad-hoc body, we can't make
3874an official declaration.
3875
3876This is your unofficial assurance that libpng from version 0.71 and
Patrick Scotta0bb96c2009-07-22 11:50:02 -04003877upward through 1.2.38 are Y2K compliant. It is my belief that earlier
The Android Open Source Project893912b2009-03-03 19:30:05 -08003878versions were also Y2K compliant.
3879
3880Libpng only has three year fields. One is a 2-byte unsigned integer that
3881will hold years up to 65535. The other two hold the date in text
3882format, and will hold years up to 9999.
3883
3884The integer is
3885 "png_uint_16 year" in png_time_struct.
3886
3887The strings are
3888 "png_charp time_buffer" in png_struct and
3889 "near_time_buffer", which is a local character string in png.c.
3890
3891There are seven time-related functions:
3892
3893 png_convert_to_rfc_1123() in png.c
3894 (formerly png_convert_to_rfc_1152() in error)
3895 png_convert_from_struct_tm() in pngwrite.c, called
3896 in pngwrite.c
3897 png_convert_from_time_t() in pngwrite.c
3898 png_get_tIME() in pngget.c
3899 png_handle_tIME() in pngrutil.c, called in pngread.c
3900 png_set_tIME() in pngset.c
3901 png_write_tIME() in pngwutil.c, called in pngwrite.c
3902
3903All appear to handle dates properly in a Y2K environment. The
3904png_convert_from_time_t() function calls gmtime() to convert from system
3905clock time, which returns (year - 1900), which we properly convert to
3906the full 4-digit year. There is a possibility that applications using
3907libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
3908function, or that they are incorrectly passing only a 2-digit year
3909instead of "year - 1900" into the png_convert_from_struct_tm() function,
3910but this is not under our control. The libpng documentation has always
3911stated that it works with 4-digit years, and the APIs have been
3912documented as such.
3913
3914The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
3915integer to hold the year, and can hold years as large as 65535.
3916
3917zlib, upon which libpng depends, is also Y2K compliant. It contains
3918no date-related code.
3919
3920
3921 Glenn Randers-Pehrson
3922 libpng maintainer
3923 PNG Development Group
3924
3925.SH NOTE
3926
3927Note about libpng version numbers:
3928
3929Due to various miscommunications, unforeseen code incompatibilities
3930and occasional factors outside the authors' control, version numbering
3931on the library has not always been consistent and straightforward.
3932The following table summarizes matters since version 0.89c, which was
3933the first widely used release:
3934
3935 source png.h png.h shared-lib
3936 version string int version
3937 ------- ------ ----- ----------
3938 0.89c ("beta 3") 0.89 89 1.0.89
3939 0.90 ("beta 4") 0.90 90 0.90
3940 0.95 ("beta 5") 0.95 95 0.95
3941 0.96 ("beta 6") 0.96 96 0.96
3942 0.97b ("beta 7") 1.00.97 97 1.0.1
3943 0.97c 0.97 97 2.0.97
3944 0.98 0.98 98 2.0.98
3945 0.99 0.99 98 2.0.99
3946 0.99a-m 0.99 99 2.0.99
3947 1.00 1.00 100 2.1.0
3948 1.0.0 1.0.0 100 2.1.0
3949 1.0.0 (from here on, the 100 2.1.0
3950 1.0.1 png.h string is 10001 2.1.0
3951 1.0.1a-e identical to the 10002 from here on, the
3952 1.0.2 source version) 10002 shared library is 2.V
3953 1.0.2a-b 10003 where V is the source
3954 1.0.1 10001 code version except as
3955 1.0.1a-e 10002 2.1.0.1a-e noted.
3956 1.0.2 10002 2.1.0.2
3957 1.0.2a-b 10003 2.1.0.2a-b
3958 1.0.3 10003 2.1.0.3
3959 1.0.3a-d 10004 2.1.0.3a-d
3960 1.0.4 10004 2.1.0.4
3961 1.0.4a-f 10005 2.1.0.4a-f
3962 1.0.5 (+ 2 patches) 10005 2.1.0.5
3963 1.0.5a-d 10006 2.1.0.5a-d
3964 1.0.5e-r 10100 2.1.0.5e-r
3965 1.0.5s-v 10006 2.1.0.5s-v
3966 1.0.6 (+ 3 patches) 10006 2.1.0.6
3967 1.0.6d-g 10007 2.1.0.6d-g
3968 1.0.6h 10007 10.6h
3969 1.0.6i 10007 10.6i
3970 1.0.6j 10007 2.1.0.6j
3971 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14
3972 1.0.7beta15-18 1 10007 2.1.0.7beta15-18
3973 1.0.7rc1-2 1 10007 2.1.0.7rc1-2
3974 1.0.7 1 10007 2.1.0.7
3975 1.0.8beta1-4 1 10008 2.1.0.8beta1-4
3976 1.0.8rc1 1 10008 2.1.0.8rc1
3977 1.0.8 1 10008 2.1.0.8
3978 1.0.9beta1-6 1 10009 2.1.0.9beta1-6
3979 1.0.9rc1 1 10009 2.1.0.9rc1
3980 1.0.9beta7-10 1 10009 2.1.0.9beta7-10
3981 1.0.9rc2 1 10009 2.1.0.9rc2
3982 1.0.9 1 10009 2.1.0.9
3983 1.0.10beta1 1 10010 2.1.0.10beta1
3984 1.0.10rc1 1 10010 2.1.0.10rc1
3985 1.0.10 1 10010 2.1.0.10
3986 1.0.11beta1-3 1 10011 2.1.0.11beta1-3
3987 1.0.11rc1 1 10011 2.1.0.11rc1
3988 1.0.11 1 10011 2.1.0.11
3989 1.0.12beta1-2 2 10012 2.1.0.12beta1-2
3990 1.0.12rc1 2 10012 2.1.0.12rc1
3991 1.0.12 2 10012 2.1.0.12
3992 1.1.0a-f - 10100 2.1.1.0a-f abandoned
3993 1.2.0beta1-2 2 10200 2.1.2.0beta1-2
3994 1.2.0beta3-5 3 10200 3.1.2.0beta3-5
3995 1.2.0rc1 3 10200 3.1.2.0rc1
3996 1.2.0 3 10200 3.1.2.0
3997 1.2.1beta-4 3 10201 3.1.2.1beta1-4
3998 1.2.1rc1-2 3 10201 3.1.2.1rc1-2
3999 1.2.1 3 10201 3.1.2.1
4000 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6
4001 1.0.13beta1 10 10013 10.so.0.1.0.13beta1
4002 1.0.13rc1 10 10013 10.so.0.1.0.13rc1
4003 1.2.2rc1 12 10202 12.so.0.1.2.2rc1
4004 1.0.13 10 10013 10.so.0.1.0.13
4005 1.2.2 12 10202 12.so.0.1.2.2
4006 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6
4007 1.2.3 12 10203 12.so.0.1.2.3
4008 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3
4009 1.2.4rc1 13 10204 12.so.0.1.2.4rc1
4010 1.0.14 10 10014 10.so.0.1.0.14
4011 1.2.4 13 10204 12.so.0.1.2.4
4012 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2
4013 1.0.15rc1 10 10015 10.so.0.1.0.15rc1
4014 1.0.15 10 10015 10.so.0.1.0.15
4015 1.2.5 13 10205 12.so.0.1.2.5
4016 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4
4017 1.2.6rc1-5 13 10206 12.so.0.1.2.6rc1-5
4018 1.0.16 10 10016 10.so.0.1.0.16
4019 1.2.6 13 10206 12.so.0.1.2.6
4020 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2
4021 1.0.17rc1 10 10017 10.so.0.1.0.17rc1
4022 1.2.7rc1 13 10207 12.so.0.1.2.7rc1
4023 1.0.17 10 10017 10.so.0.1.0.17
4024 1.2.7 13 10207 12.so.0.1.2.7
4025 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5
4026 1.0.18rc1-5 10 10018 10.so.0.1.0.18rc1-5
4027 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5
4028 1.0.18 10 10018 10.so.0.1.0.18
4029 1.2.8 13 10208 12.so.0.1.2.8
4030 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3
4031 1.2.9beta4-11 13 10209 12.so.0.9[.0]
4032 1.2.9rc1 13 10209 12.so.0.9[.0]
4033 1.2.9 13 10209 12.so.0.9[.0]
4034 1.2.10beta1-8 13 10210 12.so.0.10[.0]
4035 1.2.10rc1-3 13 10210 12.so.0.10[.0]
4036 1.2.10 13 10210 12.so.0.10[.0]
4037 1.2.11beta1-4 13 10211 12.so.0.11[.0]
4038 1.0.19rc1-5 10 10019 10.so.0.19[.0]
4039 1.2.11rc1-5 13 10211 12.so.0.11[.0]
4040 1.0.19 10 10019 10.so.0.19[.0]
4041 1.2.11 13 10211 12.so.0.11[.0]
4042 1.0.20 10 10020 10.so.0.20[.0]
4043 1.2.12 13 10212 12.so.0.12[.0]
4044 1.2.13beta1 13 10213 12.so.0.13[.0]
4045 1.0.21 10 10021 10.so.0.21[.0]
4046 1.2.13 13 10213 12.so.0.13[.0]
4047 1.2.14beta1-2 13 10214 12.so.0.14[.0]
4048 1.0.22rc1 10 10022 10.so.0.22[.0]
4049 1.2.14rc1 13 10214 12.so.0.14[.0]
4050 1.2.15beta1-6 13 10215 12.so.0.15[.0]
4051 1.0.23rc1-5 10 10023 10.so.0.23[.0]
4052 1.2.15rc1-5 13 10215 12.so.0.15[.0]
4053 1.0.23 10 10023 10.so.0.23[.0]
4054 1.2.15 13 10215 12.so.0.15[.0]
4055 1.2.16beta1-2 13 10216 12.so.0.16[.0]
4056 1.2.16rc1 13 10216 12.so.0.16[.0]
4057 1.0.24 10 10024 10.so.0.24[.0]
4058 1.2.16 13 10216 12.so.0.16[.0]
4059 1.2.17beta1-2 13 10217 12.so.0.17[.0]
4060 1.0.25rc1 10 10025 10.so.0.25[.0]
4061 1.2.17rc1-3 13 10217 12.so.0.17[.0]
4062 1.0.25 10 10025 10.so.0.25[.0]
4063 1.2.17 13 10217 12.so.0.17[.0]
4064 1.0.26 10 10026 10.so.0.26[.0]
4065 1.2.18 13 10218 12.so.0.18[.0]
4066 1.2.19beta1-31 13 10219 12.so.0.19[.0]
4067 1.0.27rc1-6 10 10027 10.so.0.27[.0]
4068 1.2.19rc1-6 13 10219 12.so.0.19[.0]
4069 1.0.27 10 10027 10.so.0.27[.0]
4070 1.2.19 13 10219 12.so.0.19[.0]
4071 1.2.20beta01-04 13 10220 12.so.0.20[.0]
4072 1.0.28rc1-6 10 10028 10.so.0.28[.0]
4073 1.2.20rc1-6 13 10220 12.so.0.20[.0]
4074 1.0.28 10 10028 10.so.0.28[.0]
4075 1.2.20 13 10220 12.so.0.20[.0]
4076 1.2.21beta1-2 13 10221 12.so.0.21[.0]
4077 1.2.21rc1-3 13 10221 12.so.0.21[.0]
4078 1.0.29 10 10029 10.so.0.29[.0]
4079 1.2.21 13 10221 12.so.0.21[.0]
4080 1.2.22beta1-4 13 10222 12.so.0.22[.0]
4081 1.0.30rc1 13 10030 10.so.0.30[.0]
4082 1.2.22rc1 13 10222 12.so.0.22[.0]
4083 1.0.30 10 10030 10.so.0.30[.0]
4084 1.2.22 13 10222 12.so.0.22[.0]
4085 1.2.23beta01-05 13 10223 12.so.0.23[.0]
4086 1.2.23rc01 13 10223 12.so.0.23[.0]
4087 1.2.23 13 10223 12.so.0.23[.0]
4088 1.2.24beta01-02 13 10224 12.so.0.24[.0]
4089 1.2.24rc01 13 10224 12.so.0.24[.0]
4090 1.2.24 13 10224 12.so.0.24[.0]
4091 1.2.25beta01-06 13 10225 12.so.0.25[.0]
4092 1.2.25rc01-02 13 10225 12.so.0.25[.0]
4093 1.0.31 10 10031 10.so.0.31[.0]
4094 1.2.25 13 10225 12.so.0.25[.0]
4095 1.2.26beta01-06 13 10226 12.so.0.26[.0]
4096 1.2.26rc01 13 10226 12.so.0.26[.0]
4097 1.2.26 13 10226 12.so.0.26[.0]
4098 1.0.32 10 10032 10.so.0.32[.0]
4099 1.2.27beta01-06 13 10227 12.so.0.27[.0]
4100 1.2.27rc01 13 10227 12.so.0.27[.0]
4101 1.0.33 10 10033 10.so.0.33[.0]
4102 1.2.27 13 10227 12.so.0.27[.0]
4103 1.0.34 10 10034 10.so.0.34[.0]
4104 1.2.28 13 10228 12.so.0.28[.0]
4105 1.2.29beta01-03 13 10229 12.so.0.29[.0]
4106 1.2.29rc01 13 10229 12.so.0.29[.0]
4107 1.0.35 10 10035 10.so.0.35[.0]
4108 1.2.29 13 10229 12.so.0.29[.0]
The Android Open Source Project4215dd12009-03-09 11:52:12 -07004109 1.0.37 10 10037 10.so.0.37[.0]
4110 1.2.30beta01-04 13 10230 12.so.0.30[.0]
4111 1.0.38rc01-08 10 10038 10.so.0.38[.0]
4112 1.2.30rc01-08 13 10230 12.so.0.30[.0]
4113 1.0.38 10 10038 10.so.0.38[.0]
4114 1.2.30 13 10230 12.so.0.30[.0]
4115 1.0.39rc01-03 10 10039 10.so.0.39[.0]
4116 1.2.31rc01-03 13 10231 12.so.0.31[.0]
4117 1.0.39 10 10039 10.so.0.39[.0]
4118 1.2.31 13 10231 12.so.0.31[.0]
4119 1.2.32beta01-02 13 10232 12.so.0.32[.0]
4120 1.0.40rc01 10 10040 10.so.0.40[.0]
4121 1.2.32rc01 13 10232 12.so.0.32[.0]
4122 1.0.40 10 10040 10.so.0.40[.0]
4123 1.2.32 13 10232 12.so.0.32[.0]
4124 1.2.33beta01-02 13 10233 12.so.0.33[.0]
4125 1.2.33rc01-02 13 10233 12.so.0.33[.0]
4126 1.0.41rc01 10 10041 10.so.0.41[.0]
4127 1.2.33 13 10233 12.so.0.33[.0]
4128 1.0.41 10 10041 10.so.0.41[.0]
4129 1.2.34beta01-07 13 10234 12.so.0.34[.0]
4130 1.0.42rc01 10 10042 10.so.0.42[.0]
4131 1.2.34rc01 13 10234 12.so.0.34[.0]
4132 1.0.42 10 10042 10.so.0.42[.0]
4133 1.2.34 13 10234 12.so.0.34[.0]
4134 1.2.35beta01-03 13 10235 12.so.0.35[.0]
4135 1.0.43rc01-02 10 10043 10.so.0.43[.0]
4136 1.2.35rc01-02 13 10235 12.so.0.35[.0]
4137 1.0.43 10 10043 10.so.0.43[.0]
4138 1.2.35 13 10235 12.so.0.35[.0]
Patrick Scotta0bb96c2009-07-22 11:50:02 -04004139 1.2.36beta01-05 13 10236 12.so.0.36[.0]
4140 1.2.36rc01 13 10236 12.so.0.36[.0]
4141 1.0.44 10 10044 10.so.0.44[.0]
4142 1.2.36 13 10236 12.so.0.36[.0]
4143 1.2.37beta01-03 13 10237 12.so.0.37[.0]
4144 1.2.37rc01 13 10237 12.so.0.37[.0]
4145 1.2.37 13 10237 12.so.0.37[.0]
4146 1.2.45 10 10045 12.so.0.45[.0]
4147 1.0.46 10 10046 10.so.0.46[.0]
4148 1.2.38beta01 13 10238 12.so.0.38[.0]
4149 1.2.38rc01-03 13 10238 12.so.0.38[.0]
4150 1.0.47 10 10047 10.so.0.47[.0]
4151 1.2.38 13 10238 12.so.0.38[.0]
The Android Open Source Project893912b2009-03-03 19:30:05 -08004152
4153Henceforth the source version will match the shared-library minor
4154and patch numbers; the shared-library major version number will be
4155used for changes in backward compatibility, as it is intended. The
4156PNG_PNGLIB_VER macro, which is not used within libpng but is available
4157for applications, is an unsigned integer of the form xyyzz corresponding
4158to the source version x.y.z (leading zeros in y and z). Beta versions
4159were given the previous public release number plus a letter, until
4160version 1.0.6j; from then on they were given the upcoming public
4161release number plus "betaNN" or "rcN".
4162
4163.SH "SEE ALSO"
4164.IR libpngpf(3) ", " png(5)
4165.LP
4166.IR libpng :
4167.IP
4168http://libpng.sourceforge.net (follow the [DOWNLOAD] link)
4169http://www.libpng.org/pub/png
4170
4171.LP
4172.IR zlib :
4173.IP
4174(generally) at the same location as
4175.I libpng
4176or at
4177.br
4178ftp://ftp.info-zip.org/pub/infozip/zlib
4179
4180.LP
4181.IR PNG specification: RFC 2083
4182.IP
4183(generally) at the same location as
4184.I libpng
4185or at
4186.br
4187ftp://ftp.rfc-editor.org:/in-notes/rfc2083.txt
4188.br
4189or (as a W3C Recommendation) at
4190.br
4191http://www.w3.org/TR/REC-png.html
4192
4193.LP
4194In the case of any inconsistency between the PNG specification
4195and this library, the specification takes precedence.
4196
4197.SH AUTHORS
4198This man page: Glenn Randers-Pehrson
4199<glennrp at users.sourceforge.net>
4200
4201The contributing authors would like to thank all those who helped
4202with testing, bug fixes, and patience. This wouldn't have been
4203possible without all of you.
4204
4205Thanks to Frank J. T. Wojcik for helping with the documentation.
4206
Patrick Scotta0bb96c2009-07-22 11:50:02 -04004207Libpng version 1.2.38 - July 16, 2009:
The Android Open Source Project893912b2009-03-03 19:30:05 -08004208Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
4209Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
4210
4211Supported by the PNG development group
4212.br
4213png-mng-implement at lists.sf.net
4214(subscription required; visit
4215png-mng-implement at lists.sourceforge.net (subscription required; visit
4216https://lists.sourceforge.net/lists/listinfo/png-mng-implement
4217to subscribe).
4218
4219.SH COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
4220
4221(This copy of the libpng notices is provided for your convenience. In case of
4222any discrepancy between this copy and the notices in the file png.h that is
4223included in the libpng distribution, the latter shall prevail.)
4224
4225If you modify libpng you may insert additional notices immediately following
4226this sentence.
4227
Patrick Scotta0bb96c2009-07-22 11:50:02 -04004228This code is released under the libpng license.
4229
4230libpng versions 1.2.6, August 15, 2004, through 1.2.38, July 16, 2009, are
The Android Open Source Project893912b2009-03-03 19:30:05 -08004231Copyright (c) 2004,2006-2008 Glenn Randers-Pehrson, and are
4232distributed according to the same disclaimer and license as libpng-1.2.5
4233with the following individual added to the list of Contributing Authors
4234
4235 Cosmin Truta
4236
4237libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
4238Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
4239distributed according to the same disclaimer and license as libpng-1.0.6
4240with the following individuals added to the list of Contributing Authors
4241
4242 Simon-Pierre Cadieux
4243 Eric S. Raymond
4244 Gilles Vollant
4245
4246and with the following additions to the disclaimer:
4247
4248 There is no warranty against interference with your
4249 enjoyment of the library or against infringement.
4250 There is no warranty that our efforts or the library
4251 will fulfill any of your particular purposes or needs.
4252 This library is provided with all faults, and the entire
4253 risk of satisfactory quality, performance, accuracy, and
4254 effort is with the user.
4255
4256libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
4257Copyright (c) 1998, 1999 Glenn Randers-Pehrson
4258Distributed according to the same disclaimer and license as libpng-0.96,
4259with the following individuals added to the list of Contributing Authors:
4260
4261 Tom Lane
4262 Glenn Randers-Pehrson
4263 Willem van Schaik
4264
4265libpng versions 0.89, June 1996, through 0.96, May 1997, are
4266Copyright (c) 1996, 1997 Andreas Dilger
4267Distributed according to the same disclaimer and license as libpng-0.88,
4268with the following individuals added to the list of Contributing Authors:
4269
4270 John Bowler
4271 Kevin Bracey
4272 Sam Bushell
4273 Magnus Holmgren
4274 Greg Roelofs
4275 Tom Tanner
4276
4277libpng versions 0.5, May 1995, through 0.88, January 1996, are
4278Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
4279
4280For the purposes of this copyright and license, "Contributing Authors"
4281is defined as the following set of individuals:
4282
4283 Andreas Dilger
4284 Dave Martindale
4285 Guy Eric Schalnat
4286 Paul Schmidt
4287 Tim Wegner
4288
4289The PNG Reference Library is supplied "AS IS". The Contributing Authors
4290and Group 42, Inc. disclaim all warranties, expressed or implied,
4291including, without limitation, the warranties of merchantability and of
4292fitness for any purpose. The Contributing Authors and Group 42, Inc.
4293assume no liability for direct, indirect, incidental, special, exemplary,
4294or consequential damages, which may result from the use of the PNG
4295Reference Library, even if advised of the possibility of such damage.
4296
4297Permission is hereby granted to use, copy, modify, and distribute this
4298source code, or portions hereof, for any purpose, without fee, subject
4299to the following restrictions:
4300
43011. The origin of this source code must not be misrepresented.
4302
43032. Altered versions must be plainly marked as such and
4304 must not be misrepresented as being the original source.
4305
43063. This Copyright notice may not be removed or altered from
4307 any source or altered source distribution.
4308
4309The Contributing Authors and Group 42, Inc. specifically permit, without
4310fee, and encourage the use of this source code as a component to
4311supporting the PNG file format in commercial products. If you use this
4312source code in a product, acknowledgment is not required but would be
4313appreciated.
4314
4315
4316A "png_get_copyright" function is available, for convenient use in "about"
4317boxes and the like:
4318
4319 printf("%s",png_get_copyright(NULL));
4320
4321Also, the PNG logo (in PNG format, of course) is supplied in the
4322files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
4323
4324Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
4325certification mark of the Open Source Initiative.
4326
4327Glenn Randers-Pehrson
4328glennrp at users.sourceforge.net
Patrick Scotta0bb96c2009-07-22 11:50:02 -04004329July 16, 2009
The Android Open Source Project893912b2009-03-03 19:30:05 -08004330
4331.\" end of man page
4332