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