blob: acbaee2dcc0e5e09dbf62212b488182e577161dd [file] [log] [blame]
Glenn Randers-Pehrsonf8b008c1999-09-18 10:54:36 -05001.TH LIBPNG 3 "September 18, 1999"
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06002.SH NAME
Glenn Randers-Pehrsonf8b008c1999-09-18 10:54:36 -05003libpng \- Portable Network Graphics (PNG) Reference Library 1.0.4 - September 18, 1999
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06004.SH SYNOPSIS
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05005\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06006
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05007\fB#include <png.h>\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06008
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05009\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060010
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050011\fBint png_check_sig (png_bytep \fP\fIsig\fP\fB, int \fInum\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060012
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050013\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060014
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050015\fBvoid png_chunk_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060016
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050017\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060018
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050019\fBvoid png_chunk_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060020
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050021\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060022
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050023\fBvoid png_convert_from_struct_tm (png_timep \fP\fIptime\fP\fB, struct tm FAR * \fIttime\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060024
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050025\fI\fB
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -050026
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050027\fBvoid png_convert_from_time_t (png_timep \fP\fIptime\fP\fB, time_t \fIttime\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060028
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050029\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060030
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050031\fBpng_charp png_convert_to_rfc1123 (png_structp \fP\fIpng_ptr\fP\fB, png_timep \fIptime\fP\fB);\fP
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -060032
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050033\fI\fB
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -060034
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050035\fBpng_infop png_create_info_struct (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060036
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050037\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060038
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050039\fBpng_structp png_create_read_struct (png_const_charp \fP\fIuser_png_ver\fP\fB, voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarn_fn\fP\fB);\fP
40
41\fI\fB
42
43\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
44
45\fI\fB
46
47\fBpng_structp png_create_write_struct (png_const_charp \fP\fIuser_png_ver\fP\fB, voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarn_fn\fP\fB);\fP
48
49\fI\fB
50
51\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
52
53\fI\fB
54
55\fBint png_debug(int \fP\fIlevel\fP\fB, png_const_charp \fImessage\fP\fB);\fP
56
57\fI\fB
58
59\fBint png_debug1(int \fP\fIlevel\fP\fB, png_const_charp \fP\fImessage\fP\fB, \fIp1\fP\fB);\fP
60
61\fI\fB
62
63\fBint png_debug2(int \fP\fIlevel\fP\fB, png_const_charp \fP\fImessage\fP\fB, \fP\fIp1\fP\fB, \fIp2\fP\fB);\fP
64
65\fI\fB
66
67\fBvoid png_destroy_info_struct (png_structp \fP\fIpng_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP
68
69\fI\fB
70
71\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
72
73\fI\fB
74
75\fBvoid png_destroy_write_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP
76
77\fI\fB
78
79\fBvoid png_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP
80
81\fI\fB
82
83\fBvoid png_free (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP
84
85\fI\fB
86
87\fBvoid png_free_default(png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP
88
89\fI\fB
90
91\fBpng_byte png_get_bit_depth (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
92
93\fI\fB
94
95\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
96
97\fI\fB
98
99\fBpng_byte png_get_channels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
100
101\fI\fB
102
103\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
104
105\fI\fB
106
107\fBpng_byte png_get_color_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
108
109\fI\fB
110
111\fBpng_byte png_get_compression_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
112
113\fI\fB
114
115\fBpng_byte png_get_copyright (png_structp \fIpng_ptr\fP\fB);\fP
116
117\fI\fB
118
119\fBpng_voidp png_get_error_ptr (png_structp \fIpng_ptr\fP\fB);\fP
120
121\fI\fB
122
123\fBpng_byte png_get_filter_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
124
125\fI\fB
126
127\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
128
129\fI\fB
130
131\fBpng_byte png_get_header_version (png_structp \fIpng_ptr\fP\fB);\fP
132
133\fI\fB
134
135\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
136
137\fI\fB
138
139\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
140
141\fI\fB
142
143\fBpng_uint_32 png_get_image_height (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
144
145\fI\fB
146
147\fBpng_uint_32 png_get_image_width (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
148
149\fI\fB
150
151\fBpng_byte png_get_interlace_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
152
153\fI\fB
154
155\fBpng_voidp png_get_io_ptr (png_structp \fIpng_ptr\fP\fB);\fP
156
157\fI\fB
158
159\fBpng_voidp png_get_mem_ptr(png_structp \fIpng_ptr\fP\fB);\fP
160
161\fI\fB
162
163\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
164
165\fI\fB
166
167\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
168
169\fI\fB
170
171\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
172
173\fI\fB
174
175\fBfloat png_get_pixel_aspect_ratio (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
176
177\fI\fB
178
179\fBpng_uint_32 png_get_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
180
181\fI\fB
182
183\fBpng_voidp png_get_progressive_ptr (png_structp \fIpng_ptr\fP\fB);\fP
184
185\fI\fB
186
187\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
188
189\fI\fB
190
191\fBpng_byte png_get_rgb_to_gray_status (png_structp \fIpng_ptr)
192
193\fBpng_uint_32 png_get_rowbytes (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
194
195\fI\fB
196
197\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
198
199\fI\fB
200
201\fBpng_bytep png_get_signature (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
202
203\fI\fB
204
205\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
206
207\fI\fB
208
209\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
210
211\fI\fB
212
213\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
214
215\fI\fB
216
217\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
218
219\fI\fB
220
221\fBpng_voidp png_get_user_transform_ptr (png_structp \fIpng_ptr\fP\fB);\fP
222
223\fI\fB
224
225\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
226
227\fI\fB
228
229\fBpng_uint_32 png_get_x_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
230
231\fI\fB
232
233\fBpng_uint_32 png_get_x_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
234
235\fI\fB
236
237\fBpng_uint_32 png_get_x_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
238
239\fI\fB
240
241\fBpng_uint_32 png_get_y_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
242
243\fI\fB
244
245\fBpng_uint_32 png_get_y_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
246
247\fI\fB
248
249\fBpng_uint_32 png_get_y_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
250
251\fI\fB
252
253\fBvoid png_info_init (png_infop \fIinfo_ptr\fP\fB);\fP
254
255\fI\fB
256
257\fBvoid png_init_io (png_structp \fP\fIpng_ptr\fP\fB, FILE \fI*fp\fP\fB);\fP
258
259\fI\fB
260
261\fBpng_voidp png_malloc (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
262
263\fI\fB
264
265\fBpng_voidp png_malloc_default(png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
266
267\fI\fB
268
269\fBvoidp png_memcpy (png_voidp \fP\fIs1\fP\fB, png_voidp \fP\fIs2\fP\fB, png_size_t \fIsize\fP\fB);\fP
270
271\fI\fB
272
273\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
274
275\fI\fB
276
277\fBvoidp png_memset (png_voidp \fP\fIs1\fP\fB, int \fP\fIvalue\fP\fB, png_size_t \fIsize\fP\fB);\fP
278
279\fI\fB
280
281\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
282
283\fI\fB
284
285\fBvoid png_permit_empty_plte (png_structp \fP\fIpng_ptr\fP\fB, int \fIempty_plte_permitted\fP\fB);\fP
286
287\fI\fB
288
289\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
290
291\fI\fB
292
293\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
294
295\fI\fB
296
297\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
298
299\fI\fB
300
301\fBvoid png_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
302
303\fI\fB
304
305\fBvoid png_read_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP
306
307\fI\fB
308
309\fBvoid png_read_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
310
311\fI\fB
312
313\fBvoid png_read_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fIdisplay_row\fP\fB);\fP
314
315\fI\fB
316
317\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
318
319\fI\fB
320
321\fBvoid png_read_update_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
322
323\fI\fB
324
325\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
326
327\fI\fB
328
329\fBvoid png_set_bgr (png_structp \fIpng_ptr\fP\fB);\fP
330
331\fI\fB
332
333\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
334
335\fI\fB
336
337\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
338
339\fI\fB
340
341\fBvoid png_set_compression_level (png_structp \fP\fIpng_ptr\fP\fB, int \fIlevel\fP\fB);\fP
342
343\fI\fB
344
345\fBvoid png_set_compression_mem_level (png_structp \fP\fIpng_ptr\fP\fB, int \fImem_level\fP\fB);\fP
346
347\fI\fB
348
349\fBvoid png_set_compression_method (png_structp \fP\fIpng_ptr\fP\fB, int \fImethod\fP\fB);\fP
350
351\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600352
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500353\fBvoid png_set_compression_strategy (png_structp \fP\fIpng_ptr\fP\fB, int \fIstrategy\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600354
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500355\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600356
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500357\fBvoid png_set_compression_window_bits (png_structp \fP\fIpng_ptr\fP\fB, int \fIwindow_bits\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600358
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500359\fI\fB
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500360
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500361\fBvoid png_set_crc_action (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcrit_action\fP\fB, int \fIancil_action\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600362
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500363\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600364
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500365\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600366
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500367\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600368
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500369\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600370
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500371\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600372
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500373\fBvoid png_set_expand (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600374
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500375\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600376
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500377\fBvoid png_set_filler (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600378
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500379\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600380
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500381\fBvoid png_set_filter (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fImethod\fP\fB, int \fIfilters\fP\fB);\fP
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600382
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500383\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600384
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500385\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
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500386
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500387\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600388
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500389\fBvoid png_set_flush (png_structp \fP\fIpng_ptr\fP\fB, int \fInrows\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600390
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500391\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600392
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500393\fBvoid png_set_gamma (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIscreen_gamma\fP\fB, double \fIdefault_file_gamma\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600394
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500395\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600396
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500397\fBvoid png_set_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fIfile_gamma\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600398
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500399\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600400
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500401\fBvoid png_set_gray_1_2_4_to_8(png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600402
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500403\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600404
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500405\fBvoid png_set_gray_to_rgb (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600406
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500407\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600408
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500409\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600410
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500411\fI\fB
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600412
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500413\fBint png_set_interlace_handling (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600414
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500415\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600416
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500417\fBvoid png_set_invert_alpha (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600418
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500419\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600420
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500421\fBvoid png_set_invert_mono (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600422
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500423\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600424
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500425\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600426
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500427\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600428
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500429\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600430
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500431\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600432
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500433\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
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600434
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500435\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600436
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500437\fBvoid png_set_packing (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600438
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500439\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600440
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500441\fBvoid png_set_packswap (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600442
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500443\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600444
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500445\fBvoid png_set_palette_to_rgb(png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600446
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500447\fI\fB
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500448
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500449\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600450
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500451\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600452
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500453\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600454
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500455\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600456
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500457\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600458
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500459\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600460
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500461\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600462
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500463\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600464
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500465\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600466
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500467\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600468
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500469\fBvoid png_set_read_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_read_status_ptr \fIread_row_fn\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600470
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500471\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600472
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500473\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600474
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500475\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600476
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500477\fBvoid png_set_rgb_to_gray (png_structp \fP\fIpng_ptr\fP\fB, int \fIerror_action\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600478
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500479\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600480
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500481\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600482
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500483\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600484
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500485\fBvoid png_set_shift (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fItrue_bits\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600486
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500487\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600488
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500489\fBvoid png_set_sig_bytes (png_structp \fP\fIpng_ptr\fP\fB, int \fInum_bytes\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600490
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500491\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600492
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500493\fBvoid png_set_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIintent\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600494
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500495\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600496
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500497\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600498
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500499\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600500
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500501\fBvoid png_set_strip_16 (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600502
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500503\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600504
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500505\fBvoid png_set_strip_alpha (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600506
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500507\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600508
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500509\fBvoid png_set_swap (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600510
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500511\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600512
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500513\fBvoid png_set_swap_alpha (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600514
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500515\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600516
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500517\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600518
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500519\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600520
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500521\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600522
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500523\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600524
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500525\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
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500526
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500527\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600528
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500529\fBvoid png_set_tRNS_to_alpha(png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600530
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500531\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600532
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500533\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600534
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500535\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600536
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500537\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600538
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500539\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600540
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500541\fBvoid png_set_write_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_write_status_ptr \fIwrite_row_fn\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600542
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500543\fI\fB
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600544
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500545\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
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600546
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500547\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600548
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500549\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600550
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500551\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600552
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500553\fBvoid png_start_read_image (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600554
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500555\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600556
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500557\fBvoid png_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600558
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500559\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600560
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500561\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600562
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500563\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600564
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500565\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600566
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500567\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600568
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500569\fBvoid png_write_chunk_end (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600570
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500571\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600572
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500573\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600574
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500575\fI\fB
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600576
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500577\fBvoid png_write_destroy (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600578
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500579\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600580
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500581\fBvoid png_write_destroy_info (png_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600582
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500583\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600584
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500585\fBvoid png_write_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600586
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500587\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600588
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500589\fBvoid png_write_flush (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600590
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500591\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600592
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500593\fBvoid png_write_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600594
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500595\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600596
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500597\fBvoid png_write_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600598
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500599\fI\fB
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500600
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500601\fBvoid png_write_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIrow\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600602
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500603\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600604
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500605\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
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600606
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500607\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600608
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -0600609.SH DESCRIPTION
610The
611.I libpng
612library supports encoding, decoding, and various manipulations of
613the Portable Network Graphics (PNG) format image files. It uses the
614.IR zlib(3)
615compression library.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600616Following is a copy of the libpng.txt file that accompanies libpng.
617.SH LIBPNG.TXT
618libpng.txt - A description on how to use and modify libpng
619
Glenn Randers-Pehrsonf8b008c1999-09-18 10:54:36 -0500620 libpng version 1.0.4 - September 18, 1999
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600621 Updated and distributed by Glenn Randers-Pehrson
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500622 <randeg@alum.rpi.edu>
Glenn Randers-Pehrson87544ac1999-01-13 22:06:39 -0600623 Copyright (c) 1998, 1999 Glenn Randers-Pehrson
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600624 For conditions of distribution and use, see copyright
625 notice in png.h.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600626
627 based on:
628
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600629 libpng 1.0 beta 6 version 0.96 May 28, 1997
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600630 Updated and distributed by Andreas Dilger
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600631 Copyright (c) 1996, 1997 Andreas Dilger
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600632
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600633 libpng 1.0 beta 2 - version 0.88 January 26, 1996
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600634 For conditions of distribution and use, see copyright
635 notice in png.h. Copyright (c) 1995, 1996 Guy Eric
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600636 Schalnat, Group 42, Inc.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600637
638 Updated/rewritten per request in the libpng FAQ
639 Copyright (c) 1995 Frank J. T. Wojcik
640 December 18, 1995 && January 20, 1996
641
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500642 *
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600643.SH I. Introduction
644
645This file describes how to use and modify the PNG reference library
646(known as libpng) for your own use. There are five sections to this
647file: introduction, structures, reading, writing, and modification and
648configuration notes for various special platforms. In addition to this
649file, example.c is a good starting point for using the library, as
650it is heavily commented and should include everything most people
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600651will need. We assume that libpng is already installed; see the
652INSTALL file for instructions on how to install libpng.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600653
654Libpng was written as a companion to the PNG specification, as a way
655of reducing the amount of time and effort it takes to support the PNG
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500656file format in application programs.
657
658The PNG-1.2 specification is available at <http://www.cdrom.com/png>.
659
660The PNG-1.0 specification is available
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600661as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/> and as a
662W3C Recommendation <http://www.w3.org/TR/REC.png.html>. Some
663additional chunks are described in the special-purpose public chunks
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500664documents at <ftp://ftp.uu.net/graphics/png/documents/>.
665
666Other information
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600667about PNG, and the latest version of libpng, can be found at the PNG home
668page, <http://www.cdrom.com/pub/png/>.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600669
670Most users will not have to modify the library significantly; advanced
671users may want to modify it more. All attempts were made to make it as
672complete as possible, while keeping the code easy to understand.
673Currently, this library only supports C. Support for other languages
674is being considered.
675
676Libpng has been designed to handle multiple sessions at one time,
677to be easily modifiable, to be portable to the vast majority of
678machines (ANSI, K&R, 16-, 32-, and 64-bit) available, and to be easy
679to use. The ultimate goal of libpng is to promote the acceptance of
680the PNG file format in whatever way possible. While there is still
681work to be done (see the TODO file), libpng should cover the
682majority of the needs of its users.
683
684Libpng uses zlib for its compression and decompression of PNG files.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600685Further information about zlib, and the latest version of zlib, can
686be found at the zlib home page, <http://www.cdrom.com/pub/infozip/zlib/>.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600687The zlib compression utility is a general purpose utility that is
688useful for more than PNG files, and can be used without libpng.
689See the documentation delivered with zlib for more details.
690You can usually find the source files for the zlib utility wherever you
691find the libpng source files.
692
693Libpng is thread safe, provided the threads are using different
694instances of the structures. Each thread should have its own
695png_struct and png_info instances, and thus its own image.
696Libpng does not protect itself against two threads using the
697same instance of a structure.
698
699
700.SH II. Structures
701
702There are two main structures that are important to libpng, png_struct
703and png_info. The first, png_struct, is an internal structure that
704will not, for the most part, be used by a user except as the first
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600705variable passed to every libpng function call.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600706
707The png_info structure is designed to provide information about the
708PNG file. At one time, the fields of png_info were intended to be
709directly accessible to the user. However, this tended to cause problems
710with applications using dynamically loaded libraries, and as a result
711a set of interface functions for png_info was developed. The fields
712of png_info are still available for older applications, but it is
713suggested that applications use the new interfaces if at all possible.
714
715The png.h header file is an invaluable reference for programming with libpng.
716And while I'm on the topic, make sure you include the libpng header file:
717
718#include <png.h>
719
720.SH III. Reading
721
722Reading PNG files:
723
724We'll now walk you through the possible functions to call when reading
725in a PNG file, briefly explaining the syntax and purpose of each one.
726See example.c and png.h for more detail. While Progressive reading
727is covered in the next section, you will still need some of the
728functions discussed in this section to read a PNG file.
729
730You will want to do the I/O initialization(*) before you get into libpng,
731so if it doesn't work, you don't have much to undo. Of course, you
732will also want to insure that you are, in fact, dealing with a PNG
733file. Libpng provides a simple check to see if a file is a PNG file.
734To use it, pass in the first 1 to 8 bytes of the file, and it will
735return true or false (1 or 0) depending on whether the bytes could be
736part of a PNG file. Of course, the more bytes you pass in, the
737greater the accuracy of the prediction.
738
739If you are intending to keep the file pointer open for use in libpng,
740you must ensure you don't read more than 8 bytes from the beginning
741of the file, and you also have to make a call to png_set_sig_bytes_read()
742with the number of bytes you read from the beginning. Libpng will
743then only check the bytes (if any) that your program didn't read.
744
745(*): If you are not using the standard I/O functions, you will need
746to replace them with custom functions. See the discussion under
747Customizing libpng.
748
749
750 FILE *fp = fopen(file_name, "rb");
751 if (!fp)
752 {
753 return;
754 }
755 fread(header, 1, number, fp);
Glenn Randers-Pehrsonc9442291999-01-06 21:50:16 -0600756 is_png = !png_sig_cmp(header, 0, number);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600757 if (!is_png)
758 {
759 return;
760 }
761
762
763Next, png_struct and png_info need to be allocated and initialized. In
764order to ensure that the size of these structures is correct even with a
765dynamically linked libpng, there are functions to initialize and
766allocate the structures. We also pass the library version, optional
767pointers to error handling functions, and a pointer to a data struct for
768use by the error functions, if necessary (the pointer and functions can
769be NULL if the default error handlers are to be used). See the section
770on Changes to Libpng below regarding the old initialization functions.
771
772 png_structp png_ptr = png_create_read_struct
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -0500773 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600774 user_error_fn, user_warning_fn);
775 if (!png_ptr)
776 return;
777
778 png_infop info_ptr = png_create_info_struct(png_ptr);
779 if (!info_ptr)
780 {
781 png_destroy_read_struct(&png_ptr,
782 (png_infopp)NULL, (png_infopp)NULL);
783 return;
784 }
785
786 png_infop end_info = png_create_info_struct(png_ptr);
787 if (!end_info)
788 {
789 png_destroy_read_struct(&png_ptr, &info_ptr,
790 (png_infopp)NULL);
791 return;
792 }
793
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500794If you want to use your own memory allocation routines,
795define PNG_USER_MEM_SUPPORTED and use
796png_create_read_struct_2() instead of png_create_read_struct():
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600797
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500798 png_structp png_ptr = png_create_read_struct_2
799 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
800 user_error_fn, user_warning_fn, (png_voidp)
801 user_mem_ptr, user_malloc_fn, user_free_fn);
802
803The error handling routines passed to png_create_read_struct()
804and the memory alloc/free routines passed to png_create_struct_2()
805are only necessary if you are not using the libpng supplied error
806handling and memory alloc/free functions.
807
808When libpng encounters an error, it expects to longjmp back
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600809to your routine. Therefore, you will need to call setjmp and pass
810your png_ptr->jmpbuf. If you read the file from different
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600811routines, you will need to update the jmpbuf field every time you enter
812a new routine that will call a png_ function.
813
814See your documentation of setjmp/longjmp for your compiler for more
815handling in the Customizing Libpng section below for more information on
816the libpng error handling. If an error occurs, and libpng longjmp's
817back to your setjmp, you will want to call png_destroy_read_struct() to
818free any memory.
819
820 if (setjmp(png_ptr->jmpbuf))
821 {
822 png_destroy_read_struct(&png_ptr, &info_ptr,
823 &end_info);
824 fclose(fp);
825 return;
826 }
827
828Now you need to set up the input code. The default for libpng is to
829use the C function fread(). If you use this, you will need to pass a
830valid FILE * in the function png_init_io(). Be sure that the file is
831opened in binary mode. If you wish to handle reading data in another
832way, you need not call the png_init_io() function, but you must then
833implement the libpng I/O methods discussed in the Customizing Libpng
834section below.
835
836 png_init_io(png_ptr, fp);
837
838If you had previously opened the file and read any of the signature from
839the beginning in order to see if this was a PNG file, you need to let
840libpng know that there are some bytes missing from the start of the file.
841
842 png_set_sig_bytes(png_ptr, number);
843
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600844At this point, you can set up a callback function that will be
845called after each row has been read, which you can use to control
846a progress meter or the like. It's demonstrated in pngtest.c.
847You must supply a function
848
849 void read_row_callback(png_ptr, png_uint_32 row, int pass);
850 {
851 /* put your code here */
852 }
853
854(You can give it another name that you like instead of "read_row_callback")
855
856To inform libpng about your function, use
857
858 png_set_read_status_fn(png_ptr, read_row_callback);
859
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600860In PNG files, the alpha channel in an image is the level of opacity.
861If you need the alpha channel in an image to be the level of transparency
862instead of opacity, you can invert the alpha channel (or the tRNS chunk
863data) after it's read, so that 0 is fully opaque and 255 (in 8-bit or
864paletted images) or 65535 (in 16-bit images) is fully transparent, with
865
866 png_set_invert_alpha(png_ptr);
867
868This has to appear here rather than later with the other transformations
869because the tRNS chunk data must be modified in the case of paletted images.
870If your image is not a paletted image, the tRNS data (which in such cases
871represents a single color to be rendered as transparent) won't be changed.
872
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600873Finally, you can write your own transformation function if none of
874the existing ones meets your needs. This is done by setting a callback
875with
876
877 png_set_read_user_transform_fn(png_ptr,
878 read_transform_fn);
879
880You must supply the function
881
882 void read_transform_fn(png_ptr ptr, row_info_ptr
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600883 row_info, png_bytep data)
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -0600884
885See pngtest.c for a working example. Your function will be called
886after all of the other transformations have been processed.
887
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500888You can also set up a pointer to a user structure for use by your
889callback function, and you can inform libpng that your transform
890function will change the number of channels or bit depth with the
891function
892
893 png_set_user_transform_info(png_ptr, user_ptr,
894 user_depth, user_channels);
895
896
897You can retrieve the pointer via the function
898png_get_user_transform_ptr(). For example:
899
900 voidp read_user_transform_ptr =
901 png_get_user_transform_ptr(png_ptr);
902
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600903You are now ready to read all the file information up to the actual
904image data. You do this with a call to png_read_info().
905
906 png_read_info(png_ptr, info_ptr);
907
908Functions are used to get the information from the info_ptr:
909
910 png_get_IHDR(png_ptr, info_ptr, &width, &height,
911 &bit_depth, &color_type, &interlace_type,
912 &compression_type, &filter_type);
913
914 width - holds the width of the image
915 in pixels (up to 2^31).
916 height - holds the height of the image
917 in pixels (up to 2^31).
918 bit_depth - holds the bit depth of one of the
919 image channels. (valid values are
920 1, 2, 4, 8, 16 and depend also on
921 the color_type. See also
922 significant bits (sBIT) below).
923 color_type - describes which color/alpha channels
924 are present.
925 PNG_COLOR_TYPE_GRAY
926 (bit depths 1, 2, 4, 8, 16)
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600927 PNG_COLOR_TYPE_GRAY_ALPHA
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600928 (bit depths 8, 16)
929 PNG_COLOR_TYPE_PALETTE
930 (bit depths 1, 2, 4, 8)
931 PNG_COLOR_TYPE_RGB
932 (bit_depths 8, 16)
933 PNG_COLOR_TYPE_RGB_ALPHA
934 (bit_depths 8, 16)
935
936 PNG_COLOR_MASK_PALETTE
937 PNG_COLOR_MASK_COLOR
938 PNG_COLOR_MASK_ALPHA
939
940 filter_type - (must be PNG_FILTER_TYPE_BASE
941 for PNG 1.0)
942 compression_type - (must be PNG_COMPRESSION_TYPE_BASE
943 for PNG 1.0)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600944 interlace_type - (PNG_INTERLACE_NONE or
945 PNG_INTERLACE_ADAM7)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600946 Any or all of interlace_type, compression_type, of
947 filter_type can be
948 NULL if you are not interested in their values.
949
950 channels = png_get_channels(png_ptr, info_ptr);
951 channels - number of channels of info for the
952 color type (valid values are 1 (GRAY,
953 PALETTE), 2 (GRAY_ALPHA), 3 (RGB),
954 4 (RGB_ALPHA or RGB + filler byte))
955 rowbytes = png_get_rowbytes(png_ptr, info_ptr);
956 rowbytes - number of bytes needed to hold a row
957
958 signature = png_get_signature(png_ptr, info_ptr);
959 signature - holds the signature read from the
960 file (if any). The data is kept in
961 the same offset it would be if the
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -0600962 whole signature were read (i.e. if an
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600963 application had already read in 4
964 bytes of signature before starting
965 libpng, the remaining 4 bytes would
966 be in signature[4] through signature[7]
967 (see png_set_sig_bytes())).
968
969
970 width = png_get_image_width(png_ptr,
971 info_ptr);
972 height = png_get_image_height(png_ptr,
973 info_ptr);
974 bit_depth = png_get_bit_depth(png_ptr,
975 info_ptr);
976 color_type = png_get_color_type(png_ptr,
977 info_ptr);
978 filter_type = png_get_filter_type(png_ptr,
979 info_ptr);
980 compression_type = png_get_compression_type(png_ptr,
981 info_ptr);
982 interlace_type = png_get_interlace_type(png_ptr,
983 info_ptr);
984
985
986These are also important, but their validity depends on whether the chunk
987has been read. The png_get_valid(png_ptr, info_ptr, PNG_INFO_<chunk>) and
988png_get_<chunk>(png_ptr, info_ptr, ...) functions return non-zero if the
989data has been read, or zero if it is missing. The parameters to the
990png_get_<chunk> are set directly if they are simple data types, or a pointer
991into the info_ptr is returned for any complex types.
992
993 png_get_PLTE(png_ptr, info_ptr, &palette,
994 &num_palette);
995 palette - the palette for the file
996 (array of png_color)
997 num_palette - number of entries in the palette
998
999 png_get_gAMA(png_ptr, info_ptr, &gamma);
1000 gamma - the gamma the file is written
1001 at (PNG_INFO_gAMA)
1002
1003 png_get_sRGB(png_ptr, info_ptr, &srgb_intent);
1004 srgb_intent - the rendering intent (PNG_INFO_sRGB)
1005 The presence of the sRGB chunk
1006 means that the pixel data is in the
1007 sRGB color space. This chunk also
1008 implies specific values of gAMA and
1009 cHRM.
1010
1011 png_get_sBIT(png_ptr, info_ptr, &sig_bit);
1012 sig_bit - the number of significant bits for
1013 (PNG_INFO_sBIT) each of the gray,
1014 red, green, and blue channels,
1015 whichever are appropriate for the
1016 given color type (png_color_16)
1017
1018 png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans,
1019 &trans_values);
1020 trans - array of transparent entries for
1021 palette (PNG_INFO_tRNS)
1022 trans_values - transparent pixel for non-paletted
1023 images (PNG_INFO_tRNS)
1024 num_trans - number of transparent entries
1025 (PNG_INFO_tRNS)
1026
1027 png_get_hIST(png_ptr, info_ptr, &hist);
1028 (PNG_INFO_hIST)
1029 hist - histogram of palette (array of
1030 png_color_16)
1031
1032 png_get_tIME(png_ptr, info_ptr, &mod_time);
1033 mod_time - time image was last modified
1034 (PNG_VALID_tIME)
1035
1036 png_get_bKGD(png_ptr, info_ptr, &background);
1037 background - background color (PNG_VALID_bKGD)
1038
1039 num_text = png_get_text(png_ptr, info_ptr, &text_ptr);
1040 text_ptr - array of png_text holding image
1041 comments
1042 text_ptr[i]->key - keyword for comment.
1043 text_ptr[i]->text - text comments for current
1044 keyword.
1045 text_ptr[i]->compression - type of compression used
1046 on "text" PNG_TEXT_COMPRESSION_NONE
1047 or PNG_TEXT_COMPRESSION_zTXt
1048 num_text - number of comments
1049
1050 png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y,
1051 &unit_type);
1052 offset_x - positive offset from the left edge
1053 of the screen
1054 offset_y - positive offset from the top edge
1055 of the screen
1056 unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER
1057
1058 png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y,
1059 &unit_type);
1060 res_x - pixels/unit physical resolution in
1061 x direction
1062 res_y - pixels/unit physical resolution in
1063 x direction
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001064 unit_type - PNG_RESOLUTION_UNKNOWN,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001065 PNG_RESOLUTION_METER
1066
1067The data from the pHYs chunk can be retrieved in several convenient
1068forms:
1069
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001070 res_x = png_get_x_pixels_per_meter(png_ptr,
1071 info_ptr)
1072 res_y = png_get_y_pixels_per_meter(png_ptr,
1073 info_ptr)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001074 res_x_and_y = png_get_pixels_per_meter(png_ptr,
1075 info_ptr)
1076 aspect_ratio = png_get_pixel_aspect_ratio(png_ptr,
1077 info_ptr)
1078
1079 (Each of these returns 0 [signifying "unknown"] if
1080 the data is not present or if res_x is 0;
1081 res_x_and_y is 0 if res_x != res_y)
1082
1083For more information, see the png_info definition in png.h and the
1084PNG specification for chunk contents. Be careful with trusting
1085rowbytes, as some of the transformations could increase the space
1086needed to hold a row (expand, filler, gray_to_rgb, etc.).
1087See png_read_update_info(), below.
1088
1089A quick word about text_ptr and num_text. PNG stores comments in
1090keyword/text pairs, one pair per chunk, with no limit on the number
1091of text chunks, and a 2^31 byte limit on their size. While there are
1092suggested keywords, there is no requirement to restrict the use to these
1093strings. It is strongly suggested that keywords and text be sensible
1094to humans (that's the point), so don't use abbreviations. Non-printing
1095symbols are not allowed. See the PNG specification for more details.
1096There is also no requirement to have text after the keyword.
1097
1098Keywords should be limited to 79 Latin-1 characters without leading or
1099trailing spaces, but non-consecutive spaces are allowed within the
1100keyword. It is possible to have the same keyword any number of times.
1101The text_ptr is an array of png_text structures, each holding pointer
1102to a keyword and a pointer to a text string. Only the text string may
1103be null. The keyword/text pairs are put into the array in the order
1104that they are received. However, some or all of the text chunks may be
1105after the image, so, to make sure you have read all the text chunks,
1106don't mess with these until after you read the stuff after the image.
1107This will be mentioned again below in the discussion that goes with
1108png_read_end().
1109
1110After you've read the header information, you can set up the library
1111to handle any special transformations of the image data. The various
1112ways to transform the data will be described in the order that they
1113should occur. This is important, as some of these change the color
1114type and/or bit depth of the data, and some others only work on
1115certain color types and bit depths. Even though each transformation
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001116checks to see if it has data that it can do something with, you should
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001117make sure to only enable a transformation if it will be valid for the
1118data. For example, don't swap red and blue on grayscale data.
1119
1120The colors used for the background and transparency values should be
1121supplied in the same format/depth as the current image data. They
1122are stored in the same format/depth as the image data in a bKGD or tRNS
1123chunk, so this is what libpng expects for this data. The colors are
1124transformed to keep in sync with the image data when an application
1125calls the png_read_update_info() routine (see below).
1126
1127Data will be decoded into the supplied row buffers packed into bytes
1128unless the library has been told to transform it into another format.
1129For example, 4 bit/pixel paletted or grayscale data will be returned
11302 pixels/byte with the leftmost pixel in the high-order bits of the
1131byte, unless png_set_packing() is called. 8-bit RGB data will be stored
Glenn Randers-Pehrson896239b1998-04-21 15:03:57 -05001132in RGB RGB RGB format unless png_set_filler() is called to insert filler
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001133bytes, either before or after each RGB triplet. 16-bit RGB data will
Glenn Randers-Pehrson896239b1998-04-21 15:03:57 -05001134be returned RRGGBB RRGGBB, with the most significant byte of the color
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001135value first, unless png_set_strip_16() is called to transform it to
Glenn Randers-Pehrson896239b1998-04-21 15:03:57 -05001136regular RGB RGB triplets, or png_set_filler() is called to insert
1137filler bytes, either before or after each RRGGBB triplet. Similarly,
11388-bit or 16-bit grayscale data can be modified with png_set_filler()
1139or png_set_strip_16().
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001140
1141The following code transforms grayscale images of less than 8 to 8 bits,
1142changes paletted images to RGB, and adds a full alpha channel if there is
1143transparency information in a tRNS chunk. This is most useful on
1144grayscale images with bit depths of 2 or 4 or if there is a multiple-image
1145viewing application that wishes to treat all images in the same way.
1146
1147 if (color_type == PNG_COLOR_TYPE_PALETTE &&
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05001148 bit_depth <= 8) png_set_palette_to_rgb(png_ptr);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001149
1150 if (color_type == PNG_COLOR_TYPE_GRAY &&
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05001151 bit_depth < 8) png_set_gray_1_2_4_to_8(png_ptr);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001152
1153 if (png_get_valid(png_ptr, info_ptr,
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05001154 PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr);
1155
1156These three functions are actually aliases for png_set_expand(), added
1157in libpng version 1.0.4, with the function names expanded to improve code
1158readability. In some future version they may actually do different
1159things.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001160
1161PNG can have files with 16 bits per channel. If you only can handle
11628 bits per channel, this will strip the pixels down to 8 bit.
1163
1164 if (bit_depth == 16)
1165 png_set_strip_16(png_ptr);
1166
1167The png_set_background() function tells libpng to composite images
1168with alpha or simple transparency against the supplied background
1169color. If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid),
1170you may use this color, or supply another color more suitable for
1171the current display (e.g., the background color from a web page). You
1172need to tell libpng whether the color is in the gamma space of the
1173display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file
1174(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one
1175that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't
1176know why anyone would use this, but it's here).
1177
1178If, for some reason, you don't need the alpha channel on an image,
1179and you want to remove it rather than combining it with the background
1180(but the image author certainly had in mind that you *would* combine
1181it with the background, so that's what you should probably do):
1182
1183 if (color_type & PNG_COLOR_MASK_ALPHA)
1184 png_set_strip_alpha(png_ptr);
1185
1186PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
1187they can, resulting in, for example, 8 pixels per byte for 1 bit
1188files. This code expands to 1 pixel per byte without changing the
1189values of the pixels:
1190
1191 if (bit_depth < 8)
1192 png_set_packing(png_ptr);
1193
1194PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels
1195stored in a PNG image have been "scaled" or "shifted" up to the next
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001196higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060011978 bits/sample in the range [0, 255]). However, it is also possible to
1198convert the PNG pixel data back to the original bit depth of the image.
1199This call reduces the pixels back down to the original bit depth:
1200
1201 png_color_16p sig_bit;
1202
1203 if (png_get_sBIT(png_ptr, info_ptr, &sig_bit))
1204 png_set_shift(png_ptr, sig_bit);
1205
1206PNG files store 3-color pixels in red, green, blue order. This code
1207changes the storage of the pixels to blue, green, red:
1208
1209 if (color_type == PNG_COLOR_TYPE_RGB ||
1210 color_type == PNG_COLOR_TYPE_RGB_ALPHA)
1211 png_set_bgr(png_ptr);
1212
1213PNG files store RGB pixels packed into 3 bytes. This code expands them
1214into 4 bytes for windowing systems that need them in this format:
1215
1216 if (bit_depth == 8 && color_type ==
1217 PNG_COLOR_TYPE_RGB) png_set_filler(png_ptr,
1218 filler, PNG_FILLER_BEFORE);
1219
Glenn Randers-Pehrson896239b1998-04-21 15:03:57 -05001220where "filler" is the 8 or 16-bit number to fill with, and the location is
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001221either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether
1222you want the filler before the RGB or after. This transformation
1223does not affect images that already have full alpha channels.
1224
1225If you are reading an image with an alpha channel, and you need the
1226data as ARGB instead of the normal PNG format RGBA:
1227
1228 if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
1229 png_set_swap_alpha(png_ptr);
1230
1231For some uses, you may want a grayscale image to be represented as
1232RGB. This code will do that conversion:
1233
1234 if (color_type == PNG_COLOR_TYPE_GRAY ||
1235 color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
1236 png_set_gray_to_rgb(png_ptr);
1237
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001238Conversely, you can convert an RGB or RGBA image to grayscale or grayscale
1239with alpha. This is intended for conversion of images that really are
1240gray (red == green == blue), so the function simply strips out the red
1241and blue channels, leaving the green channel in the gray position.
1242
1243 if (color_type == PNG_COLOR_TYPE_RGB ||
1244 color_type == PNG_COLOR_TYPE_RGB_ALPHA)
1245 png_set_rgb_to_gray(png_ptr, error_action,
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05001246 double red_weight, double green_weight);
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001247
1248 error_action = 1: silently do the conversion
1249 error_action = 2: issue a warning if the original
1250 image has any pixel where
1251 red != green or red != blue
1252 error_action = 3: issue an error and abort the
1253 conversion if the original
1254 image has any pixel where
1255 red != green or red != blue
1256
1257 red_weight: weight of red component
1258 (NULL -> default 54/256)
1259 green_weight: weight of green component
1260 (NULL -> default 183/256)
1261
1262If you have set error_action = 1 or 2, you can
1263later check whether the image really was gray, after processing
1264the image rows, with the png_get_rgb_to_gray_status(png_ptr) function.
1265It will return a png_byte that is zero if the image was gray or
12661 if there were any non-gray pixels. bKGD and sBIT data
1267will be silently converted to grayscale, using the green channel
1268data, regardless of the error_action setting.
1269
1270With 0.0<=red_weight+green_weight<=1.0,
1271the normalized graylevel is computed:
1272
1273 int rw = red_weight * 256;
1274 int gw = green_weight * 256;
1275 int bw = 256 - (rw + gw);
1276 gray = (rw*red + gw*green + bw*blue)/256;
1277
1278The default values approximate those recommended in the Charles
1279Poynton's Color FAQ, <http://www.inforamp.net/~poynton/>
1280Copyright (c) 1998-01-04 Charles Poynton poynton@inforamp.net
1281
1282 Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
1283
1284Libpng approximates this with
1285
1286 Y = 0.211 * R + 0.715 * G + 0.074 * B
1287
1288which can be expressed with integers as
1289
1290 Y = (54 * R + 183 * G + 19 * B)/256
1291
1292The calculation is done in a linear colorspace, if the image gamma
1293is known.
1294
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05001295If you have a grayscale and you are using png_set_expand_depth() or
1296png_set_expand() to change to
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -05001297a higher bit-depth, you must either supply the background color as a gray
1298value at the original file bit-depth (need_expand = 1) or else supply the
1299background color as an RGB triplet at the final, expanded bit depth
1300(need_expand = 0). Similarly, if you are reading a paletted image, you
1301must either supply the background color as a palette index (need_expand = 1)
1302or as an RGB triplet that may or may not be in the palette (need_expand = 0).
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001303
1304 png_color_16 my_background;
1305 png_color_16p image_background;
1306
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -05001307 if (png_get_bKGD(png_ptr, info_ptr, &image_background))
1308 png_set_background(png_ptr, image_background,
1309 PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001310 else
1311 png_set_background(png_ptr, &my_background,
1312 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
1313
1314To properly display PNG images on any kind of system, the application needs
1315to know what the display gamma is. Ideally, the user will know this, and
1316the application will allow them to set it. One method of allowing the user
1317to set the display gamma separately for each system is to check for the
1318DISPLAY_GAMMA and VIEWING_GAMMA environment variables or for a SCREEN_GAMMA
1319environment variable, which will hopefully be correctly set.
1320
1321Note that display_gamma is the gamma of your display, while screen_gamma is
1322the overall gamma correction required to produce pleasing results,
1323which depends on the lighting conditions in the surrounding environment.
1324Screen_gamma is display_gamma/viewing_gamma, where viewing_gamma is
1325the amount of additional gamma correction needed to compensate for
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06001326a (viewing_gamma=1.25) environment. In a dim or brightly lit room, no
1327compensation other than the display_gamma is needed (viewing_gamma=1.0).
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001328
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05001329 double gamma, screen_gamma;
1330
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001331 if (/* We have a user-defined screen
1332 gamma value */)
1333 {
1334 screen_gamma = user_defined_screen_gamma;
1335 }
1336 /* One way that applications can share the same
1337 screen gamma value */
1338 else if ((gamma_str = getenv("SCREEN_GAMMA"))
1339 != NULL)
1340 {
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05001341 screen_gamma = (double)atof(gamma_str);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001342 }
1343 /* If we don't have another value */
1344 else
1345 {
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001346 screen_gamma = 2.2; /* A good guess for a
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001347 PC monitor in a bright office or a dim room */
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001348 screen_gamma = 2.0; /* A good guess for a
1349 PC monitor in a dark room */
1350 screen_gamma = 1.7 or 1.0; /* A good
1351 guess for Mac systems */
1352 }
1353
1354The png_set_gamma() function handles gamma transformations of the data.
1355Pass both the file gamma and the current screen_gamma. If the file does
1356not have a gamma value, you can pass one anyway if you have an idea what
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001357it is (usually 0.45455 is a good guess for GIF images on PCs). Note
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001358that file gammas are inverted from screen gammas. See the discussions
1359on gamma in the PNG specification for an excellent description of what
1360gamma is, and why all applications should support it. It is strongly
1361recommended that PNG viewers support gamma correction.
1362
1363 if (png_get_gAMA(png_ptr, info_ptr, &gamma))
1364 png_set_gamma(png_ptr, screen_gamma, gamma);
1365 else
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001366 png_set_gamma(png_ptr, screen_gamma, 0.45455);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001367
1368If you need to reduce an RGB file to a paletted file, or if a paletted
1369file has more entries then will fit on your screen, png_set_dither()
1370will do that. Note that this is a simple match dither that merely
1371finds the closest color available. This should work fairly well with
1372optimized palettes, and fairly badly with linear color cubes. If you
1373pass a palette that is larger then maximum_colors, the file will
1374reduce the number of colors in the palette so it will fit into
1375maximum_colors. If there is a histogram, it will use it to make
1376more intelligent choices when reducing the palette. If there is no
1377histogram, it may not do as good a job.
1378
1379 if (color_type & PNG_COLOR_MASK_COLOR)
1380 {
1381 if (png_get_valid(png_ptr, info_ptr,
1382 PNG_INFO_PLTE))
1383 {
1384 png_color_16p histogram;
1385
1386 png_get_hIST(png_ptr, info_ptr,
1387 &histogram);
1388 png_set_dither(png_ptr, palette, num_palette,
1389 max_screen_colors, histogram, 1);
1390 }
1391 else
1392 {
1393 png_color std_color_cube[MAX_SCREEN_COLORS] =
1394 { ... colors ... };
1395
1396 png_set_dither(png_ptr, std_color_cube,
1397 MAX_SCREEN_COLORS, MAX_SCREEN_COLORS,
1398 NULL,0);
1399 }
1400 }
1401
1402PNG files describe monochrome as black being zero and white being one.
1403The following code will reverse this (make black be one and white be
1404zero):
1405
1406 if (bit_depth == 1 && color_type == PNG_COLOR_GRAY)
1407 png_set_invert_mono(png_ptr);
1408
1409PNG files store 16 bit pixels in network byte order (big-endian,
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001410ie. most significant bits first). This code changes the storage to the
1411other way (little-endian, i.e. least significant bits first, the
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001412way PCs store them):
1413
1414 if (bit_depth == 16)
1415 png_set_swap(png_ptr);
1416
1417If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you
1418need to change the order the pixels are packed into bytes, you can use:
1419
1420 if (bit_depth < 8)
1421 png_set_packswap(png_ptr);
1422
1423The last thing to handle is interlacing; this is covered in detail below,
1424but you must call the function here if you want libpng to handle expansion
1425of the interlaced image.
1426
1427 number_of_passes = png_set_interlace_handling(png_ptr);
1428
1429After setting the transformations, libpng can update your png_info
1430structure to reflect any transformations you've requested with this
1431call. This is most useful to update the info structure's rowbytes
1432field so you can use it to allocate your image memory. This function
1433will also update your palette with the correct screen_gamma and
1434background if these have been given with the calls above.
1435
1436 png_read_update_info(png_ptr, info_ptr);
1437
1438After you call png_read_update_info(), you can allocate any
1439memory you need to hold the image. The row data is simply
1440raw byte data for all forms of images. As the actual allocation
1441varies among applications, no example will be given. If you
1442are allocating one large chunk, you will need to build an
1443array of pointers to each row, as it will be needed for some
1444of the functions below.
1445
1446After you've allocated memory, you can read the image data.
1447The simplest way to do this is in one function call. If you are
1448allocating enough memory to hold the whole image, you can just
1449call png_read_image() and libpng will read in all the image data
1450and put it in the memory area supplied. You will need to pass in
1451an array of pointers to each row.
1452
1453This function automatically handles interlacing, so you don't need
1454to call png_set_interlace_handling() or call this function multiple
1455times, or any of that other stuff necessary with png_read_rows().
1456
1457 png_read_image(png_ptr, row_pointers);
1458
1459where row_pointers is:
1460
1461 png_bytep row_pointers[height];
1462
1463You can point to void or char or whatever you use for pixels.
1464
1465If you don't want to read in the whole image at once, you can
1466use png_read_rows() instead. If there is no interlacing (check
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001467interlace_type == PNG_INTERLACE_NONE), this is simple:
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001468
1469 png_read_rows(png_ptr, row_pointers, NULL,
1470 number_of_rows);
1471
1472where row_pointers is the same as in the png_read_image() call.
1473
1474If you are doing this just one row at a time, you can do this with
1475row_pointers:
1476
1477 png_bytep row_pointers = row;
1478 png_read_row(png_ptr, &row_pointers, NULL);
1479
1480If the file is interlaced (info_ptr->interlace_type != 0), things get
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05001481somewhat harder. The only current (PNG Specification version 1.2)
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001482interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001483is a somewhat complicated 2D interlace scheme, known as Adam7, that
1484breaks down an image into seven smaller images of varying size, based
1485on an 8x8 grid.
1486
1487libpng can fill out those images or it can give them to you "as is".
1488If you want them filled out, there are two ways to do that. The one
1489mentioned in the PNG specification is to expand each pixel to cover
1490those pixels that have not been read yet (the "rectangle" method).
1491This results in a blocky image for the first pass, which gradually
1492smooths out as more pixels are read. The other method is the "sparkle"
1493method, where pixels are drawn only in their final locations, with the
1494rest of the image remaining whatever colors they were initialized to
1495before the start of the read. The first method usually looks better,
1496but tends to be slower, as there are more pixels to put in the rows.
1497
1498If you don't want libpng to handle the interlacing details, just call
1499png_read_rows() seven times to read in all seven images. Each of the
1500images is a valid image by itself, or they can all be combined on an
15018x8 grid to form a single image (although if you intend to combine them
1502you would be far better off using the libpng interlace handling).
1503
1504The first pass will return an image 1/8 as wide as the entire image
1505(every 8th column starting in column 0) and 1/8 as high as the original
1506(every 8th row starting in row 0), the second will be 1/8 as wide
1507(starting in column 4) and 1/8 as high (also starting in row 0). The
1508third pass will be 1/4 as wide (every 4th pixel starting in column 0) and
15091/8 as high (every 8th row starting in row 4), and the fourth pass will
1510be 1/4 as wide and 1/4 as high (every 4th column starting in column 2,
1511and every 4th row starting in row 0). The fifth pass will return an
1512image 1/2 as wide, and 1/4 as high (starting at column 0 and row 2),
1513while the sixth pass will be 1/2 as wide and 1/2 as high as the original
1514(starting in column 1 and row 0). The seventh and final pass will be as
1515wide as the original, and 1/2 as high, containing all of the odd
1516numbered scanlines. Phew!
1517
1518If you want libpng to expand the images, call this before calling
1519png_start_read_image() or png_read_update_info():
1520
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001521 if (interlace_type == PNG_INTERLACE_ADAM7)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001522 number_of_passes
1523 = png_set_interlace_handling(png_ptr);
1524
1525This will return the number of passes needed. Currently, this
1526is seven, but may change if another interlace type is added.
1527This function can be called even if the file is not interlaced,
1528where it will return one pass.
1529
1530If you are not going to display the image after each pass, but are
1531going to wait until the entire image is read in, use the sparkle
1532effect. This effect is faster and the end result of either method
1533is exactly the same. If you are planning on displaying the image
1534after each pass, the "rectangle" effect is generally considered the
1535better looking one.
1536
1537If you only want the "sparkle" effect, just call png_read_rows() as
1538normal, with the third parameter NULL. Make sure you make pass over
1539the image number_of_passes times, and you don't change the data in the
1540rows between calls. You can change the locations of the data, just
1541not the data. Each pass only writes the pixels appropriate for that
1542pass, and assumes the data from previous passes is still valid.
1543
1544 png_read_rows(png_ptr, row_pointers, NULL,
1545 number_of_rows);
1546
1547If you only want the first effect (the rectangles), do the same as
1548before except pass the row buffer in the third parameter, and leave
1549the second parameter NULL.
1550
1551 png_read_rows(png_ptr, NULL, row_pointers,
1552 number_of_rows);
1553
1554After you are finished reading the image, you can finish reading
1555the file. If you are interested in comments or time, which may be
1556stored either before or after the image data, you should pass the
1557separate png_info struct if you want to keep the comments from
1558before and after the image separate. If you are not interested, you
1559can pass NULL.
1560
1561 png_read_end(png_ptr, end_info);
1562
1563When you are done, you can free all memory allocated by libpng like this:
1564
1565 png_destroy_read_struct(&png_ptr, &info_ptr,
1566 &end_info);
1567
1568For a more compact example of reading a PNG image, see the file example.c.
1569
1570
1571Reading PNG files progressively:
1572
1573The progressive reader is slightly different then the non-progressive
1574reader. Instead of calling png_read_info(), png_read_rows(), and
1575png_read_end(), you make one call to png_process_data(), which calls
1576callbacks when it has the info, a row, or the end of the image. You
1577set up these callbacks with png_set_progressive_read_fn(). You don't
1578have to worry about the input/output functions of libpng, as you are
1579giving the library the data directly in png_process_data(). I will
1580assume that you have read the section on reading PNG files above,
1581so I will only highlight the differences (although I will show
1582all of the code).
1583
1584png_structp png_ptr;
1585png_infop info_ptr;
1586
1587 /* An example code fragment of how you would
1588 initialize the progressive reader in your
1589 application. */
1590 int
1591 initialize_png_reader()
1592 {
1593 png_ptr = png_create_read_struct
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -05001594 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001595 user_error_fn, user_warning_fn);
1596 if (!png_ptr)
1597 return -1;
1598 info_ptr = png_create_info_struct(png_ptr);
1599 if (!info_ptr)
1600 {
1601 png_destroy_read_struct(&png_ptr, (png_infopp)NULL,
1602 (png_infopp)NULL);
1603 return -1;
1604 }
1605
1606 if (setjmp(png_ptr->jmpbuf))
1607 {
1608 png_destroy_read_struct(&png_ptr, &info_ptr,
1609 (png_infopp)NULL);
1610 return -1;
1611 }
1612
1613 /* This one's new. You can provide functions
1614 to be called when the header info is valid,
1615 when each row is completed, and when the image
1616 is finished. If you aren't using all functions,
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001617 you can specify NULL parameters. Even when all
1618 three functions are NULL, you need to call
1619 png_set_progressive_read_fn(). You can use
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001620 any struct as the user_ptr (cast to a void pointer
1621 for the function call), and retrieve the pointer
1622 from inside the callbacks using the function
1623
1624 png_get_progressive_ptr(png_ptr);
1625
1626 which will return a void pointer, which you have
1627 to cast appropriately.
1628 */
1629 png_set_progressive_read_fn(png_ptr, (void *)user_ptr,
1630 info_callback, row_callback, end_callback);
1631
1632 return 0;
1633 }
1634
1635 /* A code fragment that you call as you receive blocks
1636 of data */
1637 int
1638 process_data(png_bytep buffer, png_uint_32 length)
1639 {
1640 if (setjmp(png_ptr->jmpbuf))
1641 {
1642 png_destroy_read_struct(&png_ptr, &info_ptr,
1643 (png_infopp)NULL);
1644 return -1;
1645 }
1646
1647 /* This one's new also. Simply give it a chunk
1648 of data from the file stream (in order, of
1649 course). On machines with segmented memory
1650 models machines, don't give it any more than
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001651 64K. The library seems to run fine with sizes
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001652 of 4K. Although you can give it much less if
1653 necessary (I assume you can give it chunks of
1654 1 byte, I haven't tried less then 256 bytes
1655 yet). When this function returns, you may
1656 want to display any rows that were generated
1657 in the row callback if you don't already do
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001658 so there.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001659 */
1660 png_process_data(png_ptr, info_ptr, buffer, length);
1661 return 0;
1662 }
1663
1664 /* This function is called (as set by
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001665 png_set_progressive_read_fn() above) when enough data
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001666 has been supplied so all of the header has been
1667 read.
1668 */
1669 void
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06001670 info_callback(png_structp png_ptr, png_infop info)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001671 {
1672 /* Do any setup here, including setting any of
1673 the transformations mentioned in the Reading
1674 PNG files section. For now, you _must_ call
1675 either png_start_read_image() or
1676 png_read_update_info() after all the
1677 transformations are set (even if you don't set
1678 any). You may start getting rows before
1679 png_process_data() returns, so this is your
1680 last chance to prepare for that.
1681 */
1682 }
1683
1684 /* This function is called when each row of image
1685 data is complete */
1686 void
1687 row_callback(png_structp png_ptr, png_bytep new_row,
1688 png_uint_32 row_num, int pass)
1689 {
1690 /* If the image is interlaced, and you turned
1691 on the interlace handler, this function will
1692 be called for every row in every pass. Some
1693 of these rows will not be changed from the
1694 previous pass. When the row is not changed,
1695 the new_row variable will be NULL. The rows
1696 and passes are called in order, so you don't
1697 really need the row_num and pass, but I'm
1698 supplying them because it may make your life
1699 easier.
1700
1701 For the non-NULL rows of interlaced images,
1702 you must call png_progressive_combine_row()
1703 passing in the row and the old row. You can
1704 call this function for NULL rows (it will just
1705 return) and for non-interlaced images (it just
1706 does the memcpy for you) if it will make the
1707 code easier. Thus, you can just do this for
1708 all cases:
1709 */
1710
1711 png_progressive_combine_row(png_ptr, old_row,
1712 new_row);
1713
1714 /* where old_row is what was displayed for
Glenn Randers-Pehrson345bc271998-06-14 14:43:31 -05001715 previously for the row. Note that the first
1716 pass (pass == 0, really) will completely cover
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001717 the old row, so the rows do not have to be
1718 initialized. After the first pass (and only
1719 for interlaced images), you will have to pass
1720 the current row, and the function will combine
1721 the old row and the new row.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001722 */
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001723 }
1724
1725 void
1726 end_callback(png_structp png_ptr, png_infop info)
1727 {
1728 /* This function is called after the whole image
1729 has been read, including any chunks after the
1730 image (up to and including the IEND). You
1731 will usually have the same info chunk as you
1732 had in the header, although some data may have
1733 been added to the comments and time fields.
1734
1735 Most people won't do much here, perhaps setting
1736 a flag that marks the image as finished.
1737 */
1738 }
1739
Glenn Randers-Pehrson896239b1998-04-21 15:03:57 -05001740
1741
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001742.SH IV. Writing
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001743
1744Much of this is very similar to reading. However, everything of
1745importance is repeated here, so you won't have to constantly look
1746back up in the reading section to understand writing.
1747
1748You will want to do the I/O initialization before you get into libpng,
1749so if it doesn't work, you don't have anything to undo. If you are not
1750using the standard I/O functions, you will need to replace them with
1751custom writing functions. See the discussion under Customizing libpng.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001752
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001753 FILE *fp = fopen(file_name, "wb");
1754 if (!fp)
1755 {
1756 return;
1757 }
1758
1759Next, png_struct and png_info need to be allocated and initialized.
1760As these can be both relatively large, you may not want to store these
1761on the stack, unless you have stack space to spare. Of course, you
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06001762will want to check if they return NULL. If you are also reading,
1763you won't want to name your read structure and your write structure
1764both "png_ptr"; you can call them anything you like, such as
1765"read_ptr" and "write_ptr". Look at pngtest.c, for example.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001766
1767 png_structp png_ptr = png_create_write_struct
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -05001768 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001769 user_error_fn, user_warning_fn);
1770 if (!png_ptr)
1771 return;
1772
1773 png_infop info_ptr = png_create_info_struct(png_ptr);
1774 if (!info_ptr)
1775 {
1776 png_destroy_write_struct(&png_ptr,
1777 (png_infopp)NULL);
1778 return;
1779 }
1780
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -05001781If you want to use your own memory allocation routines,
1782define PNG_USER_MEM_SUPPORTED and use
1783png_create_write_struct_2() instead of png_create_read_struct():
1784
1785 png_structp png_ptr = png_create_write_struct_2
1786 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
1787 user_error_fn, user_warning_fn, (png_voidp)
1788 user_mem_ptr, user_malloc_fn, user_free_fn);
1789
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001790After you have these structures, you will need to set up the
1791error handling. When libpng encounters an error, it expects to
1792longjmp() back to your routine. Therefore, you will need to call
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001793setjmp() and pass the png_ptr->jmpbuf. If you
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001794write the file from different routines, you will need to update
1795the jmpbuf field every time you enter a new routine that will
1796call a png_ function. See your documentation of setjmp/longjmp
1797for your compiler for more information on setjmp/longjmp. See
1798the discussion on libpng error handling in the Customizing Libpng
1799section below for more information on the libpng error handling.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001800
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001801 if (setjmp(png_ptr->jmpbuf))
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001802 {
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001803 png_destroy_write_struct(&png_ptr, &info_ptr);
1804 fclose(fp);
1805 return;
1806 }
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001807 ...
1808 return;
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001809
1810Now you need to set up the output code. The default for libpng is to
1811use the C function fwrite(). If you use this, you will need to pass a
1812valid FILE * in the function png_init_io(). Be sure that the file is
1813opened in binary mode. Again, if you wish to handle writing data in
1814another way, see the discussion on libpng I/O handling in the Customizing
1815Libpng section below.
1816
1817 png_init_io(png_ptr, fp);
1818
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06001819At this point, you can set up a callback function that will be
1820called after each row has been written, which you can use to control
1821a progress meter or the like. It's demonstrated in pngtest.c.
1822You must supply a function
1823
1824 void write_row_callback(png_ptr, png_uint_32 row, int pass);
1825 {
1826 /* put your code here */
1827 }
1828
1829(You can give it another name that you like instead of "write_row_callback")
1830
1831To inform libpng about your function, use
1832
1833 png_set_write_status_fn(png_ptr, write_row_callback);
1834
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001835You now have the option of modifying how the compression library will
1836run. The following functions are mainly for testing, but may be useful
1837in some cases, like if you need to write PNG files extremely fast and
1838are willing to give up some compression, or if you want to get the
1839maximum possible compression at the expense of slower writing. If you
1840have no special needs in this area, let the library do what it wants by
1841not calling this function at all, as it has been tuned to deliver a good
1842speed/compression ratio. The second parameter to png_set_filter() is
1843the filter method, for which the only valid value is '0' (as of the
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05001844July 1999 PNG specification, version 1.2). The third parameter is a
Glenn Randers-Pehrson896239b1998-04-21 15:03:57 -05001845flag that indicates which filter type(s) are to be tested for each
1846scanline. See the Compression Library for details on the specific filter
1847types.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001848
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001849
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001850 /* turn on or off filtering, and/or choose
1851 specific filters */
1852 png_set_filter(png_ptr, 0,
1853 PNG_FILTER_NONE | PNG_FILTER_SUB |
1854 PNG_FILTER_PAETH);
1855
1856The png_set_compression_???() functions interface to the zlib compression
1857library, and should mostly be ignored unless you really know what you are
1858doing. The only generally useful call is png_set_compression_level()
1859which changes how much time zlib spends on trying to compress the image
1860data. See the Compression Library for details on the compression levels.
1861
1862 /* set the zlib compression level */
1863 png_set_compression_level(png_ptr,
1864 Z_BEST_COMPRESSION);
1865
1866 /* set other zlib parameters */
1867 png_set_compression_mem_level(png_ptr, 8);
1868 png_set_compression_strategy(png_ptr,
1869 Z_DEFAULT_STRATEGY);
1870 png_set_compression_window_bits(png_ptr, 15);
1871 png_set_compression_method(png_ptr, 8);
1872
1873You now need to fill in the png_info structure with all the data you
1874wish to write before the actual image. Note that the only thing you
1875are allowed to write after the image is the text chunks and the time
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05001876chunk (as of PNG Specification 1.2, anyway). See png_write_end() and
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001877the latest PNG specification for more information on that. If you
1878wish to write them before the image, fill them in now, and flag that
1879data as being valid. If you want to wait until after the data, don't
1880fill them until png_write_end(). For all the fields in png_info and
1881their data types, see png.h. For explanations of what the fields
1882contain, see the PNG specification.
1883
1884Some of the more important parts of the png_info are:
1885
1886 png_set_IHDR(png_ptr, info_ptr, width, height,
1887 bit_depth, color_type, interlace_type,
1888 compression_type, filter_type)
1889 width - holds the width of the image
1890 in pixels (up to 2^31).
1891 height - holds the height of the image
1892 in pixels (up to 2^31).
1893 bit_depth - holds the bit depth of one of the
1894 image channels.
1895 (valid values are 1, 2, 4, 8, 16
1896 and depend also on the
1897 color_type. See also significant
1898 bits (sBIT) below).
1899 color_type - describes which color/alpha
1900 channels are present.
1901 PNG_COLOR_TYPE_GRAY
1902 (bit depths 1, 2, 4, 8, 16)
1903 PNG_COLOR_TYPE_GRAY_ALPHA
1904 (bit depths 8, 16)
1905 PNG_COLOR_TYPE_PALETTE
1906 (bit depths 1, 2, 4, 8)
1907 PNG_COLOR_TYPE_RGB
1908 (bit_depths 8, 16)
1909 PNG_COLOR_TYPE_RGB_ALPHA
1910 (bit_depths 8, 16)
1911
1912 PNG_COLOR_MASK_PALETTE
1913 PNG_COLOR_MASK_COLOR
1914 PNG_COLOR_MASK_ALPHA
1915
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06001916 interlace_type - PNG_INTERLACE_NONE or
1917 PNG_INTERLACE_ADAM7
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001918 compression_type - (must be
1919 PNG_COMPRESSION_TYPE_DEFAULT)
1920 filter_type - (must be PNG_FILTER_TYPE_DEFAULT)
1921
1922 png_set_PLTE(png_ptr, info_ptr, palette,
1923 num_palette);
1924 palette - the palette for the file
1925 (array of png_color)
1926 num_palette - number of entries in the palette
1927
1928 png_set_gAMA(png_ptr, info_ptr, gamma);
1929 gamma - the gamma the image was created
1930 at (PNG_INFO_gAMA)
1931
1932 png_set_sRGB(png_ptr, info_ptr, srgb_intent);
1933 srgb_intent - the rendering intent
1934 (PNG_INFO_sRGB) The presence of
1935 the sRGB chunk means that the pixel
1936 data is in the sRGB color space.
1937 This chunk also implies specific
1938 values of gAMA and cHRM. Rendering
1939 intent is the CSS-1 property that
1940 has been defined by the International
1941 Color Consortium
1942 (http://www.color.org).
1943 It can be one of
1944 PNG_SRGB_INTENT_SATURATION,
1945 PNG_SRGB_INTENT_PERCEPTUAL,
1946 PNG_SRGB_INTENT_ABSOLUTE, or
1947 PNG_SRGB_INTENT_RELATIVE.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001948
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001949
1950 png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr,
1951 srgb_intent);
1952 srgb_intent - the rendering intent
1953 (PNG_INFO_sRGB) The presence of the
1954 sRGB chunk means that the pixel
1955 data is in the sRGB color space.
1956 This function also causes gAMA and
1957 cHRM chunks with the specific values
1958 that are consistent with sRGB to be
1959 written.
1960
1961 png_set_sBIT(png_ptr, info_ptr, sig_bit);
1962 sig_bit - the number of significant bits for
1963 (PNG_INFO_sBIT) each of the gray, red,
1964 green, and blue channels, whichever are
1965 appropriate for the given color type
1966 (png_color_16)
1967
1968 png_set_tRNS(png_ptr, info_ptr, trans, num_trans,
1969 trans_values);
1970 trans - array of transparent entries for
1971 palette (PNG_INFO_tRNS)
1972 trans_values - transparent pixel for non-paletted
1973 images (PNG_INFO_tRNS)
1974 num_trans - number of transparent entries
1975 (PNG_INFO_tRNS)
1976
1977 png_set_hIST(png_ptr, info_ptr, hist);
1978 (PNG_INFO_hIST)
1979 hist - histogram of palette (array of
1980 png_color_16)
1981
1982 png_set_tIME(png_ptr, info_ptr, mod_time);
1983 mod_time - time image was last modified
1984 (PNG_VALID_tIME)
1985
1986 png_set_bKGD(png_ptr, info_ptr, background);
1987 background - background color (PNG_VALID_bKGD)
1988
1989 png_set_text(png_ptr, info_ptr, text_ptr, num_text);
1990 text_ptr - array of png_text holding image
1991 comments
1992 text_ptr[i]->key - keyword for comment.
1993 text_ptr[i]->text - text comments for current
1994 keyword.
1995 text_ptr[i]->compression - type of compression used
1996 on "text" PNG_TEXT_COMPRESSION_NONE or
1997 PNG_TEXT_COMPRESSION_zTXt
1998 num_text - number of comments in text_ptr
1999
2000 png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y,
2001 unit_type);
2002 offset_x - positive offset from the left
2003 edge of the screen
2004 offset_y - positive offset from the top
2005 edge of the screen
2006 unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER
2007
2008 png_set_pHYs(png_ptr, info_ptr, res_x, res_y,
2009 unit_type);
2010 res_x - pixels/unit physical resolution
2011 in x direction
2012 res_y - pixels/unit physical resolution
2013 in y direction
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002014 unit_type - PNG_RESOLUTION_UNKNOWN,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002015 PNG_RESOLUTION_METER
2016
2017In PNG files, the alpha channel in an image is the level of opacity.
2018If your data is supplied as a level of transparency, you can invert the
2019alpha channel before you write it, so that 0 is fully transparent and 255
2020(in 8-bit or paletted images) or 65535 (in 16-bit images) is fully opaque,
2021with
2022
2023 png_set_invert_alpha(png_ptr);
2024
2025This must appear here instead of later with the other transformations
2026because in the case of paletted images the tRNS chunk data has to
2027be inverted before the tRNS chunk is written. If your image is not a
2028paletted image, the tRNS data (which in such cases represents a single
2029color to be rendered as transparent) won't be changed.
2030
2031A quick word about text and num_text. text is an array of png_text
2032structures. num_text is the number of valid structures in the array.
2033If you want, you can use max_text to hold the size of the array, but
2034libpng ignores it for writing (it does use it for reading). Each
2035png_text structure holds a keyword-text value, and a compression type.
2036The compression types have the same valid numbers as the compression
2037types of the image data. Currently, the only valid number is zero.
2038However, you can store text either compressed or uncompressed, unlike
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002039images, which always have to be compressed. So if you don't want the
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002040text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE.
2041Until text gets around 1000 bytes, it is not worth compressing it.
2042After the text has been written out to the file, the compression type
2043is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR,
2044so that it isn't written out again at the end (in case you are calling
2045png_write_end() with the same struct.
2046
2047The keywords that are given in the PNG Specification are:
2048
2049 Title Short (one line) title or
2050 caption for image
2051 Author Name of image's creator
2052 Description Description of image (possibly long)
2053 Copyright Copyright notice
2054 Creation Time Time of original image creation
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002055 (usually RFC 1123 format, see below)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002056 Software Software used to create the image
2057 Disclaimer Legal disclaimer
2058 Warning Warning of nature of content
2059 Source Device used to create the image
2060 Comment Miscellaneous comment; conversion
2061 from other image format
2062
2063The keyword-text pairs work like this. Keywords should be short
2064simple descriptions of what the comment is about. Some typical
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002065keywords are found in the PNG specification, as is some recommendations
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002066on keywords. You can repeat keywords in a file. You can even write
2067some text before the image and some after. For example, you may want
2068to put a description of the image before the image, but leave the
2069disclaimer until after, so viewers working over modem connections
2070don't have to wait for the disclaimer to go over the modem before
2071they start seeing the image. Finally, keywords should be full
2072words, not abbreviations. Keywords and text are in the ISO 8859-1
2073(Latin-1) character set (a superset of regular ASCII) and can not
2074contain NUL characters, and should not contain control or other
2075unprintable characters. To make the comments widely readable, stick
2076with basic ASCII, and avoid machine specific character set extensions
2077like the IBM-PC character set. The keyword must be present, but
2078you can leave off the text string on non-compressed pairs.
2079Compressed pairs must have a text string, as only the text string
2080is compressed anyway, so the compression would be meaningless.
2081
2082PNG supports modification time via the png_time structure. Two
2083conversion routines are proved, png_convert_from_time_t() for
2084time_t and png_convert_from_struct_tm() for struct tm. The
2085time_t routine uses gmtime(). You don't have to use either of
2086these, but if you wish to fill in the png_time structure directly,
2087you should provide the time in universal time (GMT) if possible
2088instead of your local time. Note that the year number is the full
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002089year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002090that months start with 1.
2091
2092If you want to store the time of the original image creation, you should
2093use a plain tEXt chunk with the "Creation Time" keyword. This is
2094necessary because the "creation time" of a PNG image is somewhat vague,
2095depending on whether you mean the PNG file, the time the image was
2096created in a non-PNG format, a still photo from which the image was
2097scanned, or possibly the subject matter itself. In order to facilitate
2098machine-readable dates, it is recommended that the "Creation Time"
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002099tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"),
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002100although this isn't a requirement. Unlike the tIME chunk, the
2101"Creation Time" tEXt chunk is not expected to be automatically changed
2102by the software. To facilitate the use of RFC 1123 dates, a function
2103png_convert_to_rfc1123(png_timep) is provided to convert from PNG
2104time to an RFC 1123 format string.
2105
2106You are now ready to write all the file information up to the actual
2107image data. You do this with a call to png_write_info().
2108
2109 png_write_info(png_ptr, info_ptr);
2110
2111After you've written the file information, you can set up the library
2112to handle any special transformations of the image data. The various
2113ways to transform the data will be described in the order that they
2114should occur. This is important, as some of these change the color
2115type and/or bit depth of the data, and some others only work on
2116certain color types and bit depths. Even though each transformation
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002117checks to see if it has data that it can do something with, you should
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002118make sure to only enable a transformation if it will be valid for the
2119data. For example, don't swap red and blue on grayscale data.
2120
Glenn Randers-Pehrson896239b1998-04-21 15:03:57 -05002121PNG files store RGB pixels packed into 3 or 6 bytes. This code tells
2122the library to expand the input data to 4 or 8 bytes per pixel
2123(or expand 1 or 2-byte grayscale data to 2 or 4 bytes per pixel).
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002124
2125 png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
2126
2127where the 0 is the value that will be put in the 4th byte, and the
2128location is either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending
2129upon whether the filler byte is stored XRGB or RGBX.
2130
2131PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
2132they can, resulting in, for example, 8 pixels per byte for 1 bit files.
2133If the data is supplied at 1 pixel per byte, use this code, which will
2134correctly pack the pixels into a single byte:
2135
2136 png_set_packing(png_ptr);
2137
2138PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your
2139data is of another bit depth, you can write an sBIT chunk into the
2140file so that decoders can get the original data if desired.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002141
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002142 /* Set the true bit depth of the image data */
2143 if (color_type & PNG_COLOR_MASK_COLOR)
2144 {
2145 sig_bit.red = true_bit_depth;
2146 sig_bit.green = true_bit_depth;
2147 sig_bit.blue = true_bit_depth;
2148 }
2149 else
2150 {
2151 sig_bit.gray = true_bit_depth;
2152 }
2153 if (color_type & PNG_COLOR_MASK_ALPHA)
2154 {
2155 sig_bit.alpha = true_bit_depth;
2156 }
2157
2158 png_set_sBIT(png_ptr, info_ptr, &sig_bit);
2159
2160If the data is stored in the row buffer in a bit depth other than
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002161one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG),
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002162this will scale the values to appear to be the correct bit depth as
2163is required by PNG.
2164
2165 png_set_shift(png_ptr, &sig_bit);
2166
2167PNG files store 16 bit pixels in network byte order (big-endian,
2168ie. most significant bits first). This code would be used if they are
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002169supplied the other way (little-endian, i.e. least significant bits
2170first, the way PCs store them):
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002171
2172 if (bit_depth > 8)
2173 png_set_swap(png_ptr);
2174
2175If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you
2176need to change the order the pixels are packed into bytes, you can use:
2177
2178 if (bit_depth < 8)
2179 png_set_packswap(png_ptr);
2180
2181PNG files store 3 color pixels in red, green, blue order. This code
2182would be used if they are supplied as blue, green, red:
2183
2184 png_set_bgr(png_ptr);
2185
2186PNG files describe monochrome as black being zero and white being
2187one. This code would be used if the pixels are supplied with this reversed
2188(black being one and white being zero):
2189
2190 png_set_invert_mono(png_ptr);
2191
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06002192Finally, you can write your own transformation function if none of
2193the existing ones meets your needs. This is done by setting a callback
2194with
2195
2196 png_set_write_user_transform_fn(png_ptr,
2197 write_transform_fn);
2198
2199You must supply the function
2200
2201 void write_transform_fn(png_ptr ptr, row_info_ptr
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002202 row_info, png_bytep data)
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06002203
2204See pngtest.c for a working example. Your function will be called
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05002205before any of the other transformations are processed.
2206
2207You can also set up a pointer to a user structure for use by your
2208callback function.
2209
2210 png_set_user_transform_info(png_ptr, user_ptr, 0, 0);
2211
2212The user_channels and user_depth parameters of this function are ignored
2213when writing; you can set them to zero as shown.
2214
2215You can retrieve the pointer via the function
2216png_get_user_transform_ptr(). For example:
2217
2218 voidp write_user_transform_ptr =
2219 png_get_user_transform_ptr(png_ptr);
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06002220
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002221It is possible to have libpng flush any pending output, either manually,
2222or automatically after a certain number of lines have been written. To
2223flush the output stream a single time call:
2224
2225 png_write_flush(png_ptr);
2226
2227and to have libpng flush the output stream periodically after a certain
2228number of scanlines have been written, call:
2229
2230 png_set_flush(png_ptr, nrows);
2231
2232Note that the distance between rows is from the last time png_write_flush()
2233was called, or the first row of the image if it has never been called.
2234So if you write 50 lines, and then png_set_flush 25, it will flush the
2235output on the next scanline, and every 25 lines thereafter, unless
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002236png_write_flush() is called before 25 more lines have been written.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002237If nrows is too small (less than about 10 lines for a 640 pixel wide
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002238RGB image) the image compression may decrease noticeably (although this
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002239may be acceptable for real-time applications). Infrequent flushing will
2240only degrade the compression performance by a few percent over images
2241that do not use flushing.
2242
2243That's it for the transformations. Now you can write the image data.
2244The simplest way to do this is in one function call. If have the
2245whole image in memory, you can just call png_write_image() and libpng
2246will write the image. You will need to pass in an array of pointers to
2247each row. This function automatically handles interlacing, so you don't
2248need to call png_set_interlace_handling() or call this function multiple
2249times, or any of that other stuff necessary with png_write_rows().
2250
2251 png_write_image(png_ptr, row_pointers);
2252
2253where row_pointers is:
2254
Glenn Randers-Pehrson896239b1998-04-21 15:03:57 -05002255 png_byte *row_pointers[height];
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002256
2257You can point to void or char or whatever you use for pixels.
2258
Glenn Randers-Pehrson896239b1998-04-21 15:03:57 -05002259If you don't want to write the whole image at once, you can
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002260use png_write_rows() instead. If the file is not interlaced,
2261this is simple:
2262
2263 png_write_rows(png_ptr, row_pointers,
2264 number_of_rows);
2265
2266row_pointers is the same as in the png_write_image() call.
2267
2268If you are just writing one row at a time, you can do this with
2269row_pointers:
2270
2271 png_bytep row_pointer = row;
2272
2273 png_write_row(png_ptr, &row_pointer);
2274
2275When the file is interlaced, things can get a good deal more
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05002276complicated. The only currently (as of August 1999 -- PNG Specification
2277version 1.2, dated July 1999) defined interlacing scheme for PNG files
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002278is the "Adam7" interlace scheme, that breaks down an
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002279image into seven smaller images of varying size. libpng will build
2280these images for you, or you can do them yourself. If you want to
2281build them yourself, see the PNG specification for details of which
2282pixels to write when.
2283
2284If you don't want libpng to handle the interlacing details, just
2285use png_set_interlace_handling() and call png_write_rows() the
2286correct number of times to write all seven sub-images.
2287
2288If you want libpng to build the sub-images, call this before you start
2289writing any rows:
2290
2291 number_of_passes =
2292 png_set_interlace_handling(png_ptr);
2293
2294This will return the number of passes needed. Currently, this
2295is seven, but may change if another interlace type is added.
2296
2297Then write the complete image number_of_passes times.
2298
2299 png_write_rows(png_ptr, row_pointers,
2300 number_of_rows);
2301
2302As some of these rows are not used, and thus return immediately,
2303you may want to read about interlacing in the PNG specification,
2304and only update the rows that are actually used.
2305
2306After you are finished writing the image, you should finish writing
2307the file. If you are interested in writing comments or time, you should
2308pass an appropriately filled png_info pointer. If you are not interested,
2309you can pass NULL.
2310
2311 png_write_end(png_ptr, info_ptr);
2312
2313When you are done, you can free all memory used by libpng like this:
2314
2315 png_destroy_write_struct(&png_ptr, &info_ptr);
2316
2317You must free any data you allocated for info_ptr, such as comments,
2318palette, or histogram, before the call to png_destroy_write_struct();
2319
2320For a more compact example of writing a PNG image, see the file example.c.
2321
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002322.SH V. Modifying/Customizing libpng:
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002323
2324There are two issues here. The first is changing how libpng does
2325standard things like memory allocation, input/output, and error handling.
2326The second deals with more complicated things like adding new chunks,
2327adding new transformations, and generally changing how libpng works.
2328
2329All of the memory allocation, input/output, and error handling in libpng
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002330goes through callbacks that are user settable. The default routines are
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002331in pngmem.c, pngrio.c, pngwio.c, and pngerror.c respectively. To change
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002332these functions, call the appropriate png_set_???_fn() function.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002333
2334Memory allocation is done through the functions png_large_malloc(),
2335png_malloc(), png_realloc(), png_large_free(), and png_free(). These
2336currently just call the standard C functions. The large functions must
2337handle exactly 64K, but they don't have to handle more than that. If
2338your pointers can't access more then 64K at a time, you will want to set
2339MAXSEG_64K in zlib.h. Since it is unlikely that the method of handling
2340memory allocation on a platform will change between applications, these
2341functions must be modified in the library at compile time.
2342
2343Input/Output in libpng is done through png_read() and png_write(),
2344which currently just call fread() and fwrite(). The FILE * is stored in
2345png_struct and is initialized via png_init_io(). If you wish to change
2346the method of I/O, the library supplies callbacks that you can set
2347through the function png_set_read_fn() and png_set_write_fn() at run
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05002348time, instead of calling the png_init_io() function.
2349These functions
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002350also provide a void pointer that can be retrieved via the function
2351png_get_io_ptr(). For example:
2352
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -05002353 png_set_read_fn(png_structp read_ptr,
2354 voidp read_io_ptr, png_rw_ptr read_data_fn)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002355
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -05002356 png_set_write_fn(png_structp write_ptr,
2357 voidp write_io_ptr, png_rw_ptr write_data_fn,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002358 png_flush_ptr output_flush_fn);
2359
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -05002360 voidp read_io_ptr = png_get_io_ptr(read_ptr);
2361 voidp write_io_ptr = png_get_io_ptr(write_ptr);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002362
2363The replacement I/O functions should have prototypes as follows:
2364
2365 void user_read_data(png_structp png_ptr,
2366 png_bytep data, png_uint_32 length);
2367 void user_write_data(png_structp png_ptr,
2368 png_bytep data, png_uint_32 length);
2369 void user_flush_data(png_structp png_ptr);
2370
2371Supplying NULL for the read, write, or flush functions sets them back
2372to using the default C stream functions. It is an error to read from
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002373a write stream, and vice versa.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002374
2375Error handling in libpng is done through png_error() and png_warning().
2376Errors handled through png_error() are fatal, meaning that png_error()
2377should never return to its caller. Currently, this is handled via
2378setjmp() and longjmp(), but you could change this to do things like
2379exit() if you should wish. On non-fatal errors, png_warning() is called
2380to print a warning message, and then control returns to the calling code.
2381By default png_error() and png_warning() print a message on stderr via
2382fprintf() unless the library is compiled with PNG_NO_STDIO defined. If
2383you wish to change the behavior of the error functions, you will need to
2384set up your own message callbacks. These functions are normally supplied
2385at the time that the png_struct is created. It is also possible to change
2386these functions after png_create_???_struct() has been called by calling:
2387
2388 png_set_error_fn(png_structp png_ptr,
2389 png_voidp error_ptr, png_error_ptr error_fn,
2390 png_error_ptr warning_fn);
2391
2392 png_voidp error_ptr = png_get_error_ptr(png_ptr);
2393
2394If NULL is supplied for either error_fn or warning_fn, then the libpng
2395default function will be used, calling fprintf() and/or longjmp() if a
2396problem is encountered. The replacement error functions should have
2397parameters as follows:
2398
2399 void user_error_fn(png_structp png_ptr,
2400 png_const_charp error_msg);
2401 void user_warning_fn(png_structp png_ptr,
2402 png_const_charp warning_msg);
2403
2404The motivation behind using setjmp() and longjmp() is the C++ throw and
2405catch exception handling methods. This makes the code much easier to write,
2406as there is no need to check every return code of every function call.
2407However, there are some uncertainties about the status of local variables
2408after a longjmp, so the user may want to be careful about doing anything after
2409setjmp returns non-zero besides returning itself. Consult your compiler
2410documentation for more details.
2411
2412If you need to read or write custom chunks, you will need to get deeper
2413into the libpng code, as a mechanism has not yet been supplied for user
2414callbacks with custom chunks. First, read the PNG specification, and have
2415a first level of understanding of how it works. Pay particular attention
2416to the sections that describe chunk names, and look at how other chunks
2417were designed, so you can do things similarly. Second, check out the
2418sections of libpng that read and write chunks. Try to find a chunk that
2419is similar to yours and copy off of it. More details can be found in the
2420comments inside the code. A way of handling unknown chunks in a generic
2421method, potentially via callback functions, would be best.
2422
2423If you wish to write your own transformation for the data, look through
2424the part of the code that does the transformations, and check out some of
2425the simpler ones to get an idea of how they work. Try to find a similar
2426transformation to the one you want to add and copy off of it. More details
2427can be found in the comments inside the code itself.
2428
2429Configuring for 16 bit platforms:
2430
2431You may need to change the png_large_malloc() and png_large_free()
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002432routines in pngmem.c, as these are required to allocate 64K, although
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002433there is already support for many of the common DOS compilers. Also,
2434you will want to look into zconf.h to tell zlib (and thus libpng) that
2435it cannot allocate more then 64K at a time. Even if you can, the memory
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002436won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002437
2438Configuring for DOS:
2439
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002440For DOS users who only have access to the lower 640K, you will
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002441have to limit zlib's memory usage via a png_set_compression_mem_level()
2442call. See zlib.h or zconf.h in the zlib library for more information.
2443
2444Configuring for Medium Model:
2445
2446Libpng's support for medium model has been tested on most of the popular
2447compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
2448defined, and FAR gets defined to far in pngconf.h, and you should be
2449all set. Everything in the library (except for zlib's structure) is
2450expecting far data. You must use the typedefs with the p or pp on
2451the end for pointers (or at least look at them and be careful). Make
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002452note that the row's of data are defined as png_bytepp, which is an
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002453unsigned char far * far *.
2454
2455Configuring for gui/windowing platforms:
2456
2457You will need to write new error and warning functions that use the GUI
2458interface, as described previously, and set them to be the error and
2459warning functions at the time that png_create_???_struct() is called,
2460in order to have them available during the structure initialization.
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002461They can be changed later via png_set_error_fn(). On some compilers,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002462you may also have to change the memory allocators (png_malloc, etc.).
2463
2464Configuring for compiler xxx:
2465
2466All includes for libpng are in pngconf.h. If you need to add/change/delete
2467an include, this is the place to do it. The includes that are not
2468needed outside libpng are protected by the PNG_INTERNAL definition,
2469which is only defined for those routines inside libpng itself. The
2470files in libpng proper only include png.h, which includes pngconf.h.
2471
2472Configuring zlib:
2473
2474There are special functions to configure the compression. Perhaps the
2475most useful one changes the compression level, which currently uses
2476input compression values in the range 0 - 9. The library normally
2477uses the default compression level (Z_DEFAULT_COMPRESSION = 6). Tests
2478have shown that for a large majority of images, compression values in
2479the range 3-6 compress nearly as well as higher levels, and do so much
2480faster. For online applications it may be desirable to have maximum speed
2481(Z_BEST_SPEED = 1). With versions of zlib after v0.99, you can also
2482specify no compression (Z_NO_COMPRESSION = 0), but this would create
2483files larger than just storing the raw bitmap. You can specify the
2484compression level by calling:
2485
2486 png_set_compression_level(png_ptr, level);
2487
2488Another useful one is to reduce the memory level used by the library.
2489The memory level defaults to 8, but it can be lowered if you are
2490short on memory (running DOS, for example, where you only have 640K).
2491
2492 png_set_compression_mem_level(png_ptr, level);
2493
2494The other functions are for configuring zlib. They are not recommended
2495for normal use and may result in writing an invalid PNG file. See
2496zlib.h for more information on what these mean.
2497
2498 png_set_compression_strategy(png_ptr,
2499 strategy);
2500 png_set_compression_window_bits(png_ptr,
2501 window_bits);
2502 png_set_compression_method(png_ptr, method);
2503
2504Controlling row filtering:
2505
2506If you want to control whether libpng uses filtering or not, which
2507filters are used, and how it goes about picking row filters, you
2508can call one of these functions. The selection and configuration
2509of row filters can have a significant impact on the size and
2510encoding speed and a somewhat lesser impact on the decoding speed
2511of an image. Filtering is enabled by default for RGB and grayscale
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002512images (with and without alpha), but not for paletted images nor
2513for any images with bit depths less than 8 bits/pixel.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002514
2515The 'method' parameter sets the main filtering method, which is
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05002516currently only '0' in the PNG 1.2 specification. The 'filters'
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002517parameter sets which filter(s), if any, should be used for each
2518scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS
2519to turn filtering on and off, respectively.
2520
2521Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB,
2522PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise
2523ORed together '|' to specify one or more filters to use. These
2524filters are described in more detail in the PNG specification. If
2525you intend to change the filter type during the course of writing
2526the image, you should start with flags set for all of the filters
2527you intend to use so that libpng can initialize its internal
2528structures appropriately for all of the filter types.
2529
2530 filters = PNG_FILTER_NONE | PNG_FILTER_SUB
2531 | PNG_FILTER_UP;
2532 png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE,
2533 filters);
2534
2535It is also possible to influence how libpng chooses from among the
2536available filters. This is done in two ways - by telling it how
2537important it is to keep the same filter for successive rows, and
2538by telling it the relative computational costs of the filters.
2539
2540 double weights[3] = {1.5, 1.3, 1.1},
2541 costs[PNG_FILTER_VALUE_LAST] =
2542 {1.0, 1.3, 1.3, 1.5, 1.7};
2543
2544 png_set_filter_selection(png_ptr,
2545 PNG_FILTER_SELECTION_WEIGHTED, 3,
2546 weights, costs);
2547
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002548The weights are multiplying factors that indicate to libpng that the
2549row filter should be the same for successive rows unless another row filter
2550is that many times better than the previous filter. In the above example,
2551if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002552"sum of absolute differences" 1.5 x 1.3 times higher than other filters
2553and still be chosen, while the NONE filter could have a sum 1.1 times
2554higher than other filters and still be chosen. Unspecified weights are
2555taken to be 1.0, and the specified weights should probably be declining
2556like those above in order to emphasize recent filters over older filters.
2557
2558The filter costs specify for each filter type a relative decoding cost
2559to be considered when selecting row filters. This means that filters
2560with higher costs are less likely to be chosen over filters with lower
2561costs, unless their "sum of absolute differences" is that much smaller.
2562The costs do not necessarily reflect the exact computational speeds of
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002563the various filters, since this would unduly influence the final image
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002564size.
2565
2566Note that the numbers above were invented purely for this example and
2567are given only to help explain the function usage. Little testing has
2568been done to find optimum values for either the costs or the weights.
2569
2570Removing unwanted object code:
2571
2572There are a bunch of #define's in pngconf.h that control what parts of
2573libpng are compiled. All the defines end in _SUPPORTED. If you are
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -05002574never going to use a capability, you can change the #define to #undef
2575before recompiling libpng and save yourself code and data space, or
2576you can turn off individual capabilities with defines that begin with
2577PNG_NO_.
2578
2579You can also turn all of the transforms and ancillary chunk capabilities
2580off en masse with compiler directives that define
2581PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
2582or all four,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002583along with directives to turn on any of the capabilities that you do
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -05002584want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06002585the extra transformations but still leave the library fully capable of reading
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002586and writing PNG files with all known public chunks [except for sPLT].
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -05002587Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002588produces a library that is incapable of reading or writing ancillary chunks.
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06002589If you are not using the progressive reading capability, you can
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -05002590turn that off with PNG_NO_PROGRESSIVE_READ (don't confuse
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06002591this with the INTERLACING capability, which you'll still have).
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002592
2593All the reading and writing specific code are in separate files, so the
2594linker should only grab the files it needs. However, if you want to
2595make sure, or if you are building a stand alone library, all the
2596reading files start with pngr and all the writing files start with
2597pngw. The files that don't match either (like png.c, pngtrans.c, etc.)
2598are used for both reading and writing, and always need to be included.
2599The progressive reader is in pngpread.c
2600
2601If you are creating or distributing a dynamically linked library (a .so
2602or DLL file), you should not remove or disable any parts of the library,
2603as this will cause applications linked with different versions of the
2604library to fail if they call functions not available in your library.
2605The size of the library itself should not be an issue, because only
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002606those sections that are actually used will be loaded into memory.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002607
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002608Requesting debug printout:
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002609
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002610The macro definition PNG_DEBUG can be used to request debugging
2611printout. Set it to an integer value in the range 0 to 3. Higher
2612numbers result in increasing amounts of debugging information. The
2613information is printed to the "stderr" file, unless another file
2614name is specified in the PNG_DEBUG_FILE macro definition.
2615
2616When PNG_DEBUG > 0, the following functions (macros) become available:
2617
2618 png_debug(level, message)
2619 png_debug1(level, message, p1)
2620 png_debug2(level, message, p1, p2)
2621
2622in which "level" is compared to PNG_DEBUG to decide whether to print
2623the message, "message" is the formatted string to be printed,
2624and p1 and p2 are parameters that are to be embedded in the string
2625according to printf-style formatting directives. For example,
2626
2627 png_debug1(2, "foo=%d\n", foo);
2628
2629is expanded to
2630
2631 if(PNG_DEBUG > 2)
2632 fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo);
2633
2634When PNG_DEBUG is defined but is zero, the macros aren't defined, but you
2635can still use PNG_DEBUG to control your own debugging:
2636
2637 #ifdef PNG_DEBUG
2638 fprintf(stderr, ...
2639 #endif
2640
2641When PNG_DEBUG = 1, the macros are defined, but only png_debug statements
2642having level = 0 will be printed. There aren't any such statements in
2643this version of libpng, but if you insert some they will be printed.
2644
2645.SH VI. Changes to Libpng from version 0.88
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002646
2647It should be noted that versions of libpng later than 0.96 are not
2648distributed by the original libpng author, Guy Schalnat, nor by
2649Andreas Dilger, who had taken over from Guy during 1996 and 1997, and
2650distributed versions 0.89 through 0.96, but rather by another member
2651of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are
2652still alive and well, but they have moved on to other things.
2653
2654The old libpng functions png_read_init(), png_write_init(),
2655png_info_init(), png_read_destroy(), and png_write_destory() have been
2656moved to PNG_INTERNAL in version 0.95 to discourage their use. The
2657preferred method of creating and initializing the libpng structures is
2658via the png_create_read_struct(), png_create_write_struct(), and
2659png_create_info_struct() because they isolate the size of the structures
2660from the application, allow version error checking, and also allow the
2661use of custom error handling routines during the initialization, which
2662the old functions do not. The functions png_read_destroy() and
2663png_write_destroy() do not actually free the memory that libpng
2664allocated for these structs, but just reset the data structures, so they
2665can be used instead of png_destroy_read_struct() and
2666png_destroy_write_struct() if you feel there is too much system overhead
2667allocating and freeing the png_struct for each image read.
2668
2669Setting the error callbacks via png_set_message_fn() before
2670png_read_init() as was suggested in libpng-0.88 is no longer supported
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002671because this caused applications that do not use custom error functions
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002672to fail if the png_ptr was not initialized to zero. It is still possible
2673to set the error callbacks AFTER png_read_init(), or to change them with
2674png_set_error_fn(), which is essentially the same function, but with a
2675new name to force compilation errors with applications that try to use
2676the old method.
2677
Glenn Randers-Pehrson87544ac1999-01-13 22:06:39 -06002678.SH VII. Y2K Compliance in libpng
2679
2680January 13, 1999
2681
2682Since the PNG Development group is an ad-hoc body, we can't make
2683an official declaration.
2684
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05002685This is your unofficial assurance that libpng from version 0.71 and
2686upward through 1.0.4 are Y2K compliant. It is my belief that earlier
2687versions were also Y2K compliant.
Glenn Randers-Pehrson87544ac1999-01-13 22:06:39 -06002688
2689Libpng only has three year fields. One is a 2-byte unsigned integer that
2690will hold years up to 65535. The other two hold the date in text
2691format, and will hold years up to 9999.
2692
2693The integer is
2694 "png_uint_16 year" in png_time_struct.
2695
2696The strings are
2697 "png_charp time_buffer" in png_struct and
2698 "near_time_buffer", which is a local character string in png.c.
2699
2700There are seven time-related functions:
2701
2702 png_convert_to_rfc_1123() in png.c
2703 (formerly png_convert_to_rfc_1152() in error)
2704 png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
2705 png_convert_from_time_t() in pngwrite.c
2706 png_get_tIME() in pngget.c
2707 png_handle_tIME() in pngrutil.c, called in pngread.c
2708 png_set_tIME() in pngset.c
2709 png_write_tIME() in pngwutil.c, called in pngwrite.c
2710
2711All appear to handle dates properly in a Y2K environment. The
2712png_convert_from_time_t() function calls gmtime() to convert from system
2713clock time, which returns (year - 1900), which we properly convert to
2714the full 4-digit year. There is a possibility that applications using
2715libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05002716function, or that they are incorrectly passing only a 2-digit year
2717instead of "year - 1900" into the png_convert_from_struct_tm() function,
2718but this is not under our control. The libpng documentation has always
2719stated that it works with 4-digit years, and the APIs have been
2720documented as such.
Glenn Randers-Pehrson87544ac1999-01-13 22:06:39 -06002721
2722The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
2723integer to hold the year, and can hold years as large as 65535.
2724
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05002725zlib, upon which libpng depends, is also Y2K compliant. It contains
2726no date-related code.
2727
Glenn Randers-Pehrson87544ac1999-01-13 22:06:39 -06002728
2729 Glenn Randers-Pehrson
2730 libpng maintainer
2731 PNG Development Group
2732
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002733.SH NOTE
2734
2735Note about libpng version numbers:
2736
2737Due to various miscommunications, unforeseen code incompatibilities
2738and occasional factors outside the authors' control, version numbering
2739on the library has not always been consistent and straightforward.
2740The following table summarizes matters since version 0.89c, which was
2741the first widely used release:
2742
Glenn Randers-Pehrson8f8fb6a1998-03-09 23:02:06 -06002743 source png.h png.h shared-lib
2744 version string int version
2745 ------- ------ ------ ----------
2746 0.89c 0.89 89 1.0.89
2747 0.90 0.90 90 0.90 [should be 2.0.90]
2748 0.95 0.95 95 0.95 [should be 2.0.95]
2749 0.96 0.96 96 0.96 [should be 2.0.96]
Glenn Randers-Pehrsonf9f2fe01998-03-15 18:20:23 -06002750 0.97b 1.00.97 97 1.0.1 [should be 2.0.97]
Glenn Randers-Pehrson8f8fb6a1998-03-09 23:02:06 -06002751 0.97c 0.97 97 2.0.97
2752 0.98 0.98 98 2.0.98
2753 0.99 0.99 98 2.0.99
2754 0.99a-m 0.99 99 2.0.99
Glenn Randers-Pehrsonf9f2fe01998-03-15 18:20:23 -06002755 1.00 1.00 100 2.1.0 [int should be 10000]
2756 1.0.0 1.0.0 100 2.1.0 [int should be 10000]
Glenn Randers-Pehrson8f8fb6a1998-03-09 23:02:06 -06002757 1.0.1 1.0.1 10001 2.1.0
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002758
Glenn Randers-Pehrson8f8fb6a1998-03-09 23:02:06 -06002759Henceforth the source version will match the shared-library
2760minor and patch numbers; the shared-library major version number will be
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002761used for changes in backward compatibility, as it is intended.
Glenn Randers-Pehrson8f8fb6a1998-03-09 23:02:06 -06002762The PNG_PNGLIB_VER macro, which is not used within libpng but
2763is available for applications, is an unsigned integer of the form
Glenn Randers-Pehrsonf9f2fe01998-03-15 18:20:23 -06002764xyyzz corresponding to the source version x.y.z (leading zeros in y and z).
Glenn Randers-Pehrson8f8fb6a1998-03-09 23:02:06 -06002765
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06002766.SH "SEE ALSO"
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002767libpngpf(3), png(5)
2768.LP
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06002769.IR libpng :
2770.IP
2771ftp://ftp.uu.net/graphics/png
2772http://www.cdrom.com/pub/png
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002773
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002774.LP
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06002775.IR zlib :
2776.IP
2777(generally) at the same location as
2778.I libpng
2779or at
2780.br
2781ftp://ftp.uu.net/pub/archiving/zip/zlib
2782.br
2783http://www.cdrom.com/pub/infozip/zlib
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002784
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002785.LP
2786.IR PNG specification: RFC 2083
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06002787.IP
2788(generally) at the same location as
2789.I libpng
2790or at
2791.br
2792ftp://ds.internic.net/rfc/rfc2083.txt
2793.br
2794or (as a W3C Recommendation) at
2795.br
2796http://www.w3.org/TR/REC-png.html
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002797
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002798.LP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002799In the case of any inconsistency between the PNG specification
2800and this library, the specification takes precedence.
2801
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06002802.SH AUTHORS
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002803This man page: Glenn Randers-Pehrson
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05002804<randeg@alum.rpi.edu>
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002805
2806Contributing Authors: John Bowler, Kevin Bracey, Sam Bushell, Andreas Dilger,
2807Magnus Holmgren, Tom Lane, Dave Martindale, Glenn Randers-Pehrson,
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002808Greg Roelofs, Guy Eric Schalnat, Paul Schmidt, Tom Tanner, Willem van
2809Schaik, Tim Wegner.
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05002810<png-implement@ccrc.wustl.edu>
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002811
2812The contributing authors would like to thank all those who helped
2813with testing, bug fixes, and patience. This wouldn't have been
2814possible without all of you.
2815
2816Thanks to Frank J. T. Wojcik for helping with the documentation.
2817
Glenn Randers-Pehrsonf8b008c1999-09-18 10:54:36 -05002818Libpng version 1.0.4 - September 18, 1999:
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06002819Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05002820Currently maintained by Glenn Randers-Pehrson (randeg@alum.rpi.edu).
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002821
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06002822Supported by the PNG development group
2823.br
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05002824(png-implement@ccrc.wustl.edu).
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06002825
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002826.SH COPYRIGHT NOTICE:
2827
Glenn Randers-Pehrson87544ac1999-01-13 22:06:39 -06002828Copyright (c) 1998, 1999 Glenn Randers-Pehrson
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05002829Copyright (c) 1996, 1997 Andreas Dilger
2830Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
Glenn Randers-Pehrsonc9442291999-01-06 21:50:16 -06002831
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002832The PNG Reference Library (libpng) is supplied "AS IS". The Contributing
2833Authors and Group 42, Inc. disclaim all warranties, expressed or implied,
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06002834including, without limitation, the warranties of merchantability and of
2835fitness for any purpose. The Contributing Authors and Group 42, Inc.
2836assume no liability for direct, indirect, incidental, special, exemplary,
2837or consequential damages, which may result from the use of the PNG
2838Reference Library, even if advised of the possibility of such damage.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002839
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06002840Permission is hereby granted to use, copy, modify, and distribute this
2841source code, or portions hereof, for any purpose, without fee, subject
2842to the following restrictions:
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06002843
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002844 1. The origin of this source code must not be
2845 misrepresented.
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06002846
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002847 2. Altered versions must be plainly marked as such
2848 and must not be misrepresented as being the
2849 original source.
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06002850
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002851 3. This Copyright notice may not be removed or
2852 altered from any source or altered source
2853 distribution.
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06002854
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06002855The Contributing Authors and Group 42, Inc. specifically permit, without
2856fee, and encourage the use of this source code as a component to
2857supporting the PNG file format in commercial products. If you use this
2858source code in a product, acknowledgment is not required but would be
2859appreciated.
2860
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05002861A "png_get_copyright" function is available, for convenient use in "about"
2862boxes and the like:
2863
2864 printf("%s",png_get_copyright(NULL));
2865
2866Also, the PNG logo (in PNG format, of course) is supplied in the
2867file "pngnow.png".
2868
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06002869.\" end of man page
2870