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