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