Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5461 lines
213 KiB

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