blob: 1324810bce8878011af2d5b3dae00df8d2171b7d [file] [log] [blame]
Glenn Randers-Pehrsond92c1fc2011-11-17 21:03:07 -06001.TH LIBPNG 3 "November 18, 2011"
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06002.SH NAME
Glenn Randers-Pehrson36251d32011-11-17 21:14:34 -06003libpng \- Portable Network Graphics (PNG) Reference Library 1.5.7beta05
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06004.SH SYNOPSIS
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -05005\fI\fB
6
7\fB#include <png.h>\fP
8
9\fI\fB
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060010
Glenn Randers-Pehrsone0a6c062011-11-07 23:50:05 -060011\fBint \fP\fIpng_image_begin_read_from_file\fP\fB, (png_imagep \fIimage,
12
13\fBconst char \fI*file_name)\fP\fB);\fP
14
15\fBint \fP\fIpng_image_begin_read_from_stdio\fP\fB, (png_imagep \fIimage,
16
17\fBFILE* \fIfile)\fP\fB);\fP
18
19\fBint, \fP\fIpng_image_begin_read_from_memory\fP\fB, (png_imagep \fIimage,
20
21\fBpng_const_voidp \fP\fImemory\fP\fB, png_size_t \fIsize)\fP\fB);\fP
22
23\fBint \fP\fIpng_image_finish_read\fP\fB, (png_imagep \fIimage,
24
25\fBpng_colorp \fP\fIbackground\fP\fB, void \fP\fI*buffer\fP\fB, png_int_32 \fIrow_stride)\fP\fB);\fP
26
27\fBvoid \fP\fIpng_image_free\fP\fB, (png_imagep \fIimage)\fP\fB);\fP
28
29\fBint \fP\fIpng_image_write_to_file\fP\fB, (png_imagep \fIimage,
30
31\fBconst char \fP\fI*file\fP\fB, int \fP\fIconvert_to_8bit\fP\fB, const void \fI*buffer,
32
33\fBpng_int_32 \fIrow_stride)\fP\fB);\fP
34
35\fBint \fP\fIpng_image_write_to_stdio\fP\fB, (png_imagep \fP\fIimage\fP\fB, FILE \fI*file,
36
37\fBint \fP\fIconvert_to_8_bit\fP\fB, const void \fP\fI*buffer\fP\fB, png_int_32 \fIrow_stride)\fP\fB);\fP
38
39\fI\fB
40
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -050041\fBpng_uint_32 png_access_version_number \fI(void\fP\fB);\fP
42
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -050043\fI\fB
44
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -050045\fBvoid png_benign_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP
46
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -050047\fI\fB
48
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -060049\fBvoid png_build_grayscale_palette (int \fP\fIbit_depth\fP\fB, png_colorp \fIpalette\fP\fB);\fP
50
51\fI\fB
52
53\fBpng_voidp png_calloc (png_structp \fP\fIpng_ptr\fP\fB, png_alloc_size_t \fIsize\fP\fB);\fP
54
55\fI\fB
56
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -050057\fBvoid png_chunk_benign_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP
58
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -050059\fI\fB
60
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050061\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 -060062
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -050063\fI\fB
64
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050065\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 -060066
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -050067\fI\fB
68
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050069\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 -060070
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -050071\fI\fB
72
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050073\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 -060074
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -050075\fI\fB
76
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050077\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 -060078
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -050079\fI\fB
80
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050081\fBpng_infop png_create_info_struct (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -060082
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -050083\fI\fB
84
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -060085\fBpng_structp png_create_read_struct (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarn_fn\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050086
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -050087\fI\fB
88
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -060089\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
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050090
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -050091\fI\fB
92
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -060093\fBpng_structp png_create_write_struct (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarn_fn\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -050094
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -050095\fI\fB
96
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -060097\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
98
99\fI\fB
100
101\fBvoid png_data_freer (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIfreer\fP\fB, png_uint_32 \fImask)\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500102
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500103\fI\fB
104
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500105\fBvoid png_destroy_info_struct (png_structp \fP\fIpng_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP
106
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500107\fI\fB
108
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500109\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
110
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500111\fI\fB
112
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500113\fBvoid png_destroy_write_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP
114
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500115\fI\fB
116
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -0600117\fBvoid png_err (png_structp \fIpng_ptr\fP\fB);\fP
118
119\fI\fB
120
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500121\fBvoid png_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP
122
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500123\fI\fB
124
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500125\fBvoid png_free (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP
126
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500127\fI\fB
128
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600129\fBvoid png_free_chunk_list (png_structp \fIpng_ptr\fP\fB);\fP
130
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500131\fI\fB
132
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -0600133\fBvoid png_free_default (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500134
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500135\fI\fB
136
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -0600137\fBvoid png_free_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fInum\fP\fB);\fP
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600138
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500139\fI\fB
140
John Bowler0a5c9c02011-01-22 17:36:34 -0600141\fBpng_byte png_get_bit_depth (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500142
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500143\fI\fB
144
John Bowler0a5c9c02011-01-22 17:36:34 -0600145\fBpng_uint_32 png_get_bKGD (png_const_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fI*background\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500146
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500147\fI\fB
148
John Bowler0a5c9c02011-01-22 17:36:34 -0600149\fBpng_byte png_get_channels (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500150
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500151\fI\fB
152
John Bowler0a5c9c02011-01-22 17:36:34 -0600153\fBpng_uint_32 png_get_cHRM (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, double \fP\fI*white_x\fP\fB, double \fP\fI*white_y\fP\fB, double \fP\fI*red_x\fP\fB, double \fP\fI*red_y\fP\fB, double \fP\fI*green_x\fP\fB, double \fP\fI*green_y\fP\fB, double \fP\fI*blue_x\fP\fB, double \fI*blue_y\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500154
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500155\fI\fB
156
John Bowler0a5c9c02011-01-22 17:36:34 -0600157\fBpng_uint_32 png_get_cHRM_fixed (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*white_x\fP\fB, png_uint_32 \fP\fI*white_y\fP\fB, png_uint_32 \fP\fI*red_x\fP\fB, png_uint_32 \fP\fI*red_y\fP\fB, png_uint_32 \fP\fI*green_x\fP\fB, png_uint_32 \fP\fI*green_y\fP\fB, png_uint_32 \fP\fI*blue_x\fP\fB, png_uint_32 \fI*blue_y\fP\fB);\fP
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600158
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500159\fI\fB
160
John Bowler736f40f2011-08-25 16:19:44 -0500161\fBpng_uint_32 png_get_cHRM_XYZ (png_structp \fIpng_ptr,
162
163\fBpng_const_infop \fP\fIinfo_ptr\fP\fB, double \fP\fI*red_X\fP\fB, double \fP\fI*red_Y\fP\fB, double \fI*red_Z,
164
165\fBdouble \fP\fI*green_X\fP\fB, double \fP\fI*green_Y\fP\fB, double \fP\fI*green_Z\fP\fB, double \fI*blue_X,
166
167\fBdouble \fP\fI*blue_Y\fP\fB, double \fI*blue_Z\fP\fB);\fP
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -0500168
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500169\fI\fB
170
John Bowler736f40f2011-08-25 16:19:44 -0500171\fBpng_uint_32 png_get_cHRM_XYZ_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_fixed_point \fP\fI*int_red_X\fP\fB, png_fixed_point \fP\fI*int_red_Y\fP\fB, png_fixed_point \fP\fI*int_red_Z\fP\fB, png_fixed_point \fP\fI*int_green_X\fP\fB, png_fixed_point \fP\fI*int_green_Y\fP\fB, png_fixed_point \fP\fI*int_green_Z\fP\fB, png_fixed_point \fP\fI*int_blue_X\fP\fB, png_fixed_point \fP\fI*int_blue_Y\fP\fB, png_fixed_point \fI*int_blue_Z\fP\fB);\fP
172
173\fI\fB
174
175\fBpng_uint_32 png_get_chunk_cache_max (png_const_structp \fIpng_ptr\fP\fB);\fP
176
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -0600177\fI\fB
178
John Bowler0a5c9c02011-01-22 17:36:34 -0600179\fBpng_alloc_size_t png_get_chunk_malloc_max (png_const_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -0600180
181\fI\fB
182
John Bowler0a5c9c02011-01-22 17:36:34 -0600183\fBpng_byte png_get_color_type (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500184
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500185\fI\fB
186
John Bowler0a5c9c02011-01-22 17:36:34 -0600187\fBpng_uint_32 png_get_compression_buffer_size (png_const_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -0500188
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500189\fI\fB
190
John Bowler0a5c9c02011-01-22 17:36:34 -0600191\fBpng_byte png_get_compression_type (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500192
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500193\fI\fB
194
John Bowler0a5c9c02011-01-22 17:36:34 -0600195\fBpng_byte png_get_copyright (png_const_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500196
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500197\fI\fB
198
John Bowlerf19abd62011-01-22 18:29:24 -0600199\fBpng_uint_32 png_get_current_row_number \fI(png_const_structp\fP\fB);\fP
200
201\fI\fB
202
203\fBpng_byte png_get_current_pass_number \fI(png_const_structp\fP\fB);\fP
204
205\fI\fB
206
John Bowler0a5c9c02011-01-22 17:36:34 -0600207\fBpng_voidp png_get_error_ptr (png_const_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500208
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500209\fI\fB
210
John Bowler0a5c9c02011-01-22 17:36:34 -0600211\fBpng_byte png_get_filter_type (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500212
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500213\fI\fB
214
John Bowler0a5c9c02011-01-22 17:36:34 -0600215\fBpng_uint_32 png_get_gAMA (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, double \fI*file_gamma\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500216
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500217\fI\fB
218
John Bowler0a5c9c02011-01-22 17:36:34 -0600219\fBpng_uint_32 png_get_gAMA_fixed (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fI*int_file_gamma\fP\fB);\fP
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600220
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500221\fI\fB
222
John Bowler0a5c9c02011-01-22 17:36:34 -0600223\fBpng_byte png_get_header_ver (png_const_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrson5379b241999-11-27 10:22:33 -0600224
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500225\fI\fB
226
John Bowler0a5c9c02011-01-22 17:36:34 -0600227\fBpng_byte png_get_header_version (png_const_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500228
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500229\fI\fB
230
John Bowler0a5c9c02011-01-22 17:36:34 -0600231\fBpng_uint_32 png_get_hIST (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fI*hist\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500232
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500233\fI\fB
234
John Bowler0a5c9c02011-01-22 17:36:34 -0600235\fBpng_uint_32 png_get_iCCP (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_charpp \fP\fIname\fP\fB, int \fP\fI*compression_type\fP\fB, png_bytepp \fP\fIprofile\fP\fB, png_uint_32 \fI*proflen\fP\fB);\fP
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600236
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500237\fI\fB
238
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500239\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
240
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500241\fI\fB
242
John Bowler0a5c9c02011-01-22 17:36:34 -0600243\fBpng_uint_32 png_get_image_height (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500244
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500245\fI\fB
246
John Bowler0a5c9c02011-01-22 17:36:34 -0600247\fBpng_uint_32 png_get_image_width (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500248
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500249\fI\fB
250
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500251\fBpng_int_32 png_get_int_32 (png_bytep \fIbuf\fP\fB);\fP
252
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500253\fI\fB
Glenn Randers-Pehrson7b34df32006-02-24 06:30:16 -0600254
John Bowler0a5c9c02011-01-22 17:36:34 -0600255\fBpng_byte png_get_interlace_type (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500256
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500257\fI\fB
258
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -0600259\fBpng_const_bytep png_get_io_chunk_name (png_structp \fIpng_ptr\fP\fB);\fP
260
261\fI\fB
262
John Bowler0a5c9c02011-01-22 17:36:34 -0600263\fBpng_uint_32 png_get_io_chunk_type (png_const_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona63dbed2011-01-22 08:51:19 -0600264
265\fI\fB
266
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500267\fBpng_voidp png_get_io_ptr (png_structp \fIpng_ptr\fP\fB);\fP
268
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500269\fI\fB
270
Glenn Randers-Pehrsona63dbed2011-01-22 08:51:19 -0600271\fBpng_uint_32 png_get_io_state (png_structp \fIpng_ptr\fP\fB);\fP
272
273\fI\fB
274
John Bowler0a5c9c02011-01-22 17:36:34 -0600275\fBpng_byte png_get_libpng_ver (png_const_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrson5379b241999-11-27 10:22:33 -0600276
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500277\fI\fB
278
John Bowler0a5c9c02011-01-22 17:36:34 -0600279\fBpng_voidp png_get_mem_ptr (png_const_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -0500280
281\fI\fB
282
John Bowler0a5c9c02011-01-22 17:36:34 -0600283\fBpng_uint_32 png_get_oFFs (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*offset_x\fP\fB, png_uint_32 \fP\fI*offset_y\fP\fB, int \fI*unit_type\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500284
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500285\fI\fB
286
John Bowler0a5c9c02011-01-22 17:36:34 -0600287\fBpng_uint_32 png_get_pCAL (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fI*purpose\fP\fB, png_int_32 \fP\fI*X0\fP\fB, png_int_32 \fP\fI*X1\fP\fB, int \fP\fI*type\fP\fB, int \fP\fI*nparams\fP\fB, png_charp \fP\fI*units\fP\fB, png_charpp \fI*params\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500288
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500289\fI\fB
290
John Bowler0a5c9c02011-01-22 17:36:34 -0600291\fBpng_uint_32 png_get_pHYs (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*res_x\fP\fB, png_uint_32 \fP\fI*res_y\fP\fB, int \fI*unit_type\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500292
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500293\fI\fB
294
John Bowler0a5c9c02011-01-22 17:36:34 -0600295\fBfloat png_get_pixel_aspect_ratio (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500296
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500297\fI\fB
298
John Bowler0a5c9c02011-01-22 17:36:34 -0600299\fBpng_uint_32 png_get_pHYs_dpi (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*res_x\fP\fB, png_uint_32 \fP\fI*res_y\fP\fB, int \fI*unit_type\fP\fB);\fP
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -0600300
301\fI\fB
302
John Bowler0a5c9c02011-01-22 17:36:34 -0600303\fBpng_fixed_point png_get_pixel_aspect_ratio_fixed (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -0500304
305\fI\fB
306
John Bowler0a5c9c02011-01-22 17:36:34 -0600307\fBpng_uint_32 png_get_pixels_per_inch (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -0600308
309\fI\fB
310
John Bowler0a5c9c02011-01-22 17:36:34 -0600311\fBpng_uint_32 png_get_pixels_per_meter (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500312
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500313\fI\fB
314
John Bowler0a5c9c02011-01-22 17:36:34 -0600315\fBpng_voidp png_get_progressive_ptr (png_const_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500316
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500317\fI\fB
318
John Bowler0a5c9c02011-01-22 17:36:34 -0600319\fBpng_uint_32 png_get_PLTE (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_colorp \fP\fI*palette\fP\fB, int \fI*num_palette\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500320
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500321\fI\fB
322
John Bowler0a5c9c02011-01-22 17:36:34 -0600323\fBpng_byte png_get_rgb_to_gray_status (png_const_structp \fIpng_ptr)
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500324
John Bowler0a5c9c02011-01-22 17:36:34 -0600325\fBpng_uint_32 png_get_rowbytes (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500326
327\fI\fB
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500328
John Bowler0a5c9c02011-01-22 17:36:34 -0600329\fBpng_bytepp png_get_rows (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -0600330
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500331\fI\fB
332
John Bowler0a5c9c02011-01-22 17:36:34 -0600333\fBpng_uint_32 png_get_sBIT (png_const_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_8p \fI*sig_bit\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500334
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500335\fI\fB
336
John Bowler0a5c9c02011-01-22 17:36:34 -0600337\fBvoid png_get_sCAL (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, int* \fP\fIunit\fP\fB, double* \fP\fIwidth\fP\fB, double* \fIheight\fP\fB);\fP
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -0500338
339\fI\fB
340
John Bowler0a5c9c02011-01-22 17:36:34 -0600341\fBvoid png_get_sCAL_fixed (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, int* \fP\fIunit\fP\fB, png_fixed_pointp \fP\fIwidth\fP\fB, png_fixed_pointp \fIheight\fP\fB);\fP
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -0500342
343\fI\fB
344
John Bowler0a5c9c02011-01-22 17:36:34 -0600345\fBvoid png_get_sCAL_s (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, int* \fP\fIunit\fP\fB, png_charpp \fP\fIwidth\fP\fB, png_charpp \fIheight\fP\fB);\fP
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -0500346
347\fI\fB
348
John Bowler0a5c9c02011-01-22 17:36:34 -0600349\fBpng_bytep png_get_signature (png_const_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500350
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500351\fI\fB
352
John Bowler0a5c9c02011-01-22 17:36:34 -0600353\fBpng_uint_32 png_get_sPLT (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fI*splt_ptr\fP\fB);\fP
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600354
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500355\fI\fB
356
Glenn Randers-Pehrson8d0bc0f2011-01-25 22:15:58 -0600357\fBpng_uint_32 png_get_sRGB (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, int \fI*file_srgb_intent\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500358
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500359\fI\fB
360
John Bowler0a5c9c02011-01-22 17:36:34 -0600361\fBpng_uint_32 png_get_text (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fI*text_ptr\fP\fB, int \fI*num_text\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500362
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500363\fI\fB
364
John Bowler0a5c9c02011-01-22 17:36:34 -0600365\fBpng_uint_32 png_get_tIME (png_const_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fI*mod_time\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500366
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500367\fI\fB
368
John Bowler0a5c9c02011-01-22 17:36:34 -0600369\fBpng_uint_32 png_get_tRNS (png_const_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fI*trans_alpha\fP\fB, int \fP\fI*num_trans\fP\fB, png_color_16p \fI*trans_color\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500370
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500371\fI\fB
372
373\fB/* This function is really an inline macro. \fI*/
374
375\fBpng_uint_16 png_get_uint_16 (png_bytep \fIbuf\fP\fB);\fP
376
377\fI\fB
Glenn Randers-Pehrson7b34df32006-02-24 06:30:16 -0600378
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -0600379\fBpng_uint_32 png_get_uint_31 (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIbuf\fP\fB);\fP
Glenn Randers-Pehrson7b34df32006-02-24 06:30:16 -0600380
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500381\fI\fB
382
383\fB/* This function is really an inline macro. \fI*/
384
385\fBpng_uint_32 png_get_uint_32 (png_bytep \fIbuf\fP\fB);\fP
386
387\fI\fB
Glenn Randers-Pehrson7b34df32006-02-24 06:30:16 -0600388
John Bowler0a5c9c02011-01-22 17:36:34 -0600389\fBpng_uint_32 png_get_unknown_chunks (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkpp \fIunknowns\fP\fB);\fP
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600390
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500391\fI\fB
392
John Bowler0a5c9c02011-01-22 17:36:34 -0600393\fBpng_voidp png_get_user_chunk_ptr (png_const_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600394
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500395\fI\fB
396
John Bowler0a5c9c02011-01-22 17:36:34 -0600397\fBpng_uint_32 png_get_user_height_max (png_const_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500398
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500399\fI\fB
400
John Bowler0a5c9c02011-01-22 17:36:34 -0600401\fBpng_voidp png_get_user_transform_ptr (png_const_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500402
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500403\fI\fB
404
John Bowler0a5c9c02011-01-22 17:36:34 -0600405\fBpng_uint_32 png_get_user_width_max (png_const_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500406
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500407\fI\fB
408
John Bowler0a5c9c02011-01-22 17:36:34 -0600409\fBpng_uint_32 png_get_valid (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIflag\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500410
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500411\fI\fB
412
John Bowler0a5c9c02011-01-22 17:36:34 -0600413\fBfloat png_get_x_offset_inches (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -0500414
415\fI\fB
416
John Bowler0a5c9c02011-01-22 17:36:34 -0600417\fBpng_fixed_point png_get_x_offset_inches_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -0500418
419\fI\fB
420
John Bowler0a5c9c02011-01-22 17:36:34 -0600421\fBpng_int_32 png_get_x_offset_microns (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500422
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500423\fI\fB
424
John Bowler0a5c9c02011-01-22 17:36:34 -0600425\fBpng_int_32 png_get_x_offset_pixels (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500426
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500427\fI\fB
428
John Bowler0a5c9c02011-01-22 17:36:34 -0600429\fBpng_uint_32 png_get_x_pixels_per_inch (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -0600430
431\fI\fB
432
John Bowler0a5c9c02011-01-22 17:36:34 -0600433\fBpng_uint_32 png_get_x_pixels_per_meter (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500434
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500435\fI\fB
436
John Bowler0a5c9c02011-01-22 17:36:34 -0600437\fBfloat png_get_y_offset_inches (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -0500438
439\fI\fB
440
John Bowler0a5c9c02011-01-22 17:36:34 -0600441\fBpng_fixed_point png_get_y_offset_inches_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -0500442
443\fI\fB
444
John Bowler0a5c9c02011-01-22 17:36:34 -0600445\fBpng_int_32 png_get_y_offset_microns (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500446
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500447\fI\fB
448
John Bowler0a5c9c02011-01-22 17:36:34 -0600449\fBpng_int_32 png_get_y_offset_pixels (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500450
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500451\fI\fB
452
John Bowler0a5c9c02011-01-22 17:36:34 -0600453\fBpng_uint_32 png_get_y_pixels_per_inch (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -0600454
455\fI\fB
456
John Bowler0a5c9c02011-01-22 17:36:34 -0600457\fBpng_uint_32 png_get_y_pixels_per_meter (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500458
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500459\fI\fB
460
Glenn Randers-Pehrsonc1bfe682002-03-06 22:08:00 -0600461\fBint png_handle_as_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP
462
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500463\fI\fB
464
Glenn Randers-Pehrsone0a6c062011-11-07 23:50:05 -0600465\fBint png_image_begin_read_from_file (png_imagep \fP\fIimage\fP\fB, const char \fI*file_name\fP\fB);\fP
466
467\fI\fB
468
469\fBint png_image_begin_read_from_stdio (png_imagep \fP\fIimage\fP\fB, FILE* \fIfile\fP\fB);\fP
470
471\fI\fB
472
473\fBint, png_image_begin_read_from_memory (png_imagep \fP\fIimage\fP\fB, png_const_voidp \fP\fImemory\fP\fB, png_size_t \fIsize\fP\fB);\fP
474
475\fI\fB
476
477\fBint png_image_finish_read (png_imagep \fP\fIimage\fP\fB, png_colorp \fP\fIbackground\fP\fB, void \fP\fI*buffer\fP\fB, png_int_32 \fIrow_stride\fP\fB);\fP
478
479\fI\fB
480
481\fBvoid png_image_free (png_imagep \fIimage\fP\fB);\fP
482
483\fI\fB
484
485\fBint png_image_write_to_file (png_imagep \fP\fIimage\fP\fB, const char \fP\fI*file\fP\fB, int \fP\fIconvert_to_8bit\fP\fB, const void \fI*buffer,
486
487\fBpng_int_32 \fIrow_stride\fP\fB);\fP
488
489\fI\fB
490
491\fBint png_image_write_to_stdio (png_imagep \fP\fIimage\fP\fB, FILE \fP\fI*file\fP\fB, int \fP\fIconvert_to_8_bit\fP\fB, const void \fP\fI*buffer\fP\fB, png_int_32 \fIrow_stride)\fP\fB);\fP
492
493\fI\fB
494
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -0600495\fBvoid png_info_init_3 (png_infopp \fP\fIinfo_ptr\fP\fB, png_size_t \fIpng_info_struct_size\fP\fB);\fP
496
497\fI\fB
498
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -0500499\fBvoid png_init_io (png_structp \fP\fIpng_ptr\fP\fB, FILE \fI*fp\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500500
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500501\fI\fB
502
Glenn Randers-Pehrsonf98726a2010-02-19 09:54:53 -0600503\fBvoid png_longjmp (png_structp \fP\fIpng_ptr\fP\fB, int \fIval\fP\fB);\fP
504
505\fI\fB
506
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -0500507\fBpng_voidp png_malloc (png_structp \fP\fIpng_ptr\fP\fB, png_alloc_size_t \fIsize\fP\fB);\fP
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -0500508
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500509\fI\fB
510
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -0600511\fBpng_voidp png_malloc_default (png_structp \fP\fIpng_ptr\fP\fB, png_alloc_size_t \fIsize\fP\fB);\fP
512
513\fI\fB
514
515\fBpng_voidp png_malloc_warn (png_structp \fP\fIpng_ptr\fP\fB, png_alloc_size_t \fIsize\fP\fB);\fP
516
517\fI\fB
518
519\fBpng_uint_32 png_permit_mng_features (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fImng_features_permitted\fP\fB);\fP
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500520
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500521\fI\fB
522
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500523\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
524
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500525\fI\fB
526
John Bowlerf19abd62011-01-22 18:29:24 -0600527\fBpng_size_t png_process_data_pause \fP\fI(png_structp\fP\fB, int \fIsave\fP\fB);\fP
528
529\fI\fB
530
531\fBpng_uint_32 png_process_data_skip \fI(png_structp\fP\fB);\fP
532
533\fI\fB
534
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500535\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
536
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500537\fI\fB
538
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500539\fBvoid png_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
540
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500541\fI\fB
542
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500543\fBvoid png_read_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP
544
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500545\fI\fB
546
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500547\fBvoid png_read_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
548
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500549\fI\fB
550
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -0600551\fBvoid png_read_png (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fItransforms\fP\fB, png_voidp \fIparams\fP\fB);\fP
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600552
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500553\fI\fB
554
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500555\fBvoid png_read_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fIdisplay_row\fP\fB);\fP
556
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500557\fI\fB
558
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500559\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
560
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500561\fI\fB
562
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500563\fBvoid png_read_update_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
564
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500565\fI\fB
566
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -0600567\fBint png_reset_zstream (png_structp \fIpng_ptr\fP\fB);\fP
568
569\fI\fB
570
571\fBvoid png_save_int_32 (png_bytep \fP\fIbuf\fP\fB, png_int_32 \fIi\fP\fB);\fP
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500572
573\fI\fB
Glenn Randers-Pehrson7b34df32006-02-24 06:30:16 -0600574
575\fBvoid png_save_uint_16 (png_bytep \fP\fIbuf\fP\fB, unsigned int \fIi\fP\fB);\fP
576
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500577\fI\fB
578
Glenn Randers-Pehrson7b34df32006-02-24 06:30:16 -0600579\fBvoid png_save_uint_32 (png_bytep \fP\fIbuf\fP\fB, png_uint_32 \fIi\fP\fB);\fP
580
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500581\fI\fB
582
583\fBvoid png_set_add_alpha (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP
584
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500585\fI\fB
Glenn Randers-Pehrson67864af2004-08-28 23:30:07 -0500586
Glenn Randers-Pehrsonc7822512011-05-07 21:23:43 -0500587\fBvoid png_set_alpha_mode (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fImode\fP\fB, double \fIoutput_gamma\fP\fB);\fP
588
589\fI\fB
590
591\fBvoid png_set_alpha_mode_fixed (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fImode\fP\fB, png_fixed_point \fIoutput_gamma\fP\fB);\fP
592
593\fI\fB
594
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500595\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
596
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500597\fI\fB
598
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -0500599\fBvoid png_set_background_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_color_16p \fP\fIbackground_color\fP\fB, int \fP\fIbackground_gamma_code\fP\fB, int \fP\fIneed_expand\fP\fB, png_uint_32 \fIbackground_gamma\fP\fB);\fP
600
601\fI\fB
602
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -0600603\fBvoid png_set_benign_errors (png_structp \fP\fIpng_ptr\fP\fB, int \fIallowed\fP\fB);\fP
604
605\fI\fB
606
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500607\fBvoid png_set_bgr (png_structp \fIpng_ptr\fP\fB);\fP
608
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500609\fI\fB
610
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500611\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
612
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500613\fI\fB
614
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500615\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
616
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500617\fI\fB
618
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600619\fBvoid png_set_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIwhite_x\fP\fB, png_uint_32 \fP\fIwhite_y\fP\fB, png_uint_32 \fP\fIred_x\fP\fB, png_uint_32 \fP\fIred_y\fP\fB, png_uint_32 \fP\fIgreen_x\fP\fB, png_uint_32 \fP\fIgreen_y\fP\fB, png_uint_32 \fP\fIblue_x\fP\fB, png_uint_32 \fIblue_y\fP\fB);\fP
620
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500621\fI\fB
622
John Bowler736f40f2011-08-25 16:19:44 -0500623\fBvoid png_set_cHRM_XYZ (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fIred_X\fP\fB, double \fP\fIred_Y\fP\fB, double \fP\fIred_Z\fP\fB, double \fP\fIgreen_X\fP\fB, double \fIgreen_Y,
624
625\fBdouble \fP\fIgreen_Z\fP\fB, double \fP\fIblue_X\fP\fB, double \fP\fIblue_Y\fP\fB, double \fIblue_Z\fP\fB);\fP
626
627\fI\fB
628
629\fBvoid png_set_cHRM_XYZ_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_fixed_point \fP\fIint_red_X\fP\fB, png_fixed_point \fP\fIint_red_Y\fP\fB, png_fixed_point \fP\fIint_red_Z\fP\fB, png_fixed_point \fP\fIint_green_X\fP\fB, png_fixed_point \fP\fIint_green_Y\fP\fB, png_fixed_point \fP\fIint_green_Z\fP\fB, png_fixed_point \fP\fIint_blue_X\fP\fB, png_fixed_point \fP\fIint_blue_Y\fP\fB, png_fixed_point \fIint_blue_Z\fP\fB);\fP
630
631\fI\fB
632
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -0500633\fBvoid png_set_chunk_cache_max (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIuser_chunk_cache_max\fP\fB);\fP
634
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500635\fI\fB
636
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500637\fBvoid png_set_compression_level (png_structp \fP\fIpng_ptr\fP\fB, int \fIlevel\fP\fB);\fP
638
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500639\fI\fB
640
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500641\fBvoid png_set_compression_mem_level (png_structp \fP\fIpng_ptr\fP\fB, int \fImem_level\fP\fB);\fP
642
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500643\fI\fB
644
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500645\fBvoid png_set_compression_method (png_structp \fP\fIpng_ptr\fP\fB, int \fImethod\fP\fB);\fP
646
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500647\fI\fB
648
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500649\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 -0600650
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500651\fI\fB
652
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500653\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 -0600654
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500655\fI\fB
656
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500657\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 -0600658
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500659\fI\fB
660
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500661\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 -0600662
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500663\fI\fB
664
Glenn Randers-Pehrsond08b6bd2011-02-19 15:50:17 -0600665\fBvoid png_set_expand (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsonc85f5f62011-02-13 05:56:07 -0600666
667\fI\fB
668
Glenn Randers-Pehrsond08b6bd2011-02-19 15:50:17 -0600669\fBvoid png_set_expand_16 (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -0600670
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500671\fI\fB
672
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -0600673\fBvoid png_set_expand_gray_1_2_4_to_8 (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrson1ce08362006-03-08 23:35:59 -0600674
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500675\fI\fB
676
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500677\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 -0600678
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500679\fI\fB
680
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500681\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 -0600682
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500683\fI\fB
684
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500685\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 -0500686
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500687\fI\fB
688
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -0500689\fBvoid png_set_filter_heuristics_fixed (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIheuristic_method\fP\fB, int \fP\fInum_weights\fP\fB, png_fixed_point_p \fP\fIfilter_weights\fP\fB, png_fixed_point_p \fIfilter_costs\fP\fB);\fP
690
691\fI\fB
692
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500693\fBvoid png_set_flush (png_structp \fP\fIpng_ptr\fP\fB, int \fInrows\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600694
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500695\fI\fB
696
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500697\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 -0600698
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500699\fI\fB
700
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -0500701\fBvoid png_set_gamma_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIscreen_gamma\fP\fB, png_uint_32 \fIdefault_file_gamma\fP\fB);\fP
702
703\fI\fB
704
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500705\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 -0600706
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500707\fI\fB
708
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600709\fBvoid png_set_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIfile_gamma\fP\fB);\fP
710
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500711\fI\fB
712
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -0600713\fBvoid png_set_gray_1_2_4_to_8 (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600714
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500715\fI\fB
716
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500717\fBvoid png_set_gray_to_rgb (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600718
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500719\fI\fB
720
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500721\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 -0600722
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500723\fI\fB
724
Glenn Randers-Pehrson4a5a1ec2011-01-15 11:43:28 -0600725\fBvoid png_set_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_const_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_const_bytep \fP\fIprofile\fP\fB, png_uint_32 \fIproflen\fP\fB);\fP
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600726
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500727\fI\fB
728
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500729\fBint png_set_interlace_handling (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600730
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500731\fI\fB
732
Glenn Randers-Pehrsonfc4a1432000-05-17 17:39:34 -0500733\fBvoid png_set_invalid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fImask\fP\fB);\fP
734
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500735\fI\fB
736
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500737\fBvoid png_set_invert_alpha (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600738
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500739\fI\fB
740
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500741\fBvoid png_set_invert_mono (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600742
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500743\fI\fB
744
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500745\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 -0600746
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500747\fI\fB
748
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600749\fBvoid png_set_keep_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIkeep\fP\fB, png_bytep \fP\fIchunk_list\fP\fB, int \fInum_chunks\fP\fB);\fP
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600750
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500751\fI\fB
752
Glenn Randers-Pehrson1e6ed732009-11-20 22:06:56 -0600753\fBjmp_buf* png_set_longjmp_fn (png_structp \fP\fIpng_ptr\fP\fB, png_longjmp_ptr \fP\fIlongjmp_fn\fP\fB, size_t \fIjmp_buf_size\fP\fB);\fP
754
755\fI\fB
756
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -0600757\fBvoid png_set_chunk_malloc_max (png_structp \fP\fIpng_ptr\fP\fB, png_alloc_size_t \fIuser_chunk_cache_max\fP\fB);\fP
758
759\fI\fB
760
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -0600761\fBvoid png_set_compression_buffer_size (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
762
763\fI\fB
764
765\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 -0600766
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500767\fI\fB
768
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500769\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 -0600770
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500771\fI\fB
772
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500773\fBvoid png_set_packing (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600774
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500775\fI\fB
776
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500777\fBvoid png_set_packswap (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600778
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500779\fI\fB
780
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -0600781\fBvoid png_set_palette_to_rgb (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600782
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500783\fI\fB
784
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500785\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 -0600786
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500787\fI\fB
788
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500789\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 -0600790
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500791\fI\fB
792
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500793\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 -0600794
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500795\fI\fB
796
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500797\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 -0600798
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500799\fI\fB
800
Glenn Randers-Pehrson3cd7cff2010-04-16 19:27:08 -0500801\fBvoid png_set_quantize (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fP\fInum_palette\fP\fB, int \fP\fImaximum_colors\fP\fB, png_uint_16p \fP\fIhistogram\fP\fB, int \fIfull_quantize\fP\fB);\fP
802
803\fI\fB
804
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500805\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 -0600806
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500807\fI\fB
808
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500809\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 -0600810
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500811\fI\fB
812
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -0600813\fBvoid png_set_read_user_chunk_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIuser_chunk_ptr\fP\fB, png_user_chunk_ptr \fIread_user_chunk_fn\fP\fB);\fP
814
815\fI\fB
816
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500817\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 -0600818
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500819\fI\fB
820
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -0600821\fBvoid png_set_rgb_to_gray (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIerror_action\fP\fB, double \fP\fIred\fP\fB, double \fIgreen\fP\fB);\fP
822
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500823\fI\fB
824
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -0500825\fBvoid png_set_rgb_to_gray_fixed (png_structp \fP\fIpng_ptr\fP\fB, int error_action png_uint_32 \fP\fIred\fP\fB, png_uint_32 \fIgreen\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600826
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500827\fI\fB
828
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -0600829\fBvoid png_set_rows (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytepp \fIrow_pointers\fP\fB);\fP
830
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500831\fI\fB
832
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500833\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 -0600834
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500835\fI\fB
836
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -0500837\fBvoid png_set_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIunit\fP\fB, double \fP\fIwidth\fP\fB, double \fIheight\fP\fB);\fP
838
839\fI\fB
840
841\fBvoid png_set_sCAL_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIunit\fP\fB, png_fixed_point \fP\fIwidth\fP\fB, png_fixed_point \fIheight\fP\fB);\fP
842
843\fI\fB
844
845\fBvoid png_set_sCAL_s (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIunit\fP\fB, png_charp \fP\fIwidth\fP\fB, png_charp \fIheight\fP\fB);\fP
846
847\fI\fB
848
Glenn Randers-Pehrsonc4a82142011-06-18 00:44:08 -0500849\fBvoid png_set_scale_16 (png_structp \fIpng_ptr\fP\fB);\fP
850
851\fI\fB
852
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500853\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 -0600854
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500855\fI\fB
856
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500857\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 -0600858
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500859\fI\fB
860
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -0600861\fBvoid png_set_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fP\fIsplt_ptr\fP\fB, int \fInum_spalettes\fP\fB);\fP
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600862
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500863\fI\fB
864
Glenn Randers-Pehrson8d0bc0f2011-01-25 22:15:58 -0600865\fBvoid png_set_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIsrgb_intent\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600866
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500867\fI\fB
868
Glenn Randers-Pehrson8d0bc0f2011-01-25 22:15:58 -0600869\fBvoid png_set_sRGB_gAMA_and_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIsrgb_intent\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600870
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500871\fI\fB
872
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500873\fBvoid png_set_strip_16 (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600874
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500875\fI\fB
876
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500877\fBvoid png_set_strip_alpha (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600878
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500879\fI\fB
880
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -0600881\fBvoid png_set_strip_error_numbers (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIstrip_mode\fP\fB);\fP
882
883\fI\fB
884
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500885\fBvoid png_set_swap (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600886
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500887\fI\fB
888
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500889\fBvoid png_set_swap_alpha (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600890
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500891\fI\fB
892
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500893\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 -0600894
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500895\fI\fB
896
Glenn Randers-Pehrson8eb88332011-04-01 00:16:50 -0500897\fBvoid png_set_text_compression_level (png_structp \fP\fIpng_ptr\fP\fB, int \fIlevel\fP\fB);\fP
898
899\fI\fB
900
901\fBvoid png_set_text_compression_mem_level (png_structp \fP\fIpng_ptr\fP\fB, int \fImem_level\fP\fB);\fP
902
903\fI\fB
904
905\fBvoid png_set_text_compression_strategy (png_structp \fP\fIpng_ptr\fP\fB, int \fIstrategy\fP\fB);\fP
906
907\fI\fB
908
909\fBvoid png_set_text_compression_window_bits (png_structp \fP\fIpng_ptr\fP\fB, int \fIwindow_bits\fP\fB);\fP
910
911\fI\fB
912
913\fBvoid \fP\fIpng_set_text_compression_method\fP\fB, (png_structp \fP\fIpng_ptr\fP\fB, int \fImethod)\fP\fB);\fP
914
915\fI\fB
916
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500917\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 -0600918
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500919\fI\fB
920
Glenn Randers-Pehrsonf3c51e42011-01-15 10:25:25 -0600921\fBvoid png_set_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fItrans_alpha\fP\fB, int \fP\fInum_trans\fP\fB, png_color_16p \fItrans_color\fP\fB);\fP
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -0500922
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500923\fI\fB
924
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -0600925\fBvoid png_set_tRNS_to_alpha (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600926
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500927\fI\fB
928
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -0600929\fBpng_uint_32 png_set_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkp \fP\fIunknowns\fP\fB, int \fP\fInum\fP\fB, int \fIlocation\fP\fB);\fP
930
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500931\fI\fB
932
Glenn Randers-Pehrsonbb98bcb2011-01-22 16:27:39 -0600933\fBvoid png_set_unknown_chunk_location (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIchunk\fP\fB, int \fIlocation\fP\fB);\fP
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -0600934
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500935\fI\fB
936
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -0500937\fBvoid png_set_user_limits (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIuser_width_max\fP\fB, png_uint_32 \fIuser_height_max\fP\fB);\fP
938
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500939\fI\fB
940
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500941\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 -0600942
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500943\fI\fB
944
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500945\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 -0600946
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500947\fI\fB
948
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500949\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 -0600950
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500951\fI\fB
952
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500953\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 -0600954
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500955\fI\fB
956
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500957\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 -0600958
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500959\fI\fB
960
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500961\fBvoid png_start_read_image (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600962
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500963\fI\fB
964
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500965\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 -0600966
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500967\fI\fB
968
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500969\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 -0600970
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500971\fI\fB
972
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500973\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 -0600974
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500975\fI\fB
976
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500977\fBvoid png_write_chunk_end (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600978
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500979\fI\fB
980
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500981\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 -0600982
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500983\fI\fB
984
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500985\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 -0600986
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500987\fI\fB
988
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500989\fBvoid png_write_flush (png_structp \fIpng_ptr\fP\fB);\fP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -0600990
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500991\fI\fB
992
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500993\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 -0600994
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500995\fI\fB
996
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -0500997\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 -0600998
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -0500999\fI\fB
1000
Glenn Randers-Pehrson5379b241999-11-27 10:22:33 -06001001\fBvoid png_write_info_before_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
1002
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -05001003\fI\fB
1004
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -06001005\fBvoid png_write_png (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fItransforms\fP\fB, png_voidp \fIparams\fP\fB);\fP
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001006
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -05001007\fI\fB
1008
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05001009\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 -06001010
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -05001011\fI\fB
1012
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05001013\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 -06001014
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -05001015\fI\fB
1016
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -05001017\fBvoid png_write_sig (png_structp \fIpng_ptr\fP\fB);\fP
1018
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -05001019\fI\fB
1020
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001021\fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP
1022
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -05001023\fI\fB
1024
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05001025\fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP
1026
Glenn Randers-Pehrsonad81d712009-07-30 15:39:00 -05001027\fI\fB
1028
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06001029.SH DESCRIPTION
1030The
1031.I libpng
1032library supports encoding, decoding, and various manipulations of
1033the Portable Network Graphics (PNG) format image files. It uses the
1034.IR zlib(3)
1035compression library.
Glenn Randers-Pehrson557b2562010-10-17 12:55:04 -05001036Following is a copy of the libpng-manual.txt file that accompanies libpng.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001037.SH LIBPNG.TXT
Glenn Randers-Pehrson557b2562010-10-17 12:55:04 -05001038libpng-manual.txt - A description on how to use and modify libpng
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001039
Glenn Randers-Pehrson36251d32011-11-17 21:14:34 -06001040 libpng version 1.5.7beta05 - November 18, 2011
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001041 Updated and distributed by Glenn Randers-Pehrson
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -06001042 <glennrp at users.sourceforge.net>
Glenn Randers-Pehrson9f45c8e2011-01-15 19:35:03 -06001043 Copyright (c) 1998-2011 Glenn Randers-Pehrson
Glenn Randers-Pehrson037023b2009-06-24 10:27:36 -05001044
Glenn Randers-Pehrsonbfbf8652009-06-26 21:46:52 -05001045 This document is released under the libpng license.
Glenn Randers-Pehrsonc332bbc2009-06-25 13:43:50 -05001046 For conditions of distribution and use, see the disclaimer
Glenn Randers-Pehrson037023b2009-06-24 10:27:36 -05001047 and license in png.h
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001048
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05001049 Based on:
1050
Glenn Randers-Pehrson36251d32011-11-17 21:14:34 -06001051 libpng versions 0.97, January 1998, through 1.5.7beta05 - November 18, 2011
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05001052 Updated and distributed by Glenn Randers-Pehrson
Glenn Randers-Pehrson9f45c8e2011-01-15 19:35:03 -06001053 Copyright (c) 1998-2011 Glenn Randers-Pehrson
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001054
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06001055 libpng 1.0 beta 6 version 0.96 May 28, 1997
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001056 Updated and distributed by Andreas Dilger
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001057 Copyright (c) 1996, 1997 Andreas Dilger
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001058
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06001059 libpng 1.0 beta 2 - version 0.88 January 26, 1996
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001060 For conditions of distribution and use, see copyright
1061 notice in png.h. Copyright (c) 1995, 1996 Guy Eric
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06001062 Schalnat, Group 42, Inc.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001063
1064 Updated/rewritten per request in the libpng FAQ
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001065 Copyright (c) 1995, 1996 Frank J. T. Wojcik
1066 December 18, 1995 & January 20, 1996
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001067
1068.SH I. Introduction
1069
1070This file describes how to use and modify the PNG reference library
1071(known as libpng) for your own use. There are five sections to this
1072file: introduction, structures, reading, writing, and modification and
1073configuration notes for various special platforms. In addition to this
1074file, example.c is a good starting point for using the library, as
1075it is heavily commented and should include everything most people
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06001076will need. We assume that libpng is already installed; see the
1077INSTALL file for instructions on how to install libpng.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001078
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05001079For examples of libpng usage, see the files "example.c", "pngtest.c",
Glenn Randers-Pehrsonf210a052009-11-12 10:02:24 -06001080and the files in the "contrib" directory, all of which are included in
1081the libpng distribution.
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05001082
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001083Libpng was written as a companion to the PNG specification, as a way
1084of reducing the amount of time and effort it takes to support the PNG
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05001085file format in application programs.
1086
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -05001087The PNG specification (second edition), November 2003, is available as
1088a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2003 (E)) at
1089<http://www.w3.org/TR/2003/REC-PNG-20031110/
1090The W3C and ISO documents have identical technical content.
1091
1092The PNG-1.2 specification is available at
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05001093<http://www.libpng.org/pub/png/documents/>. It is technically equivalent
1094to the PNG specification (second edition) but has some additional material.
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05001095
1096The PNG-1.0 specification is available
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -05001097as RFC 2083 <http://www.libpng.org/pub/png/documents/> and as a
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05001098W3C Recommendation <http://www.w3.org/TR/REC.png.html>.
1099
1100Some additional chunks are described in the special-purpose public chunks
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -05001101documents at <http://www.libpng.org/pub/png/documents/>.
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05001102
1103Other information
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001104about PNG, and the latest version of libpng, can be found at the PNG home
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -05001105page, <http://www.libpng.org/pub/png/>.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001106
1107Most users will not have to modify the library significantly; advanced
1108users may want to modify it more. All attempts were made to make it as
1109complete as possible, while keeping the code easy to understand.
1110Currently, this library only supports C. Support for other languages
1111is being considered.
1112
1113Libpng has been designed to handle multiple sessions at one time,
1114to be easily modifiable, to be portable to the vast majority of
1115machines (ANSI, K&R, 16-, 32-, and 64-bit) available, and to be easy
1116to use. The ultimate goal of libpng is to promote the acceptance of
1117the PNG file format in whatever way possible. While there is still
1118work to be done (see the TODO file), libpng should cover the
1119majority of the needs of its users.
1120
1121Libpng uses zlib for its compression and decompression of PNG files.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001122Further information about zlib, and the latest version of zlib, can
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06001123be found at the zlib home page, <http://www.info-zip.org/pub/infozip/zlib/>.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001124The zlib compression utility is a general purpose utility that is
1125useful for more than PNG files, and can be used without libpng.
1126See the documentation delivered with zlib for more details.
1127You can usually find the source files for the zlib utility wherever you
1128find the libpng source files.
1129
1130Libpng is thread safe, provided the threads are using different
1131instances of the structures. Each thread should have its own
1132png_struct and png_info instances, and thus its own image.
1133Libpng does not protect itself against two threads using the
Glenn Randers-Pehrson56f63962008-10-06 10:16:17 -05001134same instance of a structure.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001135
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001136.SH II. Structures
1137
1138There are two main structures that are important to libpng, png_struct
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -05001139and png_info. Both are internal structures that are no longer exposed
1140in the libpng interface (as of libpng 1.5.0).
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001141
1142The png_info structure is designed to provide information about the
1143PNG file. At one time, the fields of png_info were intended to be
1144directly accessible to the user. However, this tended to cause problems
1145with applications using dynamically loaded libraries, and as a result
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001146a set of interface functions for png_info (the png_get_*() and png_set_*()
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05001147functions) was developed, and direct access to the png_info fields was
1148deprecated..
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05001149
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -05001150The png_struct structure is the object used by the library to decode a
1151single image. As of 1.5.0 this structure is also not exposed.
1152
1153Almost all libpng APIs require a pointer to a png_struct as the first argument.
1154Many (in particular the png_set and png_get APIs) also require a pointer
1155to png_info as the second argument. Some application visible macros
1156defined in png.h designed for basic data access (reading and writing
Glenn Randers-Pehrsona5e55472011-07-12 10:13:32 -05001157integers in the PNG format) don't take a png_info pointer, but it's almost
1158always safe to assume that a (png_struct*) has to be passed to call an API
1159function.
1160
1161You can have more than one png_info structure associated with an image,
1162as illustrated in pngtest.c, one for information valid prior to the
1163IDAT chunks and another (called "end_info" below) for things after them.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001164
1165The png.h header file is an invaluable reference for programming with libpng.
1166And while I'm on the topic, make sure you include the libpng header file:
1167
1168#include <png.h>
1169
Glenn Randers-Pehrsona5e55472011-07-12 10:13:32 -05001170and also (as of libpng-1.5.0) the zlib header file, if you need it:
1171
1172#include <zlib.h>
1173
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -05001174.SS Types
1175
1176The png.h header file defines a number of integral types used by the
1177APIs. Most of these are fairly obvious; for example types corresponding
1178to integers of particular sizes and types for passing color values.
1179
1180One exception is how non-integral numbers are handled. For application
1181convenience most APIs that take such numbers have C (double) arguments,
1182however internally PNG, and libpng, use 32 bit signed integers and encode
1183the value by multiplying by 100,000. As of libpng 1.5.0 a convenience
1184macro PNG_FP_1 is defined in png.h along with a type (png_fixed_point)
1185which is simply (png_int_32).
1186
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05001187All APIs that take (double) arguments also have a matching API that
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -05001188takes the corresponding fixed point integer arguments. The fixed point
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05001189API has the same name as the floating point one with "_fixed" appended.
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -05001190The actual range of values permitted in the APIs is frequently less than
1191the full range of (png_fixed_point) (-21474 to +21474). When APIs require
1192a non-negative argument the type is recorded as png_uint_32 above. Consult
1193the header file and the text below for more information.
1194
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06001195Special care must be take with sCAL chunk handling because the chunk itself
1196uses non-integral values encoded as strings containing decimal floating point
1197numbers. See the comments in the header file.
1198
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -05001199.SS Configuration
1200
1201The main header file function declarations are frequently protected by C
1202preprocessing directives of the form:
1203
1204 #ifdef PNG_feature_SUPPORTED
1205 declare-function
1206 #endif
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05001207 ...
1208 #ifdef PNG_feature_SUPPORTED
1209 use-function
1210 #endif
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -05001211
1212The library can be built without support for these APIs, although a
1213standard build will have all implemented APIs. Application programs
1214should check the feature macros before using an API for maximum
1215portability. From libpng 1.5.0 the feature macros set during the build
1216of libpng are recorded in the header file "pnglibconf.h" and this file
1217is always included by png.h.
1218
Glenn Randers-Pehrsona5e55472011-07-12 10:13:32 -05001219If you don't need to change the library configuration from the default, skip to
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06001220the next section ("Reading").
1221
1222Notice that some of the makefiles in the 'scripts' directory and (in 1.5.0) all
1223of the build project files in the 'projects' directory simply copy
1224scripts/pnglibconf.h.prebuilt to pnglibconf.h. This means that these build
1225systems do not permit easy auto-configuration of the library - they only
1226support the default configuration.
1227
1228The easiest way to make minor changes to the libpng configuration when
1229auto-configuration is supported is to add definitions to the command line
1230using (typically) CPPFLAGS. For example:
1231
1232CPPFLAGS=-DPNG_NO_FLOATING_ARITHMETIC
1233
1234will change the internal libpng math implementation for gamma correction and
1235other arithmetic calculations to fixed point, avoiding the need for fast
1236floating point support. The result can be seen in the generated pnglibconf.h -
1237make sure it contains the changed feature macro setting.
1238
1239If you need to make more extensive configuration changes - more than one or two
1240feature macro settings - you can either add -DPNG_USER_CONFIG to the build
1241command line and put a list of feature macro settings in pngusr.h or you can set
1242DFA_XTRA (a makefile variable) to a file containing the same information in the
1243form of 'option' settings.
1244
1245A. Changing pnglibconf.h
1246
1247A variety of methods exist to build libpng. Not all of these support
1248reconfiguration of pnglibconf.h. To reconfigure pnglibconf.h it must either be
1249rebuilt from scripts/pnglibconf.dfa using awk or it must be edited by hand.
1250
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05001251Hand editing is achieved by copying scripts/pnglibconf.h.prebuilt to
1252pnglibconf.h and changing the lines defining the supported features, paying
1253very close attention to the 'option' information in scripts/pnglibconf.dfa
1254that describes those features and their requirements. This is easy to get
1255wrong.
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06001256
1257B. Configuration using DFA_XTRA
1258
1259Rebuilding from pnglibconf.dfa is easy if a functioning 'awk', or a later
1260variant such as 'nawk' or 'gawk', is available. The configure build will
1261automatically find an appropriate awk and build pnglibconf.h.
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05001262The scripts/pnglibconf.mak file contains a set of make rules for doing the
1263same thing if configure is not used, and many of the makefiles in the scripts
1264directory use this approach.
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06001265
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05001266When rebuilding simply write a new file containing changed options and set
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06001267DFA_XTRA to the name of this file. This causes the build to append the new file
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05001268to the end of scripts/pnglibconf.dfa. The pngusr.dfa file should contain lines
1269of the following forms:
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06001270
1271everything = off
1272
1273This turns all optional features off. Include it at the start of pngusr.dfa to
1274make it easier to build a minimal configuration. You will need to turn at least
1275some features on afterward to enable either reading or writing code, or both.
1276
1277option feature on
1278option feature off
1279
1280Enable or disable a single feature. This will automatically enable other
1281features required by a feature that is turned on or disable other features that
1282require a feature which is turned off. Conflicting settings will cause an error
1283message to be emitted by awk.
1284
1285setting feature default value
1286
1287Changes the default value of setting 'feature' to 'value'. There are a small
1288number of settings listed at the top of pnglibconf.h, they are documented in the
1289source code. Most of these values have performance implications for the library
1290but most of them have no visible effect on the API. Some can also be overridden
1291from the API.
1292
Glenn Randers-Pehrsona5e55472011-07-12 10:13:32 -05001293This method of building a customized pnglibconf.h is illustrated in
1294contrib/pngminim/*. See the "$(PNGCONF):" target in the makefile and
1295pngusr.dfa in these directories.
1296
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06001297C. Configuration using PNG_USR_CONFIG
1298
1299If -DPNG_USR_CONFIG is added to the CFLAGS when pnglibconf.h is built the file
1300pngusr.h will automatically be included before the options in
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05001301scripts/pnglibconf.dfa are processed. Your pngusr.h file should contain only
1302macro definitions turning features on or off or setting settings.
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06001303
1304Apart from the global setting "everything = off" all the options listed above
1305can be set using macros in pngusr.h:
1306
1307#define PNG_feature_SUPPORTED
1308
1309is equivalent to:
1310
1311option feature on
1312
1313#define PNG_NO_feature
1314
1315is equivalent to:
1316
1317option feature off
1318
1319#define PNG_feature value
1320
1321is equivalent to:
1322
1323setting feature default value
1324
1325Notice that in both cases, pngusr.dfa and pngusr.h, the contents of the
1326pngusr file you supply override the contents of scripts/pnglibconf.dfa
1327
1328If confusing or incomprehensible behavior results it is possible to
1329examine the intermediate file pnglibconf.dfn to find the full set of
1330dependency information for each setting and option. Simply locate the
1331feature in the file and read the C comments that precede it.
1332
Glenn Randers-Pehrsona5e55472011-07-12 10:13:32 -05001333This method is also illustrated in the contrib/pngminim/* makefiles and
1334pngusr.h.
1335
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001336.SH III. Reading
1337
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001338We'll now walk you through the possible functions to call when reading
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001339in a PNG file sequentially, briefly explaining the syntax and purpose
1340of each one. See example.c and png.h for more detail. While
1341progressive reading is covered in the next section, you will still
1342need some of the functions discussed in this section to read a PNG
1343file.
1344
1345.SS Setup
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001346
1347You will want to do the I/O initialization(*) before you get into libpng,
1348so if it doesn't work, you don't have much to undo. Of course, you
1349will also want to insure that you are, in fact, dealing with a PNG
1350file. Libpng provides a simple check to see if a file is a PNG file.
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05001351To use it, pass in the first 1 to 8 bytes of the file to the function
Glenn Randers-Pehrson6a9c2ce2009-03-27 19:30:10 -05001352png_sig_cmp(), and it will return 0 (false) if the bytes match the
1353corresponding bytes of the PNG signature, or nonzero (true) otherwise.
1354Of course, the more bytes you pass in, the greater the accuracy of the
1355prediction.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001356
1357If you are intending to keep the file pointer open for use in libpng,
1358you must ensure you don't read more than 8 bytes from the beginning
1359of the file, and you also have to make a call to png_set_sig_bytes_read()
1360with the number of bytes you read from the beginning. Libpng will
1361then only check the bytes (if any) that your program didn't read.
1362
1363(*): If you are not using the standard I/O functions, you will need
1364to replace them with custom functions. See the discussion under
1365Customizing libpng.
1366
1367
1368 FILE *fp = fopen(file_name, "rb");
1369 if (!fp)
1370 {
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06001371 return (ERROR);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001372 }
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06001373
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001374 fread(header, 1, number, fp);
Glenn Randers-Pehrsonc9442291999-01-06 21:50:16 -06001375 is_png = !png_sig_cmp(header, 0, number);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06001376
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001377 if (!is_png)
1378 {
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06001379 return (NOT_PNG);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001380 }
1381
1382
1383Next, png_struct and png_info need to be allocated and initialized. In
1384order to ensure that the size of these structures is correct even with a
1385dynamically linked libpng, there are functions to initialize and
1386allocate the structures. We also pass the library version, optional
1387pointers to error handling functions, and a pointer to a data struct for
1388use by the error functions, if necessary (the pointer and functions can
1389be NULL if the default error handlers are to be used). See the section
1390on Changes to Libpng below regarding the old initialization functions.
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -05001391The structure allocation functions quietly return NULL if they fail to
1392create the structure, so your application should check for that.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001393
1394 png_structp png_ptr = png_create_read_struct
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06001395 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001396 user_error_fn, user_warning_fn);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06001397
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001398 if (!png_ptr)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06001399 return (ERROR);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001400
1401 png_infop info_ptr = png_create_info_struct(png_ptr);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06001402
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001403 if (!info_ptr)
1404 {
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06001405 png_destroy_read_struct(&png_ptr,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001406 (png_infopp)NULL, (png_infopp)NULL);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06001407 return (ERROR);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001408 }
1409
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -05001410If you want to use your own memory allocation routines,
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06001411use a libpng that was built with PNG_USER_MEM_SUPPORTED defined, and use
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -05001412png_create_read_struct_2() instead of png_create_read_struct():
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001413
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -05001414 png_structp png_ptr = png_create_read_struct_2
Glenn Randers-Pehrson20786be2011-04-20 22:20:40 -05001415 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -05001416 user_error_fn, user_warning_fn, (png_voidp)
1417 user_mem_ptr, user_malloc_fn, user_free_fn);
1418
1419The error handling routines passed to png_create_read_struct()
1420and the memory alloc/free routines passed to png_create_struct_2()
1421are only necessary if you are not using the libpng supplied error
1422handling and memory alloc/free functions.
1423
1424When libpng encounters an error, it expects to longjmp back
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06001425to your routine. Therefore, you will need to call setjmp and pass
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06001426your png_jmpbuf(png_ptr). If you read the file from different
John Bowlere6dc85b2011-04-27 14:47:15 -05001427routines, you will need to update the longjmp buffer every time you enter
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06001428a new routine that will call a png_*() function.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001429
1430See your documentation of setjmp/longjmp for your compiler for more
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06001431information on setjmp/longjmp. See the discussion on libpng error
1432handling in the Customizing Libpng section below for more information
1433on the libpng error handling. If an error occurs, and libpng longjmp's
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001434back to your setjmp, you will want to call png_destroy_read_struct() to
1435free any memory.
1436
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06001437 if (setjmp(png_jmpbuf(png_ptr)))
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001438 {
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06001439 png_destroy_read_struct(&png_ptr, &info_ptr,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001440 &end_info);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06001441 fclose(fp);
1442 return (ERROR);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001443 }
1444
Glenn Randers-Pehrson20786be2011-04-20 22:20:40 -05001445Pass (png_infopp)NULL instead of &end_info if you didn't create
1446an end_info structure.
1447
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001448If you would rather avoid the complexity of setjmp/longjmp issues,
Glenn Randers-Pehrson54ac9a92010-04-02 17:06:22 -05001449you can compile libpng with PNG_NO_SETJMP, in which case
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001450errors will result in a call to PNG_ABORT() which defaults to abort().
1451
Glenn Randers-Pehrson54ac9a92010-04-02 17:06:22 -05001452You can #define PNG_ABORT() to a function that does something
1453more useful than abort(), as long as your function does not
1454return.
1455
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06001456Now you need to set up the input code. The default for libpng is to
1457use the C function fread(). If you use this, you will need to pass a
1458valid FILE * in the function png_init_io(). Be sure that the file is
1459opened in binary mode. If you wish to handle reading data in another
1460way, you need not call the png_init_io() function, but you must then
1461implement the libpng I/O methods discussed in the Customizing Libpng
1462section below.
1463
1464 png_init_io(png_ptr, fp);
1465
1466If you had previously opened the file and read any of the signature from
1467the beginning in order to see if this was a PNG file, you need to let
1468libpng know that there are some bytes missing from the start of the file.
1469
1470 png_set_sig_bytes(png_ptr, number);
1471
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -06001472You can change the zlib compression buffer size to be used while
1473reading compressed data with
1474
1475 png_set_compression_buffer_size(png_ptr, buffer_size);
1476
1477where the default size is 8192 bytes. Note that the buffer size
1478is changed immediately and the buffer is reallocated immediately,
1479instead of setting a flag to be acted upon later.
1480
Glenn Randers-Pehrson9dd1cdf2011-01-06 21:42:36 -06001481If you want CRC errors to be handled in a different manner than
1482the default, use
1483
1484 png_set_crc_action(png_ptr, crit_action, ancil_action);
1485
1486The values for png_set_crc_action() say how libpng is to handle CRC errors in
1487ancillary and critical chunks, and whether to use the data contained
1488therein. Note that it is impossible to "discard" data in a critical
1489chunk.
1490
1491Choices for (int) crit_action are
1492 PNG_CRC_DEFAULT 0 error/quit
1493 PNG_CRC_ERROR_QUIT 1 error/quit
1494 PNG_CRC_WARN_USE 3 warn/use data
1495 PNG_CRC_QUIET_USE 4 quiet/use data
1496 PNG_CRC_NO_CHANGE 5 use the current value
1497
1498Choices for (int) ancil_action are
1499 PNG_CRC_DEFAULT 0 error/quit
1500 PNG_CRC_ERROR_QUIT 1 error/quit
1501 PNG_CRC_WARN_DISCARD 2 warn/discard data
1502 PNG_CRC_WARN_USE 3 warn/use data
1503 PNG_CRC_QUIET_USE 4 quiet/use data
1504 PNG_CRC_NO_CHANGE 5 use the current value
1505
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001506.SS Setting up callback code
1507
1508You can set up a callback function to handle any unknown chunks in the
1509input stream. You must supply the function
1510
Glenn Randers-Pehrson81ce8892011-01-24 08:04:37 -06001511 read_chunk_callback(png_structp png_ptr,
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001512 png_unknown_chunkp chunk);
1513 {
1514 /* The unknown chunk structure contains your
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05001515 chunk data, along with similar data for any other
1516 unknown chunks: */
1517
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001518 png_byte name[5];
1519 png_byte *data;
1520 png_size_t size;
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05001521
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06001522 /* Note that libpng has already taken care of
1523 the CRC handling */
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001524
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05001525 /* put your code here. Search for your chunk in the
1526 unknown chunk structure, process it, and return one
1527 of the following: */
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001528
1529 return (-n); /* chunk had an error */
1530 return (0); /* did not recognize */
1531 return (n); /* success */
1532 }
1533
1534(You can give your function another name that you like instead of
1535"read_chunk_callback")
1536
1537To inform libpng about your function, use
1538
1539 png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr,
1540 read_chunk_callback);
1541
1542This names not only the callback function, but also a user pointer that
1543you can retrieve with
1544
1545 png_get_user_chunk_ptr(png_ptr);
1546
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05001547If you call the png_set_read_user_chunk_fn() function, then all unknown
1548chunks will be saved when read, in case your callback function will need
1549one or more of them. This behavior can be changed with the
1550png_set_keep_unknown_chunks() function, described below.
1551
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06001552At this point, you can set up a callback function that will be
1553called after each row has been read, which you can use to control
1554a progress meter or the like. It's demonstrated in pngtest.c.
1555You must supply a function
1556
Glenn Randers-Pehrson81ce8892011-01-24 08:04:37 -06001557 void read_row_callback(png_structp png_ptr,
1558 png_uint_32 row, int pass);
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06001559 {
1560 /* put your code here */
1561 }
1562
1563(You can give it another name that you like instead of "read_row_callback")
1564
1565To inform libpng about your function, use
1566
1567 png_set_read_status_fn(png_ptr, read_row_callback);
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05001568
John Bowler59010e52011-02-16 06:16:31 -06001569When this function is called the row has already been completely processed and
1570the 'row' and 'pass' refer to the next row to be handled. For the
1571non-interlaced case the row that was just handled is simply one less than the
1572passed in row number, and pass will always be 0. For the interlaced case the
1573same applies unless the row value is 0, in which case the row just handled was
1574the last one from one of the preceding passes. Because interlacing may skip a
1575pass you cannot be sure that the preceding pass is just 'pass-1', if you really
1576need to know what the last pass is record (row,pass) from the callback and use
1577the last recorded value each time.
1578
1579As with the user transform you can find the output row using the
1580PNG_ROW_FROM_PASS_ROW macro.
1581
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001582.SS Unknown-chunk handling
1583
1584Now you get to set the way the library processes unknown chunks in the
1585input PNG stream. Both known and unknown chunks will be read. Normal
1586behavior is that known chunks will be parsed into information in
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05001587various info_ptr members while unknown chunks will be discarded. This
1588behavior can be wasteful if your application will never use some known
1589chunk types. To change this, you can call:
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001590
Glenn Randers-Pehrson272489d2004-08-04 06:34:52 -05001591 png_set_keep_unknown_chunks(png_ptr, keep,
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001592 chunk_list, num_chunks);
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05001593 keep - 0: default unknown chunk handling
1594 1: ignore; do not keep
Glenn Randers-Pehrsond029a752004-08-09 21:50:32 -05001595 2: keep only if safe-to-copy
1596 3: keep even if unsafe-to-copy
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06001597
Glenn Randers-Pehrsond029a752004-08-09 21:50:32 -05001598 You can use these definitions:
1599 PNG_HANDLE_CHUNK_AS_DEFAULT 0
1600 PNG_HANDLE_CHUNK_NEVER 1
1601 PNG_HANDLE_CHUNK_IF_SAFE 2
1602 PNG_HANDLE_CHUNK_ALWAYS 3
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06001603
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001604 chunk_list - list of chunks affected (a byte string,
1605 five bytes per chunk, NULL or '\0' if
1606 num_chunks is 0)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06001607
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001608 num_chunks - number of chunks affected; if 0, all
Glenn Randers-Pehrsondff799e2004-08-07 21:42:49 -05001609 unknown chunks are affected. If nonzero,
1610 only the chunks in the list are affected
1611
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001612Unknown chunks declared in this way will be saved as raw data onto a
1613list of png_unknown_chunk structures. If a chunk that is normally
1614known to libpng is named in the list, it will be handled as unknown,
1615according to the "keep" directive. If a chunk is named in successive
1616instances of png_set_keep_unknown_chunks(), the final instance will
Glenn Randers-Pehrsond029a752004-08-09 21:50:32 -05001617take precedence. The IHDR and IEND chunks should not be named in
1618chunk_list; if they are, libpng will process them normally anyway.
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05001619If you know that your application will never make use of some particular
1620chunks, use PNG_HANDLE_CHUNK_NEVER (or 1) as demonstrated below.
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001621
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05001622Here is an example of the usage of png_set_keep_unknown_chunks(),
1623where the private "vpAg" chunk will later be processed by a user chunk
1624callback function:
1625
1626 png_byte vpAg[5]={118, 112, 65, 103, (png_byte) '\0'};
1627
1628 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
1629 png_byte unused_chunks[]=
1630 {
1631 104, 73, 83, 84, (png_byte) '\0', /* hIST */
1632 105, 84, 88, 116, (png_byte) '\0', /* iTXt */
1633 112, 67, 65, 76, (png_byte) '\0', /* pCAL */
1634 115, 67, 65, 76, (png_byte) '\0', /* sCAL */
1635 115, 80, 76, 84, (png_byte) '\0', /* sPLT */
1636 116, 73, 77, 69, (png_byte) '\0', /* tIME */
1637 };
1638 #endif
1639
1640 ...
1641
1642 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
1643 /* ignore all unknown chunks: */
1644 png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06001645
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05001646 /* except for vpAg: */
1647 png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06001648
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05001649 /* also ignore unused known chunks: */
1650 png_set_keep_unknown_chunks(read_ptr, 1, unused_chunks,
1651 (int)sizeof(unused_chunks)/5);
1652 #endif
1653
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -05001654.SS User limits
1655
1656The PNG specification allows the width and height of an image to be as
1657large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns.
1658Since very few applications really need to process such large images,
1659we have imposed an arbitrary 1-million limit on rows and columns.
1660Larger images will be rejected immediately with a png_error() call. If
Glenn Randers-Pehrson0cb906d2011-06-11 14:22:22 -05001661you wish to change this limit, you can use
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -05001662
1663 png_set_user_limits(png_ptr, width_max, height_max);
1664
1665to set your own limits, or use width_max = height_max = 0x7fffffffL
1666to allow all valid dimensions (libpng may reject some very large images
1667anyway because of potential buffer overflow conditions).
1668
1669You should put this statement after you create the PNG structure and
1670before calling png_read_info(), png_read_png(), or png_process_data().
Glenn Randers-Pehrsoncc277082011-06-10 21:17:34 -05001671
1672When writing a PNG datastream, put this statement before calling
1673png_write_info() or png_write_png().
1674
Glenn Randers-Pehrson800d1e92008-08-20 17:25:21 -05001675If you need to retrieve the limits that are being applied, use
1676
1677 width_max = png_get_user_width_max(png_ptr);
1678 height_max = png_get_user_height_max(png_ptr);
1679
1680The PNG specification sets no limit on the number of ancillary chunks
1681allowed in a PNG datastream. You can impose a limit on the total number
1682of sPLT, tEXt, iTXt, zTXt, and unknown chunks that will be stored, with
1683
1684 png_set_chunk_cache_max(png_ptr, user_chunk_cache_max);
1685
1686where 0x7fffffffL means unlimited. You can retrieve this limit with
1687
1688 chunk_cache_max = png_get_chunk_cache_max(png_ptr);
1689
Glenn Randers-Pehrson8f5846f2009-10-31 21:31:08 -05001690This limit also applies to the number of buffers that can be allocated
1691by png_decompress_chunk() while decompressing iTXt, zTXt, and iCCP chunks.
1692
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -06001693You can also set a limit on the amount of memory that a compressed chunk
1694other than IDAT can occupy, with
1695
1696 png_set_chunk_malloc_max(png_ptr, user_chunk_malloc_max);
1697
1698and you can retrieve the limit with
1699
1700 chunk_malloc_max = png_get_chunk_malloc_max(png_ptr);
1701
1702Any chunks that would cause either of these limits to be exceeded will
1703be ignored.
1704
John Bowlercb0b2962011-05-12 21:48:29 -05001705.SS Information about your system
1706
1707If you intend to display the PNG or to incorporate it in other image data you
1708need to tell libpng information about your display or drawing surface so that
1709libpng can convert the values in the image to match the display.
1710
Glenn Randers-Pehrson733b1312011-06-15 13:21:01 -05001711From libpng-1.5.4 this information can be set before reading the PNG file
John Bowlercb0b2962011-05-12 21:48:29 -05001712header. In earlier versions png_set_gamma() existed but behaved incorrectly if
1713called before the PNG file header had been read and png_set_alpha_mode() did not
1714exist.
1715
Glenn Randers-Pehrson733b1312011-06-15 13:21:01 -05001716If you need to support versions prior to libpng-1.5.4 test the version number
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05001717as illustrated below using "PNG_LIBPNG_VER >= 10504" and follow the procedures
1718described in the appropriate manual page.
John Bowlercb0b2962011-05-12 21:48:29 -05001719
1720You give libpng the encoding expected by your system expressed as a 'gamma'
1721value. You can also specify a default encoding for the PNG file in
1722case the required information is missing from the file. By default libpng
1723assumes that the PNG data matches your system, to keep this default call:
1724
1725 png_set_gamma(png_ptr, screen_gamma, 1/screen_gamma/*file gamma*/);
1726
1727or you can use the fixed point equivalent:
1728
1729 png_set_gamma_fixed(png_ptr, PNG_FP_1*screen_gamma, PNG_FP_1/screen_gamma);
1730
Glenn Randers-Pehrson95ba4172011-09-08 12:21:42 -05001731If you don't know the gamma for your system it is probably 2.2 - a good
John Bowlercb0b2962011-05-12 21:48:29 -05001732approximation to the IEC standard for display systems (sRGB). If images are
1733too contrasty or washed out you got the value wrong - check your system
1734documentation!
1735
1736Many systems permit the system gamma to be changed via a lookup table in the
1737display driver, a few systems, including older Macs, change the response by
Glenn Randers-Pehrson733b1312011-06-15 13:21:01 -05001738default. As of 1.5.4 three special values are available to handle common
John Bowlercb0b2962011-05-12 21:48:29 -05001739situations:
1740
1741 PNG_DEFAULT_sRGB: Indicates that the system conforms to the IEC 61966-2-1
1742 standard. This matches almost all systems.
1743 PNG_GAMMA_MAC_18: Indicates that the system is an older (pre Mac OS 10.6)
1744 Apple Macintosh system with the default settings.
1745 PNG_GAMMA_LINEAR: Just the fixed point value for 1.0 - indicates that the
1746 system expects data with no gamma encoding.
1747
1748You would use the linear (unencoded) value if you need to process the pixel
1749values further because this avoids the need to decode and reencode each
1750component value whenever arithmetic is performed. A lot of graphics software
1751uses linear values for this reason, often with higher precision component values
1752to preserve overall accuracy.
1753
1754The second thing you may need to tell libpng about is how your system handles
1755alpha channel information. Some, but not all, PNG files contain an alpha
1756channel. To display these files correctly you need to compose the data onto a
1757suitable background, as described in the PNG specification.
1758
1759Libpng only supports composing onto a single color (using png_set_background;
Glenn Randers-Pehrson95ba4172011-09-08 12:21:42 -05001760see below). Otherwise you must do the composition yourself and, in this case,
John Bowlercb0b2962011-05-12 21:48:29 -05001761you may need to call png_set_alpha_mode:
1762
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05001763#if PNG_LIBPNG_VER >= 10504
John Bowlercb0b2962011-05-12 21:48:29 -05001764 png_set_alpha_mode(png_ptr, mode, screen_gamma);
Glenn Randers-Pehrson95ba4172011-09-08 12:21:42 -05001765#else
1766 png_set_gamma(png_ptr, screen_gamma, 1.0/screen_gamma);
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05001767#endif
John Bowlercb0b2962011-05-12 21:48:29 -05001768
Glenn Randers-Pehrson95ba4172011-09-08 12:21:42 -05001769The screen_gamma value is the same as the argument to png_set_gamma; however,
1770how it affects the output depends on the mode. png_set_alpha_mode() sets the
1771file gamma default to 1/screen_gamma, so normally you don't need to call
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001772png_set_gamma. If you need different defaults call png_set_gamma() before
1773png_set_alpha_mode() - if you call it after it will override the settings made
1774by png_set_alpha_mode().
John Bowlercb0b2962011-05-12 21:48:29 -05001775
1776The mode is as follows:
1777
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001778 PNG_ALPHA_PNG: The data is encoded according to the PNG specification. Red,
1779green and blue, or gray, components are gamma encoded color
1780values and are not premultiplied by the alpha value. The
1781alpha value is a linear measure of the contribution of the
1782pixel to the corresponding final output pixel.
John Bowlercb0b2962011-05-12 21:48:29 -05001783
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001784You should normally use this format if you intend to perform
1785color correction on the color values; most, maybe all, color
1786correction software has no handling for the alpha channel and,
1787anyway, the math to handle pre-multiplied component values is
1788unnecessarily complex.
John Bowlercb0b2962011-05-12 21:48:29 -05001789
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001790Before you do any arithmetic on the component values you need
1791to remove the gamma encoding and multiply out the alpha
1792channel. See the PNG specification for more detail. It is
1793important to note that when an image with an alpha channel is
1794scaled, linear encoded, pre-multiplied component values must
1795be used!
John Bowlercb0b2962011-05-12 21:48:29 -05001796
1797The remaining modes assume you don't need to do any further color correction or
Glenn Randers-Pehrson95ba4172011-09-08 12:21:42 -05001798that if you do, your color correction software knows all about alpha (it
John Bowlercb0b2962011-05-12 21:48:29 -05001799probably doesn't!)
1800
Glenn Randers-Pehrson95ba4172011-09-08 12:21:42 -05001801 PNG_ALPHA_STANDARD: The data libpng produces
1802is encoded in the standard way
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001803assumed by most correctly written graphics software.
1804The gamma encoding will be removed by libpng and the
1805linear component values will be pre-multiplied by the
1806alpha channel.
John Bowlercb0b2962011-05-12 21:48:29 -05001807
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001808With this format the final image must be re-encoded to
1809match the display gamma before the image is displayed.
1810If your system doesn't do that, yet still seems to
1811perform arithmetic on the pixels without decoding them,
1812it is broken - check out the modes below.
John Bowlercb0b2962011-05-12 21:48:29 -05001813
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001814With PNG_ALPHA_STANDARD libpng always produces linear
1815component values, whatever screen_gamma you supply. The
1816screen_gamma value is, however, used as a default for
1817the file gamma if the PNG file has no gamma information.
John Bowlercb0b2962011-05-12 21:48:29 -05001818
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001819If you call png_set_gamma() after png_set_alpha_mode() you
1820will override the linear encoding. Instead the
1821pre-multiplied pixel values will be gamma encoded but
1822the alpha channel will still be linear. This may
1823actually match the requirements of some broken software,
1824but it is unlikely.
John Bowlercb0b2962011-05-12 21:48:29 -05001825
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001826While linear 8-bit data is often used it has
1827insufficient precision for any image with a reasonable
1828dynamic range. To avoid problems, and if your software
1829supports it, use png_set_expand_16() to force all
1830components to 16 bits.
John Bowlercb0b2962011-05-12 21:48:29 -05001831
Glenn Randers-Pehrson95ba4172011-09-08 12:21:42 -05001832 PNG_ALPHA_OPTIMIZED: This mode is the same
1833as PNG_ALPHA_STANDARD except that
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001834completely opaque pixels are gamma encoded according to
1835the screen_gamma value. Pixels with alpha less than 1.0
1836will still have linear components.
John Bowlercb0b2962011-05-12 21:48:29 -05001837
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001838Use this format if you have control over your
1839compositing software and do don't do other arithmetic
1840(such as scaling) on the data you get from libpng. Your
1841compositing software can simply copy opaque pixels to
1842the output but still has linear values for the
1843non-opaque pixels.
John Bowlercb0b2962011-05-12 21:48:29 -05001844
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001845In normal compositing, where the alpha channel encodes
1846partial pixel coverage (as opposed to broad area
1847translucency), the inaccuracies of the 8-bit
1848representation of non-opaque pixels are irrelevant.
John Bowlercb0b2962011-05-12 21:48:29 -05001849
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001850You can also try this format if your software is broken;
1851it might look better.
John Bowlercb0b2962011-05-12 21:48:29 -05001852
Glenn Randers-Pehrson95ba4172011-09-08 12:21:42 -05001853 PNG_ALPHA_BROKEN: This is PNG_ALPHA_STANDARD;
1854however, all component values,
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001855including the alpha channel are gamma encoded. This is
1856an appropriate format to try if your software, or more
Glenn Randers-Pehrson95ba4172011-09-08 12:21:42 -05001857likely hardware, is totally broken, i.e., if it performs
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001858linear arithmetic directly on gamma encoded values.
John Bowlercb0b2962011-05-12 21:48:29 -05001859
1860In most cases of broken software or hardware the bug in the final display
1861manifests as a subtle halo around composited parts of the image. You may not
1862even perceive this as a halo; the composited part of the image may simply appear
1863separate from the background, as though it had been cut out of paper and pasted
1864on afterward.
1865
1866If you don't have to deal with bugs in software or hardware, or if you can fix
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001867them, there are three recommended ways of using png_set_alpha_mode():
John Bowlercb0b2962011-05-12 21:48:29 -05001868
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001869 png_set_alpha_mode(png_ptr, PNG_ALPHA_PNG,
1870 screen_gamma);
John Bowlercb0b2962011-05-12 21:48:29 -05001871
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001872You can do color correction on the result (libpng does not currently
Glenn Randers-Pehrson95ba4172011-09-08 12:21:42 -05001873support color correction internally). When you handle the alpha channel
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001874you need to undo the gamma encoding and multiply out the alpha.
1875
1876 png_set_alpha_mode(png_ptr, PNG_ALPHA_STANDARD,
1877 screen_gamma);
John Bowlercb0b2962011-05-12 21:48:29 -05001878 png_set_expand_16(png_ptr);
John Bowlercb0b2962011-05-12 21:48:29 -05001879
Glenn Randers-Pehrson95ba4172011-09-08 12:21:42 -05001880If you are using the high level interface, don't call png_set_expand_16();
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001881instead pass PNG_TRANSFORM_EXPAND_16 to the interface.
John Bowlercb0b2962011-05-12 21:48:29 -05001882
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001883With this mode you can't do color correction, but you can do arithmetic,
1884including composition and scaling, on the data without further processing.
1885
1886 png_set_alpha_mode(png_ptr, PNG_ALPHA_OPTIMIZED,
1887 screen_gamma);
1888
1889You can avoid the expansion to 16-bit components with this mode, but you
1890lose the ability to scale the image or perform other linear arithmetic.
1891All you can do is compose the result onto a matching output. Since this
Glenn Randers-Pehrson95ba4172011-09-08 12:21:42 -05001892mode is libpng-specific you also need to write your own composition
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001893software.
John Bowlercb0b2962011-05-12 21:48:29 -05001894
1895If you don't need, or can't handle, the alpha channel you can call
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001896png_set_background() to remove it by compositing against a fixed color. Don't
1897call png_set_strip_alpha() to do this - it will leave spurious pixel values in
John Bowlercb0b2962011-05-12 21:48:29 -05001898transparent parts of this image.
1899
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05001900 png_set_background(png_ptr, &background_color,
1901 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1);
John Bowlercb0b2962011-05-12 21:48:29 -05001902
1903The background_color is an RGB or grayscale value according to the data format
1904libpng will produce for you. Because you don't yet know the format of the PNG
Glenn Randers-Pehrson95ba4172011-09-08 12:21:42 -05001905file, if you call png_set_background at this point you must arrange for the
John Bowlercb0b2962011-05-12 21:48:29 -05001906format produced by libpng to always have 8-bit or 16-bit components and then
1907store the color as an 8-bit or 16-bit color as appropriate. The color contains
1908separate gray and RGB component values, so you can let libpng produce gray or
1909RGB output according to the input format, but low bit depth grayscale images
Glenn Randers-Pehrsonab389792011-07-09 19:35:22 -05001910must always be converted to at least 8-bit format. (Even though low bit depth
John Bowlercb0b2962011-05-12 21:48:29 -05001911grayscale images can't have an alpha channel they can have a transparent
1912color!)
1913
1914You set the transforms you need later, either as flags to the high level
1915interface or libpng API calls for the low level interface. For reference the
Glenn Randers-Pehrson733b1312011-06-15 13:21:01 -05001916settings and API calls required are:
John Bowlercb0b2962011-05-12 21:48:29 -05001917
19188-bit values:
Glenn Randers-Pehrsonfb29e512011-06-17 20:38:24 -05001919 PNG_TRANSFORM_SCALE_16 | PNG_EXPAND
1920 png_set_expand(png_ptr); png_set_scale_16(png_ptr);
John Bowlercb0b2962011-05-12 21:48:29 -05001921
Glenn Randers-Pehrson733b1312011-06-15 13:21:01 -05001922 If you must get exactly the same inaccurate results
1923 produced by default in versions prior to libpng-1.5.4,
Glenn Randers-Pehrsonfb29e512011-06-17 20:38:24 -05001924 use PNG_TRANSFORM_STRIP_16 and png_set_strip_16(png_ptr)
Glenn Randers-Pehrson733b1312011-06-15 13:21:01 -05001925 instead.
1926
John Bowlercb0b2962011-05-12 21:48:29 -0500192716-bit values:
1928 PNG_TRANSFORM_EXPAND_16
1929 png_set_expand_16(png_ptr);
1930
1931In either case palette image data will be expanded to RGB. If you just want
1932color data you can add PNG_TRANSFORM_GRAY_TO_RGB or png_set_gray_to_rgb(png_ptr)
1933to the list.
1934
1935Calling png_set_background before the PNG file header is read will not work
Glenn Randers-Pehrson733b1312011-06-15 13:21:01 -05001936prior to libpng-1.5.4. Because the failure may result in unexpected warnings or
John Bowlercb0b2962011-05-12 21:48:29 -05001937errors it is therefore much safer to call png_set_background after the head has
Glenn Randers-Pehrson733b1312011-06-15 13:21:01 -05001938been read. Unfortunately this means that prior to libpng-1.5.4 it cannot be
John Bowlercb0b2962011-05-12 21:48:29 -05001939used with the high level interface.
1940
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001941.SS The high-level read interface
1942
1943At this point there are two ways to proceed; through the high-level
1944read interface, or through a sequence of low-level read operations.
1945You can use the high-level interface if (a) you are willing to read
1946the entire image into memory, and (b) the input transformations
1947you want to do are limited to the following set:
1948
1949 PNG_TRANSFORM_IDENTITY No transformation
Glenn Randers-Pehrsonfb29e512011-06-17 20:38:24 -05001950 PNG_TRANSFORM_SCALE_16 Strip 16-bit samples to
1951 8-bit accurately
1952 PNG_TRANSFORM_STRIP_16 Chop 16-bit samples to
1953 8-bit less accurately
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001954 PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06001955 PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit
1956 samples to bytes
1957 PNG_TRANSFORM_PACKSWAP Change order of packed
1958 pixels to LSB first
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001959 PNG_TRANSFORM_EXPAND Perform set_expand()
1960 PNG_TRANSFORM_INVERT_MONO Invert monochrome images
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06001961 PNG_TRANSFORM_SHIFT Normalize pixels to the
1962 sBIT depth
1963 PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA
1964 to BGRA
1965 PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA
1966 to AG
1967 PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity
1968 to transparency
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001969 PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples
Glenn Randers-Pehrson99708d52009-06-29 17:30:00 -05001970 PNG_TRANSFORM_GRAY_TO_RGB Expand grayscale samples
1971 to RGB (or GA to RGBA)
John Bowlera9b34192011-05-08 19:46:51 -05001972 PNG_TRANSFORM_EXPAND_16 Expand samples to 16 bits
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001973
1974(This excludes setting a background color, doing gamma transformation,
Glenn Randers-Pehrson3cd7cff2010-04-16 19:27:08 -05001975quantizing, and setting filler.) If this is the case, simply do this:
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001976
1977 png_read_png(png_ptr, info_ptr, png_transforms, NULL)
1978
Glenn Randers-Pehrsonf210a052009-11-12 10:02:24 -06001979where png_transforms is an integer containing the bitwise OR of some
1980set of transformation flags. This call is equivalent to png_read_info(),
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001981followed the set of transformations indicated by the transform mask,
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -05001982then png_read_image(), and finally png_read_end().
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06001983
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -05001984(The final parameter of this call is not yet used. Someday it might point
1985to transformation parameters required by some future input transform.)
1986
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -05001987You must use png_transforms and not call any png_set_transform() functions
1988when you use png_read_png().
1989
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -05001990After you have called png_read_png(), you can retrieve the image data
1991with
1992
1993 row_pointers = png_get_rows(png_ptr, info_ptr);
1994
1995where row_pointers is an array of pointers to the pixel data for each row:
1996
1997 png_bytep row_pointers[height];
1998
1999If you know your image size and pixel size ahead of time, you can allocate
2000row_pointers prior to calling png_read_png() with
2001
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05002002 if (height > PNG_UINT_32_MAX/png_sizeof(png_byte))
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -05002003 png_error (png_ptr,
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002004 "Image is too tall to process in memory");
2005
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -05002006 if (width > PNG_UINT_32_MAX/pixel_size)
2007 png_error (png_ptr,
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002008 "Image is too wide to process in memory");
2009
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002010 row_pointers = png_malloc(png_ptr,
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002011 height*png_sizeof(png_bytep));
2012
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05002013 for (int i=0; i<height, i++)
2014 row_pointers[i]=NULL; /* security precaution */
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002015
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -05002016 for (int i=0; i<height, i++)
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002017 row_pointers[i]=png_malloc(png_ptr,
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002018 width*pixel_size);
2019
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06002020 png_set_rows(png_ptr, info_ptr, &row_pointers);
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -05002021
2022Alternatively you could allocate your image in one big block and define
2023row_pointers[i] to point into the proper places in your block.
2024
2025If you use png_set_rows(), the application is responsible for freeing
2026row_pointers (and row_pointers[i], if they were separately allocated).
2027
2028If you don't allocate row_pointers ahead of time, png_read_png() will
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002029do it, and it'll be free'ed by libpng when you call png_destroy_*().
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06002030
2031.SS The low-level read interface
2032
2033If you are going the low-level route, you are now ready to read all
2034the file information up to the actual image data. You do this with a
2035call to png_read_info().
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002036
2037 png_read_info(png_ptr, info_ptr);
2038
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06002039This will process all chunks up to but not including the image data.
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06002040
John Bowlercb0b2962011-05-12 21:48:29 -05002041This also copies some of the data from the PNG file into the decode structure
2042for use in later transformations. Important information copied in is:
2043
20441) The PNG file gamma from the gAMA chunk. This overwrites the default value
2045provided by an earlier call to png_set_gamma or png_set_alpha_mode.
2046
Glenn Randers-Pehrson733b1312011-06-15 13:21:01 -050020472) Prior to libpng-1.5.4 the background color from a bKGd chunk. This
John Bowlercb0b2962011-05-12 21:48:29 -05002048damages the information provided by an earlier call to png_set_background
Glenn Randers-Pehrsonab389792011-07-09 19:35:22 -05002049resulting in unexpected behavior. Libpng-1.5.4 no longer does this.
John Bowlercb0b2962011-05-12 21:48:29 -05002050
20513) The number of significant bits in each component value. Libpng uses this to
2052optimize gamma handling by reducing the internal lookup table sizes.
2053
20544) The transparent color information from a tRNS chunk. This can be modified by
2055a later call to png_set_tRNS.
2056
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06002057.SS Querying the info structure
2058
2059Functions are used to get the information from the info_ptr once it
2060has been read. Note that these fields may not be completely filled
2061in until png_read_end() has read the chunk data following the image.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002062
2063 png_get_IHDR(png_ptr, info_ptr, &width, &height,
2064 &bit_depth, &color_type, &interlace_type,
Glenn Randers-Pehrson408b4212000-12-18 09:33:57 -06002065 &compression_type, &filter_method);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002066
2067 width - holds the width of the image
2068 in pixels (up to 2^31).
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002069
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002070 height - holds the height of the image
2071 in pixels (up to 2^31).
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002072
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002073 bit_depth - holds the bit depth of one of the
2074 image channels. (valid values are
2075 1, 2, 4, 8, 16 and depend also on
2076 the color_type. See also
2077 significant bits (sBIT) below).
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002078
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002079 color_type - describes which color/alpha channels
2080 are present.
2081 PNG_COLOR_TYPE_GRAY
2082 (bit depths 1, 2, 4, 8, 16)
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002083 PNG_COLOR_TYPE_GRAY_ALPHA
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002084 (bit depths 8, 16)
2085 PNG_COLOR_TYPE_PALETTE
2086 (bit depths 1, 2, 4, 8)
2087 PNG_COLOR_TYPE_RGB
2088 (bit_depths 8, 16)
2089 PNG_COLOR_TYPE_RGB_ALPHA
2090 (bit_depths 8, 16)
2091
2092 PNG_COLOR_MASK_PALETTE
2093 PNG_COLOR_MASK_COLOR
2094 PNG_COLOR_MASK_ALPHA
2095
Glenn Randers-Pehrson2cb633b2011-01-21 08:31:29 -06002096 interlace_type - (PNG_INTERLACE_NONE or
2097 PNG_INTERLACE_ADAM7)
2098
2099 compression_type - (must be PNG_COMPRESSION_TYPE_BASE
2100 for PNG 1.0)
2101
Glenn Randers-Pehrson408b4212000-12-18 09:33:57 -06002102 filter_method - (must be PNG_FILTER_TYPE_BASE
2103 for PNG 1.0, and can also be
2104 PNG_INTRAPIXEL_DIFFERENCING if
2105 the PNG datastream is embedded in
2106 a MNG-1.0 datastream)
Glenn Randers-Pehrson0bfb58f2009-09-30 23:07:22 -05002107
2108 Any or all of interlace_type, compression_type, or
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002109 filter_method can be NULL if you are
2110 not interested in their values.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002111
Glenn Randers-Pehrson0bfb58f2009-09-30 23:07:22 -05002112 Note that png_get_IHDR() returns 32-bit data into
2113 the application's width and height variables.
2114 This is an unsafe situation if these are 16-bit
2115 variables. In such situations, the
2116 png_get_image_width() and png_get_image_height()
2117 functions described below are safer.
2118
2119 width = png_get_image_width(png_ptr,
2120 info_ptr);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002121
Glenn Randers-Pehrson0bfb58f2009-09-30 23:07:22 -05002122 height = png_get_image_height(png_ptr,
2123 info_ptr);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002124
Glenn Randers-Pehrson0bfb58f2009-09-30 23:07:22 -05002125 bit_depth = png_get_bit_depth(png_ptr,
2126 info_ptr);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002127
Glenn Randers-Pehrson0bfb58f2009-09-30 23:07:22 -05002128 color_type = png_get_color_type(png_ptr,
2129 info_ptr);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002130
Glenn Randers-Pehrson2cb633b2011-01-21 08:31:29 -06002131 interlace_type = png_get_interlace_type(png_ptr,
Glenn Randers-Pehrson0bfb58f2009-09-30 23:07:22 -05002132 info_ptr);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002133
Glenn Randers-Pehrson0bfb58f2009-09-30 23:07:22 -05002134 compression_type = png_get_compression_type(png_ptr,
2135 info_ptr);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002136
Glenn Randers-Pehrson2cb633b2011-01-21 08:31:29 -06002137 filter_method = png_get_filter_type(png_ptr,
Glenn Randers-Pehrson0bfb58f2009-09-30 23:07:22 -05002138 info_ptr);
2139
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002140 channels = png_get_channels(png_ptr, info_ptr);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002141
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002142 channels - number of channels of info for the
2143 color type (valid values are 1 (GRAY,
2144 PALETTE), 2 (GRAY_ALPHA), 3 (RGB),
2145 4 (RGB_ALPHA or RGB + filler byte))
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002146
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002147 rowbytes = png_get_rowbytes(png_ptr, info_ptr);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002148
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002149 rowbytes - number of bytes needed to hold a row
2150
2151 signature = png_get_signature(png_ptr, info_ptr);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002152
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002153 signature - holds the signature read from the
2154 file (if any). The data is kept in
2155 the same offset it would be if the
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002156 whole signature were read (i.e. if an
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002157 application had already read in 4
2158 bytes of signature before starting
2159 libpng, the remaining 4 bytes would
2160 be in signature[4] through signature[7]
2161 (see png_set_sig_bytes())).
2162
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002163These are also important, but their validity depends on whether the chunk
2164has been read. The png_get_valid(png_ptr, info_ptr, PNG_INFO_<chunk>) and
2165png_get_<chunk>(png_ptr, info_ptr, ...) functions return non-zero if the
2166data has been read, or zero if it is missing. The parameters to the
Glenn Randers-Pehrsonf210a052009-11-12 10:02:24 -06002167png_get_<chunk> are set directly if they are simple data types, or a
2168pointer into the info_ptr is returned for any complex types.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002169
2170 png_get_PLTE(png_ptr, info_ptr, &palette,
2171 &num_palette);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002172
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002173 palette - the palette for the file
2174 (array of png_color)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002175
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002176 num_palette - number of entries in the palette
2177
Glenn Randers-Pehrson8d0bc0f2011-01-25 22:15:58 -06002178 png_get_gAMA(png_ptr, info_ptr, &file_gamma);
Glenn Randers-Pehrson27742382011-01-27 09:37:34 -06002179 png_get_gAMA_fixed(png_ptr, info_ptr, &int_file_gamma);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002180
Glenn Randers-Pehrson8d0bc0f2011-01-25 22:15:58 -06002181 file_gamma - the gamma at which the file is
2182 written (PNG_INFO_gAMA)
2183
2184 int_file_gamma - 100,000 times the gamma at which the
2185 file is written
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002186
John Bowlerbbd17bd2011-08-25 17:48:18 -05002187 png_get_cHRM(png_ptr, info_ptr, &white_x, &white_y, &red_x, &red_y,
2188 &green_x, &green_y, &blue_x, &blue_y)
2189 png_get_cHRM_XYZ(png_ptr, info_ptr, &red_X, &red_Y, &red_Z, &green_X,
2190 &green_Y, &green_Z, &blue_X, &blue_Y, &blue_Z)
2191 png_get_cHRM_fixed(png_ptr, info_ptr, &int_white_x, &int_white_y,
2192 &int_red_x, &int_red_y, &int_green_x, &int_green_y,
2193 &int_blue_x, &int_blue_y)
2194 png_get_cHRM_XYZ_fixed(png_ptr, info_ptr, &int_red_X, &int_red_Y,
2195 &int_red_Z, &int_green_X, &int_green_Y, &int_green_Z,
2196 &int_blue_X, &int_blue_Y, &int_blue_Z)
2197
2198 {white,red,green,blue}_{x,y}
2199 A color space encoding specified using the chromaticities
2200 of the end points and the white point. (PNG_INFO_cHRM)
2201
2202 {red,green,blue}_{X,Y,Z}
2203 A color space encoding specified using the encoding end
2204 points - the CIE tristimulus specification of the intended
2205 color of the red, green and blue channels in the PNG RGB
2206 data. The white point is simply the sum of the three end
2207 points. (PNG_INFO_cHRM)
2208
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002209 png_get_sRGB(png_ptr, info_ptr, &srgb_intent);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002210
Glenn Randers-Pehrson27742382011-01-27 09:37:34 -06002211 file_srgb_intent - the rendering intent (PNG_INFO_sRGB)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002212 The presence of the sRGB chunk
2213 means that the pixel data is in the
2214 sRGB color space. This chunk also
2215 implies specific values of gAMA and
2216 cHRM.
2217
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002218 png_get_iCCP(png_ptr, info_ptr, &name,
2219 &compression_type, &profile, &proflen);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002220
Glenn Randers-Pehrson4a5a1ec2011-01-15 11:43:28 -06002221 name - The profile name.
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002222
Glenn Randers-Pehrson4a5a1ec2011-01-15 11:43:28 -06002223 compression_type - The compression type; always
2224 PNG_COMPRESSION_TYPE_BASE for PNG 1.0.
2225 You may give NULL to this argument to
2226 ignore it.
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002227
Glenn Randers-Pehrson4a5a1ec2011-01-15 11:43:28 -06002228 profile - International Color Consortium color
2229 profile data. May contain NULs.
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002230
Glenn Randers-Pehrson4a5a1ec2011-01-15 11:43:28 -06002231 proflen - length of profile data in bytes.
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06002232
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002233 png_get_sBIT(png_ptr, info_ptr, &sig_bit);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002234
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002235 sig_bit - the number of significant bits for
2236 (PNG_INFO_sBIT) each of the gray,
2237 red, green, and blue channels,
2238 whichever are appropriate for the
2239 given color type (png_color_16)
2240
Glenn Randers-Pehrson866b62a2009-08-08 16:33:14 -05002241 png_get_tRNS(png_ptr, info_ptr, &trans_alpha,
2242 &num_trans, &trans_color);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002243
Glenn Randers-Pehrson866b62a2009-08-08 16:33:14 -05002244 trans_alpha - array of alpha (transparency)
2245 entries for palette (PNG_INFO_tRNS)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002246
Glenn Randers-Pehrsonf3c51e42011-01-15 10:25:25 -06002247 num_trans - number of transparent entries
2248 (PNG_INFO_tRNS)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002249
Glenn Randers-Pehrson56f63962008-10-06 10:16:17 -05002250 trans_color - graylevel or color sample values of
Glenn Randers-Pehrson3d5a5202000-07-01 15:37:28 -05002251 the single transparent color for
2252 non-paletted images (PNG_INFO_tRNS)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002253
2254 png_get_hIST(png_ptr, info_ptr, &hist);
2255 (PNG_INFO_hIST)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002256
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002257 hist - histogram of palette (array of
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002258 png_uint_16)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002259
2260 png_get_tIME(png_ptr, info_ptr, &mod_time);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002261
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002262 mod_time - time image was last modified
2263 (PNG_VALID_tIME)
2264
2265 png_get_bKGD(png_ptr, info_ptr, &background);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002266
Glenn Randers-Pehrsonab389792011-07-09 19:35:22 -05002267 background - background color (of type
2268 png_color_16p) (PNG_VALID_bKGD)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06002269 valid 16-bit red, green and blue
2270 values, regardless of color_type
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002271
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06002272 num_comments = png_get_text(png_ptr, info_ptr,
2273 &text_ptr, &num_text);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002274
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06002275 num_comments - number of comments
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002276
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002277 text_ptr - array of png_text holding image
2278 comments
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002279
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002280 text_ptr[i].compression - type of compression used
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06002281 on "text" PNG_TEXT_COMPRESSION_NONE
2282 PNG_TEXT_COMPRESSION_zTXt
2283 PNG_ITXT_COMPRESSION_NONE
2284 PNG_ITXT_COMPRESSION_zTXt
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002285
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002286 text_ptr[i].key - keyword for comment. Must contain
2287 1-79 characters.
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002288
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002289 text_ptr[i].text - text comments for current
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -05002290 keyword. Can be empty.
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002291
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002292 text_ptr[i].text_length - length of text string,
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06002293 after decompression, 0 for iTXt
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002294
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002295 text_ptr[i].itxt_length - length of itxt string,
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06002296 after decompression, 0 for tEXt/zTXt
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002297
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002298 text_ptr[i].lang - language of comment (empty
2299 string for unknown).
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002300
Glenn Randers-Pehrson73d57cb2002-03-25 18:49:08 -06002301 text_ptr[i].lang_key - keyword in UTF-8
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002302 (empty string for unknown).
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002303
Glenn Randers-Pehrson8f5846f2009-10-31 21:31:08 -05002304 Note that the itxt_length, lang, and lang_key
2305 members of the text_ptr structure only exist
2306 when the library is built with iTXt chunk support.
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05002307 Prior to libpng-1.4.0, the default build was
Glenn Randers-Pehrsond4e1ddb2011-07-27 20:09:57 -05002308 without iTXt chunk support.
Glenn Randers-Pehrson8f5846f2009-10-31 21:31:08 -05002309
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002310 num_text - number of comments (same as
2311 num_comments; you can put NULL here
2312 to avoid the duplication)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002313
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002314 Note while png_set_text() will accept text, language,
2315 and translated keywords that can be NULL pointers, the
2316 structure returned by png_get_text will always contain
2317 regular zero-terminated C strings. They might be
2318 empty strings but they will never be NULL pointers.
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002319
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002320 num_spalettes = png_get_sPLT(png_ptr, info_ptr,
2321 &palette_ptr);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002322
2323 num_spalettes - number of sPLT chunks read.
2324
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002325 palette_ptr - array of palette structures holding
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002326 contents of one or more sPLT chunks
2327 read.
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06002328
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002329 png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y,
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002330 &unit_type);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002331
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002332 offset_x - positive offset from the left edge
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05002333 of the screen (can be negative)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002334
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002335 offset_y - positive offset from the top edge
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05002336 of the screen (can be negative)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002337
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002338 unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER
2339
2340 png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y,
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002341 &unit_type);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002342
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002343 res_x - pixels/unit physical resolution in
2344 x direction
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002345
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002346 res_y - pixels/unit physical resolution in
2347 x direction
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002348
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002349 unit_type - PNG_RESOLUTION_UNKNOWN,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002350 PNG_RESOLUTION_METER
2351
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002352 png_get_sCAL(png_ptr, info_ptr, &unit, &width,
2353 &height)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002354
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002355 unit - physical scale units (an integer)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002356
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06002357 width - width of a pixel in physical scale units
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002358
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06002359 height - height of a pixel in physical scale units
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002360 (width and height are doubles)
2361
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002362 png_get_sCAL_s(png_ptr, info_ptr, &unit, &width,
2363 &height)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002364
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002365 unit - physical scale units (an integer)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002366
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002367 width - width of a pixel in physical scale units
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05002368 (expressed as a string)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002369
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002370 height - height of a pixel in physical scale units
2371 (width and height are strings like "2.54")
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06002372
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002373 num_unknown_chunks = png_get_unknown_chunks(png_ptr,
2374 info_ptr, &unknowns)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002375
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002376 unknowns - array of png_unknown_chunk
2377 structures holding unknown chunks
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002378
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06002379 unknowns[i].name - name of unknown chunk
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002380
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06002381 unknowns[i].data - data of unknown chunk
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002382
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002383 unknowns[i].size - size of unknown chunk's data
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002384
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06002385 unknowns[i].location - position of chunk in file
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06002386
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002387 The value of "i" corresponds to the order in which the
2388 chunks were read from the PNG file or inserted with the
2389 png_set_unknown_chunks() function.
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002390
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05002391 The value of "location" is a bitwise "or" of
2392
2393 PNG_HAVE_IHDR (0x01)
2394 PNG_HAVE_PLTE (0x02)
2395 PNG_AFTER_IDAT (0x08)
2396
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002397The data from the pHYs chunk can be retrieved in several convenient
2398forms:
2399
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002400 res_x = png_get_x_pixels_per_meter(png_ptr,
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002401 info_ptr)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002402
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002403 res_y = png_get_y_pixels_per_meter(png_ptr,
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002404 info_ptr)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002405
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002406 res_x_and_y = png_get_pixels_per_meter(png_ptr,
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002407 info_ptr)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002408
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002409 res_x = png_get_x_pixels_per_inch(png_ptr,
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002410 info_ptr)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002411
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002412 res_y = png_get_y_pixels_per_inch(png_ptr,
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002413 info_ptr)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002414
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002415 res_x_and_y = png_get_pixels_per_inch(png_ptr,
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002416 info_ptr)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002417
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002418 aspect_ratio = png_get_pixel_aspect_ratio(png_ptr,
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002419 info_ptr)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002420
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002421 Each of these returns 0 [signifying "unknown"] if
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002422 the data is not present or if res_x is 0;
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002423 res_x_and_y is 0 if res_x != res_y
2424
2425 Note that because of the way the resolutions are
2426 stored internally, the inch conversions won't
2427 come out to exactly even number. For example,
2428 72 dpi is stored as 0.28346 pixels/meter, and
2429 when this is retrieved it is 71.9988 dpi, so
2430 be sure to round the returned value appropriately
Glenn Randers-Pehrsonc36bb792011-02-12 09:49:07 -06002431 if you want to display a reasonable-looking result.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002432
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002433The data from the oFFs chunk can be retrieved in several convenient
2434forms:
2435
2436 x_offset = png_get_x_offset_microns(png_ptr, info_ptr);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002437
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002438 y_offset = png_get_y_offset_microns(png_ptr, info_ptr);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002439
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002440 x_offset = png_get_x_offset_inches(png_ptr, info_ptr);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002441
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002442 y_offset = png_get_y_offset_inches(png_ptr, info_ptr);
2443
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002444 Each of these returns 0 [signifying "unknown" if both
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06002445 x and y are 0] if the data is not present or if the
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002446 chunk is present but the unit is the pixel. The
2447 remark about inexact inch conversions applies here
2448 as well, because a value in inches can't always be
2449 converted to microns and back without some loss
2450 of precision.
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002451
John Bowlercb0b2962011-05-12 21:48:29 -05002452For more information, see the
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002453PNG specification for chunk contents. Be careful with trusting
2454rowbytes, as some of the transformations could increase the space
2455needed to hold a row (expand, filler, gray_to_rgb, etc.).
2456See png_read_update_info(), below.
2457
2458A quick word about text_ptr and num_text. PNG stores comments in
2459keyword/text pairs, one pair per chunk, with no limit on the number
2460of text chunks, and a 2^31 byte limit on their size. While there are
2461suggested keywords, there is no requirement to restrict the use to these
2462strings. It is strongly suggested that keywords and text be sensible
2463to humans (that's the point), so don't use abbreviations. Non-printing
2464symbols are not allowed. See the PNG specification for more details.
2465There is also no requirement to have text after the keyword.
2466
2467Keywords should be limited to 79 Latin-1 characters without leading or
2468trailing spaces, but non-consecutive spaces are allowed within the
2469keyword. It is possible to have the same keyword any number of times.
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06002470The text_ptr is an array of png_text structures, each holding a
2471pointer to a language string, a pointer to a keyword and a pointer to
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05002472a text string. The text string, language code, and translated
2473keyword may be empty or NULL pointers. The keyword/text
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06002474pairs are put into the array in the order that they are received.
2475However, some or all of the text chunks may be after the image, so, to
2476make sure you have read all the text chunks, don't mess with these
2477until after you read the stuff after the image. This will be
2478mentioned again below in the discussion that goes with png_read_end().
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002479
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06002480.SS Input transformations
2481
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002482After you've read the header information, you can set up the library
2483to handle any special transformations of the image data. The various
2484ways to transform the data will be described in the order that they
2485should occur. This is important, as some of these change the color
2486type and/or bit depth of the data, and some others only work on
John Bowlercb0b2962011-05-12 21:48:29 -05002487certain color types and bit depths.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002488
John Bowlercb0b2962011-05-12 21:48:29 -05002489Transformations you request are ignored if they don't have any meaning for a
2490particular input data format. However some transformations can have an effect
2491as a result of a previous transformation. If you specify a contradictory set of
2492transformations, for example both adding and removing the alpha channel, you
2493cannot predict the final result.
2494
2495The color used for the transparency values should be supplied in the same
2496format/depth as the current image data. It is stored in the same format/depth
2497as the image data in a tRNS chunk, so this is what libpng expects for this data.
2498
2499The color used for the background value depends on the need_expand argument as
2500described below.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002501
2502Data will be decoded into the supplied row buffers packed into bytes
2503unless the library has been told to transform it into another format.
2504For example, 4 bit/pixel paletted or grayscale data will be returned
25052 pixels/byte with the leftmost pixel in the high-order bits of the
2506byte, unless png_set_packing() is called. 8-bit RGB data will be stored
Glenn Randers-Pehrson5b779162004-09-04 13:25:08 -05002507in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha()
2508is called to insert filler bytes, either before or after each RGB triplet.
250916-bit RGB data will be returned RRGGBB RRGGBB, with the most significant
Glenn Randers-Pehrsonfb29e512011-06-17 20:38:24 -05002510byte of the color value first, unless png_set_scale_16() is called to
Glenn Randers-Pehrson16e11662004-11-01 14:13:40 -06002511transform it to regular RGB RGB triplets, or png_set_filler() or
2512png_set_add alpha() is called to insert filler bytes, either before or
2513after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data can
Glenn Randers-Pehrsonfb29e512011-06-17 20:38:24 -05002514be modified with png_set_filler(), png_set_add_alpha(), png_set_strip_16(),
2515or png_set_scale_16().
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002516
2517The following code transforms grayscale images of less than 8 to 8 bits,
2518changes paletted images to RGB, and adds a full alpha channel if there is
2519transparency information in a tRNS chunk. This is most useful on
2520grayscale images with bit depths of 2 or 4 or if there is a multiple-image
2521viewing application that wishes to treat all images in the same way.
2522
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05002523 if (color_type == PNG_COLOR_TYPE_PALETTE)
2524 png_set_palette_to_rgb(png_ptr);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002525
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002526 if (png_get_valid(png_ptr, info_ptr,
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05002527 PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr);
2528
Glenn Randers-Pehrsonc36bb792011-02-12 09:49:07 -06002529 if (color_type == PNG_COLOR_TYPE_GRAY &&
2530 bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr);
2531
2532The first two functions are actually aliases for png_set_expand(), added
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05002533in libpng version 1.0.4, with the function names expanded to improve code
2534readability. In some future version they may actually do different
2535things.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002536
Glenn Randers-Pehrson1ce08362006-03-08 23:35:59 -06002537As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was
2538added. It expands the sample depth without changing tRNS to alpha.
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05002539
John Bowler63d059a2011-02-12 09:03:44 -06002540As of libpng version 1.5.2, png_set_expand_16() was added. It behaves as
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05002541png_set_expand(); however, the resultant channels have 16 bits rather than 8.
Glenn Randers-Pehrsonc36bb792011-02-12 09:49:07 -06002542Use this when the output color or gray channels are made linear to avoid fairly
John Bowler63d059a2011-02-12 09:03:44 -06002543severe accuracy loss.
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05002544
John Bowler63d059a2011-02-12 09:03:44 -06002545 if (bit_depth < 16)
2546 png_set_expand_16(png_ptr);
Glenn Randers-Pehrson1ce08362006-03-08 23:35:59 -06002547
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002548PNG can have files with 16 bits per channel. If you only can handle
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -050025498 bits per channel, this will strip the pixels down to 8-bit.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002550
2551 if (bit_depth == 16)
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05002552#if PNG_LIBPNG_VER >= 10504
Glenn Randers-Pehrsonfb29e512011-06-17 20:38:24 -05002553 png_set_scale_16(png_ptr);
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05002554#else
2555 png_set_strip_16(png_ptr);
2556#endif
2557
2558(The more accurate "png_set_scale_16()" API became available in libpng version
25591.5.4).
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002560
John Bowlercb0b2962011-05-12 21:48:29 -05002561If you need to process the alpha channel on the image separately from the image
2562data (for example if you convert it to a bitmap mask) it is possible to have
2563libpng strip the channel leaving just RGB or gray data:
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002564
2565 if (color_type & PNG_COLOR_MASK_ALPHA)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002566 png_set_strip_alpha(png_ptr);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002567
John Bowlercb0b2962011-05-12 21:48:29 -05002568If you strip the alpha channel you need to find some other way of dealing with
2569the information. If, instead, you want to convert the image to an opaque
2570version with no alpha channel use png_set_background; see below.
John Bowler63d059a2011-02-12 09:03:44 -06002571
2572As of libpng version 1.5.2, almost all useful expansions are supported, the
Glenn Randers-Pehrsoncd116fa2011-05-17 06:56:50 -05002573major ommissions are conversion of grayscale to indexed images (which can be
2574done trivially in the application) and conversion of indexed to grayscale (which
John Bowler63d059a2011-02-12 09:03:44 -06002575can be done by a trivial manipulation of the palette.)
2576
2577In the following table, the 01 means grayscale with depth<8, 31 means
2578indexed with depth<8, other numerals represent the color type, "T" means
2579the tRNS chunk is present, A means an alpha channel is present, and O
2580means tRNS or alpha is present but all pixels in the image are opaque.
2581
Glenn Randers-Pehrsonc36bb792011-02-12 09:49:07 -06002582 FROM 01 31 0 0T 0O 2 2T 2O 3 3T 3O 4A 4O 6A 6O
John Bowler63d059a2011-02-12 09:03:44 -06002583 TO
2584 01 - [G] - - - - - - - - - - - - -
2585 31 [Q] Q [Q] [Q] [Q] Q Q Q Q Q Q [Q] [Q] Q Q
2586 0 1 G + . . G G G G G G B B GB GB
2587 0T lt Gt t + . Gt G G Gt G G Bt Bt GBt GBt
2588 0O lt Gt t . + Gt Gt G Gt Gt G Bt Bt GBt GBt
2589 2 C P C C C + . . C - - CB CB B B
2590 2T Ct - Ct C C t + t - - - CBt CBt Bt Bt
2591 2O Ct - Ct C C t t + - - - CBt CBt Bt Bt
2592 3 [Q] p [Q] [Q] [Q] Q Q Q + . . [Q] [Q] Q Q
2593 3T [Qt] p [Qt][Q] [Q] Qt Qt Qt t + t [Qt][Qt] Qt Qt
2594 3O [Qt] p [Qt][Q] [Q] Qt Qt Qt t t + [Qt][Qt] Qt Qt
2595 4A lA G A T T GA GT GT GA GT GT + BA G GBA
2596 4O lA GBA A T T GA GT GT GA GT GT BA + GBA G
2597 6A CA PA CA C C A T tT PA P P C CBA + BA
2598 6O CA PBA CA C C A tT T PA P P CBA C BA +
2599
2600Within the matrix,
2601 "+" identifies entries where 'from' and 'to' are the same.
2602 "-" means the transformation is not supported.
2603 "." means nothing is necessary (a tRNS chunk can just be ignored).
2604 "t" means the transformation is obtained by png_set_tRNS.
2605 "A" means the transformation is obtained by png_set_add_alpha().
2606 "X" means the transformation is obtained by png_set_expand().
2607 "1" means the transformation is obtained by
2608 png_set_expand_gray_1_2_4_to_8() (and by png_set_expand() if there
2609 is no transparency in the original or the final format).
2610 "C" means the transformation is obtained by png_set_gray_to_rgb().
Glenn Randers-Pehrsonc36074e2011-05-16 09:08:51 -05002611 "G" means the transformation is obtained by png_set_rgb_to_gray().
John Bowler63d059a2011-02-12 09:03:44 -06002612 "P" means the transformation is obtained by
2613 png_set_expand_palette_to_rgb().
2614 "p" means the transformation is obtained by png_set_packing().
2615 "Q" means the transformation is obtained by png_set_quantize().
2616 "T" means the transformation is obtained by png_set_tRNS_to_alpha().
2617 "B" means the transformation is obtained by png_set_background(), or
2618 png_strip_alpha().
John Bowler63d059a2011-02-12 09:03:44 -06002619
2620When an entry has multiple transforms listed all are required to cause the
2621right overall transformation. When two transforms are separated by a comma
2622either will do the job. When transforms are enclosed in [] the transform should
2623do the job but this is currently unimplemented - a different format will result
2624if the suggested transformations are used.
2625
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06002626In PNG files, the alpha channel in an image
2627is the level of opacity. If you need the alpha channel in an image to
2628be the level of transparency instead of opacity, you can invert the
2629alpha channel (or the tRNS chunk data) after it's read, so that 0 is
2630fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit
2631images) is fully transparent, with
2632
2633 png_set_invert_alpha(png_ptr);
2634
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002635PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
2636they can, resulting in, for example, 8 pixels per byte for 1 bit
2637files. This code expands to 1 pixel per byte without changing the
2638values of the pixels:
2639
2640 if (bit_depth < 8)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002641 png_set_packing(png_ptr);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002642
2643PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels
2644stored in a PNG image have been "scaled" or "shifted" up to the next
Glenn Randers-Pehrsonf210a052009-11-12 10:02:24 -06002645higher possible bit depth (e.g. from 5 bits/sample in the range [0,31]
2646to 8 bits/sample in the range [0, 255]). However, it is also possible
2647to convert the PNG pixel data back to the original bit depth of the
2648image. This call reduces the pixels back down to the original bit depth:
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002649
Glenn Randers-Pehrson1ea0ff32001-08-07 22:25:59 -05002650 png_color_8p sig_bit;
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002651
2652 if (png_get_sBIT(png_ptr, info_ptr, &sig_bit))
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002653 png_set_shift(png_ptr, sig_bit);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002654
2655PNG files store 3-color pixels in red, green, blue order. This code
2656changes the storage of the pixels to blue, green, red:
2657
2658 if (color_type == PNG_COLOR_TYPE_RGB ||
2659 color_type == PNG_COLOR_TYPE_RGB_ALPHA)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002660 png_set_bgr(png_ptr);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002661
Glenn Randers-Pehrson1b8e5672001-08-25 06:46:06 -05002662PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them
2663into 4 or 8 bytes for windowing systems that need them in this format:
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002664
Glenn Randers-Pehrson1b8e5672001-08-25 06:46:06 -05002665 if (color_type == PNG_COLOR_TYPE_RGB)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002666 png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002667
Glenn Randers-Pehrson896239b1998-04-21 15:03:57 -05002668where "filler" is the 8 or 16-bit number to fill with, and the location is
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002669either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether
2670you want the filler before the RGB or after. This transformation
Glenn Randers-Pehrson1b8e5672001-08-25 06:46:06 -05002671does not affect images that already have full alpha channels. To add an
2672opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which
2673will generate RGBA pixels.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002674
Glenn Randers-Pehrson5b779162004-09-04 13:25:08 -05002675Note that png_set_filler() does not change the color type. If you want
2676to do that, you can add a true alpha channel with
2677
2678 if (color_type == PNG_COLOR_TYPE_RGB ||
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002679 color_type == PNG_COLOR_TYPE_GRAY)
2680 png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER);
Glenn Randers-Pehrson5b779162004-09-04 13:25:08 -05002681
2682where "filler" contains the alpha value to assign to each pixel.
Glenn Randers-Pehrson16e11662004-11-01 14:13:40 -06002683This function was added in libpng-1.2.7.
Glenn Randers-Pehrson5b779162004-09-04 13:25:08 -05002684
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002685If you are reading an image with an alpha channel, and you need the
2686data as ARGB instead of the normal PNG format RGBA:
2687
2688 if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002689 png_set_swap_alpha(png_ptr);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002690
2691For some uses, you may want a grayscale image to be represented as
2692RGB. This code will do that conversion:
2693
2694 if (color_type == PNG_COLOR_TYPE_GRAY ||
2695 color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002696 png_set_gray_to_rgb(png_ptr);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002697
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002698Conversely, you can convert an RGB or RGBA image to grayscale or grayscale
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06002699with alpha.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002700
2701 if (color_type == PNG_COLOR_TYPE_RGB ||
2702 color_type == PNG_COLOR_TYPE_RGB_ALPHA)
John Bowlercb0b2962011-05-12 21:48:29 -05002703 png_set_rgb_to_gray(png_ptr, error_action, double red_weight,
2704 double green_weight);
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002705
2706 error_action = 1: silently do the conversion
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002707
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002708 error_action = 2: issue a warning if the original
2709 image has any pixel where
2710 red != green or red != blue
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002711
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002712 error_action = 3: issue an error and abort the
2713 conversion if the original
2714 image has any pixel where
2715 red != green or red != blue
2716
John Bowlercb0b2962011-05-12 21:48:29 -05002717 red_weight: weight of red component
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002718
John Bowlercb0b2962011-05-12 21:48:29 -05002719 green_weight: weight of green component
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06002720 If either weight is negative, default
John Bowlercb0b2962011-05-12 21:48:29 -05002721 weights are used.
2722
2723In the corresponding fixed point API the red_weight and green_weight values are
2724simply scaled by 100,000:
2725
2726 png_set_rgb_to_gray(png_ptr, error_action, png_fixed_point red_weight,
2727 png_fixed_point green_weight);
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002728
2729If you have set error_action = 1 or 2, you can
2730later check whether the image really was gray, after processing
2731the image rows, with the png_get_rgb_to_gray_status(png_ptr) function.
2732It will return a png_byte that is zero if the image was gray or
John Bowlercb0b2962011-05-12 21:48:29 -050027331 if there were any non-gray pixels. Background and sBIT data
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002734will be silently converted to grayscale, using the green channel
John Bowlercb0b2962011-05-12 21:48:29 -05002735data for sBIT, regardless of the error_action setting.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002736
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05002737The default values come from the PNG file cHRM chunk if present; otherwise, the
John Bowlercb0b2962011-05-12 21:48:29 -05002738defaults correspond to the ITU-R recommendation 709, and also the sRGB color
2739space, as recommended in the Charles Poynton's Colour FAQ,
2740<http://www.poynton.com/>, in section 9:
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002741
John Bowlercb0b2962011-05-12 21:48:29 -05002742 <http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html#RTFToC9>
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002743
Glenn Randers-Pehrson6c988972011-07-29 12:31:16 -05002744 Y = 0.2126 * R + 0.7152 * G + 0.0722 * B
2745
2746Previous versions of this document, 1998 through 2002, recommended a slightly
2747different formula:
2748
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002749 Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
2750
Glenn Randers-Pehrson6c988972011-07-29 12:31:16 -05002751Libpng uses an integer approximation:
2752
2753 Y = (6968 * R + 23434 * G + 2366 * B)/32768
2754
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002755The calculation is done in a linear colorspace, if the image gamma
Glenn Randers-Pehrson9962b842011-01-24 00:12:14 -06002756can be determined.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002757
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05002758The png_set_background() function has been described already; it tells libpng to
John Bowlercb0b2962011-05-12 21:48:29 -05002759composite images with alpha or simple transparency against the supplied
2760background color. For compatibility with versions of libpng earlier than
Glenn Randers-Pehrson733b1312011-06-15 13:21:01 -05002761libpng-1.5.4 it is recommended that you call the function after reading the file
John Bowlercb0b2962011-05-12 21:48:29 -05002762header, even if you don't want to use the color in a bKGD chunk, if one exists.
2763
2764If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid),
2765you may use this color, or supply another color more suitable for
2766the current display (e.g., the background color from a web page). You
2767need to tell libpng how the color is represented, both the format of the
Glenn Randers-Pehrsonab389792011-07-09 19:35:22 -05002768component values in the color (the number of bits) and the gamma encoding of the
John Bowlercb0b2962011-05-12 21:48:29 -05002769color. The function takes two arguments, background_gamma_mode and need_expand
Glenn Randers-Pehrsonab389792011-07-09 19:35:22 -05002770to convey this information, however only two combinations are likely to be
2771useful:
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002772
Glenn Randers-Pehrsoncb47e202011-07-10 06:55:14 -05002773 png_color_16 my_background;
2774 png_color_16p image_background;
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002775
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -05002776 if (png_get_bKGD(png_ptr, info_ptr, &image_background))
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002777 png_set_background(png_ptr, image_background,
John Bowlercb0b2962011-05-12 21:48:29 -05002778 PNG_BACKGROUND_GAMMA_FILE, 1/*needs to be expanded*/, 1);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002779 else
Glenn Randers-Pehrsoncb47e202011-07-10 06:55:14 -05002780 png_set_background(png_ptr, &my_background,
John Bowlercb0b2962011-05-12 21:48:29 -05002781 PNG_BACKGROUND_GAMMA_SCREEN, 0/*do not expand*/, 1);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002782
John Bowlercb0b2962011-05-12 21:48:29 -05002783The second call was described above - my_background is in the format of the
2784final, display, output produced by libpng. Because you now know the format of
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05002785the PNG it is possible to avoid the need to choose either 8-bit or 16-bit
2786output and to retain palette images (the palette colors will be modified
2787appropriately and the tRNS chunk removed.) However, if you are doing this,
2788take great care not to ask for transformations without checking first that
2789they apply!
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002790
John Bowlercb0b2962011-05-12 21:48:29 -05002791In the first call the background color has the original bit depth and color type
2792of the PNG file. So, for palette images the color is supplied as a palette
2793index and for low bit greyscale images the color is a reduced bit value in
2794image_background->gray.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002795
John Bowlercb0b2962011-05-12 21:48:29 -05002796If you didn't call png_set_gamma() before reading the file header, for example
2797if you need your code to remain compatible with older versions of libpng prior
Glenn Randers-Pehrson733b1312011-06-15 13:21:01 -05002798to libpng-1.5.4, this is the place to call it.
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05002799
John Bowlercb0b2962011-05-12 21:48:29 -05002800Do not call it if you called png_set_alpha_mode(); doing so will damage the
2801settings put in place by png_set_alpha_mode(). (If png_set_alpha_mode() is
2802supported then you can certainly do png_set_gamma() before reading the PNG
2803header.)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002804
Glenn Randers-Pehrsonc7822512011-05-07 21:23:43 -05002805This API unconditionally sets the screen and file gamma values, so it will
2806override the value in the PNG file unless it is called before the PNG file
2807reading starts. For this reason you must always call it with the PNG file
2808value when you call it in this position:
2809
Glenn Randers-Pehrson8d0bc0f2011-01-25 22:15:58 -06002810 if (png_get_gAMA(png_ptr, info_ptr, &file_gamma))
2811 png_set_gamma(png_ptr, screen_gamma, file_gamma);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002812
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002813 else
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06002814 png_set_gamma(png_ptr, screen_gamma, 0.45455);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002815
Glenn Randers-Pehrson3cd7cff2010-04-16 19:27:08 -05002816If you need to reduce an RGB file to a paletted file, or if a paletted
2817file has more entries then will fit on your screen, png_set_quantize()
Glenn Randers-Pehrson862cb202010-04-16 22:12:51 -05002818will do that. Note that this is a simple match quantization that merely
Glenn Randers-Pehrson3cd7cff2010-04-16 19:27:08 -05002819finds the closest color available. This should work fairly well with
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002820optimized palettes, but fairly badly with linear color cubes. If you
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05002821pass a palette that is larger than maximum_colors, the file will
Glenn Randers-Pehrson3cd7cff2010-04-16 19:27:08 -05002822reduce the number of colors in the palette so it will fit into
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05002823maximum_colors. If there is a histogram, libpng will use it to make
Glenn Randers-Pehrson3cd7cff2010-04-16 19:27:08 -05002824more intelligent choices when reducing the palette. If there is no
2825histogram, it may not do as good a job.
2826
2827 if (color_type & PNG_COLOR_MASK_COLOR)
2828 {
2829 if (png_get_valid(png_ptr, info_ptr,
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002830 PNG_INFO_PLTE))
Glenn Randers-Pehrson3cd7cff2010-04-16 19:27:08 -05002831 {
2832 png_uint_16p histogram = NULL;
2833
2834 png_get_hIST(png_ptr, info_ptr,
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002835 &histogram);
Glenn Randers-Pehrson3cd7cff2010-04-16 19:27:08 -05002836 png_set_quantize(png_ptr, palette, num_palette,
2837 max_screen_colors, histogram, 1);
2838 }
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002839
Glenn Randers-Pehrson3cd7cff2010-04-16 19:27:08 -05002840 else
2841 {
2842 png_color std_color_cube[MAX_SCREEN_COLORS] =
2843 { ... colors ... };
2844
2845 png_set_quantize(png_ptr, std_color_cube,
2846 MAX_SCREEN_COLORS, MAX_SCREEN_COLORS,
2847 NULL,0);
2848 }
2849 }
2850
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002851PNG files describe monochrome as black being zero and white being one.
2852The following code will reverse this (make black be one and white be
2853zero):
2854
Glenn Randers-Pehrson1ea0ff32001-08-07 22:25:59 -05002855 if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY)
2856 png_set_invert_mono(png_ptr);
2857
2858This function can also be used to invert grayscale and gray-alpha images:
2859
2860 if (color_type == PNG_COLOR_TYPE_GRAY ||
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002861 color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002862 png_set_invert_mono(png_ptr);
2863
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05002864PNG files store 16-bit pixels in network byte order (big-endian,
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002865ie. most significant bits first). This code changes the storage to the
2866other way (little-endian, i.e. least significant bits first, the
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002867way PCs store them):
2868
2869 if (bit_depth == 16)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002870 png_set_swap(png_ptr);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002871
2872If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you
2873need to change the order the pixels are packed into bytes, you can use:
2874
2875 if (bit_depth < 8)
2876 png_set_packswap(png_ptr);
2877
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06002878Finally, you can write your own transformation function if none of
2879the existing ones meets your needs. This is done by setting a callback
2880with
2881
2882 png_set_read_user_transform_fn(png_ptr,
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002883 read_transform_fn);
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06002884
2885You must supply the function
2886
Glenn Randers-Pehrson93215672011-02-13 19:42:19 -06002887 void read_transform_fn(png_structp png_ptr, png_row_infop
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002888 row_info, png_bytep data)
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06002889
2890See pngtest.c for a working example. Your function will be called
John Bowlerf19abd62011-01-22 18:29:24 -06002891after all of the other transformations have been processed. Take care with
2892interlaced images if you do the interlace yourself - the width of the row is the
2893width in 'row_info', not the overall image width.
2894
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05002895If supported, libpng provides two information routines that you can use to find
John Bowlerf19abd62011-01-22 18:29:24 -06002896where you are in processing the image:
2897
2898 png_get_current_pass_number(png_structp png_ptr);
2899 png_get_current_row_number(png_structp png_ptr);
2900
2901Don't try using these outside a transform callback - firstly they are only
2902supported if user transforms are supported, secondly they may well return
2903unexpected results unless the row is actually being processed at the moment they
2904are called.
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06002905
John Bowlercd113452011-02-16 06:15:13 -06002906With interlaced
2907images the value returned is the row in the input sub-image image. Use
2908PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to
2909find the output pixel (x,y) given an interlaced sub-image pixel (row,col,pass).
2910
2911The discussion of interlace handling above contains more information on how to
2912use these values.
2913
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06002914You can also set up a pointer to a user structure for use by your
2915callback function, and you can inform libpng that your transform
2916function will change the number of channels or bit depth with the
2917function
2918
2919 png_set_user_transform_info(png_ptr, user_ptr,
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002920 user_depth, user_channels);
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06002921
2922The user's application, not libpng, is responsible for allocating and
2923freeing any memory required for the user structure.
2924
2925You can retrieve the pointer via the function
2926png_get_user_transform_ptr(). For example:
2927
2928 voidp read_user_transform_ptr =
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002929 png_get_user_transform_ptr(png_ptr);
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06002930
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002931The last thing to handle is interlacing; this is covered in detail below,
2932but you must call the function here if you want libpng to handle expansion
2933of the interlaced image.
2934
2935 number_of_passes = png_set_interlace_handling(png_ptr);
2936
2937After setting the transformations, libpng can update your png_info
2938structure to reflect any transformations you've requested with this
Glenn Randers-Pehrson968c2312011-09-26 16:35:22 -05002939call.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002940
2941 png_read_update_info(png_ptr, info_ptr);
2942
Glenn Randers-Pehrson968c2312011-09-26 16:35:22 -05002943This is most useful to update the info structure's rowbytes
2944field so you can use it to allocate your image memory. This function
2945will also update your palette with the correct screen_gamma and
2946background if these have been given with the calls above. You may
2947only call png_read_update_info() once with a particular info_ptr.
2948
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002949After you call png_read_update_info(), you can allocate any
2950memory you need to hold the image. The row data is simply
2951raw byte data for all forms of images. As the actual allocation
2952varies among applications, no example will be given. If you
2953are allocating one large chunk, you will need to build an
2954array of pointers to each row, as it will be needed for some
2955of the functions below.
2956
Glenn Randers-Pehrson968c2312011-09-26 16:35:22 -05002957Remember: Before you call png_read_update_info(), the png_get_*()
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06002958functions return the values corresponding to the original PNG image.
2959After you call png_read_update_info the values refer to the image
2960that libpng will output. Consequently you must call all the png_set_
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002961functions before you call png_read_update_info(). This is particularly
2962important for png_set_interlace_handling() - if you are going to call
2963png_read_update_info() you must call png_set_interlace_handling() before
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06002964it unless you want to receive interlaced output.
2965
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06002966.SS Reading image data
2967
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002968After you've allocated memory, you can read the image data.
2969The simplest way to do this is in one function call. If you are
2970allocating enough memory to hold the whole image, you can just
2971call png_read_image() and libpng will read in all the image data
2972and put it in the memory area supplied. You will need to pass in
2973an array of pointers to each row.
2974
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06002975This function automatically handles interlacing, so you don't
2976need to call png_set_interlace_handling() (unless you call
2977png_read_update_info()) or call this function multiple times, or any
2978of that other stuff necessary with png_read_rows().
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002979
2980 png_read_image(png_ptr, row_pointers);
2981
2982where row_pointers is:
2983
2984 png_bytep row_pointers[height];
2985
2986You can point to void or char or whatever you use for pixels.
2987
2988If you don't want to read in the whole image at once, you can
2989use png_read_rows() instead. If there is no interlacing (check
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06002990interlace_type == PNG_INTERLACE_NONE), this is simple:
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002991
2992 png_read_rows(png_ptr, row_pointers, NULL,
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06002993 number_of_rows);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002994
2995where row_pointers is the same as in the png_read_image() call.
2996
2997If you are doing this just one row at a time, you can do this with
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06002998a single row_pointer instead of an array of row_pointers:
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06002999
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06003000 png_bytep row_pointer = row;
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05003001 png_read_row(png_ptr, row_pointer, NULL);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003002
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05003003If the file is interlaced (interlace_type != 0 in the IHDR chunk), things
3004get somewhat harder. The only current (PNG Specification version 1.2)
Glenn Randers-Pehrson6e974102010-12-19 16:44:22 -06003005interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7);
3006a somewhat complicated 2D interlace scheme, known as Adam7, that
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003007breaks down an image into seven smaller images of varying size, based
Glenn Randers-Pehrson6e974102010-12-19 16:44:22 -06003008on an 8x8 grid. This number is defined (from libpng 1.5) as
3009PNG_INTERLACE_ADAM7_PASSES in png.h
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003010
3011libpng can fill out those images or it can give them to you "as is".
Glenn Randers-Pehrson6e974102010-12-19 16:44:22 -06003012It is almost always better to have libpng handle the interlacing for you.
3013If you want the images filled out, there are two ways to do that. The one
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003014mentioned in the PNG specification is to expand each pixel to cover
3015those pixels that have not been read yet (the "rectangle" method).
3016This results in a blocky image for the first pass, which gradually
3017smooths out as more pixels are read. The other method is the "sparkle"
3018method, where pixels are drawn only in their final locations, with the
3019rest of the image remaining whatever colors they were initialized to
3020before the start of the read. The first method usually looks better,
3021but tends to be slower, as there are more pixels to put in the rows.
3022
Glenn Randers-Pehrson6e974102010-12-19 16:44:22 -06003023If, as is likely, you want libpng to expand the images, call this before
3024calling png_start_read_image() or png_read_update_info():
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003025
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06003026 if (interlace_type == PNG_INTERLACE_ADAM7)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003027 number_of_passes
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003028 = png_set_interlace_handling(png_ptr);
3029
Glenn Randers-Pehrson6e974102010-12-19 16:44:22 -06003030This will return the number of passes needed. Currently, this is seven,
3031but may change if another interlace type is added. This function can be
3032called even if the file is not interlaced, where it will return one pass.
3033You then need to read the whole image 'number_of_passes' times. Each time
3034will distribute the pixels from the current pass to the correct place in
3035the output image, so you need to supply the same rows to png_read_rows in
3036each pass.
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -05003037
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003038If you are not going to display the image after each pass, but are
3039going to wait until the entire image is read in, use the sparkle
3040effect. This effect is faster and the end result of either method
3041is exactly the same. If you are planning on displaying the image
3042after each pass, the "rectangle" effect is generally considered the
3043better looking one.
3044
3045If you only want the "sparkle" effect, just call png_read_rows() as
3046normal, with the third parameter NULL. Make sure you make pass over
3047the image number_of_passes times, and you don't change the data in the
3048rows between calls. You can change the locations of the data, just
3049not the data. Each pass only writes the pixels appropriate for that
3050pass, and assumes the data from previous passes is still valid.
3051
3052 png_read_rows(png_ptr, row_pointers, NULL,
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003053 number_of_rows);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003054
3055If you only want the first effect (the rectangles), do the same as
3056before except pass the row buffer in the third parameter, and leave
3057the second parameter NULL.
3058
3059 png_read_rows(png_ptr, NULL, row_pointers,
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003060 number_of_rows);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003061
Glenn Randers-Pehrson6e974102010-12-19 16:44:22 -06003062If you don't want libpng to handle the interlacing details, just call
3063png_read_rows() PNG_INTERLACE_ADAM7_PASSES times to read in all the images.
3064Each of the images is a valid image by itself, however you will almost
3065certainly need to distribute the pixels from each sub-image to the
3066correct place. This is where everything gets very tricky.
3067
3068If you want to retrieve the separate images you must pass the correct
3069number of rows to each successive call of png_read_rows(). The calculation
3070gets pretty complicated for small images, where some sub-images may
3071not even exist because either their width or height ends up zero.
3072libpng provides two macros to help you in 1.5 and later versions:
3073
3074 png_uint_32 width = PNG_PASS_COLS(image_width, pass_number);
3075 png_uint_32 height = PNG_PASS_ROWS(image_height, pass_number);
3076
3077Respectively these tell you the width and height of the sub-image
3078corresponding to the numbered pass. 'pass' is in in the range 0 to 6 -
3079this can be confusing because the specification refers to the same passes
3080as 1 to 7! Be careful, you must check both the width and height before
3081calling png_read_rows() and not call it for that pass if either is zero.
3082
3083You can, of course, read each sub-image row by row. If you want to
3084produce optimal code to make a pixel-by-pixel transformation of an
3085interlaced image this is the best approach; read each row of each pass,
3086transform it, and write it out to a new interlaced image.
3087
3088If you want to de-interlace the image yourself libpng provides further
3089macros to help that tell you where to place the pixels in the output image.
3090Because the interlacing scheme is rectangular - sub-image pixels are always
3091arranged on a rectangular grid - all you need to know for each pass is the
3092starting column and row in the output image of the first pixel plus the
3093spacing between each pixel. As of libpng 1.5 there are four macros to
3094retrieve this information:
3095
3096 png_uint_32 x = PNG_PASS_START_COL(pass);
3097 png_uint_32 y = PNG_PASS_START_ROW(pass);
3098 png_uint_32 xStep = 1U << PNG_PASS_COL_SHIFT(pass);
3099 png_uint_32 yStep = 1U << PNG_PASS_ROW_SHIFT(pass);
3100
3101These allow you to write the obvious loop:
3102
3103 png_uint_32 input_y = 0;
3104 png_uint_32 output_y = PNG_PASS_START_ROW(pass);
3105
3106 while (output_y < output_image_height)
3107 {
3108 png_uint_32 input_x = 0;
3109 png_uint_32 output_x = PNG_PASS_START_COL(pass);
3110
3111 while (output_x < output_image_width)
3112 {
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003113 image[output_y][output_x] =
3114 subimage[pass][input_y][input_x++];
3115
Glenn Randers-Pehrson6e974102010-12-19 16:44:22 -06003116 output_x += xStep;
3117 }
3118
3119 ++input_y;
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003120 output_y += yStep;
Glenn Randers-Pehrson6e974102010-12-19 16:44:22 -06003121 }
3122
3123Notice that the steps between successive output rows and columns are
3124returned as shifts. This is possible because the pixels in the subimages
3125are always a power of 2 apart - 1, 2, 4 or 8 pixels - in the original
3126image. In practice you may need to directly calculate the output coordinate
3127given an input coordinate. libpng provides two further macros for this
3128purpose:
3129
3130 png_uint_32 output_x = PNG_COL_FROM_PASS_COL(input_x, pass);
3131 png_uint_32 output_y = PNG_ROW_FROM_PASS_ROW(input_y, pass);
3132
3133Finally a pair of macros are provided to tell you if a particular image
3134row or column appears in a given pass:
3135
3136 int col_in_pass = PNG_COL_IN_INTERLACE_PASS(output_x, pass);
3137 int row_in_pass = PNG_ROW_IN_INTERLACE_PASS(output_y, pass);
3138
3139Bear in mind that you will probably also need to check the width and height
3140of the pass in addition to the above to be sure the pass even exists!
3141
3142With any luck you are convinced by now that you don't want to do your own
3143interlace handling. In reality normally the only good reason for doing this
3144is if you are processing PNG files on a pixel-by-pixel basis and don't want
3145to load the whole file into memory when it is interlaced.
3146
3147libpng includes a test program, pngvalid, that illustrates reading and
3148writing of interlaced images. If you can't get interlacing to work in your
Glenn Randers-Pehrson95ba4172011-09-08 12:21:42 -05003149code and don't want to leave it to libpng (the recommended approach), see
Glenn Randers-Pehrson6e974102010-12-19 16:44:22 -06003150how pngvalid.c does it.
3151
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06003152.SS Finishing a sequential read
3153
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -06003154After you are finished reading the image through the
3155low-level interface, you can finish reading the file. If you are
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06003156interested in comments or time, which may be stored either before or
3157after the image data, you should pass the separate png_info struct if
3158you want to keep the comments from before and after the image
Glenn Randers-Pehrson20786be2011-04-20 22:20:40 -05003159separate.
3160
3161 png_infop end_info = png_create_info_struct(png_ptr);
3162
3163 if (!end_info)
3164 {
3165 png_destroy_read_struct(&png_ptr, &info_ptr,
3166 (png_infopp)NULL);
3167 return (ERROR);
3168 }
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003169
3170 png_read_end(png_ptr, end_info);
3171
Glenn Randers-Pehrson20786be2011-04-20 22:20:40 -05003172If you are not interested, you should still call png_read_end()
3173but you can pass NULL, avoiding the need to create an end_info structure.
3174
3175 png_read_end(png_ptr, (png_infop)NULL);
3176
Glenn Randers-Pehrson99778e12011-04-20 17:43:52 -05003177If you don't call png_read_end(), then your file pointer will be
3178left pointing to the first chunk after the last IDAT, which is probably
3179not what you want if you expect to read something beyond the end of
3180the PNG datastream.
3181
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003182When you are done, you can free all memory allocated by libpng like this:
3183
3184 png_destroy_read_struct(&png_ptr, &info_ptr,
3185 &end_info);
3186
Glenn Randers-Pehrson20786be2011-04-20 22:20:40 -05003187or, if you didn't create an end_info structure,
3188
3189 png_destroy_read_struct(&png_ptr, &info_ptr,
3190 (png_infopp)NULL);
3191
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06003192It is also possible to individually free the info_ptr members that
Glenn Randers-Pehrsonfc4a1432000-05-17 17:39:34 -05003193point to libpng-allocated storage with the following function:
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06003194
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06003195 png_free_data(png_ptr, info_ptr, mask, seq)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003196
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -05003197 mask - identifies data to be freed, a mask
Glenn Randers-Pehrsonebd7f9a2006-10-19 09:37:56 -05003198 containing the bitwise OR of one or
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -05003199 more of
3200 PNG_FREE_PLTE, PNG_FREE_TRNS,
3201 PNG_FREE_HIST, PNG_FREE_ICCP,
3202 PNG_FREE_PCAL, PNG_FREE_ROWS,
3203 PNG_FREE_SCAL, PNG_FREE_SPLT,
3204 PNG_FREE_TEXT, PNG_FREE_UNKN,
3205 or simply PNG_FREE_ALL
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003206
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06003207 seq - sequence number of item to be freed
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -05003208 (-1 for all items)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06003209
Glenn Randers-Pehrsonfc4a1432000-05-17 17:39:34 -05003210This function may be safely called when the relevant storage has
Glenn Randers-Pehrson68ea2432000-04-01 21:10:05 -06003211already been freed, or has not yet been allocated, or was allocated
Glenn Randers-Pehrsonf210a052009-11-12 10:02:24 -06003212by the user and not by libpng, and will in those cases do nothing.
3213The "seq" parameter is ignored if only one item of the selected data
3214type, such as PLTE, is allowed. If "seq" is not -1, and multiple items
3215are allowed for the data type identified in the mask, such as text or
3216sPLT, only the n'th item in the structure is freed, where n is "seq".
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06003217
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -05003218The default behavior is only to free data that was allocated internally
3219by libpng. This can be changed, so that libpng will not free the data,
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -05003220or so that it will free data that was allocated by the user with png_malloc()
3221or png_zalloc() and passed in via a png_set_*() function, with
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -05003222
3223 png_data_freer(png_ptr, info_ptr, freer, mask)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003224
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -05003225 freer - one of
3226 PNG_DESTROY_WILL_FREE_DATA
3227 PNG_SET_WILL_FREE_DATA
3228 PNG_USER_WILL_FREE_DATA
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -05003229
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003230 mask - which data elements are affected
3231 same choices as in png_free_data()
3232
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -05003233This function only affects data that has already been allocated.
3234You can call this function after reading the PNG data but before calling
3235any png_set_*() functions, to control whether the user or the png_set_*()
3236function is responsible for freeing any existing data that might be present,
3237and again after the png_set_*() functions to control whether the user
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -05003238or png_destroy_*() is supposed to free the data. When the user assumes
3239responsibility for libpng-allocated data, the application must use
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -05003240png_free() to free it, and when the user transfers responsibility to libpng
3241for data that the user has allocated, the user must have used png_malloc()
Glenn Randers-Pehrsonb1828932001-06-23 08:03:17 -05003242or png_zalloc() to allocate it.
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -05003243
3244If you allocated your row_pointers in a single block, as suggested above in
3245the description of the high level read interface, you must not transfer
3246responsibility for freeing it to the png_set_rows or png_read_destroy function,
3247because they would also try to free the individual row_pointers[i].
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -05003248
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -05003249If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword
3250separately, do not transfer responsibility for freeing text_ptr to libpng,
3251because when libpng fills a png_text structure it combines these members with
3252the key member, and png_free_data() will free only text_ptr.key. Similarly,
3253if you transfer responsibility for free'ing text_ptr from libpng to your
3254application, your application must not separately free those members.
3255
Glenn Randers-Pehrsonfc4a1432000-05-17 17:39:34 -05003256The png_free_data() function will turn off the "valid" flag for anything
Glenn Randers-Pehrsonf210a052009-11-12 10:02:24 -06003257it frees. If you need to turn the flag off for a chunk that was freed by
3258your application instead of by libpng, you can use
Glenn Randers-Pehrsonfc4a1432000-05-17 17:39:34 -05003259
3260 png_set_invalid(png_ptr, info_ptr, mask);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003261
Glenn Randers-Pehrsonfc4a1432000-05-17 17:39:34 -05003262 mask - identifies the chunks to be made invalid,
Glenn Randers-Pehrsonebd7f9a2006-10-19 09:37:56 -05003263 containing the bitwise OR of one or
Glenn Randers-Pehrsond56aca72000-11-23 11:51:42 -06003264 more of
Glenn Randers-Pehrsonfc4a1432000-05-17 17:39:34 -05003265 PNG_INFO_gAMA, PNG_INFO_sBIT,
3266 PNG_INFO_cHRM, PNG_INFO_PLTE,
3267 PNG_INFO_tRNS, PNG_INFO_bKGD,
3268 PNG_INFO_hIST, PNG_INFO_pHYs,
3269 PNG_INFO_oFFs, PNG_INFO_tIME,
3270 PNG_INFO_pCAL, PNG_INFO_sRGB,
3271 PNG_INFO_iCCP, PNG_INFO_sPLT,
3272 PNG_INFO_sCAL, PNG_INFO_IDAT
3273
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003274For a more compact example of reading a PNG image, see the file example.c.
3275
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06003276.SS Reading PNG files progressively
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003277
3278The progressive reader is slightly different then the non-progressive
3279reader. Instead of calling png_read_info(), png_read_rows(), and
3280png_read_end(), you make one call to png_process_data(), which calls
3281callbacks when it has the info, a row, or the end of the image. You
3282set up these callbacks with png_set_progressive_read_fn(). You don't
3283have to worry about the input/output functions of libpng, as you are
3284giving the library the data directly in png_process_data(). I will
3285assume that you have read the section on reading PNG files above,
3286so I will only highlight the differences (although I will show
3287all of the code).
3288
3289png_structp png_ptr;
3290png_infop info_ptr;
3291
3292 /* An example code fragment of how you would
3293 initialize the progressive reader in your
3294 application. */
3295 int
3296 initialize_png_reader()
3297 {
3298 png_ptr = png_create_read_struct
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -05003299 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003300 user_error_fn, user_warning_fn);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003301
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003302 if (!png_ptr)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -05003303 return (ERROR);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003304
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003305 info_ptr = png_create_info_struct(png_ptr);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003306
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003307 if (!info_ptr)
3308 {
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003309 png_destroy_read_struct(&png_ptr,
3310 (png_infopp)NULL, (png_infopp)NULL);
3311 return (ERROR);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003312 }
3313
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06003314 if (setjmp(png_jmpbuf(png_ptr)))
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003315 {
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003316 png_destroy_read_struct(&png_ptr, &info_ptr,
3317 (png_infopp)NULL);
3318 return (ERROR);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003319 }
3320
3321 /* This one's new. You can provide functions
3322 to be called when the header info is valid,
3323 when each row is completed, and when the image
3324 is finished. If you aren't using all functions,
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06003325 you can specify NULL parameters. Even when all
3326 three functions are NULL, you need to call
3327 png_set_progressive_read_fn(). You can use
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003328 any struct as the user_ptr (cast to a void pointer
3329 for the function call), and retrieve the pointer
3330 from inside the callbacks using the function
3331
3332 png_get_progressive_ptr(png_ptr);
3333
3334 which will return a void pointer, which you have
3335 to cast appropriately.
3336 */
3337 png_set_progressive_read_fn(png_ptr, (void *)user_ptr,
3338 info_callback, row_callback, end_callback);
3339
3340 return 0;
3341 }
3342
3343 /* A code fragment that you call as you receive blocks
3344 of data */
3345 int
3346 process_data(png_bytep buffer, png_uint_32 length)
3347 {
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06003348 if (setjmp(png_jmpbuf(png_ptr)))
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003349 {
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003350 png_destroy_read_struct(&png_ptr, &info_ptr,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003351 (png_infopp)NULL);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003352 return (ERROR);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003353 }
3354
3355 /* This one's new also. Simply give it a chunk
3356 of data from the file stream (in order, of
3357 course). On machines with segmented memory
3358 models machines, don't give it any more than
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06003359 64K. The library seems to run fine with sizes
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003360 of 4K. Although you can give it much less if
3361 necessary (I assume you can give it chunks of
3362 1 byte, I haven't tried less then 256 bytes
3363 yet). When this function returns, you may
3364 want to display any rows that were generated
3365 in the row callback if you don't already do
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06003366 so there.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003367 */
3368 png_process_data(png_ptr, info_ptr, buffer, length);
John Bowlerf19abd62011-01-22 18:29:24 -06003369
3370 /* At this point you can call png_process_data_skip if
3371 you want to handle data the library will skip yourself;
3372 it simply returns the number of bytes to skip (and stops
3373 libpng skipping that number of bytes on the next
3374 png_process_data call).
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003375 return 0;
3376 }
3377
3378 /* This function is called (as set by
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06003379 png_set_progressive_read_fn() above) when enough data
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003380 has been supplied so all of the header has been
3381 read.
3382 */
3383 void
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06003384 info_callback(png_structp png_ptr, png_infop info)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003385 {
3386 /* Do any setup here, including setting any of
3387 the transformations mentioned in the Reading
3388 PNG files section. For now, you _must_ call
3389 either png_start_read_image() or
3390 png_read_update_info() after all the
3391 transformations are set (even if you don't set
3392 any). You may start getting rows before
3393 png_process_data() returns, so this is your
3394 last chance to prepare for that.
Glenn Randers-Pehrson6e974102010-12-19 16:44:22 -06003395
3396 This is where you turn on interlace handling,
3397 assuming you don't want to do it yourself.
John Bowlerf19abd62011-01-22 18:29:24 -06003398
3399 If you need to you can stop the processing of
3400 your original input data at this point by calling
3401 png_process_data_pause. This returns the number
3402 of unprocessed bytes from the last png_process_data
3403 call - it is up to you to ensure that the next call
3404 sees these bytes again. If you don't want to bother
3405 with this you can get libpng to cache the unread
3406 bytes by setting the 'save' parameter (see png.h) but
3407 then libpng will have to copy the data internally.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003408 */
3409 }
3410
3411 /* This function is called when each row of image
3412 data is complete */
3413 void
3414 row_callback(png_structp png_ptr, png_bytep new_row,
Glenn Randers-Pehrsone68f5a32001-05-14 09:20:53 -05003415 png_uint_32 row_num, int pass)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003416 {
3417 /* If the image is interlaced, and you turned
3418 on the interlace handler, this function will
3419 be called for every row in every pass. Some
3420 of these rows will not be changed from the
3421 previous pass. When the row is not changed,
3422 the new_row variable will be NULL. The rows
3423 and passes are called in order, so you don't
3424 really need the row_num and pass, but I'm
3425 supplying them because it may make your life
3426 easier.
3427
Glenn Randers-Pehrson6e974102010-12-19 16:44:22 -06003428 If you did not turn on interlace handling then
3429 the callback is called for each row of each
3430 sub-image when the image is interlaced. In this
3431 case 'row_num' is the row in the sub-image, not
3432 the row in the output image as it is in all other
3433 cases.
3434
3435 For the non-NULL rows of interlaced images when
3436 you have switched on libpng interlace handling,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003437 you must call png_progressive_combine_row()
3438 passing in the row and the old row. You can
3439 call this function for NULL rows (it will just
3440 return) and for non-interlaced images (it just
3441 does the memcpy for you) if it will make the
3442 code easier. Thus, you can just do this for
Glenn Randers-Pehrson6e974102010-12-19 16:44:22 -06003443 all cases if you switch on interlace handling;
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003444 */
3445
3446 png_progressive_combine_row(png_ptr, old_row,
3447 new_row);
3448
3449 /* where old_row is what was displayed for
Glenn Randers-Pehrson345bc271998-06-14 14:43:31 -05003450 previously for the row. Note that the first
3451 pass (pass == 0, really) will completely cover
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003452 the old row, so the rows do not have to be
3453 initialized. After the first pass (and only
3454 for interlaced images), you will have to pass
3455 the current row, and the function will combine
3456 the old row and the new row.
John Bowlerf19abd62011-01-22 18:29:24 -06003457
3458 You can also call png_process_data_pause in this
3459 callback - see above.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06003460 */
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003461 }
3462
3463 void
3464 end_callback(png_structp png_ptr, png_infop info)
3465 {
3466 /* This function is called after the whole image
3467 has been read, including any chunks after the
3468 image (up to and including the IEND). You
3469 will usually have the same info chunk as you
3470 had in the header, although some data may have
3471 been added to the comments and time fields.
3472
3473 Most people won't do much here, perhaps setting
3474 a flag that marks the image as finished.
3475 */
3476 }
3477
Glenn Randers-Pehrson896239b1998-04-21 15:03:57 -05003478
3479
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06003480.SH IV. Writing
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003481
3482Much of this is very similar to reading. However, everything of
3483importance is repeated here, so you won't have to constantly look
3484back up in the reading section to understand writing.
3485
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06003486.SS Setup
3487
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003488You will want to do the I/O initialization before you get into libpng,
3489so if it doesn't work, you don't have anything to undo. If you are not
3490using the standard I/O functions, you will need to replace them with
3491custom writing functions. See the discussion under Customizing libpng.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06003492
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003493 FILE *fp = fopen(file_name, "wb");
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003494
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003495 if (!fp)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -05003496 return (ERROR);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003497
3498Next, png_struct and png_info need to be allocated and initialized.
3499As these can be both relatively large, you may not want to store these
3500on the stack, unless you have stack space to spare. Of course, you
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06003501will want to check if they return NULL. If you are also reading,
3502you won't want to name your read structure and your write structure
3503both "png_ptr"; you can call them anything you like, such as
3504"read_ptr" and "write_ptr". Look at pngtest.c, for example.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003505
3506 png_structp png_ptr = png_create_write_struct
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -05003507 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003508 user_error_fn, user_warning_fn);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003509
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003510 if (!png_ptr)
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -05003511 return (ERROR);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003512
3513 png_infop info_ptr = png_create_info_struct(png_ptr);
3514 if (!info_ptr)
3515 {
3516 png_destroy_write_struct(&png_ptr,
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003517 (png_infopp)NULL);
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -05003518 return (ERROR);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003519 }
3520
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -05003521If you want to use your own memory allocation routines,
3522define PNG_USER_MEM_SUPPORTED and use
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05003523png_create_write_struct_2() instead of png_create_write_struct():
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -05003524
3525 png_structp png_ptr = png_create_write_struct_2
3526 (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
3527 user_error_fn, user_warning_fn, (png_voidp)
3528 user_mem_ptr, user_malloc_fn, user_free_fn);
3529
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003530After you have these structures, you will need to set up the
3531error handling. When libpng encounters an error, it expects to
3532longjmp() back to your routine. Therefore, you will need to call
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06003533setjmp() and pass the png_jmpbuf(png_ptr). If you
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003534write the file from different routines, you will need to update
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06003535the png_jmpbuf(png_ptr) every time you enter a new routine that will
3536call a png_*() function. See your documentation of setjmp/longjmp
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003537for your compiler for more information on setjmp/longjmp. See
3538the discussion on libpng error handling in the Customizing Libpng
3539section below for more information on the libpng error handling.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06003540
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06003541 if (setjmp(png_jmpbuf(png_ptr)))
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06003542 {
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003543 png_destroy_write_struct(&png_ptr, &info_ptr);
Glenn Randers-Pehrson104622b2000-05-29 08:58:03 -05003544 fclose(fp);
3545 return (ERROR);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003546 }
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06003547 ...
3548 return;
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003549
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06003550If you would rather avoid the complexity of setjmp/longjmp issues,
Glenn Randers-Pehrson54ac9a92010-04-02 17:06:22 -05003551you can compile libpng with PNG_NO_SETJMP, in which case
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06003552errors will result in a call to PNG_ABORT() which defaults to abort().
3553
Glenn Randers-Pehrson54ac9a92010-04-02 17:06:22 -05003554You can #define PNG_ABORT() to a function that does something
3555more useful than abort(), as long as your function does not
3556return.
3557
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003558Now you need to set up the output code. The default for libpng is to
3559use the C function fwrite(). If you use this, you will need to pass a
3560valid FILE * in the function png_init_io(). Be sure that the file is
3561opened in binary mode. Again, if you wish to handle writing data in
3562another way, see the discussion on libpng I/O handling in the Customizing
3563Libpng section below.
3564
3565 png_init_io(png_ptr, fp);
3566
Glenn Randers-Pehrsond60b8fa2006-04-20 21:31:14 -05003567If you are embedding your PNG into a datastream such as MNG, and don't
3568want libpng to write the 8-byte signature, or if you have already
3569written the signature in your application, use
3570
3571 png_set_sig_bytes(png_ptr, 8);
3572
3573to inform libpng that it should not write a signature.
3574
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06003575.SS Write callbacks
3576
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06003577At this point, you can set up a callback function that will be
3578called after each row has been written, which you can use to control
3579a progress meter or the like. It's demonstrated in pngtest.c.
3580You must supply a function
3581
Glenn Randers-Pehrson81ce8892011-01-24 08:04:37 -06003582 void write_row_callback(png_structp png_ptr, png_uint_32 row,
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06003583 int pass);
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06003584 {
3585 /* put your code here */
3586 }
3587
3588(You can give it another name that you like instead of "write_row_callback")
3589
3590To inform libpng about your function, use
3591
3592 png_set_write_status_fn(png_ptr, write_row_callback);
3593
John Bowler59010e52011-02-16 06:16:31 -06003594When this function is called the row has already been completely processed and
3595it has also been written out. The 'row' and 'pass' refer to the next row to be
3596handled. For the
3597non-interlaced case the row that was just handled is simply one less than the
3598passed in row number, and pass will always be 0. For the interlaced case the
3599same applies unless the row value is 0, in which case the row just handled was
3600the last one from one of the preceding passes. Because interlacing may skip a
3601pass you cannot be sure that the preceding pass is just 'pass-1', if you really
3602need to know what the last pass is record (row,pass) from the callback and use
3603the last recorded value each time.
3604
3605As with the user transform you can find the output row using the
3606PNG_ROW_FROM_PASS_ROW macro.
3607
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003608You now have the option of modifying how the compression library will
3609run. The following functions are mainly for testing, but may be useful
3610in some cases, like if you need to write PNG files extremely fast and
3611are willing to give up some compression, or if you want to get the
3612maximum possible compression at the expense of slower writing. If you
3613have no special needs in this area, let the library do what it wants by
3614not calling this function at all, as it has been tuned to deliver a good
3615speed/compression ratio. The second parameter to png_set_filter() is
Glenn Randers-Pehrson408b4212000-12-18 09:33:57 -06003616the filter method, for which the only valid values are 0 (as of the
3617July 1999 PNG specification, version 1.2) or 64 (if you are writing
3618a PNG datastream that is to be embedded in a MNG datastream). The third
3619parameter is a flag that indicates which filter type(s) are to be tested
Glenn Randers-Pehrsonf210a052009-11-12 10:02:24 -06003620for each scanline. See the PNG specification for details on the specific
3621filter types.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003622
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06003623
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003624 /* turn on or off filtering, and/or choose
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06003625 specific filters. You can use either a single
Glenn Randers-Pehrsonebd7f9a2006-10-19 09:37:56 -05003626 PNG_FILTER_VALUE_NAME or the bitwise OR of one
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003627 or more PNG_FILTER_NAME masks.
3628 */
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003629 png_set_filter(png_ptr, 0,
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05003630 PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE |
3631 PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB |
3632 PNG_FILTER_UP | PNG_FILTER_VALUE_UP |
Glenn Randers-Pehrson76546822009-05-16 07:25:42 -05003633 PNG_FILTER_AVG | PNG_FILTER_VALUE_AVG |
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05003634 PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH|
3635 PNG_ALL_FILTERS);
3636
Glenn Randers-Pehrson6e974102010-12-19 16:44:22 -06003637If an application wants to start and stop using particular filters during
3638compression, it should start out with all of the filters (to ensure that
3639the previous row of pixels will be stored in case it's needed later),
3640and then add and remove them after the start of compression.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003641
Glenn Randers-Pehrson408b4212000-12-18 09:33:57 -06003642If you are writing a PNG datastream that is to be embedded in a MNG
3643datastream, the second parameter can be either 0 or 64.
3644
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06003645The png_set_compression_*() functions interface to the zlib compression
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003646library, and should mostly be ignored unless you really know what you are
3647doing. The only generally useful call is png_set_compression_level()
3648which changes how much time zlib spends on trying to compress the image
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05003649data. See the Compression Library (zlib.h and algorithm.txt, distributed
3650with zlib) for details on the compression levels.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003651
Glenn Randers-Pehrson38734ee2011-03-03 06:23:31 -06003652 #include zlib.h
3653
Glenn Randers-Pehrsona45f47c2011-04-01 15:31:26 -05003654 /* Set the zlib compression level */
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003655 png_set_compression_level(png_ptr,
3656 Z_BEST_COMPRESSION);
3657
Glenn Randers-Pehrsona45f47c2011-04-01 15:31:26 -05003658 /* Set other zlib parameters for compressing IDAT */
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003659 png_set_compression_mem_level(png_ptr, 8);
3660 png_set_compression_strategy(png_ptr,
3661 Z_DEFAULT_STRATEGY);
3662 png_set_compression_window_bits(png_ptr, 15);
3663 png_set_compression_method(png_ptr, 8);
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05003664 png_set_compression_buffer_size(png_ptr, 8192)
3665
Glenn Randers-Pehrsona45f47c2011-04-01 15:31:26 -05003666 /* Set zlib parameters for text compression
3667 * If you don't call these, the parameters
3668 * fall back on those defined for IDAT chunks
3669 */
Glenn Randers-Pehrson8eb88332011-04-01 00:16:50 -05003670 png_set_text_compression_mem_level(png_ptr, 8);
3671 png_set_text_compression_strategy(png_ptr,
3672 Z_DEFAULT_STRATEGY);
3673 png_set_text_compression_window_bits(png_ptr, 15);
3674 png_set_text_compression_method(png_ptr, 8);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003675
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06003676.SS Setting the contents of info for output
3677
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003678You now need to fill in the png_info structure with all the data you
3679wish to write before the actual image. Note that the only thing you
3680are allowed to write after the image is the text chunks and the time
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05003681chunk (as of PNG Specification 1.2, anyway). See png_write_end() and
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003682the latest PNG specification for more information on that. If you
3683wish to write them before the image, fill them in now, and flag that
3684data as being valid. If you want to wait until after the data, don't
3685fill them until png_write_end(). For all the fields in png_info and
3686their data types, see png.h. For explanations of what the fields
3687contain, see the PNG specification.
3688
3689Some of the more important parts of the png_info are:
3690
3691 png_set_IHDR(png_ptr, info_ptr, width, height,
3692 bit_depth, color_type, interlace_type,
Glenn Randers-Pehrson408b4212000-12-18 09:33:57 -06003693 compression_type, filter_method)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003694
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003695 width - holds the width of the image
3696 in pixels (up to 2^31).
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003697
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003698 height - holds the height of the image
3699 in pixels (up to 2^31).
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003700
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003701 bit_depth - holds the bit depth of one of the
3702 image channels.
3703 (valid values are 1, 2, 4, 8, 16
3704 and depend also on the
3705 color_type. See also significant
3706 bits (sBIT) below).
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003707
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003708 color_type - describes which color/alpha
3709 channels are present.
3710 PNG_COLOR_TYPE_GRAY
3711 (bit depths 1, 2, 4, 8, 16)
3712 PNG_COLOR_TYPE_GRAY_ALPHA
3713 (bit depths 8, 16)
3714 PNG_COLOR_TYPE_PALETTE
3715 (bit depths 1, 2, 4, 8)
3716 PNG_COLOR_TYPE_RGB
3717 (bit_depths 8, 16)
3718 PNG_COLOR_TYPE_RGB_ALPHA
3719 (bit_depths 8, 16)
3720
3721 PNG_COLOR_MASK_PALETTE
3722 PNG_COLOR_MASK_COLOR
3723 PNG_COLOR_MASK_ALPHA
3724
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06003725 interlace_type - PNG_INTERLACE_NONE or
3726 PNG_INTERLACE_ADAM7
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003727
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003728 compression_type - (must be
3729 PNG_COMPRESSION_TYPE_DEFAULT)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003730
Glenn Randers-Pehrson408b4212000-12-18 09:33:57 -06003731 filter_method - (must be PNG_FILTER_TYPE_DEFAULT
3732 or, if you are writing a PNG to
3733 be embedded in a MNG datastream,
3734 can also be
3735 PNG_INTRAPIXEL_DIFFERENCING)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003736
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05003737If you call png_set_IHDR(), the call must appear before any of the
Glenn Randers-Pehrsond60c8862009-06-15 21:56:14 -05003738other png_set_*() functions, because they might require access to some of
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05003739the IHDR settings. The remaining png_set_*() functions can be called
3740in any order.
3741
Glenn Randers-Pehrsonb5444a12009-06-08 08:36:19 -05003742If you wish, you can reset the compression_type, interlace_type, or
3743filter_method later by calling png_set_IHDR() again; if you do this, the
3744width, height, bit_depth, and color_type must be the same in each call.
Glenn Randers-Pehrson424c9852009-06-02 13:45:15 -05003745
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003746 png_set_PLTE(png_ptr, info_ptr, palette,
3747 num_palette);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003748
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003749 palette - the palette for the file
3750 (array of png_color)
3751 num_palette - number of entries in the palette
3752
Glenn Randers-Pehrson8d0bc0f2011-01-25 22:15:58 -06003753 png_set_gAMA(png_ptr, info_ptr, file_gamma);
3754 png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003755
Glenn Randers-Pehrson8d0bc0f2011-01-25 22:15:58 -06003756 file_gamma - the gamma at which the image was
3757 created (PNG_INFO_gAMA)
3758
3759 int_file_gamma - 100,000 times the gamma at which
3760 the image was created
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003761
John Bowlerbbd17bd2011-08-25 17:48:18 -05003762 png_set_cHRM(png_ptr, info_ptr, white_x, white_y, red_x, red_y,
3763 green_x, green_y, blue_x, blue_y)
3764 png_set_cHRM_XYZ(png_ptr, info_ptr, red_X, red_Y, red_Z, green_X,
3765 green_Y, green_Z, blue_X, blue_Y, blue_Z)
3766 png_set_cHRM_fixed(png_ptr, info_ptr, int_white_x, int_white_y,
3767 int_red_x, int_red_y, int_green_x, int_green_y,
3768 int_blue_x, int_blue_y)
3769 png_set_cHRM_XYZ_fixed(png_ptr, info_ptr, int_red_X, int_red_Y,
3770 int_red_Z, int_green_X, int_green_Y, int_green_Z,
3771 int_blue_X, int_blue_Y, int_blue_Z)
3772
3773 {white,red,green,blue}_{x,y}
3774 A color space encoding specified using the chromaticities
3775 of the end points and the white point.
3776
3777 {red,green,blue}_{X,Y,Z}
3778 A color space encoding specified using the encoding end
3779 points - the CIE tristimulus specification of the intended
3780 color of the red, green and blue channels in the PNG RGB
3781 data. The white point is simply the sum of the three end
3782 points.
3783
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003784 png_set_sRGB(png_ptr, info_ptr, srgb_intent);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003785
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003786 srgb_intent - the rendering intent
3787 (PNG_INFO_sRGB) The presence of
3788 the sRGB chunk means that the pixel
3789 data is in the sRGB color space.
3790 This chunk also implies specific
3791 values of gAMA and cHRM. Rendering
3792 intent is the CSS-1 property that
3793 has been defined by the International
3794 Color Consortium
3795 (http://www.color.org).
3796 It can be one of
Glenn Randers-Pehrson5379b241999-11-27 10:22:33 -06003797 PNG_sRGB_INTENT_SATURATION,
3798 PNG_sRGB_INTENT_PERCEPTUAL,
3799 PNG_sRGB_INTENT_ABSOLUTE, or
3800 PNG_sRGB_INTENT_RELATIVE.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06003801
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003802
3803 png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr,
3804 srgb_intent);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003805
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003806 srgb_intent - the rendering intent
3807 (PNG_INFO_sRGB) The presence of the
3808 sRGB chunk means that the pixel
3809 data is in the sRGB color space.
3810 This function also causes gAMA and
3811 cHRM chunks with the specific values
3812 that are consistent with sRGB to be
3813 written.
3814
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06003815 png_set_iCCP(png_ptr, info_ptr, name, compression_type,
Glenn Randers-Pehrson4a5a1ec2011-01-15 11:43:28 -06003816 profile, proflen);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003817
Glenn Randers-Pehrson4a5a1ec2011-01-15 11:43:28 -06003818 name - The profile name.
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003819
Glenn Randers-Pehrson4a5a1ec2011-01-15 11:43:28 -06003820 compression_type - The compression type; always
3821 PNG_COMPRESSION_TYPE_BASE for PNG 1.0.
3822 You may give NULL to this argument to
3823 ignore it.
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003824
Glenn Randers-Pehrson4a5a1ec2011-01-15 11:43:28 -06003825 profile - International Color Consortium color
3826 profile data. May contain NULs.
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003827
Glenn Randers-Pehrson4a5a1ec2011-01-15 11:43:28 -06003828 proflen - length of profile data in bytes.
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06003829
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003830 png_set_sBIT(png_ptr, info_ptr, sig_bit);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003831
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003832 sig_bit - the number of significant bits for
3833 (PNG_INFO_sBIT) each of the gray, red,
3834 green, and blue channels, whichever are
3835 appropriate for the given color type
3836 (png_color_16)
3837
Glenn Randers-Pehrson866b62a2009-08-08 16:33:14 -05003838 png_set_tRNS(png_ptr, info_ptr, trans_alpha,
3839 num_trans, trans_color);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003840
Glenn Randers-Pehrson866b62a2009-08-08 16:33:14 -05003841 trans_alpha - array of alpha (transparency)
3842 entries for palette (PNG_INFO_tRNS)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003843
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05003844 num_trans - number of transparent entries
3845 (PNG_INFO_tRNS)
3846
Glenn Randers-Pehrsonb5444a12009-06-08 08:36:19 -05003847 trans_color - graylevel or color sample values
3848 (in order red, green, blue) of the
3849 single transparent color for
Glenn Randers-Pehrson3d5a5202000-07-01 15:37:28 -05003850 non-paletted images (PNG_INFO_tRNS)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003851
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003852 png_set_hIST(png_ptr, info_ptr, hist);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003853
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003854 hist - histogram of palette (array of
Glenn Randers-Pehrson8d0bc0f2011-01-25 22:15:58 -06003855 png_uint_16) (PNG_INFO_hIST)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003856
3857 png_set_tIME(png_ptr, info_ptr, mod_time);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003858
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003859 mod_time - time image was last modified
3860 (PNG_VALID_tIME)
3861
3862 png_set_bKGD(png_ptr, info_ptr, background);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003863
Glenn Randers-Pehrsonab389792011-07-09 19:35:22 -05003864 background - background color (of type
3865 png_color_16p) (PNG_VALID_bKGD)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003866
3867 png_set_text(png_ptr, info_ptr, text_ptr, num_text);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003868
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003869 text_ptr - array of png_text holding image
3870 comments
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003871
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05003872 text_ptr[i].compression - type of compression used
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06003873 on "text" PNG_TEXT_COMPRESSION_NONE
3874 PNG_TEXT_COMPRESSION_zTXt
3875 PNG_ITXT_COMPRESSION_NONE
3876 PNG_ITXT_COMPRESSION_zTXt
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05003877 text_ptr[i].key - keyword for comment. Must contain
3878 1-79 characters.
3879 text_ptr[i].text - text comments for current
3880 keyword. Can be NULL or empty.
3881 text_ptr[i].text_length - length of text string,
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06003882 after decompression, 0 for iTXt
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05003883 text_ptr[i].itxt_length - length of itxt string,
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06003884 after decompression, 0 for tEXt/zTXt
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05003885 text_ptr[i].lang - language of comment (NULL or
3886 empty for unknown).
3887 text_ptr[i].translated_keyword - keyword in UTF-8 (NULL
3888 or empty for unknown).
Glenn Randers-Pehrson8f5846f2009-10-31 21:31:08 -05003889 Note that the itxt_length, lang, and lang_key
3890 members of the text_ptr structure only exist
3891 when the library is built with iTXt chunk support.
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05003892 Prior to libpng-1.4.0 the library was built by default
3893 without iTXt support.
Glenn Randers-Pehrson8f5846f2009-10-31 21:31:08 -05003894
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06003895 num_text - number of comments
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003896
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06003897 png_set_sPLT(png_ptr, info_ptr, &palette_ptr,
3898 num_spalettes);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003899
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06003900 palette_ptr - array of png_sPLT_struct structures
3901 to be added to the list of palettes
3902 in the info structure.
3903 num_spalettes - number of palette structures to be
3904 added.
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06003905
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003906 png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y,
3907 unit_type);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003908
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003909 offset_x - positive offset from the left
3910 edge of the screen
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003911
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003912 offset_y - positive offset from the top
3913 edge of the screen
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003914
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003915 unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER
3916
3917 png_set_pHYs(png_ptr, info_ptr, res_x, res_y,
3918 unit_type);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003919
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003920 res_x - pixels/unit physical resolution
3921 in x direction
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003922
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003923 res_y - pixels/unit physical resolution
3924 in y direction
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003925
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06003926 unit_type - PNG_RESOLUTION_UNKNOWN,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003927 PNG_RESOLUTION_METER
3928
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06003929 png_set_sCAL(png_ptr, info_ptr, unit, width, height)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003930
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05003931 unit - physical scale units (an integer)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003932
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06003933 width - width of a pixel in physical scale units
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003934
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06003935 height - height of a pixel in physical scale units
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05003936 (width and height are doubles)
3937
3938 png_set_sCAL_s(png_ptr, info_ptr, unit, width, height)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003939
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05003940 unit - physical scale units (an integer)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003941
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05003942 width - width of a pixel in physical scale units
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05003943 expressed as a string
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003944
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05003945 height - height of a pixel in physical scale units
3946 (width and height are strings like "2.54")
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06003947
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06003948 png_set_unknown_chunks(png_ptr, info_ptr, &unknowns,
3949 num_unknowns)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003950
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06003951 unknowns - array of png_unknown_chunk
3952 structures holding unknown chunks
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06003953 unknowns[i].name - name of unknown chunk
3954 unknowns[i].data - data of unknown chunk
Glenn Randers-Pehrson4accabb2000-04-14 14:20:47 -05003955 unknowns[i].size - size of unknown chunk's data
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06003956 unknowns[i].location - position to write chunk in file
3957 0: do not write chunk
3958 PNG_HAVE_IHDR: before PLTE
3959 PNG_HAVE_PLTE: before IDAT
3960 PNG_AFTER_IDAT: after IDAT
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06003961
3962The "location" member is set automatically according to
3963what part of the output file has already been written.
3964You can change its value after calling png_set_unknown_chunks()
3965as demonstrated in pngtest.c. Within each of the "locations",
3966the chunks are sequenced according to their position in the
3967structure (that is, the value of "i", which is the order in which
3968the chunk was either read from the input file or defined with
3969png_set_unknown_chunks).
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003970
3971A quick word about text and num_text. text is an array of png_text
3972structures. num_text is the number of valid structures in the array.
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05003973Each png_text structure holds a language code, a keyword, a text value,
3974and a compression type.
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06003975
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003976The compression types have the same valid numbers as the compression
3977types of the image data. Currently, the only valid number is zero.
3978However, you can store text either compressed or uncompressed, unlike
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06003979images, which always have to be compressed. So if you don't want the
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003980text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE.
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05003981Because tEXt and zTXt chunks don't have a language field, if you
3982specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt
3983any language code or translated keyword will not be written out.
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06003984
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05003985Until text gets around a few hundred bytes, it is not worth compressing it.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003986After the text has been written out to the file, the compression type
3987is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR,
3988so that it isn't written out again at the end (in case you are calling
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003989png_write_end() with the same struct).
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003990
3991The keywords that are given in the PNG Specification are:
3992
3993 Title Short (one line) title or
3994 caption for image
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003995
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003996 Author Name of image's creator
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003997
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06003998 Description Description of image (possibly long)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06003999
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004000 Copyright Copyright notice
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004001
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004002 Creation Time Time of original image creation
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06004003 (usually RFC 1123 format, see below)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004004
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004005 Software Software used to create the image
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004006
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004007 Disclaimer Legal disclaimer
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004008
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004009 Warning Warning of nature of content
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004010
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004011 Source Device used to create the image
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004012
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004013 Comment Miscellaneous comment; conversion
4014 from other image format
4015
4016The keyword-text pairs work like this. Keywords should be short
4017simple descriptions of what the comment is about. Some typical
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06004018keywords are found in the PNG specification, as is some recommendations
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004019on keywords. You can repeat keywords in a file. You can even write
4020some text before the image and some after. For example, you may want
4021to put a description of the image before the image, but leave the
4022disclaimer until after, so viewers working over modem connections
4023don't have to wait for the disclaimer to go over the modem before
4024they start seeing the image. Finally, keywords should be full
4025words, not abbreviations. Keywords and text are in the ISO 8859-1
4026(Latin-1) character set (a superset of regular ASCII) and can not
4027contain NUL characters, and should not contain control or other
4028unprintable characters. To make the comments widely readable, stick
4029with basic ASCII, and avoid machine specific character set extensions
4030like the IBM-PC character set. The keyword must be present, but
4031you can leave off the text string on non-compressed pairs.
4032Compressed pairs must have a text string, as only the text string
4033is compressed anyway, so the compression would be meaningless.
4034
4035PNG supports modification time via the png_time structure. Two
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -05004036conversion routines are provided, png_convert_from_time_t() for
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004037time_t and png_convert_from_struct_tm() for struct tm. The
4038time_t routine uses gmtime(). You don't have to use either of
4039these, but if you wish to fill in the png_time structure directly,
4040you should provide the time in universal time (GMT) if possible
4041instead of your local time. Note that the year number is the full
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06004042year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004043that months start with 1.
4044
4045If you want to store the time of the original image creation, you should
4046use a plain tEXt chunk with the "Creation Time" keyword. This is
4047necessary because the "creation time" of a PNG image is somewhat vague,
4048depending on whether you mean the PNG file, the time the image was
4049created in a non-PNG format, a still photo from which the image was
4050scanned, or possibly the subject matter itself. In order to facilitate
4051machine-readable dates, it is recommended that the "Creation Time"
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06004052tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"),
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004053although this isn't a requirement. Unlike the tIME chunk, the
4054"Creation Time" tEXt chunk is not expected to be automatically changed
4055by the software. To facilitate the use of RFC 1123 dates, a function
4056png_convert_to_rfc1123(png_timep) is provided to convert from PNG
4057time to an RFC 1123 format string.
4058
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004059.SS Writing unknown chunks
4060
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06004061You can use the png_set_unknown_chunks function to queue up chunks
4062for writing. You give it a chunk name, raw data, and a size; that's
4063all there is to it. The chunks will be written by the next following
4064png_write_info_before_PLTE, png_write_info, or png_write_end function.
4065Any chunks previously read into the info structure's unknown-chunk
4066list will also be written out in a sequence that satisfies the PNG
4067specification's ordering rules.
4068
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004069.SS The high-level write interface
4070
4071At this point there are two ways to proceed; through the high-level
4072write interface, or through a sequence of low-level write operations.
4073You can use the high-level interface if your image data is present
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -05004074in the info structure. All defined output
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06004075transformations are permitted, enabled by the following masks.
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004076
4077 PNG_TRANSFORM_IDENTITY No transformation
4078 PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06004079 PNG_TRANSFORM_PACKSWAP Change order of packed
4080 pixels to LSB first
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004081 PNG_TRANSFORM_INVERT_MONO Invert monochrome images
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06004082 PNG_TRANSFORM_SHIFT Normalize pixels to the
4083 sBIT depth
4084 PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA
4085 to BGRA
4086 PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA
4087 to AG
4088 PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity
4089 to transparency
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004090 PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples
Glenn Randers-Pehrson1eb14e92008-12-10 07:14:45 -06004091 PNG_TRANSFORM_STRIP_FILLER Strip out filler
4092 bytes (deprecated).
4093 PNG_TRANSFORM_STRIP_FILLER_BEFORE Strip out leading
4094 filler bytes
4095 PNG_TRANSFORM_STRIP_FILLER_AFTER Strip out trailing
4096 filler bytes
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004097
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -05004098If you have valid image data in the info structure (you can use
4099png_set_rows() to put image data in the info structure), simply do this:
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004100
4101 png_write_png(png_ptr, info_ptr, png_transforms, NULL)
4102
Glenn Randers-Pehrsonebd7f9a2006-10-19 09:37:56 -05004103where png_transforms is an integer containing the bitwise OR of some set of
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004104transformation flags. This call is equivalent to png_write_info(),
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -05004105followed the set of transformations indicated by the transform mask,
4106then png_write_image(), and finally png_write_end().
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004107
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -05004108(The final parameter of this call is not yet used. Someday it might point
4109to transformation parameters required by some future output transform.)
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004110
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -05004111You must use png_transforms and not call any png_set_transform() functions
4112when you use png_write_png().
4113
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004114.SS The low-level write interface
4115
4116If you are going the low-level route instead, you are now ready to
4117write all the file information up to the actual image data. You do
4118this with a call to png_write_info().
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004119
4120 png_write_info(png_ptr, info_ptr);
4121
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004122Note that there is one transformation you may need to do before
4123png_write_info(). In PNG files, the alpha channel in an image is the
Glenn Randers-Pehrsonf210a052009-11-12 10:02:24 -06004124level of opacity. If your data is supplied as a level of transparency,
4125you can invert the alpha channel before you write it, so that 0 is
4126fully transparent and 255 (in 8-bit or paletted images) or 65535
4127(in 16-bit images) is fully opaque, with
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004128
4129 png_set_invert_alpha(png_ptr);
4130
4131This must appear before png_write_info() instead of later with the
4132other transformations because in the case of paletted images the tRNS
4133chunk data has to be inverted before the tRNS chunk is written. If
4134your image is not a paletted image, the tRNS data (which in such cases
4135represents a single color to be rendered as transparent) won't need to
4136be changed, and you can safely do this transformation after your
4137png_write_info() call.
4138
Glenn Randers-Pehrson5379b241999-11-27 10:22:33 -06004139If you need to write a private chunk that you want to appear before
4140the PLTE chunk when PLTE is present, you can write the PNG info in
4141two steps, and insert code to write your own chunk between them:
4142
4143 png_write_info_before_PLTE(png_ptr, info_ptr);
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06004144 png_set_unknown_chunks(png_ptr, info_ptr, ...);
Glenn Randers-Pehrson5379b241999-11-27 10:22:33 -06004145 png_write_info(png_ptr, info_ptr);
4146
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004147After you've written the file information, you can set up the library
4148to handle any special transformations of the image data. The various
4149ways to transform the data will be described in the order that they
4150should occur. This is important, as some of these change the color
4151type and/or bit depth of the data, and some others only work on
4152certain color types and bit depths. Even though each transformation
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06004153checks to see if it has data that it can do something with, you should
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004154make sure to only enable a transformation if it will be valid for the
4155data. For example, don't swap red and blue on grayscale data.
4156
Glenn Randers-Pehrson896239b1998-04-21 15:03:57 -05004157PNG files store RGB pixels packed into 3 or 6 bytes. This code tells
Glenn Randers-Pehrson68ea2432000-04-01 21:10:05 -06004158the library to strip input data that has 4 or 8 bytes per pixel down
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06004159to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2
4160bytes per pixel).
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004161
4162 png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
4163
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06004164where the 0 is unused, and the location is either PNG_FILLER_BEFORE or
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05004165PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel
4166is stored XRGB or RGBX.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004167
4168PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
4169they can, resulting in, for example, 8 pixels per byte for 1 bit files.
4170If the data is supplied at 1 pixel per byte, use this code, which will
4171correctly pack the pixels into a single byte:
4172
4173 png_set_packing(png_ptr);
4174
4175PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your
4176data is of another bit depth, you can write an sBIT chunk into the
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05004177file so that decoders can recover the original data if desired.
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06004178
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004179 /* Set the true bit depth of the image data */
4180 if (color_type & PNG_COLOR_MASK_COLOR)
4181 {
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004182 sig_bit.red = true_bit_depth;
4183 sig_bit.green = true_bit_depth;
4184 sig_bit.blue = true_bit_depth;
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004185 }
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004186
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004187 else
4188 {
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004189 sig_bit.gray = true_bit_depth;
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004190 }
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004191
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004192 if (color_type & PNG_COLOR_MASK_ALPHA)
4193 {
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004194 sig_bit.alpha = true_bit_depth;
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004195 }
4196
4197 png_set_sBIT(png_ptr, info_ptr, &sig_bit);
4198
4199If the data is stored in the row buffer in a bit depth other than
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06004200one 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 -06004201this will scale the values to appear to be the correct bit depth as
4202is required by PNG.
4203
4204 png_set_shift(png_ptr, &sig_bit);
4205
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05004206PNG files store 16-bit pixels in network byte order (big-endian,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004207ie. most significant bits first). This code would be used if they are
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06004208supplied the other way (little-endian, i.e. least significant bits
4209first, the way PCs store them):
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004210
4211 if (bit_depth > 8)
4212 png_set_swap(png_ptr);
4213
4214If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you
4215need to change the order the pixels are packed into bytes, you can use:
4216
4217 if (bit_depth < 8)
4218 png_set_packswap(png_ptr);
4219
4220PNG files store 3 color pixels in red, green, blue order. This code
4221would be used if they are supplied as blue, green, red:
4222
4223 png_set_bgr(png_ptr);
4224
4225PNG files describe monochrome as black being zero and white being
4226one. This code would be used if the pixels are supplied with this reversed
4227(black being one and white being zero):
4228
4229 png_set_invert_mono(png_ptr);
4230
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06004231Finally, you can write your own transformation function if none of
4232the existing ones meets your needs. This is done by setting a callback
4233with
4234
4235 png_set_write_user_transform_fn(png_ptr,
4236 write_transform_fn);
4237
4238You must supply the function
4239
Glenn Randers-Pehrson93215672011-02-13 19:42:19 -06004240 void write_transform_fn(png_structp png_ptr, png_row_infop
4241 row_info, png_bytep data)
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06004242
4243See pngtest.c for a working example. Your function will be called
John Bowlerf19abd62011-01-22 18:29:24 -06004244before any of the other transformations are processed. If supported
4245libpng also supplies an information routine that may be called from
4246your callback:
4247
4248 png_get_current_row_number(png_ptr);
John Bowlercd113452011-02-16 06:15:13 -06004249 png_get_current_pass_number(png_ptr);
John Bowlerf19abd62011-01-22 18:29:24 -06004250
John Bowlercd113452011-02-16 06:15:13 -06004251This returns the current row passed to the transform. With interlaced
4252images the value returned is the row in the input sub-image image. Use
4253PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to
4254find the output pixel (x,y) given an interlaced sub-image pixel (row,col,pass).
4255
4256The discussion of interlace handling above contains more information on how to
4257use these values.
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05004258
4259You can also set up a pointer to a user structure for use by your
4260callback function.
4261
4262 png_set_user_transform_info(png_ptr, user_ptr, 0, 0);
4263
4264The user_channels and user_depth parameters of this function are ignored
4265when writing; you can set them to zero as shown.
4266
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05004267You can retrieve the pointer via the function png_get_user_transform_ptr().
4268For example:
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05004269
4270 voidp write_user_transform_ptr =
4271 png_get_user_transform_ptr(png_ptr);
Glenn Randers-Pehrson08a33431998-03-07 06:06:55 -06004272
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004273It is possible to have libpng flush any pending output, either manually,
4274or automatically after a certain number of lines have been written. To
4275flush the output stream a single time call:
4276
4277 png_write_flush(png_ptr);
4278
4279and to have libpng flush the output stream periodically after a certain
4280number of scanlines have been written, call:
4281
4282 png_set_flush(png_ptr, nrows);
4283
4284Note that the distance between rows is from the last time png_write_flush()
4285was called, or the first row of the image if it has never been called.
4286So if you write 50 lines, and then png_set_flush 25, it will flush the
4287output on the next scanline, and every 25 lines thereafter, unless
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06004288png_write_flush() is called before 25 more lines have been written.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004289If nrows is too small (less than about 10 lines for a 640 pixel wide
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06004290RGB image) the image compression may decrease noticeably (although this
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004291may be acceptable for real-time applications). Infrequent flushing will
4292only degrade the compression performance by a few percent over images
4293that do not use flushing.
4294
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004295.SS Writing the image data
4296
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004297That's it for the transformations. Now you can write the image data.
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06004298The simplest way to do this is in one function call. If you have the
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004299whole image in memory, you can just call png_write_image() and libpng
4300will write the image. You will need to pass in an array of pointers to
4301each row. This function automatically handles interlacing, so you don't
4302need to call png_set_interlace_handling() or call this function multiple
4303times, or any of that other stuff necessary with png_write_rows().
4304
4305 png_write_image(png_ptr, row_pointers);
4306
4307where row_pointers is:
4308
Glenn Randers-Pehrson896239b1998-04-21 15:03:57 -05004309 png_byte *row_pointers[height];
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004310
4311You can point to void or char or whatever you use for pixels.
4312
Glenn Randers-Pehrson896239b1998-04-21 15:03:57 -05004313If you don't want to write the whole image at once, you can
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004314use png_write_rows() instead. If the file is not interlaced,
4315this is simple:
4316
4317 png_write_rows(png_ptr, row_pointers,
4318 number_of_rows);
4319
4320row_pointers is the same as in the png_write_image() call.
4321
4322If you are just writing one row at a time, you can do this with
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06004323a single row_pointer instead of an array of row_pointers:
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004324
4325 png_bytep row_pointer = row;
4326
Glenn Randers-Pehrson520a7642000-03-21 05:13:06 -06004327 png_write_row(png_ptr, row_pointer);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004328
Glenn Randers-Pehrsonf210a052009-11-12 10:02:24 -06004329When the file is interlaced, things can get a good deal more complicated.
4330The only currently (as of the PNG Specification version 1.2, dated July
43311999) defined interlacing scheme for PNG files is the "Adam7" interlace
4332scheme, that breaks down an image into seven smaller images of varying
4333size. libpng will build these images for you, or you can do them
4334yourself. If you want to build them yourself, see the PNG specification
4335for details of which pixels to write when.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004336
4337If you don't want libpng to handle the interlacing details, just
4338use png_set_interlace_handling() and call png_write_rows() the
Glenn Randers-Pehrson6e974102010-12-19 16:44:22 -06004339correct number of times to write all the sub-images
4340(png_set_interlace_handling() returns the number of sub-images.)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004341
4342If you want libpng to build the sub-images, call this before you start
4343writing any rows:
4344
Glenn Randers-Pehrson6e974102010-12-19 16:44:22 -06004345 number_of_passes = png_set_interlace_handling(png_ptr);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004346
Glenn Randers-Pehrsonf210a052009-11-12 10:02:24 -06004347This will return the number of passes needed. Currently, this is seven,
4348but may change if another interlace type is added.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004349
4350Then write the complete image number_of_passes times.
4351
Glenn Randers-Pehrson6e974102010-12-19 16:44:22 -06004352 png_write_rows(png_ptr, row_pointers, number_of_rows);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004353
Glenn Randers-Pehrson6e974102010-12-19 16:44:22 -06004354Think carefully before you write an interlaced image. Typically code that
4355reads such images reads all the image data into memory, uncompressed, before
4356doing any processing. Only code that can display an image on the fly can
4357take advantage of the interlacing and even then the image has to be exactly
4358the correct size for the output device, because scaling an image requires
4359adjacent pixels and these are not available until all the passes have been
4360read.
4361
4362If you do write an interlaced image you will hardly ever need to handle
4363the interlacing yourself. Call png_set_interlace_handling() and use the
4364approach described above.
4365
4366The only time it is conceivable that you will really need to write an
4367interlaced image pass-by-pass is when you have read one pass by pass and
4368made some pixel-by-pixel transformation to it, as described in the read
4369code above. In this case use the PNG_PASS_ROWS and PNG_PASS_COLS macros
4370to determine the size of each sub-image in turn and simply write the rows
4371you obtained from the read code.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004372
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004373.SS Finishing a sequential write
4374
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004375After you are finished writing the image, you should finish writing
4376the file. If you are interested in writing comments or time, you should
4377pass an appropriately filled png_info pointer. If you are not interested,
4378you can pass NULL.
4379
4380 png_write_end(png_ptr, info_ptr);
4381
4382When you are done, you can free all memory used by libpng like this:
4383
4384 png_destroy_write_struct(&png_ptr, &info_ptr);
4385
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06004386It is also possible to individually free the info_ptr members that
Glenn Randers-Pehrsonfc4a1432000-05-17 17:39:34 -05004387point to libpng-allocated storage with the following function:
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06004388
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06004389 png_free_data(png_ptr, info_ptr, mask, seq)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004390
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -05004391 mask - identifies data to be freed, a mask
Glenn Randers-Pehrsonebd7f9a2006-10-19 09:37:56 -05004392 containing the bitwise OR of one or
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -05004393 more of
4394 PNG_FREE_PLTE, PNG_FREE_TRNS,
4395 PNG_FREE_HIST, PNG_FREE_ICCP,
4396 PNG_FREE_PCAL, PNG_FREE_ROWS,
4397 PNG_FREE_SCAL, PNG_FREE_SPLT,
4398 PNG_FREE_TEXT, PNG_FREE_UNKN,
4399 or simply PNG_FREE_ALL
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004400
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06004401 seq - sequence number of item to be freed
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -05004402 (-1 for all items)
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06004403
Glenn Randers-Pehrsonfc4a1432000-05-17 17:39:34 -05004404This function may be safely called when the relevant storage has
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -05004405already been freed, or has not yet been allocated, or was allocated
Glenn Randers-Pehrsonf210a052009-11-12 10:02:24 -06004406by the user and not by libpng, and will in those cases do nothing.
4407The "seq" parameter is ignored if only one item of the selected data
4408type, such as PLTE, is allowed. If "seq" is not -1, and multiple items
4409are allowed for the data type identified in the mask, such as text or
4410sPLT, only the n'th item in the structure is freed, where n is "seq".
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06004411
Glenn Randers-Pehrsonf210a052009-11-12 10:02:24 -06004412If you allocated data such as a palette that you passed in to libpng
4413with png_set_*, you must not free it until just before the call to
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06004414png_destroy_write_struct().
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004415
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -05004416The default behavior is only to free data that was allocated internally
4417by libpng. This can be changed, so that libpng will not free the data,
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -05004418or so that it will free data that was allocated by the user with png_malloc()
4419or png_zalloc() and passed in via a png_set_*() function, with
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -05004420
4421 png_data_freer(png_ptr, info_ptr, freer, mask)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004422
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -05004423 freer - one of
4424 PNG_DESTROY_WILL_FREE_DATA
4425 PNG_SET_WILL_FREE_DATA
4426 PNG_USER_WILL_FREE_DATA
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -05004427
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004428 mask - which data elements are affected
4429 same choices as in png_free_data()
4430
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -05004431For example, to transfer responsibility for some data from a read structure
4432to a write structure, you could use
4433
4434 png_data_freer(read_ptr, read_info_ptr,
4435 PNG_USER_WILL_FREE_DATA,
4436 PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004437
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -05004438 png_data_freer(write_ptr, write_info_ptr,
4439 PNG_DESTROY_WILL_FREE_DATA,
4440 PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST)
4441
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05004442thereby briefly reassigning responsibility for freeing to the user but
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -05004443immediately afterwards reassigning it once more to the write_destroy
4444function. Having done this, it would then be safe to destroy the read
4445structure and continue to use the PLTE, tRNS, and hIST data in the write
4446structure.
4447
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -05004448This function only affects data that has already been allocated.
4449You can call this function before calling after the png_set_*() functions
4450to control whether the user or png_destroy_*() is supposed to free the data.
4451When the user assumes responsibility for libpng-allocated data, the
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -05004452application must use
4453png_free() to free it, and when the user transfers responsibility to libpng
4454for data that the user has allocated, the user must have used png_malloc()
4455or png_zalloc() to allocate it.
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -05004456
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -05004457If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword
4458separately, do not transfer responsibility for freeing text_ptr to libpng,
4459because when libpng fills a png_text structure it combines these members with
4460the key member, and png_free_data() will free only text_ptr.key. Similarly,
4461if you transfer responsibility for free'ing text_ptr from libpng to your
4462application, your application must not separately free those members.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004463For a more compact example of writing a PNG image, see the file example.c.
4464
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06004465.SH V. Modifying/Customizing libpng:
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004466
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05004467There are two issues here. The first is changing how libpng does
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004468standard things like memory allocation, input/output, and error handling.
4469The second deals with more complicated things like adding new chunks,
4470adding new transformations, and generally changing how libpng works.
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06004471Both of those are compile-time issues; that is, they are generally
4472determined at the time the code is written, and there is rarely a need
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05004473to provide the user with a means of changing them.
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06004474
4475Memory allocation, input/output, and error handling
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004476
4477All of the memory allocation, input/output, and error handling in libpng
Glenn Randers-Pehrson231e6872001-01-12 15:13:06 -06004478goes through callbacks that are user-settable. The default routines are
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05004479in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06004480these functions, call the appropriate png_set_*_fn() function.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004481
Glenn Randers-Pehrsonf210a052009-11-12 10:02:24 -06004482Memory allocation is done through the functions png_malloc(), png_calloc(),
4483and png_free(). These currently just call the standard C functions.
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -05004484png_calloc() calls png_malloc() and then clears the newly
4485allocated memory to zero. There is limited support for certain systems
4486with segmented memory architectures and the types of pointers declared by
4487png.h match this; you will have to use appropriate pointers in your
4488application. Since it is
Glenn Randers-Pehrsonf210a052009-11-12 10:02:24 -06004489unlikely that the method of handling memory allocation on a platform
4490will change between applications, these functions must be modified in
4491the library at compile time. If you prefer to use a different method
4492of allocating and freeing data, you can use png_create_read_struct_2() or
4493png_create_write_struct_2() to register your own functions as described
4494above. These functions also provide a void pointer that can be retrieved
4495via
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -05004496
4497 mem_ptr=png_get_mem_ptr(png_ptr);
4498
4499Your replacement memory functions must have prototypes as follows:
4500
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06004501 png_voidp malloc_fn(png_structp png_ptr,
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -06004502 png_alloc_size_t size);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004503
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -05004504 void free_fn(png_structp png_ptr, png_voidp ptr);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004505
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -05004506Your malloc_fn() must return NULL in case of failure. The png_malloc()
4507function will normally call png_error() if it receives a NULL from the
4508system memory allocator or from your replacement malloc_fn().
Glenn Randers-Pehrson82ae3832001-04-20 10:32:10 -05004509
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05004510Your free_fn() will never be called with a NULL ptr, since libpng's
4511png_free() checks for NULL before calling free_fn().
4512
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004513Input/Output in libpng is done through png_read() and png_write(),
4514which currently just call fread() and fwrite(). The FILE * is stored in
4515png_struct and is initialized via png_init_io(). If you wish to change
4516the method of I/O, the library supplies callbacks that you can set
4517through the function png_set_read_fn() and png_set_write_fn() at run
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -05004518time, instead of calling the png_init_io() function. These functions
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004519also provide a void pointer that can be retrieved via the function
4520png_get_io_ptr(). For example:
4521
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -05004522 png_set_read_fn(png_structp read_ptr,
4523 voidp read_io_ptr, png_rw_ptr read_data_fn)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004524
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -05004525 png_set_write_fn(png_structp write_ptr,
4526 voidp write_io_ptr, png_rw_ptr write_data_fn,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004527 png_flush_ptr output_flush_fn);
4528
Glenn Randers-Pehrsonf7d1a171998-06-06 15:31:35 -05004529 voidp read_io_ptr = png_get_io_ptr(read_ptr);
4530 voidp write_io_ptr = png_get_io_ptr(write_ptr);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004531
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -05004532The replacement I/O functions must have prototypes as follows:
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004533
4534 void user_read_data(png_structp png_ptr,
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -05004535 png_bytep data, png_size_t length);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004536
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004537 void user_write_data(png_structp png_ptr,
Glenn Randers-Pehrson837a3d12002-05-10 20:19:58 -05004538 png_bytep data, png_size_t length);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004539
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004540 void user_flush_data(png_structp png_ptr);
4541
Glenn Randers-Pehrsonebd7f9a2006-10-19 09:37:56 -05004542The user_read_data() function is responsible for detecting and
4543handling end-of-data errors.
4544
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004545Supplying NULL for the read, write, or flush functions sets them back
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05004546to using the default C stream functions, which expect the io_ptr to
4547point to a standard *FILE structure. It is probably a mistake
4548to use NULL for one of write_data_fn and output_flush_fn but not both
4549of them, unless you have built libpng with PNG_NO_WRITE_FLUSH defined.
4550It is an error to read from a write stream, and vice versa.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004551
4552Error handling in libpng is done through png_error() and png_warning().
4553Errors handled through png_error() are fatal, meaning that png_error()
4554should never return to its caller. Currently, this is handled via
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004555setjmp() and longjmp() (unless you have compiled libpng with
Glenn Randers-Pehrson54ac9a92010-04-02 17:06:22 -05004556PNG_NO_SETJMP, in which case it is handled via PNG_ABORT()),
Glenn Randers-Pehrson60988072010-04-13 22:11:06 -05004557but you could change this to do things like exit() if you should wish,
Glenn Randers-Pehrson54ac9a92010-04-02 17:06:22 -05004558as long as your function does not return.
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004559
4560On non-fatal errors, png_warning() is called
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004561to print a warning message, and then control returns to the calling code.
4562By default png_error() and png_warning() print a message on stderr via
Glenn Randers-Pehrson38e6e772000-04-09 19:06:13 -05004563fprintf() unless the library is compiled with PNG_NO_CONSOLE_IO defined
4564(because you don't want the messages) or PNG_NO_STDIO defined (because
4565fprintf() isn't available). If you wish to change the behavior of the error
4566functions, you will need to set up your own message callbacks. These
4567functions are normally supplied at the time that the png_struct is created.
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05004568It is also possible to redirect errors and warnings to your own replacement
4569functions after png_create_*_struct() has been called by calling:
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004570
4571 png_set_error_fn(png_structp png_ptr,
4572 png_voidp error_ptr, png_error_ptr error_fn,
4573 png_error_ptr warning_fn);
4574
4575 png_voidp error_ptr = png_get_error_ptr(png_ptr);
4576
4577If NULL is supplied for either error_fn or warning_fn, then the libpng
4578default function will be used, calling fprintf() and/or longjmp() if a
4579problem is encountered. The replacement error functions should have
4580parameters as follows:
4581
4582 void user_error_fn(png_structp png_ptr,
4583 png_const_charp error_msg);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004584
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004585 void user_warning_fn(png_structp png_ptr,
4586 png_const_charp warning_msg);
4587
4588The motivation behind using setjmp() and longjmp() is the C++ throw and
4589catch exception handling methods. This makes the code much easier to write,
4590as there is no need to check every return code of every function call.
4591However, there are some uncertainties about the status of local variables
Glenn Randers-Pehrsonf210a052009-11-12 10:02:24 -06004592after a longjmp, so the user may want to be careful about doing anything
4593after setjmp returns non-zero besides returning itself. Consult your
4594compiler documentation for more details. For an alternative approach, you
Glenn Randers-Pehrsona5e55472011-07-12 10:13:32 -05004595may wish to use the "cexcept" facility (see http://cexcept.sourceforge.net),
4596which is illustrated in pngvalid.c and in contrib/visupng.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004597
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004598.SS Custom chunks
4599
4600If you need to read or write custom chunks, you may need to get deeper
4601into the libpng code. The library now has mechanisms for storing
4602and writing chunks of unknown type; you can even declare callbacks
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -06004603for custom chunks. However, this may not be good enough if the
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004604library code itself needs to know about interactions between your
4605chunk and existing `intrinsic' chunks.
4606
4607If you need to write a new intrinsic chunk, first read the PNG
Glenn Randers-Pehrsonf210a052009-11-12 10:02:24 -06004608specification. Acquire a first level of understanding of how it works.
4609Pay particular attention to the sections that describe chunk names,
4610and look at how other chunks were designed, so you can do things
4611similarly. Second, check out the sections of libpng that read and
4612write chunks. Try to find a chunk that is similar to yours and use
4613it as a template. More details can be found in the comments inside
Glenn Randers-Pehrsona5e55472011-07-12 10:13:32 -05004614the code. It is best to handle private or unknown chunks in a generic method,
4615via callback functions, instead of by modifying libpng functions. This
4616is illustrated in pngtest.c, which uses a callback function to handle a
4617private "vpAg" chunk and the new "sTER" chunk, which are both unknown to
4618libpng.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004619
4620If you wish to write your own transformation for the data, look through
4621the part of the code that does the transformations, and check out some of
4622the simpler ones to get an idea of how they work. Try to find a similar
4623transformation to the one you want to add and copy off of it. More details
4624can be found in the comments inside the code itself.
4625
Glenn Randers-Pehrson593fc042011-05-12 22:18:23 -05004626.SS Configuring for 16-bit platforms
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004627
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05004628You will want to look into zconf.h to tell zlib (and thus libpng) that
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004629it cannot allocate more then 64K at a time. Even if you can, the memory
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06004630won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004631
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004632.SS Configuring for DOS
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004633
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06004634For DOS users who only have access to the lower 640K, you will
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004635have to limit zlib's memory usage via a png_set_compression_mem_level()
4636call. See zlib.h or zconf.h in the zlib library for more information.
4637
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004638.SS Configuring for Medium Model
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004639
4640Libpng's support for medium model has been tested on most of the popular
4641compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
4642defined, and FAR gets defined to far in pngconf.h, and you should be
4643all set. Everything in the library (except for zlib's structure) is
4644expecting far data. You must use the typedefs with the p or pp on
4645the end for pointers (or at least look at them and be careful). Make
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05004646note that the rows of data are defined as png_bytepp, which is
4647an "unsigned char far * far *".
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004648
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004649.SS Configuring for gui/windowing platforms:
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004650
4651You will need to write new error and warning functions that use the GUI
4652interface, as described previously, and set them to be the error and
Glenn Randers-Pehrsona77ef622000-02-18 13:48:52 -06004653warning functions at the time that png_create_*_struct() is called,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004654in order to have them available during the structure initialization.
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06004655They can be changed later via png_set_error_fn(). On some compilers,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004656you may also have to change the memory allocators (png_malloc, etc.).
4657
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004658.SS Configuring for compiler xxx:
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004659
Glenn Randers-Pehrsonbeb572e2006-08-19 13:59:24 -05004660All includes for libpng are in pngconf.h. If you need to add, change
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05004661or delete an include, this is the place to do it.
4662The includes that are not needed outside libpng are placed in pngpriv.h,
4663which is only used by the routines inside libpng itself.
4664The files in libpng proper only include pngpriv.h and png.h, which
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05004665%14%in turn includes pngconf.h.
4666in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h.
4667As of libpng-1.5.0, pngpriv.h also includes three other private header
4668files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material
4669that previously appeared in the public headers.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004670
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004671.SS Configuring zlib:
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004672
4673There are special functions to configure the compression. Perhaps the
4674most useful one changes the compression level, which currently uses
4675input compression values in the range 0 - 9. The library normally
4676uses the default compression level (Z_DEFAULT_COMPRESSION = 6). Tests
4677have shown that for a large majority of images, compression values in
4678the range 3-6 compress nearly as well as higher levels, and do so much
4679faster. For online applications it may be desirable to have maximum speed
4680(Z_BEST_SPEED = 1). With versions of zlib after v0.99, you can also
4681specify no compression (Z_NO_COMPRESSION = 0), but this would create
4682files larger than just storing the raw bitmap. You can specify the
4683compression level by calling:
4684
Glenn Randers-Pehrson38734ee2011-03-03 06:23:31 -06004685 #include zlib.h
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004686 png_set_compression_level(png_ptr, level);
4687
4688Another useful one is to reduce the memory level used by the library.
4689The memory level defaults to 8, but it can be lowered if you are
4690short on memory (running DOS, for example, where you only have 640K).
Glenn Randers-Pehrson4fb046a2002-04-15 09:25:51 -05004691Note that the memory level does have an effect on compression; among
4692other things, lower levels will result in sections of incompressible
4693data being emitted in smaller stored blocks, with a correspondingly
4694larger relative overhead of up to 15% in the worst case.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004695
Glenn Randers-Pehrson38734ee2011-03-03 06:23:31 -06004696 #include zlib.h
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004697 png_set_compression_mem_level(png_ptr, level);
4698
4699The other functions are for configuring zlib. They are not recommended
4700for normal use and may result in writing an invalid PNG file. See
4701zlib.h for more information on what these mean.
4702
Glenn Randers-Pehrson38734ee2011-03-03 06:23:31 -06004703 #include zlib.h
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004704 png_set_compression_strategy(png_ptr,
4705 strategy);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004706
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004707 png_set_compression_window_bits(png_ptr,
4708 window_bits);
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004709
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004710 png_set_compression_method(png_ptr, method);
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05004711
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05004712 png_set_compression_buffer_size(png_ptr, size);
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004713
Glenn Randers-Pehrson7a287242011-07-26 12:03:11 -05004714As of libpng version 1.5.4, additional APIs became
4715available to set these separately for non-IDAT
4716compressed chunks such as zTXt, iTXt, and iCCP:
4717
4718 #include zlib.h
4719 #if PNG_LIBPNG_VER <= 10504
4720 png_set_text_compression_level(png_ptr, level);
4721
4722 png_set_text_compression_mem_level(png_ptr, level);
4723
4724 png_set_text_compression_strategy(png_ptr,
4725 strategy);
4726
4727 png_set_text_compression_window_bits(png_ptr,
4728 window_bits);
4729
4730 png_set_text_compression_method(png_ptr, method);
4731 #endif
4732
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004733.SS Controlling row filtering
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004734
4735If you want to control whether libpng uses filtering or not, which
4736filters are used, and how it goes about picking row filters, you
4737can call one of these functions. The selection and configuration
4738of row filters can have a significant impact on the size and
4739encoding speed and a somewhat lesser impact on the decoding speed
4740of an image. Filtering is enabled by default for RGB and grayscale
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06004741images (with and without alpha), but not for paletted images nor
4742for any images with bit depths less than 8 bits/pixel.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004743
4744The 'method' parameter sets the main filtering method, which is
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05004745currently only '0' in the PNG 1.2 specification. The 'filters'
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004746parameter sets which filter(s), if any, should be used for each
4747scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS
4748to turn filtering on and off, respectively.
4749
4750Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB,
4751PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise
Glenn Randers-Pehrson6942d532000-05-01 09:31:54 -05004752ORed together with '|' to specify one or more filters to use.
Glenn Randers-Pehrson4fb046a2002-04-15 09:25:51 -05004753These filters are described in more detail in the PNG specification.
4754If you intend to change the filter type during the course of writing
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004755the image, you should start with flags set for all of the filters
4756you intend to use so that libpng can initialize its internal
Glenn Randers-Pehrson4fb046a2002-04-15 09:25:51 -05004757structures appropriately for all of the filter types. (Note that this
4758means the first row must always be adaptively filtered, because libpng
4759currently does not allocate the filter buffers until png_write_row()
4760is called for the first time.)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004761
4762 filters = PNG_FILTER_NONE | PNG_FILTER_SUB
Glenn Randers-Pehrson76546822009-05-16 07:25:42 -05004763 PNG_FILTER_UP | PNG_FILTER_AVG |
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05004764 PNG_FILTER_PAETH | PNG_ALL_FILTERS;
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05004765
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004766 png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE,
4767 filters);
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06004768 The second parameter can also be
4769 PNG_INTRAPIXEL_DIFFERENCING if you are
4770 writing a PNG to be embedded in a MNG
4771 datastream. This parameter must be the
4772 same as the value of filter_method used
4773 in png_set_IHDR().
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004774
4775It is also possible to influence how libpng chooses from among the
Glenn Randers-Pehrson4fb046a2002-04-15 09:25:51 -05004776available filters. This is done in one or both of two ways - by
4777telling it how important it is to keep the same filter for successive
4778rows, and by telling it the relative computational costs of the filters.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004779
4780 double weights[3] = {1.5, 1.3, 1.1},
4781 costs[PNG_FILTER_VALUE_LAST] =
4782 {1.0, 1.3, 1.3, 1.5, 1.7};
4783
Glenn Randers-Pehrson4fb046a2002-04-15 09:25:51 -05004784 png_set_filter_heuristics(png_ptr,
4785 PNG_FILTER_HEURISTIC_WEIGHTED, 3,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004786 weights, costs);
4787
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06004788The weights are multiplying factors that indicate to libpng that the
4789row filter should be the same for successive rows unless another row filter
4790is that many times better than the previous filter. In the above example,
4791if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004792"sum of absolute differences" 1.5 x 1.3 times higher than other filters
4793and still be chosen, while the NONE filter could have a sum 1.1 times
4794higher than other filters and still be chosen. Unspecified weights are
4795taken to be 1.0, and the specified weights should probably be declining
4796like those above in order to emphasize recent filters over older filters.
4797
4798The filter costs specify for each filter type a relative decoding cost
4799to be considered when selecting row filters. This means that filters
4800with higher costs are less likely to be chosen over filters with lower
4801costs, unless their "sum of absolute differences" is that much smaller.
4802The costs do not necessarily reflect the exact computational speeds of
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06004803the various filters, since this would unduly influence the final image
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004804size.
4805
4806Note that the numbers above were invented purely for this example and
4807are given only to help explain the function usage. Little testing has
4808been done to find optimum values for either the costs or the weights.
4809
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004810.SS Removing unwanted object code
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004811
4812There are a bunch of #define's in pngconf.h that control what parts of
4813libpng are compiled. All the defines end in _SUPPORTED. If you are
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -05004814never going to use a capability, you can change the #define to #undef
4815before recompiling libpng and save yourself code and data space, or
4816you can turn off individual capabilities with defines that begin with
4817PNG_NO_.
4818
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004819In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead.
4820
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -05004821You can also turn all of the transforms and ancillary chunk capabilities
Glenn Randers-Pehrson228bd392000-04-23 23:14:02 -05004822off en masse with compiler directives that define
Glenn Randers-Pehrsond0dce401998-05-09 10:02:29 -05004823PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
4824or all four,
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004825along with directives to turn on any of the capabilities that you do
Glenn Randers-Pehrsonf210a052009-11-12 10:02:24 -06004826want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the extra
4827transformations but still leave the library fully capable of reading
4828and writing PNG files with all known public chunks. Use of the
4829PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library
4830that is incapable of reading or writing ancillary chunks. If you are
4831not using the progressive reading capability, you can turn that off
4832with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING
4833capability, which you'll still have).
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004834
4835All the reading and writing specific code are in separate files, so the
4836linker should only grab the files it needs. However, if you want to
4837make sure, or if you are building a stand alone library, all the
Glenn Randers-Pehrsona5e55472011-07-12 10:13:32 -05004838reading files start with "pngr" and all the writing files start with "pngw".
4839The files that don't match either (like png.c, pngtrans.c, etc.)
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004840are used for both reading and writing, and always need to be included.
4841The progressive reader is in pngpread.c
4842
4843If you are creating or distributing a dynamically linked library (a .so
4844or DLL file), you should not remove or disable any parts of the library,
4845as this will cause applications linked with different versions of the
4846library to fail if they call functions not available in your library.
4847The size of the library itself should not be an issue, because only
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06004848those sections that are actually used will be loaded into memory.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004849
Glenn Randers-Pehrson61c32d92000-02-04 23:40:16 -06004850.SS Requesting debug printout
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004851
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06004852The macro definition PNG_DEBUG can be used to request debugging
4853printout. Set it to an integer value in the range 0 to 3. Higher
4854numbers result in increasing amounts of debugging information. The
4855information is printed to the "stderr" file, unless another file
4856name is specified in the PNG_DEBUG_FILE macro definition.
4857
4858When PNG_DEBUG > 0, the following functions (macros) become available:
4859
4860 png_debug(level, message)
4861 png_debug1(level, message, p1)
4862 png_debug2(level, message, p1, p2)
4863
4864in which "level" is compared to PNG_DEBUG to decide whether to print
4865the message, "message" is the formatted string to be printed,
4866and p1 and p2 are parameters that are to be embedded in the string
4867according to printf-style formatting directives. For example,
4868
4869 png_debug1(2, "foo=%d\n", foo);
4870
4871is expanded to
4872
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004873 if (PNG_DEBUG > 2)
4874 fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo);
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06004875
4876When PNG_DEBUG is defined but is zero, the macros aren't defined, but you
4877can still use PNG_DEBUG to control your own debugging:
4878
4879 #ifdef PNG_DEBUG
4880 fprintf(stderr, ...
4881 #endif
4882
4883When PNG_DEBUG = 1, the macros are defined, but only png_debug statements
4884having level = 0 will be printed. There aren't any such statements in
4885this version of libpng, but if you insert some they will be printed.
4886
Glenn Randers-Pehrson56f63962008-10-06 10:16:17 -05004887.SH VI. MNG support
Glenn Randers-Pehrson2ad31ae2000-12-15 08:54:42 -06004888
4889The MNG specification (available at http://www.libpng.org/pub/mng) allows
4890certain extensions to PNG for PNG images that are embedded in MNG datastreams.
4891Libpng can support some of these extensions. To enable them, use the
4892png_permit_mng_features() function:
4893
4894 feature_set = png_permit_mng_features(png_ptr, mask)
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004895
Glenn Randers-Pehrsonebd7f9a2006-10-19 09:37:56 -05004896 mask is a png_uint_32 containing the bitwise OR of the
Glenn Randers-Pehrson2ad31ae2000-12-15 08:54:42 -06004897 features you want to enable. These include
4898 PNG_FLAG_MNG_EMPTY_PLTE
4899 PNG_FLAG_MNG_FILTER_64
4900 PNG_ALL_MNG_FEATURES
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004901
Glenn Randers-Pehrsonebd7f9a2006-10-19 09:37:56 -05004902 feature_set is a png_uint_32 that is the bitwise AND of
Glenn Randers-Pehrson2ad31ae2000-12-15 08:54:42 -06004903 your mask with the set of MNG features that is
4904 supported by the version of libpng that you are using.
4905
Glenn Randers-Pehrson408b4212000-12-18 09:33:57 -06004906It is an error to use this function when reading or writing a standalone
4907PNG file with the PNG 8-byte signature. The PNG datastream must be wrapped
Glenn Randers-Pehrsonf05f8032000-12-23 14:27:39 -06004908in a MNG datastream. As a minimum, it must have the MNG 8-byte signature
4909and the MHDR and MEND chunks. Libpng does not provide support for these
4910or any other MNG chunks; your application must provide its own support for
4911them. You may wish to consider using libmng (available at
4912http://www.libmng.com) instead.
Glenn Randers-Pehrson408b4212000-12-18 09:33:57 -06004913
Glenn Randers-Pehrson8fb550c2009-03-21 08:15:32 -05004914.SH VII. Changes to Libpng from version 0.88
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004915
4916It should be noted that versions of libpng later than 0.96 are not
4917distributed by the original libpng author, Guy Schalnat, nor by
4918Andreas Dilger, who had taken over from Guy during 1996 and 1997, and
4919distributed versions 0.89 through 0.96, but rather by another member
4920of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are
4921still alive and well, but they have moved on to other things.
4922
4923The old libpng functions png_read_init(), png_write_init(),
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -05004924png_info_init(), png_read_destroy(), and png_write_destroy() have been
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05004925moved to PNG_INTERNAL in version 0.95 to discourage their use. These
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06004926functions will be removed from libpng version 1.4.0.
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05004927
4928The preferred method of creating and initializing the libpng structures is
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004929via the png_create_read_struct(), png_create_write_struct(), and
4930png_create_info_struct() because they isolate the size of the structures
4931from the application, allow version error checking, and also allow the
4932use of custom error handling routines during the initialization, which
4933the old functions do not. The functions png_read_destroy() and
4934png_write_destroy() do not actually free the memory that libpng
4935allocated for these structs, but just reset the data structures, so they
4936can be used instead of png_destroy_read_struct() and
4937png_destroy_write_struct() if you feel there is too much system overhead
4938allocating and freeing the png_struct for each image read.
4939
4940Setting the error callbacks via png_set_message_fn() before
4941png_read_init() as was suggested in libpng-0.88 is no longer supported
Glenn Randers-Pehrson5c6aeb21998-12-29 11:47:59 -06004942because this caused applications that do not use custom error functions
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004943to fail if the png_ptr was not initialized to zero. It is still possible
4944to set the error callbacks AFTER png_read_init(), or to change them with
Glenn Randers-Pehrson75294572000-05-06 14:09:57 -05004945png_set_error_fn(), which is essentially the same function, but with a new
4946name to force compilation errors with applications that try to use the old
4947method.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06004948
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -05004949Starting with version 1.0.7, you can find out which version of the library
4950you are using at run-time:
4951
4952 png_uint_32 libpng_vn = png_access_version_number();
4953
4954The number libpng_vn is constructed from the major version, minor
4955version with leading zero, and release number with leading zero,
4956(e.g., libpng_vn for version 1.0.7 is 10007).
4957
Glenn Randers-Pehrson95ba4172011-09-08 12:21:42 -05004958Note that this function does not take a png_ptr, so you can call it
4959before you've created one.
4960
Glenn Randers-Pehrson1ef65b62000-05-12 06:19:53 -05004961You can also check which version of png.h you used when compiling your
4962application:
4963
4964 png_uint_32 application_vn = PNG_LIBPNG_VER;
4965
Glenn Randers-Pehrson6a9c2ce2009-03-27 19:30:10 -05004966.SH VIII. Changes to Libpng from version 1.0.x to 1.2.x
Glenn Randers-Pehrson87544ac1999-01-13 22:06:39 -06004967
Glenn Randers-Pehrson6a9c2ce2009-03-27 19:30:10 -05004968Support for user memory management was enabled by default. To
4969accomplish this, the functions png_create_read_struct_2(),
4970png_create_write_struct_2(), png_set_mem_fn(), png_get_mem_ptr(),
4971png_malloc_default(), and png_free_default() were added.
4972
Glenn Randers-Pehrsond6ea40a2009-11-02 07:32:00 -06004973Support for the iTXt chunk has been enabled by default as of
4974version 1.2.41.
4975
Glenn Randers-Pehrson6a9c2ce2009-03-27 19:30:10 -05004976Support for certain MNG features was enabled.
4977
4978Support for numbered error messages was added. However, we never got
4979around to actually numbering the error messages. The function
4980png_set_strip_error_numbers() was added (Note: the prototype for this
4981function was inadvertently removed from png.h in PNG_NO_ASSEMBLER_CODE
4982builds of libpng-1.2.15. It was restored in libpng-1.2.36).
4983
4984The png_malloc_warn() function was added at libpng-1.2.3. This issues
4985a png_warning and returns NULL instead of aborting when it fails to
4986acquire the requested memory allocation.
4987
4988Support for setting user limits on image width and height was enabled
4989by default. The functions png_set_user_limits(), png_get_user_width_max(),
4990and png_get_user_height_max() were added at libpng-1.2.6.
4991
4992The png_set_add_alpha() function was added at libpng-1.2.7.
4993
4994The function png_set_expand_gray_1_2_4_to_8() was added at libpng-1.2.9.
4995Unlike png_set_gray_1_2_4_to_8(), the new function does not expand the
4996tRNS chunk to alpha. The png_set_gray_1_2_4_to_8() function is
4997deprecated.
4998
4999A number of macro definitions in support of runtime selection of
5000assembler code features (especially Intel MMX code support) were
5001added at libpng-1.2.0:
5002
5003 PNG_ASM_FLAG_MMX_SUPPORT_COMPILED
5004 PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU
5005 PNG_ASM_FLAG_MMX_READ_COMBINE_ROW
5006 PNG_ASM_FLAG_MMX_READ_INTERLACE
5007 PNG_ASM_FLAG_MMX_READ_FILTER_SUB
5008 PNG_ASM_FLAG_MMX_READ_FILTER_UP
5009 PNG_ASM_FLAG_MMX_READ_FILTER_AVG
5010 PNG_ASM_FLAG_MMX_READ_FILTER_PAETH
5011 PNG_ASM_FLAGS_INITIALIZED
5012 PNG_MMX_READ_FLAGS
5013 PNG_MMX_FLAGS
5014 PNG_MMX_WRITE_FLAGS
5015 PNG_MMX_FLAGS
5016
5017We added the following functions in support of runtime
5018selection of assembler code features:
5019
5020 png_get_mmx_flagmask()
5021 png_set_mmx_thresholds()
5022 png_get_asm_flags()
5023 png_get_mmx_bitdepth_threshold()
5024 png_get_mmx_rowbytes_threshold()
5025 png_set_asm_flags()
5026
5027We replaced all of these functions with simple stubs in libpng-1.2.20,
5028when the Intel assembler code was removed due to a licensing issue.
5029
Glenn Randers-Pehrson3d893a02009-08-31 13:32:46 -05005030These macros are deprecated:
5031
5032 PNG_READ_TRANSFORMS_NOT_SUPPORTED
5033 PNG_PROGRESSIVE_READ_NOT_SUPPORTED
5034 PNG_NO_SEQUENTIAL_READ_SUPPORTED
5035 PNG_WRITE_TRANSFORMS_NOT_SUPPORTED
5036 PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED
5037 PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED
5038
5039They have been replaced, respectively, by:
5040
5041 PNG_NO_READ_TRANSFORMS
5042 PNG_NO_PROGRESSIVE_READ
5043 PNG_NO_SEQUENTIAL_READ
5044 PNG_NO_WRITE_TRANSFORMS
5045 PNG_NO_READ_ANCILLARY_CHUNKS
5046 PNG_NO_WRITE_ANCILLARY_CHUNKS
5047
Glenn Randers-Pehrson6a9c2ce2009-03-27 19:30:10 -05005048PNG_MAX_UINT was replaced with PNG_UINT_31_MAX. It has been
5049deprecated since libpng-1.0.16 and libpng-1.2.6.
5050
5051The function
5052 png_check_sig(sig, num)
5053was replaced with
5054 !png_sig_cmp(sig, 0, num)
5055It has been deprecated since libpng-0.90.
5056
Glenn Randers-Pehrson6a9c2ce2009-03-27 19:30:10 -05005057The function
5058 png_set_gray_1_2_4_to_8()
5059which also expands tRNS to alpha was replaced with
5060 png_set_expand_gray_1_2_4_to_8()
5061which does not. It has been deprecated since libpng-1.0.18 and 1.2.9.
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -06005062
Glenn Randers-Pehrsond740c842009-11-04 19:01:54 -06005063.SH IX. Changes to Libpng from version 1.0.x/1.2.x to 1.4.x
5064
5065Private libpng prototypes and macro definitions were moved from
5066png.h and pngconf.h into a new pngpriv.h header file.
5067
Glenn Randers-Pehrson6a9c2ce2009-03-27 19:30:10 -05005068Functions png_set_benign_errors(), png_benign_error(), and
5069png_chunk_benign_error() were added.
5070
5071Support for setting the maximum amount of memory that the application
5072will allocate for reading chunks was added, as a security measure.
5073The functions png_set_chunk_cache_max() and png_get_chunk_cache_max()
5074were added to the library.
5075
Glenn Randers-Pehrsonf210a052009-11-12 10:02:24 -06005076We implemented support for I/O states by adding png_ptr member io_state
5077and functions png_get_io_chunk_name() and png_get_io_state() in pngget.c
Glenn Randers-Pehrson6a9c2ce2009-03-27 19:30:10 -05005078
Glenn Randers-Pehrson5df7edb2009-10-29 23:32:44 -05005079We added PNG_TRANSFORM_GRAY_TO_RGB to the available high-level
5080input transforms.
5081
Glenn Randers-Pehrson5df7edb2009-10-29 23:32:44 -05005082Checking for and reporting of errors in the IHDR chunk is more thorough.
5083
Glenn Randers-Pehrson45af8192009-12-30 08:37:29 -06005084Support for global arrays was removed, to improve thread safety.
5085
5086Some obsolete/deprecated macros and functions have been removed.
5087
5088Typecasted NULL definitions such as
5089 #define png_voidp_NULL (png_voidp)NULL
5090were eliminated. If you used these in your application, just use
5091NULL instead.
5092
5093The png_struct and info_struct members "trans" and "trans_values" were
5094changed to "trans_alpha" and "trans_color", respectively.
5095
5096The obsolete, unused pnggccrd.c and pngvcrd.c files and related makefiles
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -06005097were removed.
Glenn Randers-Pehrson45af8192009-12-30 08:37:29 -06005098
5099The PNG_1_0_X and PNG_1_2_X macros were eliminated.
5100
Glenn Randers-Pehrson5df7edb2009-10-29 23:32:44 -05005101The PNG_LEGACY_SUPPORTED macro was eliminated.
5102
5103Many WIN32_WCE #ifdefs were removed.
5104
5105The functions png_read_init(info_ptr), png_write_init(info_ptr),
5106png_info_init(info_ptr), png_read_destroy(), and png_write_destroy()
5107have been removed. They have been deprecated since libpng-0.95.
5108
Glenn Randers-Pehrson6a9c2ce2009-03-27 19:30:10 -05005109The png_permit_empty_plte() was removed. It has been deprecated
5110since libpng-1.0.9. Use png_permit_mng_features() instead.
5111
5112We removed the obsolete stub functions png_get_mmx_flagmask(),
5113png_set_mmx_thresholds(), png_get_asm_flags(),
5114png_get_mmx_bitdepth_threshold(), png_get_mmx_rowbytes_threshold(),
5115png_set_asm_flags(), and png_mmx_supported()
5116
Glenn Randers-Pehrson45af8192009-12-30 08:37:29 -06005117We removed the obsolete png_check_sig(), png_memcpy_check(), and
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -05005118png_memset_check() functions. Instead use !png_sig_cmp(), memcpy(),
5119and memset(), respectively.
Glenn Randers-Pehrson6a9c2ce2009-03-27 19:30:10 -05005120
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -06005121The function png_set_gray_1_2_4_to_8() was removed. It has been
5122deprecated since libpng-1.0.18 and 1.2.9, when it was replaced with
5123png_set_expand_gray_1_2_4_to_8() because the former function also
Glenn Randers-Pehrsonc36bb792011-02-12 09:49:07 -06005124expanded any tRNS chunk to an alpha channel.
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -06005125
Glenn Randers-Pehrson5b40b012010-11-25 07:16:29 -06005126Macros for png_get_uint_16, png_get_uint_32, and png_get_int_32
5127were added and are used by default instead of the corresponding
5128functions. Unfortunately,
Glenn Randers-Pehrsonc36bb792011-02-12 09:49:07 -06005129from libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
Glenn Randers-Pehrson5b40b012010-11-25 07:16:29 -06005130function) incorrectly returned a value of type png_uint_32.
5131
Glenn Randers-Pehrson6a9c2ce2009-03-27 19:30:10 -05005132We changed the prototype for png_malloc() from
5133 png_malloc(png_structp png_ptr, png_uint_32 size)
5134to
5135 png_malloc(png_structp png_ptr, png_alloc_size_t size)
5136
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -06005137This also applies to the prototype for the user replacement malloc_fn().
5138
Glenn Randers-Pehrson45af8192009-12-30 08:37:29 -06005139The png_calloc() function was added and is used in place of
Glenn Randers-Pehrson2be8b642010-07-29 19:09:18 -05005140of "png_malloc(); memset();" except in the case in png_read_png()
Glenn Randers-Pehrson45af8192009-12-30 08:37:29 -06005141where the array consists of pointers; in this case a "for" loop is used
5142after the png_malloc() to set the pointers to NULL, to give robust.
5143behavior in case the application runs out of memory part-way through
5144the process.
5145
Glenn Randers-Pehrson6a9c2ce2009-03-27 19:30:10 -05005146We changed the prototypes of png_get_compression_buffer_size() and
5147png_set_compression_buffer_size() to work with png_size_t instead of
5148png_uint_32.
5149
Glenn Randers-Pehrson45af8192009-12-30 08:37:29 -06005150Support for numbered error messages was removed by default, since we
5151never got around to actually numbering the error messages. The function
5152png_set_strip_error_numbers() was removed from the library by default.
5153
5154The png_zalloc() and png_zfree() functions are no longer exported.
Glenn Randers-Pehrson6a9c2ce2009-03-27 19:30:10 -05005155The png_zalloc() function no longer zeroes out the memory that it
5156allocates.
5157
Glenn Randers-Pehrson3cd7cff2010-04-16 19:27:08 -05005158Support for dithering was disabled by default in libpng-1.4.0, because
Glenn Randers-Pehrson9f1cd702011-04-16 19:40:23 -05005159it has not been well tested and doesn't actually "dither".
5160The code was not
Glenn Randers-Pehrson3cd7cff2010-04-16 19:27:08 -05005161removed, however, and could be enabled by building libpng with
5162PNG_READ_DITHER_SUPPORTED defined. In libpng-1.4.2, this support
5163was reenabled, but the function was renamed png_set_quantize() to
5164reflect more accurately what it actually does. At the same time,
5165the PNG_DITHER_[RED,GREEN_BLUE]_BITS macros were also renamed to
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06005166PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS, and PNG_READ_DITHER_SUPPORTED
5167was renamed to PNG_READ_QUANTIZE_SUPPORTED.
Glenn Randers-Pehrson60988072010-04-13 22:11:06 -05005168
Glenn Randers-Pehrson6a9c2ce2009-03-27 19:30:10 -05005169We removed the trailing '.' from the warning and error messages.
5170
Glenn Randers-Pehrson5b40b012010-11-25 07:16:29 -06005171.SH X. Changes to Libpng from version 1.4.x to 1.5.x
5172
Glenn Randers-Pehrsonc36bb792011-02-12 09:49:07 -06005173From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
Glenn Randers-Pehrson5b40b012010-11-25 07:16:29 -06005174function) incorrectly returned a value of type png_uint_32.
5175
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06005176A. Changes that affect users of libpng
5177
5178There are no substantial API changes between the non-deprecated parts of
5179the 1.4.5 API and the 1.5.0 API, however the ability to directly access
5180the main libpng control structures, png_struct and png_info, deprecated
5181in earlier versions of libpng, has been completely removed from
5182libpng 1.5.
5183
Glenn Randers-Pehrson00879b12011-01-15 19:25:34 -06005184We no longer include zlib.h in png.h. Applications that need access
5185to information in zlib.h will need to add the '#include "zlib.h"'
5186directive. It does not matter whether it is placed prior to or after
5187the '"#include png.h"' directive.
5188
5189We moved the png_strcpy(), png_strncpy(), png_strlen(), png_memcpy(),
5190png_memcmp(), png_sprintf, and png_memcpy() macros into a private
5191header file (pngpriv.h) that is not accessible to applications.
5192
Glenn Randers-Pehrson9d23b402011-01-08 10:42:01 -06005193In png_get_iCCP, the type of "profile" was changed from png_charpp
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06005194to png_bytepp, and in png_set_iCCP, from png_charp to png_const_bytep.
Glenn Randers-Pehrson9d23b402011-01-08 10:42:01 -06005195
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06005196There are changes of form in png.h, including new and changed macros to
Glenn Randers-Pehrson95ba4172011-09-08 12:21:42 -05005197declare parts of the API. Some API functions with arguments that are
5198pointers to data not modified within the function have been corrected to
5199declare these arguments with PNG_CONST.
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06005200
5201Much of the internal use of C macros to control the library build has also
5202changed and some of this is visible in the exported header files, in
5203particular the use of macros to control data and API elements visible
5204during application compilation may require significant revision to
5205application code. (It is extremely rare for an application to do this.)
5206
5207Any program that compiled against libpng 1.4 and did not use deprecated
5208features or access internal library structures should compile and work
Glenn Randers-Pehrsond08b6bd2011-02-19 15:50:17 -06005209against libpng 1.5, except for the change in the prototype for
5210png_get_iCCP() and png_set_iCCP() API functions mentioned above.
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06005211
Glenn Randers-Pehrson6e974102010-12-19 16:44:22 -06005212libpng 1.5.0 adds PNG_ PASS macros to help in the reading and writing of
5213interlaced images. The macros return the number of rows and columns in
5214each pass and information that can be used to de-interlace and (if
5215absolutely necessary) interlace an image.
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06005216
5217libpng 1.5.0 adds an API png_longjmp(png_ptr, value). This API calls
Glenn Randers-Pehrsond08b6bd2011-02-19 15:50:17 -06005218the application-provided png_longjmp_ptr on the internal, but application
Glenn Randers-Pehrson33ced442011-04-27 14:58:06 -05005219initialized, longjmp buffer. It is provided as a convenience to avoid
5220the need to use the png_jmpbuf macro, which had the unnecessary side
5221effect of resetting the internal png_longjmp_ptr value.
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06005222
5223libpng 1.5.0 includes a complete fixed point API. By default this is
5224present along with the corresponding floating point API. In general the
5225fixed point API is faster and smaller than the floating point one because
5226the PNG file format used fixed point, not floating point. This applies
5227even if the library uses floating point in internal calculations. A new
5228macro, PNG_FLOATING_ARITHMETIC_SUPPORTED, reveals whether the library
5229uses floating point arithmetic (the default) or fixed point arithmetic
5230internally for performance critical calculations such as gamma correction.
Glenn Randers-Pehrson00879b12011-01-15 19:25:34 -06005231In some cases, the gamma calculations may produce slightly different
5232results. This has changed the results in png_rgb_to_gray and in alpha
5233composition (png_set_background for example). This applies even if the
5234original image was already linear (gamma == 1.0) and, therefore, it is
5235not necessary to linearize the image. This is because libpng has *not*
5236been changed to optimize that case correctly, yet.
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06005237
5238Fixed point support for the sCAL chunk comes with an important caveat;
5239the sCAL specification uses a decimal encoding of floating point values
5240and the accuracy of PNG fixed point values is insufficient for
5241representation of these values. Consequently a "string" API
5242(png_get_sCAL_s and png_set_sCAL_s) is the only reliable way of reading
5243arbitrary sCAL chunks in the absence of either the floating point API or
5244internal floating point calculations.
5245
5246Applications no longer need to include the optional distribution header
5247file pngusr.h or define the corresponding macros during application
5248build in order to see the correct variant of the libpng API. From 1.5.0
5249application code can check for the corresponding _SUPPORTED macro:
5250
5251#ifdef PNG_INCH_CONVERSIONS_SUPPORTED
5252 /* code that uses the inch conversion APIs. */
5253#endif
5254
5255This macro will only be defined if the inch conversion functions have been
5256compiled into libpng. The full set of macros, and whether or not support
5257has been compiled in, are available in the header file pnglibconf.h.
5258This header file is specific to the libpng build. Notice that prior to
52591.5.0 the _SUPPORTED macros would always have the default definition unless
5260reset by pngusr.h or by explicit settings on the compiler command line.
5261These settings may produce compiler warnings or errors in 1.5.0 because
5262of macro redefinition.
5263
Glenn Randers-Pehrsonc36bb792011-02-12 09:49:07 -06005264From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06005265function) incorrectly returned a value of type png_uint_32. libpng 1.5.0
5266is consistent with the implementation in 1.4.5 and 1.2.x (where the macro
5267did not exist.)
5268
5269Applications can now choose whether to use these macros or to call the
5270corresponding function by defining PNG_USE_READ_MACROS or
5271PNG_NO_USE_READ_MACROS before including png.h. Notice that this is
5272only supported from 1.5.0 -defining PNG_NO_USE_READ_MACROS prior to 1.5.0
Glenn Randers-Pehrson95ba4172011-09-08 12:21:42 -05005273will lead to a link failure.
Glenn Randers-Pehrson59fa3e92011-01-06 07:07:06 -06005274
Glenn Randers-Pehrson733b1312011-06-15 13:21:01 -05005275Prior to libpng-1.5.4, the zlib compressor used the same set of parameters
Glenn Randers-Pehrson8eb88332011-04-01 00:16:50 -05005276when compressing the IDAT data and textual data such as zTXt and iCCP.
Glenn Randers-Pehrson733b1312011-06-15 13:21:01 -05005277In libpng-1.5.4 we reinitialized the zlib stream for each type of data.
Glenn Randers-Pehrson8eb88332011-04-01 00:16:50 -05005278We added five png_set_text_*() functions for setting the parameters to
5279use with textual data.
5280
Glenn Randers-Pehrson733b1312011-06-15 13:21:01 -05005281Prior to libpng-1.5.4, the PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
John Bowlerb2bee332011-06-10 23:24:58 -05005282option was off by default, and slightly inaccurate scaling occurred.
Glenn Randers-Pehrsonfb29e512011-06-17 20:38:24 -05005283This option can no longer be turned off, and the choice of accurate
5284or inaccurate 16-to-8 scaling is by using the new png_set_scale_16_to_8()
5285API for accurate scaling or the old png_set_strip_16_to_8() API for simple
5286chopping.
Glenn Randers-Pehrson0cb906d2011-06-11 14:22:22 -05005287
Glenn Randers-Pehrson733b1312011-06-15 13:21:01 -05005288Prior to libpng-1.5.4, the png_set_user_limits() function could only be
Glenn Randers-Pehrson0cb906d2011-06-11 14:22:22 -05005289used to reduce the width and height limits from the value of
5290PNG_USER_WIDTH_MAX and PNG_USER_HEIGHT_MAX, although this document said
5291that it could be used to override them. Now this function will reduce or
5292increase the limits.
John Bowlerb2bee332011-06-10 23:24:58 -05005293
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06005294B. Changes to the build and configuration of libpng
5295
5296Details of internal changes to the library code can be found in the CHANGES
Glenn Randers-Pehrsona5e55472011-07-12 10:13:32 -05005297file and in the GIT repository logs. These will be of no concern to the vast
5298majority of library users or builders, however the few who configure libpng
5299to a non-default feature set may need to change how this is done.
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06005300
5301There should be no need for library builders to alter build scripts if
5302these use the distributed build support - configure or the makefiles -
5303however users of the makefiles may care to update their build scripts
5304to build pnglibconf.h where the corresponding makefile does not do so.
5305
5306Building libpng with a non-default configuration has changed completely.
5307The old method using pngusr.h should still work correctly even though the
Glenn Randers-Pehrsona5e55472011-07-12 10:13:32 -05005308way pngusr.h is used in the build has been changed; however, library
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06005309builders will probably want to examine the changes to take advantage of
5310new capabilities and to simplify their build system.
5311
5312B.1 Specific changes to library configuration capabilities
5313
5314The library now supports a complete fixed point implementation and can
Glenn Randers-Pehrsona5e55472011-07-12 10:13:32 -05005315thus be used on systems that have no floating point support or very
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06005316limited or slow support. Previously gamma correction, an essential part
5317of complete PNG support, required reasonably fast floating point.
5318
5319As part of this the choice of internal implementation has been made
5320independent of the choice of fixed versus floating point APIs and all the
5321missing fixed point APIs have been implemented.
5322
5323The exact mechanism used to control attributes of API functions has
5324changed. A single set of operating system independent macro definitions
5325is used and operating system specific directives are defined in
5326pnglibconf.h
5327
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06005328As part of this the mechanism used to choose procedure call standards on
5329those systems that allow a choice has been changed. At present this only
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06005330affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems
Glenn Randers-Pehrsona5e55472011-07-12 10:13:32 -05005331running on Intel processors. As before, PNGAPI is defined where required
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06005332to control the exported API functions; however, two new macros, PNGCBAPI
5333and PNGCAPI, are used instead for callback functions (PNGCBAPI) and
5334(PNGCAPI) for functions that must match a C library prototype (currently
5335only png_longjmp_ptr, which must match the C longjmp function.) The new
5336approach is documented in pngconf.h
5337
Glenn Randers-Pehrsona5e55472011-07-12 10:13:32 -05005338Despite these changes, libpng 1.5.0 only supports the native C function
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06005339calling standard on those platforms tested so far (__cdecl on Microsoft
5340Windows). This is because the support requirements for alternative
5341calling conventions seem to no longer exist. Developers who find it
5342necessary to set PNG_API_RULE to 1 should advise the mailing list
5343(png-mng-implement) of this and library builders who use Openwatcom and
5344therefore set PNG_API_RULE to 2 should also contact the mailing list.
5345
5346A new test program, pngvalid, is provided in addition to pngtest.
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06005347pngvalid validates the arithmetic accuracy of the gamma correction
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06005348calculations and includes a number of validations of the file format.
5349A subset of the full range of tests is run when "make check" is done
5350(in the 'configure' build.) pngvalid also allows total allocated memory
5351usage to be evaluated and performs additional memory overwrite validation.
5352
5353Many changes to individual feature macros have been made. The following
5354are the changes most likely to be noticed by library builders who
5355configure libpng:
5356
53571) All feature macros now have consistent naming:
5358
5359#define PNG_NO_feature turns the feature off
5360#define PNG_feature_SUPPORTED turns the feature on
5361
5362pnglibconf.h contains one line for each feature macro which is either:
5363
5364#define PNG_feature_SUPPORTED
5365
5366if the feature is supported or:
5367
5368/*#undef PNG_feature_SUPPORTED*/
5369
5370if it is not. Library code consistently checks for the 'SUPPORTED' macro.
Glenn Randers-Pehrsond0797f52011-07-12 10:28:02 -05005371It does not, and libpng applications should not, check for the 'NO' macro
5372which will not normally be defined even if the feature is not supported.
5373The 'NO' macros are only used internally for setting or not setting the
5374corresponding 'SUPPORTED' macros.
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06005375
5376Compatibility with the old names is provided as follows:
5377
5378PNG_INCH_CONVERSIONS turns on PNG_INCH_CONVERSIONS_SUPPORTED
5379
5380And the following definitions disable the corresponding feature:
5381
5382PNG_SETJMP_NOT_SUPPORTED disables SETJMP
5383PNG_READ_TRANSFORMS_NOT_SUPPORTED disables READ_TRANSFORMS
5384PNG_NO_READ_COMPOSITED_NODIV disables READ_COMPOSITE_NODIV
5385PNG_WRITE_TRANSFORMS_NOT_SUPPORTED disables WRITE_TRANSFORMS
5386PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED disables READ_ANCILLARY_CHUNKS
5387PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED disables WRITE_ANCILLARY_CHUNKS
5388
5389Library builders should remove use of the above, inconsistent, names.
5390
53912) Warning and error message formatting was previously conditional on
5392the STDIO feature. The library has been changed to use the
5393CONSOLE_IO feature instead. This means that if CONSOLE_IO is disabled
5394the library no longer uses the printf(3) functions, even though the
5395default read/write implementations use (FILE) style stdio.h functions.
5396
53973) Three feature macros now control the fixed/floating point decisions:
5398
5399PNG_FLOATING_POINT_SUPPORTED enables the floating point APIs
5400
5401PNG_FIXED_POINT_SUPPORTED enables the fixed point APIs; however, in
5402practice these are normally required internally anyway (because the PNG
5403file format is fixed point), therefore in most cases PNG_NO_FIXED_POINT
5404merely stops the function from being exported.
5405
5406PNG_FLOATING_ARITHMETIC_SUPPORTED chooses between the internal floating
5407point implementation or the fixed point one. Typically the fixed point
5408implementation is larger and slower than the floating point implementation
5409on a system that supports floating point, however it may be faster on a
5410system which lacks floating point hardware and therefore uses a software
5411emulation.
5412
54134) Added PNG_{READ,WRITE}_INT_FUNCTIONS_SUPPORTED. This allows the
5414functions to read and write ints to be disabled independently of
5415PNG_USE_READ_MACROS, which allows libpng to be built with the functions
5416even though the default is to use the macros - this allows applications
5417to choose at app buildtime whether or not to use macros (previously
5418impossible because the functions weren't in the default build.)
5419
5420B.2 Changes to the configuration mechanism
5421
5422Prior to libpng-1.5.0 library builders who needed to configure libpng
5423had either to modify the exported pngconf.h header file to add system
5424specific configuration or had to write feature selection macros into
5425pngusr.h and cause this to be included into pngconf.h by defining
5426PNG_USER_CONFIG. The latter mechanism had the disadvantage that an
5427application built without PNG_USER_CONFIG defined would see the
5428unmodified, default, libpng API and thus would probably fail to link.
5429
5430These mechanisms still work in the configure build and in any makefile
Glenn Randers-Pehrsona5e55472011-07-12 10:13:32 -05005431build that builds pnglibconf.h, although the feature selection macros
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06005432have changed somewhat as described above. In 1.5.0, however, pngusr.h is
5433processed only once, when the exported header file pnglibconf.h is built.
Glenn Randers-Pehrsona5e55472011-07-12 10:13:32 -05005434pngconf.h no longer includes pngusr.h, therefore pngusr.h is ignored after the
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06005435build of pnglibconf.h and it is never included in an application build.
5436
5437The rarely used alternative of adding a list of feature macros to the
5438CFLAGS setting in the build also still works, however the macros will be
5439copied to pnglibconf.h and this may produce macro redefinition warnings
5440when the individual C files are compiled.
5441
5442All configuration now only works if pnglibconf.h is built from
5443scripts/pnglibconf.dfa. This requires the program awk. Brian Kernighan
5444(the original author of awk) maintains C source code of that awk and this
5445and all known later implementations (often called by subtly different
5446names - nawk and gawk for example) are adequate to build pnglibconf.h.
5447The Sun Microsystems (now Oracle) program 'awk' is an earlier version
Glenn Randers-Pehrsona5e55472011-07-12 10:13:32 -05005448and does not work; this may also apply to other systems that have a
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06005449functioning awk called 'nawk'.
5450
5451Configuration options are now documented in scripts/pnglibconf.dfa. This
5452file also includes dependency information that ensures a configuration is
5453consistent; that is, if a feature is switched off dependent features are
5454also removed. As a recommended alternative to using feature macros in
5455pngusr.h a system builder may also define equivalent options in pngusr.dfa
5456(or, indeed, any file) and add that to the configuration by setting
5457DFA_XTRA to the file name. The makefiles in contrib/pngminim illustrate
5458how to do this, and a case where pngusr.h is still required.
5459
Glenn Randers-Pehrson5b40b012010-11-25 07:16:29 -06005460.SH XI. Detecting libpng
Glenn Randers-Pehrson424c9852009-06-02 13:45:15 -05005461
5462The png_get_io_ptr() function has been present since libpng-0.88, has never
5463changed, and is unaffected by conditional compilation macros. It is the
5464best choice for use in configure scripts for detecting the presence of any
Glenn Randers-Pehrson99708d52009-06-29 17:30:00 -05005465libpng version since 0.88. In an autoconf "configure.in" you could use
5466
5467 AC_CHECK_LIB(png, png_get_io_ptr, ...
Glenn Randers-Pehrson424c9852009-06-02 13:45:15 -05005468
Glenn Randers-Pehrson5b40b012010-11-25 07:16:29 -06005469.SH XII. Source code repository
Glenn Randers-Pehrson76546822009-05-16 07:25:42 -05005470
5471Since about February 2009, version 1.2.34, libpng has been under "git" source
5472control. The git repository was built from old libpng-x.y.z.tar.gz files
5473going back to version 0.70. You can access the git repository (read only)
5474at
5475
5476 git://libpng.git.sourceforge.net/gitroot/libpng
5477
5478or you can browse it via "gitweb" at
5479
5480 http://libpng.git.sourceforge.net/git/gitweb.cgi?p=libpng
5481
5482Patches can be sent to glennrp at users.sourceforge.net or to
5483png-mng-implement at lists.sourceforge.net or you can upload them to
5484the libpng bug tracker at
5485
5486 http://libpng.sourceforge.net
5487
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06005488We also accept patches built from the tar or zip distributions, and
5489simple verbal discriptions of bug fixes, reported either to the
Glenn Randers-Pehrsona5e55472011-07-12 10:13:32 -05005490SourceForge bug tracker, to the png-mng-implement at lists.sf.net
5491mailing list, or directly to glennrp.
Glenn Randers-Pehrson7bc25012011-01-21 23:29:09 -06005492
Glenn Randers-Pehrson5b40b012010-11-25 07:16:29 -06005493.SH XIII. Coding style
Glenn Randers-Pehrson76546822009-05-16 07:25:42 -05005494
5495Our coding style is similar to the "Allman" style, with curly
5496braces on separate lines:
5497
5498 if (condition)
5499 {
5500 action;
5501 }
5502
5503 else if (another condition)
5504 {
5505 another action;
5506 }
5507
5508The braces can be omitted from simple one-line actions:
5509
5510 if (condition)
5511 return (0);
5512
5513We use 3-space indentation, except for continued statements which
5514are usually indented the same as the first line of the statement
5515plus four more spaces.
5516
Glenn Randers-Pehrson5ade7ed2009-09-30 15:11:49 -05005517For macro definitions we use 2-space indentation, always leaving the "#"
5518in the first column.
5519
5520 #ifndef PNG_NO_FEATURE
5521 # ifndef PNG_FEATURE_SUPPORTED
5522 # define PNG_FEATURE_SUPPORTED
5523 # endif
5524 #endif
5525
Glenn Randers-Pehrson76546822009-05-16 07:25:42 -05005526Comments appear with the leading "/*" at the same indentation as
5527the statement that follows the comment:
5528
5529 /* Single-line comment */
5530 statement;
5531
Glenn Randers-Pehrsone4c706a2010-03-06 14:51:54 -06005532 /* This is a multiple-line
5533 * comment.
Glenn Randers-Pehrson76546822009-05-16 07:25:42 -05005534 */
5535 statement;
5536
Glenn Randers-Pehrsone4c706a2010-03-06 14:51:54 -06005537Very short comments can be placed after the end of the statement
Glenn Randers-Pehrson76546822009-05-16 07:25:42 -05005538to which they pertain:
5539
5540 statement; /* comment */
5541
5542We don't use C++ style ("//") comments. We have, however,
5543used them in the past in some now-abandoned MMX assembler
5544code.
5545
Glenn Randers-Pehrsonb5444a12009-06-08 08:36:19 -05005546Functions and their curly braces are not indented, and
Glenn Randers-Pehrson76546822009-05-16 07:25:42 -05005547exported functions are marked with PNGAPI:
5548
5549 /* This is a public function that is visible to
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06005550 * application programmers. It does thus-and-so.
Glenn Randers-Pehrson76546822009-05-16 07:25:42 -05005551 */
5552 void PNGAPI
5553 png_exported_function(png_ptr, png_info, foo)
5554 {
5555 body;
5556 }
5557
Glenn Randers-Pehrson416976f2009-07-27 22:16:09 -05005558The prototypes for all exported functions appear in png.h,
5559above the comment that says
5560
5561 /* Maintainer: Put new public prototypes here ... */
Glenn Randers-Pehrson76546822009-05-16 07:25:42 -05005562
5563We mark all non-exported functions with "/* PRIVATE */"":
5564
5565 void /* PRIVATE */
5566 png_non_exported_function(png_ptr, png_info, foo)
5567 {
5568 body;
5569 }
5570
Glenn Randers-Pehrson416976f2009-07-27 22:16:09 -05005571The prototypes for non-exported functions (except for those in
Glenn Randers-Pehrson5df7edb2009-10-29 23:32:44 -05005572pngtest) appear in
5573pngpriv.h
Glenn Randers-Pehrson416976f2009-07-27 22:16:09 -05005574above the comment that says
5575
5576 /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
Glenn Randers-Pehrson76546822009-05-16 07:25:42 -05005577
Glenn Randers-Pehrsoncbbe9a52011-01-29 16:12:11 -06005578To avoid polluting the global namespace, the names of all exported
5579functions and variables begin with "png_", and all publicly visible C
5580preprocessor macros begin with "PNG_". We request that applications that
5581use libpng *not* begin any of their own symbols with either of these strings.
Glenn Randers-Pehrson76546822009-05-16 07:25:42 -05005582
5583We put a space after each comma and after each semicolon
Glenn Randers-Pehrson49a56e72010-12-06 20:06:01 -06005584in "for" statements, and we put spaces before and after each
Glenn Randers-Pehrsone4c706a2010-03-06 14:51:54 -06005585C binary operator and after "for" or "while", and before
5586"?". We don't put a space between a typecast and the expression
5587being cast, nor do we put one between a function name and the
Glenn Randers-Pehrson76546822009-05-16 07:25:42 -05005588left parenthesis that follows it:
5589
5590 for (i = 2; i > 0; --i)
Glenn Randers-Pehrson67f3b482009-09-23 11:36:28 -05005591 y[i] = a(x) + (int)b;
Glenn Randers-Pehrson76546822009-05-16 07:25:42 -05005592
Glenn Randers-Pehrsond60c8862009-06-15 21:56:14 -05005593We prefer #ifdef and #ifndef to #if defined() and if !defined()
5594when there is only one macro being tested.
5595
Glenn Randers-Pehrson8db19982011-10-27 16:17:24 -05005596We prefer to express integers that are used as bit masks in hex format,
5597with an even number of lower-case hex digits (e.g., 0x00, 0xff, 0x0100).
5598
Glenn Randers-Pehrson67f3b482009-09-23 11:36:28 -05005599We do not use the TAB character for indentation in the C sources.
5600
Glenn Randers-Pehrson62ca98e2009-12-20 15:14:57 -06005601Lines do not exceed 80 characters.
5602
Glenn Randers-Pehrsonf210a052009-11-12 10:02:24 -06005603Other rules can be inferred by inspecting the libpng source.
Glenn Randers-Pehrson76546822009-05-16 07:25:42 -05005604
Glenn Randers-Pehrson5b40b012010-11-25 07:16:29 -06005605.SH XIV. Y2K Compliance in libpng
Glenn Randers-Pehrson76546822009-05-16 07:25:42 -05005606
Glenn Randers-Pehrsond92c1fc2011-11-17 21:03:07 -06005607November 18, 2011
Glenn Randers-Pehrson87544ac1999-01-13 22:06:39 -06005608
5609Since the PNG Development group is an ad-hoc body, we can't make
5610an official declaration.
5611
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05005612This is your unofficial assurance that libpng from version 0.71 and
Glenn Randers-Pehrson36251d32011-11-17 21:14:34 -06005613upward through 1.5.7beta05 are Y2K compliant. It is my belief that earlier
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05005614versions were also Y2K compliant.
Glenn Randers-Pehrson87544ac1999-01-13 22:06:39 -06005615
5616Libpng only has three year fields. One is a 2-byte unsigned integer that
5617will hold years up to 65535. The other two hold the date in text
5618format, and will hold years up to 9999.
5619
5620The integer is
5621 "png_uint_16 year" in png_time_struct.
5622
5623The strings are
5624 "png_charp time_buffer" in png_struct and
5625 "near_time_buffer", which is a local character string in png.c.
5626
5627There are seven time-related functions:
5628
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06005629 png_convert_to_rfc_1123() in png.c
Glenn Randers-Pehrson87544ac1999-01-13 22:06:39 -06005630 (formerly png_convert_to_rfc_1152() in error)
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06005631 png_convert_from_struct_tm() in pngwrite.c, called
5632 in pngwrite.c
Glenn Randers-Pehrson87544ac1999-01-13 22:06:39 -06005633 png_convert_from_time_t() in pngwrite.c
5634 png_get_tIME() in pngget.c
5635 png_handle_tIME() in pngrutil.c, called in pngread.c
5636 png_set_tIME() in pngset.c
5637 png_write_tIME() in pngwutil.c, called in pngwrite.c
5638
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06005639All appear to handle dates properly in a Y2K environment. The
Glenn Randers-Pehrson87544ac1999-01-13 22:06:39 -06005640png_convert_from_time_t() function calls gmtime() to convert from system
5641clock time, which returns (year - 1900), which we properly convert to
5642the full 4-digit year. There is a possibility that applications using
5643libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05005644function, or that they are incorrectly passing only a 2-digit year
5645instead of "year - 1900" into the png_convert_from_struct_tm() function,
5646but this is not under our control. The libpng documentation has always
5647stated that it works with 4-digit years, and the APIs have been
5648documented as such.
Glenn Randers-Pehrson87544ac1999-01-13 22:06:39 -06005649
5650The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
5651integer to hold the year, and can hold years as large as 65535.
5652
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05005653zlib, upon which libpng depends, is also Y2K compliant. It contains
5654no date-related code.
5655
Glenn Randers-Pehrson87544ac1999-01-13 22:06:39 -06005656
5657 Glenn Randers-Pehrson
5658 libpng maintainer
5659 PNG Development Group
5660
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06005661.SH NOTE
5662
5663Note about libpng version numbers:
5664
5665Due to various miscommunications, unforeseen code incompatibilities
5666and occasional factors outside the authors' control, version numbering
5667on the library has not always been consistent and straightforward.
5668The following table summarizes matters since version 0.89c, which was
5669the first widely used release:
5670
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06005671 source png.h png.h shared-lib
5672 version string int version
5673 ------- ------ ----- ----------
5674 0.89c ("beta 3") 0.89 89 1.0.89
5675 0.90 ("beta 4") 0.90 90 0.90
5676 0.95 ("beta 5") 0.95 95 0.95
5677 0.96 ("beta 6") 0.96 96 0.96
5678 0.97b ("beta 7") 1.00.97 97 1.0.1
5679 0.97c 0.97 97 2.0.97
5680 0.98 0.98 98 2.0.98
5681 0.99 0.99 98 2.0.99
5682 0.99a-m 0.99 99 2.0.99
5683 1.00 1.00 100 2.1.0
5684 1.0.0 1.0.0 100 2.1.0
5685 1.0.0 (from here on, the 100 2.1.0
5686 1.0.1 png.h string is 10001 2.1.0
5687 1.0.1a-e identical to the 10002 from here on, the
5688 1.0.2 source version) 10002 shared library is 2.V
5689 1.0.2a-b 10003 where V is the source
5690 1.0.1 10001 code version except as
5691 1.0.1a-e 10002 2.1.0.1a-e noted.
5692 1.0.2 10002 2.1.0.2
5693 1.0.2a-b 10003 2.1.0.2a-b
5694 1.0.3 10003 2.1.0.3
5695 1.0.3a-d 10004 2.1.0.3a-d
5696 1.0.4 10004 2.1.0.4
5697 1.0.4a-f 10005 2.1.0.4a-f
5698 1.0.5 (+ 2 patches) 10005 2.1.0.5
5699 1.0.5a-d 10006 2.1.0.5a-d
5700 1.0.5e-r 10100 2.1.0.5e-r
5701 1.0.5s-v 10006 2.1.0.5s-v
5702 1.0.6 (+ 3 patches) 10006 2.1.0.6
5703 1.0.6d-g 10007 2.1.0.6d-g
5704 1.0.6h 10007 10.6h
5705 1.0.6i 10007 10.6i
5706 1.0.6j 10007 2.1.0.6j
Glenn Randers-Pehrson25467032011-01-28 11:58:40 -06005707 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06005708 1.0.7beta15-18 1 10007 2.1.0.7beta15-18
5709 1.0.7rc1-2 1 10007 2.1.0.7rc1-2
5710 1.0.7 1 10007 2.1.0.7
5711 1.0.8beta1-4 1 10008 2.1.0.8beta1-4
5712 1.0.8rc1 1 10008 2.1.0.8rc1
5713 1.0.8 1 10008 2.1.0.8
5714 1.0.9beta1-6 1 10009 2.1.0.9beta1-6
5715 1.0.9rc1 1 10009 2.1.0.9rc1
5716 1.0.9beta7-10 1 10009 2.1.0.9beta7-10
5717 1.0.9rc2 1 10009 2.1.0.9rc2
5718 1.0.9 1 10009 2.1.0.9
Glenn Randers-Pehrsone1644472001-03-23 05:06:56 -06005719 1.0.10beta1 1 10010 2.1.0.10beta1
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06005720 1.0.10rc1 1 10010 2.1.0.10rc1
Glenn Randers-Pehrson13cfbac2001-03-30 06:42:28 -06005721 1.0.10 1 10010 2.1.0.10
Glenn Randers-Pehrsone1eff582001-04-14 20:15:41 -05005722 1.0.11beta1-3 1 10011 2.1.0.11beta1-3
Glenn Randers-Pehrson82ae3832001-04-20 10:32:10 -05005723 1.0.11rc1 1 10011 2.1.0.11rc1
Glenn Randers-Pehrson32835392001-04-27 08:29:32 -05005724 1.0.11 1 10011 2.1.0.11
Glenn Randers-Pehrsonb1828932001-06-23 08:03:17 -05005725 1.0.12beta1-2 2 10012 2.1.0.12beta1-2
5726 1.0.12rc1 2 10012 2.1.0.12rc1
5727 1.0.12 2 10012 2.1.0.12
5728 1.1.0a-f - 10100 2.1.1.0a-f abandoned
Glenn Randers-Pehrson8b6a8892001-05-18 04:54:50 -05005729 1.2.0beta1-2 2 10200 2.1.2.0beta1-2
Glenn Randers-Pehrson5a0be342001-10-18 20:55:13 -05005730 1.2.0beta3-5 3 10200 3.1.2.0beta3-5
5731 1.2.0rc1 3 10200 3.1.2.0rc1
5732 1.2.0 3 10200 3.1.2.0
Glenn Randers-Pehrson5cded0b2001-11-07 07:10:08 -06005733 1.2.1beta-4 3 10201 3.1.2.1beta1-4
Glenn Randers-Pehrsondb3b88d2001-12-04 06:30:43 -06005734 1.2.1rc1-2 3 10201 3.1.2.1rc1-2
5735 1.2.1 3 10201 3.1.2.1
Glenn Randers-Pehrson25228ab2002-03-31 07:33:55 -06005736 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6
Glenn Randers-Pehrsonfcbd7872002-04-07 16:35:38 -05005737 1.0.13beta1 10 10013 10.so.0.1.0.13beta1
5738 1.0.13rc1 10 10013 10.so.0.1.0.13rc1
5739 1.2.2rc1 12 10202 12.so.0.1.2.2rc1
Glenn Randers-Pehrson4fb046a2002-04-15 09:25:51 -05005740 1.0.13 10 10013 10.so.0.1.0.13
5741 1.2.2 12 10202 12.so.0.1.2.2
Glenn Randers-Pehrson22f28962002-05-13 18:17:09 -05005742 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6
5743 1.2.3 12 10203 12.so.0.1.2.3
Glenn Randers-Pehrsond020e9d2002-06-28 09:34:00 -05005744 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3
Glenn Randers-Pehrson2ae022d2002-07-01 22:23:46 -05005745 1.2.4rc1 13 10204 12.so.0.1.2.4rc1
Glenn Randers-Pehrson484a8a12002-07-07 19:15:20 -05005746 1.0.14 10 10014 10.so.0.1.0.14
5747 1.2.4 13 10204 12.so.0.1.2.4
Glenn Randers-Pehrson5b5dcf82004-07-17 22:45:44 -05005748 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2
5749 1.0.15rc1 10 10015 10.so.0.1.0.15rc1
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -05005750 1.0.15 10 10015 10.so.0.1.0.15
5751 1.2.5 13 10205 12.so.0.1.2.5
5752 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4
Glenn Randers-Pehrson37f116a2004-08-15 07:15:39 -05005753 1.2.6rc1-5 13 10206 12.so.0.1.2.6rc1-5
5754 1.0.16 10 10016 10.so.0.1.0.16
5755 1.2.6 13 10206 12.so.0.1.2.6
Glenn Randers-Pehrson67864af2004-08-28 23:30:07 -05005756 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2
Glenn Randers-Pehrson5b779162004-09-04 13:25:08 -05005757 1.0.17rc1 10 10017 12.so.0.1.0.17rc1
5758 1.2.7rc1 13 10207 12.so.0.1.2.7rc1
Glenn Randers-Pehrson250dfe12004-09-11 21:19:54 -05005759 1.0.17 10 10017 12.so.0.1.0.17
5760 1.2.7 13 10207 12.so.0.1.2.7
Glenn Randers-Pehrson40936072004-11-20 11:18:40 -06005761 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5
Glenn Randers-Pehrson584b96e2004-11-29 15:08:00 -06005762 1.0.18rc1-5 10 10018 12.so.0.1.0.18rc1-5
5763 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5
Glenn Randers-Pehrson917648e2004-12-02 18:14:51 -06005764 1.0.18 10 10018 12.so.0.1.0.18
5765 1.2.8 13 10208 12.so.0.1.2.8
Glenn Randers-Pehrsone6474622006-03-04 16:50:47 -06005766 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3
Glenn Randers-Pehrson4deeb792006-03-22 16:21:59 -06005767 1.2.9beta4-11 13 10209 12.so.0.9[.0]
Glenn Randers-Pehrson3a512032006-03-31 05:29:33 -06005768 1.2.9rc1 13 10209 12.so.0.9[.0]
Glenn Randers-Pehrsona7d0c942006-04-14 06:22:52 -05005769 1.2.9 13 10209 12.so.0.9[.0]
Glenn Randers-Pehrsond60b8fa2006-04-20 21:31:14 -05005770 1.2.10beta1-7 13 10210 12.so.0.10[.0]
Glenn Randers-Pehrson17218292006-04-20 07:20:46 -05005771 1.2.10rc1-2 13 10210 12.so.0.10[.0]
Glenn Randers-Pehrson86dc9812006-05-10 07:27:44 -05005772 1.2.10 13 10210 12.so.0.10[.0]
Glenn Randers-Pehrson6bc53be2006-06-16 07:52:03 -05005773 1.4.0beta1-6 14 10400 14.so.0.0[.0]
Glenn Randers-Pehrsond60c8862009-06-15 21:56:14 -05005774 1.2.11beta1-4 13 10210 12.so.0.11[.0]
Glenn Randers-Pehrson3424ee72006-07-12 13:33:47 -05005775 1.4.0beta7-8 14 10400 14.so.0.0[.0]
Glenn Randers-Pehrson701dbaa2006-11-17 09:36:54 -06005776 1.2.11 13 10211 12.so.0.11[.0]
5777 1.2.12 13 10212 12.so.0.12[.0]
5778 1.4.0beta9-14 14 10400 14.so.0.0[.0]
5779 1.2.13 13 10213 12.so.0.13[.0]
Glenn Randers-Pehrson97a9b482008-10-25 20:03:28 -05005780 1.4.0beta15-36 14 10400 14.so.0.0[.0]
Glenn Randers-Pehrsonfa028102009-10-10 06:15:21 -05005781 1.4.0beta37-87 14 10400 14.so.14.0[.0]
Glenn Randers-Pehrson733da8c2009-10-30 00:00:15 -05005782 1.4.0rc01 14 10400 14.so.14.0[.0]
Glenn Randers-Pehrson62ca98e2009-12-20 15:14:57 -06005783 1.4.0beta88-109 14 10400 14.so.14.0[.0]
Glenn Randers-Pehrson67a83db2010-01-01 18:26:18 -06005784 1.4.0rc02-08 14 10400 14.so.14.0[.0]
Glenn Randers-Pehrsondbcfb712009-12-25 14:24:18 -06005785 1.4.0 14 10400 14.so.14.0[.0]
Glenn Randers-Pehrsone3f3c4e2010-02-07 18:08:50 -06005786 1.4.1beta01-03 14 10401 14.so.14.1[.0]
5787 1.4.1rc01 14 10401 14.so.14.1[.0]
Glenn Randers-Pehrson7a5be532010-02-14 07:16:19 -06005788 1.4.1beta04-12 14 10401 14.so.14.1[.0]
Glenn Randers-Pehrsonaaf377c2010-03-08 11:20:30 -06005789 1.4.1 14 10401 14.so.14.1[.0]
Glenn Randers-Pehrson5b3d5542010-06-18 21:55:53 -05005790 1.4.2 14 10402 14.so.14.2[.0]
5791 1.4.3 14 10403 14.so.14.3[.0]
Glenn Randers-Pehrson2776d5e2010-11-21 15:18:02 -06005792 1.4.4 14 10404 14.so.14.4[.0]
Glenn Randers-Pehrsonfd20a5a2010-12-27 08:53:08 -06005793 1.5.0beta01-58 15 10500 15.so.15.0[.0]
Glenn Randers-Pehrson64b863c2011-01-04 09:57:06 -06005794 1.5.0rc01-07 15 10500 15.so.15.0[.0]
Glenn Randers-Pehrsonf5ea1b72011-01-06 06:42:51 -06005795 1.5.0 15 10500 15.so.15.0[.0]
Glenn Randers-Pehrsonef123cc2011-01-28 15:20:34 -06005796 1.5.1beta01-11 15 10501 15.so.15.1[.0]
Glenn Randers-Pehrson3d3aae12011-02-02 22:58:27 -06005797 1.5.1rc01-02 15 10501 15.so.15.1[.0]
5798 1.5.1 15 10501 15.so.15.1[.0]
Glenn Randers-Pehrsonf3dd1cc2011-03-18 22:02:20 -05005799 1.5.2beta01-03 15 10502 15.so.15.2[.0]
Glenn Randers-Pehrson77fd0832011-03-24 08:59:48 -05005800 1.5.2rc01-03 15 10502 15.so.15.2[.0]
Glenn Randers-Pehrsondcc35052011-03-31 11:23:49 -05005801 1.5.2 15 10502 15.so.15.2[.0]
Glenn Randers-Pehrson36edbb52011-06-03 07:15:04 -05005802 1.5.3beta01-10 15 10503 15.so.15.3[.0]
Glenn Randers-Pehrsonfb278732011-06-10 20:43:39 -05005803 1.5.3rc01-02 15 10503 15.so.15.3[.0]
Glenn Randers-Pehrson413138a2011-06-13 22:07:37 -05005804 1.5.3beta11 15 10503 15.so.15.3[.0]
5805 1.5.3 [omitted]
Glenn Randers-Pehrson9daf91e2011-06-22 23:10:36 -05005806 1.5.4beta01-08 15 10504 15.so.15.4[.0]
Glenn Randers-Pehrson78bb9da2011-06-30 18:59:45 -05005807 1.5.4rc01 15 10504 15.so.15.4[.0]
Glenn Randers-Pehrsond404b6d2011-07-07 06:24:57 -05005808 1.5.4 15 10504 15.so.15.4[.0]
Glenn Randers-Pehrson3c2ae602011-09-09 06:02:09 -05005809 1.5.5beta01-08 15 10505 15.so.15.5[.0]
5810 1.5.5rc01 15 10505 15.so.15.5[.0]
Glenn Randers-Pehrson3e2263a2011-09-22 08:40:32 -05005811 1.5.5 15 10505 15.so.15.5[.0]
Glenn Randers-Pehrson93254f62011-10-26 08:36:21 -05005812 1.5.6beta01-07 15 10506 15.so.15.6[.0]
Glenn Randers-Pehrsonbc6726b2011-11-02 22:43:00 -05005813 1.5.6rc01-03 15 10506 15.so.15.6[.0]
5814 1.5.6 15 10506 15.so.15.6[.0]
Glenn Randers-Pehrson36251d32011-11-17 21:14:34 -06005815 1.5.7beta01-05 15 10507 15.so.15.7[.0]
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06005816
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06005817Henceforth the source version will match the shared-library minor
5818and patch numbers; the shared-library major version number will be
5819used for changes in backward compatibility, as it is intended. The
5820PNG_PNGLIB_VER macro, which is not used within libpng but is available
5821for applications, is an unsigned integer of the form xyyzz corresponding
5822to the source version x.y.z (leading zeros in y and z). Beta versions
Glenn Randers-Pehrsone1644472001-03-23 05:06:56 -06005823were given the previous public release number plus a letter, until
5824version 1.0.6j; from then on they were given the upcoming public
5825release number plus "betaNN" or "rcN".
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06005826
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06005827.SH "SEE ALSO"
Glenn Randers-Pehrson4e763f12010-03-03 10:45:50 -06005828.BR "png"(5), " libpngpf"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5)
Glenn Randers-Pehrson7fb32a82010-03-03 09:47:49 -06005829
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06005830.LP
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06005831.IR libpng :
5832.IP
Glenn Randers-Pehrsona4981d42004-08-25 22:00:45 -05005833http://libpng.sourceforge.net (follow the [DOWNLOAD] link)
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -06005834http://www.libpng.org/pub/png
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06005835
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06005836.LP
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06005837.IR zlib :
5838.IP
5839(generally) at the same location as
5840.I libpng
5841or at
5842.br
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -06005843ftp://ftp.info-zip.org/pub/infozip/zlib
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06005844
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06005845.LP
5846.IR PNG specification: RFC 2083
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06005847.IP
5848(generally) at the same location as
5849.I libpng
5850or at
5851.br
5852ftp://ds.internic.net/rfc/rfc2083.txt
5853.br
5854or (as a W3C Recommendation) at
5855.br
5856http://www.w3.org/TR/REC-png.html
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06005857
Glenn Randers-Pehrsoncbe52d81998-02-28 07:00:24 -06005858.LP
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06005859In the case of any inconsistency between the PNG specification
5860and this library, the specification takes precedence.
5861
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06005862.SH AUTHORS
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06005863This man page: Glenn Randers-Pehrson
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -06005864<glennrp at users.sourceforge.net>
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06005865
5866The contributing authors would like to thank all those who helped
5867with testing, bug fixes, and patience. This wouldn't have been
5868possible without all of you.
5869
5870Thanks to Frank J. T. Wojcik for helping with the documentation.
Glenn Randers-Pehrson166c5a31999-12-10 09:43:02 -06005871
Glenn Randers-Pehrson36251d32011-11-17 21:14:34 -06005872Libpng version 1.5.7beta05 - November 18, 2011:
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06005873Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -06005874Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06005875
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06005876Supported by the PNG development group
5877.br
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -06005878png-mng-implement at lists.sf.net
5879(subscription required; visit
Glenn Randers-Pehrson7b34df32006-02-24 06:30:16 -06005880png-mng-implement at lists.sourceforge.net (subscription required; visit
Glenn Randers-Pehrson9c3ab682006-02-20 22:09:05 -06005881https://lists.sourceforge.net/lists/listinfo/png-mng-implement
5882to subscribe).
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06005883
Glenn Randers-Pehrson3d5a5202000-07-01 15:37:28 -05005884.SH COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06005885
Glenn Randers-Pehrson5e5c1e12000-11-10 12:26:19 -06005886(This copy of the libpng notices is provided for your convenience. In case of
5887any discrepancy between this copy and the notices in the file png.h that is
5888included in the libpng distribution, the latter shall prevail.)
5889
Glenn Randers-Pehrson3d5a5202000-07-01 15:37:28 -05005890If you modify libpng you may insert additional notices immediately following
5891this sentence.
5892
Glenn Randers-Pehrsonbfbf8652009-06-26 21:46:52 -05005893This code is released under the libpng license.
Glenn Randers-Pehrson037023b2009-06-24 10:27:36 -05005894
Glenn Randers-Pehrson36251d32011-11-17 21:14:34 -06005895libpng versions 1.2.6, August 15, 2004, through 1.5.7beta05, November 18, 2011, are
Glenn Randers-Pehrsona7dbcba2007-05-15 16:16:34 -05005896Copyright (c) 2004,2006-2007 Glenn Randers-Pehrson, and are
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -05005897distributed according to the same disclaimer and license as libpng-1.2.5
Glenn Randers-Pehrsond029a752004-08-09 21:50:32 -05005898with the following individual added to the list of Contributing Authors
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -05005899
5900 Cosmin Truta
Glenn Randers-Pehrson5fea36f2004-07-28 08:20:44 -05005901
5902libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
Glenn Randers-Pehrsonc6de22d2002-02-23 18:55:25 -06005903Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
Glenn Randers-Pehrson32fc5ce2000-07-24 06:34:14 -05005904distributed according to the same disclaimer and license as libpng-1.0.6
Glenn Randers-Pehrson3d5a5202000-07-01 15:37:28 -05005905with the following individuals added to the list of Contributing Authors
5906
5907 Simon-Pierre Cadieux
5908 Eric S. Raymond
5909 Gilles Vollant
5910
5911and with the following additions to the disclaimer:
5912
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -06005913 There is no warranty against interference with your
5914 enjoyment of the library or against infringement.
5915 There is no warranty that our efforts or the library
5916 will fulfill any of your particular purposes or needs.
5917 This library is provided with all faults, and the entire
5918 risk of satisfactory quality, performance, accuracy, and
5919 effort is with the user.
Glenn Randers-Pehrson3d5a5202000-07-01 15:37:28 -05005920
5921libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
5922Copyright (c) 1998, 1999 Glenn Randers-Pehrson
5923Distributed according to the same disclaimer and license as libpng-0.96,
5924with the following individuals added to the list of Contributing Authors:
5925
5926 Tom Lane
5927 Glenn Randers-Pehrson
5928 Willem van Schaik
5929
5930libpng versions 0.89, June 1996, through 0.96, May 1997, are
Glenn Randers-Pehrson54a066a1999-09-19 06:04:18 -05005931Copyright (c) 1996, 1997 Andreas Dilger
Glenn Randers-Pehrson3d5a5202000-07-01 15:37:28 -05005932Distributed according to the same disclaimer and license as libpng-0.88,
5933with the following individuals added to the list of Contributing Authors:
Glenn Randers-Pehrsonbcfd15d1999-10-01 14:22:25 -05005934
5935 John Bowler
5936 Kevin Bracey
5937 Sam Bushell
Glenn Randers-Pehrsonbcfd15d1999-10-01 14:22:25 -05005938 Magnus Holmgren
Glenn Randers-Pehrsonbcfd15d1999-10-01 14:22:25 -05005939 Greg Roelofs
Glenn Randers-Pehrson3d5a5202000-07-01 15:37:28 -05005940 Tom Tanner
5941
5942libpng versions 0.5, May 1995, through 0.88, January 1996, are
5943Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
5944
5945For the purposes of this copyright and license, "Contributing Authors"
5946is defined as the following set of individuals:
5947
5948 Andreas Dilger
5949 Dave Martindale
Glenn Randers-Pehrsonbcfd15d1999-10-01 14:22:25 -05005950 Guy Eric Schalnat
5951 Paul Schmidt
Glenn Randers-Pehrsonbcfd15d1999-10-01 14:22:25 -05005952 Tim Wegner
Glenn Randers-Pehrsonc9442291999-01-06 21:50:16 -06005953
Glenn Randers-Pehrson3d5a5202000-07-01 15:37:28 -05005954The PNG Reference Library is supplied "AS IS". The Contributing Authors
5955and Group 42, Inc. disclaim all warranties, expressed or implied,
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06005956including, without limitation, the warranties of merchantability and of
5957fitness for any purpose. The Contributing Authors and Group 42, Inc.
5958assume no liability for direct, indirect, incidental, special, exemplary,
5959or consequential damages, which may result from the use of the PNG
5960Reference Library, even if advised of the possibility of such damage.
Glenn Randers-Pehrsona357b991998-02-08 20:56:40 -06005961
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06005962Permission is hereby granted to use, copy, modify, and distribute this
5963source code, or portions hereof, for any purpose, without fee, subject
5964to the following restrictions:
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06005965
Glenn Randers-Pehrson3d5a5202000-07-01 15:37:28 -050059661. The origin of this source code must not be misrepresented.
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06005967
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -060059682. Altered versions must be plainly marked as such and
5969 must not be misrepresented as being the original source.
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06005970
Glenn Randers-Pehrson19095602001-03-14 07:08:39 -060059713. This Copyright notice may not be removed or altered from
5972 any source or altered source distribution.
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06005973
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06005974The Contributing Authors and Group 42, Inc. specifically permit, without
5975fee, and encourage the use of this source code as a component to
5976supporting the PNG file format in commercial products. If you use this
5977source code in a product, acknowledgment is not required but would be
5978appreciated.
5979
Glenn Randers-Pehrson3d5a5202000-07-01 15:37:28 -05005980
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05005981A "png_get_copyright" function is available, for convenient use in "about"
5982boxes and the like:
5983
5984 printf("%s",png_get_copyright(NULL));
5985
5986Also, the PNG logo (in PNG format, of course) is supplied in the
Glenn Randers-Pehrsona4d54bd2000-07-14 08:15:12 -05005987files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
Glenn Randers-Pehrson4393a9a1999-09-17 12:27:26 -05005988
Glenn Randers-Pehrson3d5a5202000-07-01 15:37:28 -05005989Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
Glenn Randers-Pehrsonbcfd15d1999-10-01 14:22:25 -05005990certification mark of the Open Source Initiative.
5991
Glenn Randers-Pehrson3d5a5202000-07-01 15:37:28 -05005992Glenn Randers-Pehrson
Glenn Randers-Pehrson5dd2b8e2004-11-24 07:50:16 -06005993glennrp at users.sourceforge.net
Glenn Randers-Pehrsond92c1fc2011-11-17 21:03:07 -06005994November 18, 2011
Glenn Randers-Pehrson3d5a5202000-07-01 15:37:28 -05005995
Glenn Randers-Pehrson0f881d61998-02-07 10:20:57 -06005996.\" end of man page
5997