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

📄 libpng.txt

📁 神龙卡开发原代码
💻 TXT
📖 第 1 页 / 共 5 页
字号:
                 unknown chunks are affectedUnknown chunks declared in this way will be saved as raw data onto alist of png_unknown_chunk structures.  If a chunk that is normallyknown to libpng is named in the list, it will be handled as unknown,according to the "keep" directive.  If a chunk is named in successiveinstances of png_set_keep_unknown_chunks(), the final instance willtake precedence.The high-level read interfaceAt this point there are two ways to proceed; through the high-levelread interface, or through a sequence of low-level read operations.You can use the high-level interface if (a) you are willing to readthe entire image into memory, and (b) the input transformationsyou want to do are limited to the following set:    PNG_TRANSFORM_IDENTITY      No transformation    PNG_TRANSFORM_STRIP_16      Strip 16-bit samples to                                8 bits    PNG_TRANSFORM_STRIP_ALPHA   Discard the alpha channel    PNG_TRANSFORM_PACKING       Expand 1, 2 and 4-bit                                samples to bytes    PNG_TRANSFORM_PACKSWAP      Change order of packed                                pixels to LSB first    PNG_TRANSFORM_EXPAND        Perform set_expand()    PNG_TRANSFORM_INVERT_MONO   Invert monochrome images    PNG_TRANSFORM_SHIFT         Normalize pixels to the                                sBIT depth    PNG_TRANSFORM_BGR           Flip RGB to BGR, RGBA                                to BGRA    PNG_TRANSFORM_SWAP_ALPHA    Flip RGBA to ARGB or GA                                to AG    PNG_TRANSFORM_INVERT_ALPHA  Change alpha from opacity                                to transparency    PNG_TRANSFORM_SWAP_ENDIAN   Byte-swap 16-bit samples(This excludes setting a background color, doing gamma transformation,dithering, and setting filler.)  If this is the case, simply do this:    png_read_png(png_ptr, info_ptr, png_transforms, NULL)where png_transforms is an integer containing the logical OR ofsome set of transformation flags.  This call is equivalent to png_read_info(),followed the set of transformations indicated by the transform mask,then png_read_image(), and finally png_read_end().(The final parameter of this call is not yet used.  Someday it might pointto transformation parameters required by some future input transform.)After you have called png_read_png(), you can retrieve the image datawith   row_pointers = png_get_rows(png_ptr, info_ptr);where row_pointers is an array of pointers to the pixel data for each row:   png_bytep row_pointers[height];If you know your image size and pixel size ahead of time, you can allocaterow_pointers prior to calling png_read_png() with   row_pointers = png_malloc(png_ptr,      height*sizeof(png_bytep));   for (int i=0; i<height, i++)      row_pointers[i]=png_malloc(png_ptr,         width*pixel_size);   png_set_rows(png_ptr, info_ptr, &row_pointers);Alternatively you could allocate your image in one big block and definerow_pointers[i] to point into the proper places in your block.If you use png_set_rows(), the application is responsible for freeingrow_pointers (and row_pointers[i], if they were separately allocated).If you don't allocate row_pointers ahead of time, png_read_png() willdo it, and it'll be free'ed when you call png_destroy_*().The low-level read interfaceIf you are going the low-level route, you are now ready to read allthe file information up to the actual image data.  You do this with acall to png_read_info().    png_read_info(png_ptr, info_ptr);This will process all chunks up to but not including the image data.Querying the info structureFunctions are used to get the information from the info_ptr once ithas been read.  Note that these fields may not be completely filledin until png_read_end() has read the chunk data following the image.    png_get_IHDR(png_ptr, info_ptr, &width, &height,       &bit_depth, &color_type, &interlace_type,       &compression_type, &filter_method);    width          - holds the width of the image                     in pixels (up to 2^31).    height         - holds the height of the image                     in pixels (up to 2^31).    bit_depth      - holds the bit depth of one of the                     image channels.  (valid values are                     1, 2, 4, 8, 16 and depend also on                     the color_type.  See also                     significant bits (sBIT) below).    color_type     - describes which color/alpha channels                         are present.                     PNG_COLOR_TYPE_GRAY                        (bit depths 1, 2, 4, 8, 16)                     PNG_COLOR_TYPE_GRAY_ALPHA                        (bit depths 8, 16)                     PNG_COLOR_TYPE_PALETTE                        (bit depths 1, 2, 4, 8)                     PNG_COLOR_TYPE_RGB                        (bit_depths 8, 16)                     PNG_COLOR_TYPE_RGB_ALPHA                        (bit_depths 8, 16)                     PNG_COLOR_MASK_PALETTE                     PNG_COLOR_MASK_COLOR                     PNG_COLOR_MASK_ALPHA    filter_method  - (must be PNG_FILTER_TYPE_BASE                     for PNG 1.0, and can also be                     PNG_INTRAPIXEL_DIFFERENCING if                     the PNG datastream is embedded in                     a MNG-1.0 datastream)    compression_type - (must be PNG_COMPRESSION_TYPE_BASE                     for PNG 1.0)    interlace_type - (PNG_INTERLACE_NONE or                     PNG_INTERLACE_ADAM7)    Any or all of interlace_type, compression_type, of    filter_method can be NULL if you are    not interested in their values.    channels = png_get_channels(png_ptr, info_ptr);    channels       - number of channels of info for the                     color type (valid values are 1 (GRAY,                     PALETTE), 2 (GRAY_ALPHA), 3 (RGB),                     4 (RGB_ALPHA or RGB + filler byte))    rowbytes = png_get_rowbytes(png_ptr, info_ptr);    rowbytes       - number of bytes needed to hold a row    signature = png_get_signature(png_ptr, info_ptr);    signature      - holds the signature read from the                     file (if any).  The data is kept in                     the same offset it would be if the                     whole signature were read (i.e. if an                     application had already read in 4                     bytes of signature before starting                     libpng, the remaining 4 bytes would                     be in signature[4] through signature[7]                     (see png_set_sig_bytes())).    width            = png_get_image_width(png_ptr,                         info_ptr);    height           = png_get_image_height(png_ptr,                         info_ptr);    bit_depth        = png_get_bit_depth(png_ptr,                         info_ptr);    color_type       = png_get_color_type(png_ptr,                         info_ptr);    filter_method    = png_get_filter_type(png_ptr,                         info_ptr);    compression_type = png_get_compression_type(png_ptr,                         info_ptr);    interlace_type   = png_get_interlace_type(png_ptr,                         info_ptr);These are also important, but their validity depends on whether the chunkhas been read.  The png_get_valid(png_ptr, info_ptr, PNG_INFO_<chunk>) andpng_get_<chunk>(png_ptr, info_ptr, ...) functions return non-zero if thedata has been read, or zero if it is missing.  The parameters to thepng_get_<chunk> are set directly if they are simple data types, or a pointerinto the info_ptr is returned for any complex types.    png_get_PLTE(png_ptr, info_ptr, &palette,                     &num_palette);    palette        - the palette for the file                     (array of png_color)    num_palette    - number of entries in the palette    png_get_gAMA(png_ptr, info_ptr, &gamma);    gamma          - the gamma the file is written                     at (PNG_INFO_gAMA)    png_get_sRGB(png_ptr, info_ptr, &srgb_intent);    srgb_intent    - the rendering intent (PNG_INFO_sRGB)                     The presence of the sRGB chunk                     means that the pixel data is in the                     sRGB color space.  This chunk also                     implies specific values of gAMA and                     cHRM.    png_get_iCCP(png_ptr, info_ptr, &name,       &compression_type, &profile, &proflen);    name            - The profile name.    compression     - The compression type; always                      PNG_COMPRESSION_TYPE_BASE for PNG 1.0.                      You may give NULL to this argument to                      ignore it.    profile         - International Color Consortium color                      profile data. May contain NULs.    proflen         - length of profile data in bytes.    png_get_sBIT(png_ptr, info_ptr, &sig_bit);    sig_bit        - the number of significant bits for                     (PNG_INFO_sBIT) each of the gray,                     red, green, and blue channels,                     whichever are appropriate for the                     given color type (png_color_16)    png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans,                     &trans_values);    trans          - array of transparent entries for                     palette (PNG_INFO_tRNS)    trans_values   - graylevel or color sample values of                     the single transparent color for                     non-paletted images (PNG_INFO_tRNS)    num_trans      - number of transparent entries                     (PNG_INFO_tRNS)    png_get_hIST(png_ptr, info_ptr, &hist);                     (PNG_INFO_hIST)    hist           - histogram of palette (array of                     png_uint_16)    png_get_tIME(png_ptr, info_ptr, &mod_time);    mod_time       - time image was last modified                    (PNG_VALID_tIME)    png_get_bKGD(png_ptr, info_ptr, &background);    background     - background color (PNG_VALID_bKGD)                     valid 16-bit red, green and blue                     values, regardless of color_type    num_comments   = png_get_text(png_ptr, info_ptr,                     &text_ptr, &num_text);    num_comments   - number of comments    text_ptr       - array of png_text holding image                     comments    text_ptr[i].compression - type of compression used                 on "text" PNG_TEXT_COMPRESSION_NONE                           PNG_TEXT_COMPRESSION_zTXt                           PNG_ITXT_COMPRESSION_NONE                           PNG_ITXT_COMPRESSION_zTXt    text_ptr[i].key   - keyword for comment.  Must contain                         1-79 characters.    text_ptr[i].text  - text comments for current                         keyword.  Can be empty.    text_ptr[i].text_length - length of text string,                 after decompression, 0 for iTXt    text_ptr[i].itxt_length - length of itxt string,                 after decompression, 0 for tEXt/zTXt    text_ptr[i].lang  - language of comment (empty                         string for unknown).    text_ptr[i].translated_keyword  - keyword in UTF-8                         (empty string for unknown).    num_text       - number of comments (same as                     num_comments; you can put NULL here                     to avoid the duplication)    Note while png_set_text() will accept text, language,    and translated keywords that can be NULL pointers, the    structure returned by png_get_text will always contain    regular zero-terminated C strings.  They might be    empty strings but they will never be NULL pointers.    num_spalettes = png_get_sPLT(png_ptr, info_ptr,       &palette_ptr);    palette_ptr    - array of palette structures holding                     contents of one or more sPLT chunks                     read.    num_spalettes  - number of sPLT chunks read.    png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y,       &unit_type);    offset_x       - positive offset from the left edge                     of the screen    offset_y       - positive offset from the top edge                     of the screen    unit_type      - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER    png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y,       &unit_type);    res_x          - pixels/unit physical resolution in                     x direction    res_y          - pixels/unit physical resolution in                     x direction    unit_type      - PNG_RESOLUTION_UNKNOWN,                     PNG_RESOLUTION_METER    png_get_sCAL(png_ptr, info_ptr, &unit, &width,       &height)    unit        - physical scale units (an integer)    width       - width of a pixel in physical scale units    height      - height of a pixel in physical scale units                 (width and height are doubles)    png_get_sCAL_s(png_ptr, info_ptr, &unit, &width,       &height)    unit        - physical scale units (an integer)    width       - width of a pixel in physical scale units    height      - height of a pixel in physical scale units                 (width and height are strings like "2.54")    num_unknown_chunks = png_get_unknown_chunks(png_ptr,       info_ptr, &unknowns)    unknowns          - array of png_unknown_chunk                        structures holding unknown chunks    unknowns[i].name  - name of unknown chunk    unknowns[i].data  - data of unknown chunk    unknowns[i].size  - size of unknown chunk's data    unknowns[i].location - position of chunk in file

⌨️ 快捷键说明

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