⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libpng.3

📁 编译qtopia需要的库。里面包含了在嵌入式系统开发常用的电子元器件封装
💻 3
📖 第 1 页 / 共 5 页
字号:
    The value of "i" corresponds to the order in which the    chunks were read from the PNG file or inserted with the    png_set_unknown_chunks() function.The data from the pHYs chunk can be retrieved in several convenientforms:    res_x = png_get_x_pixels_per_meter(png_ptr,       info_ptr)    res_y = png_get_y_pixels_per_meter(png_ptr,       info_ptr)    res_x_and_y = png_get_pixels_per_meter(png_ptr,       info_ptr)    res_x = png_get_x_pixels_per_inch(png_ptr,       info_ptr)    res_y = png_get_y_pixels_per_inch(png_ptr,       info_ptr)    res_x_and_y = png_get_pixels_per_inch(png_ptr,       info_ptr)    aspect_ratio = png_get_pixel_aspect_ratio(png_ptr,       info_ptr)   (Each of these returns 0 [signifying "unknown"] if       the data is not present or if res_x is 0;       res_x_and_y is 0 if res_x != res_y)The data from the oFFs chunk can be retrieved in several convenientforms:    x_offset = png_get_x_offset_microns(png_ptr, info_ptr);    y_offset = png_get_y_offset_microns(png_ptr, info_ptr);    x_offset = png_get_x_offset_inches(png_ptr, info_ptr);    y_offset = png_get_y_offset_inches(png_ptr, info_ptr);   (Each of these returns 0 [signifying "unknown" if both       x and y are 0] if the data is not present or if the       chunk is present but the unit is the pixel)For more information, see the png_info definition in png.h and thePNG specification for chunk contents.  Be careful with trustingrowbytes, as some of the transformations could increase the spaceneeded to hold a row (expand, filler, gray_to_rgb, etc.).See png_read_update_info(), below.A quick word about text_ptr and num_text.  PNG stores comments inkeyword/text pairs, one pair per chunk, with no limit on the numberof text chunks, and a 2^31 byte limit on their size.  While there aresuggested keywords, there is no requirement to restrict the use to thesestrings.  It is strongly suggested that keywords and text be sensibleto humans (that's the point), so don't use abbreviations.  Non-printingsymbols are not allowed.  See the PNG specification for more details.There is also no requirement to have text after the keyword.Keywords should be limited to 79 Latin-1 characters without leading ortrailing spaces, but non-consecutive spaces are allowed within thekeyword.  It is possible to have the same keyword any number of times.The text_ptr is an array of png_text structures, each holding apointer to a language string, a pointer to a keyword and a pointer toa text string.  The text string, language code, and translatedkeyword may be empty or NULL pointers.  The keyword/textpairs are put into the array in the order that they are received.However, some or all of the text chunks may be after the image, so, tomake sure you have read all the text chunks, don't mess with theseuntil after you read the stuff after the image.  This will bementioned again below in the discussion that goes with png_read_end()..SS Input transformationsAfter you've read the header information, you can set up the libraryto handle any special transformations of the image data.  The variousways to transform the data will be described in the order that theyshould occur.  This is important, as some of these change the colortype and/or bit depth of the data, and some others only work oncertain color types and bit depths.  Even though each transformationchecks to see if it has data that it can do something with, you shouldmake sure to only enable a transformation if it will be valid for thedata.  For example, don't swap red and blue on grayscale data.The colors used for the background and transparency values should besupplied in the same format/depth as the current image data.  Theyare stored in the same format/depth as the image data in a bKGD or tRNSchunk, so this is what libpng expects for this data.  The colors aretransformed to keep in sync with the image data when an applicationcalls the png_read_update_info() routine (see below).Data will be decoded into the supplied row buffers packed into bytesunless the library has been told to transform it into another format.For example, 4 bit/pixel paletted or grayscale data will be returned2 pixels/byte with the leftmost pixel in the high-order bits of thebyte, unless png_set_packing() is called.  8-bit RGB data will be storedin RGB RGB RGB format unless png_set_filler() or png_set_add_alpha()is called to insert filler bytes, either before or after each RGB triplet.16-bit RGB data will be returned RRGGBB RRGGBB, with the most significantbyte of the color value first, unless png_set_strip_16() is called totransform it to regular RGB RGB triplets, or png_set_filler() orpng_set_add alpha() is called to insert filler bytes, either before orafter each RRGGBB triplet.  Similarly, 8-bit or 16-bit grayscale data canbe modified withpng_set_filler(), png_set_add_alpha(), or png_set_strip_16().The following code transforms grayscale images of less than 8 to 8 bits,changes paletted images to RGB, and adds a full alpha channel if there istransparency information in a tRNS chunk.  This is most useful ongrayscale images with bit depths of 2 or 4 or if there is a multiple-imageviewing application that wishes to treat all images in the same way.    if (color_type == PNG_COLOR_TYPE_PALETTE)        png_set_palette_to_rgb(png_ptr);    if (color_type == PNG_COLOR_TYPE_GRAY &&        bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr);    if (png_get_valid(png_ptr, info_ptr,        PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr);These three functions are actually aliases for png_set_expand(), addedin libpng version 1.0.4, with the function names expanded to improve codereadability.  In some future version they may actually do differentthings.As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() wasadded.  It expands the sample depth without changing tRNS to alpha.At the same time, png_set_gray_1_2_4_to_8() was deprecated, and itwill be removed from a future version.PNG can have files with 16 bits per channel.  If you only can handle8 bits per channel, this will strip the pixels down to 8 bit.    if (bit_depth == 16)        png_set_strip_16(png_ptr);If, for some reason, you don't need the alpha channel on an image,and you want to remove it rather than combining it with the background(but the image author certainly had in mind that you *would* combineit with the background, so that's what you should probably do):    if (color_type & PNG_COLOR_MASK_ALPHA)        png_set_strip_alpha(png_ptr);In PNG files, the alpha channel in an imageis the level of opacity.  If you need the alpha channel in an image tobe the level of transparency instead of opacity, you can invert thealpha channel (or the tRNS chunk data) after it's read, so that 0 isfully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bitimages) is fully transparent, with    png_set_invert_alpha(png_ptr);PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small asthey can, resulting in, for example, 8 pixels per byte for 1 bitfiles.  This code expands to 1 pixel per byte without changing thevalues of the pixels:    if (bit_depth < 8)        png_set_packing(png_ptr);PNG files have possible bit depths of 1, 2, 4, 8, and 16.  All pixelsstored in a PNG image have been "scaled" or "shifted" up to the nexthigher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to8 bits/sample in the range [0, 255]).  However, it is also possible toconvert the PNG pixel data back to the original bit depth of the image.This call reduces the pixels back down to the original bit depth:    png_color_8p sig_bit;    if (png_get_sBIT(png_ptr, info_ptr, &sig_bit))        png_set_shift(png_ptr, sig_bit);PNG files store 3-color pixels in red, green, blue order.  This codechanges the storage of the pixels to blue, green, red:    if (color_type == PNG_COLOR_TYPE_RGB ||        color_type == PNG_COLOR_TYPE_RGB_ALPHA)        png_set_bgr(png_ptr);PNG files store RGB pixels packed into 3 or 6 bytes. This code expands theminto 4 or 8 bytes for windowing systems that need them in this format:    if (color_type == PNG_COLOR_TYPE_RGB)        png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE);where "filler" is the 8 or 16-bit number to fill with, and the location iseither PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whetheryou want the filler before the RGB or after.  This transformationdoes not affect images that already have full alpha channels.  To add anopaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER whichwill generate RGBA pixels.Note that png_set_filler() does not change the color type.  If you wantto do that, you can add a true alpha channel with    if (color_type == PNG_COLOR_TYPE_RGB ||           color_type == PNG_COLOR_TYPE_GRAY)    png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER);where "filler" contains the alpha value to assign to each pixel.This function was added in libpng-1.2.7.If you are reading an image with an alpha channel, and you need thedata as ARGB instead of the normal PNG format RGBA:    if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)        png_set_swap_alpha(png_ptr);For some uses, you may want a grayscale image to be represented asRGB.  This code will do that conversion:    if (color_type == PNG_COLOR_TYPE_GRAY ||        color_type == PNG_COLOR_TYPE_GRAY_ALPHA)          png_set_gray_to_rgb(png_ptr);Conversely, you can convert an RGB or RGBA image to grayscale or grayscalewith alpha.    if (color_type == PNG_COLOR_TYPE_RGB ||        color_type == PNG_COLOR_TYPE_RGB_ALPHA)          png_set_rgb_to_gray_fixed(png_ptr, error_action,             int red_weight, int green_weight);    error_action = 1: silently do the conversion    error_action = 2: issue a warning if the original                      image has any pixel where                      red != green or red != blue    error_action = 3: issue an error and abort the                      conversion if the original                      image has any pixel where                      red != green or red != blue    red_weight:       weight of red component times 100000    green_weight:     weight of green component times 100000                      If either weight is negative, default                      weights (21268, 71514) are used.If you have set error_action = 1 or 2, you canlater check whether the image really was gray, after processingthe image rows, with the png_get_rgb_to_gray_status(png_ptr) function.It will return a png_byte that is zero if the image was gray or1 if there were any non-gray pixels.  bKGD and sBIT datawill be silently converted to grayscale, using the green channeldata, regardless of the error_action setting.With red_weight+green_weight<=100000,the normalized graylevel is computed:    int rw = red_weight * 65536;    int gw = green_weight * 65536;    int bw = 65536 - (rw + gw);    gray = (rw*red + gw*green + bw*blue)/65536;The default values approximate those recommended in the CharlesPoynton's Color FAQ, <http://www.inforamp.net/~poynton/>Copyright (c) 1998-01-04 Charles Poynton <poynton at inforamp.net>    Y = 0.212671 * R + 0.715160 * G + 0.072169 * BLibpng approximates this with    Y = 0.21268 * R    + 0.7151 * G    + 0.07217 * Bwhich can be expressed with integers as    Y = (6969 * R + 23434 * G + 2365 * B)/32768The calculation is done in a linear colorspace, if the image gammais known.If you have a grayscale and you are using png_set_expand_depth(),png_set_expand(), or png_set_gray_to_rgb to change to truecolor or toa higher bit-depth, you must either supply the background color as a grayvalue at the original file bit-depth (need_expand = 1) or else supply thebackground color as an RGB triplet at the final, expanded bit depth(need_expand = 0).  Similarly, if you are reading a palett

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -