setting background and doing gamma adjustment then you can read the entire image including pixels into the info structure with this call:/png_read_pngpng_ptr info_ptr png_transforms png_voidp_NULLelse/ OK youre doing it the hard way with the lower-level functions // The call to png_read_info gives us all of the information from the PNG file before the first IDAT image data chunk. REQUIRED/png_read_infopng_ptr info_ptrpng_get_IHDRpng_ptr info_ptr ampwidth ampheight ampbit_depth ampcolor_typeampinterlace_type int_p_NULL int_p_NULL/ Set up the data transformations you want. Note that these are all optional. Only call them if you want/need them. Many of the transformations only work on specific types of images and many are mutually exclusive.// tell libpng to strip 16 bit/color files down to 8 bits/color /png_set_strip_16png_ptr/ Strip alpha bytes from the input data without combining with the background not recommended./png_set_strip_alphapng_ptr/ Extract multiple pixels with bit depths of 1 2 and 4 from a single byte into separate bytes useful for paletted and grayscale images./png_set_packingpng_ptr/ Change the order of packed pixels to least significant bit first not useful if you are using png_set_packing. /png_set_packswappng_ptr/ Expand paletted colors into true RGB triplets /if color_type PNG_COLOR_TYPE_PALETTEpng_set_palette_rgbpng_ptr/ Expand grayscale images to the full 8 bits from 1 2 or 4 bits/pixel /if color_type PNG_COLOR_TYPE_GRAY ampamp bit_depth lt 8png_set_gray_1_2_4_to_8png_ptr/ Expand paletted or RGB images with transparency to full alpha channels so the data will be available as RGBA quartets./if png_get_validpng_ptr info_ptr PNG_INFO_tRNSpng_set_tRNS_to_alphapng_ptr/ Set the background color to draw transparent and alpha images over. It is possible to set the red green and blue components directly for paletted images instead of supplying a palette index. Note that even if the PNG file supplies a background you are not required to use it - you should use the solid application background if it has one./png_color_16 my_background image_backgroundif png_get_bKGDpng_ptr info_ptr ampimage_backgroundpng_set_backgroundpng_ptr image_backgroundPNG_BACKGROUND_GAMMA_FILE 1 1.0elsepng_set_backgroundpng_ptr ampmy_backgroundPNG_BACKGROUND_GAMMA_SCREEN 0 1.0/ Some suggestions as to how to get a screen gamma value // Note that screen gamma is the display_exponent which includes the CRT_exponent a.
上一篇:
【精品】B语言程序报告21啊撒
下一篇:
大学生汉语写作水平与英语水平相关性研究