Show
Ignore:
Timestamp:
02/15/10 11:37:15 (2 years ago)
Author:
Carsten
Message:

Upgraded vendor/libpng from 1.2.40 to 1.2.42.

Files:
1 moved

Legend:

Unmodified
Added
Removed
  • vendor/libpng/libpng-1.2.42.txt

    r11 r43  
    11libpng.txt - A description on how to use and modify libpng 
    22 
    3  libpng version 1.2.40 - September 10, 2009 
     3 libpng version 1.2.42 - January 3, 2010 
    44 Updated and distributed by Glenn Randers-Pehrson 
    55 <glennrp at users.sourceforge.net> 
     
    1212 Based on: 
    1313 
    14  libpng versions 0.97, January 1998, through 1.2.40 - September 10, 2009 
     14 libpng versions 0.97, January 1998, through 1.2.42 - January 3, 2010 
    1515 Updated and distributed by Glenn Randers-Pehrson 
    1616 Copyright (c) 1998-2009 Glenn Randers-Pehrson 
     
    4141 
    4242For examples of libpng usage, see the files "example.c", "pngtest.c", 
    43 and the files in the "contrib" directory, all of which are included in the 
    44 libpng distribution. 
     43and the files in the "contrib" directory, all of which are included in 
     44the libpng distribution. 
    4545 
    4646Libpng was written as a companion to the PNG specification, as a way 
     
    410410   width_max = png_get_user_width_max(png_ptr); 
    411411   height_max = png_get_user_height_max(png_ptr); 
     412 
     413The PNG specification sets no limit on the number of ancillary chunks 
     414allowed in a PNG datastream.  You can impose a limit on the total number 
     415of sPLT, tEXt, iTXt, zTXt, and unknown chunks that will be stored, with 
     416 
     417   png_set_chunk_cache_max(png_ptr, user_chunk_cache_max); 
     418 
     419where 0x7fffffffL means unlimited.  You can retrieve this limit with 
     420 
     421   chunk_cache_max = png_get_chunk_cache_max(png_ptr); 
     422 
     423This limit also applies to the number of buffers that can be allocated 
     424by png_decompress_chunk() while decompressing iTXt, zTXt, and iCCP chunks. 
    412425 
    413426The high-level read interface 
     
    438451                                to transparency 
    439452    PNG_TRANSFORM_SWAP_ENDIAN   Byte-swap 16-bit samples 
     453    PNG_TRANSFORM_GRAY_TO_RGB   Expand grayscale samples 
     454                                to RGB (or GA to RGBA) 
    440455 
    441456(This excludes setting a background color, doing gamma transformation, 
     
    444459    png_read_png(png_ptr, info_ptr, png_transforms, NULL) 
    445460 
    446 where png_transforms is an integer containing the bitwise OR of 
    447 some set of transformation flags.  This call is equivalent to png_read_info(), 
     461where png_transforms is an integer containing the bitwise OR of some 
     462set of transformation flags.  This call is equivalent to png_read_info(), 
    448463followed the set of transformations indicated by the transform mask, 
    449464then png_read_image(), and finally png_read_end(). 
     
    546561    interlace_type - (PNG_INTERLACE_NONE or 
    547562                     PNG_INTERLACE_ADAM7) 
    548     Any or all of interlace_type, compression_type, of 
     563 
     564    Any or all of interlace_type, compression_type, or 
    549565    filter_method can be NULL if you are 
    550566    not interested in their values. 
    551567 
    552     channels = png_get_channels(png_ptr, info_ptr); 
    553     channels       - number of channels of info for the 
    554                      color type (valid values are 1 (GRAY, 
    555                      PALETTE), 2 (GRAY_ALPHA), 3 (RGB), 
    556                      4 (RGB_ALPHA or RGB + filler byte)) 
    557     rowbytes = png_get_rowbytes(png_ptr, info_ptr); 
    558     rowbytes       - number of bytes needed to hold a row 
    559  
    560     signature = png_get_signature(png_ptr, info_ptr); 
    561     signature      - holds the signature read from the 
    562                      file (if any).  The data is kept in 
    563                      the same offset it would be if the 
    564                      whole signature were read (i.e. if an 
    565                      application had already read in 4 
    566                      bytes of signature before starting 
    567                      libpng, the remaining 4 bytes would 
    568                      be in signature[4] through signature[7] 
    569                      (see png_set_sig_bytes())). 
    570  
     568    Note that png_get_IHDR() returns 32-bit data into 
     569    the application's width and height variables. 
     570    This is an unsafe situation if these are 16-bit 
     571    variables.  In such situations, the 
     572    png_get_image_width() and png_get_image_height() 
     573    functions described below are safer. 
    571574 
    572575    width            = png_get_image_width(png_ptr, 
     
    585588                         info_ptr); 
    586589 
     590    channels = png_get_channels(png_ptr, info_ptr); 
     591    channels       - number of channels of info for the 
     592                     color type (valid values are 1 (GRAY, 
     593                     PALETTE), 2 (GRAY_ALPHA), 3 (RGB), 
     594                     4 (RGB_ALPHA or RGB + filler byte)) 
     595    rowbytes = png_get_rowbytes(png_ptr, info_ptr); 
     596    rowbytes       - number of bytes needed to hold a row 
     597 
     598    signature = png_get_signature(png_ptr, info_ptr); 
     599    signature      - holds the signature read from the 
     600                     file (if any).  The data is kept in 
     601                     the same offset it would be if the 
     602                     whole signature were read (i.e. if an 
     603                     application had already read in 4 
     604                     bytes of signature before starting 
     605                     libpng, the remaining 4 bytes would 
     606                     be in signature[4] through signature[7] 
     607                     (see png_set_sig_bytes())). 
    587608 
    588609These are also important, but their validity depends on whether the chunk 
     
    590611png_get_<chunk>(png_ptr, info_ptr, ...) functions return non-zero if the 
    591612data has been read, or zero if it is missing.  The parameters to the 
    592 png_get_<chunk> are set directly if they are simple data types, or a pointer 
    593 into the info_ptr is returned for any complex types. 
     613png_get_<chunk> are set directly if they are simple data types, or a 
     614pointer into the info_ptr is returned for any complex types. 
    594615 
    595616    png_get_PLTE(png_ptr, info_ptr, &palette, 
     
    631652    png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, 
    632653                     &trans_values); 
    633     trans          - array of transparent entries for 
    634                      palette (PNG_INFO_tRNS) 
     654    trans          - array of transparent 
     655                     entries for palette (PNG_INFO_tRNS) 
    635656    trans_values   - graylevel or color sample values of 
    636657                     the single transparent color for 
     
    675696    text_ptr[i].lang_key  - keyword in UTF-8 
    676697                         (empty string for unknown). 
     698    Note that the itxt_length, lang, and lang_key 
     699    members of the text_ptr structure only exist 
     700    when the library is built with iTXt chunk support. 
     701 
    677702    num_text       - number of comments (same as 
    678703                     num_comments; you can put NULL here 
     
    854879added.  It expands the sample depth without changing tRNS to alpha. 
    855880 
     881As of libpng version 1.2.42, not all possible expansions are supported. 
     882 
     883In the following table, the 01 means grayscale with depth<8, 31 means 
     884indexed with depth<8, other numerals represent the color type, "T" means 
     885the tRNS chunk is present, A means an alpha channel is present, and O 
     886means tRNS or alpha is present but all pixels in the image are opaque. 
     887 
     888  FROM  01  31   0  0T  0O   2  2T  2O   3  3T  3O  4A  4O  6A  6O  
     889   TO 
     890   01    -                    
     891   31        - 
     892    0    1       -            
     893   0T                - 
     894   0O                    - 
     895    2           GX           - 
     896   2T                            - 
     897   2O                                - 
     898    3        1                           - 
     899   3T                                        - 
     900   3O                                            - 
     901   4A                T                               - 
     902   4O                                                    - 
     903   6A               GX         TX           TX               - 
     904   6O                   GX                      TX               - 
     905 
     906Within the matrix, 
     907     "-" means the transformation is not supported. 
     908     "X" means the transformation is obtained by png_set_expand(). 
     909     "1" means the transformation is obtained by 
     910         png_set_expand_gray_1_2_4_to_8 
     911     "G" means the transformation is obtained by 
     912         png_set_gray_to_rgb(). 
     913     "P" means the transformation is obtained by 
     914         png_set_expand_palette_to_rgb(). 
     915     "T" means the transformation is obtained by 
     916         png_set_tRNS_to_alpha(). 
     917 
    856918PNG can have files with 16 bits per channel.  If you only can handle 
    8579198 bits per channel, this will strip the pixels down to 8 bit. 
     
    877939    png_set_invert_alpha(png_ptr); 
    878940 
     941The PNG format only supports pixels with postmultiplied alpha. 
     942If you want to replace the pixels, after reading them, with pixels 
     943that have premultiplied color samples, you can do this with 
     944 
     945    png_set_premultiply_alpha(png_ptr); 
     946 
     947If you do this, any input with a tRNS chunk will be expanded to 
     948have an alpha channel. 
     949 
    879950PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as 
    880951they can, resulting in, for example, 8 pixels per byte for 1 bit 
     
    887958PNG files have possible bit depths of 1, 2, 4, 8, and 16.  All pixels 
    888959stored in a PNG image have been "scaled" or "shifted" up to the next 
    889 higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to 
    890 8 bits/sample in the range [0, 255]).  However, it is also possible to 
    891 convert the PNG pixel data back to the original bit depth of the image. 
    892 This call reduces the pixels back down to the original bit depth: 
     960higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] 
     961to 8 bits/sample in the range [0, 255]).  However, it is also possible 
     962to convert the PNG pixel data back to the original bit depth of the 
     963image.  This call reduces the pixels back down to the original bit depth: 
    893964 
    894965    png_color_8p sig_bit; 
     
    13371408This function may be safely called when the relevant storage has 
    13381409already been freed, or has not yet been allocated, or was allocated 
    1339 by the user and not by libpng,  and will in those 
    1340 cases do nothing.  The "seq" parameter is ignored if only one item 
    1341 of the selected data type, such as PLTE, is allowed.  If "seq" is not 
    1342 -1, and multiple items are allowed for the data type identified in 
    1343 the mask, such as text or sPLT, only the n'th item in the structure 
    1344 is freed, where n is "seq". 
     1410by the user and not by libpng,  and will in those cases do nothing. 
     1411The "seq" parameter is ignored if only one item of the selected data 
     1412type, such as PLTE, is allowed.  If "seq" is not -1, and multiple items 
     1413are allowed for the data type identified in the mask, such as text or 
     1414sPLT, only the n'th item in the structure is freed, where n is "seq". 
    13451415 
    13461416The default behavior is only to free data that was allocated internally 
     
    13811451 
    13821452The png_free_data() function will turn off the "valid" flag for anything 
    1383 it frees.  If you need to turn the flag off for a chunk that was freed by your 
    1384 application instead of by libpng, you can use 
     1453it frees.  If you need to turn the flag off for a chunk that was freed by 
     1454your application instead of by libpng, you can use 
    13851455 
    13861456    png_set_invalid(png_ptr, info_ptr, mask); 
     
    16921762a PNG datastream that is to be embedded in a MNG datastream).  The third 
    16931763parameter is a flag that indicates which filter type(s) are to be tested 
    1694 for each scanline.  See the PNG specification for details on the specific filter 
    1695 types. 
     1764for each scanline.  See the PNG specification for details on the specific 
     1765filter types. 
    16961766 
    16971767 
     
    18611931    png_set_tRNS(png_ptr, info_ptr, trans, num_trans, 
    18621932       trans_values); 
    1863     trans          - array of transparent entries for 
    1864                      palette (PNG_INFO_tRNS) 
     1933    trans          - array of transparent 
     1934                     entries for palette (PNG_INFO_tRNS) 
    18651935    trans_values   - graylevel or color sample values 
    18661936                     (in order red, green, blue) of the 
     
    19021972    text_ptr[i].translated_keyword  - keyword in UTF-8 (NULL 
    19031973                         or empty for unknown). 
     1974    Note that the itxt_length, lang, and lang_key 
     1975    members of the text_ptr structure only exist 
     1976    when the library is built with iTXt chunk support. 
     1977 
    19041978    num_text       - number of comments 
    19051979 
     
    21072181Note that there is one transformation you may need to do before 
    21082182png_write_info().  In PNG files, the alpha channel in an image is the 
    2109 level of opacity.  If your data is supplied as a level of 
    2110 transparency, you can invert the alpha channel before you write it, so 
    2111 that 0 is fully transparent and 255 (in 8-bit or paletted images) or 
    2112 65535 (in 16-bit images) is fully opaque, with 
     2183level of opacity.  If your data is supplied as a level of transparency, 
     2184you can invert the alpha channel before you write it, so that 0 is 
     2185fully transparent and 255 (in 8-bit or paletted images) or 65535 
     2186(in 16-bit images) is fully opaque, with 
    21132187 
    21142188    png_set_invert_alpha(png_ptr); 
     
    22972371    png_write_row(png_ptr, row_pointer); 
    22982372 
    2299 When the file is interlaced, things can get a good deal more 
    2300 complicated.  The only currently (as of the PNG Specification 
    2301 version 1.2, dated July 1999) defined interlacing scheme for PNG files 
    2302 is the "Adam7" interlace scheme, that breaks down an 
    2303 image into seven smaller images of varying size.  libpng will build 
    2304 these images for you, or you can do them yourself.  If you want to 
    2305 build them yourself, see the PNG specification for details of which 
    2306 pixels to write when. 
     2373When the file is interlaced, things can get a good deal more complicated. 
     2374The only currently (as of the PNG Specification version 1.2, dated July 
     23751999) defined interlacing scheme for PNG files is the "Adam7" interlace 
     2376scheme, that breaks down an image into seven smaller images of varying 
     2377size.  libpng will build these images for you, or you can do them 
     2378yourself.  If you want to build them yourself, see the PNG specification 
     2379for details of which pixels to write when. 
    23072380 
    23082381If you don't want libpng to handle the interlacing details, just 
     
    23162389       png_set_interlace_handling(png_ptr); 
    23172390 
    2318 This will return the number of passes needed.  Currently, this 
    2319 is seven, but may change if another interlace type is added. 
     2391This will return the number of passes needed.  Currently, this is seven, 
     2392but may change if another interlace type is added. 
    23202393 
    23212394Then write the complete image number_of_passes times. 
     
    23242397       number_of_rows); 
    23252398 
    2326 As some of these rows are not used, and thus return immediately, 
    2327 you may want to read about interlacing in the PNG specification, 
    2328 and only update the rows that are actually used. 
     2399As some of these rows are not used, and thus return immediately, you may 
     2400want to read about interlacing in the PNG specification, and only update 
     2401the rows that are actually used. 
    23292402 
    23302403Finishing a sequential write 
     
    23592432This function may be safely called when the relevant storage has 
    23602433already been freed, or has not yet been allocated, or was allocated 
    2361 by the user  and not by libpng,  and will in those 
    2362 cases do nothing.  The "seq" parameter is ignored if only one item 
    2363 of the selected data type, such as PLTE, is allowed.  If "seq" is not 
    2364 -1, and multiple items are allowed for the data type identified in 
    2365 the mask, such as text or sPLT, only the n'th item in the structure 
    2366 is freed, where n is "seq". 
    2367  
    2368 If you allocated data such as a palette that you passed 
    2369 in to libpng with png_set_*, you must not free it until just before the call to 
     2434by the user  and not by libpng,  and will in those cases do nothing. 
     2435The "seq" parameter is ignored if only one item of the selected data 
     2436type, such as PLTE, is allowed.  If "seq" is not -1, and multiple items 
     2437are allowed for the data type identified in the mask, such as text or 
     2438sPLT, only the n'th item in the structure is freed, where n is "seq". 
     2439 
     2440If you allocated data such as a palette that you passed in to libpng 
     2441with png_set_*, you must not free it until just before the call to 
    23702442png_destroy_write_struct(). 
    23712443 
     
    24332505these functions, call the appropriate png_set_*_fn() function. 
    24342506 
    2435 Memory allocation is done through the functions png_malloc() 
    2436 and png_free().  These currently just call the standard C functions.  If 
    2437 your pointers can't access more then 64K at a time, you will want to set 
    2438 MAXSEG_64K in zlib.h.  Since it is unlikely that the method of handling 
    2439 memory allocation on a platform will change between applications, these 
    2440 functions must be modified in the library at compile time.  If you prefer 
    2441 to use a different method of allocating and freeing data, you can use 
    2442 png_create_read_struct_2() or png_create_write_struct_2() to register 
    2443 your own functions as described above. 
    2444 These functions also provide a void pointer that can be retrieved via 
     2507Memory allocation is done through the functions png_malloc(), png_calloc(), 
     2508and png_free().  These currently just call the standard C functions. 
     2509png_calloc() calls png_malloc() and then png_memset() to clear the newly 
     2510allocated memory to zero.  If your pointers can't access more then 64K 
     2511at a time, you will want to set MAXSEG_64K in zlib.h.  Since it is 
     2512unlikely that the method of handling memory allocation on a platform 
     2513will change between applications, these functions must be modified in 
     2514the library at compile time.  If you prefer to use a different method 
     2515of allocating and freeing data, you can use png_create_read_struct_2() or 
     2516png_create_write_struct_2() to register your own functions as described 
     2517above.  These functions also provide a void pointer that can be retrieved 
     2518via 
    24452519 
    24462520    mem_ptr=png_get_mem_ptr(png_ptr); 
     
    25342608as there is no need to check every return code of every function call. 
    25352609However, there are some uncertainties about the status of local variables 
    2536 after a longjmp, so the user may want to be careful about doing anything after 
    2537 setjmp returns non-zero besides returning itself.  Consult your compiler 
    2538 documentation for more details.  For an alternative approach, you may wish 
    2539 to use the "cexcept" facility (see http://cexcept.sourceforge.net). 
     2610after a longjmp, so the user may want to be careful about doing anything 
     2611after setjmp returns non-zero besides returning itself.  Consult your 
     2612compiler documentation for more details.  For an alternative approach, you 
     2613may wish to use the "cexcept" facility (see http://cexcept.sourceforge.net). 
    25402614 
    25412615Custom chunks 
     
    25492623 
    25502624If you need to write a new intrinsic chunk, first read the PNG 
    2551 specification. Acquire a first level of 
    2552 understanding of how it works.  Pay particular attention to the 
    2553 sections that describe chunk names, and look at how other chunks were 
    2554 designed, so you can do things similarly.  Second, check out the 
    2555 sections of libpng that read and write chunks.  Try to find a chunk 
    2556 that is similar to yours and use it as a template.  More details can 
    2557 be found in the comments inside the code.  It is best to handle unknown 
    2558 chunks in a generic method, via callback functions, instead of by 
    2559 modifying libpng functions. 
     2625specification. Acquire a first level of understanding of how it works. 
     2626Pay particular attention to the sections that describe chunk names, 
     2627and look at how other chunks were designed, so you can do things 
     2628similarly.  Second, check out the sections of libpng that read and 
     2629write chunks.  Try to find a chunk that is similar to yours and use 
     2630it as a template.  More details can be found in the comments inside 
     2631the code.  It is best to handle unknown chunks in a generic method, 
     2632via callback functions, instead of by modifying libpng functions. 
    25602633 
    25612634If you wish to write your own transformation for the data, look through 
     
    27342807or all four, 
    27352808along with directives to turn on any of the capabilities that you do 
    2736 want.  The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable 
    2737 the extra transformations but still leave the library fully capable of reading 
    2738 and writing PNG files with all known public chunks 
    2739 Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive 
    2740 produces a library that is incapable of reading or writing ancillary chunks. 
    2741 If you are not using the progressive reading capability, you can 
    2742 turn that off with PNG_NO_PROGRESSIVE_READ (don't confuse 
    2743 this with the INTERLACING capability, which you'll still have). 
     2809want.  The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the extra 
     2810transformations but still leave the library fully capable of reading 
     2811and writing PNG files with all known public chunks. Use of the 
     2812PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library 
     2813that is incapable of reading or writing ancillary chunks.  If you are 
     2814not using the progressive reading capability, you can turn that off 
     2815with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING 
     2816capability, which you'll still have). 
    27442817 
    27452818All the reading and writing specific code are in separate files, so the 
     
    28752948png_create_write_struct_2(), png_set_mem_fn(), png_get_mem_ptr(), 
    28762949png_malloc_default(), and png_free_default() were added. 
     2950 
     2951Support for the iTXt chunk has been enabled by default as of 
     2952version 1.2.41. 
    28772953 
    28782954Support for certain MNG features was enabled. 
     
    29303006when the Intel assembler code was removed due to a licensing issue. 
    29313007 
     3008These macros are deprecated: 
     3009 
     3010    PNG_READ_TRANSFORMS_NOT_SUPPORTED 
     3011    PNG_PROGRESSIVE_READ_NOT_SUPPORTED 
     3012    PNG_NO_SEQUENTIAL_READ_SUPPORTED 
     3013    PNG_WRITE_TRANSFORMS_NOT_SUPPORTED 
     3014    PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED 
     3015    PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED 
     3016 
     3017They have been replaced, respectively, by: 
     3018 
     3019    PNG_NO_READ_TRANSFORMS 
     3020    PNG_NO_PROGRESSIVE_READ 
     3021    PNG_NO_SEQUENTIAL_READ 
     3022    PNG_NO_WRITE_TRANSFORMS 
     3023    PNG_NO_READ_ANCILLARY_CHUNKS 
     3024    PNG_NO_WRITE_ANCILLARY_CHUNKS 
     3025 
     3026PNG_MAX_UINT was replaced with PNG_UINT_31_MAX.  It has been 
     3027deprecated since libpng-1.0.16 and libpng-1.2.6. 
     3028 
     3029The function 
     3030    png_check_sig(sig, num) 
     3031was replaced with 
     3032    !png_sig_cmp(sig, 0, num) 
     3033It has been deprecated since libpng-0.90. 
     3034 
     3035The function 
     3036    png_set_gray_1_2_4_to_8() 
     3037which also expands tRNS to alpha was replaced with 
     3038    png_set_expand_gray_1_2_4_to_8() 
     3039which does not. It has been deprecated since libpng-1.0.18 and 1.2.9. 
     3040 
    29323041IX.  (Omitted) 
     3042 
    29333043 
    29343044X. Detecting libpng 
     
    29833093are usually indented the same as the first line of the statement 
    29843094plus four more spaces. 
     3095 
     3096For macro definitions we use 2-space indentation, always leaving the "#" 
     3097in the first column. 
     3098 
     3099    #ifndef PNG_NO_FEATURE 
     3100    #  ifndef PNG_FEATURE_SUPPORTED 
     3101    #    define PNG_FEATURE_SUPPORTED 
     3102    #  endif 
     3103    #endif 
    29853104 
    29863105Comments appear with the leading "/*" at the same indentation as 
     
    30483167 
    30493168    for (i = 2; i > 0; --i) 
    3050        x[i] = a(x) + (int)b; 
     3169       y[i] = a(x) + (int)b; 
    30513170 
    30523171We prefer #ifdef and #ifndef to #if defined() and if !defined() 
    30533172when there is only one macro being tested. 
    30543173 
    3055 Other rules can be inferred by inspecting the libpng 
    3056 source. 
     3174We do not use the TAB character for indentation in the C sources. 
     3175 
     3176Lines do not exceed 80 characters. 
     3177 
     3178Other rules can be inferred by inspecting the libpng source. 
    30573179 
    30583180XIII. Y2K Compliance in libpng 
    30593181 
    3060 September 10, 2009 
     3182January 3, 2010 
    30613183 
    30623184Since the PNG Development group is an ad-hoc body, we can't make 
     
    30643186 
    30653187This is your unofficial assurance that libpng from version 0.71 and 
    3066 upward through 1.2.40 are Y2K compliant.  It is my belief that earlier 
     3188upward through 1.2.42 are Y2K compliant.  It is my belief that earlier 
    30673189versions were also Y2K compliant. 
    30683190