Glenn Randers-Pehrson | d92c1fc | 2011-11-17 21:03:07 -0600 | [diff] [blame] | 1 | .TH LIBPNG 3 "November 18, 2011" |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 2 | .SH NAME |
Glenn Randers-Pehrson | 36251d3 | 2011-11-17 21:14:34 -0600 | [diff] [blame^] | 3 | libpng \- Portable Network Graphics (PNG) Reference Library 1.5.7beta05 |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 4 | .SH SYNOPSIS |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 5 | \fI\fB |
| 6 | |
| 7 | \fB#include <png.h>\fP |
| 8 | |
| 9 | \fI\fB |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 10 | |
Glenn Randers-Pehrson | e0a6c06 | 2011-11-07 23:50:05 -0600 | [diff] [blame] | 11 | \fBint \fP\fIpng_image_begin_read_from_file\fP\fB, (png_imagep \fIimage, |
| 12 | |
| 13 | \fBconst char \fI*file_name)\fP\fB);\fP |
| 14 | |
| 15 | \fBint \fP\fIpng_image_begin_read_from_stdio\fP\fB, (png_imagep \fIimage, |
| 16 | |
| 17 | \fBFILE* \fIfile)\fP\fB);\fP |
| 18 | |
| 19 | \fBint, \fP\fIpng_image_begin_read_from_memory\fP\fB, (png_imagep \fIimage, |
| 20 | |
| 21 | \fBpng_const_voidp \fP\fImemory\fP\fB, png_size_t \fIsize)\fP\fB);\fP |
| 22 | |
| 23 | \fBint \fP\fIpng_image_finish_read\fP\fB, (png_imagep \fIimage, |
| 24 | |
| 25 | \fBpng_colorp \fP\fIbackground\fP\fB, void \fP\fI*buffer\fP\fB, png_int_32 \fIrow_stride)\fP\fB);\fP |
| 26 | |
| 27 | \fBvoid \fP\fIpng_image_free\fP\fB, (png_imagep \fIimage)\fP\fB);\fP |
| 28 | |
| 29 | \fBint \fP\fIpng_image_write_to_file\fP\fB, (png_imagep \fIimage, |
| 30 | |
| 31 | \fBconst char \fP\fI*file\fP\fB, int \fP\fIconvert_to_8bit\fP\fB, const void \fI*buffer, |
| 32 | |
| 33 | \fBpng_int_32 \fIrow_stride)\fP\fB);\fP |
| 34 | |
| 35 | \fBint \fP\fIpng_image_write_to_stdio\fP\fB, (png_imagep \fP\fIimage\fP\fB, FILE \fI*file, |
| 36 | |
| 37 | \fBint \fP\fIconvert_to_8_bit\fP\fB, const void \fP\fI*buffer\fP\fB, png_int_32 \fIrow_stride)\fP\fB);\fP |
| 38 | |
| 39 | \fI\fB |
| 40 | |
Glenn Randers-Pehrson | 1ef65b6 | 2000-05-12 06:19:53 -0500 | [diff] [blame] | 41 | \fBpng_uint_32 png_access_version_number \fI(void\fP\fB);\fP |
| 42 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 43 | \fI\fB |
| 44 | |
Glenn Randers-Pehrson | 6bc53be | 2006-06-16 07:52:03 -0500 | [diff] [blame] | 45 | \fBvoid png_benign_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP |
| 46 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 47 | \fI\fB |
| 48 | |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 49 | \fBvoid png_build_grayscale_palette (int \fP\fIbit_depth\fP\fB, png_colorp \fIpalette\fP\fB);\fP |
| 50 | |
| 51 | \fI\fB |
| 52 | |
| 53 | \fBpng_voidp png_calloc (png_structp \fP\fIpng_ptr\fP\fB, png_alloc_size_t \fIsize\fP\fB);\fP |
| 54 | |
| 55 | \fI\fB |
| 56 | |
Glenn Randers-Pehrson | 6bc53be | 2006-06-16 07:52:03 -0500 | [diff] [blame] | 57 | \fBvoid png_chunk_benign_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP |
| 58 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 59 | \fI\fB |
| 60 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 61 | \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] | 62 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 63 | \fI\fB |
| 64 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 65 | \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] | 66 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 67 | \fI\fB |
| 68 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 69 | \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] | 70 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 71 | \fI\fB |
| 72 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 73 | \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] | 74 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 75 | \fI\fB |
| 76 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 77 | \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] | 78 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 79 | \fI\fB |
| 80 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 81 | \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] | 82 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 83 | \fI\fB |
| 84 | |
Glenn Randers-Pehrson | 5e5c1e1 | 2000-11-10 12:26:19 -0600 | [diff] [blame] | 85 | \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] | 86 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 87 | \fI\fB |
| 88 | |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 89 | \fBpng_structp png_create_read_struct_2 (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fP\fIwarn_fn\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 90 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 91 | \fI\fB |
| 92 | |
Glenn Randers-Pehrson | 5e5c1e1 | 2000-11-10 12:26:19 -0600 | [diff] [blame] | 93 | \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] | 94 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 95 | \fI\fB |
| 96 | |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 97 | \fBpng_structp png_create_write_struct_2 (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fP\fIwarn_fn\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP |
| 98 | |
| 99 | \fI\fB |
| 100 | |
| 101 | \fBvoid png_data_freer (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIfreer\fP\fB, png_uint_32 \fImask)\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 102 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 103 | \fI\fB |
| 104 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 105 | \fBvoid png_destroy_info_struct (png_structp \fP\fIpng_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP |
| 106 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 107 | \fI\fB |
| 108 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 109 | \fBvoid png_destroy_read_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fP\fIinfo_ptr_ptr\fP\fB, png_infopp \fIend_info_ptr_ptr\fP\fB);\fP |
| 110 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 111 | \fI\fB |
| 112 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 113 | \fBvoid png_destroy_write_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP |
| 114 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 115 | \fI\fB |
| 116 | |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 117 | \fBvoid png_err (png_structp \fIpng_ptr\fP\fB);\fP |
| 118 | |
| 119 | \fI\fB |
| 120 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 121 | \fBvoid png_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP |
| 122 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 123 | \fI\fB |
| 124 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 125 | \fBvoid png_free (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP |
| 126 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 127 | \fI\fB |
| 128 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 129 | \fBvoid png_free_chunk_list (png_structp \fIpng_ptr\fP\fB);\fP |
| 130 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 131 | \fI\fB |
| 132 | |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 133 | \fBvoid png_free_default (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 134 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 135 | \fI\fB |
| 136 | |
Glenn Randers-Pehrson | a77ef62 | 2000-02-18 13:48:52 -0600 | [diff] [blame] | 137 | \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] | 138 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 139 | \fI\fB |
| 140 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 141 | \fBpng_byte png_get_bit_depth (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 142 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 143 | \fI\fB |
| 144 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 145 | \fBpng_uint_32 png_get_bKGD (png_const_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fI*background\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 146 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 147 | \fI\fB |
| 148 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 149 | \fBpng_byte png_get_channels (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 150 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 151 | \fI\fB |
| 152 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 153 | \fBpng_uint_32 png_get_cHRM (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, double \fP\fI*white_x\fP\fB, double \fP\fI*white_y\fP\fB, double \fP\fI*red_x\fP\fB, double \fP\fI*red_y\fP\fB, double \fP\fI*green_x\fP\fB, double \fP\fI*green_y\fP\fB, double \fP\fI*blue_x\fP\fB, double \fI*blue_y\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 154 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 155 | \fI\fB |
| 156 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 157 | \fBpng_uint_32 png_get_cHRM_fixed (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*white_x\fP\fB, png_uint_32 \fP\fI*white_y\fP\fB, png_uint_32 \fP\fI*red_x\fP\fB, png_uint_32 \fP\fI*red_y\fP\fB, png_uint_32 \fP\fI*green_x\fP\fB, png_uint_32 \fP\fI*green_y\fP\fB, png_uint_32 \fP\fI*blue_x\fP\fB, png_uint_32 \fI*blue_y\fP\fB);\fP |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 158 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 159 | \fI\fB |
| 160 | |
John Bowler | 736f40f | 2011-08-25 16:19:44 -0500 | [diff] [blame] | 161 | \fBpng_uint_32 png_get_cHRM_XYZ (png_structp \fIpng_ptr, |
| 162 | |
| 163 | \fBpng_const_infop \fP\fIinfo_ptr\fP\fB, double \fP\fI*red_X\fP\fB, double \fP\fI*red_Y\fP\fB, double \fI*red_Z, |
| 164 | |
| 165 | \fBdouble \fP\fI*green_X\fP\fB, double \fP\fI*green_Y\fP\fB, double \fP\fI*green_Z\fP\fB, double \fI*blue_X, |
| 166 | |
| 167 | \fBdouble \fP\fI*blue_Y\fP\fB, double \fI*blue_Z\fP\fB);\fP |
Glenn Randers-Pehrson | 800d1e9 | 2008-08-20 17:25:21 -0500 | [diff] [blame] | 168 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 169 | \fI\fB |
| 170 | |
John Bowler | 736f40f | 2011-08-25 16:19:44 -0500 | [diff] [blame] | 171 | \fBpng_uint_32 png_get_cHRM_XYZ_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_fixed_point \fP\fI*int_red_X\fP\fB, png_fixed_point \fP\fI*int_red_Y\fP\fB, png_fixed_point \fP\fI*int_red_Z\fP\fB, png_fixed_point \fP\fI*int_green_X\fP\fB, png_fixed_point \fP\fI*int_green_Y\fP\fB, png_fixed_point \fP\fI*int_green_Z\fP\fB, png_fixed_point \fP\fI*int_blue_X\fP\fB, png_fixed_point \fP\fI*int_blue_Y\fP\fB, png_fixed_point \fI*int_blue_Z\fP\fB);\fP |
| 172 | |
| 173 | \fI\fB |
| 174 | |
| 175 | \fBpng_uint_32 png_get_chunk_cache_max (png_const_structp \fIpng_ptr\fP\fB);\fP |
| 176 | |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 177 | \fI\fB |
| 178 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 179 | \fBpng_alloc_size_t png_get_chunk_malloc_max (png_const_structp \fIpng_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 180 | |
| 181 | \fI\fB |
| 182 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 183 | \fBpng_byte png_get_color_type (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 184 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 185 | \fI\fB |
| 186 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 187 | \fBpng_uint_32 png_get_compression_buffer_size (png_const_structp \fIpng_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 800d1e9 | 2008-08-20 17:25:21 -0500 | [diff] [blame] | 188 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 189 | \fI\fB |
| 190 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 191 | \fBpng_byte png_get_compression_type (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 192 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 193 | \fI\fB |
| 194 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 195 | \fBpng_byte png_get_copyright (png_const_structp \fIpng_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 196 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 197 | \fI\fB |
| 198 | |
John Bowler | f19abd6 | 2011-01-22 18:29:24 -0600 | [diff] [blame] | 199 | \fBpng_uint_32 png_get_current_row_number \fI(png_const_structp\fP\fB);\fP |
| 200 | |
| 201 | \fI\fB |
| 202 | |
| 203 | \fBpng_byte png_get_current_pass_number \fI(png_const_structp\fP\fB);\fP |
| 204 | |
| 205 | \fI\fB |
| 206 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 207 | \fBpng_voidp png_get_error_ptr (png_const_structp \fIpng_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 208 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 209 | \fI\fB |
| 210 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 211 | \fBpng_byte png_get_filter_type (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 212 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 213 | \fI\fB |
| 214 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 215 | \fBpng_uint_32 png_get_gAMA (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, double \fI*file_gamma\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 216 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 217 | \fI\fB |
| 218 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 219 | \fBpng_uint_32 png_get_gAMA_fixed (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fI*int_file_gamma\fP\fB);\fP |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 220 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 221 | \fI\fB |
| 222 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 223 | \fBpng_byte png_get_header_ver (png_const_structp \fIpng_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 5379b24 | 1999-11-27 10:22:33 -0600 | [diff] [blame] | 224 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 225 | \fI\fB |
| 226 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 227 | \fBpng_byte png_get_header_version (png_const_structp \fIpng_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 228 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 229 | \fI\fB |
| 230 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 231 | \fBpng_uint_32 png_get_hIST (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fI*hist\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 232 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 233 | \fI\fB |
| 234 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 235 | \fBpng_uint_32 png_get_iCCP (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_charpp \fP\fIname\fP\fB, int \fP\fI*compression_type\fP\fB, png_bytepp \fP\fIprofile\fP\fB, png_uint_32 \fI*proflen\fP\fB);\fP |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 236 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 237 | \fI\fB |
| 238 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 239 | \fBpng_uint_32 png_get_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*width\fP\fB, png_uint_32 \fP\fI*height\fP\fB, int \fP\fI*bit_depth\fP\fB, int \fP\fI*color_type\fP\fB, int \fP\fI*interlace_type\fP\fB, int \fP\fI*compression_type\fP\fB, int \fI*filter_type\fP\fB);\fP |
| 240 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 241 | \fI\fB |
| 242 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 243 | \fBpng_uint_32 png_get_image_height (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 244 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 245 | \fI\fB |
| 246 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 247 | \fBpng_uint_32 png_get_image_width (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 248 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 249 | \fI\fB |
| 250 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 251 | \fBpng_int_32 png_get_int_32 (png_bytep \fIbuf\fP\fB);\fP |
| 252 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 253 | \fI\fB |
Glenn Randers-Pehrson | 7b34df3 | 2006-02-24 06:30:16 -0600 | [diff] [blame] | 254 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 255 | \fBpng_byte png_get_interlace_type (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 256 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 257 | \fI\fB |
| 258 | |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 259 | \fBpng_const_bytep png_get_io_chunk_name (png_structp \fIpng_ptr\fP\fB);\fP |
| 260 | |
| 261 | \fI\fB |
| 262 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 263 | \fBpng_uint_32 png_get_io_chunk_type (png_const_structp \fIpng_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | a63dbed | 2011-01-22 08:51:19 -0600 | [diff] [blame] | 264 | |
| 265 | \fI\fB |
| 266 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 267 | \fBpng_voidp png_get_io_ptr (png_structp \fIpng_ptr\fP\fB);\fP |
| 268 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 269 | \fI\fB |
| 270 | |
Glenn Randers-Pehrson | a63dbed | 2011-01-22 08:51:19 -0600 | [diff] [blame] | 271 | \fBpng_uint_32 png_get_io_state (png_structp \fIpng_ptr\fP\fB);\fP |
| 272 | |
| 273 | \fI\fB |
| 274 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 275 | \fBpng_byte png_get_libpng_ver (png_const_structp \fIpng_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 5379b24 | 1999-11-27 10:22:33 -0600 | [diff] [blame] | 276 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 277 | \fI\fB |
| 278 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 279 | \fBpng_voidp png_get_mem_ptr (png_const_structp \fIpng_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 280 | |
| 281 | \fI\fB |
| 282 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 283 | \fBpng_uint_32 png_get_oFFs (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*offset_x\fP\fB, png_uint_32 \fP\fI*offset_y\fP\fB, int \fI*unit_type\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 284 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 285 | \fI\fB |
| 286 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 287 | \fBpng_uint_32 png_get_pCAL (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fI*purpose\fP\fB, png_int_32 \fP\fI*X0\fP\fB, png_int_32 \fP\fI*X1\fP\fB, int \fP\fI*type\fP\fB, int \fP\fI*nparams\fP\fB, png_charp \fP\fI*units\fP\fB, png_charpp \fI*params\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 288 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 289 | \fI\fB |
| 290 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 291 | \fBpng_uint_32 png_get_pHYs (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*res_x\fP\fB, png_uint_32 \fP\fI*res_y\fP\fB, int \fI*unit_type\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 292 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 293 | \fI\fB |
| 294 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 295 | \fBfloat png_get_pixel_aspect_ratio (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 296 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 297 | \fI\fB |
| 298 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 299 | \fBpng_uint_32 png_get_pHYs_dpi (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*res_x\fP\fB, png_uint_32 \fP\fI*res_y\fP\fB, int \fI*unit_type\fP\fB);\fP |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 300 | |
| 301 | \fI\fB |
| 302 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 303 | \fBpng_fixed_point png_get_pixel_aspect_ratio_fixed (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 304 | |
| 305 | \fI\fB |
| 306 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 307 | \fBpng_uint_32 png_get_pixels_per_inch (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 308 | |
| 309 | \fI\fB |
| 310 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 311 | \fBpng_uint_32 png_get_pixels_per_meter (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 312 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 313 | \fI\fB |
| 314 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 315 | \fBpng_voidp png_get_progressive_ptr (png_const_structp \fIpng_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 316 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 317 | \fI\fB |
| 318 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 319 | \fBpng_uint_32 png_get_PLTE (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_colorp \fP\fI*palette\fP\fB, int \fI*num_palette\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 320 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 321 | \fI\fB |
| 322 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 323 | \fBpng_byte png_get_rgb_to_gray_status (png_const_structp \fIpng_ptr) |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 324 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 325 | \fBpng_uint_32 png_get_rowbytes (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 326 | |
| 327 | \fI\fB |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 328 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 329 | \fBpng_bytepp png_get_rows (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | a77ef62 | 2000-02-18 13:48:52 -0600 | [diff] [blame] | 330 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 331 | \fI\fB |
| 332 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 333 | \fBpng_uint_32 png_get_sBIT (png_const_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_8p \fI*sig_bit\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 334 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 335 | \fI\fB |
| 336 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 337 | \fBvoid png_get_sCAL (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, int* \fP\fIunit\fP\fB, double* \fP\fIwidth\fP\fB, double* \fIheight\fP\fB);\fP |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 338 | |
| 339 | \fI\fB |
| 340 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 341 | \fBvoid png_get_sCAL_fixed (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, int* \fP\fIunit\fP\fB, png_fixed_pointp \fP\fIwidth\fP\fB, png_fixed_pointp \fIheight\fP\fB);\fP |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 342 | |
| 343 | \fI\fB |
| 344 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 345 | \fBvoid png_get_sCAL_s (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, int* \fP\fIunit\fP\fB, png_charpp \fP\fIwidth\fP\fB, png_charpp \fIheight\fP\fB);\fP |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 346 | |
| 347 | \fI\fB |
| 348 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 349 | \fBpng_bytep png_get_signature (png_const_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] | 350 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 351 | \fI\fB |
| 352 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 353 | \fBpng_uint_32 png_get_sPLT (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fI*splt_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 354 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 355 | \fI\fB |
| 356 | |
Glenn Randers-Pehrson | 8d0bc0f | 2011-01-25 22:15:58 -0600 | [diff] [blame] | 357 | \fBpng_uint_32 png_get_sRGB (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, int \fI*file_srgb_intent\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 358 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 359 | \fI\fB |
| 360 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 361 | \fBpng_uint_32 png_get_text (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fI*text_ptr\fP\fB, int \fI*num_text\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 362 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 363 | \fI\fB |
| 364 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 365 | \fBpng_uint_32 png_get_tIME (png_const_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fI*mod_time\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 366 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 367 | \fI\fB |
| 368 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 369 | \fBpng_uint_32 png_get_tRNS (png_const_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fI*trans_alpha\fP\fB, int \fP\fI*num_trans\fP\fB, png_color_16p \fI*trans_color\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 370 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 371 | \fI\fB |
| 372 | |
| 373 | \fB/* This function is really an inline macro. \fI*/ |
| 374 | |
| 375 | \fBpng_uint_16 png_get_uint_16 (png_bytep \fIbuf\fP\fB);\fP |
| 376 | |
| 377 | \fI\fB |
Glenn Randers-Pehrson | 7b34df3 | 2006-02-24 06:30:16 -0600 | [diff] [blame] | 378 | |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 379 | \fBpng_uint_32 png_get_uint_31 (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIbuf\fP\fB);\fP |
Glenn Randers-Pehrson | 7b34df3 | 2006-02-24 06:30:16 -0600 | [diff] [blame] | 380 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 381 | \fI\fB |
| 382 | |
| 383 | \fB/* This function is really an inline macro. \fI*/ |
| 384 | |
| 385 | \fBpng_uint_32 png_get_uint_32 (png_bytep \fIbuf\fP\fB);\fP |
| 386 | |
| 387 | \fI\fB |
Glenn Randers-Pehrson | 7b34df3 | 2006-02-24 06:30:16 -0600 | [diff] [blame] | 388 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 389 | \fBpng_uint_32 png_get_unknown_chunks (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkpp \fIunknowns\fP\fB);\fP |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 390 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 391 | \fI\fB |
| 392 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 393 | \fBpng_voidp png_get_user_chunk_ptr (png_const_structp \fIpng_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 394 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 395 | \fI\fB |
| 396 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 397 | \fBpng_uint_32 png_get_user_height_max (png_const_structp \fIpng_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 272489d | 2004-08-04 06:34:52 -0500 | [diff] [blame] | 398 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 399 | \fI\fB |
| 400 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 401 | \fBpng_voidp png_get_user_transform_ptr (png_const_structp \fIpng_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 402 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 403 | \fI\fB |
| 404 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 405 | \fBpng_uint_32 png_get_user_width_max (png_const_structp \fIpng_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 272489d | 2004-08-04 06:34:52 -0500 | [diff] [blame] | 406 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 407 | \fI\fB |
| 408 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 409 | \fBpng_uint_32 png_get_valid (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIflag\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 410 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 411 | \fI\fB |
| 412 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 413 | \fBfloat png_get_x_offset_inches (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 414 | |
| 415 | \fI\fB |
| 416 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 417 | \fBpng_fixed_point png_get_x_offset_inches_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 418 | |
| 419 | \fI\fB |
| 420 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 421 | \fBpng_int_32 png_get_x_offset_microns (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 422 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 423 | \fI\fB |
| 424 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 425 | \fBpng_int_32 png_get_x_offset_pixels (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 426 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 427 | \fI\fB |
| 428 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 429 | \fBpng_uint_32 png_get_x_pixels_per_inch (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 430 | |
| 431 | \fI\fB |
| 432 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 433 | \fBpng_uint_32 png_get_x_pixels_per_meter (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 434 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 435 | \fI\fB |
| 436 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 437 | \fBfloat png_get_y_offset_inches (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 438 | |
| 439 | \fI\fB |
| 440 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 441 | \fBpng_fixed_point png_get_y_offset_inches_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 442 | |
| 443 | \fI\fB |
| 444 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 445 | \fBpng_int_32 png_get_y_offset_microns (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 446 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 447 | \fI\fB |
| 448 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 449 | \fBpng_int_32 png_get_y_offset_pixels (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 450 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 451 | \fI\fB |
| 452 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 453 | \fBpng_uint_32 png_get_y_pixels_per_inch (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 454 | |
| 455 | \fI\fB |
| 456 | |
John Bowler | 0a5c9c0 | 2011-01-22 17:36:34 -0600 | [diff] [blame] | 457 | \fBpng_uint_32 png_get_y_pixels_per_meter (png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 458 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 459 | \fI\fB |
| 460 | |
Glenn Randers-Pehrson | c1bfe68 | 2002-03-06 22:08:00 -0600 | [diff] [blame] | 461 | \fBint png_handle_as_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP |
| 462 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 463 | \fI\fB |
| 464 | |
Glenn Randers-Pehrson | e0a6c06 | 2011-11-07 23:50:05 -0600 | [diff] [blame] | 465 | \fBint png_image_begin_read_from_file (png_imagep \fP\fIimage\fP\fB, const char \fI*file_name\fP\fB);\fP |
| 466 | |
| 467 | \fI\fB |
| 468 | |
| 469 | \fBint png_image_begin_read_from_stdio (png_imagep \fP\fIimage\fP\fB, FILE* \fIfile\fP\fB);\fP |
| 470 | |
| 471 | \fI\fB |
| 472 | |
| 473 | \fBint, png_image_begin_read_from_memory (png_imagep \fP\fIimage\fP\fB, png_const_voidp \fP\fImemory\fP\fB, png_size_t \fIsize\fP\fB);\fP |
| 474 | |
| 475 | \fI\fB |
| 476 | |
| 477 | \fBint png_image_finish_read (png_imagep \fP\fIimage\fP\fB, png_colorp \fP\fIbackground\fP\fB, void \fP\fI*buffer\fP\fB, png_int_32 \fIrow_stride\fP\fB);\fP |
| 478 | |
| 479 | \fI\fB |
| 480 | |
| 481 | \fBvoid png_image_free (png_imagep \fIimage\fP\fB);\fP |
| 482 | |
| 483 | \fI\fB |
| 484 | |
| 485 | \fBint png_image_write_to_file (png_imagep \fP\fIimage\fP\fB, const char \fP\fI*file\fP\fB, int \fP\fIconvert_to_8bit\fP\fB, const void \fI*buffer, |
| 486 | |
| 487 | \fBpng_int_32 \fIrow_stride\fP\fB);\fP |
| 488 | |
| 489 | \fI\fB |
| 490 | |
| 491 | \fBint png_image_write_to_stdio (png_imagep \fP\fIimage\fP\fB, FILE \fP\fI*file\fP\fB, int \fP\fIconvert_to_8_bit\fP\fB, const void \fP\fI*buffer\fP\fB, png_int_32 \fIrow_stride)\fP\fB);\fP |
| 492 | |
| 493 | \fI\fB |
| 494 | |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 495 | \fBvoid png_info_init_3 (png_infopp \fP\fIinfo_ptr\fP\fB, png_size_t \fIpng_info_struct_size\fP\fB);\fP |
| 496 | |
| 497 | \fI\fB |
| 498 | |
Glenn Randers-Pehrson | 8b6a889 | 2001-05-18 04:54:50 -0500 | [diff] [blame] | 499 | \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] | 500 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 501 | \fI\fB |
| 502 | |
Glenn Randers-Pehrson | f98726a | 2010-02-19 09:54:53 -0600 | [diff] [blame] | 503 | \fBvoid png_longjmp (png_structp \fP\fIpng_ptr\fP\fB, int \fIval\fP\fB);\fP |
| 504 | |
| 505 | \fI\fB |
| 506 | |
Glenn Randers-Pehrson | beb572e | 2006-08-19 13:59:24 -0500 | [diff] [blame] | 507 | \fBpng_voidp png_malloc (png_structp \fP\fIpng_ptr\fP\fB, png_alloc_size_t \fIsize\fP\fB);\fP |
Glenn Randers-Pehrson | 8b6a889 | 2001-05-18 04:54:50 -0500 | [diff] [blame] | 508 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 509 | \fI\fB |
| 510 | |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 511 | \fBpng_voidp png_malloc_default (png_structp \fP\fIpng_ptr\fP\fB, png_alloc_size_t \fIsize\fP\fB);\fP |
| 512 | |
| 513 | \fI\fB |
| 514 | |
| 515 | \fBpng_voidp png_malloc_warn (png_structp \fP\fIpng_ptr\fP\fB, png_alloc_size_t \fIsize\fP\fB);\fP |
| 516 | |
| 517 | \fI\fB |
| 518 | |
| 519 | \fBpng_uint_32 png_permit_mng_features (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fImng_features_permitted\fP\fB);\fP |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 520 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 521 | \fI\fB |
| 522 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 523 | \fBvoid png_process_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_size\fP\fB);\fP |
| 524 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 525 | \fI\fB |
| 526 | |
John Bowler | f19abd6 | 2011-01-22 18:29:24 -0600 | [diff] [blame] | 527 | \fBpng_size_t png_process_data_pause \fP\fI(png_structp\fP\fB, int \fIsave\fP\fB);\fP |
| 528 | |
| 529 | \fI\fB |
| 530 | |
| 531 | \fBpng_uint_32 png_process_data_skip \fI(png_structp\fP\fB);\fP |
| 532 | |
| 533 | \fI\fB |
| 534 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 535 | \fBvoid png_progressive_combine_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIold_row\fP\fB, png_bytep \fInew_row\fP\fB);\fP |
| 536 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 537 | \fI\fB |
| 538 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 539 | \fBvoid png_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP |
| 540 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 541 | \fI\fB |
| 542 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 543 | \fBvoid png_read_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP |
| 544 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 545 | \fI\fB |
| 546 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 547 | \fBvoid png_read_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP |
| 548 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 549 | \fI\fB |
| 550 | |
Glenn Randers-Pehrson | 5e5c1e1 | 2000-11-10 12:26:19 -0600 | [diff] [blame] | 551 | \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] | 552 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 553 | \fI\fB |
| 554 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 555 | \fBvoid png_read_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fIdisplay_row\fP\fB);\fP |
| 556 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 557 | \fI\fB |
| 558 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 559 | \fBvoid png_read_rows (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fP\fIrow\fP\fB, png_bytepp \fP\fIdisplay_row\fP\fB, png_uint_32 \fInum_rows\fP\fB);\fP |
| 560 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 561 | \fI\fB |
| 562 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 563 | \fBvoid png_read_update_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP |
| 564 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 565 | \fI\fB |
| 566 | |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 567 | \fBint png_reset_zstream (png_structp \fIpng_ptr\fP\fB);\fP |
| 568 | |
| 569 | \fI\fB |
| 570 | |
| 571 | \fBvoid png_save_int_32 (png_bytep \fP\fIbuf\fP\fB, png_int_32 \fIi\fP\fB);\fP |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 572 | |
| 573 | \fI\fB |
Glenn Randers-Pehrson | 7b34df3 | 2006-02-24 06:30:16 -0600 | [diff] [blame] | 574 | |
| 575 | \fBvoid png_save_uint_16 (png_bytep \fP\fIbuf\fP\fB, unsigned int \fIi\fP\fB);\fP |
| 576 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 577 | \fI\fB |
| 578 | |
Glenn Randers-Pehrson | 7b34df3 | 2006-02-24 06:30:16 -0600 | [diff] [blame] | 579 | \fBvoid png_save_uint_32 (png_bytep \fP\fIbuf\fP\fB, png_uint_32 \fIi\fP\fB);\fP |
| 580 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 581 | \fI\fB |
| 582 | |
| 583 | \fBvoid png_set_add_alpha (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP |
| 584 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 585 | \fI\fB |
Glenn Randers-Pehrson | 67864af | 2004-08-28 23:30:07 -0500 | [diff] [blame] | 586 | |
Glenn Randers-Pehrson | c782251 | 2011-05-07 21:23:43 -0500 | [diff] [blame] | 587 | \fBvoid png_set_alpha_mode (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fImode\fP\fB, double \fIoutput_gamma\fP\fB);\fP |
| 588 | |
| 589 | \fI\fB |
| 590 | |
| 591 | \fBvoid png_set_alpha_mode_fixed (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fImode\fP\fB, png_fixed_point \fIoutput_gamma\fP\fB);\fP |
| 592 | |
| 593 | \fI\fB |
| 594 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 595 | \fBvoid png_set_background (png_structp \fP\fIpng_ptr\fP\fB, png_color_16p \fP\fIbackground_color\fP\fB, int \fP\fIbackground_gamma_code\fP\fB, int \fP\fIneed_expand\fP\fB, double \fIbackground_gamma\fP\fB);\fP |
| 596 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 597 | \fI\fB |
| 598 | |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 599 | \fBvoid png_set_background_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_color_16p \fP\fIbackground_color\fP\fB, int \fP\fIbackground_gamma_code\fP\fB, int \fP\fIneed_expand\fP\fB, png_uint_32 \fIbackground_gamma\fP\fB);\fP |
| 600 | |
| 601 | \fI\fB |
| 602 | |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 603 | \fBvoid png_set_benign_errors (png_structp \fP\fIpng_ptr\fP\fB, int \fIallowed\fP\fB);\fP |
| 604 | |
| 605 | \fI\fB |
| 606 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 607 | \fBvoid png_set_bgr (png_structp \fIpng_ptr\fP\fB);\fP |
| 608 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 609 | \fI\fB |
| 610 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 611 | \fBvoid png_set_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fIbackground\fP\fB);\fP |
| 612 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 613 | \fI\fB |
| 614 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 615 | \fBvoid png_set_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP |
| 616 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 617 | \fI\fB |
| 618 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 619 | \fBvoid png_set_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIwhite_x\fP\fB, png_uint_32 \fP\fIwhite_y\fP\fB, png_uint_32 \fP\fIred_x\fP\fB, png_uint_32 \fP\fIred_y\fP\fB, png_uint_32 \fP\fIgreen_x\fP\fB, png_uint_32 \fP\fIgreen_y\fP\fB, png_uint_32 \fP\fIblue_x\fP\fB, png_uint_32 \fIblue_y\fP\fB);\fP |
| 620 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 621 | \fI\fB |
| 622 | |
John Bowler | 736f40f | 2011-08-25 16:19:44 -0500 | [diff] [blame] | 623 | \fBvoid png_set_cHRM_XYZ (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fIred_X\fP\fB, double \fP\fIred_Y\fP\fB, double \fP\fIred_Z\fP\fB, double \fP\fIgreen_X\fP\fB, double \fIgreen_Y, |
| 624 | |
| 625 | \fBdouble \fP\fIgreen_Z\fP\fB, double \fP\fIblue_X\fP\fB, double \fP\fIblue_Y\fP\fB, double \fIblue_Z\fP\fB);\fP |
| 626 | |
| 627 | \fI\fB |
| 628 | |
| 629 | \fBvoid png_set_cHRM_XYZ_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_fixed_point \fP\fIint_red_X\fP\fB, png_fixed_point \fP\fIint_red_Y\fP\fB, png_fixed_point \fP\fIint_red_Z\fP\fB, png_fixed_point \fP\fIint_green_X\fP\fB, png_fixed_point \fP\fIint_green_Y\fP\fB, png_fixed_point \fP\fIint_green_Z\fP\fB, png_fixed_point \fP\fIint_blue_X\fP\fB, png_fixed_point \fP\fIint_blue_Y\fP\fB, png_fixed_point \fIint_blue_Z\fP\fB);\fP |
| 630 | |
| 631 | \fI\fB |
| 632 | |
Glenn Randers-Pehrson | 800d1e9 | 2008-08-20 17:25:21 -0500 | [diff] [blame] | 633 | \fBvoid png_set_chunk_cache_max (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIuser_chunk_cache_max\fP\fB);\fP |
| 634 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 635 | \fI\fB |
| 636 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 637 | \fBvoid png_set_compression_level (png_structp \fP\fIpng_ptr\fP\fB, int \fIlevel\fP\fB);\fP |
| 638 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 639 | \fI\fB |
| 640 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 641 | \fBvoid png_set_compression_mem_level (png_structp \fP\fIpng_ptr\fP\fB, int \fImem_level\fP\fB);\fP |
| 642 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 643 | \fI\fB |
| 644 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 645 | \fBvoid png_set_compression_method (png_structp \fP\fIpng_ptr\fP\fB, int \fImethod\fP\fB);\fP |
| 646 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 647 | \fI\fB |
| 648 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 649 | \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] | 650 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 651 | \fI\fB |
| 652 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 653 | \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] | 654 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 655 | \fI\fB |
| 656 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 657 | \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] | 658 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 659 | \fI\fB |
| 660 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 661 | \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] | 662 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 663 | \fI\fB |
| 664 | |
Glenn Randers-Pehrson | d08b6bd | 2011-02-19 15:50:17 -0600 | [diff] [blame] | 665 | \fBvoid png_set_expand (png_structp \fIpng_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | c85f5f6 | 2011-02-13 05:56:07 -0600 | [diff] [blame] | 666 | |
| 667 | \fI\fB |
| 668 | |
Glenn Randers-Pehrson | d08b6bd | 2011-02-19 15:50:17 -0600 | [diff] [blame] | 669 | \fBvoid png_set_expand_16 (png_structp \fIpng_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 670 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 671 | \fI\fB |
| 672 | |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 673 | \fBvoid png_set_expand_gray_1_2_4_to_8 (png_structp \fIpng_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | 1ce0836 | 2006-03-08 23:35:59 -0600 | [diff] [blame] | 674 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 675 | \fI\fB |
| 676 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 677 | \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] | 678 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 679 | \fI\fB |
| 680 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 681 | \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] | 682 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 683 | \fI\fB |
| 684 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 685 | \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] | 686 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 687 | \fI\fB |
| 688 | |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 689 | \fBvoid png_set_filter_heuristics_fixed (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIheuristic_method\fP\fB, int \fP\fInum_weights\fP\fB, png_fixed_point_p \fP\fIfilter_weights\fP\fB, png_fixed_point_p \fIfilter_costs\fP\fB);\fP |
| 690 | |
| 691 | \fI\fB |
| 692 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 693 | \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] | 694 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 695 | \fI\fB |
| 696 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 697 | \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] | 698 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 699 | \fI\fB |
| 700 | |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 701 | \fBvoid png_set_gamma_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIscreen_gamma\fP\fB, png_uint_32 \fIdefault_file_gamma\fP\fB);\fP |
| 702 | |
| 703 | \fI\fB |
| 704 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 705 | \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] | 706 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 707 | \fI\fB |
| 708 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 709 | \fBvoid png_set_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIfile_gamma\fP\fB);\fP |
| 710 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 711 | \fI\fB |
| 712 | |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 713 | \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] | 714 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 715 | \fI\fB |
| 716 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 717 | \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] | 718 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 719 | \fI\fB |
| 720 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 721 | \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] | 722 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 723 | \fI\fB |
| 724 | |
Glenn Randers-Pehrson | 4a5a1ec | 2011-01-15 11:43:28 -0600 | [diff] [blame] | 725 | \fBvoid png_set_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_const_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_const_bytep \fP\fIprofile\fP\fB, png_uint_32 \fIproflen\fP\fB);\fP |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 726 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 727 | \fI\fB |
| 728 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 729 | \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] | 730 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 731 | \fI\fB |
| 732 | |
Glenn Randers-Pehrson | fc4a143 | 2000-05-17 17:39:34 -0500 | [diff] [blame] | 733 | \fBvoid png_set_invalid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fImask\fP\fB);\fP |
| 734 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 735 | \fI\fB |
| 736 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 737 | \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] | 738 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 739 | \fI\fB |
| 740 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 741 | \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] | 742 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 743 | \fI\fB |
| 744 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 745 | \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] | 746 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 747 | \fI\fB |
| 748 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 749 | \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] | 750 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 751 | \fI\fB |
| 752 | |
Glenn Randers-Pehrson | 1e6ed73 | 2009-11-20 22:06:56 -0600 | [diff] [blame] | 753 | \fBjmp_buf* png_set_longjmp_fn (png_structp \fP\fIpng_ptr\fP\fB, png_longjmp_ptr \fP\fIlongjmp_fn\fP\fB, size_t \fIjmp_buf_size\fP\fB);\fP |
| 754 | |
| 755 | \fI\fB |
| 756 | |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 757 | \fBvoid png_set_chunk_malloc_max (png_structp \fP\fIpng_ptr\fP\fB, png_alloc_size_t \fIuser_chunk_cache_max\fP\fB);\fP |
| 758 | |
| 759 | \fI\fB |
| 760 | |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 761 | \fBvoid png_set_compression_buffer_size (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP |
| 762 | |
| 763 | \fI\fB |
| 764 | |
| 765 | \fBvoid png_set_mem_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 766 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 767 | \fI\fB |
| 768 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 769 | \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] | 770 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 771 | \fI\fB |
| 772 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 773 | \fBvoid png_set_packing (png_structp \fIpng_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 774 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 775 | \fI\fB |
| 776 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 777 | \fBvoid png_set_packswap (png_structp \fIpng_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 778 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 779 | \fI\fB |
| 780 | |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 781 | \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] | 782 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 783 | \fI\fB |
| 784 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 785 | \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] | 786 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 787 | \fI\fB |
| 788 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 789 | \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] | 790 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 791 | \fI\fB |
| 792 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 793 | \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] | 794 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 795 | \fI\fB |
| 796 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 797 | \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] | 798 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 799 | \fI\fB |
| 800 | |
Glenn Randers-Pehrson | 3cd7cff | 2010-04-16 19:27:08 -0500 | [diff] [blame] | 801 | \fBvoid png_set_quantize (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fP\fInum_palette\fP\fB, int \fP\fImaximum_colors\fP\fB, png_uint_16p \fP\fIhistogram\fP\fB, int \fIfull_quantize\fP\fB);\fP |
| 802 | |
| 803 | \fI\fB |
| 804 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 805 | \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] | 806 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 807 | \fI\fB |
| 808 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 809 | \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] | 810 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 811 | \fI\fB |
| 812 | |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 813 | \fBvoid png_set_read_user_chunk_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIuser_chunk_ptr\fP\fB, png_user_chunk_ptr \fIread_user_chunk_fn\fP\fB);\fP |
| 814 | |
| 815 | \fI\fB |
| 816 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 817 | \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] | 818 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 819 | \fI\fB |
| 820 | |
Glenn Randers-Pehrson | 520a764 | 2000-03-21 05:13:06 -0600 | [diff] [blame] | 821 | \fBvoid png_set_rgb_to_gray (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIerror_action\fP\fB, double \fP\fIred\fP\fB, double \fIgreen\fP\fB);\fP |
| 822 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 823 | \fI\fB |
| 824 | |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 825 | \fBvoid png_set_rgb_to_gray_fixed (png_structp \fP\fIpng_ptr\fP\fB, int error_action png_uint_32 \fP\fIred\fP\fB, png_uint_32 \fIgreen\fP\fB);\fP |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 826 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 827 | \fI\fB |
| 828 | |
Glenn Randers-Pehrson | a77ef62 | 2000-02-18 13:48:52 -0600 | [diff] [blame] | 829 | \fBvoid png_set_rows (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytepp \fIrow_pointers\fP\fB);\fP |
| 830 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 831 | \fI\fB |
| 832 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 833 | \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] | 834 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 835 | \fI\fB |
| 836 | |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 837 | \fBvoid png_set_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIunit\fP\fB, double \fP\fIwidth\fP\fB, double \fIheight\fP\fB);\fP |
| 838 | |
| 839 | \fI\fB |
| 840 | |
| 841 | \fBvoid png_set_sCAL_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIunit\fP\fB, png_fixed_point \fP\fIwidth\fP\fB, png_fixed_point \fIheight\fP\fB);\fP |
| 842 | |
| 843 | \fI\fB |
| 844 | |
| 845 | \fBvoid png_set_sCAL_s (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIunit\fP\fB, png_charp \fP\fIwidth\fP\fB, png_charp \fIheight\fP\fB);\fP |
| 846 | |
| 847 | \fI\fB |
| 848 | |
Glenn Randers-Pehrson | c4a8214 | 2011-06-18 00:44:08 -0500 | [diff] [blame] | 849 | \fBvoid png_set_scale_16 (png_structp \fIpng_ptr\fP\fB);\fP |
| 850 | |
| 851 | \fI\fB |
| 852 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 853 | \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] | 854 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 855 | \fI\fB |
| 856 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 857 | \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] | 858 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 859 | \fI\fB |
| 860 | |
Glenn Randers-Pehrson | a77ef62 | 2000-02-18 13:48:52 -0600 | [diff] [blame] | 861 | \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] | 862 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 863 | \fI\fB |
| 864 | |
Glenn Randers-Pehrson | 8d0bc0f | 2011-01-25 22:15:58 -0600 | [diff] [blame] | 865 | \fBvoid png_set_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIsrgb_intent\fP\fB);\fP |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 866 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 867 | \fI\fB |
| 868 | |
Glenn Randers-Pehrson | 8d0bc0f | 2011-01-25 22:15:58 -0600 | [diff] [blame] | 869 | \fBvoid png_set_sRGB_gAMA_and_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIsrgb_intent\fP\fB);\fP |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 870 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 871 | \fI\fB |
| 872 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 873 | \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] | 874 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 875 | \fI\fB |
| 876 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 877 | \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] | 878 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 879 | \fI\fB |
| 880 | |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 881 | \fBvoid png_set_strip_error_numbers (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIstrip_mode\fP\fB);\fP |
| 882 | |
| 883 | \fI\fB |
| 884 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 885 | \fBvoid png_set_swap (png_structp \fIpng_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 886 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 887 | \fI\fB |
| 888 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 889 | \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] | 890 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 891 | \fI\fB |
| 892 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 893 | \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] | 894 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 895 | \fI\fB |
| 896 | |
Glenn Randers-Pehrson | 8eb8833 | 2011-04-01 00:16:50 -0500 | [diff] [blame] | 897 | \fBvoid png_set_text_compression_level (png_structp \fP\fIpng_ptr\fP\fB, int \fIlevel\fP\fB);\fP |
| 898 | |
| 899 | \fI\fB |
| 900 | |
| 901 | \fBvoid png_set_text_compression_mem_level (png_structp \fP\fIpng_ptr\fP\fB, int \fImem_level\fP\fB);\fP |
| 902 | |
| 903 | \fI\fB |
| 904 | |
| 905 | \fBvoid png_set_text_compression_strategy (png_structp \fP\fIpng_ptr\fP\fB, int \fIstrategy\fP\fB);\fP |
| 906 | |
| 907 | \fI\fB |
| 908 | |
| 909 | \fBvoid png_set_text_compression_window_bits (png_structp \fP\fIpng_ptr\fP\fB, int \fIwindow_bits\fP\fB);\fP |
| 910 | |
| 911 | \fI\fB |
| 912 | |
| 913 | \fBvoid \fP\fIpng_set_text_compression_method\fP\fB, (png_structp \fP\fIpng_ptr\fP\fB, int \fImethod)\fP\fB);\fP |
| 914 | |
| 915 | \fI\fB |
| 916 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 917 | \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] | 918 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 919 | \fI\fB |
| 920 | |
Glenn Randers-Pehrson | f3c51e4 | 2011-01-15 10:25:25 -0600 | [diff] [blame] | 921 | \fBvoid png_set_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fItrans_alpha\fP\fB, int \fP\fInum_trans\fP\fB, png_color_16p \fItrans_color\fP\fB);\fP |
Glenn Randers-Pehrson | f7d1a17 | 1998-06-06 15:31:35 -0500 | [diff] [blame] | 922 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 923 | \fI\fB |
| 924 | |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 925 | \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] | 926 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 927 | \fI\fB |
| 928 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 929 | \fBpng_uint_32 png_set_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkp \fP\fIunknowns\fP\fB, int \fP\fInum\fP\fB, int \fIlocation\fP\fB);\fP |
| 930 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 931 | \fI\fB |
| 932 | |
Glenn Randers-Pehrson | bb98bcb | 2011-01-22 16:27:39 -0600 | [diff] [blame] | 933 | \fBvoid png_set_unknown_chunk_location (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIchunk\fP\fB, int \fIlocation\fP\fB);\fP |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 934 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 935 | \fI\fB |
| 936 | |
Glenn Randers-Pehrson | 272489d | 2004-08-04 06:34:52 -0500 | [diff] [blame] | 937 | \fBvoid png_set_user_limits (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIuser_width_max\fP\fB, png_uint_32 \fIuser_height_max\fP\fB);\fP |
| 938 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 939 | \fI\fB |
| 940 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 941 | \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] | 942 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 943 | \fI\fB |
| 944 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 945 | \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] | 946 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 947 | \fI\fB |
| 948 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 949 | \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] | 950 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 951 | \fI\fB |
| 952 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 953 | \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] | 954 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 955 | \fI\fB |
| 956 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 957 | \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] | 958 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 959 | \fI\fB |
| 960 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 961 | \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] | 962 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 963 | \fI\fB |
| 964 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 965 | \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] | 966 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 967 | \fI\fB |
| 968 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 969 | \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] | 970 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 971 | \fI\fB |
| 972 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 973 | \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] | 974 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 975 | \fI\fB |
| 976 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 977 | \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] | 978 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 979 | \fI\fB |
| 980 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 981 | \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] | 982 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 983 | \fI\fB |
| 984 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 985 | \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] | 986 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 987 | \fI\fB |
| 988 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 989 | \fBvoid png_write_flush (png_structp \fIpng_ptr\fP\fB);\fP |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 990 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 991 | \fI\fB |
| 992 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 993 | \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] | 994 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 995 | \fI\fB |
| 996 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 997 | \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] | 998 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 999 | \fI\fB |
| 1000 | |
Glenn Randers-Pehrson | 5379b24 | 1999-11-27 10:22:33 -0600 | [diff] [blame] | 1001 | \fBvoid png_write_info_before_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP |
| 1002 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 1003 | \fI\fB |
| 1004 | |
Glenn Randers-Pehrson | 5e5c1e1 | 2000-11-10 12:26:19 -0600 | [diff] [blame] | 1005 | \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] | 1006 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 1007 | \fI\fB |
| 1008 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 1009 | \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] | 1010 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 1011 | \fI\fB |
| 1012 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 1013 | \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] | 1014 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 1015 | \fI\fB |
| 1016 | |
Glenn Randers-Pehrson | 6bc53be | 2006-06-16 07:52:03 -0500 | [diff] [blame] | 1017 | \fBvoid png_write_sig (png_structp \fIpng_ptr\fP\fB);\fP |
| 1018 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 1019 | \fI\fB |
| 1020 | |
Glenn Randers-Pehrson | 5b5dcf8 | 2004-07-17 22:45:44 -0500 | [diff] [blame] | 1021 | \fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP |
| 1022 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 1023 | \fI\fB |
| 1024 | |
Glenn Randers-Pehrson | 5b5dcf8 | 2004-07-17 22:45:44 -0500 | [diff] [blame] | 1025 | \fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP |
| 1026 | |
Glenn Randers-Pehrson | ad81d71 | 2009-07-30 15:39:00 -0500 | [diff] [blame] | 1027 | \fI\fB |
| 1028 | |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 1029 | .SH DESCRIPTION |
| 1030 | The |
| 1031 | .I libpng |
| 1032 | library supports encoding, decoding, and various manipulations of |
| 1033 | the Portable Network Graphics (PNG) format image files. It uses the |
| 1034 | .IR zlib(3) |
| 1035 | compression library. |
Glenn Randers-Pehrson | 557b256 | 2010-10-17 12:55:04 -0500 | [diff] [blame] | 1036 | Following is a copy of the libpng-manual.txt file that accompanies libpng. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1037 | .SH LIBPNG.TXT |
Glenn Randers-Pehrson | 557b256 | 2010-10-17 12:55:04 -0500 | [diff] [blame] | 1038 | libpng-manual.txt - A description on how to use and modify libpng |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1039 | |
Glenn Randers-Pehrson | 36251d3 | 2011-11-17 21:14:34 -0600 | [diff] [blame^] | 1040 | libpng version 1.5.7beta05 - November 18, 2011 |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1041 | Updated and distributed by Glenn Randers-Pehrson |
Glenn Randers-Pehrson | 5dd2b8e | 2004-11-24 07:50:16 -0600 | [diff] [blame] | 1042 | <glennrp at users.sourceforge.net> |
Glenn Randers-Pehrson | 9f45c8e | 2011-01-15 19:35:03 -0600 | [diff] [blame] | 1043 | Copyright (c) 1998-2011 Glenn Randers-Pehrson |
Glenn Randers-Pehrson | 037023b | 2009-06-24 10:27:36 -0500 | [diff] [blame] | 1044 | |
Glenn Randers-Pehrson | bfbf865 | 2009-06-26 21:46:52 -0500 | [diff] [blame] | 1045 | This document is released under the libpng license. |
Glenn Randers-Pehrson | c332bbc | 2009-06-25 13:43:50 -0500 | [diff] [blame] | 1046 | For conditions of distribution and use, see the disclaimer |
Glenn Randers-Pehrson | 037023b | 2009-06-24 10:27:36 -0500 | [diff] [blame] | 1047 | and license in png.h |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1048 | |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 1049 | Based on: |
| 1050 | |
Glenn Randers-Pehrson | 36251d3 | 2011-11-17 21:14:34 -0600 | [diff] [blame^] | 1051 | libpng versions 0.97, January 1998, through 1.5.7beta05 - November 18, 2011 |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 1052 | Updated and distributed by Glenn Randers-Pehrson |
Glenn Randers-Pehrson | 9f45c8e | 2011-01-15 19:35:03 -0600 | [diff] [blame] | 1053 | Copyright (c) 1998-2011 Glenn Randers-Pehrson |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1054 | |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 1055 | libpng 1.0 beta 6 version 0.96 May 28, 1997 |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 1056 | Updated and distributed by Andreas Dilger |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1057 | Copyright (c) 1996, 1997 Andreas Dilger |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1058 | |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 1059 | libpng 1.0 beta 2 - version 0.88 January 26, 1996 |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1060 | For conditions of distribution and use, see copyright |
| 1061 | notice in png.h. Copyright (c) 1995, 1996 Guy Eric |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 1062 | Schalnat, Group 42, Inc. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1063 | |
| 1064 | Updated/rewritten per request in the libpng FAQ |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1065 | Copyright (c) 1995, 1996 Frank J. T. Wojcik |
| 1066 | December 18, 1995 & January 20, 1996 |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1067 | |
| 1068 | .SH I. Introduction |
| 1069 | |
| 1070 | This file describes how to use and modify the PNG reference library |
| 1071 | (known as libpng) for your own use. There are five sections to this |
| 1072 | file: introduction, structures, reading, writing, and modification and |
| 1073 | configuration notes for various special platforms. In addition to this |
| 1074 | file, example.c is a good starting point for using the library, as |
| 1075 | it is heavily commented and should include everything most people |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 1076 | will need. We assume that libpng is already installed; see the |
| 1077 | INSTALL file for instructions on how to install libpng. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1078 | |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 1079 | For examples of libpng usage, see the files "example.c", "pngtest.c", |
Glenn Randers-Pehrson | f210a05 | 2009-11-12 10:02:24 -0600 | [diff] [blame] | 1080 | and the files in the "contrib" directory, all of which are included in |
| 1081 | the libpng distribution. |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 1082 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1083 | Libpng was written as a companion to the PNG specification, as a way |
| 1084 | 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] | 1085 | file format in application programs. |
| 1086 | |
Glenn Randers-Pehrson | a4981d4 | 2004-08-25 22:00:45 -0500 | [diff] [blame] | 1087 | The PNG specification (second edition), November 2003, is available as |
| 1088 | a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2003 (E)) at |
| 1089 | <http://www.w3.org/TR/2003/REC-PNG-20031110/ |
| 1090 | The W3C and ISO documents have identical technical content. |
| 1091 | |
| 1092 | The PNG-1.2 specification is available at |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 1093 | <http://www.libpng.org/pub/png/documents/>. It is technically equivalent |
| 1094 | to the PNG specification (second edition) but has some additional material. |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 1095 | |
| 1096 | The PNG-1.0 specification is available |
Glenn Randers-Pehrson | a4981d4 | 2004-08-25 22:00:45 -0500 | [diff] [blame] | 1097 | as RFC 2083 <http://www.libpng.org/pub/png/documents/> and as a |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 1098 | W3C Recommendation <http://www.w3.org/TR/REC.png.html>. |
| 1099 | |
| 1100 | Some additional chunks are described in the special-purpose public chunks |
Glenn Randers-Pehrson | a4981d4 | 2004-08-25 22:00:45 -0500 | [diff] [blame] | 1101 | documents at <http://www.libpng.org/pub/png/documents/>. |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 1102 | |
| 1103 | Other information |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 1104 | about PNG, and the latest version of libpng, can be found at the PNG home |
Glenn Randers-Pehrson | a4981d4 | 2004-08-25 22:00:45 -0500 | [diff] [blame] | 1105 | page, <http://www.libpng.org/pub/png/>. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1106 | |
| 1107 | Most users will not have to modify the library significantly; advanced |
| 1108 | users may want to modify it more. All attempts were made to make it as |
| 1109 | complete as possible, while keeping the code easy to understand. |
| 1110 | Currently, this library only supports C. Support for other languages |
| 1111 | is being considered. |
| 1112 | |
| 1113 | Libpng has been designed to handle multiple sessions at one time, |
| 1114 | to be easily modifiable, to be portable to the vast majority of |
| 1115 | machines (ANSI, K&R, 16-, 32-, and 64-bit) available, and to be easy |
| 1116 | to use. The ultimate goal of libpng is to promote the acceptance of |
| 1117 | the PNG file format in whatever way possible. While there is still |
| 1118 | work to be done (see the TODO file), libpng should cover the |
| 1119 | majority of the needs of its users. |
| 1120 | |
| 1121 | Libpng uses zlib for its compression and decompression of PNG files. |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 1122 | Further information about zlib, and the latest version of zlib, can |
Glenn Randers-Pehrson | d56aca7 | 2000-11-23 11:51:42 -0600 | [diff] [blame] | 1123 | 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] | 1124 | The zlib compression utility is a general purpose utility that is |
| 1125 | useful for more than PNG files, and can be used without libpng. |
| 1126 | See the documentation delivered with zlib for more details. |
| 1127 | You can usually find the source files for the zlib utility wherever you |
| 1128 | find the libpng source files. |
| 1129 | |
| 1130 | Libpng is thread safe, provided the threads are using different |
| 1131 | instances of the structures. Each thread should have its own |
| 1132 | png_struct and png_info instances, and thus its own image. |
| 1133 | Libpng does not protect itself against two threads using the |
Glenn Randers-Pehrson | 56f6396 | 2008-10-06 10:16:17 -0500 | [diff] [blame] | 1134 | same instance of a structure. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1135 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1136 | .SH II. Structures |
| 1137 | |
| 1138 | There are two main structures that are important to libpng, png_struct |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 1139 | and png_info. Both are internal structures that are no longer exposed |
| 1140 | in the libpng interface (as of libpng 1.5.0). |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1141 | |
| 1142 | The png_info structure is designed to provide information about the |
| 1143 | PNG file. At one time, the fields of png_info were intended to be |
| 1144 | directly accessible to the user. However, this tended to cause problems |
| 1145 | with applications using dynamically loaded libraries, and as a result |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 1146 | a set of interface functions for png_info (the png_get_*() and png_set_*() |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 1147 | functions) was developed, and direct access to the png_info fields was |
| 1148 | deprecated.. |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 1149 | |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 1150 | The png_struct structure is the object used by the library to decode a |
| 1151 | single image. As of 1.5.0 this structure is also not exposed. |
| 1152 | |
| 1153 | Almost all libpng APIs require a pointer to a png_struct as the first argument. |
| 1154 | Many (in particular the png_set and png_get APIs) also require a pointer |
| 1155 | to png_info as the second argument. Some application visible macros |
| 1156 | defined in png.h designed for basic data access (reading and writing |
Glenn Randers-Pehrson | a5e5547 | 2011-07-12 10:13:32 -0500 | [diff] [blame] | 1157 | integers in the PNG format) don't take a png_info pointer, but it's almost |
| 1158 | always safe to assume that a (png_struct*) has to be passed to call an API |
| 1159 | function. |
| 1160 | |
| 1161 | You can have more than one png_info structure associated with an image, |
| 1162 | as illustrated in pngtest.c, one for information valid prior to the |
| 1163 | IDAT chunks and another (called "end_info" below) for things after them. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1164 | |
| 1165 | The png.h header file is an invaluable reference for programming with libpng. |
| 1166 | And while I'm on the topic, make sure you include the libpng header file: |
| 1167 | |
| 1168 | #include <png.h> |
| 1169 | |
Glenn Randers-Pehrson | a5e5547 | 2011-07-12 10:13:32 -0500 | [diff] [blame] | 1170 | and also (as of libpng-1.5.0) the zlib header file, if you need it: |
| 1171 | |
| 1172 | #include <zlib.h> |
| 1173 | |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 1174 | .SS Types |
| 1175 | |
| 1176 | The png.h header file defines a number of integral types used by the |
| 1177 | APIs. Most of these are fairly obvious; for example types corresponding |
| 1178 | to integers of particular sizes and types for passing color values. |
| 1179 | |
| 1180 | One exception is how non-integral numbers are handled. For application |
| 1181 | convenience most APIs that take such numbers have C (double) arguments, |
| 1182 | however internally PNG, and libpng, use 32 bit signed integers and encode |
| 1183 | the value by multiplying by 100,000. As of libpng 1.5.0 a convenience |
| 1184 | macro PNG_FP_1 is defined in png.h along with a type (png_fixed_point) |
| 1185 | which is simply (png_int_32). |
| 1186 | |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 1187 | All APIs that take (double) arguments also have a matching API that |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 1188 | takes the corresponding fixed point integer arguments. The fixed point |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 1189 | API has the same name as the floating point one with "_fixed" appended. |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 1190 | The actual range of values permitted in the APIs is frequently less than |
| 1191 | the full range of (png_fixed_point) (-21474 to +21474). When APIs require |
| 1192 | a non-negative argument the type is recorded as png_uint_32 above. Consult |
| 1193 | the header file and the text below for more information. |
| 1194 | |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 1195 | Special care must be take with sCAL chunk handling because the chunk itself |
| 1196 | uses non-integral values encoded as strings containing decimal floating point |
| 1197 | numbers. See the comments in the header file. |
| 1198 | |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 1199 | .SS Configuration |
| 1200 | |
| 1201 | The main header file function declarations are frequently protected by C |
| 1202 | preprocessing directives of the form: |
| 1203 | |
| 1204 | #ifdef PNG_feature_SUPPORTED |
| 1205 | declare-function |
| 1206 | #endif |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 1207 | ... |
| 1208 | #ifdef PNG_feature_SUPPORTED |
| 1209 | use-function |
| 1210 | #endif |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 1211 | |
| 1212 | The library can be built without support for these APIs, although a |
| 1213 | standard build will have all implemented APIs. Application programs |
| 1214 | should check the feature macros before using an API for maximum |
| 1215 | portability. From libpng 1.5.0 the feature macros set during the build |
| 1216 | of libpng are recorded in the header file "pnglibconf.h" and this file |
| 1217 | is always included by png.h. |
| 1218 | |
Glenn Randers-Pehrson | a5e5547 | 2011-07-12 10:13:32 -0500 | [diff] [blame] | 1219 | If you don't need to change the library configuration from the default, skip to |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 1220 | the next section ("Reading"). |
| 1221 | |
| 1222 | Notice that some of the makefiles in the 'scripts' directory and (in 1.5.0) all |
| 1223 | of the build project files in the 'projects' directory simply copy |
| 1224 | scripts/pnglibconf.h.prebuilt to pnglibconf.h. This means that these build |
| 1225 | systems do not permit easy auto-configuration of the library - they only |
| 1226 | support the default configuration. |
| 1227 | |
| 1228 | The easiest way to make minor changes to the libpng configuration when |
| 1229 | auto-configuration is supported is to add definitions to the command line |
| 1230 | using (typically) CPPFLAGS. For example: |
| 1231 | |
| 1232 | CPPFLAGS=-DPNG_NO_FLOATING_ARITHMETIC |
| 1233 | |
| 1234 | will change the internal libpng math implementation for gamma correction and |
| 1235 | other arithmetic calculations to fixed point, avoiding the need for fast |
| 1236 | floating point support. The result can be seen in the generated pnglibconf.h - |
| 1237 | make sure it contains the changed feature macro setting. |
| 1238 | |
| 1239 | If you need to make more extensive configuration changes - more than one or two |
| 1240 | feature macro settings - you can either add -DPNG_USER_CONFIG to the build |
| 1241 | command line and put a list of feature macro settings in pngusr.h or you can set |
| 1242 | DFA_XTRA (a makefile variable) to a file containing the same information in the |
| 1243 | form of 'option' settings. |
| 1244 | |
| 1245 | A. Changing pnglibconf.h |
| 1246 | |
| 1247 | A variety of methods exist to build libpng. Not all of these support |
| 1248 | reconfiguration of pnglibconf.h. To reconfigure pnglibconf.h it must either be |
| 1249 | rebuilt from scripts/pnglibconf.dfa using awk or it must be edited by hand. |
| 1250 | |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 1251 | Hand editing is achieved by copying scripts/pnglibconf.h.prebuilt to |
| 1252 | pnglibconf.h and changing the lines defining the supported features, paying |
| 1253 | very close attention to the 'option' information in scripts/pnglibconf.dfa |
| 1254 | that describes those features and their requirements. This is easy to get |
| 1255 | wrong. |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 1256 | |
| 1257 | B. Configuration using DFA_XTRA |
| 1258 | |
| 1259 | Rebuilding from pnglibconf.dfa is easy if a functioning 'awk', or a later |
| 1260 | variant such as 'nawk' or 'gawk', is available. The configure build will |
| 1261 | automatically find an appropriate awk and build pnglibconf.h. |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 1262 | The scripts/pnglibconf.mak file contains a set of make rules for doing the |
| 1263 | same thing if configure is not used, and many of the makefiles in the scripts |
| 1264 | directory use this approach. |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 1265 | |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 1266 | When rebuilding simply write a new file containing changed options and set |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 1267 | DFA_XTRA to the name of this file. This causes the build to append the new file |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 1268 | to the end of scripts/pnglibconf.dfa. The pngusr.dfa file should contain lines |
| 1269 | of the following forms: |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 1270 | |
| 1271 | everything = off |
| 1272 | |
| 1273 | This turns all optional features off. Include it at the start of pngusr.dfa to |
| 1274 | make it easier to build a minimal configuration. You will need to turn at least |
| 1275 | some features on afterward to enable either reading or writing code, or both. |
| 1276 | |
| 1277 | option feature on |
| 1278 | option feature off |
| 1279 | |
| 1280 | Enable or disable a single feature. This will automatically enable other |
| 1281 | features required by a feature that is turned on or disable other features that |
| 1282 | require a feature which is turned off. Conflicting settings will cause an error |
| 1283 | message to be emitted by awk. |
| 1284 | |
| 1285 | setting feature default value |
| 1286 | |
| 1287 | Changes the default value of setting 'feature' to 'value'. There are a small |
| 1288 | number of settings listed at the top of pnglibconf.h, they are documented in the |
| 1289 | source code. Most of these values have performance implications for the library |
| 1290 | but most of them have no visible effect on the API. Some can also be overridden |
| 1291 | from the API. |
| 1292 | |
Glenn Randers-Pehrson | a5e5547 | 2011-07-12 10:13:32 -0500 | [diff] [blame] | 1293 | This method of building a customized pnglibconf.h is illustrated in |
| 1294 | contrib/pngminim/*. See the "$(PNGCONF):" target in the makefile and |
| 1295 | pngusr.dfa in these directories. |
| 1296 | |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 1297 | C. Configuration using PNG_USR_CONFIG |
| 1298 | |
| 1299 | If -DPNG_USR_CONFIG is added to the CFLAGS when pnglibconf.h is built the file |
| 1300 | pngusr.h will automatically be included before the options in |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 1301 | scripts/pnglibconf.dfa are processed. Your pngusr.h file should contain only |
| 1302 | macro definitions turning features on or off or setting settings. |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 1303 | |
| 1304 | Apart from the global setting "everything = off" all the options listed above |
| 1305 | can be set using macros in pngusr.h: |
| 1306 | |
| 1307 | #define PNG_feature_SUPPORTED |
| 1308 | |
| 1309 | is equivalent to: |
| 1310 | |
| 1311 | option feature on |
| 1312 | |
| 1313 | #define PNG_NO_feature |
| 1314 | |
| 1315 | is equivalent to: |
| 1316 | |
| 1317 | option feature off |
| 1318 | |
| 1319 | #define PNG_feature value |
| 1320 | |
| 1321 | is equivalent to: |
| 1322 | |
| 1323 | setting feature default value |
| 1324 | |
| 1325 | Notice that in both cases, pngusr.dfa and pngusr.h, the contents of the |
| 1326 | pngusr file you supply override the contents of scripts/pnglibconf.dfa |
| 1327 | |
| 1328 | If confusing or incomprehensible behavior results it is possible to |
| 1329 | examine the intermediate file pnglibconf.dfn to find the full set of |
| 1330 | dependency information for each setting and option. Simply locate the |
| 1331 | feature in the file and read the C comments that precede it. |
| 1332 | |
Glenn Randers-Pehrson | a5e5547 | 2011-07-12 10:13:32 -0500 | [diff] [blame] | 1333 | This method is also illustrated in the contrib/pngminim/* makefiles and |
| 1334 | pngusr.h. |
| 1335 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1336 | .SH III. Reading |
| 1337 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1338 | 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] | 1339 | in a PNG file sequentially, briefly explaining the syntax and purpose |
| 1340 | of each one. See example.c and png.h for more detail. While |
| 1341 | progressive reading is covered in the next section, you will still |
| 1342 | need some of the functions discussed in this section to read a PNG |
| 1343 | file. |
| 1344 | |
| 1345 | .SS Setup |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1346 | |
| 1347 | You will want to do the I/O initialization(*) before you get into libpng, |
| 1348 | so if it doesn't work, you don't have much to undo. Of course, you |
| 1349 | will also want to insure that you are, in fact, dealing with a PNG |
| 1350 | 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] | 1351 | To use it, pass in the first 1 to 8 bytes of the file to the function |
Glenn Randers-Pehrson | 6a9c2ce | 2009-03-27 19:30:10 -0500 | [diff] [blame] | 1352 | png_sig_cmp(), and it will return 0 (false) if the bytes match the |
| 1353 | corresponding bytes of the PNG signature, or nonzero (true) otherwise. |
| 1354 | Of course, the more bytes you pass in, the greater the accuracy of the |
| 1355 | prediction. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1356 | |
| 1357 | If you are intending to keep the file pointer open for use in libpng, |
| 1358 | you must ensure you don't read more than 8 bytes from the beginning |
| 1359 | of the file, and you also have to make a call to png_set_sig_bytes_read() |
| 1360 | with the number of bytes you read from the beginning. Libpng will |
| 1361 | then only check the bytes (if any) that your program didn't read. |
| 1362 | |
| 1363 | (*): If you are not using the standard I/O functions, you will need |
| 1364 | to replace them with custom functions. See the discussion under |
| 1365 | Customizing libpng. |
| 1366 | |
| 1367 | |
| 1368 | FILE *fp = fopen(file_name, "rb"); |
| 1369 | if (!fp) |
| 1370 | { |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 1371 | return (ERROR); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1372 | } |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 1373 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1374 | fread(header, 1, number, fp); |
Glenn Randers-Pehrson | c944229 | 1999-01-06 21:50:16 -0600 | [diff] [blame] | 1375 | is_png = !png_sig_cmp(header, 0, number); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 1376 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1377 | if (!is_png) |
| 1378 | { |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 1379 | return (NOT_PNG); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1380 | } |
| 1381 | |
| 1382 | |
| 1383 | Next, png_struct and png_info need to be allocated and initialized. In |
| 1384 | order to ensure that the size of these structures is correct even with a |
| 1385 | dynamically linked libpng, there are functions to initialize and |
| 1386 | allocate the structures. We also pass the library version, optional |
| 1387 | pointers to error handling functions, and a pointer to a data struct for |
| 1388 | use by the error functions, if necessary (the pointer and functions can |
| 1389 | be NULL if the default error handlers are to be used). See the section |
| 1390 | on Changes to Libpng below regarding the old initialization functions. |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 1391 | The structure allocation functions quietly return NULL if they fail to |
| 1392 | create the structure, so your application should check for that. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1393 | |
| 1394 | png_structp png_ptr = png_create_read_struct |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 1395 | (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1396 | user_error_fn, user_warning_fn); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 1397 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1398 | if (!png_ptr) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 1399 | return (ERROR); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1400 | |
| 1401 | png_infop info_ptr = png_create_info_struct(png_ptr); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 1402 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1403 | if (!info_ptr) |
| 1404 | { |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 1405 | png_destroy_read_struct(&png_ptr, |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1406 | (png_infopp)NULL, (png_infopp)NULL); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 1407 | return (ERROR); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1408 | } |
| 1409 | |
Glenn Randers-Pehrson | f7d1a17 | 1998-06-06 15:31:35 -0500 | [diff] [blame] | 1410 | If you want to use your own memory allocation routines, |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 1411 | use a libpng that was built with PNG_USER_MEM_SUPPORTED defined, and use |
Glenn Randers-Pehrson | f7d1a17 | 1998-06-06 15:31:35 -0500 | [diff] [blame] | 1412 | png_create_read_struct_2() instead of png_create_read_struct(): |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1413 | |
Glenn Randers-Pehrson | f7d1a17 | 1998-06-06 15:31:35 -0500 | [diff] [blame] | 1414 | png_structp png_ptr = png_create_read_struct_2 |
Glenn Randers-Pehrson | 20786be | 2011-04-20 22:20:40 -0500 | [diff] [blame] | 1415 | (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, |
Glenn Randers-Pehrson | f7d1a17 | 1998-06-06 15:31:35 -0500 | [diff] [blame] | 1416 | user_error_fn, user_warning_fn, (png_voidp) |
| 1417 | user_mem_ptr, user_malloc_fn, user_free_fn); |
| 1418 | |
| 1419 | The error handling routines passed to png_create_read_struct() |
| 1420 | and the memory alloc/free routines passed to png_create_struct_2() |
| 1421 | are only necessary if you are not using the libpng supplied error |
| 1422 | handling and memory alloc/free functions. |
| 1423 | |
| 1424 | When libpng encounters an error, it expects to longjmp back |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 1425 | 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] | 1426 | your png_jmpbuf(png_ptr). If you read the file from different |
John Bowler | e6dc85b | 2011-04-27 14:47:15 -0500 | [diff] [blame] | 1427 | routines, you will need to update the longjmp buffer every time you enter |
Glenn Randers-Pehrson | 520a764 | 2000-03-21 05:13:06 -0600 | [diff] [blame] | 1428 | a new routine that will call a png_*() function. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1429 | |
| 1430 | See your documentation of setjmp/longjmp for your compiler for more |
Glenn Randers-Pehrson | a77ef62 | 2000-02-18 13:48:52 -0600 | [diff] [blame] | 1431 | information on setjmp/longjmp. See the discussion on libpng error |
| 1432 | handling in the Customizing Libpng section below for more information |
| 1433 | 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] | 1434 | back to your setjmp, you will want to call png_destroy_read_struct() to |
| 1435 | free any memory. |
| 1436 | |
Glenn Randers-Pehrson | 520a764 | 2000-03-21 05:13:06 -0600 | [diff] [blame] | 1437 | if (setjmp(png_jmpbuf(png_ptr))) |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1438 | { |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 1439 | png_destroy_read_struct(&png_ptr, &info_ptr, |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1440 | &end_info); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 1441 | fclose(fp); |
| 1442 | return (ERROR); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1443 | } |
| 1444 | |
Glenn Randers-Pehrson | 20786be | 2011-04-20 22:20:40 -0500 | [diff] [blame] | 1445 | Pass (png_infopp)NULL instead of &end_info if you didn't create |
| 1446 | an end_info structure. |
| 1447 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1448 | If you would rather avoid the complexity of setjmp/longjmp issues, |
Glenn Randers-Pehrson | 54ac9a9 | 2010-04-02 17:06:22 -0500 | [diff] [blame] | 1449 | you can compile libpng with PNG_NO_SETJMP, in which case |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1450 | errors will result in a call to PNG_ABORT() which defaults to abort(). |
| 1451 | |
Glenn Randers-Pehrson | 54ac9a9 | 2010-04-02 17:06:22 -0500 | [diff] [blame] | 1452 | You can #define PNG_ABORT() to a function that does something |
| 1453 | more useful than abort(), as long as your function does not |
| 1454 | return. |
| 1455 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 1456 | Now you need to set up the input code. The default for libpng is to |
| 1457 | use the C function fread(). If you use this, you will need to pass a |
| 1458 | valid FILE * in the function png_init_io(). Be sure that the file is |
| 1459 | opened in binary mode. If you wish to handle reading data in another |
| 1460 | way, you need not call the png_init_io() function, but you must then |
| 1461 | implement the libpng I/O methods discussed in the Customizing Libpng |
| 1462 | section below. |
| 1463 | |
| 1464 | png_init_io(png_ptr, fp); |
| 1465 | |
| 1466 | If you had previously opened the file and read any of the signature from |
| 1467 | the beginning in order to see if this was a PNG file, you need to let |
| 1468 | libpng know that there are some bytes missing from the start of the file. |
| 1469 | |
| 1470 | png_set_sig_bytes(png_ptr, number); |
| 1471 | |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 1472 | You can change the zlib compression buffer size to be used while |
| 1473 | reading compressed data with |
| 1474 | |
| 1475 | png_set_compression_buffer_size(png_ptr, buffer_size); |
| 1476 | |
| 1477 | where the default size is 8192 bytes. Note that the buffer size |
| 1478 | is changed immediately and the buffer is reallocated immediately, |
| 1479 | instead of setting a flag to be acted upon later. |
| 1480 | |
Glenn Randers-Pehrson | 9dd1cdf | 2011-01-06 21:42:36 -0600 | [diff] [blame] | 1481 | If you want CRC errors to be handled in a different manner than |
| 1482 | the default, use |
| 1483 | |
| 1484 | png_set_crc_action(png_ptr, crit_action, ancil_action); |
| 1485 | |
| 1486 | The values for png_set_crc_action() say how libpng is to handle CRC errors in |
| 1487 | ancillary and critical chunks, and whether to use the data contained |
| 1488 | therein. Note that it is impossible to "discard" data in a critical |
| 1489 | chunk. |
| 1490 | |
| 1491 | Choices for (int) crit_action are |
| 1492 | PNG_CRC_DEFAULT 0 error/quit |
| 1493 | PNG_CRC_ERROR_QUIT 1 error/quit |
| 1494 | PNG_CRC_WARN_USE 3 warn/use data |
| 1495 | PNG_CRC_QUIET_USE 4 quiet/use data |
| 1496 | PNG_CRC_NO_CHANGE 5 use the current value |
| 1497 | |
| 1498 | Choices for (int) ancil_action are |
| 1499 | PNG_CRC_DEFAULT 0 error/quit |
| 1500 | PNG_CRC_ERROR_QUIT 1 error/quit |
| 1501 | PNG_CRC_WARN_DISCARD 2 warn/discard data |
| 1502 | PNG_CRC_WARN_USE 3 warn/use data |
| 1503 | PNG_CRC_QUIET_USE 4 quiet/use data |
| 1504 | PNG_CRC_NO_CHANGE 5 use the current value |
| 1505 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1506 | .SS Setting up callback code |
| 1507 | |
| 1508 | You can set up a callback function to handle any unknown chunks in the |
| 1509 | input stream. You must supply the function |
| 1510 | |
Glenn Randers-Pehrson | 81ce889 | 2011-01-24 08:04:37 -0600 | [diff] [blame] | 1511 | read_chunk_callback(png_structp png_ptr, |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1512 | png_unknown_chunkp chunk); |
| 1513 | { |
| 1514 | /* The unknown chunk structure contains your |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 1515 | chunk data, along with similar data for any other |
| 1516 | unknown chunks: */ |
| 1517 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1518 | png_byte name[5]; |
| 1519 | png_byte *data; |
| 1520 | png_size_t size; |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 1521 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 1522 | /* Note that libpng has already taken care of |
| 1523 | the CRC handling */ |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1524 | |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 1525 | /* put your code here. Search for your chunk in the |
| 1526 | unknown chunk structure, process it, and return one |
| 1527 | of the following: */ |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1528 | |
| 1529 | return (-n); /* chunk had an error */ |
| 1530 | return (0); /* did not recognize */ |
| 1531 | return (n); /* success */ |
| 1532 | } |
| 1533 | |
| 1534 | (You can give your function another name that you like instead of |
| 1535 | "read_chunk_callback") |
| 1536 | |
| 1537 | To inform libpng about your function, use |
| 1538 | |
| 1539 | png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr, |
| 1540 | read_chunk_callback); |
| 1541 | |
| 1542 | This names not only the callback function, but also a user pointer that |
| 1543 | you can retrieve with |
| 1544 | |
| 1545 | png_get_user_chunk_ptr(png_ptr); |
| 1546 | |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 1547 | If you call the png_set_read_user_chunk_fn() function, then all unknown |
| 1548 | chunks will be saved when read, in case your callback function will need |
| 1549 | one or more of them. This behavior can be changed with the |
| 1550 | png_set_keep_unknown_chunks() function, described below. |
| 1551 | |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 1552 | At this point, you can set up a callback function that will be |
| 1553 | called after each row has been read, which you can use to control |
| 1554 | a progress meter or the like. It's demonstrated in pngtest.c. |
| 1555 | You must supply a function |
| 1556 | |
Glenn Randers-Pehrson | 81ce889 | 2011-01-24 08:04:37 -0600 | [diff] [blame] | 1557 | void read_row_callback(png_structp png_ptr, |
| 1558 | png_uint_32 row, int pass); |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 1559 | { |
| 1560 | /* put your code here */ |
| 1561 | } |
| 1562 | |
| 1563 | (You can give it another name that you like instead of "read_row_callback") |
| 1564 | |
| 1565 | To inform libpng about your function, use |
| 1566 | |
| 1567 | png_set_read_status_fn(png_ptr, read_row_callback); |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 1568 | |
John Bowler | 59010e5 | 2011-02-16 06:16:31 -0600 | [diff] [blame] | 1569 | When this function is called the row has already been completely processed and |
| 1570 | the 'row' and 'pass' refer to the next row to be handled. For the |
| 1571 | non-interlaced case the row that was just handled is simply one less than the |
| 1572 | passed in row number, and pass will always be 0. For the interlaced case the |
| 1573 | same applies unless the row value is 0, in which case the row just handled was |
| 1574 | the last one from one of the preceding passes. Because interlacing may skip a |
| 1575 | pass you cannot be sure that the preceding pass is just 'pass-1', if you really |
| 1576 | need to know what the last pass is record (row,pass) from the callback and use |
| 1577 | the last recorded value each time. |
| 1578 | |
| 1579 | As with the user transform you can find the output row using the |
| 1580 | PNG_ROW_FROM_PASS_ROW macro. |
| 1581 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1582 | .SS Unknown-chunk handling |
| 1583 | |
| 1584 | Now you get to set the way the library processes unknown chunks in the |
| 1585 | input PNG stream. Both known and unknown chunks will be read. Normal |
| 1586 | behavior is that known chunks will be parsed into information in |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 1587 | various info_ptr members while unknown chunks will be discarded. This |
| 1588 | behavior can be wasteful if your application will never use some known |
| 1589 | chunk types. To change this, you can call: |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1590 | |
Glenn Randers-Pehrson | 272489d | 2004-08-04 06:34:52 -0500 | [diff] [blame] | 1591 | png_set_keep_unknown_chunks(png_ptr, keep, |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1592 | chunk_list, num_chunks); |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 1593 | keep - 0: default unknown chunk handling |
| 1594 | 1: ignore; do not keep |
Glenn Randers-Pehrson | d029a75 | 2004-08-09 21:50:32 -0500 | [diff] [blame] | 1595 | 2: keep only if safe-to-copy |
| 1596 | 3: keep even if unsafe-to-copy |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 1597 | |
Glenn Randers-Pehrson | d029a75 | 2004-08-09 21:50:32 -0500 | [diff] [blame] | 1598 | You can use these definitions: |
| 1599 | PNG_HANDLE_CHUNK_AS_DEFAULT 0 |
| 1600 | PNG_HANDLE_CHUNK_NEVER 1 |
| 1601 | PNG_HANDLE_CHUNK_IF_SAFE 2 |
| 1602 | PNG_HANDLE_CHUNK_ALWAYS 3 |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 1603 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1604 | chunk_list - list of chunks affected (a byte string, |
| 1605 | five bytes per chunk, NULL or '\0' if |
| 1606 | num_chunks is 0) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 1607 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1608 | num_chunks - number of chunks affected; if 0, all |
Glenn Randers-Pehrson | dff799e | 2004-08-07 21:42:49 -0500 | [diff] [blame] | 1609 | unknown chunks are affected. If nonzero, |
| 1610 | only the chunks in the list are affected |
| 1611 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1612 | Unknown chunks declared in this way will be saved as raw data onto a |
| 1613 | list of png_unknown_chunk structures. If a chunk that is normally |
| 1614 | known to libpng is named in the list, it will be handled as unknown, |
| 1615 | according to the "keep" directive. If a chunk is named in successive |
| 1616 | instances of png_set_keep_unknown_chunks(), the final instance will |
Glenn Randers-Pehrson | d029a75 | 2004-08-09 21:50:32 -0500 | [diff] [blame] | 1617 | take precedence. The IHDR and IEND chunks should not be named in |
| 1618 | chunk_list; if they are, libpng will process them normally anyway. |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 1619 | If you know that your application will never make use of some particular |
| 1620 | chunks, use PNG_HANDLE_CHUNK_NEVER (or 1) as demonstrated below. |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1621 | |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 1622 | Here is an example of the usage of png_set_keep_unknown_chunks(), |
| 1623 | where the private "vpAg" chunk will later be processed by a user chunk |
| 1624 | callback function: |
| 1625 | |
| 1626 | png_byte vpAg[5]={118, 112, 65, 103, (png_byte) '\0'}; |
| 1627 | |
| 1628 | #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) |
| 1629 | png_byte unused_chunks[]= |
| 1630 | { |
| 1631 | 104, 73, 83, 84, (png_byte) '\0', /* hIST */ |
| 1632 | 105, 84, 88, 116, (png_byte) '\0', /* iTXt */ |
| 1633 | 112, 67, 65, 76, (png_byte) '\0', /* pCAL */ |
| 1634 | 115, 67, 65, 76, (png_byte) '\0', /* sCAL */ |
| 1635 | 115, 80, 76, 84, (png_byte) '\0', /* sPLT */ |
| 1636 | 116, 73, 77, 69, (png_byte) '\0', /* tIME */ |
| 1637 | }; |
| 1638 | #endif |
| 1639 | |
| 1640 | ... |
| 1641 | |
| 1642 | #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) |
| 1643 | /* ignore all unknown chunks: */ |
| 1644 | png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 1645 | |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 1646 | /* except for vpAg: */ |
| 1647 | png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 1648 | |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 1649 | /* also ignore unused known chunks: */ |
| 1650 | png_set_keep_unknown_chunks(read_ptr, 1, unused_chunks, |
| 1651 | (int)sizeof(unused_chunks)/5); |
| 1652 | #endif |
| 1653 | |
Glenn Randers-Pehrson | 800d1e9 | 2008-08-20 17:25:21 -0500 | [diff] [blame] | 1654 | .SS User limits |
| 1655 | |
| 1656 | The PNG specification allows the width and height of an image to be as |
| 1657 | large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns. |
| 1658 | Since very few applications really need to process such large images, |
| 1659 | we have imposed an arbitrary 1-million limit on rows and columns. |
| 1660 | Larger images will be rejected immediately with a png_error() call. If |
Glenn Randers-Pehrson | 0cb906d | 2011-06-11 14:22:22 -0500 | [diff] [blame] | 1661 | you wish to change this limit, you can use |
Glenn Randers-Pehrson | 800d1e9 | 2008-08-20 17:25:21 -0500 | [diff] [blame] | 1662 | |
| 1663 | png_set_user_limits(png_ptr, width_max, height_max); |
| 1664 | |
| 1665 | to set your own limits, or use width_max = height_max = 0x7fffffffL |
| 1666 | to allow all valid dimensions (libpng may reject some very large images |
| 1667 | anyway because of potential buffer overflow conditions). |
| 1668 | |
| 1669 | You should put this statement after you create the PNG structure and |
| 1670 | before calling png_read_info(), png_read_png(), or png_process_data(). |
Glenn Randers-Pehrson | cc27708 | 2011-06-10 21:17:34 -0500 | [diff] [blame] | 1671 | |
| 1672 | When writing a PNG datastream, put this statement before calling |
| 1673 | png_write_info() or png_write_png(). |
| 1674 | |
Glenn Randers-Pehrson | 800d1e9 | 2008-08-20 17:25:21 -0500 | [diff] [blame] | 1675 | If you need to retrieve the limits that are being applied, use |
| 1676 | |
| 1677 | width_max = png_get_user_width_max(png_ptr); |
| 1678 | height_max = png_get_user_height_max(png_ptr); |
| 1679 | |
| 1680 | The PNG specification sets no limit on the number of ancillary chunks |
| 1681 | allowed in a PNG datastream. You can impose a limit on the total number |
| 1682 | of sPLT, tEXt, iTXt, zTXt, and unknown chunks that will be stored, with |
| 1683 | |
| 1684 | png_set_chunk_cache_max(png_ptr, user_chunk_cache_max); |
| 1685 | |
| 1686 | where 0x7fffffffL means unlimited. You can retrieve this limit with |
| 1687 | |
| 1688 | chunk_cache_max = png_get_chunk_cache_max(png_ptr); |
| 1689 | |
Glenn Randers-Pehrson | 8f5846f | 2009-10-31 21:31:08 -0500 | [diff] [blame] | 1690 | This limit also applies to the number of buffers that can be allocated |
| 1691 | by png_decompress_chunk() while decompressing iTXt, zTXt, and iCCP chunks. |
| 1692 | |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 1693 | You can also set a limit on the amount of memory that a compressed chunk |
| 1694 | other than IDAT can occupy, with |
| 1695 | |
| 1696 | png_set_chunk_malloc_max(png_ptr, user_chunk_malloc_max); |
| 1697 | |
| 1698 | and you can retrieve the limit with |
| 1699 | |
| 1700 | chunk_malloc_max = png_get_chunk_malloc_max(png_ptr); |
| 1701 | |
| 1702 | Any chunks that would cause either of these limits to be exceeded will |
| 1703 | be ignored. |
| 1704 | |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1705 | .SS Information about your system |
| 1706 | |
| 1707 | If you intend to display the PNG or to incorporate it in other image data you |
| 1708 | need to tell libpng information about your display or drawing surface so that |
| 1709 | libpng can convert the values in the image to match the display. |
| 1710 | |
Glenn Randers-Pehrson | 733b131 | 2011-06-15 13:21:01 -0500 | [diff] [blame] | 1711 | From libpng-1.5.4 this information can be set before reading the PNG file |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1712 | header. In earlier versions png_set_gamma() existed but behaved incorrectly if |
| 1713 | called before the PNG file header had been read and png_set_alpha_mode() did not |
| 1714 | exist. |
| 1715 | |
Glenn Randers-Pehrson | 733b131 | 2011-06-15 13:21:01 -0500 | [diff] [blame] | 1716 | If you need to support versions prior to libpng-1.5.4 test the version number |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 1717 | as illustrated below using "PNG_LIBPNG_VER >= 10504" and follow the procedures |
| 1718 | described in the appropriate manual page. |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1719 | |
| 1720 | You give libpng the encoding expected by your system expressed as a 'gamma' |
| 1721 | value. You can also specify a default encoding for the PNG file in |
| 1722 | case the required information is missing from the file. By default libpng |
| 1723 | assumes that the PNG data matches your system, to keep this default call: |
| 1724 | |
| 1725 | png_set_gamma(png_ptr, screen_gamma, 1/screen_gamma/*file gamma*/); |
| 1726 | |
| 1727 | or you can use the fixed point equivalent: |
| 1728 | |
| 1729 | png_set_gamma_fixed(png_ptr, PNG_FP_1*screen_gamma, PNG_FP_1/screen_gamma); |
| 1730 | |
Glenn Randers-Pehrson | 95ba417 | 2011-09-08 12:21:42 -0500 | [diff] [blame] | 1731 | If you don't know the gamma for your system it is probably 2.2 - a good |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1732 | approximation to the IEC standard for display systems (sRGB). If images are |
| 1733 | too contrasty or washed out you got the value wrong - check your system |
| 1734 | documentation! |
| 1735 | |
| 1736 | Many systems permit the system gamma to be changed via a lookup table in the |
| 1737 | display driver, a few systems, including older Macs, change the response by |
Glenn Randers-Pehrson | 733b131 | 2011-06-15 13:21:01 -0500 | [diff] [blame] | 1738 | default. As of 1.5.4 three special values are available to handle common |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1739 | situations: |
| 1740 | |
| 1741 | PNG_DEFAULT_sRGB: Indicates that the system conforms to the IEC 61966-2-1 |
| 1742 | standard. This matches almost all systems. |
| 1743 | PNG_GAMMA_MAC_18: Indicates that the system is an older (pre Mac OS 10.6) |
| 1744 | Apple Macintosh system with the default settings. |
| 1745 | PNG_GAMMA_LINEAR: Just the fixed point value for 1.0 - indicates that the |
| 1746 | system expects data with no gamma encoding. |
| 1747 | |
| 1748 | You would use the linear (unencoded) value if you need to process the pixel |
| 1749 | values further because this avoids the need to decode and reencode each |
| 1750 | component value whenever arithmetic is performed. A lot of graphics software |
| 1751 | uses linear values for this reason, often with higher precision component values |
| 1752 | to preserve overall accuracy. |
| 1753 | |
| 1754 | The second thing you may need to tell libpng about is how your system handles |
| 1755 | alpha channel information. Some, but not all, PNG files contain an alpha |
| 1756 | channel. To display these files correctly you need to compose the data onto a |
| 1757 | suitable background, as described in the PNG specification. |
| 1758 | |
| 1759 | Libpng only supports composing onto a single color (using png_set_background; |
Glenn Randers-Pehrson | 95ba417 | 2011-09-08 12:21:42 -0500 | [diff] [blame] | 1760 | see below). Otherwise you must do the composition yourself and, in this case, |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1761 | you may need to call png_set_alpha_mode: |
| 1762 | |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 1763 | #if PNG_LIBPNG_VER >= 10504 |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1764 | png_set_alpha_mode(png_ptr, mode, screen_gamma); |
Glenn Randers-Pehrson | 95ba417 | 2011-09-08 12:21:42 -0500 | [diff] [blame] | 1765 | #else |
| 1766 | png_set_gamma(png_ptr, screen_gamma, 1.0/screen_gamma); |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 1767 | #endif |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1768 | |
Glenn Randers-Pehrson | 95ba417 | 2011-09-08 12:21:42 -0500 | [diff] [blame] | 1769 | The screen_gamma value is the same as the argument to png_set_gamma; however, |
| 1770 | how it affects the output depends on the mode. png_set_alpha_mode() sets the |
| 1771 | file gamma default to 1/screen_gamma, so normally you don't need to call |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1772 | png_set_gamma. If you need different defaults call png_set_gamma() before |
| 1773 | png_set_alpha_mode() - if you call it after it will override the settings made |
| 1774 | by png_set_alpha_mode(). |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1775 | |
| 1776 | The mode is as follows: |
| 1777 | |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1778 | PNG_ALPHA_PNG: The data is encoded according to the PNG specification. Red, |
| 1779 | green and blue, or gray, components are gamma encoded color |
| 1780 | values and are not premultiplied by the alpha value. The |
| 1781 | alpha value is a linear measure of the contribution of the |
| 1782 | pixel to the corresponding final output pixel. |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1783 | |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1784 | You should normally use this format if you intend to perform |
| 1785 | color correction on the color values; most, maybe all, color |
| 1786 | correction software has no handling for the alpha channel and, |
| 1787 | anyway, the math to handle pre-multiplied component values is |
| 1788 | unnecessarily complex. |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1789 | |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1790 | Before you do any arithmetic on the component values you need |
| 1791 | to remove the gamma encoding and multiply out the alpha |
| 1792 | channel. See the PNG specification for more detail. It is |
| 1793 | important to note that when an image with an alpha channel is |
| 1794 | scaled, linear encoded, pre-multiplied component values must |
| 1795 | be used! |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1796 | |
| 1797 | The remaining modes assume you don't need to do any further color correction or |
Glenn Randers-Pehrson | 95ba417 | 2011-09-08 12:21:42 -0500 | [diff] [blame] | 1798 | that if you do, your color correction software knows all about alpha (it |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1799 | probably doesn't!) |
| 1800 | |
Glenn Randers-Pehrson | 95ba417 | 2011-09-08 12:21:42 -0500 | [diff] [blame] | 1801 | PNG_ALPHA_STANDARD: The data libpng produces |
| 1802 | is encoded in the standard way |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1803 | assumed by most correctly written graphics software. |
| 1804 | The gamma encoding will be removed by libpng and the |
| 1805 | linear component values will be pre-multiplied by the |
| 1806 | alpha channel. |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1807 | |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1808 | With this format the final image must be re-encoded to |
| 1809 | match the display gamma before the image is displayed. |
| 1810 | If your system doesn't do that, yet still seems to |
| 1811 | perform arithmetic on the pixels without decoding them, |
| 1812 | it is broken - check out the modes below. |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1813 | |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1814 | With PNG_ALPHA_STANDARD libpng always produces linear |
| 1815 | component values, whatever screen_gamma you supply. The |
| 1816 | screen_gamma value is, however, used as a default for |
| 1817 | the file gamma if the PNG file has no gamma information. |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1818 | |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1819 | If you call png_set_gamma() after png_set_alpha_mode() you |
| 1820 | will override the linear encoding. Instead the |
| 1821 | pre-multiplied pixel values will be gamma encoded but |
| 1822 | the alpha channel will still be linear. This may |
| 1823 | actually match the requirements of some broken software, |
| 1824 | but it is unlikely. |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1825 | |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1826 | While linear 8-bit data is often used it has |
| 1827 | insufficient precision for any image with a reasonable |
| 1828 | dynamic range. To avoid problems, and if your software |
| 1829 | supports it, use png_set_expand_16() to force all |
| 1830 | components to 16 bits. |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1831 | |
Glenn Randers-Pehrson | 95ba417 | 2011-09-08 12:21:42 -0500 | [diff] [blame] | 1832 | PNG_ALPHA_OPTIMIZED: This mode is the same |
| 1833 | as PNG_ALPHA_STANDARD except that |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1834 | completely opaque pixels are gamma encoded according to |
| 1835 | the screen_gamma value. Pixels with alpha less than 1.0 |
| 1836 | will still have linear components. |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1837 | |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1838 | Use this format if you have control over your |
| 1839 | compositing software and do don't do other arithmetic |
| 1840 | (such as scaling) on the data you get from libpng. Your |
| 1841 | compositing software can simply copy opaque pixels to |
| 1842 | the output but still has linear values for the |
| 1843 | non-opaque pixels. |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1844 | |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1845 | In normal compositing, where the alpha channel encodes |
| 1846 | partial pixel coverage (as opposed to broad area |
| 1847 | translucency), the inaccuracies of the 8-bit |
| 1848 | representation of non-opaque pixels are irrelevant. |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1849 | |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1850 | You can also try this format if your software is broken; |
| 1851 | it might look better. |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1852 | |
Glenn Randers-Pehrson | 95ba417 | 2011-09-08 12:21:42 -0500 | [diff] [blame] | 1853 | PNG_ALPHA_BROKEN: This is PNG_ALPHA_STANDARD; |
| 1854 | however, all component values, |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1855 | including the alpha channel are gamma encoded. This is |
| 1856 | an appropriate format to try if your software, or more |
Glenn Randers-Pehrson | 95ba417 | 2011-09-08 12:21:42 -0500 | [diff] [blame] | 1857 | likely hardware, is totally broken, i.e., if it performs |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1858 | linear arithmetic directly on gamma encoded values. |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1859 | |
| 1860 | In most cases of broken software or hardware the bug in the final display |
| 1861 | manifests as a subtle halo around composited parts of the image. You may not |
| 1862 | even perceive this as a halo; the composited part of the image may simply appear |
| 1863 | separate from the background, as though it had been cut out of paper and pasted |
| 1864 | on afterward. |
| 1865 | |
| 1866 | If you don't have to deal with bugs in software or hardware, or if you can fix |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1867 | them, there are three recommended ways of using png_set_alpha_mode(): |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1868 | |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1869 | png_set_alpha_mode(png_ptr, PNG_ALPHA_PNG, |
| 1870 | screen_gamma); |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1871 | |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1872 | You can do color correction on the result (libpng does not currently |
Glenn Randers-Pehrson | 95ba417 | 2011-09-08 12:21:42 -0500 | [diff] [blame] | 1873 | support color correction internally). When you handle the alpha channel |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1874 | you need to undo the gamma encoding and multiply out the alpha. |
| 1875 | |
| 1876 | png_set_alpha_mode(png_ptr, PNG_ALPHA_STANDARD, |
| 1877 | screen_gamma); |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1878 | png_set_expand_16(png_ptr); |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1879 | |
Glenn Randers-Pehrson | 95ba417 | 2011-09-08 12:21:42 -0500 | [diff] [blame] | 1880 | If you are using the high level interface, don't call png_set_expand_16(); |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1881 | instead pass PNG_TRANSFORM_EXPAND_16 to the interface. |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1882 | |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1883 | With this mode you can't do color correction, but you can do arithmetic, |
| 1884 | including composition and scaling, on the data without further processing. |
| 1885 | |
| 1886 | png_set_alpha_mode(png_ptr, PNG_ALPHA_OPTIMIZED, |
| 1887 | screen_gamma); |
| 1888 | |
| 1889 | You can avoid the expansion to 16-bit components with this mode, but you |
| 1890 | lose the ability to scale the image or perform other linear arithmetic. |
| 1891 | All you can do is compose the result onto a matching output. Since this |
Glenn Randers-Pehrson | 95ba417 | 2011-09-08 12:21:42 -0500 | [diff] [blame] | 1892 | mode is libpng-specific you also need to write your own composition |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1893 | software. |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1894 | |
| 1895 | If you don't need, or can't handle, the alpha channel you can call |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1896 | png_set_background() to remove it by compositing against a fixed color. Don't |
| 1897 | call png_set_strip_alpha() to do this - it will leave spurious pixel values in |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1898 | transparent parts of this image. |
| 1899 | |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 1900 | png_set_background(png_ptr, &background_color, |
| 1901 | PNG_BACKGROUND_GAMMA_SCREEN, 0, 1); |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1902 | |
| 1903 | The background_color is an RGB or grayscale value according to the data format |
| 1904 | libpng will produce for you. Because you don't yet know the format of the PNG |
Glenn Randers-Pehrson | 95ba417 | 2011-09-08 12:21:42 -0500 | [diff] [blame] | 1905 | file, if you call png_set_background at this point you must arrange for the |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1906 | format produced by libpng to always have 8-bit or 16-bit components and then |
| 1907 | store the color as an 8-bit or 16-bit color as appropriate. The color contains |
| 1908 | separate gray and RGB component values, so you can let libpng produce gray or |
| 1909 | RGB output according to the input format, but low bit depth grayscale images |
Glenn Randers-Pehrson | ab38979 | 2011-07-09 19:35:22 -0500 | [diff] [blame] | 1910 | must always be converted to at least 8-bit format. (Even though low bit depth |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1911 | grayscale images can't have an alpha channel they can have a transparent |
| 1912 | color!) |
| 1913 | |
| 1914 | You set the transforms you need later, either as flags to the high level |
| 1915 | interface or libpng API calls for the low level interface. For reference the |
Glenn Randers-Pehrson | 733b131 | 2011-06-15 13:21:01 -0500 | [diff] [blame] | 1916 | settings and API calls required are: |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1917 | |
| 1918 | 8-bit values: |
Glenn Randers-Pehrson | fb29e51 | 2011-06-17 20:38:24 -0500 | [diff] [blame] | 1919 | PNG_TRANSFORM_SCALE_16 | PNG_EXPAND |
| 1920 | png_set_expand(png_ptr); png_set_scale_16(png_ptr); |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1921 | |
Glenn Randers-Pehrson | 733b131 | 2011-06-15 13:21:01 -0500 | [diff] [blame] | 1922 | If you must get exactly the same inaccurate results |
| 1923 | produced by default in versions prior to libpng-1.5.4, |
Glenn Randers-Pehrson | fb29e51 | 2011-06-17 20:38:24 -0500 | [diff] [blame] | 1924 | use PNG_TRANSFORM_STRIP_16 and png_set_strip_16(png_ptr) |
Glenn Randers-Pehrson | 733b131 | 2011-06-15 13:21:01 -0500 | [diff] [blame] | 1925 | instead. |
| 1926 | |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1927 | 16-bit values: |
| 1928 | PNG_TRANSFORM_EXPAND_16 |
| 1929 | png_set_expand_16(png_ptr); |
| 1930 | |
| 1931 | In either case palette image data will be expanded to RGB. If you just want |
| 1932 | color data you can add PNG_TRANSFORM_GRAY_TO_RGB or png_set_gray_to_rgb(png_ptr) |
| 1933 | to the list. |
| 1934 | |
| 1935 | Calling png_set_background before the PNG file header is read will not work |
Glenn Randers-Pehrson | 733b131 | 2011-06-15 13:21:01 -0500 | [diff] [blame] | 1936 | prior to libpng-1.5.4. Because the failure may result in unexpected warnings or |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1937 | errors it is therefore much safer to call png_set_background after the head has |
Glenn Randers-Pehrson | 733b131 | 2011-06-15 13:21:01 -0500 | [diff] [blame] | 1938 | been read. Unfortunately this means that prior to libpng-1.5.4 it cannot be |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 1939 | used with the high level interface. |
| 1940 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1941 | .SS The high-level read interface |
| 1942 | |
| 1943 | At this point there are two ways to proceed; through the high-level |
| 1944 | read interface, or through a sequence of low-level read operations. |
| 1945 | You can use the high-level interface if (a) you are willing to read |
| 1946 | the entire image into memory, and (b) the input transformations |
| 1947 | you want to do are limited to the following set: |
| 1948 | |
| 1949 | PNG_TRANSFORM_IDENTITY No transformation |
Glenn Randers-Pehrson | fb29e51 | 2011-06-17 20:38:24 -0500 | [diff] [blame] | 1950 | PNG_TRANSFORM_SCALE_16 Strip 16-bit samples to |
| 1951 | 8-bit accurately |
| 1952 | PNG_TRANSFORM_STRIP_16 Chop 16-bit samples to |
| 1953 | 8-bit less accurately |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1954 | PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 1955 | PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit |
| 1956 | samples to bytes |
| 1957 | PNG_TRANSFORM_PACKSWAP Change order of packed |
| 1958 | pixels to LSB first |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1959 | PNG_TRANSFORM_EXPAND Perform set_expand() |
| 1960 | PNG_TRANSFORM_INVERT_MONO Invert monochrome images |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 1961 | PNG_TRANSFORM_SHIFT Normalize pixels to the |
| 1962 | sBIT depth |
| 1963 | PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA |
| 1964 | to BGRA |
| 1965 | PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA |
| 1966 | to AG |
| 1967 | PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity |
| 1968 | to transparency |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1969 | PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples |
Glenn Randers-Pehrson | 99708d5 | 2009-06-29 17:30:00 -0500 | [diff] [blame] | 1970 | PNG_TRANSFORM_GRAY_TO_RGB Expand grayscale samples |
| 1971 | to RGB (or GA to RGBA) |
John Bowler | a9b3419 | 2011-05-08 19:46:51 -0500 | [diff] [blame] | 1972 | PNG_TRANSFORM_EXPAND_16 Expand samples to 16 bits |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1973 | |
| 1974 | (This excludes setting a background color, doing gamma transformation, |
Glenn Randers-Pehrson | 3cd7cff | 2010-04-16 19:27:08 -0500 | [diff] [blame] | 1975 | quantizing, and setting filler.) If this is the case, simply do this: |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1976 | |
| 1977 | png_read_png(png_ptr, info_ptr, png_transforms, NULL) |
| 1978 | |
Glenn Randers-Pehrson | f210a05 | 2009-11-12 10:02:24 -0600 | [diff] [blame] | 1979 | where png_transforms is an integer containing the bitwise OR of some |
| 1980 | 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] | 1981 | followed the set of transformations indicated by the transform mask, |
Glenn Randers-Pehrson | 6942d53 | 2000-05-01 09:31:54 -0500 | [diff] [blame] | 1982 | then png_read_image(), and finally png_read_end(). |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 1983 | |
Glenn Randers-Pehrson | 6942d53 | 2000-05-01 09:31:54 -0500 | [diff] [blame] | 1984 | (The final parameter of this call is not yet used. Someday it might point |
| 1985 | to transformation parameters required by some future input transform.) |
| 1986 | |
Glenn Randers-Pehrson | a4981d4 | 2004-08-25 22:00:45 -0500 | [diff] [blame] | 1987 | You must use png_transforms and not call any png_set_transform() functions |
| 1988 | when you use png_read_png(). |
| 1989 | |
Glenn Randers-Pehrson | 6942d53 | 2000-05-01 09:31:54 -0500 | [diff] [blame] | 1990 | After you have called png_read_png(), you can retrieve the image data |
| 1991 | with |
| 1992 | |
| 1993 | row_pointers = png_get_rows(png_ptr, info_ptr); |
| 1994 | |
| 1995 | where row_pointers is an array of pointers to the pixel data for each row: |
| 1996 | |
| 1997 | png_bytep row_pointers[height]; |
| 1998 | |
| 1999 | If you know your image size and pixel size ahead of time, you can allocate |
| 2000 | row_pointers prior to calling png_read_png() with |
| 2001 | |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 2002 | if (height > PNG_UINT_32_MAX/png_sizeof(png_byte)) |
Glenn Randers-Pehrson | 5fea36f | 2004-07-28 08:20:44 -0500 | [diff] [blame] | 2003 | png_error (png_ptr, |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2004 | "Image is too tall to process in memory"); |
| 2005 | |
Glenn Randers-Pehrson | 5fea36f | 2004-07-28 08:20:44 -0500 | [diff] [blame] | 2006 | if (width > PNG_UINT_32_MAX/pixel_size) |
| 2007 | png_error (png_ptr, |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2008 | "Image is too wide to process in memory"); |
| 2009 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2010 | row_pointers = png_malloc(png_ptr, |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2011 | height*png_sizeof(png_bytep)); |
| 2012 | |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 2013 | for (int i=0; i<height, i++) |
| 2014 | row_pointers[i]=NULL; /* security precaution */ |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2015 | |
Glenn Randers-Pehrson | 6942d53 | 2000-05-01 09:31:54 -0500 | [diff] [blame] | 2016 | for (int i=0; i<height, i++) |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2017 | row_pointers[i]=png_malloc(png_ptr, |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2018 | width*pixel_size); |
| 2019 | |
Glenn Randers-Pehrson | d56aca7 | 2000-11-23 11:51:42 -0600 | [diff] [blame] | 2020 | png_set_rows(png_ptr, info_ptr, &row_pointers); |
Glenn Randers-Pehrson | 6942d53 | 2000-05-01 09:31:54 -0500 | [diff] [blame] | 2021 | |
| 2022 | Alternatively you could allocate your image in one big block and define |
| 2023 | row_pointers[i] to point into the proper places in your block. |
| 2024 | |
| 2025 | If you use png_set_rows(), the application is responsible for freeing |
| 2026 | row_pointers (and row_pointers[i], if they were separately allocated). |
| 2027 | |
| 2028 | If you don't allocate row_pointers ahead of time, png_read_png() will |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2029 | do it, and it'll be free'ed by libpng when you call png_destroy_*(). |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 2030 | |
| 2031 | .SS The low-level read interface |
| 2032 | |
| 2033 | If you are going the low-level route, you are now ready to read all |
| 2034 | the file information up to the actual image data. You do this with a |
| 2035 | call to png_read_info(). |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2036 | |
| 2037 | png_read_info(png_ptr, info_ptr); |
| 2038 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 2039 | 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] | 2040 | |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2041 | This also copies some of the data from the PNG file into the decode structure |
| 2042 | for use in later transformations. Important information copied in is: |
| 2043 | |
| 2044 | 1) The PNG file gamma from the gAMA chunk. This overwrites the default value |
| 2045 | provided by an earlier call to png_set_gamma or png_set_alpha_mode. |
| 2046 | |
Glenn Randers-Pehrson | 733b131 | 2011-06-15 13:21:01 -0500 | [diff] [blame] | 2047 | 2) Prior to libpng-1.5.4 the background color from a bKGd chunk. This |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2048 | damages the information provided by an earlier call to png_set_background |
Glenn Randers-Pehrson | ab38979 | 2011-07-09 19:35:22 -0500 | [diff] [blame] | 2049 | resulting in unexpected behavior. Libpng-1.5.4 no longer does this. |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2050 | |
| 2051 | 3) The number of significant bits in each component value. Libpng uses this to |
| 2052 | optimize gamma handling by reducing the internal lookup table sizes. |
| 2053 | |
| 2054 | 4) The transparent color information from a tRNS chunk. This can be modified by |
| 2055 | a later call to png_set_tRNS. |
| 2056 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 2057 | .SS Querying the info structure |
| 2058 | |
| 2059 | Functions are used to get the information from the info_ptr once it |
| 2060 | has been read. Note that these fields may not be completely filled |
| 2061 | 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] | 2062 | |
| 2063 | png_get_IHDR(png_ptr, info_ptr, &width, &height, |
| 2064 | &bit_depth, &color_type, &interlace_type, |
Glenn Randers-Pehrson | 408b421 | 2000-12-18 09:33:57 -0600 | [diff] [blame] | 2065 | &compression_type, &filter_method); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2066 | |
| 2067 | width - holds the width of the image |
| 2068 | in pixels (up to 2^31). |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2069 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2070 | height - holds the height of the image |
| 2071 | in pixels (up to 2^31). |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2072 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2073 | bit_depth - holds the bit depth of one of the |
| 2074 | image channels. (valid values are |
| 2075 | 1, 2, 4, 8, 16 and depend also on |
| 2076 | the color_type. See also |
| 2077 | significant bits (sBIT) below). |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2078 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2079 | color_type - describes which color/alpha channels |
| 2080 | are present. |
| 2081 | PNG_COLOR_TYPE_GRAY |
| 2082 | (bit depths 1, 2, 4, 8, 16) |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 2083 | PNG_COLOR_TYPE_GRAY_ALPHA |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2084 | (bit depths 8, 16) |
| 2085 | PNG_COLOR_TYPE_PALETTE |
| 2086 | (bit depths 1, 2, 4, 8) |
| 2087 | PNG_COLOR_TYPE_RGB |
| 2088 | (bit_depths 8, 16) |
| 2089 | PNG_COLOR_TYPE_RGB_ALPHA |
| 2090 | (bit_depths 8, 16) |
| 2091 | |
| 2092 | PNG_COLOR_MASK_PALETTE |
| 2093 | PNG_COLOR_MASK_COLOR |
| 2094 | PNG_COLOR_MASK_ALPHA |
| 2095 | |
Glenn Randers-Pehrson | 2cb633b | 2011-01-21 08:31:29 -0600 | [diff] [blame] | 2096 | interlace_type - (PNG_INTERLACE_NONE or |
| 2097 | PNG_INTERLACE_ADAM7) |
| 2098 | |
| 2099 | compression_type - (must be PNG_COMPRESSION_TYPE_BASE |
| 2100 | for PNG 1.0) |
| 2101 | |
Glenn Randers-Pehrson | 408b421 | 2000-12-18 09:33:57 -0600 | [diff] [blame] | 2102 | filter_method - (must be PNG_FILTER_TYPE_BASE |
| 2103 | for PNG 1.0, and can also be |
| 2104 | PNG_INTRAPIXEL_DIFFERENCING if |
| 2105 | the PNG datastream is embedded in |
| 2106 | a MNG-1.0 datastream) |
Glenn Randers-Pehrson | 0bfb58f | 2009-09-30 23:07:22 -0500 | [diff] [blame] | 2107 | |
| 2108 | Any or all of interlace_type, compression_type, or |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2109 | filter_method can be NULL if you are |
| 2110 | not interested in their values. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2111 | |
Glenn Randers-Pehrson | 0bfb58f | 2009-09-30 23:07:22 -0500 | [diff] [blame] | 2112 | Note that png_get_IHDR() returns 32-bit data into |
| 2113 | the application's width and height variables. |
| 2114 | This is an unsafe situation if these are 16-bit |
| 2115 | variables. In such situations, the |
| 2116 | png_get_image_width() and png_get_image_height() |
| 2117 | functions described below are safer. |
| 2118 | |
| 2119 | width = png_get_image_width(png_ptr, |
| 2120 | info_ptr); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2121 | |
Glenn Randers-Pehrson | 0bfb58f | 2009-09-30 23:07:22 -0500 | [diff] [blame] | 2122 | height = png_get_image_height(png_ptr, |
| 2123 | info_ptr); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2124 | |
Glenn Randers-Pehrson | 0bfb58f | 2009-09-30 23:07:22 -0500 | [diff] [blame] | 2125 | bit_depth = png_get_bit_depth(png_ptr, |
| 2126 | info_ptr); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2127 | |
Glenn Randers-Pehrson | 0bfb58f | 2009-09-30 23:07:22 -0500 | [diff] [blame] | 2128 | color_type = png_get_color_type(png_ptr, |
| 2129 | info_ptr); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2130 | |
Glenn Randers-Pehrson | 2cb633b | 2011-01-21 08:31:29 -0600 | [diff] [blame] | 2131 | interlace_type = png_get_interlace_type(png_ptr, |
Glenn Randers-Pehrson | 0bfb58f | 2009-09-30 23:07:22 -0500 | [diff] [blame] | 2132 | info_ptr); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2133 | |
Glenn Randers-Pehrson | 0bfb58f | 2009-09-30 23:07:22 -0500 | [diff] [blame] | 2134 | compression_type = png_get_compression_type(png_ptr, |
| 2135 | info_ptr); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2136 | |
Glenn Randers-Pehrson | 2cb633b | 2011-01-21 08:31:29 -0600 | [diff] [blame] | 2137 | filter_method = png_get_filter_type(png_ptr, |
Glenn Randers-Pehrson | 0bfb58f | 2009-09-30 23:07:22 -0500 | [diff] [blame] | 2138 | info_ptr); |
| 2139 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2140 | channels = png_get_channels(png_ptr, info_ptr); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2141 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2142 | channels - number of channels of info for the |
| 2143 | color type (valid values are 1 (GRAY, |
| 2144 | PALETTE), 2 (GRAY_ALPHA), 3 (RGB), |
| 2145 | 4 (RGB_ALPHA or RGB + filler byte)) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2146 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2147 | rowbytes = png_get_rowbytes(png_ptr, info_ptr); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2148 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2149 | rowbytes - number of bytes needed to hold a row |
| 2150 | |
| 2151 | signature = png_get_signature(png_ptr, info_ptr); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2152 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2153 | signature - holds the signature read from the |
| 2154 | file (if any). The data is kept in |
| 2155 | the same offset it would be if the |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 2156 | whole signature were read (i.e. if an |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2157 | application had already read in 4 |
| 2158 | bytes of signature before starting |
| 2159 | libpng, the remaining 4 bytes would |
| 2160 | be in signature[4] through signature[7] |
| 2161 | (see png_set_sig_bytes())). |
| 2162 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2163 | These are also important, but their validity depends on whether the chunk |
| 2164 | has been read. The png_get_valid(png_ptr, info_ptr, PNG_INFO_<chunk>) and |
| 2165 | png_get_<chunk>(png_ptr, info_ptr, ...) functions return non-zero if the |
| 2166 | data has been read, or zero if it is missing. The parameters to the |
Glenn Randers-Pehrson | f210a05 | 2009-11-12 10:02:24 -0600 | [diff] [blame] | 2167 | png_get_<chunk> are set directly if they are simple data types, or a |
| 2168 | pointer into the info_ptr is returned for any complex types. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2169 | |
| 2170 | png_get_PLTE(png_ptr, info_ptr, &palette, |
| 2171 | &num_palette); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2172 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2173 | palette - the palette for the file |
| 2174 | (array of png_color) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2175 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2176 | num_palette - number of entries in the palette |
| 2177 | |
Glenn Randers-Pehrson | 8d0bc0f | 2011-01-25 22:15:58 -0600 | [diff] [blame] | 2178 | png_get_gAMA(png_ptr, info_ptr, &file_gamma); |
Glenn Randers-Pehrson | 2774238 | 2011-01-27 09:37:34 -0600 | [diff] [blame] | 2179 | png_get_gAMA_fixed(png_ptr, info_ptr, &int_file_gamma); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2180 | |
Glenn Randers-Pehrson | 8d0bc0f | 2011-01-25 22:15:58 -0600 | [diff] [blame] | 2181 | file_gamma - the gamma at which the file is |
| 2182 | written (PNG_INFO_gAMA) |
| 2183 | |
| 2184 | int_file_gamma - 100,000 times the gamma at which the |
| 2185 | file is written |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2186 | |
John Bowler | bbd17bd | 2011-08-25 17:48:18 -0500 | [diff] [blame] | 2187 | png_get_cHRM(png_ptr, info_ptr, &white_x, &white_y, &red_x, &red_y, |
| 2188 | &green_x, &green_y, &blue_x, &blue_y) |
| 2189 | png_get_cHRM_XYZ(png_ptr, info_ptr, &red_X, &red_Y, &red_Z, &green_X, |
| 2190 | &green_Y, &green_Z, &blue_X, &blue_Y, &blue_Z) |
| 2191 | png_get_cHRM_fixed(png_ptr, info_ptr, &int_white_x, &int_white_y, |
| 2192 | &int_red_x, &int_red_y, &int_green_x, &int_green_y, |
| 2193 | &int_blue_x, &int_blue_y) |
| 2194 | png_get_cHRM_XYZ_fixed(png_ptr, info_ptr, &int_red_X, &int_red_Y, |
| 2195 | &int_red_Z, &int_green_X, &int_green_Y, &int_green_Z, |
| 2196 | &int_blue_X, &int_blue_Y, &int_blue_Z) |
| 2197 | |
| 2198 | {white,red,green,blue}_{x,y} |
| 2199 | A color space encoding specified using the chromaticities |
| 2200 | of the end points and the white point. (PNG_INFO_cHRM) |
| 2201 | |
| 2202 | {red,green,blue}_{X,Y,Z} |
| 2203 | A color space encoding specified using the encoding end |
| 2204 | points - the CIE tristimulus specification of the intended |
| 2205 | color of the red, green and blue channels in the PNG RGB |
| 2206 | data. The white point is simply the sum of the three end |
| 2207 | points. (PNG_INFO_cHRM) |
| 2208 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2209 | png_get_sRGB(png_ptr, info_ptr, &srgb_intent); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2210 | |
Glenn Randers-Pehrson | 2774238 | 2011-01-27 09:37:34 -0600 | [diff] [blame] | 2211 | file_srgb_intent - the rendering intent (PNG_INFO_sRGB) |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2212 | The presence of the sRGB chunk |
| 2213 | means that the pixel data is in the |
| 2214 | sRGB color space. This chunk also |
| 2215 | implies specific values of gAMA and |
| 2216 | cHRM. |
| 2217 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2218 | png_get_iCCP(png_ptr, info_ptr, &name, |
| 2219 | &compression_type, &profile, &proflen); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2220 | |
Glenn Randers-Pehrson | 4a5a1ec | 2011-01-15 11:43:28 -0600 | [diff] [blame] | 2221 | name - The profile name. |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2222 | |
Glenn Randers-Pehrson | 4a5a1ec | 2011-01-15 11:43:28 -0600 | [diff] [blame] | 2223 | compression_type - The compression type; always |
| 2224 | PNG_COMPRESSION_TYPE_BASE for PNG 1.0. |
| 2225 | You may give NULL to this argument to |
| 2226 | ignore it. |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2227 | |
Glenn Randers-Pehrson | 4a5a1ec | 2011-01-15 11:43:28 -0600 | [diff] [blame] | 2228 | profile - International Color Consortium color |
| 2229 | profile data. May contain NULs. |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2230 | |
Glenn Randers-Pehrson | 4a5a1ec | 2011-01-15 11:43:28 -0600 | [diff] [blame] | 2231 | proflen - length of profile data in bytes. |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 2232 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2233 | png_get_sBIT(png_ptr, info_ptr, &sig_bit); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2234 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2235 | sig_bit - the number of significant bits for |
| 2236 | (PNG_INFO_sBIT) each of the gray, |
| 2237 | red, green, and blue channels, |
| 2238 | whichever are appropriate for the |
| 2239 | given color type (png_color_16) |
| 2240 | |
Glenn Randers-Pehrson | 866b62a | 2009-08-08 16:33:14 -0500 | [diff] [blame] | 2241 | png_get_tRNS(png_ptr, info_ptr, &trans_alpha, |
| 2242 | &num_trans, &trans_color); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2243 | |
Glenn Randers-Pehrson | 866b62a | 2009-08-08 16:33:14 -0500 | [diff] [blame] | 2244 | trans_alpha - array of alpha (transparency) |
| 2245 | entries for palette (PNG_INFO_tRNS) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2246 | |
Glenn Randers-Pehrson | f3c51e4 | 2011-01-15 10:25:25 -0600 | [diff] [blame] | 2247 | num_trans - number of transparent entries |
| 2248 | (PNG_INFO_tRNS) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2249 | |
Glenn Randers-Pehrson | 56f6396 | 2008-10-06 10:16:17 -0500 | [diff] [blame] | 2250 | trans_color - graylevel or color sample values of |
Glenn Randers-Pehrson | 3d5a520 | 2000-07-01 15:37:28 -0500 | [diff] [blame] | 2251 | the single transparent color for |
| 2252 | non-paletted images (PNG_INFO_tRNS) |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2253 | |
| 2254 | png_get_hIST(png_ptr, info_ptr, &hist); |
| 2255 | (PNG_INFO_hIST) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2256 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2257 | hist - histogram of palette (array of |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2258 | png_uint_16) |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2259 | |
| 2260 | png_get_tIME(png_ptr, info_ptr, &mod_time); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2261 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2262 | mod_time - time image was last modified |
| 2263 | (PNG_VALID_tIME) |
| 2264 | |
| 2265 | png_get_bKGD(png_ptr, info_ptr, &background); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2266 | |
Glenn Randers-Pehrson | ab38979 | 2011-07-09 19:35:22 -0500 | [diff] [blame] | 2267 | background - background color (of type |
| 2268 | png_color_16p) (PNG_VALID_bKGD) |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 2269 | valid 16-bit red, green and blue |
| 2270 | values, regardless of color_type |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2271 | |
Glenn Randers-Pehrson | a77ef62 | 2000-02-18 13:48:52 -0600 | [diff] [blame] | 2272 | num_comments = png_get_text(png_ptr, info_ptr, |
| 2273 | &text_ptr, &num_text); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2274 | |
Glenn Randers-Pehrson | a77ef62 | 2000-02-18 13:48:52 -0600 | [diff] [blame] | 2275 | num_comments - number of comments |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2276 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2277 | text_ptr - array of png_text holding image |
| 2278 | comments |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2279 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2280 | text_ptr[i].compression - type of compression used |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 2281 | on "text" PNG_TEXT_COMPRESSION_NONE |
| 2282 | PNG_TEXT_COMPRESSION_zTXt |
| 2283 | PNG_ITXT_COMPRESSION_NONE |
| 2284 | PNG_ITXT_COMPRESSION_zTXt |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2285 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2286 | text_ptr[i].key - keyword for comment. Must contain |
| 2287 | 1-79 characters. |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2288 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2289 | text_ptr[i].text - text comments for current |
Glenn Randers-Pehrson | 1ef65b6 | 2000-05-12 06:19:53 -0500 | [diff] [blame] | 2290 | keyword. Can be empty. |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2291 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2292 | text_ptr[i].text_length - length of text string, |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 2293 | after decompression, 0 for iTXt |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2294 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2295 | text_ptr[i].itxt_length - length of itxt string, |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 2296 | after decompression, 0 for tEXt/zTXt |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2297 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2298 | text_ptr[i].lang - language of comment (empty |
| 2299 | string for unknown). |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2300 | |
Glenn Randers-Pehrson | 73d57cb | 2002-03-25 18:49:08 -0600 | [diff] [blame] | 2301 | text_ptr[i].lang_key - keyword in UTF-8 |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2302 | (empty string for unknown). |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2303 | |
Glenn Randers-Pehrson | 8f5846f | 2009-10-31 21:31:08 -0500 | [diff] [blame] | 2304 | Note that the itxt_length, lang, and lang_key |
| 2305 | members of the text_ptr structure only exist |
| 2306 | when the library is built with iTXt chunk support. |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 2307 | Prior to libpng-1.4.0, the default build was |
Glenn Randers-Pehrson | d4e1ddb | 2011-07-27 20:09:57 -0500 | [diff] [blame] | 2308 | without iTXt chunk support. |
Glenn Randers-Pehrson | 8f5846f | 2009-10-31 21:31:08 -0500 | [diff] [blame] | 2309 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2310 | num_text - number of comments (same as |
| 2311 | num_comments; you can put NULL here |
| 2312 | to avoid the duplication) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2313 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2314 | Note while png_set_text() will accept text, language, |
| 2315 | and translated keywords that can be NULL pointers, the |
| 2316 | structure returned by png_get_text will always contain |
| 2317 | regular zero-terminated C strings. They might be |
| 2318 | empty strings but they will never be NULL pointers. |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2319 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2320 | num_spalettes = png_get_sPLT(png_ptr, info_ptr, |
| 2321 | &palette_ptr); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2322 | |
| 2323 | num_spalettes - number of sPLT chunks read. |
| 2324 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2325 | palette_ptr - array of palette structures holding |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2326 | contents of one or more sPLT chunks |
| 2327 | read. |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 2328 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2329 | png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2330 | &unit_type); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2331 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2332 | offset_x - positive offset from the left edge |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 2333 | of the screen (can be negative) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2334 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2335 | offset_y - positive offset from the top edge |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 2336 | of the screen (can be negative) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2337 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2338 | unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER |
| 2339 | |
| 2340 | png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2341 | &unit_type); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2342 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2343 | res_x - pixels/unit physical resolution in |
| 2344 | x direction |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2345 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2346 | res_y - pixels/unit physical resolution in |
| 2347 | x direction |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2348 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 2349 | unit_type - PNG_RESOLUTION_UNKNOWN, |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2350 | PNG_RESOLUTION_METER |
| 2351 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2352 | png_get_sCAL(png_ptr, info_ptr, &unit, &width, |
| 2353 | &height) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2354 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2355 | unit - physical scale units (an integer) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2356 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 2357 | width - width of a pixel in physical scale units |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2358 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 2359 | height - height of a pixel in physical scale units |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2360 | (width and height are doubles) |
| 2361 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2362 | png_get_sCAL_s(png_ptr, info_ptr, &unit, &width, |
| 2363 | &height) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2364 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2365 | unit - physical scale units (an integer) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2366 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2367 | width - width of a pixel in physical scale units |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 2368 | (expressed as a string) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2369 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2370 | height - height of a pixel in physical scale units |
| 2371 | (width and height are strings like "2.54") |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 2372 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2373 | num_unknown_chunks = png_get_unknown_chunks(png_ptr, |
| 2374 | info_ptr, &unknowns) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2375 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2376 | unknowns - array of png_unknown_chunk |
| 2377 | structures holding unknown chunks |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2378 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 2379 | unknowns[i].name - name of unknown chunk |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2380 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 2381 | unknowns[i].data - data of unknown chunk |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2382 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2383 | unknowns[i].size - size of unknown chunk's data |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2384 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 2385 | unknowns[i].location - position of chunk in file |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 2386 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2387 | The value of "i" corresponds to the order in which the |
| 2388 | chunks were read from the PNG file or inserted with the |
| 2389 | png_set_unknown_chunks() function. |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2390 | |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 2391 | The value of "location" is a bitwise "or" of |
| 2392 | |
| 2393 | PNG_HAVE_IHDR (0x01) |
| 2394 | PNG_HAVE_PLTE (0x02) |
| 2395 | PNG_AFTER_IDAT (0x08) |
| 2396 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2397 | The data from the pHYs chunk can be retrieved in several convenient |
| 2398 | forms: |
| 2399 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 2400 | res_x = png_get_x_pixels_per_meter(png_ptr, |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2401 | info_ptr) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2402 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 2403 | res_y = png_get_y_pixels_per_meter(png_ptr, |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2404 | info_ptr) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2405 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2406 | res_x_and_y = png_get_pixels_per_meter(png_ptr, |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2407 | info_ptr) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2408 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2409 | res_x = png_get_x_pixels_per_inch(png_ptr, |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2410 | info_ptr) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2411 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2412 | res_y = png_get_y_pixels_per_inch(png_ptr, |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2413 | info_ptr) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2414 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2415 | res_x_and_y = png_get_pixels_per_inch(png_ptr, |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2416 | info_ptr) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2417 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2418 | aspect_ratio = png_get_pixel_aspect_ratio(png_ptr, |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2419 | info_ptr) |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2420 | |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2421 | Each of these returns 0 [signifying "unknown"] if |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2422 | the data is not present or if res_x is 0; |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2423 | res_x_and_y is 0 if res_x != res_y |
| 2424 | |
| 2425 | Note that because of the way the resolutions are |
| 2426 | stored internally, the inch conversions won't |
| 2427 | come out to exactly even number. For example, |
| 2428 | 72 dpi is stored as 0.28346 pixels/meter, and |
| 2429 | when this is retrieved it is 71.9988 dpi, so |
| 2430 | be sure to round the returned value appropriately |
Glenn Randers-Pehrson | c36bb79 | 2011-02-12 09:49:07 -0600 | [diff] [blame] | 2431 | if you want to display a reasonable-looking result. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2432 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2433 | The data from the oFFs chunk can be retrieved in several convenient |
| 2434 | forms: |
| 2435 | |
| 2436 | x_offset = png_get_x_offset_microns(png_ptr, info_ptr); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2437 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2438 | y_offset = png_get_y_offset_microns(png_ptr, info_ptr); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2439 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2440 | x_offset = png_get_x_offset_inches(png_ptr, info_ptr); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2441 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2442 | y_offset = png_get_y_offset_inches(png_ptr, info_ptr); |
| 2443 | |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2444 | Each of these returns 0 [signifying "unknown" if both |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 2445 | x and y are 0] if the data is not present or if the |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2446 | chunk is present but the unit is the pixel. The |
| 2447 | remark about inexact inch conversions applies here |
| 2448 | as well, because a value in inches can't always be |
| 2449 | converted to microns and back without some loss |
| 2450 | of precision. |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 2451 | |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2452 | For more information, see the |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2453 | PNG specification for chunk contents. Be careful with trusting |
| 2454 | rowbytes, as some of the transformations could increase the space |
| 2455 | needed to hold a row (expand, filler, gray_to_rgb, etc.). |
| 2456 | See png_read_update_info(), below. |
| 2457 | |
| 2458 | A quick word about text_ptr and num_text. PNG stores comments in |
| 2459 | keyword/text pairs, one pair per chunk, with no limit on the number |
| 2460 | of text chunks, and a 2^31 byte limit on their size. While there are |
| 2461 | suggested keywords, there is no requirement to restrict the use to these |
| 2462 | strings. It is strongly suggested that keywords and text be sensible |
| 2463 | to humans (that's the point), so don't use abbreviations. Non-printing |
| 2464 | symbols are not allowed. See the PNG specification for more details. |
| 2465 | There is also no requirement to have text after the keyword. |
| 2466 | |
| 2467 | Keywords should be limited to 79 Latin-1 characters without leading or |
| 2468 | trailing spaces, but non-consecutive spaces are allowed within the |
| 2469 | 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] | 2470 | The text_ptr is an array of png_text structures, each holding a |
| 2471 | 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] | 2472 | a text string. The text string, language code, and translated |
| 2473 | keyword may be empty or NULL pointers. The keyword/text |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 2474 | pairs are put into the array in the order that they are received. |
| 2475 | However, some or all of the text chunks may be after the image, so, to |
| 2476 | make sure you have read all the text chunks, don't mess with these |
| 2477 | until after you read the stuff after the image. This will be |
| 2478 | 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] | 2479 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 2480 | .SS Input transformations |
| 2481 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2482 | After you've read the header information, you can set up the library |
| 2483 | to handle any special transformations of the image data. The various |
| 2484 | ways to transform the data will be described in the order that they |
| 2485 | should occur. This is important, as some of these change the color |
| 2486 | type and/or bit depth of the data, and some others only work on |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2487 | certain color types and bit depths. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2488 | |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2489 | Transformations you request are ignored if they don't have any meaning for a |
| 2490 | particular input data format. However some transformations can have an effect |
| 2491 | as a result of a previous transformation. If you specify a contradictory set of |
| 2492 | transformations, for example both adding and removing the alpha channel, you |
| 2493 | cannot predict the final result. |
| 2494 | |
| 2495 | The color used for the transparency values should be supplied in the same |
| 2496 | format/depth as the current image data. It is stored in the same format/depth |
| 2497 | as the image data in a tRNS chunk, so this is what libpng expects for this data. |
| 2498 | |
| 2499 | The color used for the background value depends on the need_expand argument as |
| 2500 | described below. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2501 | |
| 2502 | Data will be decoded into the supplied row buffers packed into bytes |
| 2503 | unless the library has been told to transform it into another format. |
| 2504 | For example, 4 bit/pixel paletted or grayscale data will be returned |
| 2505 | 2 pixels/byte with the leftmost pixel in the high-order bits of the |
| 2506 | byte, unless png_set_packing() is called. 8-bit RGB data will be stored |
Glenn Randers-Pehrson | 5b77916 | 2004-09-04 13:25:08 -0500 | [diff] [blame] | 2507 | in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha() |
| 2508 | is called to insert filler bytes, either before or after each RGB triplet. |
| 2509 | 16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant |
Glenn Randers-Pehrson | fb29e51 | 2011-06-17 20:38:24 -0500 | [diff] [blame] | 2510 | byte of the color value first, unless png_set_scale_16() is called to |
Glenn Randers-Pehrson | 16e1166 | 2004-11-01 14:13:40 -0600 | [diff] [blame] | 2511 | transform it to regular RGB RGB triplets, or png_set_filler() or |
| 2512 | png_set_add alpha() is called to insert filler bytes, either before or |
| 2513 | after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data can |
Glenn Randers-Pehrson | fb29e51 | 2011-06-17 20:38:24 -0500 | [diff] [blame] | 2514 | be modified with png_set_filler(), png_set_add_alpha(), png_set_strip_16(), |
| 2515 | or png_set_scale_16(). |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2516 | |
| 2517 | The following code transforms grayscale images of less than 8 to 8 bits, |
| 2518 | changes paletted images to RGB, and adds a full alpha channel if there is |
| 2519 | transparency information in a tRNS chunk. This is most useful on |
| 2520 | grayscale images with bit depths of 2 or 4 or if there is a multiple-image |
| 2521 | viewing application that wishes to treat all images in the same way. |
| 2522 | |
Glenn Randers-Pehrson | 228bd39 | 2000-04-23 23:14:02 -0500 | [diff] [blame] | 2523 | if (color_type == PNG_COLOR_TYPE_PALETTE) |
| 2524 | png_set_palette_to_rgb(png_ptr); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2525 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2526 | if (png_get_valid(png_ptr, info_ptr, |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 2527 | PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr); |
| 2528 | |
Glenn Randers-Pehrson | c36bb79 | 2011-02-12 09:49:07 -0600 | [diff] [blame] | 2529 | if (color_type == PNG_COLOR_TYPE_GRAY && |
| 2530 | bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr); |
| 2531 | |
| 2532 | The first two functions are actually aliases for png_set_expand(), added |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 2533 | in libpng version 1.0.4, with the function names expanded to improve code |
| 2534 | readability. In some future version they may actually do different |
| 2535 | things. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2536 | |
Glenn Randers-Pehrson | 1ce0836 | 2006-03-08 23:35:59 -0600 | [diff] [blame] | 2537 | As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was |
| 2538 | added. It expands the sample depth without changing tRNS to alpha. |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 2539 | |
John Bowler | 63d059a | 2011-02-12 09:03:44 -0600 | [diff] [blame] | 2540 | As of libpng version 1.5.2, png_set_expand_16() was added. It behaves as |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 2541 | png_set_expand(); however, the resultant channels have 16 bits rather than 8. |
Glenn Randers-Pehrson | c36bb79 | 2011-02-12 09:49:07 -0600 | [diff] [blame] | 2542 | Use this when the output color or gray channels are made linear to avoid fairly |
John Bowler | 63d059a | 2011-02-12 09:03:44 -0600 | [diff] [blame] | 2543 | severe accuracy loss. |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 2544 | |
John Bowler | 63d059a | 2011-02-12 09:03:44 -0600 | [diff] [blame] | 2545 | if (bit_depth < 16) |
| 2546 | png_set_expand_16(png_ptr); |
Glenn Randers-Pehrson | 1ce0836 | 2006-03-08 23:35:59 -0600 | [diff] [blame] | 2547 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2548 | PNG can have files with 16 bits per channel. If you only can handle |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 2549 | 8 bits per channel, this will strip the pixels down to 8-bit. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2550 | |
| 2551 | if (bit_depth == 16) |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 2552 | #if PNG_LIBPNG_VER >= 10504 |
Glenn Randers-Pehrson | fb29e51 | 2011-06-17 20:38:24 -0500 | [diff] [blame] | 2553 | png_set_scale_16(png_ptr); |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 2554 | #else |
| 2555 | png_set_strip_16(png_ptr); |
| 2556 | #endif |
| 2557 | |
| 2558 | (The more accurate "png_set_scale_16()" API became available in libpng version |
| 2559 | 1.5.4). |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2560 | |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2561 | If you need to process the alpha channel on the image separately from the image |
| 2562 | data (for example if you convert it to a bitmap mask) it is possible to have |
| 2563 | libpng strip the channel leaving just RGB or gray data: |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2564 | |
| 2565 | if (color_type & PNG_COLOR_MASK_ALPHA) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2566 | png_set_strip_alpha(png_ptr); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2567 | |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2568 | If you strip the alpha channel you need to find some other way of dealing with |
| 2569 | the information. If, instead, you want to convert the image to an opaque |
| 2570 | version with no alpha channel use png_set_background; see below. |
John Bowler | 63d059a | 2011-02-12 09:03:44 -0600 | [diff] [blame] | 2571 | |
| 2572 | As of libpng version 1.5.2, almost all useful expansions are supported, the |
Glenn Randers-Pehrson | cd116fa | 2011-05-17 06:56:50 -0500 | [diff] [blame] | 2573 | major ommissions are conversion of grayscale to indexed images (which can be |
| 2574 | done trivially in the application) and conversion of indexed to grayscale (which |
John Bowler | 63d059a | 2011-02-12 09:03:44 -0600 | [diff] [blame] | 2575 | can be done by a trivial manipulation of the palette.) |
| 2576 | |
| 2577 | In the following table, the 01 means grayscale with depth<8, 31 means |
| 2578 | indexed with depth<8, other numerals represent the color type, "T" means |
| 2579 | the tRNS chunk is present, A means an alpha channel is present, and O |
| 2580 | means tRNS or alpha is present but all pixels in the image are opaque. |
| 2581 | |
Glenn Randers-Pehrson | c36bb79 | 2011-02-12 09:49:07 -0600 | [diff] [blame] | 2582 | FROM 01 31 0 0T 0O 2 2T 2O 3 3T 3O 4A 4O 6A 6O |
John Bowler | 63d059a | 2011-02-12 09:03:44 -0600 | [diff] [blame] | 2583 | TO |
| 2584 | 01 - [G] - - - - - - - - - - - - - |
| 2585 | 31 [Q] Q [Q] [Q] [Q] Q Q Q Q Q Q [Q] [Q] Q Q |
| 2586 | 0 1 G + . . G G G G G G B B GB GB |
| 2587 | 0T lt Gt t + . Gt G G Gt G G Bt Bt GBt GBt |
| 2588 | 0O lt Gt t . + Gt Gt G Gt Gt G Bt Bt GBt GBt |
| 2589 | 2 C P C C C + . . C - - CB CB B B |
| 2590 | 2T Ct - Ct C C t + t - - - CBt CBt Bt Bt |
| 2591 | 2O Ct - Ct C C t t + - - - CBt CBt Bt Bt |
| 2592 | 3 [Q] p [Q] [Q] [Q] Q Q Q + . . [Q] [Q] Q Q |
| 2593 | 3T [Qt] p [Qt][Q] [Q] Qt Qt Qt t + t [Qt][Qt] Qt Qt |
| 2594 | 3O [Qt] p [Qt][Q] [Q] Qt Qt Qt t t + [Qt][Qt] Qt Qt |
| 2595 | 4A lA G A T T GA GT GT GA GT GT + BA G GBA |
| 2596 | 4O lA GBA A T T GA GT GT GA GT GT BA + GBA G |
| 2597 | 6A CA PA CA C C A T tT PA P P C CBA + BA |
| 2598 | 6O CA PBA CA C C A tT T PA P P CBA C BA + |
| 2599 | |
| 2600 | Within the matrix, |
| 2601 | "+" identifies entries where 'from' and 'to' are the same. |
| 2602 | "-" means the transformation is not supported. |
| 2603 | "." means nothing is necessary (a tRNS chunk can just be ignored). |
| 2604 | "t" means the transformation is obtained by png_set_tRNS. |
| 2605 | "A" means the transformation is obtained by png_set_add_alpha(). |
| 2606 | "X" means the transformation is obtained by png_set_expand(). |
| 2607 | "1" means the transformation is obtained by |
| 2608 | png_set_expand_gray_1_2_4_to_8() (and by png_set_expand() if there |
| 2609 | is no transparency in the original or the final format). |
| 2610 | "C" means the transformation is obtained by png_set_gray_to_rgb(). |
Glenn Randers-Pehrson | c36074e | 2011-05-16 09:08:51 -0500 | [diff] [blame] | 2611 | "G" means the transformation is obtained by png_set_rgb_to_gray(). |
John Bowler | 63d059a | 2011-02-12 09:03:44 -0600 | [diff] [blame] | 2612 | "P" means the transformation is obtained by |
| 2613 | png_set_expand_palette_to_rgb(). |
| 2614 | "p" means the transformation is obtained by png_set_packing(). |
| 2615 | "Q" means the transformation is obtained by png_set_quantize(). |
| 2616 | "T" means the transformation is obtained by png_set_tRNS_to_alpha(). |
| 2617 | "B" means the transformation is obtained by png_set_background(), or |
| 2618 | png_strip_alpha(). |
John Bowler | 63d059a | 2011-02-12 09:03:44 -0600 | [diff] [blame] | 2619 | |
| 2620 | When an entry has multiple transforms listed all are required to cause the |
| 2621 | right overall transformation. When two transforms are separated by a comma |
| 2622 | either will do the job. When transforms are enclosed in [] the transform should |
| 2623 | do the job but this is currently unimplemented - a different format will result |
| 2624 | if the suggested transformations are used. |
| 2625 | |
Glenn Randers-Pehrson | 520a764 | 2000-03-21 05:13:06 -0600 | [diff] [blame] | 2626 | In PNG files, the alpha channel in an image |
| 2627 | is the level of opacity. If you need the alpha channel in an image to |
| 2628 | be the level of transparency instead of opacity, you can invert the |
| 2629 | alpha channel (or the tRNS chunk data) after it's read, so that 0 is |
| 2630 | fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit |
| 2631 | images) is fully transparent, with |
| 2632 | |
| 2633 | png_set_invert_alpha(png_ptr); |
| 2634 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2635 | PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as |
| 2636 | they can, resulting in, for example, 8 pixels per byte for 1 bit |
| 2637 | files. This code expands to 1 pixel per byte without changing the |
| 2638 | values of the pixels: |
| 2639 | |
| 2640 | if (bit_depth < 8) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2641 | png_set_packing(png_ptr); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2642 | |
| 2643 | PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels |
| 2644 | stored in a PNG image have been "scaled" or "shifted" up to the next |
Glenn Randers-Pehrson | f210a05 | 2009-11-12 10:02:24 -0600 | [diff] [blame] | 2645 | higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] |
| 2646 | to 8 bits/sample in the range [0, 255]). However, it is also possible |
| 2647 | to convert the PNG pixel data back to the original bit depth of the |
| 2648 | image. This call reduces the pixels back down to the original bit depth: |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2649 | |
Glenn Randers-Pehrson | 1ea0ff3 | 2001-08-07 22:25:59 -0500 | [diff] [blame] | 2650 | png_color_8p sig_bit; |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2651 | |
| 2652 | if (png_get_sBIT(png_ptr, info_ptr, &sig_bit)) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2653 | png_set_shift(png_ptr, sig_bit); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2654 | |
| 2655 | PNG files store 3-color pixels in red, green, blue order. This code |
| 2656 | changes the storage of the pixels to blue, green, red: |
| 2657 | |
| 2658 | if (color_type == PNG_COLOR_TYPE_RGB || |
| 2659 | color_type == PNG_COLOR_TYPE_RGB_ALPHA) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2660 | png_set_bgr(png_ptr); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2661 | |
Glenn Randers-Pehrson | 1b8e567 | 2001-08-25 06:46:06 -0500 | [diff] [blame] | 2662 | PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them |
| 2663 | into 4 or 8 bytes for windowing systems that need them in this format: |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2664 | |
Glenn Randers-Pehrson | 1b8e567 | 2001-08-25 06:46:06 -0500 | [diff] [blame] | 2665 | if (color_type == PNG_COLOR_TYPE_RGB) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2666 | png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2667 | |
Glenn Randers-Pehrson | 896239b | 1998-04-21 15:03:57 -0500 | [diff] [blame] | 2668 | 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] | 2669 | either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether |
| 2670 | you want the filler before the RGB or after. This transformation |
Glenn Randers-Pehrson | 1b8e567 | 2001-08-25 06:46:06 -0500 | [diff] [blame] | 2671 | does not affect images that already have full alpha channels. To add an |
| 2672 | opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which |
| 2673 | will generate RGBA pixels. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2674 | |
Glenn Randers-Pehrson | 5b77916 | 2004-09-04 13:25:08 -0500 | [diff] [blame] | 2675 | Note that png_set_filler() does not change the color type. If you want |
| 2676 | to do that, you can add a true alpha channel with |
| 2677 | |
| 2678 | if (color_type == PNG_COLOR_TYPE_RGB || |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2679 | color_type == PNG_COLOR_TYPE_GRAY) |
| 2680 | png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER); |
Glenn Randers-Pehrson | 5b77916 | 2004-09-04 13:25:08 -0500 | [diff] [blame] | 2681 | |
| 2682 | where "filler" contains the alpha value to assign to each pixel. |
Glenn Randers-Pehrson | 16e1166 | 2004-11-01 14:13:40 -0600 | [diff] [blame] | 2683 | This function was added in libpng-1.2.7. |
Glenn Randers-Pehrson | 5b77916 | 2004-09-04 13:25:08 -0500 | [diff] [blame] | 2684 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2685 | If you are reading an image with an alpha channel, and you need the |
| 2686 | data as ARGB instead of the normal PNG format RGBA: |
| 2687 | |
| 2688 | if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2689 | png_set_swap_alpha(png_ptr); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2690 | |
| 2691 | For some uses, you may want a grayscale image to be represented as |
| 2692 | RGB. This code will do that conversion: |
| 2693 | |
| 2694 | if (color_type == PNG_COLOR_TYPE_GRAY || |
| 2695 | color_type == PNG_COLOR_TYPE_GRAY_ALPHA) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2696 | png_set_gray_to_rgb(png_ptr); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2697 | |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 2698 | 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] | 2699 | with alpha. |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 2700 | |
| 2701 | if (color_type == PNG_COLOR_TYPE_RGB || |
| 2702 | color_type == PNG_COLOR_TYPE_RGB_ALPHA) |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2703 | png_set_rgb_to_gray(png_ptr, error_action, double red_weight, |
| 2704 | double green_weight); |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 2705 | |
| 2706 | error_action = 1: silently do the conversion |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2707 | |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 2708 | error_action = 2: issue a warning if the original |
| 2709 | image has any pixel where |
| 2710 | red != green or red != blue |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2711 | |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 2712 | error_action = 3: issue an error and abort the |
| 2713 | conversion if the original |
| 2714 | image has any pixel where |
| 2715 | red != green or red != blue |
| 2716 | |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2717 | red_weight: weight of red component |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2718 | |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2719 | green_weight: weight of green component |
Glenn Randers-Pehrson | 520a764 | 2000-03-21 05:13:06 -0600 | [diff] [blame] | 2720 | If either weight is negative, default |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2721 | weights are used. |
| 2722 | |
| 2723 | In the corresponding fixed point API the red_weight and green_weight values are |
| 2724 | simply scaled by 100,000: |
| 2725 | |
| 2726 | png_set_rgb_to_gray(png_ptr, error_action, png_fixed_point red_weight, |
| 2727 | png_fixed_point green_weight); |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 2728 | |
| 2729 | If you have set error_action = 1 or 2, you can |
| 2730 | later check whether the image really was gray, after processing |
| 2731 | the image rows, with the png_get_rgb_to_gray_status(png_ptr) function. |
| 2732 | It will return a png_byte that is zero if the image was gray or |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2733 | 1 if there were any non-gray pixels. Background and sBIT data |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 2734 | will be silently converted to grayscale, using the green channel |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2735 | data for sBIT, regardless of the error_action setting. |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 2736 | |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 2737 | The default values come from the PNG file cHRM chunk if present; otherwise, the |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2738 | defaults correspond to the ITU-R recommendation 709, and also the sRGB color |
| 2739 | space, as recommended in the Charles Poynton's Colour FAQ, |
| 2740 | <http://www.poynton.com/>, in section 9: |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 2741 | |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2742 | <http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html#RTFToC9> |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 2743 | |
Glenn Randers-Pehrson | 6c98897 | 2011-07-29 12:31:16 -0500 | [diff] [blame] | 2744 | Y = 0.2126 * R + 0.7152 * G + 0.0722 * B |
| 2745 | |
| 2746 | Previous versions of this document, 1998 through 2002, recommended a slightly |
| 2747 | different formula: |
| 2748 | |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 2749 | Y = 0.212671 * R + 0.715160 * G + 0.072169 * B |
| 2750 | |
Glenn Randers-Pehrson | 6c98897 | 2011-07-29 12:31:16 -0500 | [diff] [blame] | 2751 | Libpng uses an integer approximation: |
| 2752 | |
| 2753 | Y = (6968 * R + 23434 * G + 2366 * B)/32768 |
| 2754 | |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 2755 | The calculation is done in a linear colorspace, if the image gamma |
Glenn Randers-Pehrson | 9962b84 | 2011-01-24 00:12:14 -0600 | [diff] [blame] | 2756 | can be determined. |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 2757 | |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 2758 | The png_set_background() function has been described already; it tells libpng to |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2759 | composite images with alpha or simple transparency against the supplied |
| 2760 | background color. For compatibility with versions of libpng earlier than |
Glenn Randers-Pehrson | 733b131 | 2011-06-15 13:21:01 -0500 | [diff] [blame] | 2761 | libpng-1.5.4 it is recommended that you call the function after reading the file |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2762 | header, even if you don't want to use the color in a bKGD chunk, if one exists. |
| 2763 | |
| 2764 | If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid), |
| 2765 | you may use this color, or supply another color more suitable for |
| 2766 | the current display (e.g., the background color from a web page). You |
| 2767 | need to tell libpng how the color is represented, both the format of the |
Glenn Randers-Pehrson | ab38979 | 2011-07-09 19:35:22 -0500 | [diff] [blame] | 2768 | component values in the color (the number of bits) and the gamma encoding of the |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2769 | color. The function takes two arguments, background_gamma_mode and need_expand |
Glenn Randers-Pehrson | ab38979 | 2011-07-09 19:35:22 -0500 | [diff] [blame] | 2770 | to convey this information, however only two combinations are likely to be |
| 2771 | useful: |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2772 | |
Glenn Randers-Pehrson | cb47e20 | 2011-07-10 06:55:14 -0500 | [diff] [blame] | 2773 | png_color_16 my_background; |
| 2774 | png_color_16p image_background; |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2775 | |
Glenn Randers-Pehrson | d0dce40 | 1998-05-09 10:02:29 -0500 | [diff] [blame] | 2776 | if (png_get_bKGD(png_ptr, info_ptr, &image_background)) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2777 | png_set_background(png_ptr, image_background, |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2778 | PNG_BACKGROUND_GAMMA_FILE, 1/*needs to be expanded*/, 1); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2779 | else |
Glenn Randers-Pehrson | cb47e20 | 2011-07-10 06:55:14 -0500 | [diff] [blame] | 2780 | png_set_background(png_ptr, &my_background, |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2781 | PNG_BACKGROUND_GAMMA_SCREEN, 0/*do not expand*/, 1); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2782 | |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2783 | The second call was described above - my_background is in the format of the |
| 2784 | final, display, output produced by libpng. Because you now know the format of |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 2785 | the PNG it is possible to avoid the need to choose either 8-bit or 16-bit |
| 2786 | output and to retain palette images (the palette colors will be modified |
| 2787 | appropriately and the tRNS chunk removed.) However, if you are doing this, |
| 2788 | take great care not to ask for transformations without checking first that |
| 2789 | they apply! |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2790 | |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2791 | In the first call the background color has the original bit depth and color type |
| 2792 | of the PNG file. So, for palette images the color is supplied as a palette |
| 2793 | index and for low bit greyscale images the color is a reduced bit value in |
| 2794 | image_background->gray. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2795 | |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2796 | If you didn't call png_set_gamma() before reading the file header, for example |
| 2797 | if you need your code to remain compatible with older versions of libpng prior |
Glenn Randers-Pehrson | 733b131 | 2011-06-15 13:21:01 -0500 | [diff] [blame] | 2798 | to libpng-1.5.4, this is the place to call it. |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 2799 | |
John Bowler | cb0b296 | 2011-05-12 21:48:29 -0500 | [diff] [blame] | 2800 | Do not call it if you called png_set_alpha_mode(); doing so will damage the |
| 2801 | settings put in place by png_set_alpha_mode(). (If png_set_alpha_mode() is |
| 2802 | supported then you can certainly do png_set_gamma() before reading the PNG |
| 2803 | header.) |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2804 | |
Glenn Randers-Pehrson | c782251 | 2011-05-07 21:23:43 -0500 | [diff] [blame] | 2805 | This API unconditionally sets the screen and file gamma values, so it will |
| 2806 | override the value in the PNG file unless it is called before the PNG file |
| 2807 | reading starts. For this reason you must always call it with the PNG file |
| 2808 | value when you call it in this position: |
| 2809 | |
Glenn Randers-Pehrson | 8d0bc0f | 2011-01-25 22:15:58 -0600 | [diff] [blame] | 2810 | if (png_get_gAMA(png_ptr, info_ptr, &file_gamma)) |
| 2811 | png_set_gamma(png_ptr, screen_gamma, file_gamma); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2812 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2813 | else |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 2814 | png_set_gamma(png_ptr, screen_gamma, 0.45455); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2815 | |
Glenn Randers-Pehrson | 3cd7cff | 2010-04-16 19:27:08 -0500 | [diff] [blame] | 2816 | If you need to reduce an RGB file to a paletted file, or if a paletted |
| 2817 | file has more entries then will fit on your screen, png_set_quantize() |
Glenn Randers-Pehrson | 862cb20 | 2010-04-16 22:12:51 -0500 | [diff] [blame] | 2818 | will do that. Note that this is a simple match quantization that merely |
Glenn Randers-Pehrson | 3cd7cff | 2010-04-16 19:27:08 -0500 | [diff] [blame] | 2819 | finds the closest color available. This should work fairly well with |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2820 | optimized palettes, but fairly badly with linear color cubes. If you |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 2821 | pass a palette that is larger than maximum_colors, the file will |
Glenn Randers-Pehrson | 3cd7cff | 2010-04-16 19:27:08 -0500 | [diff] [blame] | 2822 | reduce the number of colors in the palette so it will fit into |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 2823 | maximum_colors. If there is a histogram, libpng will use it to make |
Glenn Randers-Pehrson | 3cd7cff | 2010-04-16 19:27:08 -0500 | [diff] [blame] | 2824 | more intelligent choices when reducing the palette. If there is no |
| 2825 | histogram, it may not do as good a job. |
| 2826 | |
| 2827 | if (color_type & PNG_COLOR_MASK_COLOR) |
| 2828 | { |
| 2829 | if (png_get_valid(png_ptr, info_ptr, |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2830 | PNG_INFO_PLTE)) |
Glenn Randers-Pehrson | 3cd7cff | 2010-04-16 19:27:08 -0500 | [diff] [blame] | 2831 | { |
| 2832 | png_uint_16p histogram = NULL; |
| 2833 | |
| 2834 | png_get_hIST(png_ptr, info_ptr, |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2835 | &histogram); |
Glenn Randers-Pehrson | 3cd7cff | 2010-04-16 19:27:08 -0500 | [diff] [blame] | 2836 | png_set_quantize(png_ptr, palette, num_palette, |
| 2837 | max_screen_colors, histogram, 1); |
| 2838 | } |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2839 | |
Glenn Randers-Pehrson | 3cd7cff | 2010-04-16 19:27:08 -0500 | [diff] [blame] | 2840 | else |
| 2841 | { |
| 2842 | png_color std_color_cube[MAX_SCREEN_COLORS] = |
| 2843 | { ... colors ... }; |
| 2844 | |
| 2845 | png_set_quantize(png_ptr, std_color_cube, |
| 2846 | MAX_SCREEN_COLORS, MAX_SCREEN_COLORS, |
| 2847 | NULL,0); |
| 2848 | } |
| 2849 | } |
| 2850 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2851 | PNG files describe monochrome as black being zero and white being one. |
| 2852 | The following code will reverse this (make black be one and white be |
| 2853 | zero): |
| 2854 | |
Glenn Randers-Pehrson | 1ea0ff3 | 2001-08-07 22:25:59 -0500 | [diff] [blame] | 2855 | if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY) |
| 2856 | png_set_invert_mono(png_ptr); |
| 2857 | |
| 2858 | This function can also be used to invert grayscale and gray-alpha images: |
| 2859 | |
| 2860 | if (color_type == PNG_COLOR_TYPE_GRAY || |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2861 | color_type == PNG_COLOR_TYPE_GRAY_ALPHA) |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2862 | png_set_invert_mono(png_ptr); |
| 2863 | |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 2864 | 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] | 2865 | ie. most significant bits first). This code changes the storage to the |
| 2866 | other way (little-endian, i.e. least significant bits first, the |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2867 | way PCs store them): |
| 2868 | |
| 2869 | if (bit_depth == 16) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2870 | png_set_swap(png_ptr); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2871 | |
| 2872 | If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you |
| 2873 | need to change the order the pixels are packed into bytes, you can use: |
| 2874 | |
| 2875 | if (bit_depth < 8) |
| 2876 | png_set_packswap(png_ptr); |
| 2877 | |
Glenn Randers-Pehrson | 520a764 | 2000-03-21 05:13:06 -0600 | [diff] [blame] | 2878 | Finally, you can write your own transformation function if none of |
| 2879 | the existing ones meets your needs. This is done by setting a callback |
| 2880 | with |
| 2881 | |
| 2882 | png_set_read_user_transform_fn(png_ptr, |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2883 | read_transform_fn); |
Glenn Randers-Pehrson | 520a764 | 2000-03-21 05:13:06 -0600 | [diff] [blame] | 2884 | |
| 2885 | You must supply the function |
| 2886 | |
Glenn Randers-Pehrson | 9321567 | 2011-02-13 19:42:19 -0600 | [diff] [blame] | 2887 | void read_transform_fn(png_structp png_ptr, png_row_infop |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2888 | row_info, png_bytep data) |
Glenn Randers-Pehrson | 520a764 | 2000-03-21 05:13:06 -0600 | [diff] [blame] | 2889 | |
| 2890 | See pngtest.c for a working example. Your function will be called |
John Bowler | f19abd6 | 2011-01-22 18:29:24 -0600 | [diff] [blame] | 2891 | after all of the other transformations have been processed. Take care with |
| 2892 | interlaced images if you do the interlace yourself - the width of the row is the |
| 2893 | width in 'row_info', not the overall image width. |
| 2894 | |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 2895 | If supported, libpng provides two information routines that you can use to find |
John Bowler | f19abd6 | 2011-01-22 18:29:24 -0600 | [diff] [blame] | 2896 | where you are in processing the image: |
| 2897 | |
| 2898 | png_get_current_pass_number(png_structp png_ptr); |
| 2899 | png_get_current_row_number(png_structp png_ptr); |
| 2900 | |
| 2901 | Don't try using these outside a transform callback - firstly they are only |
| 2902 | supported if user transforms are supported, secondly they may well return |
| 2903 | unexpected results unless the row is actually being processed at the moment they |
| 2904 | are called. |
Glenn Randers-Pehrson | 520a764 | 2000-03-21 05:13:06 -0600 | [diff] [blame] | 2905 | |
John Bowler | cd11345 | 2011-02-16 06:15:13 -0600 | [diff] [blame] | 2906 | With interlaced |
| 2907 | images the value returned is the row in the input sub-image image. Use |
| 2908 | PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to |
| 2909 | find the output pixel (x,y) given an interlaced sub-image pixel (row,col,pass). |
| 2910 | |
| 2911 | The discussion of interlace handling above contains more information on how to |
| 2912 | use these values. |
| 2913 | |
Glenn Randers-Pehrson | 520a764 | 2000-03-21 05:13:06 -0600 | [diff] [blame] | 2914 | You can also set up a pointer to a user structure for use by your |
| 2915 | callback function, and you can inform libpng that your transform |
| 2916 | function will change the number of channels or bit depth with the |
| 2917 | function |
| 2918 | |
| 2919 | png_set_user_transform_info(png_ptr, user_ptr, |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2920 | user_depth, user_channels); |
Glenn Randers-Pehrson | 520a764 | 2000-03-21 05:13:06 -0600 | [diff] [blame] | 2921 | |
| 2922 | The user's application, not libpng, is responsible for allocating and |
| 2923 | freeing any memory required for the user structure. |
| 2924 | |
| 2925 | You can retrieve the pointer via the function |
| 2926 | png_get_user_transform_ptr(). For example: |
| 2927 | |
| 2928 | voidp read_user_transform_ptr = |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2929 | png_get_user_transform_ptr(png_ptr); |
Glenn Randers-Pehrson | 520a764 | 2000-03-21 05:13:06 -0600 | [diff] [blame] | 2930 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2931 | The last thing to handle is interlacing; this is covered in detail below, |
| 2932 | but you must call the function here if you want libpng to handle expansion |
| 2933 | of the interlaced image. |
| 2934 | |
| 2935 | number_of_passes = png_set_interlace_handling(png_ptr); |
| 2936 | |
| 2937 | After setting the transformations, libpng can update your png_info |
| 2938 | structure to reflect any transformations you've requested with this |
Glenn Randers-Pehrson | 968c231 | 2011-09-26 16:35:22 -0500 | [diff] [blame] | 2939 | call. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2940 | |
| 2941 | png_read_update_info(png_ptr, info_ptr); |
| 2942 | |
Glenn Randers-Pehrson | 968c231 | 2011-09-26 16:35:22 -0500 | [diff] [blame] | 2943 | This is most useful to update the info structure's rowbytes |
| 2944 | field so you can use it to allocate your image memory. This function |
| 2945 | will also update your palette with the correct screen_gamma and |
| 2946 | background if these have been given with the calls above. You may |
| 2947 | only call png_read_update_info() once with a particular info_ptr. |
| 2948 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2949 | After you call png_read_update_info(), you can allocate any |
| 2950 | memory you need to hold the image. The row data is simply |
| 2951 | raw byte data for all forms of images. As the actual allocation |
| 2952 | varies among applications, no example will be given. If you |
| 2953 | are allocating one large chunk, you will need to build an |
| 2954 | array of pointers to each row, as it will be needed for some |
| 2955 | of the functions below. |
| 2956 | |
Glenn Randers-Pehrson | 968c231 | 2011-09-26 16:35:22 -0500 | [diff] [blame] | 2957 | Remember: Before you call png_read_update_info(), the png_get_*() |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 2958 | functions return the values corresponding to the original PNG image. |
| 2959 | After you call png_read_update_info the values refer to the image |
| 2960 | that libpng will output. Consequently you must call all the png_set_ |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2961 | functions before you call png_read_update_info(). This is particularly |
| 2962 | important for png_set_interlace_handling() - if you are going to call |
| 2963 | png_read_update_info() you must call png_set_interlace_handling() before |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 2964 | it unless you want to receive interlaced output. |
| 2965 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 2966 | .SS Reading image data |
| 2967 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2968 | After you've allocated memory, you can read the image data. |
| 2969 | The simplest way to do this is in one function call. If you are |
| 2970 | allocating enough memory to hold the whole image, you can just |
| 2971 | call png_read_image() and libpng will read in all the image data |
| 2972 | and put it in the memory area supplied. You will need to pass in |
| 2973 | an array of pointers to each row. |
| 2974 | |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 2975 | This function automatically handles interlacing, so you don't |
| 2976 | need to call png_set_interlace_handling() (unless you call |
| 2977 | png_read_update_info()) or call this function multiple times, or any |
| 2978 | of that other stuff necessary with png_read_rows(). |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2979 | |
| 2980 | png_read_image(png_ptr, row_pointers); |
| 2981 | |
| 2982 | where row_pointers is: |
| 2983 | |
| 2984 | png_bytep row_pointers[height]; |
| 2985 | |
| 2986 | You can point to void or char or whatever you use for pixels. |
| 2987 | |
| 2988 | If you don't want to read in the whole image at once, you can |
| 2989 | use png_read_rows() instead. If there is no interlacing (check |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 2990 | interlace_type == PNG_INTERLACE_NONE), this is simple: |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2991 | |
| 2992 | png_read_rows(png_ptr, row_pointers, NULL, |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 2993 | number_of_rows); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2994 | |
| 2995 | where row_pointers is the same as in the png_read_image() call. |
| 2996 | |
| 2997 | 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] | 2998 | a single row_pointer instead of an array of row_pointers: |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 2999 | |
Glenn Randers-Pehrson | 520a764 | 2000-03-21 05:13:06 -0600 | [diff] [blame] | 3000 | png_bytep row_pointer = row; |
Glenn Randers-Pehrson | 228bd39 | 2000-04-23 23:14:02 -0500 | [diff] [blame] | 3001 | png_read_row(png_ptr, row_pointer, NULL); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3002 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 3003 | If the file is interlaced (interlace_type != 0 in the IHDR chunk), things |
| 3004 | get somewhat harder. The only current (PNG Specification version 1.2) |
Glenn Randers-Pehrson | 6e97410 | 2010-12-19 16:44:22 -0600 | [diff] [blame] | 3005 | interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7); |
| 3006 | a somewhat complicated 2D interlace scheme, known as Adam7, that |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3007 | breaks down an image into seven smaller images of varying size, based |
Glenn Randers-Pehrson | 6e97410 | 2010-12-19 16:44:22 -0600 | [diff] [blame] | 3008 | on an 8x8 grid. This number is defined (from libpng 1.5) as |
| 3009 | PNG_INTERLACE_ADAM7_PASSES in png.h |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3010 | |
| 3011 | libpng can fill out those images or it can give them to you "as is". |
Glenn Randers-Pehrson | 6e97410 | 2010-12-19 16:44:22 -0600 | [diff] [blame] | 3012 | It is almost always better to have libpng handle the interlacing for you. |
| 3013 | If you want the images filled out, there are two ways to do that. The one |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3014 | mentioned in the PNG specification is to expand each pixel to cover |
| 3015 | those pixels that have not been read yet (the "rectangle" method). |
| 3016 | This results in a blocky image for the first pass, which gradually |
| 3017 | smooths out as more pixels are read. The other method is the "sparkle" |
| 3018 | method, where pixels are drawn only in their final locations, with the |
| 3019 | rest of the image remaining whatever colors they were initialized to |
| 3020 | before the start of the read. The first method usually looks better, |
| 3021 | but tends to be slower, as there are more pixels to put in the rows. |
| 3022 | |
Glenn Randers-Pehrson | 6e97410 | 2010-12-19 16:44:22 -0600 | [diff] [blame] | 3023 | If, as is likely, you want libpng to expand the images, call this before |
| 3024 | calling png_start_read_image() or png_read_update_info(): |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3025 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 3026 | if (interlace_type == PNG_INTERLACE_ADAM7) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3027 | number_of_passes |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3028 | = png_set_interlace_handling(png_ptr); |
| 3029 | |
Glenn Randers-Pehrson | 6e97410 | 2010-12-19 16:44:22 -0600 | [diff] [blame] | 3030 | This will return the number of passes needed. Currently, this is seven, |
| 3031 | but may change if another interlace type is added. This function can be |
| 3032 | called even if the file is not interlaced, where it will return one pass. |
| 3033 | You then need to read the whole image 'number_of_passes' times. Each time |
| 3034 | will distribute the pixels from the current pass to the correct place in |
| 3035 | the output image, so you need to supply the same rows to png_read_rows in |
| 3036 | each pass. |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 3037 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3038 | If you are not going to display the image after each pass, but are |
| 3039 | going to wait until the entire image is read in, use the sparkle |
| 3040 | effect. This effect is faster and the end result of either method |
| 3041 | is exactly the same. If you are planning on displaying the image |
| 3042 | after each pass, the "rectangle" effect is generally considered the |
| 3043 | better looking one. |
| 3044 | |
| 3045 | If you only want the "sparkle" effect, just call png_read_rows() as |
| 3046 | normal, with the third parameter NULL. Make sure you make pass over |
| 3047 | the image number_of_passes times, and you don't change the data in the |
| 3048 | rows between calls. You can change the locations of the data, just |
| 3049 | not the data. Each pass only writes the pixels appropriate for that |
| 3050 | pass, and assumes the data from previous passes is still valid. |
| 3051 | |
| 3052 | png_read_rows(png_ptr, row_pointers, NULL, |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3053 | number_of_rows); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3054 | |
| 3055 | If you only want the first effect (the rectangles), do the same as |
| 3056 | before except pass the row buffer in the third parameter, and leave |
| 3057 | the second parameter NULL. |
| 3058 | |
| 3059 | png_read_rows(png_ptr, NULL, row_pointers, |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3060 | number_of_rows); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3061 | |
Glenn Randers-Pehrson | 6e97410 | 2010-12-19 16:44:22 -0600 | [diff] [blame] | 3062 | If you don't want libpng to handle the interlacing details, just call |
| 3063 | png_read_rows() PNG_INTERLACE_ADAM7_PASSES times to read in all the images. |
| 3064 | Each of the images is a valid image by itself, however you will almost |
| 3065 | certainly need to distribute the pixels from each sub-image to the |
| 3066 | correct place. This is where everything gets very tricky. |
| 3067 | |
| 3068 | If you want to retrieve the separate images you must pass the correct |
| 3069 | number of rows to each successive call of png_read_rows(). The calculation |
| 3070 | gets pretty complicated for small images, where some sub-images may |
| 3071 | not even exist because either their width or height ends up zero. |
| 3072 | libpng provides two macros to help you in 1.5 and later versions: |
| 3073 | |
| 3074 | png_uint_32 width = PNG_PASS_COLS(image_width, pass_number); |
| 3075 | png_uint_32 height = PNG_PASS_ROWS(image_height, pass_number); |
| 3076 | |
| 3077 | Respectively these tell you the width and height of the sub-image |
| 3078 | corresponding to the numbered pass. 'pass' is in in the range 0 to 6 - |
| 3079 | this can be confusing because the specification refers to the same passes |
| 3080 | as 1 to 7! Be careful, you must check both the width and height before |
| 3081 | calling png_read_rows() and not call it for that pass if either is zero. |
| 3082 | |
| 3083 | You can, of course, read each sub-image row by row. If you want to |
| 3084 | produce optimal code to make a pixel-by-pixel transformation of an |
| 3085 | interlaced image this is the best approach; read each row of each pass, |
| 3086 | transform it, and write it out to a new interlaced image. |
| 3087 | |
| 3088 | If you want to de-interlace the image yourself libpng provides further |
| 3089 | macros to help that tell you where to place the pixels in the output image. |
| 3090 | Because the interlacing scheme is rectangular - sub-image pixels are always |
| 3091 | arranged on a rectangular grid - all you need to know for each pass is the |
| 3092 | starting column and row in the output image of the first pixel plus the |
| 3093 | spacing between each pixel. As of libpng 1.5 there are four macros to |
| 3094 | retrieve this information: |
| 3095 | |
| 3096 | png_uint_32 x = PNG_PASS_START_COL(pass); |
| 3097 | png_uint_32 y = PNG_PASS_START_ROW(pass); |
| 3098 | png_uint_32 xStep = 1U << PNG_PASS_COL_SHIFT(pass); |
| 3099 | png_uint_32 yStep = 1U << PNG_PASS_ROW_SHIFT(pass); |
| 3100 | |
| 3101 | These allow you to write the obvious loop: |
| 3102 | |
| 3103 | png_uint_32 input_y = 0; |
| 3104 | png_uint_32 output_y = PNG_PASS_START_ROW(pass); |
| 3105 | |
| 3106 | while (output_y < output_image_height) |
| 3107 | { |
| 3108 | png_uint_32 input_x = 0; |
| 3109 | png_uint_32 output_x = PNG_PASS_START_COL(pass); |
| 3110 | |
| 3111 | while (output_x < output_image_width) |
| 3112 | { |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3113 | image[output_y][output_x] = |
| 3114 | subimage[pass][input_y][input_x++]; |
| 3115 | |
Glenn Randers-Pehrson | 6e97410 | 2010-12-19 16:44:22 -0600 | [diff] [blame] | 3116 | output_x += xStep; |
| 3117 | } |
| 3118 | |
| 3119 | ++input_y; |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3120 | output_y += yStep; |
Glenn Randers-Pehrson | 6e97410 | 2010-12-19 16:44:22 -0600 | [diff] [blame] | 3121 | } |
| 3122 | |
| 3123 | Notice that the steps between successive output rows and columns are |
| 3124 | returned as shifts. This is possible because the pixels in the subimages |
| 3125 | are always a power of 2 apart - 1, 2, 4 or 8 pixels - in the original |
| 3126 | image. In practice you may need to directly calculate the output coordinate |
| 3127 | given an input coordinate. libpng provides two further macros for this |
| 3128 | purpose: |
| 3129 | |
| 3130 | png_uint_32 output_x = PNG_COL_FROM_PASS_COL(input_x, pass); |
| 3131 | png_uint_32 output_y = PNG_ROW_FROM_PASS_ROW(input_y, pass); |
| 3132 | |
| 3133 | Finally a pair of macros are provided to tell you if a particular image |
| 3134 | row or column appears in a given pass: |
| 3135 | |
| 3136 | int col_in_pass = PNG_COL_IN_INTERLACE_PASS(output_x, pass); |
| 3137 | int row_in_pass = PNG_ROW_IN_INTERLACE_PASS(output_y, pass); |
| 3138 | |
| 3139 | Bear in mind that you will probably also need to check the width and height |
| 3140 | of the pass in addition to the above to be sure the pass even exists! |
| 3141 | |
| 3142 | With any luck you are convinced by now that you don't want to do your own |
| 3143 | interlace handling. In reality normally the only good reason for doing this |
| 3144 | is if you are processing PNG files on a pixel-by-pixel basis and don't want |
| 3145 | to load the whole file into memory when it is interlaced. |
| 3146 | |
| 3147 | libpng includes a test program, pngvalid, that illustrates reading and |
| 3148 | writing of interlaced images. If you can't get interlacing to work in your |
Glenn Randers-Pehrson | 95ba417 | 2011-09-08 12:21:42 -0500 | [diff] [blame] | 3149 | code and don't want to leave it to libpng (the recommended approach), see |
Glenn Randers-Pehrson | 6e97410 | 2010-12-19 16:44:22 -0600 | [diff] [blame] | 3150 | how pngvalid.c does it. |
| 3151 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 3152 | .SS Finishing a sequential read |
| 3153 | |
Glenn Randers-Pehrson | 9c3ab68 | 2006-02-20 22:09:05 -0600 | [diff] [blame] | 3154 | After you are finished reading the image through the |
| 3155 | low-level interface, you can finish reading the file. If you are |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 3156 | interested in comments or time, which may be stored either before or |
| 3157 | after the image data, you should pass the separate png_info struct if |
| 3158 | you want to keep the comments from before and after the image |
Glenn Randers-Pehrson | 20786be | 2011-04-20 22:20:40 -0500 | [diff] [blame] | 3159 | separate. |
| 3160 | |
| 3161 | png_infop end_info = png_create_info_struct(png_ptr); |
| 3162 | |
| 3163 | if (!end_info) |
| 3164 | { |
| 3165 | png_destroy_read_struct(&png_ptr, &info_ptr, |
| 3166 | (png_infopp)NULL); |
| 3167 | return (ERROR); |
| 3168 | } |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3169 | |
| 3170 | png_read_end(png_ptr, end_info); |
| 3171 | |
Glenn Randers-Pehrson | 20786be | 2011-04-20 22:20:40 -0500 | [diff] [blame] | 3172 | If you are not interested, you should still call png_read_end() |
| 3173 | but you can pass NULL, avoiding the need to create an end_info structure. |
| 3174 | |
| 3175 | png_read_end(png_ptr, (png_infop)NULL); |
| 3176 | |
Glenn Randers-Pehrson | 99778e1 | 2011-04-20 17:43:52 -0500 | [diff] [blame] | 3177 | If you don't call png_read_end(), then your file pointer will be |
| 3178 | left pointing to the first chunk after the last IDAT, which is probably |
| 3179 | not what you want if you expect to read something beyond the end of |
| 3180 | the PNG datastream. |
| 3181 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3182 | When you are done, you can free all memory allocated by libpng like this: |
| 3183 | |
| 3184 | png_destroy_read_struct(&png_ptr, &info_ptr, |
| 3185 | &end_info); |
| 3186 | |
Glenn Randers-Pehrson | 20786be | 2011-04-20 22:20:40 -0500 | [diff] [blame] | 3187 | or, if you didn't create an end_info structure, |
| 3188 | |
| 3189 | png_destroy_read_struct(&png_ptr, &info_ptr, |
| 3190 | (png_infopp)NULL); |
| 3191 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 3192 | 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] | 3193 | point to libpng-allocated storage with the following function: |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 3194 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 3195 | png_free_data(png_ptr, info_ptr, mask, seq) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3196 | |
Glenn Randers-Pehrson | 1ef65b6 | 2000-05-12 06:19:53 -0500 | [diff] [blame] | 3197 | mask - identifies data to be freed, a mask |
Glenn Randers-Pehrson | ebd7f9a | 2006-10-19 09:37:56 -0500 | [diff] [blame] | 3198 | containing the bitwise OR of one or |
Glenn Randers-Pehrson | 1ef65b6 | 2000-05-12 06:19:53 -0500 | [diff] [blame] | 3199 | more of |
| 3200 | PNG_FREE_PLTE, PNG_FREE_TRNS, |
| 3201 | PNG_FREE_HIST, PNG_FREE_ICCP, |
| 3202 | PNG_FREE_PCAL, PNG_FREE_ROWS, |
| 3203 | PNG_FREE_SCAL, PNG_FREE_SPLT, |
| 3204 | PNG_FREE_TEXT, PNG_FREE_UNKN, |
| 3205 | or simply PNG_FREE_ALL |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3206 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 3207 | seq - sequence number of item to be freed |
Glenn Randers-Pehrson | 1ef65b6 | 2000-05-12 06:19:53 -0500 | [diff] [blame] | 3208 | (-1 for all items) |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 3209 | |
Glenn Randers-Pehrson | fc4a143 | 2000-05-17 17:39:34 -0500 | [diff] [blame] | 3210 | This function may be safely called when the relevant storage has |
Glenn Randers-Pehrson | 68ea243 | 2000-04-01 21:10:05 -0600 | [diff] [blame] | 3211 | already been freed, or has not yet been allocated, or was allocated |
Glenn Randers-Pehrson | f210a05 | 2009-11-12 10:02:24 -0600 | [diff] [blame] | 3212 | by the user and not by libpng, and will in those cases do nothing. |
| 3213 | The "seq" parameter is ignored if only one item of the selected data |
| 3214 | type, such as PLTE, is allowed. If "seq" is not -1, and multiple items |
| 3215 | are allowed for the data type identified in the mask, such as text or |
| 3216 | sPLT, only the n'th item in the structure is freed, where n is "seq". |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 3217 | |
Glenn Randers-Pehrson | 38e6e77 | 2000-04-09 19:06:13 -0500 | [diff] [blame] | 3218 | The default behavior is only to free data that was allocated internally |
| 3219 | 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] | 3220 | or so that it will free data that was allocated by the user with png_malloc() |
| 3221 | 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] | 3222 | |
| 3223 | png_data_freer(png_ptr, info_ptr, freer, mask) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3224 | |
Glenn Randers-Pehrson | 1ef65b6 | 2000-05-12 06:19:53 -0500 | [diff] [blame] | 3225 | freer - one of |
| 3226 | PNG_DESTROY_WILL_FREE_DATA |
| 3227 | PNG_SET_WILL_FREE_DATA |
| 3228 | PNG_USER_WILL_FREE_DATA |
Glenn Randers-Pehrson | 38e6e77 | 2000-04-09 19:06:13 -0500 | [diff] [blame] | 3229 | |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3230 | mask - which data elements are affected |
| 3231 | same choices as in png_free_data() |
| 3232 | |
Glenn Randers-Pehrson | 38e6e77 | 2000-04-09 19:06:13 -0500 | [diff] [blame] | 3233 | This function only affects data that has already been allocated. |
| 3234 | You can call this function after reading the PNG data but before calling |
| 3235 | any png_set_*() functions, to control whether the user or the png_set_*() |
| 3236 | function is responsible for freeing any existing data that might be present, |
| 3237 | 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] | 3238 | or png_destroy_*() is supposed to free the data. When the user assumes |
| 3239 | responsibility for libpng-allocated data, the application must use |
Glenn Randers-Pehrson | 1ef65b6 | 2000-05-12 06:19:53 -0500 | [diff] [blame] | 3240 | png_free() to free it, and when the user transfers responsibility to libpng |
| 3241 | 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] | 3242 | or png_zalloc() to allocate it. |
Glenn Randers-Pehrson | 6942d53 | 2000-05-01 09:31:54 -0500 | [diff] [blame] | 3243 | |
| 3244 | If you allocated your row_pointers in a single block, as suggested above in |
| 3245 | the description of the high level read interface, you must not transfer |
| 3246 | responsibility for freeing it to the png_set_rows or png_read_destroy function, |
| 3247 | 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] | 3248 | |
Glenn Randers-Pehrson | 1ef65b6 | 2000-05-12 06:19:53 -0500 | [diff] [blame] | 3249 | If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword |
| 3250 | separately, do not transfer responsibility for freeing text_ptr to libpng, |
| 3251 | because when libpng fills a png_text structure it combines these members with |
| 3252 | the key member, and png_free_data() will free only text_ptr.key. Similarly, |
| 3253 | if you transfer responsibility for free'ing text_ptr from libpng to your |
| 3254 | application, your application must not separately free those members. |
| 3255 | |
Glenn Randers-Pehrson | fc4a143 | 2000-05-17 17:39:34 -0500 | [diff] [blame] | 3256 | The png_free_data() function will turn off the "valid" flag for anything |
Glenn Randers-Pehrson | f210a05 | 2009-11-12 10:02:24 -0600 | [diff] [blame] | 3257 | it frees. If you need to turn the flag off for a chunk that was freed by |
| 3258 | your application instead of by libpng, you can use |
Glenn Randers-Pehrson | fc4a143 | 2000-05-17 17:39:34 -0500 | [diff] [blame] | 3259 | |
| 3260 | png_set_invalid(png_ptr, info_ptr, mask); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3261 | |
Glenn Randers-Pehrson | fc4a143 | 2000-05-17 17:39:34 -0500 | [diff] [blame] | 3262 | mask - identifies the chunks to be made invalid, |
Glenn Randers-Pehrson | ebd7f9a | 2006-10-19 09:37:56 -0500 | [diff] [blame] | 3263 | containing the bitwise OR of one or |
Glenn Randers-Pehrson | d56aca7 | 2000-11-23 11:51:42 -0600 | [diff] [blame] | 3264 | more of |
Glenn Randers-Pehrson | fc4a143 | 2000-05-17 17:39:34 -0500 | [diff] [blame] | 3265 | PNG_INFO_gAMA, PNG_INFO_sBIT, |
| 3266 | PNG_INFO_cHRM, PNG_INFO_PLTE, |
| 3267 | PNG_INFO_tRNS, PNG_INFO_bKGD, |
| 3268 | PNG_INFO_hIST, PNG_INFO_pHYs, |
| 3269 | PNG_INFO_oFFs, PNG_INFO_tIME, |
| 3270 | PNG_INFO_pCAL, PNG_INFO_sRGB, |
| 3271 | PNG_INFO_iCCP, PNG_INFO_sPLT, |
| 3272 | PNG_INFO_sCAL, PNG_INFO_IDAT |
| 3273 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3274 | For a more compact example of reading a PNG image, see the file example.c. |
| 3275 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 3276 | .SS Reading PNG files progressively |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3277 | |
| 3278 | The progressive reader is slightly different then the non-progressive |
| 3279 | reader. Instead of calling png_read_info(), png_read_rows(), and |
| 3280 | png_read_end(), you make one call to png_process_data(), which calls |
| 3281 | callbacks when it has the info, a row, or the end of the image. You |
| 3282 | set up these callbacks with png_set_progressive_read_fn(). You don't |
| 3283 | have to worry about the input/output functions of libpng, as you are |
| 3284 | giving the library the data directly in png_process_data(). I will |
| 3285 | assume that you have read the section on reading PNG files above, |
| 3286 | so I will only highlight the differences (although I will show |
| 3287 | all of the code). |
| 3288 | |
| 3289 | png_structp png_ptr; |
| 3290 | png_infop info_ptr; |
| 3291 | |
| 3292 | /* An example code fragment of how you would |
| 3293 | initialize the progressive reader in your |
| 3294 | application. */ |
| 3295 | int |
| 3296 | initialize_png_reader() |
| 3297 | { |
| 3298 | png_ptr = png_create_read_struct |
Glenn Randers-Pehrson | d0dce40 | 1998-05-09 10:02:29 -0500 | [diff] [blame] | 3299 | (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3300 | user_error_fn, user_warning_fn); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3301 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3302 | if (!png_ptr) |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 3303 | return (ERROR); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3304 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3305 | info_ptr = png_create_info_struct(png_ptr); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3306 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3307 | if (!info_ptr) |
| 3308 | { |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3309 | png_destroy_read_struct(&png_ptr, |
| 3310 | (png_infopp)NULL, (png_infopp)NULL); |
| 3311 | return (ERROR); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3312 | } |
| 3313 | |
Glenn Randers-Pehrson | 520a764 | 2000-03-21 05:13:06 -0600 | [diff] [blame] | 3314 | if (setjmp(png_jmpbuf(png_ptr))) |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3315 | { |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3316 | png_destroy_read_struct(&png_ptr, &info_ptr, |
| 3317 | (png_infopp)NULL); |
| 3318 | return (ERROR); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3319 | } |
| 3320 | |
| 3321 | /* This one's new. You can provide functions |
| 3322 | to be called when the header info is valid, |
| 3323 | when each row is completed, and when the image |
| 3324 | is finished. If you aren't using all functions, |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 3325 | you can specify NULL parameters. Even when all |
| 3326 | three functions are NULL, you need to call |
| 3327 | png_set_progressive_read_fn(). You can use |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3328 | any struct as the user_ptr (cast to a void pointer |
| 3329 | for the function call), and retrieve the pointer |
| 3330 | from inside the callbacks using the function |
| 3331 | |
| 3332 | png_get_progressive_ptr(png_ptr); |
| 3333 | |
| 3334 | which will return a void pointer, which you have |
| 3335 | to cast appropriately. |
| 3336 | */ |
| 3337 | png_set_progressive_read_fn(png_ptr, (void *)user_ptr, |
| 3338 | info_callback, row_callback, end_callback); |
| 3339 | |
| 3340 | return 0; |
| 3341 | } |
| 3342 | |
| 3343 | /* A code fragment that you call as you receive blocks |
| 3344 | of data */ |
| 3345 | int |
| 3346 | process_data(png_bytep buffer, png_uint_32 length) |
| 3347 | { |
Glenn Randers-Pehrson | 520a764 | 2000-03-21 05:13:06 -0600 | [diff] [blame] | 3348 | if (setjmp(png_jmpbuf(png_ptr))) |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3349 | { |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3350 | png_destroy_read_struct(&png_ptr, &info_ptr, |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3351 | (png_infopp)NULL); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3352 | return (ERROR); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3353 | } |
| 3354 | |
| 3355 | /* This one's new also. Simply give it a chunk |
| 3356 | of data from the file stream (in order, of |
| 3357 | course). On machines with segmented memory |
| 3358 | models machines, don't give it any more than |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 3359 | 64K. The library seems to run fine with sizes |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3360 | of 4K. Although you can give it much less if |
| 3361 | necessary (I assume you can give it chunks of |
| 3362 | 1 byte, I haven't tried less then 256 bytes |
| 3363 | yet). When this function returns, you may |
| 3364 | want to display any rows that were generated |
| 3365 | in the row callback if you don't already do |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 3366 | so there. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3367 | */ |
| 3368 | png_process_data(png_ptr, info_ptr, buffer, length); |
John Bowler | f19abd6 | 2011-01-22 18:29:24 -0600 | [diff] [blame] | 3369 | |
| 3370 | /* At this point you can call png_process_data_skip if |
| 3371 | you want to handle data the library will skip yourself; |
| 3372 | it simply returns the number of bytes to skip (and stops |
| 3373 | libpng skipping that number of bytes on the next |
| 3374 | png_process_data call). |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3375 | return 0; |
| 3376 | } |
| 3377 | |
| 3378 | /* This function is called (as set by |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 3379 | png_set_progressive_read_fn() above) when enough data |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3380 | has been supplied so all of the header has been |
| 3381 | read. |
| 3382 | */ |
| 3383 | void |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 3384 | info_callback(png_structp png_ptr, png_infop info) |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3385 | { |
| 3386 | /* Do any setup here, including setting any of |
| 3387 | the transformations mentioned in the Reading |
| 3388 | PNG files section. For now, you _must_ call |
| 3389 | either png_start_read_image() or |
| 3390 | png_read_update_info() after all the |
| 3391 | transformations are set (even if you don't set |
| 3392 | any). You may start getting rows before |
| 3393 | png_process_data() returns, so this is your |
| 3394 | last chance to prepare for that. |
Glenn Randers-Pehrson | 6e97410 | 2010-12-19 16:44:22 -0600 | [diff] [blame] | 3395 | |
| 3396 | This is where you turn on interlace handling, |
| 3397 | assuming you don't want to do it yourself. |
John Bowler | f19abd6 | 2011-01-22 18:29:24 -0600 | [diff] [blame] | 3398 | |
| 3399 | If you need to you can stop the processing of |
| 3400 | your original input data at this point by calling |
| 3401 | png_process_data_pause. This returns the number |
| 3402 | of unprocessed bytes from the last png_process_data |
| 3403 | call - it is up to you to ensure that the next call |
| 3404 | sees these bytes again. If you don't want to bother |
| 3405 | with this you can get libpng to cache the unread |
| 3406 | bytes by setting the 'save' parameter (see png.h) but |
| 3407 | then libpng will have to copy the data internally. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3408 | */ |
| 3409 | } |
| 3410 | |
| 3411 | /* This function is called when each row of image |
| 3412 | data is complete */ |
| 3413 | void |
| 3414 | row_callback(png_structp png_ptr, png_bytep new_row, |
Glenn Randers-Pehrson | e68f5a3 | 2001-05-14 09:20:53 -0500 | [diff] [blame] | 3415 | png_uint_32 row_num, int pass) |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3416 | { |
| 3417 | /* If the image is interlaced, and you turned |
| 3418 | on the interlace handler, this function will |
| 3419 | be called for every row in every pass. Some |
| 3420 | of these rows will not be changed from the |
| 3421 | previous pass. When the row is not changed, |
| 3422 | the new_row variable will be NULL. The rows |
| 3423 | and passes are called in order, so you don't |
| 3424 | really need the row_num and pass, but I'm |
| 3425 | supplying them because it may make your life |
| 3426 | easier. |
| 3427 | |
Glenn Randers-Pehrson | 6e97410 | 2010-12-19 16:44:22 -0600 | [diff] [blame] | 3428 | If you did not turn on interlace handling then |
| 3429 | the callback is called for each row of each |
| 3430 | sub-image when the image is interlaced. In this |
| 3431 | case 'row_num' is the row in the sub-image, not |
| 3432 | the row in the output image as it is in all other |
| 3433 | cases. |
| 3434 | |
| 3435 | For the non-NULL rows of interlaced images when |
| 3436 | you have switched on libpng interlace handling, |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3437 | you must call png_progressive_combine_row() |
| 3438 | passing in the row and the old row. You can |
| 3439 | call this function for NULL rows (it will just |
| 3440 | return) and for non-interlaced images (it just |
| 3441 | does the memcpy for you) if it will make the |
| 3442 | code easier. Thus, you can just do this for |
Glenn Randers-Pehrson | 6e97410 | 2010-12-19 16:44:22 -0600 | [diff] [blame] | 3443 | all cases if you switch on interlace handling; |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3444 | */ |
| 3445 | |
| 3446 | png_progressive_combine_row(png_ptr, old_row, |
| 3447 | new_row); |
| 3448 | |
| 3449 | /* where old_row is what was displayed for |
Glenn Randers-Pehrson | 345bc27 | 1998-06-14 14:43:31 -0500 | [diff] [blame] | 3450 | previously for the row. Note that the first |
| 3451 | pass (pass == 0, really) will completely cover |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3452 | the old row, so the rows do not have to be |
| 3453 | initialized. After the first pass (and only |
| 3454 | for interlaced images), you will have to pass |
| 3455 | the current row, and the function will combine |
| 3456 | the old row and the new row. |
John Bowler | f19abd6 | 2011-01-22 18:29:24 -0600 | [diff] [blame] | 3457 | |
| 3458 | You can also call png_process_data_pause in this |
| 3459 | callback - see above. |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 3460 | */ |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3461 | } |
| 3462 | |
| 3463 | void |
| 3464 | end_callback(png_structp png_ptr, png_infop info) |
| 3465 | { |
| 3466 | /* This function is called after the whole image |
| 3467 | has been read, including any chunks after the |
| 3468 | image (up to and including the IEND). You |
| 3469 | will usually have the same info chunk as you |
| 3470 | had in the header, although some data may have |
| 3471 | been added to the comments and time fields. |
| 3472 | |
| 3473 | Most people won't do much here, perhaps setting |
| 3474 | a flag that marks the image as finished. |
| 3475 | */ |
| 3476 | } |
| 3477 | |
Glenn Randers-Pehrson | 896239b | 1998-04-21 15:03:57 -0500 | [diff] [blame] | 3478 | |
| 3479 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 3480 | .SH IV. Writing |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3481 | |
| 3482 | Much of this is very similar to reading. However, everything of |
| 3483 | importance is repeated here, so you won't have to constantly look |
| 3484 | back up in the reading section to understand writing. |
| 3485 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 3486 | .SS Setup |
| 3487 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3488 | You will want to do the I/O initialization before you get into libpng, |
| 3489 | so if it doesn't work, you don't have anything to undo. If you are not |
| 3490 | using the standard I/O functions, you will need to replace them with |
| 3491 | custom writing functions. See the discussion under Customizing libpng. |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 3492 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3493 | FILE *fp = fopen(file_name, "wb"); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3494 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3495 | if (!fp) |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 3496 | return (ERROR); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3497 | |
| 3498 | Next, png_struct and png_info need to be allocated and initialized. |
| 3499 | As these can be both relatively large, you may not want to store these |
| 3500 | 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] | 3501 | will want to check if they return NULL. If you are also reading, |
| 3502 | you won't want to name your read structure and your write structure |
| 3503 | both "png_ptr"; you can call them anything you like, such as |
| 3504 | "read_ptr" and "write_ptr". Look at pngtest.c, for example. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3505 | |
| 3506 | png_structp png_ptr = png_create_write_struct |
Glenn Randers-Pehrson | d0dce40 | 1998-05-09 10:02:29 -0500 | [diff] [blame] | 3507 | (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3508 | user_error_fn, user_warning_fn); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3509 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3510 | if (!png_ptr) |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 3511 | return (ERROR); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3512 | |
| 3513 | png_infop info_ptr = png_create_info_struct(png_ptr); |
| 3514 | if (!info_ptr) |
| 3515 | { |
| 3516 | png_destroy_write_struct(&png_ptr, |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3517 | (png_infopp)NULL); |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 3518 | return (ERROR); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3519 | } |
| 3520 | |
Glenn Randers-Pehrson | f7d1a17 | 1998-06-06 15:31:35 -0500 | [diff] [blame] | 3521 | If you want to use your own memory allocation routines, |
| 3522 | define PNG_USER_MEM_SUPPORTED and use |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 3523 | png_create_write_struct_2() instead of png_create_write_struct(): |
Glenn Randers-Pehrson | f7d1a17 | 1998-06-06 15:31:35 -0500 | [diff] [blame] | 3524 | |
| 3525 | png_structp png_ptr = png_create_write_struct_2 |
| 3526 | (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, |
| 3527 | user_error_fn, user_warning_fn, (png_voidp) |
| 3528 | user_mem_ptr, user_malloc_fn, user_free_fn); |
| 3529 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3530 | After you have these structures, you will need to set up the |
| 3531 | error handling. When libpng encounters an error, it expects to |
| 3532 | longjmp() back to your routine. Therefore, you will need to call |
Glenn Randers-Pehrson | 520a764 | 2000-03-21 05:13:06 -0600 | [diff] [blame] | 3533 | setjmp() and pass the png_jmpbuf(png_ptr). If you |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3534 | write the file from different routines, you will need to update |
Glenn Randers-Pehrson | 520a764 | 2000-03-21 05:13:06 -0600 | [diff] [blame] | 3535 | the png_jmpbuf(png_ptr) every time you enter a new routine that will |
| 3536 | call a png_*() function. See your documentation of setjmp/longjmp |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3537 | for your compiler for more information on setjmp/longjmp. See |
| 3538 | the discussion on libpng error handling in the Customizing Libpng |
| 3539 | section below for more information on the libpng error handling. |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 3540 | |
Glenn Randers-Pehrson | 520a764 | 2000-03-21 05:13:06 -0600 | [diff] [blame] | 3541 | if (setjmp(png_jmpbuf(png_ptr))) |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 3542 | { |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3543 | png_destroy_write_struct(&png_ptr, &info_ptr); |
Glenn Randers-Pehrson | 104622b | 2000-05-29 08:58:03 -0500 | [diff] [blame] | 3544 | fclose(fp); |
| 3545 | return (ERROR); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3546 | } |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 3547 | ... |
| 3548 | return; |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3549 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 3550 | If you would rather avoid the complexity of setjmp/longjmp issues, |
Glenn Randers-Pehrson | 54ac9a9 | 2010-04-02 17:06:22 -0500 | [diff] [blame] | 3551 | you can compile libpng with PNG_NO_SETJMP, in which case |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 3552 | errors will result in a call to PNG_ABORT() which defaults to abort(). |
| 3553 | |
Glenn Randers-Pehrson | 54ac9a9 | 2010-04-02 17:06:22 -0500 | [diff] [blame] | 3554 | You can #define PNG_ABORT() to a function that does something |
| 3555 | more useful than abort(), as long as your function does not |
| 3556 | return. |
| 3557 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3558 | Now you need to set up the output code. The default for libpng is to |
| 3559 | use the C function fwrite(). If you use this, you will need to pass a |
| 3560 | valid FILE * in the function png_init_io(). Be sure that the file is |
| 3561 | opened in binary mode. Again, if you wish to handle writing data in |
| 3562 | another way, see the discussion on libpng I/O handling in the Customizing |
| 3563 | Libpng section below. |
| 3564 | |
| 3565 | png_init_io(png_ptr, fp); |
| 3566 | |
Glenn Randers-Pehrson | d60b8fa | 2006-04-20 21:31:14 -0500 | [diff] [blame] | 3567 | If you are embedding your PNG into a datastream such as MNG, and don't |
| 3568 | want libpng to write the 8-byte signature, or if you have already |
| 3569 | written the signature in your application, use |
| 3570 | |
| 3571 | png_set_sig_bytes(png_ptr, 8); |
| 3572 | |
| 3573 | to inform libpng that it should not write a signature. |
| 3574 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 3575 | .SS Write callbacks |
| 3576 | |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 3577 | At this point, you can set up a callback function that will be |
| 3578 | called after each row has been written, which you can use to control |
| 3579 | a progress meter or the like. It's demonstrated in pngtest.c. |
| 3580 | You must supply a function |
| 3581 | |
Glenn Randers-Pehrson | 81ce889 | 2011-01-24 08:04:37 -0600 | [diff] [blame] | 3582 | void write_row_callback(png_structp png_ptr, png_uint_32 row, |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 3583 | int pass); |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 3584 | { |
| 3585 | /* put your code here */ |
| 3586 | } |
| 3587 | |
| 3588 | (You can give it another name that you like instead of "write_row_callback") |
| 3589 | |
| 3590 | To inform libpng about your function, use |
| 3591 | |
| 3592 | png_set_write_status_fn(png_ptr, write_row_callback); |
| 3593 | |
John Bowler | 59010e5 | 2011-02-16 06:16:31 -0600 | [diff] [blame] | 3594 | When this function is called the row has already been completely processed and |
| 3595 | it has also been written out. The 'row' and 'pass' refer to the next row to be |
| 3596 | handled. For the |
| 3597 | non-interlaced case the row that was just handled is simply one less than the |
| 3598 | passed in row number, and pass will always be 0. For the interlaced case the |
| 3599 | same applies unless the row value is 0, in which case the row just handled was |
| 3600 | the last one from one of the preceding passes. Because interlacing may skip a |
| 3601 | pass you cannot be sure that the preceding pass is just 'pass-1', if you really |
| 3602 | need to know what the last pass is record (row,pass) from the callback and use |
| 3603 | the last recorded value each time. |
| 3604 | |
| 3605 | As with the user transform you can find the output row using the |
| 3606 | PNG_ROW_FROM_PASS_ROW macro. |
| 3607 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3608 | You now have the option of modifying how the compression library will |
| 3609 | run. The following functions are mainly for testing, but may be useful |
| 3610 | in some cases, like if you need to write PNG files extremely fast and |
| 3611 | are willing to give up some compression, or if you want to get the |
| 3612 | maximum possible compression at the expense of slower writing. If you |
| 3613 | have no special needs in this area, let the library do what it wants by |
| 3614 | not calling this function at all, as it has been tuned to deliver a good |
| 3615 | speed/compression ratio. The second parameter to png_set_filter() is |
Glenn Randers-Pehrson | 408b421 | 2000-12-18 09:33:57 -0600 | [diff] [blame] | 3616 | the filter method, for which the only valid values are 0 (as of the |
| 3617 | July 1999 PNG specification, version 1.2) or 64 (if you are writing |
| 3618 | a PNG datastream that is to be embedded in a MNG datastream). The third |
| 3619 | parameter is a flag that indicates which filter type(s) are to be tested |
Glenn Randers-Pehrson | f210a05 | 2009-11-12 10:02:24 -0600 | [diff] [blame] | 3620 | for each scanline. See the PNG specification for details on the specific |
| 3621 | filter types. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3622 | |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 3623 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3624 | /* turn on or off filtering, and/or choose |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 3625 | specific filters. You can use either a single |
Glenn Randers-Pehrson | ebd7f9a | 2006-10-19 09:37:56 -0500 | [diff] [blame] | 3626 | PNG_FILTER_VALUE_NAME or the bitwise OR of one |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3627 | or more PNG_FILTER_NAME masks. |
| 3628 | */ |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3629 | png_set_filter(png_ptr, 0, |
Glenn Randers-Pehrson | 228bd39 | 2000-04-23 23:14:02 -0500 | [diff] [blame] | 3630 | PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE | |
| 3631 | PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | |
| 3632 | PNG_FILTER_UP | PNG_FILTER_VALUE_UP | |
Glenn Randers-Pehrson | 7654682 | 2009-05-16 07:25:42 -0500 | [diff] [blame] | 3633 | PNG_FILTER_AVG | PNG_FILTER_VALUE_AVG | |
Glenn Randers-Pehrson | 228bd39 | 2000-04-23 23:14:02 -0500 | [diff] [blame] | 3634 | PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH| |
| 3635 | PNG_ALL_FILTERS); |
| 3636 | |
Glenn Randers-Pehrson | 6e97410 | 2010-12-19 16:44:22 -0600 | [diff] [blame] | 3637 | If an application wants to start and stop using particular filters during |
| 3638 | compression, it should start out with all of the filters (to ensure that |
| 3639 | the previous row of pixels will be stored in case it's needed later), |
| 3640 | and then add and remove them after the start of compression. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3641 | |
Glenn Randers-Pehrson | 408b421 | 2000-12-18 09:33:57 -0600 | [diff] [blame] | 3642 | If you are writing a PNG datastream that is to be embedded in a MNG |
| 3643 | datastream, the second parameter can be either 0 or 64. |
| 3644 | |
Glenn Randers-Pehrson | a77ef62 | 2000-02-18 13:48:52 -0600 | [diff] [blame] | 3645 | The png_set_compression_*() functions interface to the zlib compression |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3646 | library, and should mostly be ignored unless you really know what you are |
| 3647 | doing. The only generally useful call is png_set_compression_level() |
| 3648 | 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] | 3649 | data. See the Compression Library (zlib.h and algorithm.txt, distributed |
| 3650 | with zlib) for details on the compression levels. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3651 | |
Glenn Randers-Pehrson | 38734ee | 2011-03-03 06:23:31 -0600 | [diff] [blame] | 3652 | #include zlib.h |
| 3653 | |
Glenn Randers-Pehrson | a45f47c | 2011-04-01 15:31:26 -0500 | [diff] [blame] | 3654 | /* Set the zlib compression level */ |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3655 | png_set_compression_level(png_ptr, |
| 3656 | Z_BEST_COMPRESSION); |
| 3657 | |
Glenn Randers-Pehrson | a45f47c | 2011-04-01 15:31:26 -0500 | [diff] [blame] | 3658 | /* Set other zlib parameters for compressing IDAT */ |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3659 | png_set_compression_mem_level(png_ptr, 8); |
| 3660 | png_set_compression_strategy(png_ptr, |
| 3661 | Z_DEFAULT_STRATEGY); |
| 3662 | png_set_compression_window_bits(png_ptr, 15); |
| 3663 | png_set_compression_method(png_ptr, 8); |
Glenn Randers-Pehrson | 228bd39 | 2000-04-23 23:14:02 -0500 | [diff] [blame] | 3664 | png_set_compression_buffer_size(png_ptr, 8192) |
| 3665 | |
Glenn Randers-Pehrson | a45f47c | 2011-04-01 15:31:26 -0500 | [diff] [blame] | 3666 | /* Set zlib parameters for text compression |
| 3667 | * If you don't call these, the parameters |
| 3668 | * fall back on those defined for IDAT chunks |
| 3669 | */ |
Glenn Randers-Pehrson | 8eb8833 | 2011-04-01 00:16:50 -0500 | [diff] [blame] | 3670 | png_set_text_compression_mem_level(png_ptr, 8); |
| 3671 | png_set_text_compression_strategy(png_ptr, |
| 3672 | Z_DEFAULT_STRATEGY); |
| 3673 | png_set_text_compression_window_bits(png_ptr, 15); |
| 3674 | png_set_text_compression_method(png_ptr, 8); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3675 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 3676 | .SS Setting the contents of info for output |
| 3677 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3678 | You now need to fill in the png_info structure with all the data you |
| 3679 | wish to write before the actual image. Note that the only thing you |
| 3680 | 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] | 3681 | 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] | 3682 | the latest PNG specification for more information on that. If you |
| 3683 | wish to write them before the image, fill them in now, and flag that |
| 3684 | data as being valid. If you want to wait until after the data, don't |
| 3685 | fill them until png_write_end(). For all the fields in png_info and |
| 3686 | their data types, see png.h. For explanations of what the fields |
| 3687 | contain, see the PNG specification. |
| 3688 | |
| 3689 | Some of the more important parts of the png_info are: |
| 3690 | |
| 3691 | png_set_IHDR(png_ptr, info_ptr, width, height, |
| 3692 | bit_depth, color_type, interlace_type, |
Glenn Randers-Pehrson | 408b421 | 2000-12-18 09:33:57 -0600 | [diff] [blame] | 3693 | compression_type, filter_method) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3694 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3695 | width - holds the width of the image |
| 3696 | in pixels (up to 2^31). |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3697 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3698 | height - holds the height of the image |
| 3699 | in pixels (up to 2^31). |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3700 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3701 | bit_depth - holds the bit depth of one of the |
| 3702 | image channels. |
| 3703 | (valid values are 1, 2, 4, 8, 16 |
| 3704 | and depend also on the |
| 3705 | color_type. See also significant |
| 3706 | bits (sBIT) below). |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3707 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3708 | color_type - describes which color/alpha |
| 3709 | channels are present. |
| 3710 | PNG_COLOR_TYPE_GRAY |
| 3711 | (bit depths 1, 2, 4, 8, 16) |
| 3712 | PNG_COLOR_TYPE_GRAY_ALPHA |
| 3713 | (bit depths 8, 16) |
| 3714 | PNG_COLOR_TYPE_PALETTE |
| 3715 | (bit depths 1, 2, 4, 8) |
| 3716 | PNG_COLOR_TYPE_RGB |
| 3717 | (bit_depths 8, 16) |
| 3718 | PNG_COLOR_TYPE_RGB_ALPHA |
| 3719 | (bit_depths 8, 16) |
| 3720 | |
| 3721 | PNG_COLOR_MASK_PALETTE |
| 3722 | PNG_COLOR_MASK_COLOR |
| 3723 | PNG_COLOR_MASK_ALPHA |
| 3724 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 3725 | interlace_type - PNG_INTERLACE_NONE or |
| 3726 | PNG_INTERLACE_ADAM7 |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3727 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3728 | compression_type - (must be |
| 3729 | PNG_COMPRESSION_TYPE_DEFAULT) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3730 | |
Glenn Randers-Pehrson | 408b421 | 2000-12-18 09:33:57 -0600 | [diff] [blame] | 3731 | filter_method - (must be PNG_FILTER_TYPE_DEFAULT |
| 3732 | or, if you are writing a PNG to |
| 3733 | be embedded in a MNG datastream, |
| 3734 | can also be |
| 3735 | PNG_INTRAPIXEL_DIFFERENCING) |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3736 | |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 3737 | If you call png_set_IHDR(), the call must appear before any of the |
Glenn Randers-Pehrson | d60c886 | 2009-06-15 21:56:14 -0500 | [diff] [blame] | 3738 | other png_set_*() functions, because they might require access to some of |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 3739 | the IHDR settings. The remaining png_set_*() functions can be called |
| 3740 | in any order. |
| 3741 | |
Glenn Randers-Pehrson | b5444a1 | 2009-06-08 08:36:19 -0500 | [diff] [blame] | 3742 | If you wish, you can reset the compression_type, interlace_type, or |
| 3743 | filter_method later by calling png_set_IHDR() again; if you do this, the |
| 3744 | width, height, bit_depth, and color_type must be the same in each call. |
Glenn Randers-Pehrson | 424c985 | 2009-06-02 13:45:15 -0500 | [diff] [blame] | 3745 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3746 | png_set_PLTE(png_ptr, info_ptr, palette, |
| 3747 | num_palette); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3748 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3749 | palette - the palette for the file |
| 3750 | (array of png_color) |
| 3751 | num_palette - number of entries in the palette |
| 3752 | |
Glenn Randers-Pehrson | 8d0bc0f | 2011-01-25 22:15:58 -0600 | [diff] [blame] | 3753 | png_set_gAMA(png_ptr, info_ptr, file_gamma); |
| 3754 | png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3755 | |
Glenn Randers-Pehrson | 8d0bc0f | 2011-01-25 22:15:58 -0600 | [diff] [blame] | 3756 | file_gamma - the gamma at which the image was |
| 3757 | created (PNG_INFO_gAMA) |
| 3758 | |
| 3759 | int_file_gamma - 100,000 times the gamma at which |
| 3760 | the image was created |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3761 | |
John Bowler | bbd17bd | 2011-08-25 17:48:18 -0500 | [diff] [blame] | 3762 | png_set_cHRM(png_ptr, info_ptr, white_x, white_y, red_x, red_y, |
| 3763 | green_x, green_y, blue_x, blue_y) |
| 3764 | png_set_cHRM_XYZ(png_ptr, info_ptr, red_X, red_Y, red_Z, green_X, |
| 3765 | green_Y, green_Z, blue_X, blue_Y, blue_Z) |
| 3766 | png_set_cHRM_fixed(png_ptr, info_ptr, int_white_x, int_white_y, |
| 3767 | int_red_x, int_red_y, int_green_x, int_green_y, |
| 3768 | int_blue_x, int_blue_y) |
| 3769 | png_set_cHRM_XYZ_fixed(png_ptr, info_ptr, int_red_X, int_red_Y, |
| 3770 | int_red_Z, int_green_X, int_green_Y, int_green_Z, |
| 3771 | int_blue_X, int_blue_Y, int_blue_Z) |
| 3772 | |
| 3773 | {white,red,green,blue}_{x,y} |
| 3774 | A color space encoding specified using the chromaticities |
| 3775 | of the end points and the white point. |
| 3776 | |
| 3777 | {red,green,blue}_{X,Y,Z} |
| 3778 | A color space encoding specified using the encoding end |
| 3779 | points - the CIE tristimulus specification of the intended |
| 3780 | color of the red, green and blue channels in the PNG RGB |
| 3781 | data. The white point is simply the sum of the three end |
| 3782 | points. |
| 3783 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3784 | png_set_sRGB(png_ptr, info_ptr, srgb_intent); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3785 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3786 | srgb_intent - the rendering intent |
| 3787 | (PNG_INFO_sRGB) The presence of |
| 3788 | the sRGB chunk means that the pixel |
| 3789 | data is in the sRGB color space. |
| 3790 | This chunk also implies specific |
| 3791 | values of gAMA and cHRM. Rendering |
| 3792 | intent is the CSS-1 property that |
| 3793 | has been defined by the International |
| 3794 | Color Consortium |
| 3795 | (http://www.color.org). |
| 3796 | It can be one of |
Glenn Randers-Pehrson | 5379b24 | 1999-11-27 10:22:33 -0600 | [diff] [blame] | 3797 | PNG_sRGB_INTENT_SATURATION, |
| 3798 | PNG_sRGB_INTENT_PERCEPTUAL, |
| 3799 | PNG_sRGB_INTENT_ABSOLUTE, or |
| 3800 | PNG_sRGB_INTENT_RELATIVE. |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 3801 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3802 | |
| 3803 | png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, |
| 3804 | srgb_intent); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3805 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3806 | srgb_intent - the rendering intent |
| 3807 | (PNG_INFO_sRGB) The presence of the |
| 3808 | sRGB chunk means that the pixel |
| 3809 | data is in the sRGB color space. |
| 3810 | This function also causes gAMA and |
| 3811 | cHRM chunks with the specific values |
| 3812 | that are consistent with sRGB to be |
| 3813 | written. |
| 3814 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 3815 | png_set_iCCP(png_ptr, info_ptr, name, compression_type, |
Glenn Randers-Pehrson | 4a5a1ec | 2011-01-15 11:43:28 -0600 | [diff] [blame] | 3816 | profile, proflen); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3817 | |
Glenn Randers-Pehrson | 4a5a1ec | 2011-01-15 11:43:28 -0600 | [diff] [blame] | 3818 | name - The profile name. |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3819 | |
Glenn Randers-Pehrson | 4a5a1ec | 2011-01-15 11:43:28 -0600 | [diff] [blame] | 3820 | compression_type - The compression type; always |
| 3821 | PNG_COMPRESSION_TYPE_BASE for PNG 1.0. |
| 3822 | You may give NULL to this argument to |
| 3823 | ignore it. |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3824 | |
Glenn Randers-Pehrson | 4a5a1ec | 2011-01-15 11:43:28 -0600 | [diff] [blame] | 3825 | profile - International Color Consortium color |
| 3826 | profile data. May contain NULs. |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3827 | |
Glenn Randers-Pehrson | 4a5a1ec | 2011-01-15 11:43:28 -0600 | [diff] [blame] | 3828 | proflen - length of profile data in bytes. |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 3829 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3830 | png_set_sBIT(png_ptr, info_ptr, sig_bit); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3831 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3832 | sig_bit - the number of significant bits for |
| 3833 | (PNG_INFO_sBIT) each of the gray, red, |
| 3834 | green, and blue channels, whichever are |
| 3835 | appropriate for the given color type |
| 3836 | (png_color_16) |
| 3837 | |
Glenn Randers-Pehrson | 866b62a | 2009-08-08 16:33:14 -0500 | [diff] [blame] | 3838 | png_set_tRNS(png_ptr, info_ptr, trans_alpha, |
| 3839 | num_trans, trans_color); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3840 | |
Glenn Randers-Pehrson | 866b62a | 2009-08-08 16:33:14 -0500 | [diff] [blame] | 3841 | trans_alpha - array of alpha (transparency) |
| 3842 | entries for palette (PNG_INFO_tRNS) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3843 | |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 3844 | num_trans - number of transparent entries |
| 3845 | (PNG_INFO_tRNS) |
| 3846 | |
Glenn Randers-Pehrson | b5444a1 | 2009-06-08 08:36:19 -0500 | [diff] [blame] | 3847 | trans_color - graylevel or color sample values |
| 3848 | (in order red, green, blue) of the |
| 3849 | single transparent color for |
Glenn Randers-Pehrson | 3d5a520 | 2000-07-01 15:37:28 -0500 | [diff] [blame] | 3850 | non-paletted images (PNG_INFO_tRNS) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3851 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3852 | png_set_hIST(png_ptr, info_ptr, hist); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3853 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3854 | hist - histogram of palette (array of |
Glenn Randers-Pehrson | 8d0bc0f | 2011-01-25 22:15:58 -0600 | [diff] [blame] | 3855 | png_uint_16) (PNG_INFO_hIST) |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3856 | |
| 3857 | png_set_tIME(png_ptr, info_ptr, mod_time); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3858 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3859 | mod_time - time image was last modified |
| 3860 | (PNG_VALID_tIME) |
| 3861 | |
| 3862 | png_set_bKGD(png_ptr, info_ptr, background); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3863 | |
Glenn Randers-Pehrson | ab38979 | 2011-07-09 19:35:22 -0500 | [diff] [blame] | 3864 | background - background color (of type |
| 3865 | png_color_16p) (PNG_VALID_bKGD) |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3866 | |
| 3867 | png_set_text(png_ptr, info_ptr, text_ptr, num_text); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3868 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3869 | text_ptr - array of png_text holding image |
| 3870 | comments |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3871 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 3872 | text_ptr[i].compression - type of compression used |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 3873 | on "text" PNG_TEXT_COMPRESSION_NONE |
| 3874 | PNG_TEXT_COMPRESSION_zTXt |
| 3875 | PNG_ITXT_COMPRESSION_NONE |
| 3876 | PNG_ITXT_COMPRESSION_zTXt |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 3877 | text_ptr[i].key - keyword for comment. Must contain |
| 3878 | 1-79 characters. |
| 3879 | text_ptr[i].text - text comments for current |
| 3880 | keyword. Can be NULL or empty. |
| 3881 | text_ptr[i].text_length - length of text string, |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 3882 | after decompression, 0 for iTXt |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 3883 | text_ptr[i].itxt_length - length of itxt string, |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 3884 | after decompression, 0 for tEXt/zTXt |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 3885 | text_ptr[i].lang - language of comment (NULL or |
| 3886 | empty for unknown). |
| 3887 | text_ptr[i].translated_keyword - keyword in UTF-8 (NULL |
| 3888 | or empty for unknown). |
Glenn Randers-Pehrson | 8f5846f | 2009-10-31 21:31:08 -0500 | [diff] [blame] | 3889 | Note that the itxt_length, lang, and lang_key |
| 3890 | members of the text_ptr structure only exist |
| 3891 | when the library is built with iTXt chunk support. |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 3892 | Prior to libpng-1.4.0 the library was built by default |
| 3893 | without iTXt support. |
Glenn Randers-Pehrson | 8f5846f | 2009-10-31 21:31:08 -0500 | [diff] [blame] | 3894 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 3895 | num_text - number of comments |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3896 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 3897 | png_set_sPLT(png_ptr, info_ptr, &palette_ptr, |
| 3898 | num_spalettes); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3899 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 3900 | palette_ptr - array of png_sPLT_struct structures |
| 3901 | to be added to the list of palettes |
| 3902 | in the info structure. |
| 3903 | num_spalettes - number of palette structures to be |
| 3904 | added. |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 3905 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3906 | png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, |
| 3907 | unit_type); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3908 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3909 | offset_x - positive offset from the left |
| 3910 | edge of the screen |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3911 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3912 | offset_y - positive offset from the top |
| 3913 | edge of the screen |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3914 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3915 | unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER |
| 3916 | |
| 3917 | png_set_pHYs(png_ptr, info_ptr, res_x, res_y, |
| 3918 | unit_type); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3919 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3920 | res_x - pixels/unit physical resolution |
| 3921 | in x direction |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3922 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3923 | res_y - pixels/unit physical resolution |
| 3924 | in y direction |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3925 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 3926 | unit_type - PNG_RESOLUTION_UNKNOWN, |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3927 | PNG_RESOLUTION_METER |
| 3928 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 3929 | png_set_sCAL(png_ptr, info_ptr, unit, width, height) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3930 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 3931 | unit - physical scale units (an integer) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3932 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 3933 | width - width of a pixel in physical scale units |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3934 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 3935 | height - height of a pixel in physical scale units |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 3936 | (width and height are doubles) |
| 3937 | |
| 3938 | png_set_sCAL_s(png_ptr, info_ptr, unit, width, height) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3939 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 3940 | unit - physical scale units (an integer) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3941 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 3942 | width - width of a pixel in physical scale units |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 3943 | expressed as a string |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3944 | |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 3945 | height - height of a pixel in physical scale units |
| 3946 | (width and height are strings like "2.54") |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 3947 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 3948 | png_set_unknown_chunks(png_ptr, info_ptr, &unknowns, |
| 3949 | num_unknowns) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3950 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 3951 | unknowns - array of png_unknown_chunk |
| 3952 | structures holding unknown chunks |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 3953 | unknowns[i].name - name of unknown chunk |
| 3954 | unknowns[i].data - data of unknown chunk |
Glenn Randers-Pehrson | 4accabb | 2000-04-14 14:20:47 -0500 | [diff] [blame] | 3955 | unknowns[i].size - size of unknown chunk's data |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 3956 | unknowns[i].location - position to write chunk in file |
| 3957 | 0: do not write chunk |
| 3958 | PNG_HAVE_IHDR: before PLTE |
| 3959 | PNG_HAVE_PLTE: before IDAT |
| 3960 | PNG_AFTER_IDAT: after IDAT |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 3961 | |
| 3962 | The "location" member is set automatically according to |
| 3963 | what part of the output file has already been written. |
| 3964 | You can change its value after calling png_set_unknown_chunks() |
| 3965 | as demonstrated in pngtest.c. Within each of the "locations", |
| 3966 | the chunks are sequenced according to their position in the |
| 3967 | structure (that is, the value of "i", which is the order in which |
| 3968 | the chunk was either read from the input file or defined with |
| 3969 | png_set_unknown_chunks). |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3970 | |
| 3971 | A quick word about text and num_text. text is an array of png_text |
| 3972 | 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] | 3973 | Each png_text structure holds a language code, a keyword, a text value, |
| 3974 | and a compression type. |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 3975 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3976 | The compression types have the same valid numbers as the compression |
| 3977 | types of the image data. Currently, the only valid number is zero. |
| 3978 | However, you can store text either compressed or uncompressed, unlike |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 3979 | 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] | 3980 | text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE. |
Glenn Randers-Pehrson | 228bd39 | 2000-04-23 23:14:02 -0500 | [diff] [blame] | 3981 | Because tEXt and zTXt chunks don't have a language field, if you |
| 3982 | specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt |
| 3983 | any language code or translated keyword will not be written out. |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 3984 | |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 3985 | Until text gets around a few hundred bytes, it is not worth compressing it. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3986 | After the text has been written out to the file, the compression type |
| 3987 | is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR, |
| 3988 | so that it isn't written out again at the end (in case you are calling |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3989 | png_write_end() with the same struct). |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3990 | |
| 3991 | The keywords that are given in the PNG Specification are: |
| 3992 | |
| 3993 | Title Short (one line) title or |
| 3994 | caption for image |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3995 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3996 | Author Name of image's creator |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3997 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 3998 | Description Description of image (possibly long) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 3999 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4000 | Copyright Copyright notice |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4001 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4002 | Creation Time Time of original image creation |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 4003 | (usually RFC 1123 format, see below) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4004 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4005 | Software Software used to create the image |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4006 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4007 | Disclaimer Legal disclaimer |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4008 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4009 | Warning Warning of nature of content |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4010 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4011 | Source Device used to create the image |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4012 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4013 | Comment Miscellaneous comment; conversion |
| 4014 | from other image format |
| 4015 | |
| 4016 | The keyword-text pairs work like this. Keywords should be short |
| 4017 | simple descriptions of what the comment is about. Some typical |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 4018 | keywords are found in the PNG specification, as is some recommendations |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4019 | on keywords. You can repeat keywords in a file. You can even write |
| 4020 | some text before the image and some after. For example, you may want |
| 4021 | to put a description of the image before the image, but leave the |
| 4022 | disclaimer until after, so viewers working over modem connections |
| 4023 | don't have to wait for the disclaimer to go over the modem before |
| 4024 | they start seeing the image. Finally, keywords should be full |
| 4025 | words, not abbreviations. Keywords and text are in the ISO 8859-1 |
| 4026 | (Latin-1) character set (a superset of regular ASCII) and can not |
| 4027 | contain NUL characters, and should not contain control or other |
| 4028 | unprintable characters. To make the comments widely readable, stick |
| 4029 | with basic ASCII, and avoid machine specific character set extensions |
| 4030 | like the IBM-PC character set. The keyword must be present, but |
| 4031 | you can leave off the text string on non-compressed pairs. |
| 4032 | Compressed pairs must have a text string, as only the text string |
| 4033 | is compressed anyway, so the compression would be meaningless. |
| 4034 | |
| 4035 | PNG supports modification time via the png_time structure. Two |
Glenn Randers-Pehrson | 6942d53 | 2000-05-01 09:31:54 -0500 | [diff] [blame] | 4036 | conversion routines are provided, png_convert_from_time_t() for |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4037 | time_t and png_convert_from_struct_tm() for struct tm. The |
| 4038 | time_t routine uses gmtime(). You don't have to use either of |
| 4039 | these, but if you wish to fill in the png_time structure directly, |
| 4040 | you should provide the time in universal time (GMT) if possible |
| 4041 | 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] | 4042 | 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] | 4043 | that months start with 1. |
| 4044 | |
| 4045 | If you want to store the time of the original image creation, you should |
| 4046 | use a plain tEXt chunk with the "Creation Time" keyword. This is |
| 4047 | necessary because the "creation time" of a PNG image is somewhat vague, |
| 4048 | depending on whether you mean the PNG file, the time the image was |
| 4049 | created in a non-PNG format, a still photo from which the image was |
| 4050 | scanned, or possibly the subject matter itself. In order to facilitate |
| 4051 | machine-readable dates, it is recommended that the "Creation Time" |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 4052 | 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] | 4053 | although this isn't a requirement. Unlike the tIME chunk, the |
| 4054 | "Creation Time" tEXt chunk is not expected to be automatically changed |
| 4055 | by the software. To facilitate the use of RFC 1123 dates, a function |
| 4056 | png_convert_to_rfc1123(png_timep) is provided to convert from PNG |
| 4057 | time to an RFC 1123 format string. |
| 4058 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4059 | .SS Writing unknown chunks |
| 4060 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 4061 | You can use the png_set_unknown_chunks function to queue up chunks |
| 4062 | for writing. You give it a chunk name, raw data, and a size; that's |
| 4063 | all there is to it. The chunks will be written by the next following |
| 4064 | png_write_info_before_PLTE, png_write_info, or png_write_end function. |
| 4065 | Any chunks previously read into the info structure's unknown-chunk |
| 4066 | list will also be written out in a sequence that satisfies the PNG |
| 4067 | specification's ordering rules. |
| 4068 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4069 | .SS The high-level write interface |
| 4070 | |
| 4071 | At this point there are two ways to proceed; through the high-level |
| 4072 | write interface, or through a sequence of low-level write operations. |
| 4073 | 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] | 4074 | in the info structure. All defined output |
Glenn Randers-Pehrson | a77ef62 | 2000-02-18 13:48:52 -0600 | [diff] [blame] | 4075 | transformations are permitted, enabled by the following masks. |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4076 | |
| 4077 | PNG_TRANSFORM_IDENTITY No transformation |
| 4078 | PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 4079 | PNG_TRANSFORM_PACKSWAP Change order of packed |
| 4080 | pixels to LSB first |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4081 | PNG_TRANSFORM_INVERT_MONO Invert monochrome images |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 4082 | PNG_TRANSFORM_SHIFT Normalize pixels to the |
| 4083 | sBIT depth |
| 4084 | PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA |
| 4085 | to BGRA |
| 4086 | PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA |
| 4087 | to AG |
| 4088 | PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity |
| 4089 | to transparency |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4090 | PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples |
Glenn Randers-Pehrson | 1eb14e9 | 2008-12-10 07:14:45 -0600 | [diff] [blame] | 4091 | PNG_TRANSFORM_STRIP_FILLER Strip out filler |
| 4092 | bytes (deprecated). |
| 4093 | PNG_TRANSFORM_STRIP_FILLER_BEFORE Strip out leading |
| 4094 | filler bytes |
| 4095 | PNG_TRANSFORM_STRIP_FILLER_AFTER Strip out trailing |
| 4096 | filler bytes |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4097 | |
Glenn Randers-Pehrson | 1ef65b6 | 2000-05-12 06:19:53 -0500 | [diff] [blame] | 4098 | If you have valid image data in the info structure (you can use |
| 4099 | 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] | 4100 | |
| 4101 | png_write_png(png_ptr, info_ptr, png_transforms, NULL) |
| 4102 | |
Glenn Randers-Pehrson | ebd7f9a | 2006-10-19 09:37:56 -0500 | [diff] [blame] | 4103 | where png_transforms is an integer containing the bitwise OR of some set of |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4104 | transformation flags. This call is equivalent to png_write_info(), |
Glenn Randers-Pehrson | 6942d53 | 2000-05-01 09:31:54 -0500 | [diff] [blame] | 4105 | followed the set of transformations indicated by the transform mask, |
| 4106 | then png_write_image(), and finally png_write_end(). |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4107 | |
Glenn Randers-Pehrson | 6942d53 | 2000-05-01 09:31:54 -0500 | [diff] [blame] | 4108 | (The final parameter of this call is not yet used. Someday it might point |
| 4109 | to transformation parameters required by some future output transform.) |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4110 | |
Glenn Randers-Pehrson | a4981d4 | 2004-08-25 22:00:45 -0500 | [diff] [blame] | 4111 | You must use png_transforms and not call any png_set_transform() functions |
| 4112 | when you use png_write_png(). |
| 4113 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4114 | .SS The low-level write interface |
| 4115 | |
| 4116 | If you are going the low-level route instead, you are now ready to |
| 4117 | write all the file information up to the actual image data. You do |
| 4118 | this with a call to png_write_info(). |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4119 | |
| 4120 | png_write_info(png_ptr, info_ptr); |
| 4121 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4122 | Note that there is one transformation you may need to do before |
| 4123 | png_write_info(). In PNG files, the alpha channel in an image is the |
Glenn Randers-Pehrson | f210a05 | 2009-11-12 10:02:24 -0600 | [diff] [blame] | 4124 | level of opacity. If your data is supplied as a level of transparency, |
| 4125 | you can invert the alpha channel before you write it, so that 0 is |
| 4126 | fully transparent and 255 (in 8-bit or paletted images) or 65535 |
| 4127 | (in 16-bit images) is fully opaque, with |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4128 | |
| 4129 | png_set_invert_alpha(png_ptr); |
| 4130 | |
| 4131 | This must appear before png_write_info() instead of later with the |
| 4132 | other transformations because in the case of paletted images the tRNS |
| 4133 | chunk data has to be inverted before the tRNS chunk is written. If |
| 4134 | your image is not a paletted image, the tRNS data (which in such cases |
| 4135 | represents a single color to be rendered as transparent) won't need to |
| 4136 | be changed, and you can safely do this transformation after your |
| 4137 | png_write_info() call. |
| 4138 | |
Glenn Randers-Pehrson | 5379b24 | 1999-11-27 10:22:33 -0600 | [diff] [blame] | 4139 | If you need to write a private chunk that you want to appear before |
| 4140 | the PLTE chunk when PLTE is present, you can write the PNG info in |
| 4141 | two steps, and insert code to write your own chunk between them: |
| 4142 | |
| 4143 | png_write_info_before_PLTE(png_ptr, info_ptr); |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 4144 | png_set_unknown_chunks(png_ptr, info_ptr, ...); |
Glenn Randers-Pehrson | 5379b24 | 1999-11-27 10:22:33 -0600 | [diff] [blame] | 4145 | png_write_info(png_ptr, info_ptr); |
| 4146 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4147 | After you've written the file information, you can set up the library |
| 4148 | to handle any special transformations of the image data. The various |
| 4149 | ways to transform the data will be described in the order that they |
| 4150 | should occur. This is important, as some of these change the color |
| 4151 | type and/or bit depth of the data, and some others only work on |
| 4152 | certain color types and bit depths. Even though each transformation |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 4153 | 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] | 4154 | make sure to only enable a transformation if it will be valid for the |
| 4155 | data. For example, don't swap red and blue on grayscale data. |
| 4156 | |
Glenn Randers-Pehrson | 896239b | 1998-04-21 15:03:57 -0500 | [diff] [blame] | 4157 | 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] | 4158 | 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] | 4159 | to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2 |
| 4160 | bytes per pixel). |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4161 | |
| 4162 | png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); |
| 4163 | |
Glenn Randers-Pehrson | 520a764 | 2000-03-21 05:13:06 -0600 | [diff] [blame] | 4164 | 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] | 4165 | PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel |
| 4166 | is stored XRGB or RGBX. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4167 | |
| 4168 | PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as |
| 4169 | they can, resulting in, for example, 8 pixels per byte for 1 bit files. |
| 4170 | If the data is supplied at 1 pixel per byte, use this code, which will |
| 4171 | correctly pack the pixels into a single byte: |
| 4172 | |
| 4173 | png_set_packing(png_ptr); |
| 4174 | |
| 4175 | PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your |
| 4176 | 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] | 4177 | file so that decoders can recover the original data if desired. |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 4178 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4179 | /* Set the true bit depth of the image data */ |
| 4180 | if (color_type & PNG_COLOR_MASK_COLOR) |
| 4181 | { |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4182 | sig_bit.red = true_bit_depth; |
| 4183 | sig_bit.green = true_bit_depth; |
| 4184 | sig_bit.blue = true_bit_depth; |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4185 | } |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4186 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4187 | else |
| 4188 | { |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4189 | sig_bit.gray = true_bit_depth; |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4190 | } |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4191 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4192 | if (color_type & PNG_COLOR_MASK_ALPHA) |
| 4193 | { |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4194 | sig_bit.alpha = true_bit_depth; |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4195 | } |
| 4196 | |
| 4197 | png_set_sBIT(png_ptr, info_ptr, &sig_bit); |
| 4198 | |
| 4199 | 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] | 4200 | 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] | 4201 | this will scale the values to appear to be the correct bit depth as |
| 4202 | is required by PNG. |
| 4203 | |
| 4204 | png_set_shift(png_ptr, &sig_bit); |
| 4205 | |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 4206 | PNG files store 16-bit pixels in network byte order (big-endian, |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4207 | 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] | 4208 | supplied the other way (little-endian, i.e. least significant bits |
| 4209 | first, the way PCs store them): |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4210 | |
| 4211 | if (bit_depth > 8) |
| 4212 | png_set_swap(png_ptr); |
| 4213 | |
| 4214 | If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you |
| 4215 | need to change the order the pixels are packed into bytes, you can use: |
| 4216 | |
| 4217 | if (bit_depth < 8) |
| 4218 | png_set_packswap(png_ptr); |
| 4219 | |
| 4220 | PNG files store 3 color pixels in red, green, blue order. This code |
| 4221 | would be used if they are supplied as blue, green, red: |
| 4222 | |
| 4223 | png_set_bgr(png_ptr); |
| 4224 | |
| 4225 | PNG files describe monochrome as black being zero and white being |
| 4226 | one. This code would be used if the pixels are supplied with this reversed |
| 4227 | (black being one and white being zero): |
| 4228 | |
| 4229 | png_set_invert_mono(png_ptr); |
| 4230 | |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 4231 | Finally, you can write your own transformation function if none of |
| 4232 | the existing ones meets your needs. This is done by setting a callback |
| 4233 | with |
| 4234 | |
| 4235 | png_set_write_user_transform_fn(png_ptr, |
| 4236 | write_transform_fn); |
| 4237 | |
| 4238 | You must supply the function |
| 4239 | |
Glenn Randers-Pehrson | 9321567 | 2011-02-13 19:42:19 -0600 | [diff] [blame] | 4240 | void write_transform_fn(png_structp png_ptr, png_row_infop |
| 4241 | row_info, png_bytep data) |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 4242 | |
| 4243 | See pngtest.c for a working example. Your function will be called |
John Bowler | f19abd6 | 2011-01-22 18:29:24 -0600 | [diff] [blame] | 4244 | before any of the other transformations are processed. If supported |
| 4245 | libpng also supplies an information routine that may be called from |
| 4246 | your callback: |
| 4247 | |
| 4248 | png_get_current_row_number(png_ptr); |
John Bowler | cd11345 | 2011-02-16 06:15:13 -0600 | [diff] [blame] | 4249 | png_get_current_pass_number(png_ptr); |
John Bowler | f19abd6 | 2011-01-22 18:29:24 -0600 | [diff] [blame] | 4250 | |
John Bowler | cd11345 | 2011-02-16 06:15:13 -0600 | [diff] [blame] | 4251 | This returns the current row passed to the transform. With interlaced |
| 4252 | images the value returned is the row in the input sub-image image. Use |
| 4253 | PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to |
| 4254 | find the output pixel (x,y) given an interlaced sub-image pixel (row,col,pass). |
| 4255 | |
| 4256 | The discussion of interlace handling above contains more information on how to |
| 4257 | use these values. |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 4258 | |
| 4259 | You can also set up a pointer to a user structure for use by your |
| 4260 | callback function. |
| 4261 | |
| 4262 | png_set_user_transform_info(png_ptr, user_ptr, 0, 0); |
| 4263 | |
| 4264 | The user_channels and user_depth parameters of this function are ignored |
| 4265 | when writing; you can set them to zero as shown. |
| 4266 | |
Glenn Randers-Pehrson | 228bd39 | 2000-04-23 23:14:02 -0500 | [diff] [blame] | 4267 | You can retrieve the pointer via the function png_get_user_transform_ptr(). |
| 4268 | For example: |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 4269 | |
| 4270 | voidp write_user_transform_ptr = |
| 4271 | png_get_user_transform_ptr(png_ptr); |
Glenn Randers-Pehrson | 08a3343 | 1998-03-07 06:06:55 -0600 | [diff] [blame] | 4272 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4273 | It is possible to have libpng flush any pending output, either manually, |
| 4274 | or automatically after a certain number of lines have been written. To |
| 4275 | flush the output stream a single time call: |
| 4276 | |
| 4277 | png_write_flush(png_ptr); |
| 4278 | |
| 4279 | and to have libpng flush the output stream periodically after a certain |
| 4280 | number of scanlines have been written, call: |
| 4281 | |
| 4282 | png_set_flush(png_ptr, nrows); |
| 4283 | |
| 4284 | Note that the distance between rows is from the last time png_write_flush() |
| 4285 | was called, or the first row of the image if it has never been called. |
| 4286 | So if you write 50 lines, and then png_set_flush 25, it will flush the |
| 4287 | output on the next scanline, and every 25 lines thereafter, unless |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 4288 | 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] | 4289 | 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] | 4290 | RGB image) the image compression may decrease noticeably (although this |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4291 | may be acceptable for real-time applications). Infrequent flushing will |
| 4292 | only degrade the compression performance by a few percent over images |
| 4293 | that do not use flushing. |
| 4294 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4295 | .SS Writing the image data |
| 4296 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4297 | 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] | 4298 | 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] | 4299 | whole image in memory, you can just call png_write_image() and libpng |
| 4300 | will write the image. You will need to pass in an array of pointers to |
| 4301 | each row. This function automatically handles interlacing, so you don't |
| 4302 | need to call png_set_interlace_handling() or call this function multiple |
| 4303 | times, or any of that other stuff necessary with png_write_rows(). |
| 4304 | |
| 4305 | png_write_image(png_ptr, row_pointers); |
| 4306 | |
| 4307 | where row_pointers is: |
| 4308 | |
Glenn Randers-Pehrson | 896239b | 1998-04-21 15:03:57 -0500 | [diff] [blame] | 4309 | png_byte *row_pointers[height]; |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4310 | |
| 4311 | You can point to void or char or whatever you use for pixels. |
| 4312 | |
Glenn Randers-Pehrson | 896239b | 1998-04-21 15:03:57 -0500 | [diff] [blame] | 4313 | 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] | 4314 | use png_write_rows() instead. If the file is not interlaced, |
| 4315 | this is simple: |
| 4316 | |
| 4317 | png_write_rows(png_ptr, row_pointers, |
| 4318 | number_of_rows); |
| 4319 | |
| 4320 | row_pointers is the same as in the png_write_image() call. |
| 4321 | |
| 4322 | 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] | 4323 | a single row_pointer instead of an array of row_pointers: |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4324 | |
| 4325 | png_bytep row_pointer = row; |
| 4326 | |
Glenn Randers-Pehrson | 520a764 | 2000-03-21 05:13:06 -0600 | [diff] [blame] | 4327 | png_write_row(png_ptr, row_pointer); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4328 | |
Glenn Randers-Pehrson | f210a05 | 2009-11-12 10:02:24 -0600 | [diff] [blame] | 4329 | When the file is interlaced, things can get a good deal more complicated. |
| 4330 | The only currently (as of the PNG Specification version 1.2, dated July |
| 4331 | 1999) defined interlacing scheme for PNG files is the "Adam7" interlace |
| 4332 | scheme, that breaks down an image into seven smaller images of varying |
| 4333 | size. libpng will build these images for you, or you can do them |
| 4334 | yourself. If you want to build them yourself, see the PNG specification |
| 4335 | for details of which pixels to write when. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4336 | |
| 4337 | If you don't want libpng to handle the interlacing details, just |
| 4338 | use png_set_interlace_handling() and call png_write_rows() the |
Glenn Randers-Pehrson | 6e97410 | 2010-12-19 16:44:22 -0600 | [diff] [blame] | 4339 | correct number of times to write all the sub-images |
| 4340 | (png_set_interlace_handling() returns the number of sub-images.) |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4341 | |
| 4342 | If you want libpng to build the sub-images, call this before you start |
| 4343 | writing any rows: |
| 4344 | |
Glenn Randers-Pehrson | 6e97410 | 2010-12-19 16:44:22 -0600 | [diff] [blame] | 4345 | number_of_passes = png_set_interlace_handling(png_ptr); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4346 | |
Glenn Randers-Pehrson | f210a05 | 2009-11-12 10:02:24 -0600 | [diff] [blame] | 4347 | This will return the number of passes needed. Currently, this is seven, |
| 4348 | but may change if another interlace type is added. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4349 | |
| 4350 | Then write the complete image number_of_passes times. |
| 4351 | |
Glenn Randers-Pehrson | 6e97410 | 2010-12-19 16:44:22 -0600 | [diff] [blame] | 4352 | png_write_rows(png_ptr, row_pointers, number_of_rows); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4353 | |
Glenn Randers-Pehrson | 6e97410 | 2010-12-19 16:44:22 -0600 | [diff] [blame] | 4354 | Think carefully before you write an interlaced image. Typically code that |
| 4355 | reads such images reads all the image data into memory, uncompressed, before |
| 4356 | doing any processing. Only code that can display an image on the fly can |
| 4357 | take advantage of the interlacing and even then the image has to be exactly |
| 4358 | the correct size for the output device, because scaling an image requires |
| 4359 | adjacent pixels and these are not available until all the passes have been |
| 4360 | read. |
| 4361 | |
| 4362 | If you do write an interlaced image you will hardly ever need to handle |
| 4363 | the interlacing yourself. Call png_set_interlace_handling() and use the |
| 4364 | approach described above. |
| 4365 | |
| 4366 | The only time it is conceivable that you will really need to write an |
| 4367 | interlaced image pass-by-pass is when you have read one pass by pass and |
| 4368 | made some pixel-by-pixel transformation to it, as described in the read |
| 4369 | code above. In this case use the PNG_PASS_ROWS and PNG_PASS_COLS macros |
| 4370 | to determine the size of each sub-image in turn and simply write the rows |
| 4371 | you obtained from the read code. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4372 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4373 | .SS Finishing a sequential write |
| 4374 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4375 | After you are finished writing the image, you should finish writing |
| 4376 | the file. If you are interested in writing comments or time, you should |
| 4377 | pass an appropriately filled png_info pointer. If you are not interested, |
| 4378 | you can pass NULL. |
| 4379 | |
| 4380 | png_write_end(png_ptr, info_ptr); |
| 4381 | |
| 4382 | When you are done, you can free all memory used by libpng like this: |
| 4383 | |
| 4384 | png_destroy_write_struct(&png_ptr, &info_ptr); |
| 4385 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 4386 | 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] | 4387 | point to libpng-allocated storage with the following function: |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 4388 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 4389 | png_free_data(png_ptr, info_ptr, mask, seq) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4390 | |
Glenn Randers-Pehrson | 1ef65b6 | 2000-05-12 06:19:53 -0500 | [diff] [blame] | 4391 | mask - identifies data to be freed, a mask |
Glenn Randers-Pehrson | ebd7f9a | 2006-10-19 09:37:56 -0500 | [diff] [blame] | 4392 | containing the bitwise OR of one or |
Glenn Randers-Pehrson | 1ef65b6 | 2000-05-12 06:19:53 -0500 | [diff] [blame] | 4393 | more of |
| 4394 | PNG_FREE_PLTE, PNG_FREE_TRNS, |
| 4395 | PNG_FREE_HIST, PNG_FREE_ICCP, |
| 4396 | PNG_FREE_PCAL, PNG_FREE_ROWS, |
| 4397 | PNG_FREE_SCAL, PNG_FREE_SPLT, |
| 4398 | PNG_FREE_TEXT, PNG_FREE_UNKN, |
| 4399 | or simply PNG_FREE_ALL |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4400 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 4401 | seq - sequence number of item to be freed |
Glenn Randers-Pehrson | 1ef65b6 | 2000-05-12 06:19:53 -0500 | [diff] [blame] | 4402 | (-1 for all items) |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 4403 | |
Glenn Randers-Pehrson | fc4a143 | 2000-05-17 17:39:34 -0500 | [diff] [blame] | 4404 | This function may be safely called when the relevant storage has |
Glenn Randers-Pehrson | 6942d53 | 2000-05-01 09:31:54 -0500 | [diff] [blame] | 4405 | already been freed, or has not yet been allocated, or was allocated |
Glenn Randers-Pehrson | f210a05 | 2009-11-12 10:02:24 -0600 | [diff] [blame] | 4406 | by the user and not by libpng, and will in those cases do nothing. |
| 4407 | The "seq" parameter is ignored if only one item of the selected data |
| 4408 | type, such as PLTE, is allowed. If "seq" is not -1, and multiple items |
| 4409 | are allowed for the data type identified in the mask, such as text or |
| 4410 | sPLT, only the n'th item in the structure is freed, where n is "seq". |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 4411 | |
Glenn Randers-Pehrson | f210a05 | 2009-11-12 10:02:24 -0600 | [diff] [blame] | 4412 | If you allocated data such as a palette that you passed in to libpng |
| 4413 | 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] | 4414 | png_destroy_write_struct(). |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4415 | |
Glenn Randers-Pehrson | 38e6e77 | 2000-04-09 19:06:13 -0500 | [diff] [blame] | 4416 | The default behavior is only to free data that was allocated internally |
| 4417 | 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] | 4418 | or so that it will free data that was allocated by the user with png_malloc() |
| 4419 | 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] | 4420 | |
| 4421 | png_data_freer(png_ptr, info_ptr, freer, mask) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4422 | |
Glenn Randers-Pehrson | 1ef65b6 | 2000-05-12 06:19:53 -0500 | [diff] [blame] | 4423 | freer - one of |
| 4424 | PNG_DESTROY_WILL_FREE_DATA |
| 4425 | PNG_SET_WILL_FREE_DATA |
| 4426 | PNG_USER_WILL_FREE_DATA |
Glenn Randers-Pehrson | 38e6e77 | 2000-04-09 19:06:13 -0500 | [diff] [blame] | 4427 | |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4428 | mask - which data elements are affected |
| 4429 | same choices as in png_free_data() |
| 4430 | |
Glenn Randers-Pehrson | 38e6e77 | 2000-04-09 19:06:13 -0500 | [diff] [blame] | 4431 | For example, to transfer responsibility for some data from a read structure |
| 4432 | to a write structure, you could use |
| 4433 | |
| 4434 | png_data_freer(read_ptr, read_info_ptr, |
| 4435 | PNG_USER_WILL_FREE_DATA, |
| 4436 | PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4437 | |
Glenn Randers-Pehrson | 38e6e77 | 2000-04-09 19:06:13 -0500 | [diff] [blame] | 4438 | png_data_freer(write_ptr, write_info_ptr, |
| 4439 | PNG_DESTROY_WILL_FREE_DATA, |
| 4440 | PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) |
| 4441 | |
Glenn Randers-Pehrson | 228bd39 | 2000-04-23 23:14:02 -0500 | [diff] [blame] | 4442 | thereby briefly reassigning responsibility for freeing to the user but |
Glenn Randers-Pehrson | 38e6e77 | 2000-04-09 19:06:13 -0500 | [diff] [blame] | 4443 | immediately afterwards reassigning it once more to the write_destroy |
| 4444 | function. Having done this, it would then be safe to destroy the read |
| 4445 | structure and continue to use the PLTE, tRNS, and hIST data in the write |
| 4446 | structure. |
| 4447 | |
Glenn Randers-Pehrson | 6942d53 | 2000-05-01 09:31:54 -0500 | [diff] [blame] | 4448 | This function only affects data that has already been allocated. |
| 4449 | You can call this function before calling after the png_set_*() functions |
| 4450 | to control whether the user or png_destroy_*() is supposed to free the data. |
| 4451 | When the user assumes responsibility for libpng-allocated data, the |
Glenn Randers-Pehrson | 1ef65b6 | 2000-05-12 06:19:53 -0500 | [diff] [blame] | 4452 | application must use |
| 4453 | png_free() to free it, and when the user transfers responsibility to libpng |
| 4454 | for data that the user has allocated, the user must have used png_malloc() |
| 4455 | or png_zalloc() to allocate it. |
Glenn Randers-Pehrson | 6942d53 | 2000-05-01 09:31:54 -0500 | [diff] [blame] | 4456 | |
Glenn Randers-Pehrson | 1ef65b6 | 2000-05-12 06:19:53 -0500 | [diff] [blame] | 4457 | If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword |
| 4458 | separately, do not transfer responsibility for freeing text_ptr to libpng, |
| 4459 | because when libpng fills a png_text structure it combines these members with |
| 4460 | the key member, and png_free_data() will free only text_ptr.key. Similarly, |
| 4461 | if you transfer responsibility for free'ing text_ptr from libpng to your |
| 4462 | application, your application must not separately free those members. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4463 | For a more compact example of writing a PNG image, see the file example.c. |
| 4464 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 4465 | .SH V. Modifying/Customizing libpng: |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4466 | |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 4467 | There are two issues here. The first is changing how libpng does |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4468 | standard things like memory allocation, input/output, and error handling. |
| 4469 | The second deals with more complicated things like adding new chunks, |
| 4470 | adding new transformations, and generally changing how libpng works. |
Glenn Randers-Pehrson | 231e687 | 2001-01-12 15:13:06 -0600 | [diff] [blame] | 4471 | Both of those are compile-time issues; that is, they are generally |
| 4472 | determined at the time the code is written, and there is rarely a need |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 4473 | to provide the user with a means of changing them. |
Glenn Randers-Pehrson | 231e687 | 2001-01-12 15:13:06 -0600 | [diff] [blame] | 4474 | |
| 4475 | Memory allocation, input/output, and error handling |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4476 | |
| 4477 | 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] | 4478 | goes through callbacks that are user-settable. The default routines are |
Glenn Randers-Pehrson | 228bd39 | 2000-04-23 23:14:02 -0500 | [diff] [blame] | 4479 | 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] | 4480 | these functions, call the appropriate png_set_*_fn() function. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4481 | |
Glenn Randers-Pehrson | f210a05 | 2009-11-12 10:02:24 -0600 | [diff] [blame] | 4482 | Memory allocation is done through the functions png_malloc(), png_calloc(), |
| 4483 | and png_free(). These currently just call the standard C functions. |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 4484 | png_calloc() calls png_malloc() and then clears the newly |
| 4485 | allocated memory to zero. There is limited support for certain systems |
| 4486 | with segmented memory architectures and the types of pointers declared by |
| 4487 | png.h match this; you will have to use appropriate pointers in your |
| 4488 | application. Since it is |
Glenn Randers-Pehrson | f210a05 | 2009-11-12 10:02:24 -0600 | [diff] [blame] | 4489 | unlikely that the method of handling memory allocation on a platform |
| 4490 | will change between applications, these functions must be modified in |
| 4491 | the library at compile time. If you prefer to use a different method |
| 4492 | of allocating and freeing data, you can use png_create_read_struct_2() or |
| 4493 | png_create_write_struct_2() to register your own functions as described |
| 4494 | above. These functions also provide a void pointer that can be retrieved |
| 4495 | via |
Glenn Randers-Pehrson | 6942d53 | 2000-05-01 09:31:54 -0500 | [diff] [blame] | 4496 | |
| 4497 | mem_ptr=png_get_mem_ptr(png_ptr); |
| 4498 | |
| 4499 | Your replacement memory functions must have prototypes as follows: |
| 4500 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 4501 | png_voidp malloc_fn(png_structp png_ptr, |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 4502 | png_alloc_size_t size); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4503 | |
Glenn Randers-Pehrson | 6942d53 | 2000-05-01 09:31:54 -0500 | [diff] [blame] | 4504 | void free_fn(png_structp png_ptr, png_voidp ptr); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4505 | |
Glenn Randers-Pehrson | 5fea36f | 2004-07-28 08:20:44 -0500 | [diff] [blame] | 4506 | Your malloc_fn() must return NULL in case of failure. The png_malloc() |
| 4507 | function will normally call png_error() if it receives a NULL from the |
| 4508 | system memory allocator or from your replacement malloc_fn(). |
Glenn Randers-Pehrson | 82ae383 | 2001-04-20 10:32:10 -0500 | [diff] [blame] | 4509 | |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 4510 | Your free_fn() will never be called with a NULL ptr, since libpng's |
| 4511 | png_free() checks for NULL before calling free_fn(). |
| 4512 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4513 | Input/Output in libpng is done through png_read() and png_write(), |
| 4514 | which currently just call fread() and fwrite(). The FILE * is stored in |
| 4515 | png_struct and is initialized via png_init_io(). If you wish to change |
| 4516 | the method of I/O, the library supplies callbacks that you can set |
| 4517 | 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] | 4518 | time, instead of calling the png_init_io() function. These functions |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4519 | also provide a void pointer that can be retrieved via the function |
| 4520 | png_get_io_ptr(). For example: |
| 4521 | |
Glenn Randers-Pehrson | f7d1a17 | 1998-06-06 15:31:35 -0500 | [diff] [blame] | 4522 | png_set_read_fn(png_structp read_ptr, |
| 4523 | voidp read_io_ptr, png_rw_ptr read_data_fn) |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4524 | |
Glenn Randers-Pehrson | f7d1a17 | 1998-06-06 15:31:35 -0500 | [diff] [blame] | 4525 | png_set_write_fn(png_structp write_ptr, |
| 4526 | voidp write_io_ptr, png_rw_ptr write_data_fn, |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4527 | png_flush_ptr output_flush_fn); |
| 4528 | |
Glenn Randers-Pehrson | f7d1a17 | 1998-06-06 15:31:35 -0500 | [diff] [blame] | 4529 | voidp read_io_ptr = png_get_io_ptr(read_ptr); |
| 4530 | voidp write_io_ptr = png_get_io_ptr(write_ptr); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4531 | |
Glenn Randers-Pehrson | 6942d53 | 2000-05-01 09:31:54 -0500 | [diff] [blame] | 4532 | The replacement I/O functions must have prototypes as follows: |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4533 | |
| 4534 | void user_read_data(png_structp png_ptr, |
Glenn Randers-Pehrson | 837a3d1 | 2002-05-10 20:19:58 -0500 | [diff] [blame] | 4535 | png_bytep data, png_size_t length); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4536 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4537 | void user_write_data(png_structp png_ptr, |
Glenn Randers-Pehrson | 837a3d1 | 2002-05-10 20:19:58 -0500 | [diff] [blame] | 4538 | png_bytep data, png_size_t length); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4539 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4540 | void user_flush_data(png_structp png_ptr); |
| 4541 | |
Glenn Randers-Pehrson | ebd7f9a | 2006-10-19 09:37:56 -0500 | [diff] [blame] | 4542 | The user_read_data() function is responsible for detecting and |
| 4543 | handling end-of-data errors. |
| 4544 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4545 | Supplying NULL for the read, write, or flush functions sets them back |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 4546 | to using the default C stream functions, which expect the io_ptr to |
| 4547 | point to a standard *FILE structure. It is probably a mistake |
| 4548 | to use NULL for one of write_data_fn and output_flush_fn but not both |
| 4549 | of them, unless you have built libpng with PNG_NO_WRITE_FLUSH defined. |
| 4550 | It is an error to read from a write stream, and vice versa. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4551 | |
| 4552 | Error handling in libpng is done through png_error() and png_warning(). |
| 4553 | Errors handled through png_error() are fatal, meaning that png_error() |
| 4554 | should never return to its caller. Currently, this is handled via |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4555 | setjmp() and longjmp() (unless you have compiled libpng with |
Glenn Randers-Pehrson | 54ac9a9 | 2010-04-02 17:06:22 -0500 | [diff] [blame] | 4556 | PNG_NO_SETJMP, in which case it is handled via PNG_ABORT()), |
Glenn Randers-Pehrson | 6098807 | 2010-04-13 22:11:06 -0500 | [diff] [blame] | 4557 | but you could change this to do things like exit() if you should wish, |
Glenn Randers-Pehrson | 54ac9a9 | 2010-04-02 17:06:22 -0500 | [diff] [blame] | 4558 | as long as your function does not return. |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4559 | |
| 4560 | On non-fatal errors, png_warning() is called |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4561 | to print a warning message, and then control returns to the calling code. |
| 4562 | 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] | 4563 | fprintf() unless the library is compiled with PNG_NO_CONSOLE_IO defined |
| 4564 | (because you don't want the messages) or PNG_NO_STDIO defined (because |
| 4565 | fprintf() isn't available). If you wish to change the behavior of the error |
| 4566 | functions, you will need to set up your own message callbacks. These |
| 4567 | 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] | 4568 | It is also possible to redirect errors and warnings to your own replacement |
| 4569 | functions after png_create_*_struct() has been called by calling: |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4570 | |
| 4571 | png_set_error_fn(png_structp png_ptr, |
| 4572 | png_voidp error_ptr, png_error_ptr error_fn, |
| 4573 | png_error_ptr warning_fn); |
| 4574 | |
| 4575 | png_voidp error_ptr = png_get_error_ptr(png_ptr); |
| 4576 | |
| 4577 | If NULL is supplied for either error_fn or warning_fn, then the libpng |
| 4578 | default function will be used, calling fprintf() and/or longjmp() if a |
| 4579 | problem is encountered. The replacement error functions should have |
| 4580 | parameters as follows: |
| 4581 | |
| 4582 | void user_error_fn(png_structp png_ptr, |
| 4583 | png_const_charp error_msg); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4584 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4585 | void user_warning_fn(png_structp png_ptr, |
| 4586 | png_const_charp warning_msg); |
| 4587 | |
| 4588 | The motivation behind using setjmp() and longjmp() is the C++ throw and |
| 4589 | catch exception handling methods. This makes the code much easier to write, |
| 4590 | as there is no need to check every return code of every function call. |
| 4591 | However, there are some uncertainties about the status of local variables |
Glenn Randers-Pehrson | f210a05 | 2009-11-12 10:02:24 -0600 | [diff] [blame] | 4592 | after a longjmp, so the user may want to be careful about doing anything |
| 4593 | after setjmp returns non-zero besides returning itself. Consult your |
| 4594 | compiler documentation for more details. For an alternative approach, you |
Glenn Randers-Pehrson | a5e5547 | 2011-07-12 10:13:32 -0500 | [diff] [blame] | 4595 | may wish to use the "cexcept" facility (see http://cexcept.sourceforge.net), |
| 4596 | which is illustrated in pngvalid.c and in contrib/visupng. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4597 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4598 | .SS Custom chunks |
| 4599 | |
| 4600 | If you need to read or write custom chunks, you may need to get deeper |
| 4601 | into the libpng code. The library now has mechanisms for storing |
| 4602 | and writing chunks of unknown type; you can even declare callbacks |
Glenn Randers-Pehrson | 9c3ab68 | 2006-02-20 22:09:05 -0600 | [diff] [blame] | 4603 | for custom chunks. However, this may not be good enough if the |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4604 | library code itself needs to know about interactions between your |
| 4605 | chunk and existing `intrinsic' chunks. |
| 4606 | |
| 4607 | If you need to write a new intrinsic chunk, first read the PNG |
Glenn Randers-Pehrson | f210a05 | 2009-11-12 10:02:24 -0600 | [diff] [blame] | 4608 | specification. Acquire a first level of understanding of how it works. |
| 4609 | Pay particular attention to the sections that describe chunk names, |
| 4610 | and look at how other chunks were designed, so you can do things |
| 4611 | similarly. Second, check out the sections of libpng that read and |
| 4612 | write chunks. Try to find a chunk that is similar to yours and use |
| 4613 | it as a template. More details can be found in the comments inside |
Glenn Randers-Pehrson | a5e5547 | 2011-07-12 10:13:32 -0500 | [diff] [blame] | 4614 | the code. It is best to handle private or unknown chunks in a generic method, |
| 4615 | via callback functions, instead of by modifying libpng functions. This |
| 4616 | is illustrated in pngtest.c, which uses a callback function to handle a |
| 4617 | private "vpAg" chunk and the new "sTER" chunk, which are both unknown to |
| 4618 | libpng. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4619 | |
| 4620 | If you wish to write your own transformation for the data, look through |
| 4621 | the part of the code that does the transformations, and check out some of |
| 4622 | the simpler ones to get an idea of how they work. Try to find a similar |
| 4623 | transformation to the one you want to add and copy off of it. More details |
| 4624 | can be found in the comments inside the code itself. |
| 4625 | |
Glenn Randers-Pehrson | 593fc04 | 2011-05-12 22:18:23 -0500 | [diff] [blame] | 4626 | .SS Configuring for 16-bit platforms |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4627 | |
Glenn Randers-Pehrson | 228bd39 | 2000-04-23 23:14:02 -0500 | [diff] [blame] | 4628 | 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] | 4629 | 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] | 4630 | 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] | 4631 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4632 | .SS Configuring for DOS |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4633 | |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 4634 | 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] | 4635 | have to limit zlib's memory usage via a png_set_compression_mem_level() |
| 4636 | call. See zlib.h or zconf.h in the zlib library for more information. |
| 4637 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4638 | .SS Configuring for Medium Model |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4639 | |
| 4640 | Libpng's support for medium model has been tested on most of the popular |
| 4641 | compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets |
| 4642 | defined, and FAR gets defined to far in pngconf.h, and you should be |
| 4643 | all set. Everything in the library (except for zlib's structure) is |
| 4644 | expecting far data. You must use the typedefs with the p or pp on |
| 4645 | the end for pointers (or at least look at them and be careful). Make |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 4646 | note that the rows of data are defined as png_bytepp, which is |
| 4647 | an "unsigned char far * far *". |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4648 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4649 | .SS Configuring for gui/windowing platforms: |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4650 | |
| 4651 | You will need to write new error and warning functions that use the GUI |
| 4652 | 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] | 4653 | warning functions at the time that png_create_*_struct() is called, |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4654 | in order to have them available during the structure initialization. |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 4655 | 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] | 4656 | you may also have to change the memory allocators (png_malloc, etc.). |
| 4657 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4658 | .SS Configuring for compiler xxx: |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4659 | |
Glenn Randers-Pehrson | beb572e | 2006-08-19 13:59:24 -0500 | [diff] [blame] | 4660 | All includes for libpng are in pngconf.h. If you need to add, change |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 4661 | or delete an include, this is the place to do it. |
| 4662 | The includes that are not needed outside libpng are placed in pngpriv.h, |
| 4663 | which is only used by the routines inside libpng itself. |
| 4664 | The files in libpng proper only include pngpriv.h and png.h, which |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 4665 | %14%in turn includes pngconf.h. |
| 4666 | in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h. |
| 4667 | As of libpng-1.5.0, pngpriv.h also includes three other private header |
| 4668 | files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material |
| 4669 | that previously appeared in the public headers. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4670 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4671 | .SS Configuring zlib: |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4672 | |
| 4673 | There are special functions to configure the compression. Perhaps the |
| 4674 | most useful one changes the compression level, which currently uses |
| 4675 | input compression values in the range 0 - 9. The library normally |
| 4676 | uses the default compression level (Z_DEFAULT_COMPRESSION = 6). Tests |
| 4677 | have shown that for a large majority of images, compression values in |
| 4678 | the range 3-6 compress nearly as well as higher levels, and do so much |
| 4679 | faster. For online applications it may be desirable to have maximum speed |
| 4680 | (Z_BEST_SPEED = 1). With versions of zlib after v0.99, you can also |
| 4681 | specify no compression (Z_NO_COMPRESSION = 0), but this would create |
| 4682 | files larger than just storing the raw bitmap. You can specify the |
| 4683 | compression level by calling: |
| 4684 | |
Glenn Randers-Pehrson | 38734ee | 2011-03-03 06:23:31 -0600 | [diff] [blame] | 4685 | #include zlib.h |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4686 | png_set_compression_level(png_ptr, level); |
| 4687 | |
| 4688 | Another useful one is to reduce the memory level used by the library. |
| 4689 | The memory level defaults to 8, but it can be lowered if you are |
| 4690 | short on memory (running DOS, for example, where you only have 640K). |
Glenn Randers-Pehrson | 4fb046a | 2002-04-15 09:25:51 -0500 | [diff] [blame] | 4691 | Note that the memory level does have an effect on compression; among |
| 4692 | other things, lower levels will result in sections of incompressible |
| 4693 | data being emitted in smaller stored blocks, with a correspondingly |
| 4694 | larger relative overhead of up to 15% in the worst case. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4695 | |
Glenn Randers-Pehrson | 38734ee | 2011-03-03 06:23:31 -0600 | [diff] [blame] | 4696 | #include zlib.h |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4697 | png_set_compression_mem_level(png_ptr, level); |
| 4698 | |
| 4699 | The other functions are for configuring zlib. They are not recommended |
| 4700 | for normal use and may result in writing an invalid PNG file. See |
| 4701 | zlib.h for more information on what these mean. |
| 4702 | |
Glenn Randers-Pehrson | 38734ee | 2011-03-03 06:23:31 -0600 | [diff] [blame] | 4703 | #include zlib.h |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4704 | png_set_compression_strategy(png_ptr, |
| 4705 | strategy); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4706 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4707 | png_set_compression_window_bits(png_ptr, |
| 4708 | window_bits); |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4709 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4710 | png_set_compression_method(png_ptr, method); |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 4711 | |
Glenn Randers-Pehrson | 228bd39 | 2000-04-23 23:14:02 -0500 | [diff] [blame] | 4712 | png_set_compression_buffer_size(png_ptr, size); |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4713 | |
Glenn Randers-Pehrson | 7a28724 | 2011-07-26 12:03:11 -0500 | [diff] [blame] | 4714 | As of libpng version 1.5.4, additional APIs became |
| 4715 | available to set these separately for non-IDAT |
| 4716 | compressed chunks such as zTXt, iTXt, and iCCP: |
| 4717 | |
| 4718 | #include zlib.h |
| 4719 | #if PNG_LIBPNG_VER <= 10504 |
| 4720 | png_set_text_compression_level(png_ptr, level); |
| 4721 | |
| 4722 | png_set_text_compression_mem_level(png_ptr, level); |
| 4723 | |
| 4724 | png_set_text_compression_strategy(png_ptr, |
| 4725 | strategy); |
| 4726 | |
| 4727 | png_set_text_compression_window_bits(png_ptr, |
| 4728 | window_bits); |
| 4729 | |
| 4730 | png_set_text_compression_method(png_ptr, method); |
| 4731 | #endif |
| 4732 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4733 | .SS Controlling row filtering |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4734 | |
| 4735 | If you want to control whether libpng uses filtering or not, which |
| 4736 | filters are used, and how it goes about picking row filters, you |
| 4737 | can call one of these functions. The selection and configuration |
| 4738 | of row filters can have a significant impact on the size and |
| 4739 | encoding speed and a somewhat lesser impact on the decoding speed |
| 4740 | 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] | 4741 | images (with and without alpha), but not for paletted images nor |
| 4742 | for any images with bit depths less than 8 bits/pixel. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4743 | |
| 4744 | The 'method' parameter sets the main filtering method, which is |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 4745 | currently only '0' in the PNG 1.2 specification. The 'filters' |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4746 | parameter sets which filter(s), if any, should be used for each |
| 4747 | scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS |
| 4748 | to turn filtering on and off, respectively. |
| 4749 | |
| 4750 | Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB, |
| 4751 | 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] | 4752 | ORed together with '|' to specify one or more filters to use. |
Glenn Randers-Pehrson | 4fb046a | 2002-04-15 09:25:51 -0500 | [diff] [blame] | 4753 | These filters are described in more detail in the PNG specification. |
| 4754 | If you intend to change the filter type during the course of writing |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4755 | the image, you should start with flags set for all of the filters |
| 4756 | you intend to use so that libpng can initialize its internal |
Glenn Randers-Pehrson | 4fb046a | 2002-04-15 09:25:51 -0500 | [diff] [blame] | 4757 | structures appropriately for all of the filter types. (Note that this |
| 4758 | means the first row must always be adaptively filtered, because libpng |
| 4759 | currently does not allocate the filter buffers until png_write_row() |
| 4760 | is called for the first time.) |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4761 | |
| 4762 | filters = PNG_FILTER_NONE | PNG_FILTER_SUB |
Glenn Randers-Pehrson | 7654682 | 2009-05-16 07:25:42 -0500 | [diff] [blame] | 4763 | PNG_FILTER_UP | PNG_FILTER_AVG | |
Glenn Randers-Pehrson | 228bd39 | 2000-04-23 23:14:02 -0500 | [diff] [blame] | 4764 | PNG_FILTER_PAETH | PNG_ALL_FILTERS; |
Glenn Randers-Pehrson | 228bd39 | 2000-04-23 23:14:02 -0500 | [diff] [blame] | 4765 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4766 | png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, |
| 4767 | filters); |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 4768 | The second parameter can also be |
| 4769 | PNG_INTRAPIXEL_DIFFERENCING if you are |
| 4770 | writing a PNG to be embedded in a MNG |
| 4771 | datastream. This parameter must be the |
| 4772 | same as the value of filter_method used |
| 4773 | in png_set_IHDR(). |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4774 | |
| 4775 | It is also possible to influence how libpng chooses from among the |
Glenn Randers-Pehrson | 4fb046a | 2002-04-15 09:25:51 -0500 | [diff] [blame] | 4776 | available filters. This is done in one or both of two ways - by |
| 4777 | telling it how important it is to keep the same filter for successive |
| 4778 | rows, and by telling it the relative computational costs of the filters. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4779 | |
| 4780 | double weights[3] = {1.5, 1.3, 1.1}, |
| 4781 | costs[PNG_FILTER_VALUE_LAST] = |
| 4782 | {1.0, 1.3, 1.3, 1.5, 1.7}; |
| 4783 | |
Glenn Randers-Pehrson | 4fb046a | 2002-04-15 09:25:51 -0500 | [diff] [blame] | 4784 | png_set_filter_heuristics(png_ptr, |
| 4785 | PNG_FILTER_HEURISTIC_WEIGHTED, 3, |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4786 | weights, costs); |
| 4787 | |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 4788 | The weights are multiplying factors that indicate to libpng that the |
| 4789 | row filter should be the same for successive rows unless another row filter |
| 4790 | is that many times better than the previous filter. In the above example, |
| 4791 | 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] | 4792 | "sum of absolute differences" 1.5 x 1.3 times higher than other filters |
| 4793 | and still be chosen, while the NONE filter could have a sum 1.1 times |
| 4794 | higher than other filters and still be chosen. Unspecified weights are |
| 4795 | taken to be 1.0, and the specified weights should probably be declining |
| 4796 | like those above in order to emphasize recent filters over older filters. |
| 4797 | |
| 4798 | The filter costs specify for each filter type a relative decoding cost |
| 4799 | to be considered when selecting row filters. This means that filters |
| 4800 | with higher costs are less likely to be chosen over filters with lower |
| 4801 | costs, unless their "sum of absolute differences" is that much smaller. |
| 4802 | The costs do not necessarily reflect the exact computational speeds of |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 4803 | the various filters, since this would unduly influence the final image |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4804 | size. |
| 4805 | |
| 4806 | Note that the numbers above were invented purely for this example and |
| 4807 | are given only to help explain the function usage. Little testing has |
| 4808 | been done to find optimum values for either the costs or the weights. |
| 4809 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4810 | .SS Removing unwanted object code |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4811 | |
| 4812 | There are a bunch of #define's in pngconf.h that control what parts of |
| 4813 | 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] | 4814 | never going to use a capability, you can change the #define to #undef |
| 4815 | before recompiling libpng and save yourself code and data space, or |
| 4816 | you can turn off individual capabilities with defines that begin with |
| 4817 | PNG_NO_. |
| 4818 | |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4819 | In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead. |
| 4820 | |
Glenn Randers-Pehrson | d0dce40 | 1998-05-09 10:02:29 -0500 | [diff] [blame] | 4821 | 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] | 4822 | off en masse with compiler directives that define |
Glenn Randers-Pehrson | d0dce40 | 1998-05-09 10:02:29 -0500 | [diff] [blame] | 4823 | PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS, |
| 4824 | or all four, |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4825 | along with directives to turn on any of the capabilities that you do |
Glenn Randers-Pehrson | f210a05 | 2009-11-12 10:02:24 -0600 | [diff] [blame] | 4826 | want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the extra |
| 4827 | transformations but still leave the library fully capable of reading |
| 4828 | and writing PNG files with all known public chunks. Use of the |
| 4829 | PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library |
| 4830 | that is incapable of reading or writing ancillary chunks. If you are |
| 4831 | not using the progressive reading capability, you can turn that off |
| 4832 | with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING |
| 4833 | capability, which you'll still have). |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4834 | |
| 4835 | All the reading and writing specific code are in separate files, so the |
| 4836 | linker should only grab the files it needs. However, if you want to |
| 4837 | make sure, or if you are building a stand alone library, all the |
Glenn Randers-Pehrson | a5e5547 | 2011-07-12 10:13:32 -0500 | [diff] [blame] | 4838 | reading files start with "pngr" and all the writing files start with "pngw". |
| 4839 | The files that don't match either (like png.c, pngtrans.c, etc.) |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4840 | are used for both reading and writing, and always need to be included. |
| 4841 | The progressive reader is in pngpread.c |
| 4842 | |
| 4843 | If you are creating or distributing a dynamically linked library (a .so |
| 4844 | or DLL file), you should not remove or disable any parts of the library, |
| 4845 | as this will cause applications linked with different versions of the |
| 4846 | library to fail if they call functions not available in your library. |
| 4847 | 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] | 4848 | those sections that are actually used will be loaded into memory. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4849 | |
Glenn Randers-Pehrson | 61c32d9 | 2000-02-04 23:40:16 -0600 | [diff] [blame] | 4850 | .SS Requesting debug printout |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4851 | |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 4852 | The macro definition PNG_DEBUG can be used to request debugging |
| 4853 | printout. Set it to an integer value in the range 0 to 3. Higher |
| 4854 | numbers result in increasing amounts of debugging information. The |
| 4855 | information is printed to the "stderr" file, unless another file |
| 4856 | name is specified in the PNG_DEBUG_FILE macro definition. |
| 4857 | |
| 4858 | When PNG_DEBUG > 0, the following functions (macros) become available: |
| 4859 | |
| 4860 | png_debug(level, message) |
| 4861 | png_debug1(level, message, p1) |
| 4862 | png_debug2(level, message, p1, p2) |
| 4863 | |
| 4864 | in which "level" is compared to PNG_DEBUG to decide whether to print |
| 4865 | the message, "message" is the formatted string to be printed, |
| 4866 | and p1 and p2 are parameters that are to be embedded in the string |
| 4867 | according to printf-style formatting directives. For example, |
| 4868 | |
| 4869 | png_debug1(2, "foo=%d\n", foo); |
| 4870 | |
| 4871 | is expanded to |
| 4872 | |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4873 | if (PNG_DEBUG > 2) |
| 4874 | fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo); |
Glenn Randers-Pehrson | 5c6aeb2 | 1998-12-29 11:47:59 -0600 | [diff] [blame] | 4875 | |
| 4876 | When PNG_DEBUG is defined but is zero, the macros aren't defined, but you |
| 4877 | can still use PNG_DEBUG to control your own debugging: |
| 4878 | |
| 4879 | #ifdef PNG_DEBUG |
| 4880 | fprintf(stderr, ... |
| 4881 | #endif |
| 4882 | |
| 4883 | When PNG_DEBUG = 1, the macros are defined, but only png_debug statements |
| 4884 | having level = 0 will be printed. There aren't any such statements in |
| 4885 | this version of libpng, but if you insert some they will be printed. |
| 4886 | |
Glenn Randers-Pehrson | 56f6396 | 2008-10-06 10:16:17 -0500 | [diff] [blame] | 4887 | .SH VI. MNG support |
Glenn Randers-Pehrson | 2ad31ae | 2000-12-15 08:54:42 -0600 | [diff] [blame] | 4888 | |
| 4889 | The MNG specification (available at http://www.libpng.org/pub/mng) allows |
| 4890 | certain extensions to PNG for PNG images that are embedded in MNG datastreams. |
| 4891 | Libpng can support some of these extensions. To enable them, use the |
| 4892 | png_permit_mng_features() function: |
| 4893 | |
| 4894 | feature_set = png_permit_mng_features(png_ptr, mask) |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4895 | |
Glenn Randers-Pehrson | ebd7f9a | 2006-10-19 09:37:56 -0500 | [diff] [blame] | 4896 | mask is a png_uint_32 containing the bitwise OR of the |
Glenn Randers-Pehrson | 2ad31ae | 2000-12-15 08:54:42 -0600 | [diff] [blame] | 4897 | features you want to enable. These include |
| 4898 | PNG_FLAG_MNG_EMPTY_PLTE |
| 4899 | PNG_FLAG_MNG_FILTER_64 |
| 4900 | PNG_ALL_MNG_FEATURES |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4901 | |
Glenn Randers-Pehrson | ebd7f9a | 2006-10-19 09:37:56 -0500 | [diff] [blame] | 4902 | feature_set is a png_uint_32 that is the bitwise AND of |
Glenn Randers-Pehrson | 2ad31ae | 2000-12-15 08:54:42 -0600 | [diff] [blame] | 4903 | your mask with the set of MNG features that is |
| 4904 | supported by the version of libpng that you are using. |
| 4905 | |
Glenn Randers-Pehrson | 408b421 | 2000-12-18 09:33:57 -0600 | [diff] [blame] | 4906 | It is an error to use this function when reading or writing a standalone |
| 4907 | 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] | 4908 | in a MNG datastream. As a minimum, it must have the MNG 8-byte signature |
| 4909 | and the MHDR and MEND chunks. Libpng does not provide support for these |
| 4910 | or any other MNG chunks; your application must provide its own support for |
| 4911 | them. You may wish to consider using libmng (available at |
| 4912 | http://www.libmng.com) instead. |
Glenn Randers-Pehrson | 408b421 | 2000-12-18 09:33:57 -0600 | [diff] [blame] | 4913 | |
Glenn Randers-Pehrson | 8fb550c | 2009-03-21 08:15:32 -0500 | [diff] [blame] | 4914 | .SH VII. Changes to Libpng from version 0.88 |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4915 | |
| 4916 | It should be noted that versions of libpng later than 0.96 are not |
| 4917 | distributed by the original libpng author, Guy Schalnat, nor by |
| 4918 | Andreas Dilger, who had taken over from Guy during 1996 and 1997, and |
| 4919 | distributed versions 0.89 through 0.96, but rather by another member |
| 4920 | of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are |
| 4921 | still alive and well, but they have moved on to other things. |
| 4922 | |
| 4923 | The old libpng functions png_read_init(), png_write_init(), |
Glenn Randers-Pehrson | 8b6a889 | 2001-05-18 04:54:50 -0500 | [diff] [blame] | 4924 | 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] | 4925 | moved to PNG_INTERNAL in version 0.95 to discourage their use. These |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 4926 | functions will be removed from libpng version 1.4.0. |
Glenn Randers-Pehrson | 7529457 | 2000-05-06 14:09:57 -0500 | [diff] [blame] | 4927 | |
| 4928 | The preferred method of creating and initializing the libpng structures is |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4929 | via the png_create_read_struct(), png_create_write_struct(), and |
| 4930 | png_create_info_struct() because they isolate the size of the structures |
| 4931 | from the application, allow version error checking, and also allow the |
| 4932 | use of custom error handling routines during the initialization, which |
| 4933 | the old functions do not. The functions png_read_destroy() and |
| 4934 | png_write_destroy() do not actually free the memory that libpng |
| 4935 | allocated for these structs, but just reset the data structures, so they |
| 4936 | can be used instead of png_destroy_read_struct() and |
| 4937 | png_destroy_write_struct() if you feel there is too much system overhead |
| 4938 | allocating and freeing the png_struct for each image read. |
| 4939 | |
| 4940 | Setting the error callbacks via png_set_message_fn() before |
| 4941 | 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] | 4942 | because this caused applications that do not use custom error functions |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4943 | to fail if the png_ptr was not initialized to zero. It is still possible |
| 4944 | 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] | 4945 | png_set_error_fn(), which is essentially the same function, but with a new |
| 4946 | name to force compilation errors with applications that try to use the old |
| 4947 | method. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 4948 | |
Glenn Randers-Pehrson | 1ef65b6 | 2000-05-12 06:19:53 -0500 | [diff] [blame] | 4949 | Starting with version 1.0.7, you can find out which version of the library |
| 4950 | you are using at run-time: |
| 4951 | |
| 4952 | png_uint_32 libpng_vn = png_access_version_number(); |
| 4953 | |
| 4954 | The number libpng_vn is constructed from the major version, minor |
| 4955 | version with leading zero, and release number with leading zero, |
| 4956 | (e.g., libpng_vn for version 1.0.7 is 10007). |
| 4957 | |
Glenn Randers-Pehrson | 95ba417 | 2011-09-08 12:21:42 -0500 | [diff] [blame] | 4958 | Note that this function does not take a png_ptr, so you can call it |
| 4959 | before you've created one. |
| 4960 | |
Glenn Randers-Pehrson | 1ef65b6 | 2000-05-12 06:19:53 -0500 | [diff] [blame] | 4961 | You can also check which version of png.h you used when compiling your |
| 4962 | application: |
| 4963 | |
| 4964 | png_uint_32 application_vn = PNG_LIBPNG_VER; |
| 4965 | |
Glenn Randers-Pehrson | 6a9c2ce | 2009-03-27 19:30:10 -0500 | [diff] [blame] | 4966 | .SH VIII. Changes to Libpng from version 1.0.x to 1.2.x |
Glenn Randers-Pehrson | 87544ac | 1999-01-13 22:06:39 -0600 | [diff] [blame] | 4967 | |
Glenn Randers-Pehrson | 6a9c2ce | 2009-03-27 19:30:10 -0500 | [diff] [blame] | 4968 | Support for user memory management was enabled by default. To |
| 4969 | accomplish this, the functions png_create_read_struct_2(), |
| 4970 | png_create_write_struct_2(), png_set_mem_fn(), png_get_mem_ptr(), |
| 4971 | png_malloc_default(), and png_free_default() were added. |
| 4972 | |
Glenn Randers-Pehrson | d6ea40a | 2009-11-02 07:32:00 -0600 | [diff] [blame] | 4973 | Support for the iTXt chunk has been enabled by default as of |
| 4974 | version 1.2.41. |
| 4975 | |
Glenn Randers-Pehrson | 6a9c2ce | 2009-03-27 19:30:10 -0500 | [diff] [blame] | 4976 | Support for certain MNG features was enabled. |
| 4977 | |
| 4978 | Support for numbered error messages was added. However, we never got |
| 4979 | around to actually numbering the error messages. The function |
| 4980 | png_set_strip_error_numbers() was added (Note: the prototype for this |
| 4981 | function was inadvertently removed from png.h in PNG_NO_ASSEMBLER_CODE |
| 4982 | builds of libpng-1.2.15. It was restored in libpng-1.2.36). |
| 4983 | |
| 4984 | The png_malloc_warn() function was added at libpng-1.2.3. This issues |
| 4985 | a png_warning and returns NULL instead of aborting when it fails to |
| 4986 | acquire the requested memory allocation. |
| 4987 | |
| 4988 | Support for setting user limits on image width and height was enabled |
| 4989 | by default. The functions png_set_user_limits(), png_get_user_width_max(), |
| 4990 | and png_get_user_height_max() were added at libpng-1.2.6. |
| 4991 | |
| 4992 | The png_set_add_alpha() function was added at libpng-1.2.7. |
| 4993 | |
| 4994 | The function png_set_expand_gray_1_2_4_to_8() was added at libpng-1.2.9. |
| 4995 | Unlike png_set_gray_1_2_4_to_8(), the new function does not expand the |
| 4996 | tRNS chunk to alpha. The png_set_gray_1_2_4_to_8() function is |
| 4997 | deprecated. |
| 4998 | |
| 4999 | A number of macro definitions in support of runtime selection of |
| 5000 | assembler code features (especially Intel MMX code support) were |
| 5001 | added at libpng-1.2.0: |
| 5002 | |
| 5003 | PNG_ASM_FLAG_MMX_SUPPORT_COMPILED |
| 5004 | PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU |
| 5005 | PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
| 5006 | PNG_ASM_FLAG_MMX_READ_INTERLACE |
| 5007 | PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
| 5008 | PNG_ASM_FLAG_MMX_READ_FILTER_UP |
| 5009 | PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
| 5010 | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH |
| 5011 | PNG_ASM_FLAGS_INITIALIZED |
| 5012 | PNG_MMX_READ_FLAGS |
| 5013 | PNG_MMX_FLAGS |
| 5014 | PNG_MMX_WRITE_FLAGS |
| 5015 | PNG_MMX_FLAGS |
| 5016 | |
| 5017 | We added the following functions in support of runtime |
| 5018 | selection of assembler code features: |
| 5019 | |
| 5020 | png_get_mmx_flagmask() |
| 5021 | png_set_mmx_thresholds() |
| 5022 | png_get_asm_flags() |
| 5023 | png_get_mmx_bitdepth_threshold() |
| 5024 | png_get_mmx_rowbytes_threshold() |
| 5025 | png_set_asm_flags() |
| 5026 | |
| 5027 | We replaced all of these functions with simple stubs in libpng-1.2.20, |
| 5028 | when the Intel assembler code was removed due to a licensing issue. |
| 5029 | |
Glenn Randers-Pehrson | 3d893a0 | 2009-08-31 13:32:46 -0500 | [diff] [blame] | 5030 | These macros are deprecated: |
| 5031 | |
| 5032 | PNG_READ_TRANSFORMS_NOT_SUPPORTED |
| 5033 | PNG_PROGRESSIVE_READ_NOT_SUPPORTED |
| 5034 | PNG_NO_SEQUENTIAL_READ_SUPPORTED |
| 5035 | PNG_WRITE_TRANSFORMS_NOT_SUPPORTED |
| 5036 | PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED |
| 5037 | PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED |
| 5038 | |
| 5039 | They have been replaced, respectively, by: |
| 5040 | |
| 5041 | PNG_NO_READ_TRANSFORMS |
| 5042 | PNG_NO_PROGRESSIVE_READ |
| 5043 | PNG_NO_SEQUENTIAL_READ |
| 5044 | PNG_NO_WRITE_TRANSFORMS |
| 5045 | PNG_NO_READ_ANCILLARY_CHUNKS |
| 5046 | PNG_NO_WRITE_ANCILLARY_CHUNKS |
| 5047 | |
Glenn Randers-Pehrson | 6a9c2ce | 2009-03-27 19:30:10 -0500 | [diff] [blame] | 5048 | PNG_MAX_UINT was replaced with PNG_UINT_31_MAX. It has been |
| 5049 | deprecated since libpng-1.0.16 and libpng-1.2.6. |
| 5050 | |
| 5051 | The function |
| 5052 | png_check_sig(sig, num) |
| 5053 | was replaced with |
| 5054 | !png_sig_cmp(sig, 0, num) |
| 5055 | It has been deprecated since libpng-0.90. |
| 5056 | |
Glenn Randers-Pehrson | 6a9c2ce | 2009-03-27 19:30:10 -0500 | [diff] [blame] | 5057 | The function |
| 5058 | png_set_gray_1_2_4_to_8() |
| 5059 | which also expands tRNS to alpha was replaced with |
| 5060 | png_set_expand_gray_1_2_4_to_8() |
| 5061 | which does not. It has been deprecated since libpng-1.0.18 and 1.2.9. |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 5062 | |
Glenn Randers-Pehrson | d740c84 | 2009-11-04 19:01:54 -0600 | [diff] [blame] | 5063 | .SH IX. Changes to Libpng from version 1.0.x/1.2.x to 1.4.x |
| 5064 | |
| 5065 | Private libpng prototypes and macro definitions were moved from |
| 5066 | png.h and pngconf.h into a new pngpriv.h header file. |
| 5067 | |
Glenn Randers-Pehrson | 6a9c2ce | 2009-03-27 19:30:10 -0500 | [diff] [blame] | 5068 | Functions png_set_benign_errors(), png_benign_error(), and |
| 5069 | png_chunk_benign_error() were added. |
| 5070 | |
| 5071 | Support for setting the maximum amount of memory that the application |
| 5072 | will allocate for reading chunks was added, as a security measure. |
| 5073 | The functions png_set_chunk_cache_max() and png_get_chunk_cache_max() |
| 5074 | were added to the library. |
| 5075 | |
Glenn Randers-Pehrson | f210a05 | 2009-11-12 10:02:24 -0600 | [diff] [blame] | 5076 | We implemented support for I/O states by adding png_ptr member io_state |
| 5077 | and functions png_get_io_chunk_name() and png_get_io_state() in pngget.c |
Glenn Randers-Pehrson | 6a9c2ce | 2009-03-27 19:30:10 -0500 | [diff] [blame] | 5078 | |
Glenn Randers-Pehrson | 5df7edb | 2009-10-29 23:32:44 -0500 | [diff] [blame] | 5079 | We added PNG_TRANSFORM_GRAY_TO_RGB to the available high-level |
| 5080 | input transforms. |
| 5081 | |
Glenn Randers-Pehrson | 5df7edb | 2009-10-29 23:32:44 -0500 | [diff] [blame] | 5082 | Checking for and reporting of errors in the IHDR chunk is more thorough. |
| 5083 | |
Glenn Randers-Pehrson | 45af819 | 2009-12-30 08:37:29 -0600 | [diff] [blame] | 5084 | Support for global arrays was removed, to improve thread safety. |
| 5085 | |
| 5086 | Some obsolete/deprecated macros and functions have been removed. |
| 5087 | |
| 5088 | Typecasted NULL definitions such as |
| 5089 | #define png_voidp_NULL (png_voidp)NULL |
| 5090 | were eliminated. If you used these in your application, just use |
| 5091 | NULL instead. |
| 5092 | |
| 5093 | The png_struct and info_struct members "trans" and "trans_values" were |
| 5094 | changed to "trans_alpha" and "trans_color", respectively. |
| 5095 | |
| 5096 | The obsolete, unused pnggccrd.c and pngvcrd.c files and related makefiles |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 5097 | were removed. |
Glenn Randers-Pehrson | 45af819 | 2009-12-30 08:37:29 -0600 | [diff] [blame] | 5098 | |
| 5099 | The PNG_1_0_X and PNG_1_2_X macros were eliminated. |
| 5100 | |
Glenn Randers-Pehrson | 5df7edb | 2009-10-29 23:32:44 -0500 | [diff] [blame] | 5101 | The PNG_LEGACY_SUPPORTED macro was eliminated. |
| 5102 | |
| 5103 | Many WIN32_WCE #ifdefs were removed. |
| 5104 | |
| 5105 | The functions png_read_init(info_ptr), png_write_init(info_ptr), |
| 5106 | png_info_init(info_ptr), png_read_destroy(), and png_write_destroy() |
| 5107 | have been removed. They have been deprecated since libpng-0.95. |
| 5108 | |
Glenn Randers-Pehrson | 6a9c2ce | 2009-03-27 19:30:10 -0500 | [diff] [blame] | 5109 | The png_permit_empty_plte() was removed. It has been deprecated |
| 5110 | since libpng-1.0.9. Use png_permit_mng_features() instead. |
| 5111 | |
| 5112 | We removed the obsolete stub functions png_get_mmx_flagmask(), |
| 5113 | png_set_mmx_thresholds(), png_get_asm_flags(), |
| 5114 | png_get_mmx_bitdepth_threshold(), png_get_mmx_rowbytes_threshold(), |
| 5115 | png_set_asm_flags(), and png_mmx_supported() |
| 5116 | |
Glenn Randers-Pehrson | 45af819 | 2009-12-30 08:37:29 -0600 | [diff] [blame] | 5117 | We removed the obsolete png_check_sig(), png_memcpy_check(), and |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 5118 | png_memset_check() functions. Instead use !png_sig_cmp(), memcpy(), |
| 5119 | and memset(), respectively. |
Glenn Randers-Pehrson | 6a9c2ce | 2009-03-27 19:30:10 -0500 | [diff] [blame] | 5120 | |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 5121 | The function png_set_gray_1_2_4_to_8() was removed. It has been |
| 5122 | deprecated since libpng-1.0.18 and 1.2.9, when it was replaced with |
| 5123 | png_set_expand_gray_1_2_4_to_8() because the former function also |
Glenn Randers-Pehrson | c36bb79 | 2011-02-12 09:49:07 -0600 | [diff] [blame] | 5124 | expanded any tRNS chunk to an alpha channel. |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 5125 | |
Glenn Randers-Pehrson | 5b40b01 | 2010-11-25 07:16:29 -0600 | [diff] [blame] | 5126 | Macros for png_get_uint_16, png_get_uint_32, and png_get_int_32 |
| 5127 | were added and are used by default instead of the corresponding |
| 5128 | functions. Unfortunately, |
Glenn Randers-Pehrson | c36bb79 | 2011-02-12 09:49:07 -0600 | [diff] [blame] | 5129 | from libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the |
Glenn Randers-Pehrson | 5b40b01 | 2010-11-25 07:16:29 -0600 | [diff] [blame] | 5130 | function) incorrectly returned a value of type png_uint_32. |
| 5131 | |
Glenn Randers-Pehrson | 6a9c2ce | 2009-03-27 19:30:10 -0500 | [diff] [blame] | 5132 | We changed the prototype for png_malloc() from |
| 5133 | png_malloc(png_structp png_ptr, png_uint_32 size) |
| 5134 | to |
| 5135 | png_malloc(png_structp png_ptr, png_alloc_size_t size) |
| 5136 | |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 5137 | This also applies to the prototype for the user replacement malloc_fn(). |
| 5138 | |
Glenn Randers-Pehrson | 45af819 | 2009-12-30 08:37:29 -0600 | [diff] [blame] | 5139 | The png_calloc() function was added and is used in place of |
Glenn Randers-Pehrson | 2be8b64 | 2010-07-29 19:09:18 -0500 | [diff] [blame] | 5140 | of "png_malloc(); memset();" except in the case in png_read_png() |
Glenn Randers-Pehrson | 45af819 | 2009-12-30 08:37:29 -0600 | [diff] [blame] | 5141 | where the array consists of pointers; in this case a "for" loop is used |
| 5142 | after the png_malloc() to set the pointers to NULL, to give robust. |
| 5143 | behavior in case the application runs out of memory part-way through |
| 5144 | the process. |
| 5145 | |
Glenn Randers-Pehrson | 6a9c2ce | 2009-03-27 19:30:10 -0500 | [diff] [blame] | 5146 | We changed the prototypes of png_get_compression_buffer_size() and |
| 5147 | png_set_compression_buffer_size() to work with png_size_t instead of |
| 5148 | png_uint_32. |
| 5149 | |
Glenn Randers-Pehrson | 45af819 | 2009-12-30 08:37:29 -0600 | [diff] [blame] | 5150 | Support for numbered error messages was removed by default, since we |
| 5151 | never got around to actually numbering the error messages. The function |
| 5152 | png_set_strip_error_numbers() was removed from the library by default. |
| 5153 | |
| 5154 | The png_zalloc() and png_zfree() functions are no longer exported. |
Glenn Randers-Pehrson | 6a9c2ce | 2009-03-27 19:30:10 -0500 | [diff] [blame] | 5155 | The png_zalloc() function no longer zeroes out the memory that it |
| 5156 | allocates. |
| 5157 | |
Glenn Randers-Pehrson | 3cd7cff | 2010-04-16 19:27:08 -0500 | [diff] [blame] | 5158 | Support for dithering was disabled by default in libpng-1.4.0, because |
Glenn Randers-Pehrson | 9f1cd70 | 2011-04-16 19:40:23 -0500 | [diff] [blame] | 5159 | it has not been well tested and doesn't actually "dither". |
| 5160 | The code was not |
Glenn Randers-Pehrson | 3cd7cff | 2010-04-16 19:27:08 -0500 | [diff] [blame] | 5161 | removed, however, and could be enabled by building libpng with |
| 5162 | PNG_READ_DITHER_SUPPORTED defined. In libpng-1.4.2, this support |
| 5163 | was reenabled, but the function was renamed png_set_quantize() to |
| 5164 | reflect more accurately what it actually does. At the same time, |
| 5165 | the PNG_DITHER_[RED,GREEN_BLUE]_BITS macros were also renamed to |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 5166 | PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS, and PNG_READ_DITHER_SUPPORTED |
| 5167 | was renamed to PNG_READ_QUANTIZE_SUPPORTED. |
Glenn Randers-Pehrson | 6098807 | 2010-04-13 22:11:06 -0500 | [diff] [blame] | 5168 | |
Glenn Randers-Pehrson | 6a9c2ce | 2009-03-27 19:30:10 -0500 | [diff] [blame] | 5169 | We removed the trailing '.' from the warning and error messages. |
| 5170 | |
Glenn Randers-Pehrson | 5b40b01 | 2010-11-25 07:16:29 -0600 | [diff] [blame] | 5171 | .SH X. Changes to Libpng from version 1.4.x to 1.5.x |
| 5172 | |
Glenn Randers-Pehrson | c36bb79 | 2011-02-12 09:49:07 -0600 | [diff] [blame] | 5173 | From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the |
Glenn Randers-Pehrson | 5b40b01 | 2010-11-25 07:16:29 -0600 | [diff] [blame] | 5174 | function) incorrectly returned a value of type png_uint_32. |
| 5175 | |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 5176 | A. Changes that affect users of libpng |
| 5177 | |
| 5178 | There are no substantial API changes between the non-deprecated parts of |
| 5179 | the 1.4.5 API and the 1.5.0 API, however the ability to directly access |
| 5180 | the main libpng control structures, png_struct and png_info, deprecated |
| 5181 | in earlier versions of libpng, has been completely removed from |
| 5182 | libpng 1.5. |
| 5183 | |
Glenn Randers-Pehrson | 00879b1 | 2011-01-15 19:25:34 -0600 | [diff] [blame] | 5184 | We no longer include zlib.h in png.h. Applications that need access |
| 5185 | to information in zlib.h will need to add the '#include "zlib.h"' |
| 5186 | directive. It does not matter whether it is placed prior to or after |
| 5187 | the '"#include png.h"' directive. |
| 5188 | |
| 5189 | We moved the png_strcpy(), png_strncpy(), png_strlen(), png_memcpy(), |
| 5190 | png_memcmp(), png_sprintf, and png_memcpy() macros into a private |
| 5191 | header file (pngpriv.h) that is not accessible to applications. |
| 5192 | |
Glenn Randers-Pehrson | 9d23b40 | 2011-01-08 10:42:01 -0600 | [diff] [blame] | 5193 | In png_get_iCCP, the type of "profile" was changed from png_charpp |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 5194 | to png_bytepp, and in png_set_iCCP, from png_charp to png_const_bytep. |
Glenn Randers-Pehrson | 9d23b40 | 2011-01-08 10:42:01 -0600 | [diff] [blame] | 5195 | |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 5196 | There are changes of form in png.h, including new and changed macros to |
Glenn Randers-Pehrson | 95ba417 | 2011-09-08 12:21:42 -0500 | [diff] [blame] | 5197 | declare parts of the API. Some API functions with arguments that are |
| 5198 | pointers to data not modified within the function have been corrected to |
| 5199 | declare these arguments with PNG_CONST. |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 5200 | |
| 5201 | Much of the internal use of C macros to control the library build has also |
| 5202 | changed and some of this is visible in the exported header files, in |
| 5203 | particular the use of macros to control data and API elements visible |
| 5204 | during application compilation may require significant revision to |
| 5205 | application code. (It is extremely rare for an application to do this.) |
| 5206 | |
| 5207 | Any program that compiled against libpng 1.4 and did not use deprecated |
| 5208 | features or access internal library structures should compile and work |
Glenn Randers-Pehrson | d08b6bd | 2011-02-19 15:50:17 -0600 | [diff] [blame] | 5209 | against libpng 1.5, except for the change in the prototype for |
| 5210 | png_get_iCCP() and png_set_iCCP() API functions mentioned above. |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 5211 | |
Glenn Randers-Pehrson | 6e97410 | 2010-12-19 16:44:22 -0600 | [diff] [blame] | 5212 | libpng 1.5.0 adds PNG_ PASS macros to help in the reading and writing of |
| 5213 | interlaced images. The macros return the number of rows and columns in |
| 5214 | each pass and information that can be used to de-interlace and (if |
| 5215 | absolutely necessary) interlace an image. |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 5216 | |
| 5217 | libpng 1.5.0 adds an API png_longjmp(png_ptr, value). This API calls |
Glenn Randers-Pehrson | d08b6bd | 2011-02-19 15:50:17 -0600 | [diff] [blame] | 5218 | the application-provided png_longjmp_ptr on the internal, but application |
Glenn Randers-Pehrson | 33ced44 | 2011-04-27 14:58:06 -0500 | [diff] [blame] | 5219 | initialized, longjmp buffer. It is provided as a convenience to avoid |
| 5220 | the need to use the png_jmpbuf macro, which had the unnecessary side |
| 5221 | effect of resetting the internal png_longjmp_ptr value. |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 5222 | |
| 5223 | libpng 1.5.0 includes a complete fixed point API. By default this is |
| 5224 | present along with the corresponding floating point API. In general the |
| 5225 | fixed point API is faster and smaller than the floating point one because |
| 5226 | the PNG file format used fixed point, not floating point. This applies |
| 5227 | even if the library uses floating point in internal calculations. A new |
| 5228 | macro, PNG_FLOATING_ARITHMETIC_SUPPORTED, reveals whether the library |
| 5229 | uses floating point arithmetic (the default) or fixed point arithmetic |
| 5230 | internally for performance critical calculations such as gamma correction. |
Glenn Randers-Pehrson | 00879b1 | 2011-01-15 19:25:34 -0600 | [diff] [blame] | 5231 | In some cases, the gamma calculations may produce slightly different |
| 5232 | results. This has changed the results in png_rgb_to_gray and in alpha |
| 5233 | composition (png_set_background for example). This applies even if the |
| 5234 | original image was already linear (gamma == 1.0) and, therefore, it is |
| 5235 | not necessary to linearize the image. This is because libpng has *not* |
| 5236 | been changed to optimize that case correctly, yet. |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 5237 | |
| 5238 | Fixed point support for the sCAL chunk comes with an important caveat; |
| 5239 | the sCAL specification uses a decimal encoding of floating point values |
| 5240 | and the accuracy of PNG fixed point values is insufficient for |
| 5241 | representation of these values. Consequently a "string" API |
| 5242 | (png_get_sCAL_s and png_set_sCAL_s) is the only reliable way of reading |
| 5243 | arbitrary sCAL chunks in the absence of either the floating point API or |
| 5244 | internal floating point calculations. |
| 5245 | |
| 5246 | Applications no longer need to include the optional distribution header |
| 5247 | file pngusr.h or define the corresponding macros during application |
| 5248 | build in order to see the correct variant of the libpng API. From 1.5.0 |
| 5249 | application code can check for the corresponding _SUPPORTED macro: |
| 5250 | |
| 5251 | #ifdef PNG_INCH_CONVERSIONS_SUPPORTED |
| 5252 | /* code that uses the inch conversion APIs. */ |
| 5253 | #endif |
| 5254 | |
| 5255 | This macro will only be defined if the inch conversion functions have been |
| 5256 | compiled into libpng. The full set of macros, and whether or not support |
| 5257 | has been compiled in, are available in the header file pnglibconf.h. |
| 5258 | This header file is specific to the libpng build. Notice that prior to |
| 5259 | 1.5.0 the _SUPPORTED macros would always have the default definition unless |
| 5260 | reset by pngusr.h or by explicit settings on the compiler command line. |
| 5261 | These settings may produce compiler warnings or errors in 1.5.0 because |
| 5262 | of macro redefinition. |
| 5263 | |
Glenn Randers-Pehrson | c36bb79 | 2011-02-12 09:49:07 -0600 | [diff] [blame] | 5264 | From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 5265 | function) incorrectly returned a value of type png_uint_32. libpng 1.5.0 |
| 5266 | is consistent with the implementation in 1.4.5 and 1.2.x (where the macro |
| 5267 | did not exist.) |
| 5268 | |
| 5269 | Applications can now choose whether to use these macros or to call the |
| 5270 | corresponding function by defining PNG_USE_READ_MACROS or |
| 5271 | PNG_NO_USE_READ_MACROS before including png.h. Notice that this is |
| 5272 | only supported from 1.5.0 -defining PNG_NO_USE_READ_MACROS prior to 1.5.0 |
Glenn Randers-Pehrson | 95ba417 | 2011-09-08 12:21:42 -0500 | [diff] [blame] | 5273 | will lead to a link failure. |
Glenn Randers-Pehrson | 59fa3e9 | 2011-01-06 07:07:06 -0600 | [diff] [blame] | 5274 | |
Glenn Randers-Pehrson | 733b131 | 2011-06-15 13:21:01 -0500 | [diff] [blame] | 5275 | Prior to libpng-1.5.4, the zlib compressor used the same set of parameters |
Glenn Randers-Pehrson | 8eb8833 | 2011-04-01 00:16:50 -0500 | [diff] [blame] | 5276 | when compressing the IDAT data and textual data such as zTXt and iCCP. |
Glenn Randers-Pehrson | 733b131 | 2011-06-15 13:21:01 -0500 | [diff] [blame] | 5277 | In libpng-1.5.4 we reinitialized the zlib stream for each type of data. |
Glenn Randers-Pehrson | 8eb8833 | 2011-04-01 00:16:50 -0500 | [diff] [blame] | 5278 | We added five png_set_text_*() functions for setting the parameters to |
| 5279 | use with textual data. |
| 5280 | |
Glenn Randers-Pehrson | 733b131 | 2011-06-15 13:21:01 -0500 | [diff] [blame] | 5281 | Prior to libpng-1.5.4, the PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED |
John Bowler | b2bee33 | 2011-06-10 23:24:58 -0500 | [diff] [blame] | 5282 | option was off by default, and slightly inaccurate scaling occurred. |
Glenn Randers-Pehrson | fb29e51 | 2011-06-17 20:38:24 -0500 | [diff] [blame] | 5283 | This option can no longer be turned off, and the choice of accurate |
| 5284 | or inaccurate 16-to-8 scaling is by using the new png_set_scale_16_to_8() |
| 5285 | API for accurate scaling or the old png_set_strip_16_to_8() API for simple |
| 5286 | chopping. |
Glenn Randers-Pehrson | 0cb906d | 2011-06-11 14:22:22 -0500 | [diff] [blame] | 5287 | |
Glenn Randers-Pehrson | 733b131 | 2011-06-15 13:21:01 -0500 | [diff] [blame] | 5288 | Prior to libpng-1.5.4, the png_set_user_limits() function could only be |
Glenn Randers-Pehrson | 0cb906d | 2011-06-11 14:22:22 -0500 | [diff] [blame] | 5289 | used to reduce the width and height limits from the value of |
| 5290 | PNG_USER_WIDTH_MAX and PNG_USER_HEIGHT_MAX, although this document said |
| 5291 | that it could be used to override them. Now this function will reduce or |
| 5292 | increase the limits. |
John Bowler | b2bee33 | 2011-06-10 23:24:58 -0500 | [diff] [blame] | 5293 | |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 5294 | B. Changes to the build and configuration of libpng |
| 5295 | |
| 5296 | Details of internal changes to the library code can be found in the CHANGES |
Glenn Randers-Pehrson | a5e5547 | 2011-07-12 10:13:32 -0500 | [diff] [blame] | 5297 | file and in the GIT repository logs. These will be of no concern to the vast |
| 5298 | majority of library users or builders, however the few who configure libpng |
| 5299 | to a non-default feature set may need to change how this is done. |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 5300 | |
| 5301 | There should be no need for library builders to alter build scripts if |
| 5302 | these use the distributed build support - configure or the makefiles - |
| 5303 | however users of the makefiles may care to update their build scripts |
| 5304 | to build pnglibconf.h where the corresponding makefile does not do so. |
| 5305 | |
| 5306 | Building libpng with a non-default configuration has changed completely. |
| 5307 | The old method using pngusr.h should still work correctly even though the |
Glenn Randers-Pehrson | a5e5547 | 2011-07-12 10:13:32 -0500 | [diff] [blame] | 5308 | way pngusr.h is used in the build has been changed; however, library |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 5309 | builders will probably want to examine the changes to take advantage of |
| 5310 | new capabilities and to simplify their build system. |
| 5311 | |
| 5312 | B.1 Specific changes to library configuration capabilities |
| 5313 | |
| 5314 | The library now supports a complete fixed point implementation and can |
Glenn Randers-Pehrson | a5e5547 | 2011-07-12 10:13:32 -0500 | [diff] [blame] | 5315 | thus be used on systems that have no floating point support or very |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 5316 | limited or slow support. Previously gamma correction, an essential part |
| 5317 | of complete PNG support, required reasonably fast floating point. |
| 5318 | |
| 5319 | As part of this the choice of internal implementation has been made |
| 5320 | independent of the choice of fixed versus floating point APIs and all the |
| 5321 | missing fixed point APIs have been implemented. |
| 5322 | |
| 5323 | The exact mechanism used to control attributes of API functions has |
| 5324 | changed. A single set of operating system independent macro definitions |
| 5325 | is used and operating system specific directives are defined in |
| 5326 | pnglibconf.h |
| 5327 | |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 5328 | As part of this the mechanism used to choose procedure call standards on |
| 5329 | those systems that allow a choice has been changed. At present this only |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 5330 | affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems |
Glenn Randers-Pehrson | a5e5547 | 2011-07-12 10:13:32 -0500 | [diff] [blame] | 5331 | running on Intel processors. As before, PNGAPI is defined where required |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 5332 | to control the exported API functions; however, two new macros, PNGCBAPI |
| 5333 | and PNGCAPI, are used instead for callback functions (PNGCBAPI) and |
| 5334 | (PNGCAPI) for functions that must match a C library prototype (currently |
| 5335 | only png_longjmp_ptr, which must match the C longjmp function.) The new |
| 5336 | approach is documented in pngconf.h |
| 5337 | |
Glenn Randers-Pehrson | a5e5547 | 2011-07-12 10:13:32 -0500 | [diff] [blame] | 5338 | Despite these changes, libpng 1.5.0 only supports the native C function |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 5339 | calling standard on those platforms tested so far (__cdecl on Microsoft |
| 5340 | Windows). This is because the support requirements for alternative |
| 5341 | calling conventions seem to no longer exist. Developers who find it |
| 5342 | necessary to set PNG_API_RULE to 1 should advise the mailing list |
| 5343 | (png-mng-implement) of this and library builders who use Openwatcom and |
| 5344 | therefore set PNG_API_RULE to 2 should also contact the mailing list. |
| 5345 | |
| 5346 | A new test program, pngvalid, is provided in addition to pngtest. |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 5347 | pngvalid validates the arithmetic accuracy of the gamma correction |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 5348 | calculations and includes a number of validations of the file format. |
| 5349 | A subset of the full range of tests is run when "make check" is done |
| 5350 | (in the 'configure' build.) pngvalid also allows total allocated memory |
| 5351 | usage to be evaluated and performs additional memory overwrite validation. |
| 5352 | |
| 5353 | Many changes to individual feature macros have been made. The following |
| 5354 | are the changes most likely to be noticed by library builders who |
| 5355 | configure libpng: |
| 5356 | |
| 5357 | 1) All feature macros now have consistent naming: |
| 5358 | |
| 5359 | #define PNG_NO_feature turns the feature off |
| 5360 | #define PNG_feature_SUPPORTED turns the feature on |
| 5361 | |
| 5362 | pnglibconf.h contains one line for each feature macro which is either: |
| 5363 | |
| 5364 | #define PNG_feature_SUPPORTED |
| 5365 | |
| 5366 | if the feature is supported or: |
| 5367 | |
| 5368 | /*#undef PNG_feature_SUPPORTED*/ |
| 5369 | |
| 5370 | if it is not. Library code consistently checks for the 'SUPPORTED' macro. |
Glenn Randers-Pehrson | d0797f5 | 2011-07-12 10:28:02 -0500 | [diff] [blame] | 5371 | It does not, and libpng applications should not, check for the 'NO' macro |
| 5372 | which will not normally be defined even if the feature is not supported. |
| 5373 | The 'NO' macros are only used internally for setting or not setting the |
| 5374 | corresponding 'SUPPORTED' macros. |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 5375 | |
| 5376 | Compatibility with the old names is provided as follows: |
| 5377 | |
| 5378 | PNG_INCH_CONVERSIONS turns on PNG_INCH_CONVERSIONS_SUPPORTED |
| 5379 | |
| 5380 | And the following definitions disable the corresponding feature: |
| 5381 | |
| 5382 | PNG_SETJMP_NOT_SUPPORTED disables SETJMP |
| 5383 | PNG_READ_TRANSFORMS_NOT_SUPPORTED disables READ_TRANSFORMS |
| 5384 | PNG_NO_READ_COMPOSITED_NODIV disables READ_COMPOSITE_NODIV |
| 5385 | PNG_WRITE_TRANSFORMS_NOT_SUPPORTED disables WRITE_TRANSFORMS |
| 5386 | PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED disables READ_ANCILLARY_CHUNKS |
| 5387 | PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED disables WRITE_ANCILLARY_CHUNKS |
| 5388 | |
| 5389 | Library builders should remove use of the above, inconsistent, names. |
| 5390 | |
| 5391 | 2) Warning and error message formatting was previously conditional on |
| 5392 | the STDIO feature. The library has been changed to use the |
| 5393 | CONSOLE_IO feature instead. This means that if CONSOLE_IO is disabled |
| 5394 | the library no longer uses the printf(3) functions, even though the |
| 5395 | default read/write implementations use (FILE) style stdio.h functions. |
| 5396 | |
| 5397 | 3) Three feature macros now control the fixed/floating point decisions: |
| 5398 | |
| 5399 | PNG_FLOATING_POINT_SUPPORTED enables the floating point APIs |
| 5400 | |
| 5401 | PNG_FIXED_POINT_SUPPORTED enables the fixed point APIs; however, in |
| 5402 | practice these are normally required internally anyway (because the PNG |
| 5403 | file format is fixed point), therefore in most cases PNG_NO_FIXED_POINT |
| 5404 | merely stops the function from being exported. |
| 5405 | |
| 5406 | PNG_FLOATING_ARITHMETIC_SUPPORTED chooses between the internal floating |
| 5407 | point implementation or the fixed point one. Typically the fixed point |
| 5408 | implementation is larger and slower than the floating point implementation |
| 5409 | on a system that supports floating point, however it may be faster on a |
| 5410 | system which lacks floating point hardware and therefore uses a software |
| 5411 | emulation. |
| 5412 | |
| 5413 | 4) Added PNG_{READ,WRITE}_INT_FUNCTIONS_SUPPORTED. This allows the |
| 5414 | functions to read and write ints to be disabled independently of |
| 5415 | PNG_USE_READ_MACROS, which allows libpng to be built with the functions |
| 5416 | even though the default is to use the macros - this allows applications |
| 5417 | to choose at app buildtime whether or not to use macros (previously |
| 5418 | impossible because the functions weren't in the default build.) |
| 5419 | |
| 5420 | B.2 Changes to the configuration mechanism |
| 5421 | |
| 5422 | Prior to libpng-1.5.0 library builders who needed to configure libpng |
| 5423 | had either to modify the exported pngconf.h header file to add system |
| 5424 | specific configuration or had to write feature selection macros into |
| 5425 | pngusr.h and cause this to be included into pngconf.h by defining |
| 5426 | PNG_USER_CONFIG. The latter mechanism had the disadvantage that an |
| 5427 | application built without PNG_USER_CONFIG defined would see the |
| 5428 | unmodified, default, libpng API and thus would probably fail to link. |
| 5429 | |
| 5430 | These mechanisms still work in the configure build and in any makefile |
Glenn Randers-Pehrson | a5e5547 | 2011-07-12 10:13:32 -0500 | [diff] [blame] | 5431 | build that builds pnglibconf.h, although the feature selection macros |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 5432 | have changed somewhat as described above. In 1.5.0, however, pngusr.h is |
| 5433 | processed only once, when the exported header file pnglibconf.h is built. |
Glenn Randers-Pehrson | a5e5547 | 2011-07-12 10:13:32 -0500 | [diff] [blame] | 5434 | pngconf.h no longer includes pngusr.h, therefore pngusr.h is ignored after the |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 5435 | build of pnglibconf.h and it is never included in an application build. |
| 5436 | |
| 5437 | The rarely used alternative of adding a list of feature macros to the |
| 5438 | CFLAGS setting in the build also still works, however the macros will be |
| 5439 | copied to pnglibconf.h and this may produce macro redefinition warnings |
| 5440 | when the individual C files are compiled. |
| 5441 | |
| 5442 | All configuration now only works if pnglibconf.h is built from |
| 5443 | scripts/pnglibconf.dfa. This requires the program awk. Brian Kernighan |
| 5444 | (the original author of awk) maintains C source code of that awk and this |
| 5445 | and all known later implementations (often called by subtly different |
| 5446 | names - nawk and gawk for example) are adequate to build pnglibconf.h. |
| 5447 | The Sun Microsystems (now Oracle) program 'awk' is an earlier version |
Glenn Randers-Pehrson | a5e5547 | 2011-07-12 10:13:32 -0500 | [diff] [blame] | 5448 | and does not work; this may also apply to other systems that have a |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 5449 | functioning awk called 'nawk'. |
| 5450 | |
| 5451 | Configuration options are now documented in scripts/pnglibconf.dfa. This |
| 5452 | file also includes dependency information that ensures a configuration is |
| 5453 | consistent; that is, if a feature is switched off dependent features are |
| 5454 | also removed. As a recommended alternative to using feature macros in |
| 5455 | pngusr.h a system builder may also define equivalent options in pngusr.dfa |
| 5456 | (or, indeed, any file) and add that to the configuration by setting |
| 5457 | DFA_XTRA to the file name. The makefiles in contrib/pngminim illustrate |
| 5458 | how to do this, and a case where pngusr.h is still required. |
| 5459 | |
Glenn Randers-Pehrson | 5b40b01 | 2010-11-25 07:16:29 -0600 | [diff] [blame] | 5460 | .SH XI. Detecting libpng |
Glenn Randers-Pehrson | 424c985 | 2009-06-02 13:45:15 -0500 | [diff] [blame] | 5461 | |
| 5462 | The png_get_io_ptr() function has been present since libpng-0.88, has never |
| 5463 | changed, and is unaffected by conditional compilation macros. It is the |
| 5464 | best choice for use in configure scripts for detecting the presence of any |
Glenn Randers-Pehrson | 99708d5 | 2009-06-29 17:30:00 -0500 | [diff] [blame] | 5465 | libpng version since 0.88. In an autoconf "configure.in" you could use |
| 5466 | |
| 5467 | AC_CHECK_LIB(png, png_get_io_ptr, ... |
Glenn Randers-Pehrson | 424c985 | 2009-06-02 13:45:15 -0500 | [diff] [blame] | 5468 | |
Glenn Randers-Pehrson | 5b40b01 | 2010-11-25 07:16:29 -0600 | [diff] [blame] | 5469 | .SH XII. Source code repository |
Glenn Randers-Pehrson | 7654682 | 2009-05-16 07:25:42 -0500 | [diff] [blame] | 5470 | |
| 5471 | Since about February 2009, version 1.2.34, libpng has been under "git" source |
| 5472 | control. The git repository was built from old libpng-x.y.z.tar.gz files |
| 5473 | going back to version 0.70. You can access the git repository (read only) |
| 5474 | at |
| 5475 | |
| 5476 | git://libpng.git.sourceforge.net/gitroot/libpng |
| 5477 | |
| 5478 | or you can browse it via "gitweb" at |
| 5479 | |
| 5480 | http://libpng.git.sourceforge.net/git/gitweb.cgi?p=libpng |
| 5481 | |
| 5482 | Patches can be sent to glennrp at users.sourceforge.net or to |
| 5483 | png-mng-implement at lists.sourceforge.net or you can upload them to |
| 5484 | the libpng bug tracker at |
| 5485 | |
| 5486 | http://libpng.sourceforge.net |
| 5487 | |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 5488 | We also accept patches built from the tar or zip distributions, and |
| 5489 | simple verbal discriptions of bug fixes, reported either to the |
Glenn Randers-Pehrson | a5e5547 | 2011-07-12 10:13:32 -0500 | [diff] [blame] | 5490 | SourceForge bug tracker, to the png-mng-implement at lists.sf.net |
| 5491 | mailing list, or directly to glennrp. |
Glenn Randers-Pehrson | 7bc2501 | 2011-01-21 23:29:09 -0600 | [diff] [blame] | 5492 | |
Glenn Randers-Pehrson | 5b40b01 | 2010-11-25 07:16:29 -0600 | [diff] [blame] | 5493 | .SH XIII. Coding style |
Glenn Randers-Pehrson | 7654682 | 2009-05-16 07:25:42 -0500 | [diff] [blame] | 5494 | |
| 5495 | Our coding style is similar to the "Allman" style, with curly |
| 5496 | braces on separate lines: |
| 5497 | |
| 5498 | if (condition) |
| 5499 | { |
| 5500 | action; |
| 5501 | } |
| 5502 | |
| 5503 | else if (another condition) |
| 5504 | { |
| 5505 | another action; |
| 5506 | } |
| 5507 | |
| 5508 | The braces can be omitted from simple one-line actions: |
| 5509 | |
| 5510 | if (condition) |
| 5511 | return (0); |
| 5512 | |
| 5513 | We use 3-space indentation, except for continued statements which |
| 5514 | are usually indented the same as the first line of the statement |
| 5515 | plus four more spaces. |
| 5516 | |
Glenn Randers-Pehrson | 5ade7ed | 2009-09-30 15:11:49 -0500 | [diff] [blame] | 5517 | For macro definitions we use 2-space indentation, always leaving the "#" |
| 5518 | in the first column. |
| 5519 | |
| 5520 | #ifndef PNG_NO_FEATURE |
| 5521 | # ifndef PNG_FEATURE_SUPPORTED |
| 5522 | # define PNG_FEATURE_SUPPORTED |
| 5523 | # endif |
| 5524 | #endif |
| 5525 | |
Glenn Randers-Pehrson | 7654682 | 2009-05-16 07:25:42 -0500 | [diff] [blame] | 5526 | Comments appear with the leading "/*" at the same indentation as |
| 5527 | the statement that follows the comment: |
| 5528 | |
| 5529 | /* Single-line comment */ |
| 5530 | statement; |
| 5531 | |
Glenn Randers-Pehrson | e4c706a | 2010-03-06 14:51:54 -0600 | [diff] [blame] | 5532 | /* This is a multiple-line |
| 5533 | * comment. |
Glenn Randers-Pehrson | 7654682 | 2009-05-16 07:25:42 -0500 | [diff] [blame] | 5534 | */ |
| 5535 | statement; |
| 5536 | |
Glenn Randers-Pehrson | e4c706a | 2010-03-06 14:51:54 -0600 | [diff] [blame] | 5537 | Very short comments can be placed after the end of the statement |
Glenn Randers-Pehrson | 7654682 | 2009-05-16 07:25:42 -0500 | [diff] [blame] | 5538 | to which they pertain: |
| 5539 | |
| 5540 | statement; /* comment */ |
| 5541 | |
| 5542 | We don't use C++ style ("//") comments. We have, however, |
| 5543 | used them in the past in some now-abandoned MMX assembler |
| 5544 | code. |
| 5545 | |
Glenn Randers-Pehrson | b5444a1 | 2009-06-08 08:36:19 -0500 | [diff] [blame] | 5546 | Functions and their curly braces are not indented, and |
Glenn Randers-Pehrson | 7654682 | 2009-05-16 07:25:42 -0500 | [diff] [blame] | 5547 | exported functions are marked with PNGAPI: |
| 5548 | |
| 5549 | /* This is a public function that is visible to |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 5550 | * application programmers. It does thus-and-so. |
Glenn Randers-Pehrson | 7654682 | 2009-05-16 07:25:42 -0500 | [diff] [blame] | 5551 | */ |
| 5552 | void PNGAPI |
| 5553 | png_exported_function(png_ptr, png_info, foo) |
| 5554 | { |
| 5555 | body; |
| 5556 | } |
| 5557 | |
Glenn Randers-Pehrson | 416976f | 2009-07-27 22:16:09 -0500 | [diff] [blame] | 5558 | The prototypes for all exported functions appear in png.h, |
| 5559 | above the comment that says |
| 5560 | |
| 5561 | /* Maintainer: Put new public prototypes here ... */ |
Glenn Randers-Pehrson | 7654682 | 2009-05-16 07:25:42 -0500 | [diff] [blame] | 5562 | |
| 5563 | We mark all non-exported functions with "/* PRIVATE */"": |
| 5564 | |
| 5565 | void /* PRIVATE */ |
| 5566 | png_non_exported_function(png_ptr, png_info, foo) |
| 5567 | { |
| 5568 | body; |
| 5569 | } |
| 5570 | |
Glenn Randers-Pehrson | 416976f | 2009-07-27 22:16:09 -0500 | [diff] [blame] | 5571 | The prototypes for non-exported functions (except for those in |
Glenn Randers-Pehrson | 5df7edb | 2009-10-29 23:32:44 -0500 | [diff] [blame] | 5572 | pngtest) appear in |
| 5573 | pngpriv.h |
Glenn Randers-Pehrson | 416976f | 2009-07-27 22:16:09 -0500 | [diff] [blame] | 5574 | above the comment that says |
| 5575 | |
| 5576 | /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ |
Glenn Randers-Pehrson | 7654682 | 2009-05-16 07:25:42 -0500 | [diff] [blame] | 5577 | |
Glenn Randers-Pehrson | cbbe9a5 | 2011-01-29 16:12:11 -0600 | [diff] [blame] | 5578 | To avoid polluting the global namespace, the names of all exported |
| 5579 | functions and variables begin with "png_", and all publicly visible C |
| 5580 | preprocessor macros begin with "PNG_". We request that applications that |
| 5581 | use libpng *not* begin any of their own symbols with either of these strings. |
Glenn Randers-Pehrson | 7654682 | 2009-05-16 07:25:42 -0500 | [diff] [blame] | 5582 | |
| 5583 | We put a space after each comma and after each semicolon |
Glenn Randers-Pehrson | 49a56e7 | 2010-12-06 20:06:01 -0600 | [diff] [blame] | 5584 | in "for" statements, and we put spaces before and after each |
Glenn Randers-Pehrson | e4c706a | 2010-03-06 14:51:54 -0600 | [diff] [blame] | 5585 | C binary operator and after "for" or "while", and before |
| 5586 | "?". We don't put a space between a typecast and the expression |
| 5587 | being cast, nor do we put one between a function name and the |
Glenn Randers-Pehrson | 7654682 | 2009-05-16 07:25:42 -0500 | [diff] [blame] | 5588 | left parenthesis that follows it: |
| 5589 | |
| 5590 | for (i = 2; i > 0; --i) |
Glenn Randers-Pehrson | 67f3b48 | 2009-09-23 11:36:28 -0500 | [diff] [blame] | 5591 | y[i] = a(x) + (int)b; |
Glenn Randers-Pehrson | 7654682 | 2009-05-16 07:25:42 -0500 | [diff] [blame] | 5592 | |
Glenn Randers-Pehrson | d60c886 | 2009-06-15 21:56:14 -0500 | [diff] [blame] | 5593 | We prefer #ifdef and #ifndef to #if defined() and if !defined() |
| 5594 | when there is only one macro being tested. |
| 5595 | |
Glenn Randers-Pehrson | 8db1998 | 2011-10-27 16:17:24 -0500 | [diff] [blame] | 5596 | We prefer to express integers that are used as bit masks in hex format, |
| 5597 | with an even number of lower-case hex digits (e.g., 0x00, 0xff, 0x0100). |
| 5598 | |
Glenn Randers-Pehrson | 67f3b48 | 2009-09-23 11:36:28 -0500 | [diff] [blame] | 5599 | We do not use the TAB character for indentation in the C sources. |
| 5600 | |
Glenn Randers-Pehrson | 62ca98e | 2009-12-20 15:14:57 -0600 | [diff] [blame] | 5601 | Lines do not exceed 80 characters. |
| 5602 | |
Glenn Randers-Pehrson | f210a05 | 2009-11-12 10:02:24 -0600 | [diff] [blame] | 5603 | Other rules can be inferred by inspecting the libpng source. |
Glenn Randers-Pehrson | 7654682 | 2009-05-16 07:25:42 -0500 | [diff] [blame] | 5604 | |
Glenn Randers-Pehrson | 5b40b01 | 2010-11-25 07:16:29 -0600 | [diff] [blame] | 5605 | .SH XIV. Y2K Compliance in libpng |
Glenn Randers-Pehrson | 7654682 | 2009-05-16 07:25:42 -0500 | [diff] [blame] | 5606 | |
Glenn Randers-Pehrson | d92c1fc | 2011-11-17 21:03:07 -0600 | [diff] [blame] | 5607 | November 18, 2011 |
Glenn Randers-Pehrson | 87544ac | 1999-01-13 22:06:39 -0600 | [diff] [blame] | 5608 | |
| 5609 | Since the PNG Development group is an ad-hoc body, we can't make |
| 5610 | an official declaration. |
| 5611 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 5612 | This is your unofficial assurance that libpng from version 0.71 and |
Glenn Randers-Pehrson | 36251d3 | 2011-11-17 21:14:34 -0600 | [diff] [blame^] | 5613 | upward through 1.5.7beta05 are Y2K compliant. It is my belief that earlier |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 5614 | versions were also Y2K compliant. |
Glenn Randers-Pehrson | 87544ac | 1999-01-13 22:06:39 -0600 | [diff] [blame] | 5615 | |
| 5616 | Libpng only has three year fields. One is a 2-byte unsigned integer that |
| 5617 | will hold years up to 65535. The other two hold the date in text |
| 5618 | format, and will hold years up to 9999. |
| 5619 | |
| 5620 | The integer is |
| 5621 | "png_uint_16 year" in png_time_struct. |
| 5622 | |
| 5623 | The strings are |
| 5624 | "png_charp time_buffer" in png_struct and |
| 5625 | "near_time_buffer", which is a local character string in png.c. |
| 5626 | |
| 5627 | There are seven time-related functions: |
| 5628 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 5629 | png_convert_to_rfc_1123() in png.c |
Glenn Randers-Pehrson | 87544ac | 1999-01-13 22:06:39 -0600 | [diff] [blame] | 5630 | (formerly png_convert_to_rfc_1152() in error) |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 5631 | png_convert_from_struct_tm() in pngwrite.c, called |
| 5632 | in pngwrite.c |
Glenn Randers-Pehrson | 87544ac | 1999-01-13 22:06:39 -0600 | [diff] [blame] | 5633 | png_convert_from_time_t() in pngwrite.c |
| 5634 | png_get_tIME() in pngget.c |
| 5635 | png_handle_tIME() in pngrutil.c, called in pngread.c |
| 5636 | png_set_tIME() in pngset.c |
| 5637 | png_write_tIME() in pngwutil.c, called in pngwrite.c |
| 5638 | |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 5639 | All appear to handle dates properly in a Y2K environment. The |
Glenn Randers-Pehrson | 87544ac | 1999-01-13 22:06:39 -0600 | [diff] [blame] | 5640 | png_convert_from_time_t() function calls gmtime() to convert from system |
| 5641 | clock time, which returns (year - 1900), which we properly convert to |
| 5642 | the full 4-digit year. There is a possibility that applications using |
| 5643 | 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] | 5644 | function, or that they are incorrectly passing only a 2-digit year |
| 5645 | instead of "year - 1900" into the png_convert_from_struct_tm() function, |
| 5646 | but this is not under our control. The libpng documentation has always |
| 5647 | stated that it works with 4-digit years, and the APIs have been |
| 5648 | documented as such. |
Glenn Randers-Pehrson | 87544ac | 1999-01-13 22:06:39 -0600 | [diff] [blame] | 5649 | |
| 5650 | The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned |
| 5651 | integer to hold the year, and can hold years as large as 65535. |
| 5652 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 5653 | zlib, upon which libpng depends, is also Y2K compliant. It contains |
| 5654 | no date-related code. |
| 5655 | |
Glenn Randers-Pehrson | 87544ac | 1999-01-13 22:06:39 -0600 | [diff] [blame] | 5656 | |
| 5657 | Glenn Randers-Pehrson |
| 5658 | libpng maintainer |
| 5659 | PNG Development Group |
| 5660 | |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 5661 | .SH NOTE |
| 5662 | |
| 5663 | Note about libpng version numbers: |
| 5664 | |
| 5665 | Due to various miscommunications, unforeseen code incompatibilities |
| 5666 | and occasional factors outside the authors' control, version numbering |
| 5667 | on the library has not always been consistent and straightforward. |
| 5668 | The following table summarizes matters since version 0.89c, which was |
| 5669 | the first widely used release: |
| 5670 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 5671 | source png.h png.h shared-lib |
| 5672 | version string int version |
| 5673 | ------- ------ ----- ---------- |
| 5674 | 0.89c ("beta 3") 0.89 89 1.0.89 |
| 5675 | 0.90 ("beta 4") 0.90 90 0.90 |
| 5676 | 0.95 ("beta 5") 0.95 95 0.95 |
| 5677 | 0.96 ("beta 6") 0.96 96 0.96 |
| 5678 | 0.97b ("beta 7") 1.00.97 97 1.0.1 |
| 5679 | 0.97c 0.97 97 2.0.97 |
| 5680 | 0.98 0.98 98 2.0.98 |
| 5681 | 0.99 0.99 98 2.0.99 |
| 5682 | 0.99a-m 0.99 99 2.0.99 |
| 5683 | 1.00 1.00 100 2.1.0 |
| 5684 | 1.0.0 1.0.0 100 2.1.0 |
| 5685 | 1.0.0 (from here on, the 100 2.1.0 |
| 5686 | 1.0.1 png.h string is 10001 2.1.0 |
| 5687 | 1.0.1a-e identical to the 10002 from here on, the |
| 5688 | 1.0.2 source version) 10002 shared library is 2.V |
| 5689 | 1.0.2a-b 10003 where V is the source |
| 5690 | 1.0.1 10001 code version except as |
| 5691 | 1.0.1a-e 10002 2.1.0.1a-e noted. |
| 5692 | 1.0.2 10002 2.1.0.2 |
| 5693 | 1.0.2a-b 10003 2.1.0.2a-b |
| 5694 | 1.0.3 10003 2.1.0.3 |
| 5695 | 1.0.3a-d 10004 2.1.0.3a-d |
| 5696 | 1.0.4 10004 2.1.0.4 |
| 5697 | 1.0.4a-f 10005 2.1.0.4a-f |
| 5698 | 1.0.5 (+ 2 patches) 10005 2.1.0.5 |
| 5699 | 1.0.5a-d 10006 2.1.0.5a-d |
| 5700 | 1.0.5e-r 10100 2.1.0.5e-r |
| 5701 | 1.0.5s-v 10006 2.1.0.5s-v |
| 5702 | 1.0.6 (+ 3 patches) 10006 2.1.0.6 |
| 5703 | 1.0.6d-g 10007 2.1.0.6d-g |
| 5704 | 1.0.6h 10007 10.6h |
| 5705 | 1.0.6i 10007 10.6i |
| 5706 | 1.0.6j 10007 2.1.0.6j |
Glenn Randers-Pehrson | 2546703 | 2011-01-28 11:58:40 -0600 | [diff] [blame] | 5707 | 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 5708 | 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 |
| 5709 | 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 |
| 5710 | 1.0.7 1 10007 2.1.0.7 |
| 5711 | 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 |
| 5712 | 1.0.8rc1 1 10008 2.1.0.8rc1 |
| 5713 | 1.0.8 1 10008 2.1.0.8 |
| 5714 | 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 |
| 5715 | 1.0.9rc1 1 10009 2.1.0.9rc1 |
| 5716 | 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 |
| 5717 | 1.0.9rc2 1 10009 2.1.0.9rc2 |
| 5718 | 1.0.9 1 10009 2.1.0.9 |
Glenn Randers-Pehrson | e164447 | 2001-03-23 05:06:56 -0600 | [diff] [blame] | 5719 | 1.0.10beta1 1 10010 2.1.0.10beta1 |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 5720 | 1.0.10rc1 1 10010 2.1.0.10rc1 |
Glenn Randers-Pehrson | 13cfbac | 2001-03-30 06:42:28 -0600 | [diff] [blame] | 5721 | 1.0.10 1 10010 2.1.0.10 |
Glenn Randers-Pehrson | e1eff58 | 2001-04-14 20:15:41 -0500 | [diff] [blame] | 5722 | 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 |
Glenn Randers-Pehrson | 82ae383 | 2001-04-20 10:32:10 -0500 | [diff] [blame] | 5723 | 1.0.11rc1 1 10011 2.1.0.11rc1 |
Glenn Randers-Pehrson | 3283539 | 2001-04-27 08:29:32 -0500 | [diff] [blame] | 5724 | 1.0.11 1 10011 2.1.0.11 |
Glenn Randers-Pehrson | b182893 | 2001-06-23 08:03:17 -0500 | [diff] [blame] | 5725 | 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 |
| 5726 | 1.0.12rc1 2 10012 2.1.0.12rc1 |
| 5727 | 1.0.12 2 10012 2.1.0.12 |
| 5728 | 1.1.0a-f - 10100 2.1.1.0a-f abandoned |
Glenn Randers-Pehrson | 8b6a889 | 2001-05-18 04:54:50 -0500 | [diff] [blame] | 5729 | 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 |
Glenn Randers-Pehrson | 5a0be34 | 2001-10-18 20:55:13 -0500 | [diff] [blame] | 5730 | 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 |
| 5731 | 1.2.0rc1 3 10200 3.1.2.0rc1 |
| 5732 | 1.2.0 3 10200 3.1.2.0 |
Glenn Randers-Pehrson | 5cded0b | 2001-11-07 07:10:08 -0600 | [diff] [blame] | 5733 | 1.2.1beta-4 3 10201 3.1.2.1beta1-4 |
Glenn Randers-Pehrson | db3b88d | 2001-12-04 06:30:43 -0600 | [diff] [blame] | 5734 | 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 |
| 5735 | 1.2.1 3 10201 3.1.2.1 |
Glenn Randers-Pehrson | 25228ab | 2002-03-31 07:33:55 -0600 | [diff] [blame] | 5736 | 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 |
Glenn Randers-Pehrson | fcbd787 | 2002-04-07 16:35:38 -0500 | [diff] [blame] | 5737 | 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 |
| 5738 | 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 |
| 5739 | 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 |
Glenn Randers-Pehrson | 4fb046a | 2002-04-15 09:25:51 -0500 | [diff] [blame] | 5740 | 1.0.13 10 10013 10.so.0.1.0.13 |
| 5741 | 1.2.2 12 10202 12.so.0.1.2.2 |
Glenn Randers-Pehrson | 22f2896 | 2002-05-13 18:17:09 -0500 | [diff] [blame] | 5742 | 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 |
| 5743 | 1.2.3 12 10203 12.so.0.1.2.3 |
Glenn Randers-Pehrson | d020e9d | 2002-06-28 09:34:00 -0500 | [diff] [blame] | 5744 | 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 |
Glenn Randers-Pehrson | 2ae022d | 2002-07-01 22:23:46 -0500 | [diff] [blame] | 5745 | 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 |
Glenn Randers-Pehrson | 484a8a1 | 2002-07-07 19:15:20 -0500 | [diff] [blame] | 5746 | 1.0.14 10 10014 10.so.0.1.0.14 |
| 5747 | 1.2.4 13 10204 12.so.0.1.2.4 |
Glenn Randers-Pehrson | 5b5dcf8 | 2004-07-17 22:45:44 -0500 | [diff] [blame] | 5748 | 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2 |
| 5749 | 1.0.15rc1 10 10015 10.so.0.1.0.15rc1 |
Glenn Randers-Pehrson | 5fea36f | 2004-07-28 08:20:44 -0500 | [diff] [blame] | 5750 | 1.0.15 10 10015 10.so.0.1.0.15 |
| 5751 | 1.2.5 13 10205 12.so.0.1.2.5 |
| 5752 | 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4 |
Glenn Randers-Pehrson | 37f116a | 2004-08-15 07:15:39 -0500 | [diff] [blame] | 5753 | 1.2.6rc1-5 13 10206 12.so.0.1.2.6rc1-5 |
| 5754 | 1.0.16 10 10016 10.so.0.1.0.16 |
| 5755 | 1.2.6 13 10206 12.so.0.1.2.6 |
Glenn Randers-Pehrson | 67864af | 2004-08-28 23:30:07 -0500 | [diff] [blame] | 5756 | 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2 |
Glenn Randers-Pehrson | 5b77916 | 2004-09-04 13:25:08 -0500 | [diff] [blame] | 5757 | 1.0.17rc1 10 10017 12.so.0.1.0.17rc1 |
| 5758 | 1.2.7rc1 13 10207 12.so.0.1.2.7rc1 |
Glenn Randers-Pehrson | 250dfe1 | 2004-09-11 21:19:54 -0500 | [diff] [blame] | 5759 | 1.0.17 10 10017 12.so.0.1.0.17 |
| 5760 | 1.2.7 13 10207 12.so.0.1.2.7 |
Glenn Randers-Pehrson | 4093607 | 2004-11-20 11:18:40 -0600 | [diff] [blame] | 5761 | 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5 |
Glenn Randers-Pehrson | 584b96e | 2004-11-29 15:08:00 -0600 | [diff] [blame] | 5762 | 1.0.18rc1-5 10 10018 12.so.0.1.0.18rc1-5 |
| 5763 | 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5 |
Glenn Randers-Pehrson | 917648e | 2004-12-02 18:14:51 -0600 | [diff] [blame] | 5764 | 1.0.18 10 10018 12.so.0.1.0.18 |
| 5765 | 1.2.8 13 10208 12.so.0.1.2.8 |
Glenn Randers-Pehrson | e647462 | 2006-03-04 16:50:47 -0600 | [diff] [blame] | 5766 | 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3 |
Glenn Randers-Pehrson | 4deeb79 | 2006-03-22 16:21:59 -0600 | [diff] [blame] | 5767 | 1.2.9beta4-11 13 10209 12.so.0.9[.0] |
Glenn Randers-Pehrson | 3a51203 | 2006-03-31 05:29:33 -0600 | [diff] [blame] | 5768 | 1.2.9rc1 13 10209 12.so.0.9[.0] |
Glenn Randers-Pehrson | a7d0c94 | 2006-04-14 06:22:52 -0500 | [diff] [blame] | 5769 | 1.2.9 13 10209 12.so.0.9[.0] |
Glenn Randers-Pehrson | d60b8fa | 2006-04-20 21:31:14 -0500 | [diff] [blame] | 5770 | 1.2.10beta1-7 13 10210 12.so.0.10[.0] |
Glenn Randers-Pehrson | 1721829 | 2006-04-20 07:20:46 -0500 | [diff] [blame] | 5771 | 1.2.10rc1-2 13 10210 12.so.0.10[.0] |
Glenn Randers-Pehrson | 86dc981 | 2006-05-10 07:27:44 -0500 | [diff] [blame] | 5772 | 1.2.10 13 10210 12.so.0.10[.0] |
Glenn Randers-Pehrson | 6bc53be | 2006-06-16 07:52:03 -0500 | [diff] [blame] | 5773 | 1.4.0beta1-6 14 10400 14.so.0.0[.0] |
Glenn Randers-Pehrson | d60c886 | 2009-06-15 21:56:14 -0500 | [diff] [blame] | 5774 | 1.2.11beta1-4 13 10210 12.so.0.11[.0] |
Glenn Randers-Pehrson | 3424ee7 | 2006-07-12 13:33:47 -0500 | [diff] [blame] | 5775 | 1.4.0beta7-8 14 10400 14.so.0.0[.0] |
Glenn Randers-Pehrson | 701dbaa | 2006-11-17 09:36:54 -0600 | [diff] [blame] | 5776 | 1.2.11 13 10211 12.so.0.11[.0] |
| 5777 | 1.2.12 13 10212 12.so.0.12[.0] |
| 5778 | 1.4.0beta9-14 14 10400 14.so.0.0[.0] |
| 5779 | 1.2.13 13 10213 12.so.0.13[.0] |
Glenn Randers-Pehrson | 97a9b48 | 2008-10-25 20:03:28 -0500 | [diff] [blame] | 5780 | 1.4.0beta15-36 14 10400 14.so.0.0[.0] |
Glenn Randers-Pehrson | fa02810 | 2009-10-10 06:15:21 -0500 | [diff] [blame] | 5781 | 1.4.0beta37-87 14 10400 14.so.14.0[.0] |
Glenn Randers-Pehrson | 733da8c | 2009-10-30 00:00:15 -0500 | [diff] [blame] | 5782 | 1.4.0rc01 14 10400 14.so.14.0[.0] |
Glenn Randers-Pehrson | 62ca98e | 2009-12-20 15:14:57 -0600 | [diff] [blame] | 5783 | 1.4.0beta88-109 14 10400 14.so.14.0[.0] |
Glenn Randers-Pehrson | 67a83db | 2010-01-01 18:26:18 -0600 | [diff] [blame] | 5784 | 1.4.0rc02-08 14 10400 14.so.14.0[.0] |
Glenn Randers-Pehrson | dbcfb71 | 2009-12-25 14:24:18 -0600 | [diff] [blame] | 5785 | 1.4.0 14 10400 14.so.14.0[.0] |
Glenn Randers-Pehrson | e3f3c4e | 2010-02-07 18:08:50 -0600 | [diff] [blame] | 5786 | 1.4.1beta01-03 14 10401 14.so.14.1[.0] |
| 5787 | 1.4.1rc01 14 10401 14.so.14.1[.0] |
Glenn Randers-Pehrson | 7a5be53 | 2010-02-14 07:16:19 -0600 | [diff] [blame] | 5788 | 1.4.1beta04-12 14 10401 14.so.14.1[.0] |
Glenn Randers-Pehrson | aaf377c | 2010-03-08 11:20:30 -0600 | [diff] [blame] | 5789 | 1.4.1 14 10401 14.so.14.1[.0] |
Glenn Randers-Pehrson | 5b3d554 | 2010-06-18 21:55:53 -0500 | [diff] [blame] | 5790 | 1.4.2 14 10402 14.so.14.2[.0] |
| 5791 | 1.4.3 14 10403 14.so.14.3[.0] |
Glenn Randers-Pehrson | 2776d5e | 2010-11-21 15:18:02 -0600 | [diff] [blame] | 5792 | 1.4.4 14 10404 14.so.14.4[.0] |
Glenn Randers-Pehrson | fd20a5a | 2010-12-27 08:53:08 -0600 | [diff] [blame] | 5793 | 1.5.0beta01-58 15 10500 15.so.15.0[.0] |
Glenn Randers-Pehrson | 64b863c | 2011-01-04 09:57:06 -0600 | [diff] [blame] | 5794 | 1.5.0rc01-07 15 10500 15.so.15.0[.0] |
Glenn Randers-Pehrson | f5ea1b7 | 2011-01-06 06:42:51 -0600 | [diff] [blame] | 5795 | 1.5.0 15 10500 15.so.15.0[.0] |
Glenn Randers-Pehrson | ef123cc | 2011-01-28 15:20:34 -0600 | [diff] [blame] | 5796 | 1.5.1beta01-11 15 10501 15.so.15.1[.0] |
Glenn Randers-Pehrson | 3d3aae1 | 2011-02-02 22:58:27 -0600 | [diff] [blame] | 5797 | 1.5.1rc01-02 15 10501 15.so.15.1[.0] |
| 5798 | 1.5.1 15 10501 15.so.15.1[.0] |
Glenn Randers-Pehrson | f3dd1cc | 2011-03-18 22:02:20 -0500 | [diff] [blame] | 5799 | 1.5.2beta01-03 15 10502 15.so.15.2[.0] |
Glenn Randers-Pehrson | 77fd083 | 2011-03-24 08:59:48 -0500 | [diff] [blame] | 5800 | 1.5.2rc01-03 15 10502 15.so.15.2[.0] |
Glenn Randers-Pehrson | dcc3505 | 2011-03-31 11:23:49 -0500 | [diff] [blame] | 5801 | 1.5.2 15 10502 15.so.15.2[.0] |
Glenn Randers-Pehrson | 36edbb5 | 2011-06-03 07:15:04 -0500 | [diff] [blame] | 5802 | 1.5.3beta01-10 15 10503 15.so.15.3[.0] |
Glenn Randers-Pehrson | fb27873 | 2011-06-10 20:43:39 -0500 | [diff] [blame] | 5803 | 1.5.3rc01-02 15 10503 15.so.15.3[.0] |
Glenn Randers-Pehrson | 413138a | 2011-06-13 22:07:37 -0500 | [diff] [blame] | 5804 | 1.5.3beta11 15 10503 15.so.15.3[.0] |
| 5805 | 1.5.3 [omitted] |
Glenn Randers-Pehrson | 9daf91e | 2011-06-22 23:10:36 -0500 | [diff] [blame] | 5806 | 1.5.4beta01-08 15 10504 15.so.15.4[.0] |
Glenn Randers-Pehrson | 78bb9da | 2011-06-30 18:59:45 -0500 | [diff] [blame] | 5807 | 1.5.4rc01 15 10504 15.so.15.4[.0] |
Glenn Randers-Pehrson | d404b6d | 2011-07-07 06:24:57 -0500 | [diff] [blame] | 5808 | 1.5.4 15 10504 15.so.15.4[.0] |
Glenn Randers-Pehrson | 3c2ae60 | 2011-09-09 06:02:09 -0500 | [diff] [blame] | 5809 | 1.5.5beta01-08 15 10505 15.so.15.5[.0] |
| 5810 | 1.5.5rc01 15 10505 15.so.15.5[.0] |
Glenn Randers-Pehrson | 3e2263a | 2011-09-22 08:40:32 -0500 | [diff] [blame] | 5811 | 1.5.5 15 10505 15.so.15.5[.0] |
Glenn Randers-Pehrson | 93254f6 | 2011-10-26 08:36:21 -0500 | [diff] [blame] | 5812 | 1.5.6beta01-07 15 10506 15.so.15.6[.0] |
Glenn Randers-Pehrson | bc6726b | 2011-11-02 22:43:00 -0500 | [diff] [blame] | 5813 | 1.5.6rc01-03 15 10506 15.so.15.6[.0] |
| 5814 | 1.5.6 15 10506 15.so.15.6[.0] |
Glenn Randers-Pehrson | 36251d3 | 2011-11-17 21:14:34 -0600 | [diff] [blame^] | 5815 | 1.5.7beta01-05 15 10507 15.so.15.7[.0] |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 5816 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 5817 | Henceforth the source version will match the shared-library minor |
| 5818 | and patch numbers; the shared-library major version number will be |
| 5819 | used for changes in backward compatibility, as it is intended. The |
| 5820 | PNG_PNGLIB_VER macro, which is not used within libpng but is available |
| 5821 | for applications, is an unsigned integer of the form xyyzz corresponding |
| 5822 | 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] | 5823 | were given the previous public release number plus a letter, until |
| 5824 | version 1.0.6j; from then on they were given the upcoming public |
| 5825 | release number plus "betaNN" or "rcN". |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 5826 | |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 5827 | .SH "SEE ALSO" |
Glenn Randers-Pehrson | 4e763f1 | 2010-03-03 10:45:50 -0600 | [diff] [blame] | 5828 | .BR "png"(5), " libpngpf"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5) |
Glenn Randers-Pehrson | 7fb32a8 | 2010-03-03 09:47:49 -0600 | [diff] [blame] | 5829 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 5830 | .LP |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 5831 | .IR libpng : |
| 5832 | .IP |
Glenn Randers-Pehrson | a4981d4 | 2004-08-25 22:00:45 -0500 | [diff] [blame] | 5833 | http://libpng.sourceforge.net (follow the [DOWNLOAD] link) |
Glenn Randers-Pehrson | 5e5c1e1 | 2000-11-10 12:26:19 -0600 | [diff] [blame] | 5834 | http://www.libpng.org/pub/png |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 5835 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 5836 | .LP |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 5837 | .IR zlib : |
| 5838 | .IP |
| 5839 | (generally) at the same location as |
| 5840 | .I libpng |
| 5841 | or at |
| 5842 | .br |
Glenn Randers-Pehrson | 5e5c1e1 | 2000-11-10 12:26:19 -0600 | [diff] [blame] | 5843 | ftp://ftp.info-zip.org/pub/infozip/zlib |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 5844 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 5845 | .LP |
| 5846 | .IR PNG specification: RFC 2083 |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 5847 | .IP |
| 5848 | (generally) at the same location as |
| 5849 | .I libpng |
| 5850 | or at |
| 5851 | .br |
| 5852 | ftp://ds.internic.net/rfc/rfc2083.txt |
| 5853 | .br |
| 5854 | or (as a W3C Recommendation) at |
| 5855 | .br |
| 5856 | http://www.w3.org/TR/REC-png.html |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 5857 | |
Glenn Randers-Pehrson | cbe52d8 | 1998-02-28 07:00:24 -0600 | [diff] [blame] | 5858 | .LP |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 5859 | In the case of any inconsistency between the PNG specification |
| 5860 | and this library, the specification takes precedence. |
| 5861 | |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 5862 | .SH AUTHORS |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 5863 | This man page: Glenn Randers-Pehrson |
Glenn Randers-Pehrson | 5dd2b8e | 2004-11-24 07:50:16 -0600 | [diff] [blame] | 5864 | <glennrp at users.sourceforge.net> |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 5865 | |
| 5866 | The contributing authors would like to thank all those who helped |
| 5867 | with testing, bug fixes, and patience. This wouldn't have been |
| 5868 | possible without all of you. |
| 5869 | |
| 5870 | Thanks to Frank J. T. Wojcik for helping with the documentation. |
Glenn Randers-Pehrson | 166c5a3 | 1999-12-10 09:43:02 -0600 | [diff] [blame] | 5871 | |
Glenn Randers-Pehrson | 36251d3 | 2011-11-17 21:14:34 -0600 | [diff] [blame^] | 5872 | Libpng version 1.5.7beta05 - November 18, 2011: |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 5873 | Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. |
Glenn Randers-Pehrson | 5dd2b8e | 2004-11-24 07:50:16 -0600 | [diff] [blame] | 5874 | Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net). |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 5875 | |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 5876 | Supported by the PNG development group |
| 5877 | .br |
Glenn Randers-Pehrson | 9c3ab68 | 2006-02-20 22:09:05 -0600 | [diff] [blame] | 5878 | png-mng-implement at lists.sf.net |
| 5879 | (subscription required; visit |
Glenn Randers-Pehrson | 7b34df3 | 2006-02-24 06:30:16 -0600 | [diff] [blame] | 5880 | png-mng-implement at lists.sourceforge.net (subscription required; visit |
Glenn Randers-Pehrson | 9c3ab68 | 2006-02-20 22:09:05 -0600 | [diff] [blame] | 5881 | https://lists.sourceforge.net/lists/listinfo/png-mng-implement |
| 5882 | to subscribe). |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 5883 | |
Glenn Randers-Pehrson | 3d5a520 | 2000-07-01 15:37:28 -0500 | [diff] [blame] | 5884 | .SH COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 5885 | |
Glenn Randers-Pehrson | 5e5c1e1 | 2000-11-10 12:26:19 -0600 | [diff] [blame] | 5886 | (This copy of the libpng notices is provided for your convenience. In case of |
| 5887 | any discrepancy between this copy and the notices in the file png.h that is |
| 5888 | included in the libpng distribution, the latter shall prevail.) |
| 5889 | |
Glenn Randers-Pehrson | 3d5a520 | 2000-07-01 15:37:28 -0500 | [diff] [blame] | 5890 | If you modify libpng you may insert additional notices immediately following |
| 5891 | this sentence. |
| 5892 | |
Glenn Randers-Pehrson | bfbf865 | 2009-06-26 21:46:52 -0500 | [diff] [blame] | 5893 | This code is released under the libpng license. |
Glenn Randers-Pehrson | 037023b | 2009-06-24 10:27:36 -0500 | [diff] [blame] | 5894 | |
Glenn Randers-Pehrson | 36251d3 | 2011-11-17 21:14:34 -0600 | [diff] [blame^] | 5895 | libpng versions 1.2.6, August 15, 2004, through 1.5.7beta05, November 18, 2011, are |
Glenn Randers-Pehrson | a7dbcba | 2007-05-15 16:16:34 -0500 | [diff] [blame] | 5896 | Copyright (c) 2004,2006-2007 Glenn Randers-Pehrson, and are |
Glenn Randers-Pehrson | 5fea36f | 2004-07-28 08:20:44 -0500 | [diff] [blame] | 5897 | distributed according to the same disclaimer and license as libpng-1.2.5 |
Glenn Randers-Pehrson | d029a75 | 2004-08-09 21:50:32 -0500 | [diff] [blame] | 5898 | with the following individual added to the list of Contributing Authors |
Glenn Randers-Pehrson | 5fea36f | 2004-07-28 08:20:44 -0500 | [diff] [blame] | 5899 | |
| 5900 | Cosmin Truta |
Glenn Randers-Pehrson | 5fea36f | 2004-07-28 08:20:44 -0500 | [diff] [blame] | 5901 | |
| 5902 | libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are |
Glenn Randers-Pehrson | c6de22d | 2002-02-23 18:55:25 -0600 | [diff] [blame] | 5903 | Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are |
Glenn Randers-Pehrson | 32fc5ce | 2000-07-24 06:34:14 -0500 | [diff] [blame] | 5904 | 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] | 5905 | with the following individuals added to the list of Contributing Authors |
| 5906 | |
| 5907 | Simon-Pierre Cadieux |
| 5908 | Eric S. Raymond |
| 5909 | Gilles Vollant |
| 5910 | |
| 5911 | and with the following additions to the disclaimer: |
| 5912 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 5913 | There is no warranty against interference with your |
| 5914 | enjoyment of the library or against infringement. |
| 5915 | There is no warranty that our efforts or the library |
| 5916 | will fulfill any of your particular purposes or needs. |
| 5917 | This library is provided with all faults, and the entire |
| 5918 | risk of satisfactory quality, performance, accuracy, and |
| 5919 | effort is with the user. |
Glenn Randers-Pehrson | 3d5a520 | 2000-07-01 15:37:28 -0500 | [diff] [blame] | 5920 | |
| 5921 | libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are |
| 5922 | Copyright (c) 1998, 1999 Glenn Randers-Pehrson |
| 5923 | Distributed according to the same disclaimer and license as libpng-0.96, |
| 5924 | with the following individuals added to the list of Contributing Authors: |
| 5925 | |
| 5926 | Tom Lane |
| 5927 | Glenn Randers-Pehrson |
| 5928 | Willem van Schaik |
| 5929 | |
| 5930 | 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] | 5931 | Copyright (c) 1996, 1997 Andreas Dilger |
Glenn Randers-Pehrson | 3d5a520 | 2000-07-01 15:37:28 -0500 | [diff] [blame] | 5932 | Distributed according to the same disclaimer and license as libpng-0.88, |
| 5933 | with the following individuals added to the list of Contributing Authors: |
Glenn Randers-Pehrson | bcfd15d | 1999-10-01 14:22:25 -0500 | [diff] [blame] | 5934 | |
| 5935 | John Bowler |
| 5936 | Kevin Bracey |
| 5937 | Sam Bushell |
Glenn Randers-Pehrson | bcfd15d | 1999-10-01 14:22:25 -0500 | [diff] [blame] | 5938 | Magnus Holmgren |
Glenn Randers-Pehrson | bcfd15d | 1999-10-01 14:22:25 -0500 | [diff] [blame] | 5939 | Greg Roelofs |
Glenn Randers-Pehrson | 3d5a520 | 2000-07-01 15:37:28 -0500 | [diff] [blame] | 5940 | Tom Tanner |
| 5941 | |
| 5942 | libpng versions 0.5, May 1995, through 0.88, January 1996, are |
| 5943 | Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. |
| 5944 | |
| 5945 | For the purposes of this copyright and license, "Contributing Authors" |
| 5946 | is defined as the following set of individuals: |
| 5947 | |
| 5948 | Andreas Dilger |
| 5949 | Dave Martindale |
Glenn Randers-Pehrson | bcfd15d | 1999-10-01 14:22:25 -0500 | [diff] [blame] | 5950 | Guy Eric Schalnat |
| 5951 | Paul Schmidt |
Glenn Randers-Pehrson | bcfd15d | 1999-10-01 14:22:25 -0500 | [diff] [blame] | 5952 | Tim Wegner |
Glenn Randers-Pehrson | c944229 | 1999-01-06 21:50:16 -0600 | [diff] [blame] | 5953 | |
Glenn Randers-Pehrson | 3d5a520 | 2000-07-01 15:37:28 -0500 | [diff] [blame] | 5954 | The PNG Reference Library is supplied "AS IS". The Contributing Authors |
| 5955 | and Group 42, Inc. disclaim all warranties, expressed or implied, |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 5956 | including, without limitation, the warranties of merchantability and of |
| 5957 | fitness for any purpose. The Contributing Authors and Group 42, Inc. |
| 5958 | assume no liability for direct, indirect, incidental, special, exemplary, |
| 5959 | or consequential damages, which may result from the use of the PNG |
| 5960 | Reference Library, even if advised of the possibility of such damage. |
Glenn Randers-Pehrson | a357b99 | 1998-02-08 20:56:40 -0600 | [diff] [blame] | 5961 | |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 5962 | Permission is hereby granted to use, copy, modify, and distribute this |
| 5963 | source code, or portions hereof, for any purpose, without fee, subject |
| 5964 | to the following restrictions: |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 5965 | |
Glenn Randers-Pehrson | 3d5a520 | 2000-07-01 15:37:28 -0500 | [diff] [blame] | 5966 | 1. The origin of this source code must not be misrepresented. |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 5967 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 5968 | 2. Altered versions must be plainly marked as such and |
| 5969 | must not be misrepresented as being the original source. |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 5970 | |
Glenn Randers-Pehrson | 1909560 | 2001-03-14 07:08:39 -0600 | [diff] [blame] | 5971 | 3. This Copyright notice may not be removed or altered from |
| 5972 | any source or altered source distribution. |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 5973 | |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 5974 | The Contributing Authors and Group 42, Inc. specifically permit, without |
| 5975 | fee, and encourage the use of this source code as a component to |
| 5976 | supporting the PNG file format in commercial products. If you use this |
| 5977 | source code in a product, acknowledgment is not required but would be |
| 5978 | appreciated. |
| 5979 | |
Glenn Randers-Pehrson | 3d5a520 | 2000-07-01 15:37:28 -0500 | [diff] [blame] | 5980 | |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 5981 | A "png_get_copyright" function is available, for convenient use in "about" |
| 5982 | boxes and the like: |
| 5983 | |
| 5984 | printf("%s",png_get_copyright(NULL)); |
| 5985 | |
| 5986 | 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] | 5987 | files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). |
Glenn Randers-Pehrson | 4393a9a | 1999-09-17 12:27:26 -0500 | [diff] [blame] | 5988 | |
Glenn Randers-Pehrson | 3d5a520 | 2000-07-01 15:37:28 -0500 | [diff] [blame] | 5989 | 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] | 5990 | certification mark of the Open Source Initiative. |
| 5991 | |
Glenn Randers-Pehrson | 3d5a520 | 2000-07-01 15:37:28 -0500 | [diff] [blame] | 5992 | Glenn Randers-Pehrson |
Glenn Randers-Pehrson | 5dd2b8e | 2004-11-24 07:50:16 -0600 | [diff] [blame] | 5993 | glennrp at users.sourceforge.net |
Glenn Randers-Pehrson | d92c1fc | 2011-11-17 21:03:07 -0600 | [diff] [blame] | 5994 | November 18, 2011 |
Glenn Randers-Pehrson | 3d5a520 | 2000-07-01 15:37:28 -0500 | [diff] [blame] | 5995 | |
Glenn Randers-Pehrson | 0f881d6 | 1998-02-07 10:20:57 -0600 | [diff] [blame] | 5996 | .\" end of man page |
| 5997 | |