Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
1 deleted
86 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/3rdparty/libpng/ANNOUNCE

    r2 r561  
    11
    2 Libpng 1.2.29 - May 8, 2008
     2Libpng 1.2.40 - September 10, 2009
    33
    44This is a public release of libpng, intended for use in production codes.
     
    99"configure" script
    1010
    11    libpng-1.2.29.tar.gz
    12    libpng-1.2.29.tar.lzma
    13      (Get the lzma codec from <http://tukaani.org/lzma>).
    14    libpng-1.2.29.tar.bz2
     11   libpng-1.2.40.tar.xz (LZMA-compressed, recommended)
     12   libpng-1.2.40.tar.gz
     13   libpng-1.2.40.tar.bz2
    1514
    1615Source files with LF line endings (for Unix/Linux) without the
    1716"configure" script
    1817
    19    libpng-1.2.29-no-config.tar.gz
    20    libpng-1.2.29-no-config.tar.lzma
    21    libpng-1.2.29-no-config.tar.bz2
     18   libpng-1.2.40-no-config.tar.xz (LZMA-compressed, recommended)
     19   libpng-1.2.40-no-config.tar.gz
     20   libpng-1.2.40-no-config.tar.bz2
    2221
    2322Source files with CRLF line endings (for Windows), without the
    2423"configure" script
    2524
    26    lpng1229.zip
    27    lpng1229.7z
    28    lpng1229.tar.bz2
     25   lpng1240.zip
     26   lpng1240.7z
     27   lpng1240.tar.bz2
    2928
    3029Project files
    3130
    32    libpng-1.2.29-project-netware.zip
    33    libpng-1.2.29-project-wince.zip
     31   libpng-1.2.40-project-netware.zip
     32   libpng-1.2.40-project-wince.zip
    3433
    3534Other information:
    3635
    37    libpng-1.2.29-README.txt
    38    libpng-1.2.29-KNOWNBUGS.txt
    39    libpng-1.2.29-LICENSE.txt
    40    libpng-1.2.29-Y2K-compliance.txt
    41    libpng-1.2.29-[previous version]-diff.txt
     36   libpng-1.2.40-README.txt
     37   libpng-1.2.40-KNOWNBUGS.txt
     38   libpng-1.2.40-LICENSE.txt
     39   libpng-1.2.40-Y2K-compliance.txt
     40   libpng-1.2.40-[previous version]-diff.txt
    4241
    43 Changes since the last public release (1.2.28):
     42Changes since the last public release (1.2.39):
    4443
    45 version 1.2.29 [May 8, 2008]
     44version 1.2.40 [September 10, 2009]
    4645
    47   Removed some stray *.diff and *.orig files
    48   Reverted Makefile.in, aclocal.m4, and configure to the libpng-1.2.26
    49     versions.
    50   Added --force to autogen libtoolize options and --force-missing to
    51     automake options.
    52   Changed $(ECHO) to echo in Makefile.am and Makefile.in
    53   Updated all configure files to autoconf-2.62
    54   #ifdef out pnggcrd.c code if using MSC_VER
     46  Removed an extra png_debug() recently added to png_write_find_filter().
     47  Fixed incorrect #ifdef in pngset.c regarding unknown chunk support.
     48  Various bugfixes and improvements to CMakeLists.txt (Philip Lowman)
    5549
    5650Send comments/corrections/commendations to png-mng-implement at lists.sf.net
    57 (subscription required; visit
     51
     52Send comments/corrections/commendations to png-mng-implement at lists.sf.net
     53(subscription required; visit
    5854https://lists.sourceforge.net/lists/listinfo/png-mng-implement
    5955to subscribe) or to glennrp at users.sourceforge.net
  • trunk/src/3rdparty/libpng/CHANGES

    r2 r561  
    1 
     1/*
    22CHANGES - changes for libpng
    33
     
    540540  Renamed "PNG_GLOBAL_ARRAYS" to "PNG_USE_GLOBAL_ARRAYS" and made available
    541541    to applications a macro "PNG_USE_LOCAL_ARRAYS".
    542   #ifdef out all the new declarations when PNG_USE_GLOBAL_ARRAYS is defined.
     542  Remove all the new declarations with #ifdef/#endif when
     543    PNG_USE_GLOBAL_ARRAYS is defined.
    543544  Added PNG_EXPORT_VAR macro to accommodate making DLL's.
    544545version 1.0.5e [November 30, 1999]
     
    11801181  Detect buffer overflow in pngpread.c when IDAT is corrupted with extra data.
    11811182  Added "test-installed" target to makefile.32sunu, makefile.64sunu,
    1182     makefile.beos, makefile.darwin, makefile.dec, makefile.macosx, 
     1183    makefile.beos, makefile.darwin, makefile.dec, makefile.macosx,
    11831184    makefile.solaris, makefile.hpux, makefile.hpgcc, and makefile.so9.
    11841185version 1.2.4rc1 and 1.0.14rc1 [July 2, 2002]
     
    13011302    sequential read support.
    13021303  Added some "#if PNG_WRITE_SUPPORTED" blocks.
    1303   #ifdef'ed out some redundancy in png_malloc_default().
     1304  Removed some redundancy with #ifdef/#endif in png_malloc_default().
    13041305  Use png_malloc instead of png_zalloc to allocate the pallete.
    13051306version 1.0.16rc1 and 1.2.6rc1 [August 4, 2004]
     
    13711372    strip alpha operation in png_do_strip_filler().
    13721373  Added PNG_1_2_X definition in pngconf.h
    1373   #ifdef out png_info_init in png.c and png_read_init in pngread.c (as of 1.3.0)
     1374  Comment out with #ifdef/#endif png_info_init in png.c and png_read_init
     1375    in pngread.c (as of 1.3.0)
    13741376version 1.2.8beta2 [November 2, 2004]
    13751377  Reduce color_type to a nonalpha type after strip alpha operation in
     
    13881390    PNG_STRIP_ALPHA info to png_do_strip_filler(), to preserve ABI
    13891391    compatibility.
    1390   Revised handling of SPECIALBUILD, PRIVATEBUILD, 
     1392  Revised handling of SPECIALBUILD, PRIVATEBUILD,
    13911393    PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING.
    13921394version 1.2.8rc1 [November 24, 2004]
     
    16861688version 1.2.16beta2 [January 16, 2007]
    16871689  Revised scripts/CMakeLists.txt
    1688  
     1690
    16891691version 1.0.24, 1.2.16 [January 31, 2007]
    16901692  No changes.
    1691  
     1693
    16921694version 1.2.17beta1 [March 6, 2007]
    16931695  Revised scripts/CMakeLists.txt to install both shared and static libraries.
    16941696  Deleted a redundant line from pngset.c.
    1695  
     1697
    16961698version 1.2.17beta2 [April 26, 2007]
    16971699  Relocated misplaced test for png_ptr == NULL in pngpread.c
     
    17141716    can be free'ed in case of error.  Revised unknown chunk handling in
    17151717    pngrutil.c and pngpread.c to use this structure.
    1716  
     1718
    17171719version 1.2.17rc3 [May 8, 2007]
    17181720  Revised symbol-handling in configure script.
     
    17571759
    17581760version 1.2.19beta7 [May 22, 2007]
    1759   Squelched png_squelch_warnings() in pnggccrd.c and added an
    1760     #ifdef PNG_MMX_CODE_SUPPORTED block around the declarations that caused
    1761     the warnings that png_squelch_warnings was squelching.
     1761  Squelched png_squelch_warnings() in pnggccrd.c and added
     1762    an #ifdef PNG_MMX_CODE_SUPPORTED/#endif block around the declarations
     1763    that caused the warnings that png_squelch_warnings was squelching.
    17621764
    17631765version 1.2.19beta8 [May 22, 2007]
     
    21082110    unknown chunks.
    21092111  Added more information about png_set_keep_unknown_chunks() to the
    2110     documetation.
     2112    documentation.
    21112113  Reject tRNS chunk with out-of-range samples instead of masking off
    21122114    the invalid high bits as done in since libpng-1.2.19beta5.
     
    21282130
    21292131version 1.2.27beta05 [April 19, 2008]
    2130   Added MAINTEINERCLEANFILES variable to Makefile.am
     2132  Added MAINTAINERCLEANFILES variable to Makefile.am
    21312133
    21322134version 1.2.27beta06 [April 21, 2008]
     
    21572159  Changed $(ECHO) to echo in Makefile.am and Makefile.in
    21582160  Updated all configure files to autoconf-2.62
    2159   #ifdef out pnggcrd.c code if using MSC_VER
     2161  Comment out pnggcrd.c code with #ifdef/#endif if using MSC_VER
    21602162
    21612163version 1.2.29rc01 [May 4, 2008]
     
    21632165
    21642166version 1.0.35 and 1.2.29 [May 8, 2008]
     2167  No changes.
     2168
     2169version 1.0.37 [May 9, 2008]
     2170  Updated Makefile.in and configure (omitted version 1.0.36).
     2171
     2172version 1.2.30beta01 [May 29, 2008]
     2173  Updated libpng.pc-configure.in and libpng-config.in per debian bug reports.
     2174
     2175version 1.2.30beta02 [June 25, 2008]
     2176  Restored png_flush(png_ptr) at the end of png_write_end(), that was
     2177    removed from libpng-1.0.9beta03.
     2178
     2179version 1.2.30beta03 [July 6, 2008]
     2180  Merged some cosmetic whitespace changes from libpng-1.4.0beta19.
     2181  Inline call of png_get_uint_32() in png_get_uint_31(), as in 1.4.0beta19.
     2182  Added demo of decoding vpAg and sTER chunks to pngtest.c, from 1.4.0beta19.
     2183  Changed PNGMAJ from 0 to 12 in makefile.darwin, which does not like 0.
     2184  Added new private function png_read_chunk_header() from 1.4.0beta19.
     2185  Merge reading of chunk length and chunk type into a single 8-byte read.
     2186  Merge writing of chunk length and chunk type into a single 8-byte write.
     2187
     2188version 1.2.30beta04 [July 10, 2008]
     2189  Merged more cosmetic whitespace changes from libpng-1.4.0beta19.
     2190
     2191version 1.0.38rc01, 1.2.30rc01 [July 18, 2008]
     2192  No changes.
     2193
     2194version 1.0.38rc02, 1.2.30rc02 [July 21, 2008]
     2195  Moved local array "chunkdata" from pngrutil.c to the png_struct, so
     2196    it will be freed by png_read_destroy() in case of a read error (Kurt
     2197    Christensen).
     2198
     2199version 1.0.38rc03, 1.2.30rc03 [July 21, 2008]
     2200  Changed "purpose" and "buffer" to png_ptr->chunkdata to avoid memory leaking.
     2201
     2202version 1.0.38rc04, 1.2.30rc04 [July 22, 2008]
     2203  Changed "chunkdata = NULL" to "png_ptr->chunkdata = NULL" several places in
     2204    png_decompress_chunk().
     2205
     2206version 1.0.38rc05, 1.2.30rc05 [July 25, 2008]
     2207  Changed all remaining "chunkdata" to "png_ptr->chunkdata" in
     2208    png_decompress_chunk() and remove chunkdata from parameter list.
     2209  Put a call to png_check_chunk_name() in png_read_chunk_header().
     2210  Revised png_check_chunk_name() to reject a name with a lowercase 3rd byte.
     2211  Removed two calls to png_check_chunk_name() occuring later in the process.
     2212
     2213version 1.0.38rc06, 1.2.30rc06 [July 29, 2008]
     2214  Added a call to png_check_chunk_name() in pngpread.c
     2215  Reverted png_check_chunk_name() to accept a name with a lowercase 3rd byte.
     2216
     2217version 1.0.38r07, 1.2.30r07 [August 2, 2008]
     2218  Changed "-Wall" to "-W -Wall" in the CFLAGS in all makefiles (Cosmin Truta)
     2219  Declared png_ptr "volatile" in pngread.c and pngwrite.c to avoid warnings.
     2220  Added code in pngset.c to quiet compiler warnings.
     2221  Updated contrib/visupng/cexcept.h to version 2.0.1
     2222  Relocated a misplaced "#endif /* PNG_NO_WRITE_FILTER */" in pngwutil.c
     2223
     2224version 1.0.38r08, 1.2.30r08 [August 2, 2008]
     2225  Enclose "volatile" declarations in #ifdef PNG_SETJMP_SUPPORTED (Cosmin).
     2226
     2227version 1.0.38, 1.2.30 [August 14, 2008]
     2228  No changes.
     2229
     2230version 1.2.31rc01 [August 19, 2008]
     2231  Removed extra crc check at the end of png_handle_cHRM().  Bug introduced
     2232    in libpng-1.2.30beta03 (Heiko Nitzsche).
     2233
     2234version 1.2.31rc02 [August 19, 2008]
     2235  Added PNG_WRITE_FLUSH_SUPPORTED block around new png_flush() call.
     2236
     2237version 1.2.31rc03 [August 19, 2008]
     2238  Added PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED block, off by default, around
     2239    new png_flush().
     2240
     2241version 1.0.39, 1.2.31 [August 21, 2008]
     2242  No changes.
     2243
     2244version 1.2.32beta01 [September 6, 2008]
     2245  Shortened tIME_string to 29 bytes in pngtest.c (bug introduced in
     2246    libpng-1.2.22).
     2247  Fixed off-by-one error introduced in png_push_read_zTXt() function in
     2248    libpng-1.2.30beta04/pngpread.c (Harald van Dijk)
     2249  These bugs have been given the vulnerability id CVE-2008-3964.
     2250
     2251version 1.0.40, 1.2.32 [September 18, 2008]
     2252  No changes.
     2253
     2254version 1.2.33beta01 [October 6, 2008]
     2255  Revised makefile.darwin to fix shared library numbering.
     2256  Change png_set_gray_1_2_4_to_8() to png_set_expand_gray_1_2_4_to_8()
     2257    in example.c (debian bug report)
     2258
     2259version 1.2.33rc01 [October 15, 2008]
     2260  No changes.
     2261
     2262version 1.0.41rc01, version 1.2.33rc02 [October 23, 2008]
     2263  Changed remaining "key" to "png_ptr->chunkdata" in png_handle_tEXt()
     2264    to avoid memory leak after memory failure while reading tEXt chunk.`
     2265
     2266version 1.2.33 [October 31, 2008]
     2267  No changes.
     2268
     2269version 1.2.34beta01 [November 27, 2008]
     2270  Revised png_warning() to write its message on standard output by default
     2271    when warning_fn is NULL. This was the behavior prior to libpng-1.2.9beta9.
     2272  Fixed string vs pointer-to-string error in png_check_keyword().
     2273  Added png_check_cHRM_fixed() in png.c and moved checking from pngget.c,
     2274    pngrutil.c, and pngwrite.c, and eliminated floating point cHRM checking.
     2275  Added check for zero-area RGB cHRM triangle in png_check_cHRM_fixed().
     2276  In png_check_cHRM_fixed(), ensure white_y is > 0, and removed redundant
     2277    check for all-zero coordinates that is detected by the triangle check.
     2278  Revised png_warning() to write its message on standard output by default
     2279    when warning_fn is NULL.
     2280
     2281version 1.2.34beta02 [November 28, 2008]
     2282  Corrected off-by-one error in bKGD validity check in png_write_bKGD()
     2283    and in png_handle_bKGD().
     2284
     2285version 1.2.34beta03 [December 1, 2008]
     2286  Revised bKGD validity check to use >= x instead of > x + 1
     2287  Merged with png_debug from libpng-1.4.0 to remove newlines.
     2288
     2289version 1.2.34beta04 [December 2, 2008]
     2290  More merging with png_debug from libpng-1.4.0 to remove newlines.
     2291
     2292version 1.2.34beta05 [December 5, 2008]
     2293  Removed redundant check for key==NULL before calling png_check_keyword()
     2294    to ensure that new_key gets initialized and removed extra warning
     2295    (Arvan Pritchard).
     2296
     2297version 1.2.34beta06 [December 9, 2008]
     2298  In png_write_png(), respect the placement of the filler bytes in an earlier
     2299    call to png_set_filler() (Jim Barry).
     2300
     2301version 1.2.34beta07 [December 9, 2008]
     2302  Undid previous change and added PNG_TRANSFORM_STRIP_FILLER_BEFORE and
     2303    PNG_TRANSFORM_STRIP_FILLER_AFTER conditionals and deprecated
     2304    PNG_TRANSFORM_STRIP_FILLER (Jim Barry).
     2305
     2306version 1.0.42rc01, 1.2.34rc01 [December 11, 2008]
     2307  No changes.
     2308
     2309version 1.0.42, 1.2.34 [December 18, 2008]
     2310  No changes.
     2311
     2312version 1.2.35beta01 [February 4, 2009]
     2313  Zero out some arrays of pointers after png_malloc(). (Tavis Ormandy)
     2314
     2315version 1.2.35beta02 [February 4, 2009]
     2316  Zero out more arrays of pointers after png_malloc().
     2317
     2318version 1.2.35beta03 [February 5, 2009]
     2319  Use png_memset() instead of a loop to intialize pointers.  We realize
     2320    this will not work on platforms where the NULL pointer is not all zeroes.
     2321
     2322version 1.2.35rc01 [February 11, 2009]
     2323  No changes.
     2324
     2325version 1.2.35rc02 [February 12, 2009]
     2326  Fix typo in new png_memset call in pngset.c (png_color should be png_charp)
     2327
     2328version 1.0.43 and 1.2.35 [February 14, 2009]
     2329  No changes.
     2330
     2331version 1.2.36beta01 [February 28, 2009]
     2332  Revised comments in png_set_read_fn() and png_set_write_fn().
     2333  Revised order of #ifdef's and indentation in png_debug definitions of png.h
     2334    bug introduced in libpng-1.2.34.
     2335
     2336version 1.2.36beta02 [March 21, 2009]
     2337  Use png_memset() after png_malloc() of big_row_buf when reading an
     2338    interlaced file, to avoid a possible UMR.
     2339  Undid recent revision of PNG_NO_STDIO version of png_write_flush().  Users
     2340    having trouble with fflush() can build with PNG_NO_WRITE_FLUSH defined.
     2341  Revised libpng*.txt documentation about use of png_write_flush().
     2342  Removed fflush() from pngtest.c.
     2343  Added "#define PNG_NO_WRITE_FLUSH" to contrib/pngminim/encoder/pngusr.h
     2344
     2345version 1.2.36beta03 [March 27, 2009]
     2346  Relocated misplaced PNG_1_0_X define in png.h that caused the prototype
     2347    for png_set_strip_error_numbers() to be omitted from PNG_NO_ASSEMBLER_CODE
     2348    builds.  This bug was introduced in libpng-1.2.15beta4.
     2349  Added a section on differences between 1.0.x and 1.2.x to libpng.3/libpng.txt
     2350
     2351version 1.2.36beta04 [April 5, 2009]
     2352  Fixed potential memory leak of "new_name" in png_write_iCCP() (Ralph Giles)
     2353
     2354version 1.2.36beta05 [April 24, 2009]
     2355  Added "ifndef PNG_SKIP_SETJMP_CHECK" block in pngconf.h to allow
     2356    application code writers to bypass the check for multiple inclusion
     2357    of setjmp.h when they know that it is safe to ignore the situation.
     2358  Made some cosmetic changes to whitespace in pngtest output.
     2359  Renamed "user_chunk_data" to "my_user_chunk_data" in pngtest.c to suppress
     2360    "shadowed declaration" warning from gcc-4.3.3.
     2361  Renamed "gamma" to "png_gamma" in pngset.c to avoid "shadowed declaration"
     2362    warning about a global "gamma" variable in math.h on some platforms.
     2363
     2364version 1.2.36rc01 [April 30, 2009]
     2365  No changes.
     2366
     2367version 1.0.44 and 1.2.36 [May 7, 2009]
     2368  No changes.
     2369
     2370version 1.2.37beta01 [May 14, 2009]
     2371  Fixed inconsistency in pngrutil.c, introduced in libpng-1.2.36.  The
     2372    memset() was using "png_ptr->rowbytes" instead of "row_bytes", which
     2373    the corresponding png_malloc() uses (Joe Drew).
     2374  Clarified usage of sig_bit versus sig_bit_p in example.c (Vincent Torri)
     2375  Updated some of the makefiles in the scripts directory (merged with
     2376    those in libpng-1.4.0beta57).
     2377
     2378version 1.2.37beta02 [May 19, 2009]
     2379  Fixed typo in libpng documentation (FILTER_AVE should be FILTER_AVG)
     2380  Relocated misplaced #endif in pngwrite.c, sCAL chunk handler.
     2381  Conditionally compile png_read_finish_row() which is not used by
     2382    progressive readers.
     2383  Added contrib/pngminim/preader to demonstrate building minimal progressive
     2384    decoder, based on contrib/gregbook with embedded libpng and zlib.
     2385
     2386version 1.2.37beta03 [May 20, 2009]
     2387  In contrib/pngminim/*, renamed "makefile.std" to "makefile", since there
     2388    is only one makefile in those directories, and revised the README files
     2389    accordingly.
     2390  Reformated sources in libpng style (3-space indentation, comment format)
     2391
     2392version 1.2.37rc01 [May 27, 2009]
     2393  No changes.
     2394
     2395versions 1.2.37 and 1.0.45 [June 4, 2009]
     2396  Reformatted several remaining "else statement;" and "if () statement;" into
     2397    two lines.
     2398  Added "#define PNG_NO_WRITE_SWAP" to contrib/pngminim/encoder/pngusr.h
     2399    and "define PNG_NO_READ_SWAP" to decoder/pngusr.h and preader/pngusr.h
     2400  Added sections about the git repository and our coding style to the
     2401    documentation (merged from libpng-1.4.0beta62)
     2402  Added a section to the libpng documentation about using png_get_io_ptr()
     2403    in configure scripts to detect the presence of libpng.
     2404
     2405version 1.2.38beta01 [June 17, 2009]
     2406  Revised libpng*.txt and libpng.3 to mention calling png_set_IHDR()
     2407    multiple times and to specify the sample order in the tRNS chunk,
     2408    because the ISO PNG specification has a typo in the tRNS table.
     2409  Changed several PNG_UNKNOWN_CHUNK_SUPPORTED to
     2410    PNG_HANDLE_AS_UNKNOWN_SUPPORTED, to make the png_set_keep mechanism
     2411    available for ignoring known chunks even when not saving unknown chunks.
     2412  Adopted preference for consistent use of "#ifdef" and "#ifndef" versus
     2413    "#if defined()" and "if !defined()" where possible.
     2414  Added PNG_NO_HANDLE_AS_UNKNOWN in the PNG_LEGACY_SUPPORTED block of
     2415    pngconf.h, and moved the various unknown chunk macro definitions
     2416    outside of the PNG_READ|WRITE_ANCILLARY_CHUNK_SUPPORTED blocks.
     2417
     2418version 1.0.46 [June 18, 2009]
     2419  Removed some editing cruft from scripts/libpng.pc.in and some makefiles.
     2420
     2421version 1.2.38rc01 [June 24, 2009]
     2422  No changes.
     2423
     2424version 1.2.38rc02 [June 29, 2009]
     2425  Added a reference to the libpng license in each source file.
     2426
     2427version 1.2.38rc03 [July 11, 2009]
     2428  Revised references to the libpng license in pngconf.h and contrib/visupng
     2429    source files.
     2430  Rebuilt configure scripts with autoconf-2.63.
     2431
     2432version 1.0.47 and 1.2.38 [July 16, 2009]
     2433  No changes.
     2434
     2435version 1.2.39beta01 [July 25, 2009]
     2436  Added a prototype for png_64bit_product() in png.c
     2437
     2438version 1.2.39beta02 [July 27, 2009]
     2439  Avoid a possible NULL dereference in debug build, in png_set_text_2().
     2440    (bug introduced in libpng-0.95, discovered by Evan Rouault)
     2441
     2442version 1.2.39beta03 [July 29, 2009]
     2443  Relocated new png_64_bit_product() prototype into png.h
     2444  Expanded the information about prototypes in the libpng style section of
     2445    the documentation.
     2446  Rebuilt configure scripts with autoconf-2.64.
     2447
     2448version 1.2.39beta04 [August 1, 2009]
     2449  Replaced *.tar.lzma with *.txz in distribution.  Get the xz codec
     2450    from <http://tukaani.org/xz>.
     2451
     2452version 1.2.39beta05 [August 1, 2009]
     2453  Reject attempt to write iCCP chunk with negative embedded profile length
     2454    (JD Chen)
     2455
     2456version 1.2.39c01 [August 6, 2009]
     2457  No changes.
     2458
     2459version 1.2.39 and 1.0.48 [August 13, 2009]
     2460  No changes.
     2461
     2462version 1.2.40beta01 [August 20, 2009]
     2463  Removed an extra png_debug() recently added to png_write_find_filter().
     2464  Fixed incorrect #ifdef in pngset.c regarding unknown chunk support.
     2465
     2466version 1.2.40rc01 [September 2, 2009]
     2467  Various bugfixes and improvements to CMakeLists.txt (Philip Lowman)
     2468
     2469version 1.2.40 and 1.0.49 [September 10, 2009]
    21652470  No changes.
    21662471
     
    21722477
    21732478Glenn R-P
     2479*/
  • trunk/src/3rdparty/libpng/INSTALL

    r2 r561  
    11
    2 Installing libpng version 1.2.29 - May 8, 2008
     2Installing libpng version 1.2.40 - September 10, 2009
    33
    44On Unix/Linux and similar systems, you can simply type
     
    4545
    4646You can rename the directories that you downloaded (they
    47 might be called "libpng-1.2.29" or "lpng109" and "zlib-1.2.1"
     47might be called "libpng-1.2.40" or "lpng109" and "zlib-1.2.1"
    4848or "zlib121") so that you have directories called "zlib" and "libpng".
    4949
     
    102102 makefile.std      =>  Generic UNIX makefile (cc, creates static libpng.a)
    103103 makefile.elf      =>  Linux/ELF makefile symbol versioning,
    104                        gcc, creates libpng12.so.0.1.2.29)
     104                       gcc, creates libpng12.so.0.1.2.40)
    105105 makefile.linux    =>  Linux/ELF makefile
    106                        (gcc, creates libpng12.so.0.1.2.29)
     106                       (gcc, creates libpng12.so.0.1.2.40)
    107107 makefile.gcc      =>  Generic makefile (gcc, creates static libpng.a)
    108108 makefile.knr      =>  Archaic UNIX Makefile that converts files with
     
    126126 makefile.sgi      =>  Silicon Graphics IRIX makefile (cc, creates static lib)
    127127 makefile.sggcc    =>  Silicon Graphics (gcc,
    128                        creates libpng12.so.0.1.2.29)
     128                       creates libpng12.so.0.1.2.40)
    129129 makefile.sunos    =>  Sun makefile
    130130 makefile.solaris  =>  Solaris 2.X makefile (gcc,
    131                        creates libpng12.so.0.1.2.29)
     131                       creates libpng12.so.0.1.2.40)
    132132 makefile.solaris-x86 =>  Solaris/intelMMX 2.X makefile (gcc,
    133                        creates libpng12.so.0.1.2.29)
     133                       creates libpng12.so.0.1.2.40)
    134134 makefile.so9      =>  Solaris 9 makefile (gcc,
    135                        creates libpng12.so.0.1.2.29)
     135                       creates libpng12.so.0.1.2.40)
    136136 makefile.32sunu   =>  Sun Ultra 32-bit makefile
    137137 makefile.64sunu   =>  Sun Ultra 64-bit makefile
  • trunk/src/3rdparty/libpng/KNOWNBUG

    r2 r561  
    11
    2 Known bugs in libpng version 1.2.29
     2Known bugs in libpng version 1.2.40
    33
    441. February 23, 2006: The custom makefiles don't build libpng with -lz.
  • trunk/src/3rdparty/libpng/LICENSE

    r2 r561  
    99this sentence.
    1010
    11 libpng versions 1.2.6, August 15, 2004, through 1.2.29, May 8, 2008, are
    12 Copyright (c) 2004, 2006-2008 Glenn Randers-Pehrson, and are
     11This code is released under the libpng license.
     12
     13libpng versions 1.2.6, August 15, 2004, through 1.2.40, September 10, 2009, are
     14Copyright (c) 2004, 2006-2009 Glenn Randers-Pehrson, and are
    1315distributed according to the same disclaimer and license as libpng-1.2.5
    1416with the following individual added to the list of Contributing Authors
     
    107109Glenn Randers-Pehrson
    108110glennrp at users.sourceforge.net
    109 May 8, 2008
     111September 10, 2009
  • trunk/src/3rdparty/libpng/README

    r2 r561  
    1 README for libpng version 1.2.29 - May 8, 2008 (shared library 12.0)
     1README for libpng version 1.2.40 - September 10, 2009 (shared library 12.0)
    22See the note about version numbers near the top of png.h
    33
     
    77libpng-*.tar.lzma, or libpng-*.tar.bz2 if you want UNIX-style line
    88endings in the text files, or lpng*.7z or lpng*.zip if you want DOS-style
    9 line endings.
     9line endings.  You can get UNIX-style line endings from the *.zip file
     10by using "unzip -a" but there seems to be no simple way to recover
     11UNIX-style line endings from the *.7z file.  The *.tar.lzma file is
     12recommended for *NIX users instead.
    1013
    1114Version 0.89 was the first official release of libpng.  Don't let the
     
    5659
    5760The changes made to the library, and bugs fixed are based on discussions
    58 on the PNG-implement mailing list
     61on the png-mng-implement mailing list
    5962and not on material submitted privately to Guy, Andreas, or Glenn.  They will
    6063forward any good suggestions to the list.
     
    112115You can't reach Guy, the original libpng author, at the addresses
    113116given in previous versions of this document.  He and Andreas will read mail
    114 addressed to the png-implement list, however.
     117addressed to the png-mng-implement list, however.
    115118
    116119Please do not send general questions about PNG.  Send them to
     
    119122On the other hand,
    120123please do not send libpng questions to that address, send them to me
    121 or to the png-implement list.  I'll
     124or to the png-mng-implement list.  I'll
    122125get them in the end anyway.  If you have a question about something
    123126in the PNG specification that is related to using libpng, send it
     
    192195       makefile.std     =>  Generic UNIX makefile (cc, creates static libpng.a)
    193196       makefile.elf     =>  Linux/ELF makefile symbol versioning,
    194                             gcc, creates libpng12.so.0.1.2.29)
     197                            gcc, creates libpng12.so.0.1.2.40)
    195198       makefile.linux   =>  Linux/ELF makefile
    196                             (gcc, creates libpng12.so.0.1.2.29)
     199                            (gcc, creates libpng12.so.0.1.2.40)
    197200       makefile.gcmmx   =>  Linux/ELF makefile
    198                             (gcc, creates libpng12.so.0.1.2.29,
     201                            (gcc, creates libpng12.so.0.1.2.40,
    199202                            uses assembler code tuned for Intel MMX platform)
    200203       makefile.gcc     =>  Generic makefile (gcc, creates static libpng.a)
     
    218221       makefile.sgi     =>  Silicon Graphics IRIX (cc, creates static lib)
    219222       makefile.sggcc   =>  Silicon Graphics
    220                             (gcc, creates libpng12.so.0.1.2.29)
     223                            (gcc, creates libpng12.so.0.1.2.40)
    221224       makefile.sunos   =>  Sun makefile
    222225       makefile.solaris =>  Solaris 2.X makefile
    223                             (gcc, creates libpng12.so.0.1.2.29)
     226                            (gcc, creates libpng12.so.0.1.2.40)
    224227       makefile.so9     =>  Solaris 9 makefile
    225                             (gcc, creates libpng12.so.0.1.2.29)
     228                            (gcc, creates libpng12.so.0.1.2.40)
    226229       makefile.32sunu  =>  Sun Ultra 32-bit makefile
    227230       makefile.64sunu  =>  Sun Ultra 64-bit makefile
  • trunk/src/3rdparty/libpng/TODO

    r2 r561  
    2323  background and doing rgb-to-gray transformation.
    2424Investigate pre-incremented loop counters and other loop constructions.
     25Add interpolated method of handling interlacing.
  • trunk/src/3rdparty/libpng/Y2KINFO

    r2 r561  
    22   =========================
    33
    4       May 8, 2008
     4      September 10, 2009
    55
    66      Since the PNG Development group is an ad-hoc body, we can't make
     
    88
    99      This is your unofficial assurance that libpng from version 0.71 and
    10       upward through 1.2.29 are Y2K compliant.  It is my belief that earlier
     10      upward through 1.2.40 are Y2K compliant.  It is my belief that earlier
    1111      versions were also Y2K compliant.
    1212
  • trunk/src/3rdparty/libpng/configure

    r2 r561  
    22echo "
    33  There is no \"configure\" script in this distribution of
    4   libpng-1.2.29.
     4  libpng-1.2.40.
    55
    66  Instead, please copy the appropriate makefile for your system from the
     
    99  Update, July 2004: you can get a \"configure\" based distribution
    1010  from the libpng distribution sites.  Download the file
    11   libpng-1.2.29.tar.gz, libpng-1.2.29.tar.lzma, or libpng-1.2.29.tar.bz2
     11  libpng-1.2.40.tar.gz, libpng-1.2.40.tar.lzma, or libpng-1.2.40.tar.bz2
    1212"
    1313
  • trunk/src/3rdparty/libpng/example.c

    r2 r561  
    33
    44/* example.c - an example of using libpng
    5  * Last changed in libpng 1.2.1 December 7, 2001.
     5 * Last changed in libpng 1.2.37 [June 4, 2009]
    66 * This file has been placed in the public domain by the authors.
    7  * Maintained 1998-2007 Glenn Randers-Pehrson
     7 * Maintained 1998-2009 Glenn Randers-Pehrson
    88 * Maintained 1996, 1997 Andreas Dilger)
    99 * Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     
    9292   if ((fp = fopen(file_name, "rb")) == NULL)
    9393      return (ERROR);
     94
    9495#else no_open_file /* prototype 2 */
    95 void read_png(FILE *fp, unsigned int sig_read)  /* file is already open */
     96void read_png(FILE *fp, unsigned int sig_read)  /* File is already open */
    9697{
    9798   png_structp png_ptr;
     
    99100   png_uint_32 width, height;
    100101   int bit_depth, color_type, interlace_type;
    101 #endif no_open_file /* only use one prototype! */
     102#endif no_open_file /* Only use one prototype! */
    102103
    103104   /* Create and initialize the png_struct with the desired error handler
     
    165166    */
    166167   png_read_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL);
     168
    167169#else
    168170   /* OK, you're doing it the hard way, with the lower-level functions */
     
    176178       &interlace_type, int_p_NULL, int_p_NULL);
    177179
    178 /* Set up the data transformations you want.  Note that these are all
    179  * optional.  Only call them if you want/need them.  Many of the
    180  * transformations only work on specific types of images, and many
    181  * are mutually exclusive.
    182  */
    183 
    184    /* tell libpng to strip 16 bit/color files down to 8 bits/color */
     180   /* Set up the data transformations you want.  Note that these are all
     181    * optional.  Only call them if you want/need them.  Many of the
     182    * transformations only work on specific types of images, and many
     183    * are mutually exclusive.
     184    */
     185
     186   /* Tell libpng to strip 16 bit/color files down to 8 bits/color */
    185187   png_set_strip_16(png_ptr);
    186188
     
    205207   /* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */
    206208   if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
    207       png_set_gray_1_2_4_to_8(png_ptr);
     209      png_set_expand_gray_1_2_4_to_8(png_ptr);
    208210
    209211   /* Expand paletted or RGB images with transparency to full alpha channels
     
    229231                         PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
    230232
    231    /* Some suggestions as to how to get a screen gamma value */
    232 
    233    /* Note that screen gamma is the display_exponent, which includes
    234     * the CRT_exponent and any correction for viewing conditions */
     233   /* Some suggestions as to how to get a screen gamma value
     234    *
     235    * Note that screen gamma is the display_exponent, which includes
     236    * the CRT_exponent and any correction for viewing conditions
     237    */
    235238   if (/* We have a user-defined screen gamma value */)
    236239   {
     
    245248   else
    246249   {
    247       screen_gamma = 2.2;  /* A good guess for a PC monitors in a dimly
     250      screen_gamma = 2.2;  /* A good guess for a PC monitor in a dimly
    248251                              lit room */
    249252      screen_gamma = 1.7 or 1.0;  /* A good guess for Mac systems */
     
    278281
    279282      /* This reduces the image to the application supplied palette */
    280       if (/* we have our own palette */)
     283      if (/* We have our own palette */)
    281284      {
    282285         /* An array of colors to which the image should be dithered */
     
    298301   }
    299302
    300    /* invert monochrome files to have 0 as white and 1 as black */
     303   /* Invert monochrome files to have 0 as white and 1 as black */
    301304   png_set_invert_mono(png_ptr);
    302305
     
    307310   if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT))
    308311   {
    309       png_color_8p sig_bit;
    310 
    311       png_get_sBIT(png_ptr, info_ptr, &sig_bit);
    312       png_set_shift(png_ptr, sig_bit);
    313    }
    314 
    315    /* flip the RGB pixels to BGR (or RGBA to BGRA) */
     312      png_color_8p sig_bit_p;
     313
     314      png_get_sBIT(png_ptr, info_ptr, &sig_bit_p);
     315      png_set_shift(png_ptr, sig_bit_p);
     316   }
     317
     318   /* Flip the RGB pixels to BGR (or RGBA to BGRA) */
    316319   if (color_type & PNG_COLOR_MASK_COLOR)
    317320      png_set_bgr(png_ptr);
    318321
    319    /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
     322   /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
    320323   png_set_swap_alpha(png_ptr);
    321324
    322    /* swap bytes of 16 bit files to least significant byte first */
     325   /* Swap bytes of 16 bit files to least significant byte first */
    323326   png_set_swap(png_ptr);
    324327
     
    343346   png_bytep row_pointers[height];
    344347
     348   /* Clear the pointer array */
    345349   for (row = 0; row < height; row++)
    346    {
     350      row_pointers[row] = NULL;
     351
     352   for (row = 0; row < height; row++)
    347353      row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr,
    348354         info_ptr));
    349    }
    350355
    351356   /* Now it's time to read the image.  One of these methods is REQUIRED */
     
    373378         png_read_rows(png_ptr, png_bytepp_NULL, &row_pointers[y],
    374379            number_of_rows);
    375 #endif no_sparkle /* use only one of these two methods */
     380#endif no_sparkle /* Use only one of these two methods */
    376381      }
    377382
    378       /* if you want to display the image after every pass, do
    379          so here */
    380 #endif no_single /* use only one of these two methods */
    381    }
    382 #endif no_entire /* use only one of these two methods */
    383 
    384    /* read rest of file, and get additional chunks in info_ptr - REQUIRED */
     383      /* If you want to display the image after every pass, do so here */
     384#endif no_single /* Use only one of these two methods */
     385   }
     386#endif no_entire /* Use only one of these two methods */
     387
     388   /* Read rest of file, and get additional chunks in info_ptr - REQUIRED */
    385389   png_read_end(png_ptr, info_ptr);
    386390#endif hilevel
     
    388392   /* At this point you have read the entire image */
    389393
    390    /* clean up after the read, and free any memory allocated - REQUIRED */
     394   /* Clean up after the read, and free any memory allocated - REQUIRED */
    391395   png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
    392396
    393    /* close the file */
     397   /* Close the file */
    394398   fclose(fp);
    395399
    396    /* that's it */
     400   /* That's it */
    397401   return (OK);
    398402}
    399403
    400 /* progressively read a file */
     404/* Progressively read a file */
    401405
    402406int
     
    463467   /* This one's new also.  Simply give it chunks of data as
    464468    * they arrive from the data stream (in order, of course).
    465     * On Segmented machines, don't give it any more than 64K.
     469    * On segmented machines, don't give it any more than 64K.
    466470    * The library seems to run fine with sizes of 4K, although
    467471    * you can give it much less if necessary (I assume you can
     
    477481info_callback(png_structp png_ptr, png_infop info)
    478482{
    479 /* do any setup here, including setting any of the transformations
    480  * mentioned in the Reading PNG files section.  For now, you _must_
    481  * call either png_start_read_image() or png_read_update_info()
    482  * after all the transformations are set (even if you don't set
    483  * any).  You may start getting rows before png_process_data()
    484  * returns, so this is your last chance to prepare for that.
    485  */
     483   /* Do any setup here, including setting any of the transformations
     484    * mentioned in the Reading PNG files section.  For now, you _must_
     485    * call either png_start_read_image() or png_read_update_info()
     486    * after all the transformations are set (even if you don't set
     487    * any).  You may start getting rows before png_process_data()
     488    * returns, so this is your last chance to prepare for that.
     489    */
    486490}
    487491
     
    489493   png_uint_32 row_num, int pass)
    490494{
    491 /*
    492  * This function is called for every row in the image.  If the
    493  * image is interlaced, and you turned on the interlace handler,
    494  * this function will be called for every row in every pass.
    495  *
    496  * In this function you will receive a pointer to new row data from
    497  * libpng called new_row that is to replace a corresponding row (of
    498  * the same data format) in a buffer allocated by your application.
    499  *
    500  * The new row data pointer new_row may be NULL, indicating there is
    501  * no new data to be replaced (in cases of interlace loading).
    502  *
    503  * If new_row is not NULL then you need to call
    504  * png_progressive_combine_row() to replace the corresponding row as
    505  * shown below:
    506  */
     495   /*
     496    * This function is called for every row in the image.  If the
     497    * image is interlaced, and you turned on the interlace handler,
     498    * this function will be called for every row in every pass.
     499    *
     500    * In this function you will receive a pointer to new row data from
     501    * libpng called new_row that is to replace a corresponding row (of
     502    * the same data format) in a buffer allocated by your application.
     503    *
     504    * The new row data pointer "new_row" may be NULL, indicating there is
     505    * no new data to be replaced (in cases of interlace loading).
     506    *
     507    * If new_row is not NULL then you need to call
     508    * png_progressive_combine_row() to replace the corresponding row as
     509    * shown below:
     510    */
     511
    507512   /* Check if row_num is in bounds. */
    508    if((row_num >= 0) && (row_num < height))
     513   if ((row_num >= 0) && (row_num < height))
    509514   {
    510515     /* Get pointer to corresponding row in our
     
    516521      * data to the corresponding row data.
    517522      */
    518      if((old_row != NULL) && (new_row != NULL))
     523     if ((old_row != NULL) && (new_row != NULL))
    519524     png_progressive_combine_row(png_ptr, old_row, new_row);
    520525   }
    521 /*
    522  * The rows and passes are called in order, so you don't really
    523  * need the row_num and pass, but I'm supplying them because it
    524  * may make your life easier.
    525  *
    526  * For the non-NULL rows of interlaced images, you must call
    527  * png_progressive_combine_row() passing in the new row and the
    528  * old row, as demonstrated above.  You can call this function for
    529  * NULL rows (it will just return) and for non-interlaced images
    530  * (it just does the png_memcpy for you) if it will make the code
    531  * easier.  Thus, you can just do this for all cases:
    532  */
     526   /*
     527    * The rows and passes are called in order, so you don't really
     528    * need the row_num and pass, but I'm supplying them because it
     529    * may make your life easier.
     530    *
     531    * For the non-NULL rows of interlaced images, you must call
     532    * png_progressive_combine_row() passing in the new row and the
     533    * old row, as demonstrated above.  You can call this function for
     534    * NULL rows (it will just return) and for non-interlaced images
     535    * (it just does the png_memcpy for you) if it will make the code
     536    * easier.  Thus, you can just do this for all cases:
     537    */
    533538
    534539   png_progressive_combine_row(png_ptr, old_row, new_row);
    535540
    536 /* where old_row is what was displayed for previous rows.  Note
    537  * that the first pass (pass == 0 really) will completely cover
    538  * the old row, so the rows do not have to be initialized.  After
    539  * the first pass (and only for interlaced images), you will have
    540  * to pass the current row as new_row, and the function will combine
    541  * the old row and the new row.
    542  */
     541   /* where old_row is what was displayed for previous rows.  Note
     542    * that the first pass (pass == 0 really) will completely cover
     543    * the old row, so the rows do not have to be initialized.  After
     544    * the first pass (and only for interlaced images), you will have
     545    * to pass the current row as new_row, and the function will combine
     546    * the old row and the new row.
     547    */
    543548}
    544549
    545550end_callback(png_structp png_ptr, png_infop info)
    546551{
    547 /* this function is called when the whole image has been read,
    548  * including any chunks after the image (up to and including
    549  * the IEND).  You will usually have the same info chunk as you
    550  * had in the header, although some data may have been added
    551  * to the comments and time fields.
    552  *
    553  * Most people won't do much here, perhaps setting a flag that
    554  * marks the image as finished.
    555  */
     552   /* This function is called when the whole image has been read,
     553    * including any chunks after the image (up to and including
     554    * the IEND).  You will usually have the same info chunk as you
     555    * had in the header, although some data may have been added
     556    * to the comments and time fields.
     557    *
     558    * Most people won't do much here, perhaps setting a flag that
     559    * marks the image as finished.
     560    */
    556561}
    557562
    558 /* write a png file */
     563/* Write a png file */
    559564void write_png(char *file_name /* , ... other image information ... */)
    560565{
     
    564569   png_colorp palette;
    565570
    566    /* open the file */
     571   /* Open the file */
    567572   fp = fopen(file_name, "wb");
    568573   if (fp == NULL)
     
    598603   if (setjmp(png_jmpbuf(png_ptr)))
    599604   {
    600       /* If we get here, we had a problem reading the file */
     605      /* If we get here, we had a problem writing the file */
    601606      fclose(fp);
    602607      png_destroy_write_struct(&png_ptr, &info_ptr);
     
    605610
    606611   /* One of the following I/O initialization functions is REQUIRED */
     612
    607613#ifdef streams /* I/O initialization method 1 */
    608    /* set up the output control if you are using standard C streams */
     614   /* Set up the output control if you are using standard C streams */
    609615   png_init_io(png_ptr, fp);
     616
    610617#else no_streams /* I/O initialization method 2 */
    611    /* If you are using replacement read functions, instead of calling
    612     * png_init_io() here you would call */
     618   /* If you are using replacement write functions, instead of calling
     619    * png_init_io() here you would call
     620    */
    613621   png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn,
    614622      user_IO_flush_function);
    615623   /* where user_io_ptr is a structure you want available to the callbacks */
    616 #endif no_streams /* only use one initialization method */
     624#endif no_streams /* Only use one initialization method */
    617625
    618626#ifdef hilevel
    619627   /* This is the easy way.  Use it if you already have all the
    620     * image info living info in the structure.  You could "|" many
     628    * image info living in the structure.  You could "|" many
    621629    * PNG_TRANSFORM flags into the png_transforms integer here.
    622630    */
    623631   png_write_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL);
     632
    624633#else
    625634   /* This is the hard way */
     
    636645      PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
    637646
    638    /* set the palette if there is one.  REQUIRED for indexed-color images */
     647   /* Set the palette if there is one.  REQUIRED for indexed-color images */
    639648   palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH
    640              * png_sizeof (png_color));
    641    /* ... set palette colors ... */
     649             * png_sizeof(png_color));
     650   /* ... Set palette colors ... */
    642651   png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);
    643652   /* You must not free palette here, because png_set_PLTE only makes a link to
    644       the palette that you malloced.  Wait until you are about to destroy
    645       the png structure. */
    646 
    647    /* optional significant bit chunk */
    648    /* if we are dealing with a grayscale image then */
     653    * the palette that you malloced.  Wait until you are about to destroy
     654    * the png structure.
     655    */
     656
     657   /* Optional significant bit (sBIT) chunk */
     658   png_color_8 sig_bit;
     659   /* If we are dealing with a grayscale image then */
    649660   sig_bit.gray = true_bit_depth;
    650    /* otherwise, if we are dealing with a color image then */
     661   /* Otherwise, if we are dealing with a color image then */
    651662   sig_bit.red = true_red_bit_depth;
    652663   sig_bit.green = true_green_bit_depth;
    653664   sig_bit.blue = true_blue_bit_depth;
    654    /* if the image has an alpha channel then */
     665   /* If the image has an alpha channel then */
    655666   sig_bit.alpha = true_alpha_bit_depth;
    656    png_set_sBIT(png_ptr, info_ptr, sig_bit);
     667   png_set_sBIT(png_ptr, info_ptr, &sig_bit);
    657668
    658669
     
    679690   png_set_text(png_ptr, info_ptr, text_ptr, 3);
    680691
    681    /* other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs, */
    682    /* note that if sRGB is present the gAMA and cHRM chunks must be ignored
    683     * on read and must be written in accordance with the sRGB profile */
     692   /* Other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs */
     693
     694   /* Note that if sRGB is present the gAMA and cHRM chunks must be ignored
     695    * on read and, if your application chooses to write them, they must
     696    * be written in accordance with the sRGB profile
     697    */
    684698
    685699   /* Write the file header information.  REQUIRED */
     
    693707    *   png_write_info(png_ptr, info_ptr);
    694708    *
    695     * However, given the level of known- and unknown-chunk support in 1.1.0
     709    * However, given the level of known- and unknown-chunk support in 1.2.0
    696710    * and up, this should no longer be necessary.
    697711    */
     
    703717    */
    704718
    705    /* set up the transformations you want.  Note that these are
     719   /* Set up the transformations you want.  Note that these are
    706720    * all optional.  Only call them if you want them.
    707721    */
    708722
    709    /* invert monochrome pixels */
     723   /* Invert monochrome pixels */
    710724   png_set_invert_mono(png_ptr);
    711725
     
    715729   png_set_shift(png_ptr, &sig_bit);
    716730
    717    /* pack pixels into bytes */
     731   /* Pack pixels into bytes */
    718732   png_set_packing(png_ptr);
    719733
    720    /* swap location of alpha bytes from ARGB to RGBA */
     734   /* Swap location of alpha bytes from ARGB to RGBA */
    721735   png_set_swap_alpha(png_ptr);
    722736
     
    726740   png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
    727741
    728    /* flip BGR pixels to RGB */
     742   /* Flip BGR pixels to RGB */
    729743   png_set_bgr(png_ptr);
    730744
    731    /* swap bytes of 16-bit files to most significant byte first */
     745   /* Swap bytes of 16-bit files to most significant byte first */
    732746   png_set_swap(png_ptr);
    733747
    734    /* swap bits of 1, 2, 4 bit packed pixel formats */
     748   /* Swap bits of 1, 2, 4 bit packed pixel formats */
    735749   png_set_packswap(png_ptr);
    736750
    737    /* turn on interlace handling if you are not using png_write_image() */
     751   /* Turn on interlace handling if you are not using png_write_image() */
    738752   if (interlacing)
    739753      number_passes = png_set_interlace_handling(png_ptr);
     
    756770
    757771   /* One of the following output methods is REQUIRED */
    758 #ifdef entire /* write out the entire image data in one call */
     772
     773#ifdef entire /* Write out the entire image data in one call */
    759774   png_write_image(png_ptr, row_pointers);
    760775
    761    /* the other way to write the image - deal with interlacing */
    762 
    763 #else no_entire /* write out the image data by one or more scanlines */
     776   /* The other way to write the image - deal with interlacing */
     777
     778#else no_entire /* Write out the image data by one or more scanlines */
     779
    764780   /* The number of passes is either 1 for non-interlaced images,
    765781    * or 7 for interlaced images.
     
    772788      /* If you are only writing one row at a time, this works */
    773789      for (y = 0; y < height; y++)
    774       {
    775790         png_write_rows(png_ptr, &row_pointers[y], 1);
    776       }
    777    }
    778 #endif no_entire /* use only one output method */
     791   }
     792#endif no_entire /* Use only one output method */
    779793
    780794   /* You can write optional chunks like tEXt, zTXt, and tIME at the end
    781     * as well.  Shouldn't be necessary in 1.1.0 and up as all the public
     795    * as well.  Shouldn't be necessary in 1.2.0 and up as all the public
    782796    * chunks are supported and you can use png_set_unknown_chunks() to
    783797    * register unknown chunks into the info structure to be written out.
     
    789803
    790804   /* If you png_malloced a palette, free it here (don't free info_ptr->palette,
    791       as recommended in versions 1.0.5m and earlier of this example; if
    792       libpng mallocs info_ptr->palette, libpng will free it).  If you
    793       allocated it with malloc() instead of png_malloc(), use free() instead
    794       of png_free(). */
     805    * as recommended in versions 1.0.5m and earlier of this example; if
     806    * libpng mallocs info_ptr->palette, libpng will free it).  If you
     807    * allocated it with malloc() instead of png_malloc(), use free() instead
     808    * of png_free().
     809    */
    795810   png_free(png_ptr, palette);
    796    palette=NULL;
     811   palette = NULL;
    797812
    798813   /* Similarly, if you png_malloced any data that you passed in with
    799       png_set_something(), such as a hist or trans array, free it here,
    800       when you can be sure that libpng is through with it. */
     814    * png_set_something(), such as a hist or trans array, free it here,
     815    * when you can be sure that libpng is through with it.
     816    */
    801817   png_free(png_ptr, trans);
    802    trans=NULL;
    803 
    804    /* clean up after the write, and free any memory allocated */
     818   trans = NULL;
     819   /* Whenever you use png_free() it is a good idea to set the pointer to
     820    * NULL in case your application inadvertently tries to png_free() it
     821    * again.  When png_free() sees a NULL it returns without action, thus
     822    * avoiding the double-free security problem.
     823    */
     824
     825   /* Clean up after the write, and free any memory allocated */
    805826   png_destroy_write_struct(&png_ptr, &info_ptr);
    806827
    807    /* close the file */
     828   /* Close the file */
    808829   fclose(fp);
    809830
    810    /* that's it */
     831   /* That's it */
    811832   return (OK);
    812833}
  • trunk/src/3rdparty/libpng/libpng.3

    r2 r561  
    1 .TH LIBPNG 3 "May 8, 2008"
     1.TH LIBPNG 3 "September 10, 2009"
    22.SH NAME
    3 libpng \- Portable Network Graphics (PNG) Reference Library 1.2.29
     3libpng \- Portable Network Graphics (PNG) Reference Library 1.2.40
    44.SH SYNOPSIS
    5 \fB
    6 #include <png.h>\fP
     5\fI\fB
     6
     7\fB#include <png.h>\fP
     8
     9\fI\fB
    710
    811\fBpng_uint_32 png_access_version_number \fI(void\fP\fB);\fP
    912
     13\fI\fB
     14
    1015\fBint png_check_sig (png_bytep \fP\fIsig\fP\fB, int \fInum\fP\fB);\fP
    1116
     17\fI\fB
     18
    1219\fBvoid png_chunk_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP
    1320
     21\fI\fB
     22
    1423\fBvoid png_chunk_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP
    1524
     25\fI\fB
     26
    1627\fBvoid png_convert_from_struct_tm (png_timep \fP\fIptime\fP\fB, struct tm FAR * \fIttime\fP\fB);\fP
    1728
     29\fI\fB
     30
    1831\fBvoid png_convert_from_time_t (png_timep \fP\fIptime\fP\fB, time_t \fIttime\fP\fB);\fP
    1932
     33\fI\fB
     34
    2035\fBpng_charp png_convert_to_rfc1123 (png_structp \fP\fIpng_ptr\fP\fB, png_timep \fIptime\fP\fB);\fP
    2136
     37\fI\fB
     38
    2239\fBpng_infop png_create_info_struct (png_structp \fIpng_ptr\fP\fB);\fP
    2340
     41\fI\fB
     42
    2443\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
    2544
     45\fI\fB
     46
    2647\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
    2748
     49\fI\fB
     50
    2851\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
    2952
     53\fI\fB
     54
    3055\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
    3156
     57\fI\fB
     58
    3259\fBint png_debug(int \fP\fIlevel\fP\fB, png_const_charp \fImessage\fP\fB);\fP
    3360
     61\fI\fB
     62
    3463\fBint png_debug1(int \fP\fIlevel\fP\fB, png_const_charp \fP\fImessage\fP\fB, \fIp1\fP\fB);\fP
    3564
     65\fI\fB
     66
    3667\fBint png_debug2(int \fP\fIlevel\fP\fB, png_const_charp \fP\fImessage\fP\fB, \fP\fIp1\fP\fB, \fIp2\fP\fB);\fP
    3768
     69\fI\fB
     70
    3871\fBvoid png_destroy_info_struct (png_structp \fP\fIpng_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP
    3972
     73\fI\fB
     74
    4075\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
    4176
     77\fI\fB
     78
    4279\fBvoid png_destroy_write_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP
    4380
     81\fI\fB
     82
    4483\fBvoid png_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP
    4584
     85\fI\fB
     86
    4687\fBvoid png_free (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP
    4788
     89\fI\fB
     90
    4891\fBvoid png_free_chunk_list (png_structp \fIpng_ptr\fP\fB);\fP
    4992
     93\fI\fB
     94
    5095\fBvoid png_free_default(png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP
    5196
     97\fI\fB
     98
    5299\fBvoid png_free_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fInum\fP\fB);\fP
    53100
     101\fI\fB
     102
    54103\fBpng_byte png_get_bit_depth (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    55104
     105\fI\fB
     106
    56107\fBpng_uint_32 png_get_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fI*background\fP\fB);\fP
    57108
     109\fI\fB
     110
    58111\fBpng_byte png_get_channels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    59112
     113\fI\fB
     114
    60115\fBpng_uint_32 png_get_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_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
    61116
     117\fI\fB
     118
    62119\fBpng_uint_32 png_get_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_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
    63120
     121\fI\fB
     122
    64123\fBpng_byte png_get_color_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    65124
     125\fI\fB
     126
    66127\fBpng_byte png_get_compression_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    67128
     129\fI\fB
     130
    68131\fBpng_byte png_get_copyright (png_structp \fIpng_ptr\fP\fB);\fP
    69132
     133\fI\fB
     134
    70135\fBpng_voidp png_get_error_ptr (png_structp \fIpng_ptr\fP\fB);\fP
    71136
     137\fI\fB
     138
    72139\fBpng_byte png_get_filter_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    73140
     141\fI\fB
     142
    74143\fBpng_uint_32 png_get_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fI*file_gamma\fP\fB);\fP
    75144
     145\fI\fB
     146
    76147\fBpng_uint_32 png_get_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fI*int_file_gamma\fP\fB);\fP
    77148
     149\fI\fB
     150
    78151\fBpng_byte png_get_header_ver (png_structp \fIpng_ptr\fP\fB);\fP
    79152
     153\fI\fB
     154
    80155\fBpng_byte png_get_header_version (png_structp \fIpng_ptr\fP\fB);\fP
    81156
     157\fI\fB
     158
    82159\fBpng_uint_32 png_get_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fI*hist\fP\fB);\fP
    83160
     161\fI\fB
     162
    84163\fBpng_uint_32 png_get_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charpp \fP\fIname\fP\fB, int \fP\fI*compression_type\fP\fB, png_charpp \fP\fIprofile\fP\fB, png_uint_32 \fI*proflen\fP\fB);\fP
    85164
     165\fI\fB
     166
    86167\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
    87168
     169\fI\fB
     170
    88171\fBpng_uint_32 png_get_image_height (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    89172
     173\fI\fB
     174
    90175\fBpng_uint_32 png_get_image_width (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    91176
    92 \fB#if !defined(PNG_1_0_X) png_int_32 png_get_int_32 (png_bytep buf); \fI#endif
     177\fI\fB
     178
     179\fB#if \fI!defined(PNG_1_0_X)
     180
     181\fBpng_int_32 png_get_int_32 (png_bytep \fIbuf\fP\fB);\fP
     182
     183\fI\fB#endif
     184
     185\fI\fB
    93186
    94187\fBpng_byte png_get_interlace_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    95188
     189\fI\fB
     190
    96191\fBpng_voidp png_get_io_ptr (png_structp \fIpng_ptr\fP\fB);\fP
    97192
     193\fI\fB
     194
    98195\fBpng_byte png_get_libpng_ver (png_structp \fIpng_ptr\fP\fB);\fP
    99196
     197\fI\fB
     198
    100199\fBpng_voidp png_get_mem_ptr(png_structp \fIpng_ptr\fP\fB);\fP
    101200
     201\fI\fB
     202
    102203\fBpng_uint_32 png_get_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_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
    103204
     205\fI\fB
     206
    104207\fBpng_uint_32 png_get_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_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
    105208
     209\fI\fB
     210
    106211\fBpng_uint_32 png_get_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_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
    107212
     213\fI\fB
     214
    108215\fBfloat png_get_pixel_aspect_ratio (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    109216
     217\fI\fB
     218
    110219\fBpng_uint_32 png_get_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    111220
     221\fI\fB
     222
    112223\fBpng_voidp png_get_progressive_ptr (png_structp \fIpng_ptr\fP\fB);\fP
    113224
     225\fI\fB
     226
    114227\fBpng_uint_32 png_get_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_colorp \fP\fI*palette\fP\fB, int \fI*num_palette\fP\fB);\fP
    115228
    116 \fBpng_byte png_get_rgb_to_gray_status (png_structp png_ptr) png_uint_32 png_get_rowbytes (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
     229\fI\fB
     230
     231\fBpng_byte png_get_rgb_to_gray_status (png_structp \fIpng_ptr)
     232
     233\fBpng_uint_32 png_get_rowbytes (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
     234
     235\fI\fB
    117236
    118237\fBpng_bytepp png_get_rows (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    119238
     239\fI\fB
     240
    120241\fBpng_uint_32 png_get_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_8p \fI*sig_bit\fP\fB);\fP
    121242
     243\fI\fB
     244
    122245\fBpng_bytep png_get_signature (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    123246
     247\fI\fB
     248
    124249\fBpng_uint_32 png_get_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fI*splt_ptr\fP\fB);\fP
    125250
     251\fI\fB
     252
    126253\fBpng_uint_32 png_get_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fI*intent\fP\fB);\fP
    127254
     255\fI\fB
     256
    128257\fBpng_uint_32 png_get_text (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fI*text_ptr\fP\fB, int \fI*num_text\fP\fB);\fP
    129258
     259\fI\fB
     260
    130261\fBpng_uint_32 png_get_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fI*mod_time\fP\fB);\fP
    131262
     263\fI\fB
     264
    132265\fBpng_uint_32 png_get_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fI*trans\fP\fB, int \fP\fI*num_trans\fP\fB, png_color_16p \fI*trans_values\fP\fB);\fP
    133266
    134 \fB#if !defined(PNG_1_0_X) png_uint_16 png_get_uint_16 (png_bytep \fIbuf\fP\fB);\fP
     267\fI\fB
     268
     269\fB#if \fI!defined(PNG_1_0_X)
     270
     271\fBpng_uint_16 png_get_uint_16 (png_bytep \fIbuf\fP\fB);\fP
     272
     273\fI\fB
    135274
    136275\fBpng_uint_32 png_get_uint_31 (png_bytep \fIbuf\fP\fB);\fP
    137276
    138 \fBpng_uint_32 png_get_uint_32 (png_bytep buf); \fI#endif
     277\fI\fB
     278
     279\fBpng_uint_32 png_get_uint_32 (png_bytep \fIbuf\fP\fB);\fP
     280
     281\fI\fB#endif
     282
     283\fI\fB
    139284
    140285\fBpng_uint_32 png_get_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkpp \fIunknowns\fP\fB);\fP
    141286
     287\fI\fB
     288
    142289\fBpng_voidp png_get_user_chunk_ptr (png_structp \fIpng_ptr\fP\fB);\fP
    143290
     291\fI\fB
     292
    144293\fBpng_uint_32 png_get_user_height_max( png_structp \fIpng_ptr\fP\fB);\fP
    145294
     295\fI\fB
     296
    146297\fBpng_voidp png_get_user_transform_ptr (png_structp \fIpng_ptr\fP\fB);\fP
    147298
     299\fI\fB
     300
    148301\fBpng_uint_32 png_get_user_width_max (png_structp \fIpng_ptr\fP\fB);\fP
    149302
     303\fI\fB
     304
    150305\fBpng_uint_32 png_get_valid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIflag\fP\fB);\fP
    151306
     307\fI\fB
     308
    152309\fBpng_int_32 png_get_x_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    153310
     311\fI\fB
     312
    154313\fBpng_int_32 png_get_x_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    155314
     315\fI\fB
     316
    156317\fBpng_uint_32 png_get_x_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    157318
     319\fI\fB
     320
    158321\fBpng_int_32 png_get_y_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    159322
     323\fI\fB
     324
    160325\fBpng_int_32 png_get_y_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    161326
     327\fI\fB
     328
    162329\fBpng_uint_32 png_get_y_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    163330
     331\fI\fB
     332
    164333\fBpng_uint_32 png_get_compression_buffer_size (png_structp \fIpng_ptr\fP\fB);\fP
    165334
     335\fI\fB
     336
    166337\fBint png_handle_as_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP
    167338
     339\fI\fB
     340
    168341\fBvoid png_init_io (png_structp \fP\fIpng_ptr\fP\fB, FILE \fI*fp\fP\fB);\fP
    169342
     343\fI\fB
     344
    170345\fBDEPRECATED: void png_info_init (png_infop \fIinfo_ptr\fP\fB);\fP
    171346
     347\fI\fB
     348
    172349\fBDEPRECATED: void png_info_init_2 (png_infopp \fP\fIptr_ptr\fP\fB, png_size_t \fIpng_info_struct_size\fP\fB);\fP
    173350
     351\fI\fB
     352
    174353\fBpng_voidp png_malloc (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
    175354
     355\fI\fB
     356
    176357\fBpng_voidp png_malloc_default(png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
    177358
     359\fI\fB
     360
    178361\fBvoidp png_memcpy (png_voidp \fP\fIs1\fP\fB, png_voidp \fP\fIs2\fP\fB, png_size_t \fIsize\fP\fB);\fP
    179362
     363\fI\fB
     364
    180365\fBpng_voidp png_memcpy_check (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIs1\fP\fB, png_voidp \fP\fIs2\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
    181366
     367\fI\fB
     368
    182369\fBvoidp png_memset (png_voidp \fP\fIs1\fP\fB, int \fP\fIvalue\fP\fB, png_size_t \fIsize\fP\fB);\fP
    183370
     371\fI\fB
     372
    184373\fBpng_voidp png_memset_check (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIs1\fP\fB, int \fP\fIvalue\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
    185374
     375\fI\fB
     376
    186377\fBDEPRECATED: void png_permit_empty_plte (png_structp \fP\fIpng_ptr\fP\fB, int \fIempty_plte_permitted\fP\fB);\fP
    187378
     379\fI\fB
     380
    188381\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
    189382
     383\fI\fB
     384
    190385\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
    191386
     387\fI\fB
     388
    192389\fBvoid png_read_destroy (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_infop \fIend_info_ptr\fP\fB);\fP
    193390
     391\fI\fB
     392
    194393\fBvoid png_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    195394
     395\fI\fB
     396
    196397\fBvoid png_read_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP
    197398
     399\fI\fB
     400
    198401\fBDEPRECATED: void png_read_init (png_structp \fIpng_ptr\fP\fB);\fP
    199402
     403\fI\fB
     404
    200405\fBDEPRECATED: void png_read_init_2 (png_structpp \fP\fIptr_ptr\fP\fB, png_const_charp \fP\fIuser_png_ver\fP\fB, png_size_t \fP\fIpng_struct_size\fP\fB, png_size_t \fIpng_info_size\fP\fB);\fP
    201406
     407\fI\fB
     408
    202409\fBvoid png_read_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    203410
     411\fI\fB
     412
    204413\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
    205414
     415\fI\fB
     416
    206417\fBvoid png_read_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fIdisplay_row\fP\fB);\fP
    207418
     419\fI\fB
     420
    208421\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
    209422
     423\fI\fB
     424
    210425\fBvoid png_read_update_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    211426
    212 \fB#if !defined(PNG_1_0_X) png_save_int_32 (png_bytep \fP\fIbuf\fP\fB, png_int_32 \fIi\fP\fB);\fP
     427\fI\fB
     428
     429\fB#if \fI!defined(PNG_1_0_X)
     430
     431\fBpng_save_int_32 (png_bytep \fP\fIbuf\fP\fB, png_int_32 \fIi\fP\fB);\fP
     432
     433\fI\fB
    213434
    214435\fBvoid png_save_uint_16 (png_bytep \fP\fIbuf\fP\fB, unsigned int \fIi\fP\fB);\fP
    215436
     437\fI\fB
     438
    216439\fBvoid png_save_uint_32 (png_bytep \fP\fIbuf\fP\fB, png_uint_32 \fIi\fP\fB);\fP
    217440
    218 \fBvoid png_set_add_alpha (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int flags); \fI#endif
     441\fI\fB
     442
     443\fBvoid png_set_add_alpha (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP
     444
     445\fI\fB#endif
     446
     447\fI\fB
    219448
    220449\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
    221450
     451\fI\fB
     452
    222453\fBvoid png_set_bgr (png_structp \fIpng_ptr\fP\fB);\fP
    223454
     455\fI\fB
     456
    224457\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
    225458
     459\fI\fB
     460
    226461\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
    227462
     463\fI\fB
     464
    228465\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
    229466
     467\fI\fB
     468
    230469\fBvoid png_set_compression_level (png_structp \fP\fIpng_ptr\fP\fB, int \fIlevel\fP\fB);\fP
    231470
     471\fI\fB
     472
    232473\fBvoid png_set_compression_mem_level (png_structp \fP\fIpng_ptr\fP\fB, int \fImem_level\fP\fB);\fP
    233474
     475\fI\fB
     476
    234477\fBvoid png_set_compression_method (png_structp \fP\fIpng_ptr\fP\fB, int \fImethod\fP\fB);\fP
    235478
     479\fI\fB
     480
    236481\fBvoid png_set_compression_strategy (png_structp \fP\fIpng_ptr\fP\fB, int \fIstrategy\fP\fB);\fP
    237482
     483\fI\fB
     484
    238485\fBvoid png_set_compression_window_bits (png_structp \fP\fIpng_ptr\fP\fB, int \fIwindow_bits\fP\fB);\fP
    239486
     487\fI\fB
     488
    240489\fBvoid png_set_crc_action (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcrit_action\fP\fB, int \fIancil_action\fP\fB);\fP
    241490
     491\fI\fB
     492
    242493\fBvoid png_set_dither (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_dither\fP\fB);\fP
    243494
     495\fI\fB
     496
    244497\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
    245498
     499\fI\fB
     500
    246501\fBvoid png_set_expand (png_structp \fIpng_ptr\fP\fB);\fP
    247502
     503\fI\fB
     504
    248505\fBvoid png_set_expand_gray_1_2_4_to_8(png_structp \fIpng_ptr\fP\fB);\fP
    249506
     507\fI\fB
     508
    250509\fBvoid png_set_filler (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP
    251510
     511\fI\fB
     512
    252513\fBvoid png_set_filter (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fImethod\fP\fB, int \fIfilters\fP\fB);\fP
    253514
     515\fI\fB
     516
    254517\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
    255518
     519\fI\fB
     520
    256521\fBvoid png_set_flush (png_structp \fP\fIpng_ptr\fP\fB, int \fInrows\fP\fB);\fP
    257522
     523\fI\fB
     524
    258525\fBvoid png_set_gamma (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIscreen_gamma\fP\fB, double \fIdefault_file_gamma\fP\fB);\fP
    259526
     527\fI\fB
     528
    260529\fBvoid png_set_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fIfile_gamma\fP\fB);\fP
    261530
     531\fI\fB
     532
    262533\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
    263534
     535\fI\fB
     536
    264537\fBvoid png_set_gray_1_2_4_to_8(png_structp \fIpng_ptr\fP\fB);\fP
    265538
     539\fI\fB
     540
    266541\fBvoid png_set_gray_to_rgb (png_structp \fIpng_ptr\fP\fB);\fP
    267542
     543\fI\fB
     544
    268545\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
    269546
     547\fI\fB
     548
    270549\fBvoid png_set_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_charp \fP\fIprofile\fP\fB, png_uint_32 \fIproflen\fP\fB);\fP
    271550
     551\fI\fB
     552
    272553\fBint png_set_interlace_handling (png_structp \fIpng_ptr\fP\fB);\fP
    273554
     555\fI\fB
     556
    274557\fBvoid png_set_invalid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fImask\fP\fB);\fP
    275558
     559\fI\fB
     560
    276561\fBvoid png_set_invert_alpha (png_structp \fIpng_ptr\fP\fB);\fP
    277562
     563\fI\fB
     564
    278565\fBvoid png_set_invert_mono (png_structp \fIpng_ptr\fP\fB);\fP
    279566
     567\fI\fB
     568
    280569\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
    281570
     571\fI\fB
     572
    282573\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
    283574
     575\fI\fB
     576
    284577\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
    285578
     579\fI\fB
     580
    286581\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
    287582
     583\fI\fB
     584
    288585\fBvoid png_set_packing (png_structp \fIpng_ptr\fP\fB);\fP
    289586
     587\fI\fB
     588
    290589\fBvoid png_set_packswap (png_structp \fIpng_ptr\fP\fB);\fP
    291590
     591\fI\fB
     592
    292593\fBvoid png_set_palette_to_rgb(png_structp \fIpng_ptr\fP\fB);\fP
    293594
     595\fI\fB
     596
    294597\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
    295598
     599\fI\fB
     600
    296601\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
    297602
     603\fI\fB
     604
    298605\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
    299606
     607\fI\fB
     608
    300609\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
    301610
     611\fI\fB
     612
    302613\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
    303614
     615\fI\fB
     616
    304617\fBvoid png_set_read_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_read_status_ptr \fIread_row_fn\fP\fB);\fP
    305618
     619\fI\fB
     620
    306621\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
    307622
     623\fI\fB
     624
    308625\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
    309626
     627\fI\fB
     628
    310629\fBvoid png_set_rgb_to_gray_fixed (png_structp \fP\fIpng_ptr\fP\fB, int error_action png_fixed_point \fP\fIred\fP\fB, png_fixed_point \fIgreen\fP\fB);\fP
    311630
     631\fI\fB
     632
    312633\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
    313634
     635\fI\fB
     636
    314637\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
    315638
     639\fI\fB
     640
    316641\fBvoid png_set_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, double \fP\fIwidth\fP\fB, double \fIheight\fP\fB);\fP
    317642
     643\fI\fB
     644
    318645\fBvoid png_set_shift (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fItrue_bits\fP\fB);\fP
    319646
     647\fI\fB
     648
    320649\fBvoid png_set_sig_bytes (png_structp \fP\fIpng_ptr\fP\fB, int \fInum_bytes\fP\fB);\fP
    321650
     651\fI\fB
     652
    322653\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
    323654
     655\fI\fB
     656
    324657\fBvoid png_set_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIintent\fP\fB);\fP
    325658
     659\fI\fB
     660
    326661\fBvoid png_set_sRGB_gAMA_and_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIintent\fP\fB);\fP
    327662
     663\fI\fB
     664
    328665\fBvoid png_set_strip_16 (png_structp \fIpng_ptr\fP\fB);\fP
    329666
     667\fI\fB
     668
    330669\fBvoid png_set_strip_alpha (png_structp \fIpng_ptr\fP\fB);\fP
    331670
     671\fI\fB
     672
    332673\fBvoid png_set_swap (png_structp \fIpng_ptr\fP\fB);\fP
    333674
     675\fI\fB
     676
    334677\fBvoid png_set_swap_alpha (png_structp \fIpng_ptr\fP\fB);\fP
    335678
     679\fI\fB
     680
    336681\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
    337682
     683\fI\fB
     684
    338685\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
    339686
     687\fI\fB
     688
    340689\fBvoid png_set_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fItrans\fP\fB, int \fP\fInum_trans\fP\fB, png_color_16p \fItrans_values\fP\fB);\fP
    341690
     691\fI\fB
     692
    342693\fBvoid png_set_tRNS_to_alpha(png_structp \fIpng_ptr\fP\fB);\fP
    343694
     695\fI\fB
     696
    344697\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
    345698
     699\fI\fB
     700
    346701\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
    347702
     703\fI\fB
     704
    348705\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
    349706
     707\fI\fB
     708
    350709\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
    351710
     711\fI\fB
     712
    352713\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
    353714
     715\fI\fB
     716
    354717\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
    355718
     719\fI\fB
     720
    356721\fBvoid png_set_write_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_write_status_ptr \fIwrite_row_fn\fP\fB);\fP
    357722
     723\fI\fB
     724
    358725\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
    359726
     727\fI\fB
     728
    360729\fBvoid png_set_compression_buffer_size(png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
    361730
     731\fI\fB
     732
    362733\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
    363734
     735\fI\fB
     736
    364737\fBvoid png_start_read_image (png_structp \fIpng_ptr\fP\fB);\fP
    365738
     739\fI\fB
     740
    366741\fBvoid png_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP
    367742
     743\fI\fB
     744
    368745\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
    369746
     747\fI\fB
     748
    370749\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
    371750
     751\fI\fB
     752
    372753\fBvoid png_write_chunk_end (png_structp \fIpng_ptr\fP\fB);\fP
    373754
     755\fI\fB
     756
    374757\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
    375758
     759\fI\fB
     760
    376761\fBvoid png_write_destroy (png_structp \fIpng_ptr\fP\fB);\fP
    377762
     763\fI\fB
     764
    378765\fBvoid png_write_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    379766
     767\fI\fB
     768
    380769\fBvoid png_write_flush (png_structp \fIpng_ptr\fP\fB);\fP
    381770
     771\fI\fB
     772
    382773\fBvoid png_write_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP
    383774
     775\fI\fB
     776
    384777\fBDEPRECATED: void png_write_init (png_structp \fIpng_ptr\fP\fB);\fP
    385778
     779\fI\fB
     780
    386781\fBDEPRECATED: void png_write_init_2 (png_structpp \fP\fIptr_ptr\fP\fB, png_const_charp \fP\fIuser_png_ver\fP\fB, png_size_t \fP\fIpng_struct_size\fP\fB, png_size_t \fIpng_info_size\fP\fB);\fP
    387782
     783\fI\fB
     784
    388785\fBvoid png_write_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    389786
     787\fI\fB
     788
    390789\fBvoid png_write_info_before_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    391790
     791\fI\fB
     792
    392793\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
    393794
     795\fI\fB
     796
    394797\fBvoid png_write_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIrow\fP\fB);\fP
    395798
     799\fI\fB
     800
    396801\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
    397802
     803\fI\fB
     804
    398805\fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP
    399806
     807\fI\fB
     808
    400809\fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP
     810
     811\fI\fB
    401812
    402813.SH DESCRIPTION
     
    411822libpng.txt - A description on how to use and modify libpng
    412823
    413  libpng version 1.2.29 - May 8, 2008
     824 libpng version 1.2.40 - September 10, 2009
    414825 Updated and distributed by Glenn Randers-Pehrson
    415826 <glennrp at users.sourceforge.net>
    416  Copyright (c) 1998-2008 Glenn Randers-Pehrson
    417  For conditions of distribution and use, see copyright
    418  notice in png.h.
     827 Copyright (c) 1998-2009 Glenn Randers-Pehrson
     828
     829 This document is released under the libpng license.
     830 For conditions of distribution and use, see the disclaimer
     831 and license in png.h
    419832
    420833 Based on:
    421834
    422  libpng versions 0.97, January 1998, through 1.2.29 - May 8, 2008
     835 libpng versions 0.97, January 1998, through 1.2.40 - September 10, 2009
    423836 Updated and distributed by Glenn Randers-Pehrson
    424  Copyright (c) 1998-2008 Glenn Randers-Pehrson
     837 Copyright (c) 1998-2009 Glenn Randers-Pehrson
    425838
    426839 libpng 1.0 beta 6  version 0.96 May 28, 1997
     
    552965file.  Libpng provides a simple check to see if a file is a PNG file.
    553966To use it, pass in the first 1 to 8 bytes of the file to the function
    554 png_sig_cmp(), and it will return 0 if the bytes match the corresponding
    555 bytes of the PNG signature, or nonzero otherwise.  Of course, the more bytes
    556 you pass in, the greater the accuracy of the prediction.
     967png_sig_cmp(), and it will return 0 (false) if the bytes match the
     968corresponding bytes of the PNG signature, or nonzero (true) otherwise.
     969Of course, the more bytes you pass in, the greater the accuracy of the
     970prediction.
    557971
    558972If you are intending to keep the file pointer open for use in libpng,
     
    7311145    png_set_read_status_fn(png_ptr, read_row_callback);
    7321146
    733 .SS Width and height limits
    734 
    735 The PNG specification allows the width and height of an image to be as
    736 large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns.
    737 Since very few applications really need to process such large images,
    738 we have imposed an arbitrary 1-million limit on rows and columns.
    739 Larger images will be rejected immediately with a png_error() call. If
    740 you wish to override this limit, you can use
    741 
    742    png_set_user_limits(png_ptr, width_max, height_max);
    743 
    744 to set your own limits, or use width_max = height_max = 0x7fffffffL
    745 to allow all valid dimensions (libpng may reject some very large images
    746 anyway because of potential buffer overflow conditions).
    747 
    748 You should put this statement after you create the PNG structure and
    749 before calling png_read_info(), png_read_png(), or png_process_data().
    750 If you need to retrieve the limits that are being applied, use
    751 
    752    width_max = png_get_user_width_max(png_ptr);
    753    height_max = png_get_user_height_max(png_ptr);
    754 
    7551147.SS Unknown-chunk handling
    7561148
     
    7581150input PNG stream. Both known and unknown chunks will be read.  Normal
    7591151behavior is that known chunks will be parsed into information in
    760 various info_ptr members while unknown chunks will be discarded. To change
    761 this, you can call:
     1152various info_ptr members while unknown chunks will be discarded. This
     1153behavior can be wasteful if your application will never use some known
     1154chunk types. To change this, you can call:
    7621155
    7631156    png_set_keep_unknown_chunks(png_ptr, keep,
     
    8171210    #endif
    8181211
     1212.SS User limits
     1213
     1214The PNG specification allows the width and height of an image to be as
     1215large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns.
     1216Since very few applications really need to process such large images,
     1217we have imposed an arbitrary 1-million limit on rows and columns.
     1218Larger images will be rejected immediately with a png_error() call. If
     1219you wish to override this limit, you can use
     1220
     1221   png_set_user_limits(png_ptr, width_max, height_max);
     1222
     1223to set your own limits, or use width_max = height_max = 0x7fffffffL
     1224to allow all valid dimensions (libpng may reject some very large images
     1225anyway because of potential buffer overflow conditions).
     1226
     1227You should put this statement after you create the PNG structure and
     1228before calling png_read_info(), png_read_png(), or png_process_data().
     1229If you need to retrieve the limits that are being applied, use
     1230
     1231   width_max = png_get_user_width_max(png_ptr);
     1232   height_max = png_get_user_height_max(png_ptr);
    8191233
    8201234.SS The high-level read interface
     
    8821296   row_pointers = png_malloc(png_ptr,
    8831297      height*png_sizeof(png_bytep));
     1298   for (int i=0; i<height, i++)
     1299      row_pointers[i]=NULL;  /* security precaution */
    8841300   for (int i=0; i<height, i++)
    8851301      row_pointers[i]=png_malloc(png_ptr,
     
    12581674As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was
    12591675added.  It expands the sample depth without changing tRNS to alpha.
    1260 At the same time, png_set_gray_1_2_4_to_8() was deprecated, and it
    1261 will be removed from a future version.
    1262 
    12631676
    12641677PNG can have files with 16 bits per channel.  If you only can handle
     
    21122525       PNG_FILTER_SUB   | PNG_FILTER_VALUE_SUB  |
    21132526       PNG_FILTER_UP    | PNG_FILTER_VALUE_UP   |
    2114        PNG_FILTER_AVE   | PNG_FILTER_VALUE_AVE  |
     2527       PNG_FILTER_AVG   | PNG_FILTER_VALUE_AVG  |
    21152528       PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH|
    21162529       PNG_ALL_FILTERS);
     
    22022615
    22032616If you call png_set_IHDR(), the call must appear before any of the
    2204 other png_set_*() functions, which might require access to some of
     2617other png_set_*() functions, because they might require access to some of
    22052618the IHDR settings.  The remaining png_set_*() functions can be called
    22062619in any order.
     2620
     2621If you wish, you can reset the compression_type, interlace_type, or
     2622filter_method later by calling png_set_IHDR() again; if you do this, the
     2623width, height, bit_depth, and color_type must be the same in each call.
    22072624
    22082625    png_set_PLTE(png_ptr, info_ptr, palette,
     
    22672684    trans          - array of transparent entries for
    22682685                     palette (PNG_INFO_tRNS)
    2269     trans_values   - graylevel or color sample values of
    2270                      the single transparent color for
     2686    trans_values   - graylevel or color sample values
     2687                     (in order red, green, blue) of the
     2688                     single transparent color for
    22712689                     non-paletted images (PNG_INFO_tRNS)
    22722690    num_trans      - number of transparent entries
     
    24772895                                to transparency
    24782896    PNG_TRANSFORM_SWAP_ENDIAN   Byte-swap 16-bit samples
    2479     PNG_TRANSFORM_STRIP_FILLER  Strip out filler bytes.
     2897    PNG_TRANSFORM_STRIP_FILLER        Strip out filler
     2898                                      bytes (deprecated).
     2899    PNG_TRANSFORM_STRIP_FILLER_BEFORE Strip out leading
     2900                                      filler bytes
     2901    PNG_TRANSFORM_STRIP_FILLER_AFTER  Strip out trailing
     2902                                      filler bytes
    24802903
    24812904If you have valid image data in the info structure (you can use
     
    28843307    void user_flush_data(png_structp png_ptr);
    28853308
     3309The user_read_data() function is responsible for detecting and
     3310handling end-of-data errors.
     3311
    28863312Supplying NULL for the read, write, or flush functions sets them back
    2887 to using the default C stream functions.  It is an error to read from
    2888 a write stream, and vice versa.
     3313to using the default C stream functions, which expect the io_ptr to
     3314point to a standard *FILE structure.  It is probably a mistake
     3315to use NULL for one of write_data_fn and output_flush_fn but not both
     3316of them, unless you have built libpng with PNG_NO_WRITE_FLUSH defined.
     3317It is an error to read from a write stream, and vice versa.
    28893318
    28903319Error handling in libpng is done through png_error() and png_warning().
     
    29913420.SS Configuring for compiler xxx:
    29923421
    2993 All includes for libpng are in pngconf.h.  If you need to add/change/delete
    2994 an include, this is the place to do it.  The includes that are not
    2995 needed outside libpng are protected by the PNG_INTERNAL definition,
    2996 which is only defined for those routines inside libpng itself.  The
    2997 files in libpng proper only include png.h, which includes pngconf.h.
     3422All includes for libpng are in pngconf.h.  If you need to add, change
     3423or delete an include, this is the place to do it.
     3424The includes that are not needed outside libpng are protected by the
     3425PNG_INTERNAL definition, which is only defined for those routines inside
     3426libpng itself.  The files in libpng proper only include png.h, which
     3427includes pngconf.h.
    29983428
    29993429.SS Configuring zlib:
     
    30643494
    30653495    filters = PNG_FILTER_NONE | PNG_FILTER_SUB
    3066               PNG_FILTER_UP | PNG_FILTER_AVE |
     3496              PNG_FILTER_UP | PNG_FILTER_AVG |
    30673497              PNG_FILTER_PAETH | PNG_ALL_FILTERS;
    30683498
     
    31863616this version of libpng, but if you insert some they will be printed.
    31873617
    3188 .SH VII.  MNG support
     3618.SH VI.  MNG support
    31893619
    31903620The MNG specification (available at http://www.libpng.org/pub/mng) allows
     
    32113641http://www.libmng.com) instead.
    32123642
    3213 .SH VIII.  Changes to Libpng from version 0.88
     3643.SH VII.  Changes to Libpng from version 0.88
    32143644
    32153645It should be noted that versions of libpng later than 0.96 are not
     
    32603690   png_uint_32 application_vn = PNG_LIBPNG_VER;
    32613691
    3262 .SH IX. Y2K Compliance in libpng
    3263 
    3264 May 8, 2008
     3692.SH VIII.  Changes to Libpng from version 1.0.x to 1.2.x
     3693
     3694Support for user memory management was enabled by default.  To
     3695accomplish this, the functions png_create_read_struct_2(),
     3696png_create_write_struct_2(), png_set_mem_fn(), png_get_mem_ptr(),
     3697png_malloc_default(), and png_free_default() were added.
     3698
     3699Support for certain MNG features was enabled.
     3700
     3701Support for numbered error messages was added.  However, we never got
     3702around to actually numbering the error messages.  The function
     3703png_set_strip_error_numbers() was added (Note: the prototype for this
     3704function was inadvertently removed from png.h in PNG_NO_ASSEMBLER_CODE
     3705builds of libpng-1.2.15.  It was restored in libpng-1.2.36).
     3706
     3707The png_malloc_warn() function was added at libpng-1.2.3.  This issues
     3708a png_warning and returns NULL instead of aborting when it fails to
     3709acquire the requested memory allocation.
     3710
     3711Support for setting user limits on image width and height was enabled
     3712by default.  The functions png_set_user_limits(), png_get_user_width_max(),
     3713and png_get_user_height_max() were added at libpng-1.2.6.
     3714
     3715The png_set_add_alpha() function was added at libpng-1.2.7.
     3716
     3717The function png_set_expand_gray_1_2_4_to_8() was added at libpng-1.2.9.
     3718Unlike png_set_gray_1_2_4_to_8(), the new function does not expand the
     3719tRNS chunk to alpha. The png_set_gray_1_2_4_to_8() function is
     3720deprecated.
     3721
     3722A number of macro definitions in support of runtime selection of
     3723assembler code features (especially Intel MMX code support) were
     3724added at libpng-1.2.0:
     3725
     3726    PNG_ASM_FLAG_MMX_SUPPORT_COMPILED
     3727    PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU
     3728    PNG_ASM_FLAG_MMX_READ_COMBINE_ROW
     3729    PNG_ASM_FLAG_MMX_READ_INTERLACE
     3730    PNG_ASM_FLAG_MMX_READ_FILTER_SUB
     3731    PNG_ASM_FLAG_MMX_READ_FILTER_UP
     3732    PNG_ASM_FLAG_MMX_READ_FILTER_AVG
     3733    PNG_ASM_FLAG_MMX_READ_FILTER_PAETH
     3734    PNG_ASM_FLAGS_INITIALIZED
     3735    PNG_MMX_READ_FLAGS
     3736    PNG_MMX_FLAGS
     3737    PNG_MMX_WRITE_FLAGS
     3738    PNG_MMX_FLAGS
     3739
     3740We added the following functions in support of runtime
     3741selection of assembler code features:
     3742
     3743    png_get_mmx_flagmask()
     3744    png_set_mmx_thresholds()
     3745    png_get_asm_flags()
     3746    png_get_mmx_bitdepth_threshold()
     3747    png_get_mmx_rowbytes_threshold()
     3748    png_set_asm_flags()
     3749
     3750We replaced all of these functions with simple stubs in libpng-1.2.20,
     3751when the Intel assembler code was removed due to a licensing issue.
     3752
     3753.SH IX.  (Omitted)
     3754
     3755.SH X. Detecting libpng
     3756
     3757The png_get_io_ptr() function has been present since libpng-0.88, has never
     3758changed, and is unaffected by conditional compilation macros.  It is the
     3759best choice for use in configure scripts for detecting the presence of any
     3760libpng version since 0.88.  In an autoconf "configure.in" you could use
     3761
     3762    AC_CHECK_LIB(png, png_get_io_ptr, ...
     3763
     3764.SH XI. Source code repository
     3765
     3766Since about February 2009, version 1.2.34, libpng has been under "git" source
     3767control.  The git repository was built from old libpng-x.y.z.tar.gz files
     3768going back to version 0.70.  You can access the git repository (read only)
     3769at
     3770
     3771    git://libpng.git.sourceforge.net/gitroot/libpng
     3772
     3773or you can browse it via "gitweb" at
     3774
     3775    http://libpng.git.sourceforge.net/git/gitweb.cgi?p=libpng
     3776
     3777Patches can be sent to glennrp at users.sourceforge.net or to
     3778png-mng-implement at lists.sourceforge.net or you can upload them to
     3779the libpng bug tracker at
     3780
     3781    http://libpng.sourceforge.net
     3782
     3783.SH XII. Coding style
     3784
     3785Our coding style is similar to the "Allman" style, with curly
     3786braces on separate lines:
     3787
     3788    if (condition)
     3789    {
     3790       action;
     3791    }
     3792
     3793    else if (another condition)
     3794    {
     3795       another action;
     3796    }
     3797
     3798The braces can be omitted from simple one-line actions:
     3799
     3800    if (condition)
     3801       return (0);
     3802
     3803We use 3-space indentation, except for continued statements which
     3804are usually indented the same as the first line of the statement
     3805plus four more spaces.
     3806
     3807Comments appear with the leading "/*" at the same indentation as
     3808the statement that follows the comment:
     3809
     3810    /* Single-line comment */
     3811    statement;
     3812
     3813    /* Multiple-line
     3814     * comment
     3815     */
     3816    statement;
     3817
     3818Very short comments can be placed at the end of the statement
     3819to which they pertain:
     3820
     3821    statement;    /* comment */
     3822
     3823We don't use C++ style ("//") comments. We have, however,
     3824used them in the past in some now-abandoned MMX assembler
     3825code.
     3826
     3827Functions and their curly braces are not indented, and
     3828exported functions are marked with PNGAPI:
     3829
     3830 /* This is a public function that is visible to
     3831  * application programers. It does thus-and-so.
     3832  */
     3833 void PNGAPI
     3834 png_exported_function(png_ptr, png_info, foo)
     3835 {
     3836    body;
     3837 }
     3838
     3839The prototypes for all exported functions appear in png.h,
     3840above the comment that says
     3841
     3842    /* Maintainer: Put new public prototypes here ... */
     3843
     3844We mark all non-exported functions with "/* PRIVATE */"":
     3845
     3846 void /* PRIVATE */
     3847 png_non_exported_function(png_ptr, png_info, foo)
     3848 {
     3849    body;
     3850 }
     3851
     3852The prototypes for non-exported functions (except for those in
     3853pngtest) appear in
     3854the PNG_INTERNAL section of png.h
     3855above the comment that says
     3856
     3857  /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
     3858
     3859The names of all exported functions and variables begin
     3860with  "png_", and all publicly visible C preprocessor
     3861macros begin with "PNG_".
     3862
     3863We put a space after each comma and after each semicolon
     3864in "for" statments, and we put spaces before and after each
     3865C binary operator and after "for" or "while".  We don't
     3866put a space between a typecast and the expression being
     3867cast, nor do we put one between a function name and the
     3868left parenthesis that follows it:
     3869
     3870    for (i = 2; i > 0; --i)
     3871       x[i] = a(x) + (int)b;
     3872
     3873We prefer #ifdef and #ifndef to #if defined() and if !defined()
     3874when there is only one macro being tested.
     3875
     3876Other rules can be inferred by inspecting the libpng
     3877source.
     3878
     3879.SH XIII. Y2K Compliance in libpng
     3880
     3881September 10, 2009
    32653882
    32663883Since the PNG Development group is an ad-hoc body, we can't make
     
    32683885
    32693886This is your unofficial assurance that libpng from version 0.71 and
    3270 upward through 1.2.29 are Y2K compliant.  It is my belief that earlier
     3887upward through 1.2.40 are Y2K compliant.  It is my belief that earlier
    32713888versions were also Y2K compliant.
    32723889
     
    35004117 1.0.35              10    10035  10.so.0.35[.0]
    35014118 1.2.29              13    10229  12.so.0.29[.0]
     4119 1.0.37              10    10037  10.so.0.37[.0]
     4120 1.2.30beta01-04     13    10230  12.so.0.30[.0]
     4121 1.0.38rc01-08       10    10038  10.so.0.38[.0]
     4122 1.2.30rc01-08       13    10230  12.so.0.30[.0]
     4123 1.0.38              10    10038  10.so.0.38[.0]
     4124 1.2.30              13    10230  12.so.0.30[.0]
     4125 1.0.39rc01-03       10    10039  10.so.0.39[.0]
     4126 1.2.31rc01-03       13    10231  12.so.0.31[.0]
     4127 1.0.39              10    10039  10.so.0.39[.0]
     4128 1.2.31              13    10231  12.so.0.31[.0]
     4129 1.2.32beta01-02     13    10232  12.so.0.32[.0]
     4130 1.0.40rc01          10    10040  10.so.0.40[.0]
     4131 1.2.32rc01          13    10232  12.so.0.32[.0]
     4132 1.0.40              10    10040  10.so.0.40[.0]
     4133 1.2.32              13    10232  12.so.0.32[.0]
     4134 1.2.33beta01-02     13    10233  12.so.0.33[.0]
     4135 1.2.33rc01-02       13    10233  12.so.0.33[.0]
     4136 1.0.41rc01          10    10041  10.so.0.41[.0]
     4137 1.2.33              13    10233  12.so.0.33[.0]
     4138 1.0.41              10    10041  10.so.0.41[.0]
     4139 1.2.34beta01-07     13    10234  12.so.0.34[.0]
     4140 1.0.42rc01          10    10042  10.so.0.42[.0]
     4141 1.2.34rc01          13    10234  12.so.0.34[.0]
     4142 1.0.42              10    10042  10.so.0.42[.0]
     4143 1.2.34              13    10234  12.so.0.34[.0]
     4144 1.2.35beta01-03     13    10235  12.so.0.35[.0]
     4145 1.0.43rc01-02       10    10043  10.so.0.43[.0]
     4146 1.2.35rc01-02       13    10235  12.so.0.35[.0]
     4147 1.0.43              10    10043  10.so.0.43[.0]
     4148 1.2.35              13    10235  12.so.0.35[.0]
     4149 1.2.36beta01-05     13    10236  12.so.0.36[.0]
     4150 1.2.36rc01          13    10236  12.so.0.36[.0]
     4151 1.0.44              10    10044  10.so.0.44[.0]
     4152 1.2.36              13    10236  12.so.0.36[.0]
     4153 1.2.37beta01-03     13    10237  12.so.0.37[.0]
     4154 1.2.37rc01          13    10237  12.so.0.37[.0]
     4155 1.2.37              13    10237  12.so.0.37[.0]
     4156 1.2.45              10    10045  12.so.0.45[.0]
     4157 1.0.46              10    10046  10.so.0.46[.0]
     4158 1.2.38beta01        13    10238  12.so.0.38[.0]
     4159 1.2.38rc01-03       13    10238  12.so.0.38[.0]
     4160 1.0.47              10    10047  10.so.0.47[.0]
     4161 1.2.38              13    10238  12.so.0.38[.0]
     4162 1.2.39beta01-05     13    10239  12.so.0.39[.0]
     4163 1.2.39rc01          13    10239  12.so.0.39[.0]
     4164 1.0.48              10    10048  10.so.0.48[.0]
     4165 1.2.39              13    10239  12.so.0.39[.0]
     4166 1.2.40rc01          13    10240  12.so.0.40[.0]
     4167 1.0.49              10    10049  10.so.0.49[.0]
     4168 1.2.40              13    10240  12.so.0.40[.0]
    35024169
    35034170Henceforth the source version will match the shared-library minor
     
    35554222Thanks to Frank J. T. Wojcik for helping with the documentation.
    35564223
    3557 Libpng version 1.2.29 - May 8, 2008:
     4224Libpng version 1.2.40 - September 10, 2009:
    35584225Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
    35594226Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
     
    35764243this sentence.
    35774244
    3578 libpng versions 1.2.6, August 15, 2004, through 1.2.29, May 8, 2008, are
     4245This code is released under the libpng license.
     4246
     4247libpng versions 1.2.6, August 15, 2004, through 1.2.40, September 10, 2009, are
    35794248Copyright (c) 2004,2006-2008 Glenn Randers-Pehrson, and are
    35804249distributed according to the same disclaimer and license as libpng-1.2.5
     
    36754344Glenn Randers-Pehrson
    36764345glennrp at users.sourceforge.net
    3677 May 8, 2008
     4346September 10, 2009
    36784347
    36794348.\" end of man page
  • trunk/src/3rdparty/libpng/libpngpf.3

    r2 r561  
    1 .TH LIBPNGPF 3 "May 8, 2008"
     1.TH LIBPNGPF 3 "September 10, 2009"
    22.SH NAME
    3 libpng \- Portable Network Graphics (PNG) Reference Library 1.2.29
     3libpng \- Portable Network Graphics (PNG) Reference Library 1.2.40
    44(private functions)
    55.SH SYNOPSIS
    66\fB#include <png.h>\fP
    77
     8\fI\fB
     9
     10\fI\fB
     11
    812\fBvoid png_build_gamma_table (png_structp \fIpng_ptr\fP\fB);\fP
    913
     14\fI\fB
     15
     16\fI\fB
     17
    1018\fBvoid png_build_grayscale_palette (int \fP\fIbit_depth\fP\fB, png_colorp \fIpalette\fP\fB);\fP
    1119
     20\fI\fB
     21
     22\fI\fB
     23
    1224\fBvoid png_calculate_crc (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIptr\fP\fB, png_size_t \fIlength\fP\fB);\fP
    1325
     26\fI\fB
     27
     28\fI\fB
     29
    1430\fBvoid png_check_chunk_name (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP
    1531
     32\fI\fB
     33
     34\fI\fB
     35
    1636\fBpng_size_t png_check_keyword (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charpp \fInew_key\fP\fB);\fP
    1737
     38\fI\fB
     39
     40\fI\fB
     41
    1842\fBvoid png_combine_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fImask\fP\fB);\fP
    1943
     44\fI\fB
     45
     46\fI\fB
     47
    2048\fBvoid png_correct_palette (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fInum_palette\fP\fB);\fP
    2149
     50\fI\fB
     51
     52\fI\fB
     53
    2254\fBint png_crc_error (png_structp \fIpng_ptr\fP\fB);\fP
    2355
     56\fI\fB
     57
     58\fI\fB
     59
    2460\fBint png_crc_finish (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIskip\fP\fB);\fP
    2561
     62\fI\fB
     63
     64\fI\fB
     65
    2666\fBvoid png_crc_read (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuf\fP\fB, png_size_t \fIlength\fP\fB);\fP
    2767
     68\fI\fB
     69
     70\fI\fB
     71
    2872\fBpng_voidp png_create_struct (int \fItype\fP\fB);\fP
    2973
     74\fI\fB
     75
     76\fI\fB
     77
    3078\fBpng_voidp png_create_struct_2 (int \fP\fItype\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_voidp \fImem_ptr\fP\fB);\fP
    3179
    32 \fBpng_charp png_decompress_chunk (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcomp_type\fP\fB, png_charp \fP\fIchunkdata\fP\fB, png_size_t \fP\fIchunklength\fP\fB, png_size_t \fP\fIprefix_length\fP\fB, png_size_t \fI*data_length\fP\fB);\fP
     80\fI\fB
     81
     82\fI\fB
     83
     84\fBvoid png_decompress_chunk (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcomp_type\fP\fB, png_charp \fP\fIchunkdata\fP\fB, png_size_t \fP\fIchunklength\fP\fB, png_size_t \fP\fIprefix_length\fP\fB, png_size_t \fI*data_length\fP\fB);\fP
     85
     86\fI\fB
     87
     88\fI\fB
    3389
    3490\fBvoid png_destroy_struct (png_voidp \fIstruct_ptr\fP\fB);\fP
    3591
     92\fI\fB
     93
     94\fI\fB
     95
    3696\fBvoid png_destroy_struct_2 (png_voidp \fP\fIstruct_ptr\fP\fB, png_free_ptr \fP\fIfree_fn\fP\fB, png_voidp \fImem_ptr\fP\fB);\fP
    3797
     98\fI\fB
     99
     100\fI\fB
     101
    38102\fBvoid png_do_background (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_16p \fP\fItrans_values\fP\fB, png_color_16p \fP\fIbackground\fP\fB, png_color_16p \fP\fIbackground_1\fP\fB, png_bytep \fP\fIgamma_table\fP\fB, png_bytep \fP\fIgamma_from_1\fP\fB, png_bytep \fP\fIgamma_to_1\fP\fB, png_uint_16pp \fP\fIgamma_16\fP\fB, png_uint_16pp \fP\fIgamma_16_from_1\fP\fB, png_uint_16pp \fP\fIgamma_16_to_1\fP\fB, int \fIgamma_shift\fP\fB);\fP
    39103
     104\fI\fB
     105
     106\fI\fB
     107
    40108\fBvoid png_do_bgr (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
    41109
     110\fI\fB
     111
     112\fI\fB
     113
    42114\fBvoid png_do_chop (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
    43115
     116\fI\fB
     117
     118\fI\fB
     119
    44120\fBvoid png_do_dither (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIpalette_lookup\fP\fB, png_bytep \fIdither_lookup\fP\fB);\fP
    45121
     122\fI\fB
     123
     124\fI\fB
     125
    46126\fBvoid png_do_expand (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_16p \fItrans_value\fP\fB);\fP
    47127
     128\fI\fB
     129
     130\fI\fB
     131
    48132\fBvoid png_do_expand_palette (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_colorp \fP\fIpalette\fP\fB, png_bytep \fP\fItrans\fP\fB, int \fInum_trans\fP\fB);\fP
    49133
     134\fI\fB
     135
     136\fI\fB
     137
    50138\fBvoid png_do_gamma (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIgamma_table\fP\fB, png_uint_16pp \fP\fIgamma_16_table\fP\fB, int \fIgamma_shift\fP\fB);\fP
    51139
     140\fI\fB
     141
     142\fI\fB
     143
    52144\fBvoid png_do_gray_to_rgb (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
    53145
     146\fI\fB
     147
     148\fI\fB
     149
    54150\fBvoid png_do_invert (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
    55151
     152\fI\fB
     153
     154\fI\fB
     155
    56156\fBvoid png_do_pack (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fIbit_depth\fP\fB);\fP
    57157
     158\fI\fB
     159
     160\fI\fB
     161
    58162\fBvoid png_do_packswap (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
    59163
     164\fI\fB
     165
     166\fI\fB
     167
    60168\fBvoid png_do_read_filler (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, png_uint_32 \fIflags\fP\fB);\fP
    61169
     170\fI\fB
     171
     172\fI\fB
     173
    62174\fBvoid png_do_read_interlace (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fP\fIpass\fP\fB, png_uint_32 \fItransformations\fP\fB);\fP
    63175
     176\fI\fB
     177
     178\fI\fB
     179
    64180\fBvoid png_do_read_invert_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
    65181
     182\fI\fB
     183
     184\fI\fB
     185
    66186\fBvoid png_do_read_swap_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
    67187
     188\fI\fB
     189
     190\fI\fB
     191
    68192\fBvoid png_do_read_transformations (png_structp \fIpng_ptr\fP\fB);\fP
    69193
     194\fI\fB
     195
     196\fI\fB
     197
    70198\fBint png_do_rgb_to_gray (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
    71199
     200\fI\fB
     201
     202\fI\fB
     203
    72204\fBvoid png_do_shift (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_8p \fIbit_depth\fP\fB);\fP
    73205
     206\fI\fB
     207
     208\fI\fB
     209
    74210\fBvoid png_do_strip_filler (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fIflags\fP\fB);\fP
    75211
     212\fI\fB
     213
     214\fI\fB
     215
    76216\fBvoid png_do_swap (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
    77217
     218\fI\fB
     219
     220\fI\fB
     221
    78222\fBvoid png_do_unpack (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
    79223
     224\fI\fB
     225
     226\fI\fB
     227
    80228\fBvoid png_do_unshift (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_8p \fIsig_bits\fP\fB);\fP
    81229
     230\fI\fB
     231
     232\fI\fB
     233
    82234\fBvoid png_do_write_interlace (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fIpass\fP\fB);\fP
    83235
     236\fI\fB
     237
     238\fI\fB
     239
    84240\fBvoid png_do_write_invert_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
    85241
     242\fI\fB
     243
     244\fI\fB
     245
    86246\fBvoid png_do_write_swap_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP
    87247
     248\fI\fB
     249
     250\fI\fB
     251
    88252\fBvoid png_do_write_transformations (png_structp \fIpng_ptr\fP\fB);\fP
    89253
     254\fI\fB
     255
     256\fI\fB
     257
    90258\fBvoid *png_far_to_near (png_structp png_ptr,png_voidp \fP\fIptr\fP\fB, int \fIcheck\fP\fB);\fP
    91259
     260\fI\fB
     261
     262\fI\fB
     263
    92264\fBvoid png_flush (png_structp \fIpng_ptr\fP\fB);\fP
    93265
     266\fI\fB
     267
     268\fI\fB
     269
    94270\fBvoid png_handle_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    95271
     272\fI\fB
     273
     274\fI\fB
     275
    96276\fBvoid png_handle_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    97277
     278\fI\fB
     279
     280\fI\fB
     281
    98282\fBvoid png_handle_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    99283
     284\fI\fB
     285
     286\fI\fB
     287
    100288\fBvoid png_handle_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    101289
     290\fI\fB
     291
     292\fI\fB
     293
    102294\fBvoid png_handle_IEND (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    103295
     296\fI\fB
     297
     298\fI\fB
     299
    104300\fBvoid png_handle_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    105301
     302\fI\fB
     303
     304\fI\fB
     305
    106306\fBvoid png_handle_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    107307
     308\fI\fB
     309
     310\fI\fB
     311
    108312\fBvoid png_handle_iTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    109313
     314\fI\fB
     315
     316\fI\fB
     317
    110318\fBvoid png_handle_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    111319
     320\fI\fB
     321
     322\fI\fB
     323
    112324\fBvoid png_handle_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    113325
     326\fI\fB
     327
     328\fI\fB
     329
    114330\fBvoid png_handle_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    115331
     332\fI\fB
     333
     334\fI\fB
     335
    116336\fBvoid png_handle_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    117337
     338\fI\fB
     339
     340\fI\fB
     341
    118342\fBvoid png_handle_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    119343
     344\fI\fB
     345
     346\fI\fB
     347
    120348\fBvoid png_handle_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    121349
     350\fI\fB
     351
     352\fI\fB
     353
    122354\fBvoid png_handle_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    123355
     356\fI\fB
     357
     358\fI\fB
     359
    124360\fBvoid png_handle_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    125361
     362\fI\fB
     363
     364\fI\fB
     365
    126366\fBvoid png_handle_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    127367
     368\fI\fB
     369
     370\fI\fB
     371
    128372\fBvoid png_handle_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    129373
     374\fI\fB
     375
     376\fI\fB
     377
    130378\fBvoid png_handle_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    131379
     380\fI\fB
     381
     382\fI\fB
     383
    132384\fBvoid png_handle_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    133385
     386\fI\fB
     387
     388\fI\fB
     389
    134390\fBvoid png_handle_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    135391
     392\fI\fB
     393
     394\fI\fB
     395
    136396\fBvoid png_info_destroy (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    137397
     398\fI\fB
     399
     400\fI\fB
     401
    138402\fBvoid png_init_mmx_flags (png_structp \fIpng_ptr\fP\fB);\fP
    139403
     404\fI\fB
     405
     406\fI\fB
     407
    140408\fBvoid png_init_read_transformations (png_structp \fIpng_ptr\fP\fB);\fP
    141409
     410\fI\fB
     411
     412\fI\fB
     413
    142414\fBvoid png_process_IDAT_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_length\fP\fB);\fP
    143415
     416\fI\fB
     417
     418\fI\fB
     419
    144420\fBvoid png_process_some_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    145421
     422\fI\fB
     423
     424\fI\fB
     425
    146426\fBvoid png_push_check_crc (png_structp \fIpng_ptr\fP\fB);\fP
    147427
     428\fI\fB
     429
     430\fI\fB
     431
    148432\fBvoid png_push_crc_finish (png_structp \fIpng_ptr\fP\fB);\fP
    149433
     434\fI\fB
     435
     436\fI\fB
     437
    150438\fBvoid png_push_crc_skip (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    151439
     440\fI\fB
     441
     442\fI\fB
     443
    152444\fBvoid png_push_fill_buffer (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIlength\fP\fB);\fP
    153445
     446\fI\fB
     447
     448\fI\fB
     449
    154450\fBvoid png_push_handle_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    155451
     452\fI\fB
     453
     454\fI\fB
     455
    156456\fBvoid png_push_handle_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    157457
     458\fI\fB
     459
     460\fI\fB
     461
    158462\fBvoid png_push_handle_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
    159463
     464\fI\fB
     465
     466\fI\fB
     467
    160468\fBvoid png_push_have_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    161469
     470\fI\fB
     471
     472\fI\fB
     473
    162474\fBvoid png_push_have_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    163475
     476\fI\fB
     477
     478\fI\fB
     479
    164480\fBvoid png_push_have_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIrow\fP\fB);\fP
    165481
     482\fI\fB
     483
     484\fI\fB
     485
    166486\fBvoid png_push_process_row (png_structp \fIpng_ptr\fP\fB);\fP
    167487
     488\fI\fB
     489
     490\fI\fB
     491
    168492\fBvoid png_push_read_chunk (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    169493
     494\fI\fB
     495
     496\fI\fB
     497
    170498\fBvoid png_push_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    171499
     500\fI\fB
     501
     502\fI\fB
     503
    172504\fBvoid png_push_read_IDAT (png_structp \fIpng_ptr\fP\fB);\fP
    173505
     506\fI\fB
     507
     508\fI\fB
     509
    174510\fBvoid png_push_read_sig (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    175511
     512\fI\fB
     513
     514\fI\fB
     515
    176516\fBvoid png_push_read_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    177517
     518\fI\fB
     519
     520\fI\fB
     521
    178522\fBvoid png_push_read_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    179523
     524\fI\fB
     525
     526\fI\fB
     527
    180528\fBvoid png_push_restore_buffer (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_length\fP\fB);\fP
    181529
     530\fI\fB
     531
     532\fI\fB
     533
    182534\fBvoid png_push_save_buffer (png_structp \fIpng_ptr\fP\fB);\fP
    183535
     536\fI\fB
     537
     538\fI\fB
     539
     540\fBpng_uint_32 png_read_chunk_header (png_structp \fIpng_ptr\fP\fB);\fP
     541
     542\fI\fB
     543
     544\fI\fB
     545
    184546\fBvoid png_read_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP
    185547
     548\fI\fB
     549
     550\fI\fB
     551
    186552\fBvoid png_read_filter_row (png_structp \fP\fIpng_ptr\fP\fB, png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIprev_row\fP\fB, int \fIfilter\fP\fB);\fP
    187553
     554\fI\fB
     555
     556\fI\fB
     557
    188558\fBvoid png_read_finish_row (png_structp \fIpng_ptr\fP\fB);\fP
    189559
     560\fI\fB
     561
     562\fI\fB
     563
    190564\fBvoid png_read_push_finish_row (png_structp \fIpng_ptr\fP\fB);\fP
    191565
     566\fI\fB
     567
     568\fI\fB
     569
    192570\fBvoid png_read_start_row (png_structp \fIpng_ptr\fP\fB);\fP
    193571
     572\fI\fB
     573
     574\fI\fB
     575
    194576\fBvoid png_read_transform_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
    195577
     578\fI\fB
     579
     580\fI\fB
     581
    196582\fBvoid png_reset_crc (png_structp \fIpng_ptr\fP\fB);\fP
    197583
     584\fI\fB
     585
     586\fI\fB
     587
    198588\fBint png_set_text_2 (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
    199589
     590\fI\fB
     591
     592\fI\fB
     593
    200594\fBvoid png_write_cHRM (png_structp \fP\fIpng_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
    201595
     596\fI\fB
     597
     598\fI\fB
     599
    202600\fBvoid png_write_cHRM_fixed (png_structp \fP\fIpng_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
    203601
     602\fI\fB
     603
     604\fI\fB
     605
    204606\fBvoid png_write_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP
    205607
     608\fI\fB
     609
     610\fI\fB
     611
    206612\fBvoid png_write_filtered_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIfiltered_row\fP\fB);\fP
    207613
     614\fI\fB
     615
     616\fI\fB
     617
    208618\fBvoid png_write_find_filter (png_structp \fP\fIpng_ptr\fP\fB, png_row_infop \fIrow_info\fP\fB);\fP
    209619
     620\fI\fB
     621
     622\fI\fB
     623
    210624\fBvoid png_write_finish_row (png_structp \fIpng_ptr\fP\fB);\fP
    211625
     626\fI\fB
     627
     628\fI\fB
     629
    212630\fBvoid png_write_gAMA (png_structp \fP\fIpng_ptr\fP\fB, double \fIfile_gamma\fP\fB);\fP
    213631
     632\fI\fB
     633
     634\fI\fB
     635
    214636\fBvoid png_write_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIint_file_gamma\fP\fB);\fP
    215637
     638\fI\fB
     639
     640\fI\fB
     641
    216642\fBvoid png_write_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_uint_16p \fP\fIhist\fP\fB, int \fInum_hist\fP\fB);\fP
    217643
     644\fI\fB
     645
     646\fI\fB
     647
    218648\fBvoid png_write_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_charp \fP\fIprofile\fP\fB, int \fIproflen\fP\fB);\fP
    219649
     650\fI\fB
     651
     652\fI\fB
     653
    220654\fBvoid png_write_IDAT (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP
    221655
     656\fI\fB
     657
     658\fI\fB
     659
    222660\fBvoid png_write_IEND (png_structp \fIpng_ptr\fP\fB);\fP
    223661
     662\fI\fB
     663
     664\fI\fB
     665
    224666\fBvoid png_write_IHDR (png_structp \fP\fIpng_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\fIcompression_type\fP\fB, int \fP\fIfilter_type\fP\fB, int \fIinterlace_type\fP\fB);\fP
    225667
     668\fI\fB
     669
     670\fI\fB
     671
    226672\fBvoid png_write_iTXt (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcompression\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fIlang\fP\fB, png_charp \fP\fItranslated_key\fP\fB, png_charp \fItext\fP\fB);\fP
    227673
     674\fI\fB
     675
     676\fI\fB
     677
    228678\fBvoid png_write_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIx_offset\fP\fB, png_uint_32 \fP\fIy_offset\fP\fB, int \fIunit_type\fP\fB);\fP
    229679
     680\fI\fB
     681
     682\fI\fB
     683
    230684\fBvoid png_write_pCAL (png_structp \fP\fIpng_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
    231685
     686\fI\fB
     687
     688\fI\fB
     689
    232690\fBvoid png_write_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIx_pixels_per_unit\fP\fB, png_uint_32 \fP\fIy_pixels_per_unit\fP\fB, int \fIunit_type\fP\fB);\fP
    233691
     692\fI\fB
     693
     694\fI\fB
     695
    234696\fBvoid png_write_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, png_uint_32 \fInum_pal\fP\fB);\fP
    235697
     698\fI\fB
     699
     700\fI\fB
     701
    236702\fBvoid png_write_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fP\fIsbit\fP\fB, int \fIcolor_type\fP\fB);\fP
    237703
     704\fI\fB
     705
     706\fI\fB
     707
    238708\fBvoid png_write_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, double \fP\fIwidth\fP\fB, double \fIheight\fP\fB);\fP
    239709
     710\fI\fB
     711
     712\fI\fB
     713
    240714\fBvoid png_write_sCAL_s (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, png_charp \fP\fIwidth\fP\fB, png_charp \fIheight\fP\fB);\fP
    241715
     716\fI\fB
     717
     718\fI\fB
     719
    242720\fBvoid png_write_sig (png_structp \fIpng_ptr\fP\fB);\fP
    243721
     722\fI\fB
     723
     724\fI\fB
     725
    244726\fBvoid png_write_sRGB (png_structp \fP\fIpng_ptr\fP\fB, int \fIintent\fP\fB);\fP
    245727
     728\fI\fB
     729
     730\fI\fB
     731
    246732\fBvoid png_write_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_spalette_p \fIpalette\fP\fB);\fP
    247733
     734\fI\fB
     735
     736\fI\fB
     737
    248738\fBvoid png_write_start_row (png_structp \fIpng_ptr\fP\fB);\fP
    249739
     740\fI\fB
     741
     742\fI\fB
     743
    250744\fBvoid png_write_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fItext\fP\fB, png_size_t \fItext_len\fP\fB);\fP
    251745
     746\fI\fB
     747
     748\fI\fB
     749
    252750\fBvoid png_write_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_timep \fImod_time\fP\fB);\fP
    253751
     752\fI\fB
     753
     754\fI\fB
     755
    254756\fBvoid png_write_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fItrans\fP\fB, png_color_16p \fP\fIvalues\fP\fB, int \fP\fInumber\fP\fB, int \fIcolor_type\fP\fB);\fP
    255757
     758\fI\fB
     759
     760\fI\fB
     761
    256762\fBvoid png_write_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fItext\fP\fB, png_size_t \fP\fItext_len\fP\fB, int \fIcompression\fP\fB);\fP
    257763
     764\fI\fB
     765
     766\fI\fB
     767
    258768\fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP
    259769
     770\fI\fB
     771
     772\fI\fB
     773
    260774\fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP
     775
     776\fI\fB
    261777
    262778\fI\fB
  • trunk/src/3rdparty/libpng/png.5

    r2 r561  
    1 .TH PNG 5 "May 8, 2008"
     1.TH PNG 5 "September 10, 2009"
    22.SH NAME
    33png \- Portable Network Graphics (PNG) format
  • trunk/src/3rdparty/libpng/png.c

    r2 r561  
    22/* png.c - location for general purpose libpng functions
    33 *
    4  * Last changed in libpng 1.2.21 October 4, 2007
    5  * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2007 Glenn Randers-Pehrson
     4 * Last changed in libpng 1.2.39 [August 13, 2009]
     5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
    76 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    87 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     8 *
     9 * This code is released under the libpng license.
     10 * For conditions of distribution and use, see the disclaimer
     11 * and license in png.h
    912 */
    1013
     
    1417
    1518/* Generate a compiler error if there is an old png.h in the search path. */
    16 typedef version_1_2_29 Your_png_h_is_not_version_1_2_29;
     19typedef version_1_2_40 Your_png_h_is_not_version_1_2_40;
    1720
    1821/* Version information for C files.  This had better match the version
     
    5457
    5558#ifdef PNG_READ_SUPPORTED
    56 /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    57 
    58 /* start of interlace block */
     59/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
     60
     61/* Start of interlace block */
    5962PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
    6063
    61 /* offset to next interlace block */
     64/* Offset to next interlace block */
    6265PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
    6366
    64 /* start of interlace block in the y direction */
     67/* Start of interlace block in the y direction */
    6568PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
    6669
    67 /* offset to next interlace block in the y direction */
     70/* Offset to next interlace block in the y direction */
    6871PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
    6972
     
    9396png_set_sig_bytes(png_structp png_ptr, int num_bytes)
    9497{
    95    if(png_ptr == NULL) return;
    96    png_debug(1, "in png_set_sig_bytes\n");
     98   if (png_ptr == NULL)
     99      return;
     100   png_debug(1, "in png_set_sig_bytes");
    97101   if (num_bytes > 8)
    98102      png_error(png_ptr, "Too many bytes for PNG signature.");
     
    145149voidpf PNGAPI
    146150#else
    147 voidpf /* private */
     151voidpf /* PRIVATE */
    148152#endif
    149153png_zalloc(voidpf png_ptr, uInt items, uInt size)
     
    154158   png_uint_32 num_bytes;
    155159
    156    if(png_ptr == NULL) return (NULL);
     160   if (png_ptr == NULL)
     161      return (NULL);
    157162   if (items > PNG_UINT_32_MAX/size)
    158163   {
     
    184189}
    185190
    186 /* function to free memory for zlib */
     191/* Function to free memory for zlib */
    187192#ifdef PNG_1_0_X
    188193void PNGAPI
    189194#else
    190 void /* private */
     195void /* PRIVATE */
    191196#endif
    192197png_zfree(voidpf png_ptr, voidpf ptr)
     
    241246   png_infop info_ptr;
    242247
    243    png_debug(1, "in png_create_info_struct\n");
    244    if(png_ptr == NULL) return (NULL);
     248   png_debug(1, "in png_create_info_struct");
     249   if (png_ptr == NULL)
     250      return (NULL);
    245251#ifdef PNG_USER_MEM_SUPPORTED
    246252   info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO,
     
    264270{
    265271   png_infop info_ptr = NULL;
    266    if(png_ptr == NULL) return;
    267 
    268    png_debug(1, "in png_destroy_info_struct\n");
     272   if (png_ptr == NULL)
     273      return;
     274
     275   png_debug(1, "in png_destroy_info_struct");
    269276   if (info_ptr_ptr != NULL)
    270277      info_ptr = *info_ptr_ptr;
     
    303310   png_infop info_ptr = *ptr_ptr;
    304311
    305    if(info_ptr == NULL) return;
    306 
    307    png_debug(1, "in png_info_init_3\n");
    308 
    309    if(png_sizeof(png_info) > png_info_struct_size)
    310      {
    311        png_destroy_struct(info_ptr);
    312        info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO);
    313        *ptr_ptr = info_ptr;
    314      }
    315 
    316    /* set everything to 0 */
    317    png_memset(info_ptr, 0, png_sizeof (png_info));
     312   if (info_ptr == NULL)
     313      return;
     314
     315   png_debug(1, "in png_info_init_3");
     316
     317   if (png_sizeof(png_info) > png_info_struct_size)
     318   {
     319      png_destroy_struct(info_ptr);
     320      info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO);
     321      *ptr_ptr = info_ptr;
     322   }
     323
     324   /* Set everything to 0 */
     325   png_memset(info_ptr, 0, png_sizeof(png_info));
    318326}
    319327
     
    323331   int freer, png_uint_32 mask)
    324332{
    325    png_debug(1, "in png_data_freer\n");
     333   png_debug(1, "in png_data_freer");
    326334   if (png_ptr == NULL || info_ptr == NULL)
    327335      return;
    328    if(freer == PNG_DESTROY_WILL_FREE_DATA)
     336   if (freer == PNG_DESTROY_WILL_FREE_DATA)
    329337      info_ptr->free_me |= mask;
    330    else if(freer == PNG_USER_WILL_FREE_DATA)
     338   else if (freer == PNG_USER_WILL_FREE_DATA)
    331339      info_ptr->free_me &= ~mask;
    332340   else
     
    340348   int num)
    341349{
    342    png_debug(1, "in png_free_data\n");
     350   png_debug(1, "in png_free_data");
    343351   if (png_ptr == NULL || info_ptr == NULL)
    344352      return;
    345353
    346354#if defined(PNG_TEXT_SUPPORTED)
    347 /* free text item num or (if num == -1) all text items */
    348 #ifdef PNG_FREE_ME_SUPPORTED
    349 if ((mask & PNG_FREE_TEXT) & info_ptr->free_me)
    350 #else
    351 if (mask & PNG_FREE_TEXT)
    352 #endif
    353 {
    354    if (num != -1)
    355    {
    356      if (info_ptr->text && info_ptr->text[num].key)
    357      {
    358          png_free(png_ptr, info_ptr->text[num].key);
    359          info_ptr->text[num].key = NULL;
    360      }
    361    }
     355   /* Free text item num or (if num == -1) all text items */
     356#ifdef PNG_FREE_ME_SUPPORTED
     357   if ((mask & PNG_FREE_TEXT) & info_ptr->free_me)
     358#else
     359   if (mask & PNG_FREE_TEXT)
     360#endif
     361   {
     362      if (num != -1)
     363      {
     364         if (info_ptr->text && info_ptr->text[num].key)
     365         {
     366            png_free(png_ptr, info_ptr->text[num].key);
     367            info_ptr->text[num].key = NULL;
     368         }
     369      }
     370      else
     371      {
     372         int i;
     373         for (i = 0; i < info_ptr->num_text; i++)
     374             png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i);
     375         png_free(png_ptr, info_ptr->text);
     376         info_ptr->text = NULL;
     377         info_ptr->num_text=0;
     378      }
     379   }
     380#endif
     381
     382#if defined(PNG_tRNS_SUPPORTED)
     383   /* Free any tRNS entry */
     384#ifdef PNG_FREE_ME_SUPPORTED
     385   if ((mask & PNG_FREE_TRNS) & info_ptr->free_me)
     386#else
     387   if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS))
     388#endif
     389   {
     390      png_free(png_ptr, info_ptr->trans);
     391      info_ptr->trans = NULL;
     392      info_ptr->valid &= ~PNG_INFO_tRNS;
     393#ifndef PNG_FREE_ME_SUPPORTED
     394      png_ptr->flags &= ~PNG_FLAG_FREE_TRNS;
     395#endif
     396   }
     397#endif
     398
     399#if defined(PNG_sCAL_SUPPORTED)
     400   /* Free any sCAL entry */
     401#ifdef PNG_FREE_ME_SUPPORTED
     402   if ((mask & PNG_FREE_SCAL) & info_ptr->free_me)
     403#else
     404   if (mask & PNG_FREE_SCAL)
     405#endif
     406   {
     407#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
     408      png_free(png_ptr, info_ptr->scal_s_width);
     409      png_free(png_ptr, info_ptr->scal_s_height);
     410      info_ptr->scal_s_width = NULL;
     411      info_ptr->scal_s_height = NULL;
     412#endif
     413      info_ptr->valid &= ~PNG_INFO_sCAL;
     414   }
     415#endif
     416
     417#if defined(PNG_pCAL_SUPPORTED)
     418   /* Free any pCAL entry */
     419#ifdef PNG_FREE_ME_SUPPORTED
     420   if ((mask & PNG_FREE_PCAL) & info_ptr->free_me)
     421#else
     422   if (mask & PNG_FREE_PCAL)
     423#endif
     424   {
     425      png_free(png_ptr, info_ptr->pcal_purpose);
     426      png_free(png_ptr, info_ptr->pcal_units);
     427      info_ptr->pcal_purpose = NULL;
     428      info_ptr->pcal_units = NULL;
     429      if (info_ptr->pcal_params != NULL)
     430         {
     431            int i;
     432            for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
     433            {
     434               png_free(png_ptr, info_ptr->pcal_params[i]);
     435               info_ptr->pcal_params[i]=NULL;
     436            }
     437            png_free(png_ptr, info_ptr->pcal_params);
     438            info_ptr->pcal_params = NULL;
     439         }
     440      info_ptr->valid &= ~PNG_INFO_pCAL;
     441   }
     442#endif
     443
     444#if defined(PNG_iCCP_SUPPORTED)
     445   /* Free any iCCP entry */
     446#ifdef PNG_FREE_ME_SUPPORTED
     447   if ((mask & PNG_FREE_ICCP) & info_ptr->free_me)
     448#else
     449   if (mask & PNG_FREE_ICCP)
     450#endif
     451   {
     452      png_free(png_ptr, info_ptr->iccp_name);
     453      png_free(png_ptr, info_ptr->iccp_profile);
     454      info_ptr->iccp_name = NULL;
     455      info_ptr->iccp_profile = NULL;
     456      info_ptr->valid &= ~PNG_INFO_iCCP;
     457   }
     458#endif
     459
     460#if defined(PNG_sPLT_SUPPORTED)
     461   /* Free a given sPLT entry, or (if num == -1) all sPLT entries */
     462#ifdef PNG_FREE_ME_SUPPORTED
     463   if ((mask & PNG_FREE_SPLT) & info_ptr->free_me)
     464#else
     465   if (mask & PNG_FREE_SPLT)
     466#endif
     467   {
     468      if (num != -1)
     469      {
     470         if (info_ptr->splt_palettes)
     471         {
     472            png_free(png_ptr, info_ptr->splt_palettes[num].name);
     473            png_free(png_ptr, info_ptr->splt_palettes[num].entries);
     474            info_ptr->splt_palettes[num].name = NULL;
     475            info_ptr->splt_palettes[num].entries = NULL;
     476         }
     477      }
     478      else
     479      {
     480         if (info_ptr->splt_palettes_num)
     481         {
     482            int i;
     483            for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
     484               png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i);
     485
     486            png_free(png_ptr, info_ptr->splt_palettes);
     487            info_ptr->splt_palettes = NULL;
     488            info_ptr->splt_palettes_num = 0;
     489         }
     490         info_ptr->valid &= ~PNG_INFO_sPLT;
     491      }
     492   }
     493#endif
     494
     495#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
     496   if (png_ptr->unknown_chunk.data)
     497   {
     498      png_free(png_ptr, png_ptr->unknown_chunk.data);
     499      png_ptr->unknown_chunk.data = NULL;
     500   }
     501
     502#ifdef PNG_FREE_ME_SUPPORTED
     503   if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)
     504#else
     505   if (mask & PNG_FREE_UNKN)
     506#endif
     507   {
     508      if (num != -1)
     509      {
     510          if (info_ptr->unknown_chunks)
     511          {
     512             png_free(png_ptr, info_ptr->unknown_chunks[num].data);
     513             info_ptr->unknown_chunks[num].data = NULL;
     514          }
     515      }
     516      else
     517      {
     518         int i;
     519
     520         if (info_ptr->unknown_chunks_num)
     521         {
     522            for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++)
     523               png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i);
     524
     525            png_free(png_ptr, info_ptr->unknown_chunks);
     526            info_ptr->unknown_chunks = NULL;
     527            info_ptr->unknown_chunks_num = 0;
     528         }
     529      }
     530   }
     531#endif
     532
     533#if defined(PNG_hIST_SUPPORTED)
     534   /* Free any hIST entry */
     535#ifdef PNG_FREE_ME_SUPPORTED
     536   if ((mask & PNG_FREE_HIST)  & info_ptr->free_me)
     537#else
     538   if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST))
     539#endif
     540   {
     541      png_free(png_ptr, info_ptr->hist);
     542      info_ptr->hist = NULL;
     543      info_ptr->valid &= ~PNG_INFO_hIST;
     544#ifndef PNG_FREE_ME_SUPPORTED
     545      png_ptr->flags &= ~PNG_FLAG_FREE_HIST;
     546#endif
     547   }
     548#endif
     549
     550   /* Free any PLTE entry that was internally allocated */
     551#ifdef PNG_FREE_ME_SUPPORTED
     552   if ((mask & PNG_FREE_PLTE) & info_ptr->free_me)
     553#else
     554   if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE))
     555#endif
     556   {
     557      png_zfree(png_ptr, info_ptr->palette);
     558      info_ptr->palette = NULL;
     559      info_ptr->valid &= ~PNG_INFO_PLTE;
     560#ifndef PNG_FREE_ME_SUPPORTED
     561      png_ptr->flags &= ~PNG_FLAG_FREE_PLTE;
     562#endif
     563      info_ptr->num_palette = 0;
     564   }
     565
     566#if defined(PNG_INFO_IMAGE_SUPPORTED)
     567   /* Free any image bits attached to the info structure */
     568#ifdef PNG_FREE_ME_SUPPORTED
     569   if ((mask & PNG_FREE_ROWS) & info_ptr->free_me)
     570#else
     571   if (mask & PNG_FREE_ROWS)
     572#endif
     573   {
     574      if (info_ptr->row_pointers)
     575      {
     576         int row;
     577         for (row = 0; row < (int)info_ptr->height; row++)
     578         {
     579            png_free(png_ptr, info_ptr->row_pointers[row]);
     580            info_ptr->row_pointers[row]=NULL;
     581         }
     582         png_free(png_ptr, info_ptr->row_pointers);
     583         info_ptr->row_pointers=NULL;
     584      }
     585      info_ptr->valid &= ~PNG_INFO_IDAT;
     586   }
     587#endif
     588
     589#ifdef PNG_FREE_ME_SUPPORTED
     590   if (num == -1)
     591      info_ptr->free_me &= ~mask;
    362592   else
    363    {
    364        int i;
    365        for (i = 0; i < info_ptr->num_text; i++)
    366            png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i);
    367        png_free(png_ptr, info_ptr->text);
    368        info_ptr->text = NULL;
    369        info_ptr->num_text=0;
    370    }
    371 }
    372 #endif
    373 
    374 #if defined(PNG_tRNS_SUPPORTED)
    375 /* free any tRNS entry */
    376 #ifdef PNG_FREE_ME_SUPPORTED
    377 if ((mask & PNG_FREE_TRNS) & info_ptr->free_me)
    378 #else
    379 if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS))
    380 #endif
    381 {
    382     png_free(png_ptr, info_ptr->trans);
    383     info_ptr->valid &= ~PNG_INFO_tRNS;
    384 #ifndef PNG_FREE_ME_SUPPORTED
    385     png_ptr->flags &= ~PNG_FLAG_FREE_TRNS;
    386 #endif
    387     info_ptr->trans = NULL;
    388 }
    389 #endif
    390 
    391 #if defined(PNG_sCAL_SUPPORTED)
    392 /* free any sCAL entry */
    393 #ifdef PNG_FREE_ME_SUPPORTED
    394 if ((mask & PNG_FREE_SCAL) & info_ptr->free_me)
    395 #else
    396 if (mask & PNG_FREE_SCAL)
    397 #endif
    398 {
    399 #if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
    400     png_free(png_ptr, info_ptr->scal_s_width);
    401     png_free(png_ptr, info_ptr->scal_s_height);
    402     info_ptr->scal_s_width = NULL;
    403     info_ptr->scal_s_height = NULL;
    404 #endif
    405     info_ptr->valid &= ~PNG_INFO_sCAL;
    406 }
    407 #endif
    408 
    409 #if defined(PNG_pCAL_SUPPORTED)
    410 /* free any pCAL entry */
    411 #ifdef PNG_FREE_ME_SUPPORTED
    412 if ((mask & PNG_FREE_PCAL) & info_ptr->free_me)
    413 #else
    414 if (mask & PNG_FREE_PCAL)
    415 #endif
    416 {
    417     png_free(png_ptr, info_ptr->pcal_purpose);
    418     png_free(png_ptr, info_ptr->pcal_units);
    419     info_ptr->pcal_purpose = NULL;
    420     info_ptr->pcal_units = NULL;
    421     if (info_ptr->pcal_params != NULL)
    422     {
    423         int i;
    424         for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
    425         {
    426           png_free(png_ptr, info_ptr->pcal_params[i]);
    427           info_ptr->pcal_params[i]=NULL;
    428         }
    429         png_free(png_ptr, info_ptr->pcal_params);
    430         info_ptr->pcal_params = NULL;
    431     }
    432     info_ptr->valid &= ~PNG_INFO_pCAL;
    433 }
    434 #endif
    435 
    436 #if defined(PNG_iCCP_SUPPORTED)
    437 /* free any iCCP entry */
    438 #ifdef PNG_FREE_ME_SUPPORTED
    439 if ((mask & PNG_FREE_ICCP) & info_ptr->free_me)
    440 #else
    441 if (mask & PNG_FREE_ICCP)
    442 #endif
    443 {
    444     png_free(png_ptr, info_ptr->iccp_name);
    445     png_free(png_ptr, info_ptr->iccp_profile);
    446     info_ptr->iccp_name = NULL;
    447     info_ptr->iccp_profile = NULL;
    448     info_ptr->valid &= ~PNG_INFO_iCCP;
    449 }
    450 #endif
    451 
    452 #if defined(PNG_sPLT_SUPPORTED)
    453 /* free a given sPLT entry, or (if num == -1) all sPLT entries */
    454 #ifdef PNG_FREE_ME_SUPPORTED
    455 if ((mask & PNG_FREE_SPLT) & info_ptr->free_me)
    456 #else
    457 if (mask & PNG_FREE_SPLT)
    458 #endif
    459 {
    460    if (num != -1)
    461    {
    462       if(info_ptr->splt_palettes)
    463       {
    464           png_free(png_ptr, info_ptr->splt_palettes[num].name);
    465           png_free(png_ptr, info_ptr->splt_palettes[num].entries);
    466           info_ptr->splt_palettes[num].name = NULL;
    467           info_ptr->splt_palettes[num].entries = NULL;
    468       }
    469    }
    470    else
    471    {
    472        if(info_ptr->splt_palettes_num)
    473        {
    474          int i;
    475          for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
    476             png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i);
    477 
    478          png_free(png_ptr, info_ptr->splt_palettes);
    479          info_ptr->splt_palettes = NULL;
    480          info_ptr->splt_palettes_num = 0;
    481        }
    482        info_ptr->valid &= ~PNG_INFO_sPLT;
    483    }
    484 }
    485 #endif
    486 
    487 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
    488   if(png_ptr->unknown_chunk.data)
    489   {
    490     png_free(png_ptr, png_ptr->unknown_chunk.data);
    491     png_ptr->unknown_chunk.data = NULL;
    492   }
    493 #ifdef PNG_FREE_ME_SUPPORTED
    494 if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)
    495 #else
    496 if (mask & PNG_FREE_UNKN)
    497 #endif
    498 {
    499    if (num != -1)
    500    {
    501        if(info_ptr->unknown_chunks)
    502        {
    503           png_free(png_ptr, info_ptr->unknown_chunks[num].data);
    504           info_ptr->unknown_chunks[num].data = NULL;
    505        }
    506    }
    507    else
    508    {
    509        int i;
    510 
    511        if(info_ptr->unknown_chunks_num)
    512        {
    513          for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++)
    514             png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i);
    515 
    516          png_free(png_ptr, info_ptr->unknown_chunks);
    517          info_ptr->unknown_chunks = NULL;
    518          info_ptr->unknown_chunks_num = 0;
    519        }
    520    }
    521 }
    522 #endif
    523 
    524 #if defined(PNG_hIST_SUPPORTED)
    525 /* free any hIST entry */
    526 #ifdef PNG_FREE_ME_SUPPORTED
    527 if ((mask & PNG_FREE_HIST)  & info_ptr->free_me)
    528 #else
    529 if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST))
    530 #endif
    531 {
    532     png_free(png_ptr, info_ptr->hist);
    533     info_ptr->hist = NULL;
    534     info_ptr->valid &= ~PNG_INFO_hIST;
    535 #ifndef PNG_FREE_ME_SUPPORTED
    536     png_ptr->flags &= ~PNG_FLAG_FREE_HIST;
    537 #endif
    538 }
    539 #endif
    540 
    541 /* free any PLTE entry that was internally allocated */
    542 #ifdef PNG_FREE_ME_SUPPORTED
    543 if ((mask & PNG_FREE_PLTE) & info_ptr->free_me)
    544 #else
    545 if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE))
    546 #endif
    547 {
    548     png_zfree(png_ptr, info_ptr->palette);
    549     info_ptr->palette = NULL;
    550     info_ptr->valid &= ~PNG_INFO_PLTE;
    551 #ifndef PNG_FREE_ME_SUPPORTED
    552     png_ptr->flags &= ~PNG_FLAG_FREE_PLTE;
    553 #endif
    554     info_ptr->num_palette = 0;
    555 }
    556 
    557 #if defined(PNG_INFO_IMAGE_SUPPORTED)
    558 /* free any image bits attached to the info structure */
    559 #ifdef PNG_FREE_ME_SUPPORTED
    560 if ((mask & PNG_FREE_ROWS) & info_ptr->free_me)
    561 #else
    562 if (mask & PNG_FREE_ROWS)
    563 #endif
    564 {
    565     if(info_ptr->row_pointers)
    566     {
    567        int row;
    568        for (row = 0; row < (int)info_ptr->height; row++)
    569        {
    570           png_free(png_ptr, info_ptr->row_pointers[row]);
    571           info_ptr->row_pointers[row]=NULL;
    572        }
    573        png_free(png_ptr, info_ptr->row_pointers);
    574        info_ptr->row_pointers=NULL;
    575     }
    576     info_ptr->valid &= ~PNG_INFO_IDAT;
    577 }
    578 #endif
    579 
    580 #ifdef PNG_FREE_ME_SUPPORTED
    581    if(num == -1)
    582      info_ptr->free_me &= ~mask;
    583    else
    584      info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL);
     593      info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL);
    585594#endif
    586595}
     
    593602png_info_destroy(png_structp png_ptr, png_infop info_ptr)
    594603{
    595    png_debug(1, "in png_info_destroy\n");
     604   png_debug(1, "in png_info_destroy");
    596605
    597606   png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
    598607
    599 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
     608#if defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
    600609   if (png_ptr->num_chunk_list)
    601610   {
    602        png_free(png_ptr, png_ptr->chunk_list);
    603        png_ptr->chunk_list=NULL;
    604        png_ptr->num_chunk_list=0;
     611      png_free(png_ptr, png_ptr->chunk_list);
     612      png_ptr->chunk_list=NULL;
     613      png_ptr->num_chunk_list = 0;
    605614   }
    606615#endif
     
    617626png_get_io_ptr(png_structp png_ptr)
    618627{
    619    if(png_ptr == NULL) return (NULL);
     628   if (png_ptr == NULL)
     629      return (NULL);
    620630   return (png_ptr->io_ptr);
    621631}
     
    632642png_init_io(png_structp png_ptr, png_FILE_p fp)
    633643{
    634    png_debug(1, "in png_init_io\n");
    635    if(png_ptr == NULL) return;
     644   png_debug(1, "in png_init_io");
     645   if (png_ptr == NULL)
     646      return;
    636647   png_ptr->io_ptr = (png_voidp)fp;
    637648}
     
    649660         "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
    650661
    651    if(png_ptr == NULL) return (NULL);
     662   if (png_ptr == NULL)
     663      return (NULL);
    652664   if (png_ptr->time_buffer == NULL)
    653665   {
     
    670682   {
    671683      char near_time_buf[29];
    672       png_snprintf6(near_time_buf,29,"%d %s %d %02d:%02d:%02d +0000",
     684      png_snprintf6(near_time_buf, 29, "%d %s %d %02d:%02d:%02d +0000",
    673685          ptime->day % 32, short_months[(ptime->month - 1) % 12],
    674686          ptime->year, ptime->hour % 24, ptime->minute % 60,
     
    678690   }
    679691#else
    680    png_snprintf6(png_ptr->time_buffer,29,"%d %s %d %02d:%02d:%02d +0000",
     692   png_snprintf6(png_ptr->time_buffer, 29, "%d %s %d %02d:%02d:%02d +0000",
    681693       ptime->day % 32, short_months[(ptime->month - 1) % 12],
    682694       ptime->year, ptime->hour % 24, ptime->minute % 60,
     
    693705png_get_copyright(png_structp png_ptr)
    694706{
    695    png_ptr = png_ptr;  /* silence compiler warning about unused png_ptr */
    696    return ((png_charp) "\n libpng version 1.2.29 - May 8, 2008\n\
    697    Copyright (c) 1998-2008 Glenn Randers-Pehrson\n\
     707   png_ptr = png_ptr;  /* Silence compiler warning about unused png_ptr */
     708   return ((png_charp) "\n libpng version 1.2.40 - September 10, 2009\n\
     709   Copyright (c) 1998-2009 Glenn Randers-Pehrson\n\
    698710   Copyright (c) 1996-1997 Andreas Dilger\n\
    699711   Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n");
     
    712724{
    713725   /* Version of *.c files used when building libpng */
    714    png_ptr = png_ptr;  /* silence compiler warning about unused png_ptr */
     726   png_ptr = png_ptr;  /* Silence compiler warning about unused png_ptr */
    715727   return ((png_charp) PNG_LIBPNG_VER_STRING);
    716728}
     
    720732{
    721733   /* Version of *.h files used when building libpng */
    722    png_ptr = png_ptr;  /* silence compiler warning about unused png_ptr */
     734   png_ptr = png_ptr;  /* Silence compiler warning about unused png_ptr */
    723735   return ((png_charp) PNG_LIBPNG_VER_STRING);
    724736}
     
    728740{
    729741   /* Returns longer string containing both version and date */
    730    png_ptr = png_ptr;  /* silence compiler warning about unused png_ptr */
     742   png_ptr = png_ptr;  /* Silence compiler warning about unused png_ptr */
    731743   return ((png_charp) PNG_HEADER_VERSION_STRING
    732744#ifndef PNG_READ_SUPPORTED
     
    741753png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
    742754{
    743    /* check chunk_name and return "keep" value if it's on the list, else 0 */
     755   /* Check chunk_name and return "keep" value if it's on the list, else 0 */
    744756   int i;
    745757   png_bytep p;
    746    if(png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list<=0)
     758   if (png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list<=0)
    747759      return 0;
    748    p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5;
    749    for (i = png_ptr->num_chunk_list; i; i--, p-=5)
     760   p = png_ptr->chunk_list + png_ptr->num_chunk_list*5 - 5;
     761   for (i = png_ptr->num_chunk_list; i; i--, p -= 5)
    750762      if (!png_memcmp(chunk_name, p, 4))
    751         return ((int)*(p+4));
     763        return ((int)*(p + 4));
    752764   return 0;
    753765}
     
    758770png_reset_zstream(png_structp png_ptr)
    759771{
    760    if (png_ptr == NULL) return Z_STREAM_ERROR;
     772   if (png_ptr == NULL)
     773      return Z_STREAM_ERROR;
    761774   return (inflateReset(&png_ptr->zstream));
    762775}
     
    774787#if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED)
    775788#if !defined(PNG_1_0_X)
    776 /* this function was added to libpng 1.2.0 */
     789/* This function was added to libpng 1.2.0 */
    777790int PNGAPI
    778791png_mmx_support(void)
    779792{
    780    /* obsolete, to be removed from libpng-1.4.0 */
     793   /* Obsolete, to be removed from libpng-1.4.0 */
    781794    return -1;
    782795}
     
    791804png_convert_size(size_t size)
    792805{
    793   if (size > (png_size_t)-1)
    794      PNG_ABORT();  /* We haven't got access to png_ptr, so no png_error() */
    795   return ((png_size_t)size);
     806   if (size > (png_size_t)-1)
     807      PNG_ABORT();  /* We haven't got access to png_ptr, so no png_error() */
     808   return ((png_size_t)size);
    796809}
    797810#endif /* PNG_SIZE_T */
     811
     812/* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */
     813#if defined(PNG_cHRM_SUPPORTED)
     814#if !defined(PNG_NO_CHECK_cHRM)
     815
     816/*
     817 *    Multiply two 32-bit numbers, V1 and V2, using 32-bit
     818 *    arithmetic, to produce a 64 bit result in the HI/LO words.
     819 *
     820 *                  A B
     821 *                x C D
     822 *               ------
     823 *              AD || BD
     824 *        AC || CB || 0
     825 *
     826 *    where A and B are the high and low 16-bit words of V1,
     827 *    C and D are the 16-bit words of V2, AD is the product of
     828 *    A and D, and X || Y is (X << 16) + Y.
     829*/
     830
     831void /* PRIVATE */
     832png_64bit_product (long v1, long v2, unsigned long *hi_product,
     833   unsigned long *lo_product)
     834{
     835   int a, b, c, d;
     836   long lo, hi, x, y;
     837
     838   a = (v1 >> 16) & 0xffff;
     839   b = v1 & 0xffff;
     840   c = (v2 >> 16) & 0xffff;
     841   d = v2 & 0xffff;
     842
     843   lo = b * d;                   /* BD */
     844   x = a * d + c * b;            /* AD + CB */
     845   y = ((lo >> 16) & 0xffff) + x;
     846
     847   lo = (lo & 0xffff) | ((y & 0xffff) << 16);
     848   hi = (y >> 16) & 0xffff;
     849
     850   hi += a * c;                  /* AC */
     851
     852   *hi_product = (unsigned long)hi;
     853   *lo_product = (unsigned long)lo;
     854}
     855
     856int /* PRIVATE */
     857png_check_cHRM_fixed(png_structp png_ptr,
     858   png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x,
     859   png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y,
     860   png_fixed_point blue_x, png_fixed_point blue_y)
     861{
     862   int ret = 1;
     863   unsigned long xy_hi,xy_lo,yx_hi,yx_lo;
     864
     865   png_debug(1, "in function png_check_cHRM_fixed");
     866   if (png_ptr == NULL)
     867      return 0;
     868
     869   if (white_x < 0 || white_y <= 0 ||
     870         red_x < 0 ||   red_y <  0 ||
     871       green_x < 0 || green_y <  0 ||
     872        blue_x < 0 ||  blue_y <  0)
     873   {
     874      png_warning(png_ptr,
     875        "Ignoring attempt to set negative chromaticity value");
     876      ret = 0;
     877   }
     878   if (white_x > (png_fixed_point) PNG_UINT_31_MAX ||
     879       white_y > (png_fixed_point) PNG_UINT_31_MAX ||
     880         red_x > (png_fixed_point) PNG_UINT_31_MAX ||
     881         red_y > (png_fixed_point) PNG_UINT_31_MAX ||
     882       green_x > (png_fixed_point) PNG_UINT_31_MAX ||
     883       green_y > (png_fixed_point) PNG_UINT_31_MAX ||
     884        blue_x > (png_fixed_point) PNG_UINT_31_MAX ||
     885        blue_y > (png_fixed_point) PNG_UINT_31_MAX )
     886   {
     887      png_warning(png_ptr,
     888        "Ignoring attempt to set chromaticity value exceeding 21474.83");
     889      ret = 0;
     890   }
     891   if (white_x > 100000L - white_y)
     892   {
     893      png_warning(png_ptr, "Invalid cHRM white point");
     894      ret = 0;
     895   }
     896   if (red_x > 100000L - red_y)
     897   {
     898      png_warning(png_ptr, "Invalid cHRM red point");
     899      ret = 0;
     900   }
     901   if (green_x > 100000L - green_y)
     902   {
     903      png_warning(png_ptr, "Invalid cHRM green point");
     904      ret = 0;
     905   }
     906   if (blue_x > 100000L - blue_y)
     907   {
     908      png_warning(png_ptr, "Invalid cHRM blue point");
     909      ret = 0;
     910   }
     911
     912   png_64bit_product(green_x - red_x, blue_y - red_y, &xy_hi, &xy_lo);
     913   png_64bit_product(green_y - red_y, blue_x - red_x, &yx_hi, &yx_lo);
     914
     915   if (xy_hi == yx_hi && xy_lo == yx_lo)
     916   {
     917      png_warning(png_ptr,
     918         "Ignoring attempt to set cHRM RGB triangle with zero area");
     919      ret = 0;
     920   }
     921
     922   return ret;
     923}
     924#endif /* NO_PNG_CHECK_cHRM */
     925#endif /* PNG_cHRM_SUPPORTED */
    798926#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
  • trunk/src/3rdparty/libpng/png.h

    r2 r561  
    11/* png.h - header file for PNG reference library
    22 *
    3  * libpng version 1.2.29 - May 8, 2008
    4  * Copyright (c) 1998-2008 Glenn Randers-Pehrson
     3 * libpng version 1.2.40 - September 10, 2009
     4 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
    55 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    66 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     7 *
     8 * This code is released under the libpng license (See LICENSE, below)
    79 *
    810 * Authors and maintainers:
    911 *  libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
    1012 *  libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
    11  *  libpng versions 0.97, January 1998, through 1.2.29 - May 8, 2008: Glenn
     13 *  libpng versions 0.97, January 1998, through 1.2.40 - September 10, 2009: Glenn
    1214 *  See also "Contributing Authors", below.
    1315 *
     
    193195 *    1.0.35                  10    10035  10.so.0.35[.0]
    194196 *    1.2.29                  13    10229  12.so.0.29[.0]
     197 *    1.0.37                  10    10037  10.so.0.37[.0]
     198 *    1.2.30beta01-04         13    10230  12.so.0.30[.0]
     199 *    1.0.38rc01-08           10    10038  10.so.0.38[.0]
     200 *    1.2.30rc01-08           13    10230  12.so.0.30[.0]
     201 *    1.0.38                  10    10038  10.so.0.38[.0]
     202 *    1.2.30                  13    10230  12.so.0.30[.0]
     203 *    1.0.39rc01-03           10    10039  10.so.0.39[.0]
     204 *    1.2.31rc01-03           13    10231  12.so.0.31[.0]
     205 *    1.0.39                  10    10039  10.so.0.39[.0]
     206 *    1.2.31                  13    10231  12.so.0.31[.0]
     207 *    1.2.32beta01-02         13    10232  12.so.0.32[.0]
     208 *    1.0.40rc01              10    10040  10.so.0.40[.0]
     209 *    1.2.32rc01              13    10232  12.so.0.32[.0]
     210 *    1.0.40                  10    10040  10.so.0.40[.0]
     211 *    1.2.32                  13    10232  12.so.0.32[.0]
     212 *    1.2.33beta01-02         13    10233  12.so.0.33[.0]
     213 *    1.2.33rc01-02           13    10233  12.so.0.33[.0]
     214 *    1.0.41rc01              10    10041  10.so.0.41[.0]
     215 *    1.2.33                  13    10233  12.so.0.33[.0]
     216 *    1.0.41                  10    10041  10.so.0.41[.0]
     217 *    1.2.34beta01-07         13    10234  12.so.0.34[.0]
     218 *    1.0.42rc01              10    10042  10.so.0.42[.0]
     219 *    1.2.34rc01              13    10234  12.so.0.34[.0]
     220 *    1.0.42                  10    10042  10.so.0.42[.0]
     221 *    1.2.34                  13    10234  12.so.0.34[.0]
     222 *    1.2.35beta01-03         13    10235  12.so.0.35[.0]
     223 *    1.0.43rc01-02           10    10043  10.so.0.43[.0]
     224 *    1.2.35rc01-02           13    10235  12.so.0.35[.0]
     225 *    1.0.43                  10    10043  10.so.0.43[.0]
     226 *    1.2.35                  13    10235  12.so.0.35[.0]
     227 *    1.2.36beta01-05         13    10236  12.so.0.36[.0]
     228 *    1.2.36rc01              13    10236  12.so.0.36[.0]
     229 *    1.0.44                  10    10044  10.so.0.44[.0]
     230 *    1.2.36                  13    10236  12.so.0.36[.0]
     231 *    1.2.37beta01-03         13    10237  12.so.0.37[.0]
     232 *    1.2.37rc01              13    10237  12.so.0.37[.0]
     233 *    1.2.37                  13    10237  12.so.0.37[.0]
     234 *    1.2.45                  10    10045  12.so.0.45[.0]
     235 *    1.0.46                  10    10046  10.so.0.46[.0]
     236 *    1.2.38beta01            13    10238  12.so.0.38[.0]
     237 *    1.2.38rc01-03           13    10238  12.so.0.38[.0]
     238 *    1.0.47                  10    10047  10.so.0.47[.0]
     239 *    1.2.38                  13    10238  12.so.0.38[.0]
     240 *    1.2.39beta01-05         13    10239  12.so.0.39[.0]
     241 *    1.2.39rc01              13    10239  12.so.0.39[.0]
     242 *    1.0.48                  10    10048  10.so.0.48[.0]
     243 *    1.2.39                  13    10239  12.so.0.39[.0]
     244 *    1.2.40beta01            13    10240  12.so.0.40[.0]
     245 *    1.2.40rc01              13    10240  12.so.0.40[.0]
     246 *    1.0.49                  10    10049  10.so.0.49[.0]
     247 *    1.2.40                  13    10240  12.so.0.40[.0]
    195248 *
    196249 *    Henceforth the source version will match the shared-library major
     
    222275 * this sentence.
    223276 *
    224  * libpng versions 1.2.6, August 15, 2004, through 1.2.29, May 8, 2008, are
    225  * Copyright (c) 2004, 2006-2008 Glenn Randers-Pehrson, and are
     277 * This code is released under the libpng license.
     278 *
     279 * libpng versions 1.2.6, August 15, 2004, through 1.2.40, September 10, 2009, are
     280 * Copyright (c) 2004, 2006-2009 Glenn Randers-Pehrson, and are
    226281 * distributed according to the same disclaimer and license as libpng-1.2.5
    227282 * with the following individual added to the list of Contributing Authors:
     
    334389 * =========================
    335390 *
    336  *    May 8, 2008
     391 *    September 10, 2009
    337392 *
    338393 *    Since the PNG Development group is an ad-hoc body, we can't make
     
    340395 *
    341396 *    This is your unofficial assurance that libpng from version 0.71 and
    342  *    upward through 1.2.29 are Y2K compliant.  It is my belief that earlier
     397 *    upward through 1.2.40 are Y2K compliant.  It is my belief that earlier
    343398 *    versions were also Y2K compliant.
    344399 *
     
    396451
    397452/* Version information for png.h - this should match the version in png.c */
    398 #define PNG_LIBPNG_VER_STRING "1.2.29"
     453#define PNG_LIBPNG_VER_STRING "1.2.40"
    399454#define PNG_HEADER_VERSION_STRING \
    400    " libpng version 1.2.29 - May 8, 2008\n"
     455   " libpng version 1.2.40 - September 10, 2009\n"
    401456
    402457#define PNG_LIBPNG_VER_SONUM   0
     
    406461#define PNG_LIBPNG_VER_MAJOR   1
    407462#define PNG_LIBPNG_VER_MINOR   2
    408 #define PNG_LIBPNG_VER_RELEASE 29
     463#define PNG_LIBPNG_VER_RELEASE 40
    409464/* This should match the numeric part of the final component of
    410  * PNG_LIBPNG_VER_STRING, omitting any leading zero: */
     465 * PNG_LIBPNG_VER_STRING, omitting any leading zero:
     466 */
    411467
    412468#define PNG_LIBPNG_VER_BUILD  0
     
    418474#define PNG_LIBPNG_BUILD_STABLE   4
    419475#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7
    420  
     476
    421477/* Release-Specific Flags */
    422478#define PNG_LIBPNG_BUILD_PATCH    8 /* Can be OR'ed with
     
    433489 * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
    434490 * version 1.0.0 was mis-numbered 100 instead of 10000).  From
    435  * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release */
    436 #define PNG_LIBPNG_VER 10229 /* 1.2.29 */
     491 * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release
     492 */
     493#define PNG_LIBPNG_VER 10240 /* 1.2.40 */
    437494
    438495#ifndef PNG_VERSION_INFO_ONLY
    439 /* include the compression library's header */
     496/* Include the compression library's header */
    440497#include "zlib.h"
    441498#endif
    442499
    443 /* include all user configurable info, including optional assembler routines */
     500/* Include all user configurable info, including optional assembler routines */
    444501#include "pngconf.h"
    445502
     
    449506 * VS_FF_PRIVATEBUILD File *was not* built using standard release
    450507 * procedures. If this value is given, the StringFileInfo block must
    451  * contain a PrivateBuild string. 
     508 * contain a PrivateBuild string.
    452509 *
    453510 * VS_FF_SPECIALBUILD File *was* built by the original company using
    454511 * standard release procedures but is a variation of the standard
    455512 * file of the same version number. If this value is given, the
    456  * StringFileInfo block must contain a SpecialBuild string. 
     513 * StringFileInfo block must contain a SpecialBuild string.
    457514 */
    458515
     
    516573#endif
    517574
    518 /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
     575/* Variables declared in png.c - only it needs to define PNG_NO_EXTERN */
    519576#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
    520577/* Version information for C files, stored in png.c.  This had better match
     
    523580#ifdef PNG_USE_GLOBAL_ARRAYS
    524581PNG_EXPORT_VAR (PNG_CONST char) png_libpng_ver[18];
    525   /* need room for 99.99.99beta99z */
     582  /* Need room for 99.99.99beta99z */
    526583#else
    527584#define png_libpng_ver png_get_header_ver(NULL)
     
    642699
    643700/* Supported compression types for text in PNG files (tEXt, and zTXt).
    644  * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */
     701 * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed.
     702 */
    645703#define PNG_TEXT_COMPRESSION_NONE_WR -3
    646704#define PNG_TEXT_COMPRESSION_zTXt_WR -2
     
    669727typedef png_time FAR * FAR * png_timepp;
    670728
    671 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
     729#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
     730 defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
    672731/* png_unknown_chunk is a structure to hold queued chunks for which there is
    673732 * no specific support.  The idea is that we can use this to queue
     
    731790typedef struct png_info_struct
    732791{
    733    /* the following are necessary for every PNG file */
     792   /* The following are necessary for every PNG file */
    734793   png_uint_32 width;       /* width of image in pixels (from IHDR) */
    735794   png_uint_32 height;      /* height of image in pixels (from IHDR) */
     
    904963#endif
    905964
    906 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
    907    /* storage for unknown chunks that the library doesn't recognize. */
     965#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \
     966 defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
     967   /* Storage for unknown chunks that the library doesn't recognize. */
    908968   png_unknown_chunkp unknown_chunks;
    909969   png_size_t unknown_chunks_num;
     
    920980
    921981#if defined(PNG_sPLT_SUPPORTED)
    922    /* data on sPLT chunks (there may be more than one). */
     982   /* Data on sPLT chunks (there may be more than one). */
    923983   png_sPLT_tp splt_palettes;
    924984   png_uint_32 splt_palettes_num;
     
    11351195#define PNG_TRANSFORM_SWAP_ENDIAN    0x0200    /* read and write */
    11361196#define PNG_TRANSFORM_INVERT_ALPHA   0x0400    /* read and write */
    1137 #define PNG_TRANSFORM_STRIP_FILLER   0x0800    /* WRITE only */
     1197#define PNG_TRANSFORM_STRIP_FILLER   0x0800    /* write only, deprecated */
     1198/* Added to libpng-1.2.34 */
     1199#define PNG_TRANSFORM_STRIP_FILLER_BEFORE 0x0800  /* write only */
     1200#define PNG_TRANSFORM_STRIP_FILLER_AFTER  0x1000  /* write only */
    11381201
    11391202/* Flags for MNG supported features */
     
    12051268   png_bytep prev_row;        /* buffer to save previous (unfiltered) row */
    12061269   png_bytep row_buf;         /* buffer to save current (unfiltered) row */
    1207 #ifndef PNG_NO_WRITE_FILTERING
     1270#ifndef PNG_NO_WRITE_FILTER
    12081271   png_bytep sub_row;         /* buffer to save "sub" row when filtering */
    12091272   png_bytep up_row;          /* buffer to save "up" row when filtering */
     
    12521315
    12531316#if defined(PNG_WRITE_FLUSH_SUPPORTED)
    1254    png_flush_ptr output_flush_fn;/* Function for flushing output */
     1317   png_flush_ptr output_flush_fn; /* Function for flushing output */
    12551318   png_uint_32 flush_dist;    /* how many rows apart to flush, 0 - no flush */
    12561319   png_uint_32 flush_rows;    /* number of rows written since last flush */
     
    13501413
    13511414#ifdef PNG_FREE_ME_SUPPORTED
    1352    png_uint_32 free_me;       /* flags items libpng is responsible for freeing */
     1415   png_uint_32 free_me;   /* flags items libpng is responsible for freeing */
    13531416#endif
    13541417
     
    13581421#endif
    13591422
    1360 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
     1423#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
    13611424   int num_chunk_list;
    13621425   png_bytep chunk_list;
     
    13761439    defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
    13771440    defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
    1378 /* changed from png_byte to png_uint_32 at version 1.2.0 */
     1441/* Changed from png_byte to png_uint_32 at version 1.2.0 */
    13791442#ifdef PNG_1_0_X
    13801443   png_byte mng_features_permitted;
     
    14121475/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
    14131476#ifdef PNG_USER_MEM_SUPPORTED
    1414    png_voidp mem_ptr;                /* user supplied struct for mem functions */
    1415    png_malloc_ptr malloc_fn;         /* function for allocating memory */
    1416    png_free_ptr free_fn;             /* function for freeing memory */
     1477   png_voidp mem_ptr;            /* user supplied struct for mem functions */
     1478   png_malloc_ptr malloc_fn;     /* function for allocating memory */
     1479   png_free_ptr free_fn;         /* function for freeing memory */
    14171480#endif
    14181481
    14191482/* New member added in libpng-1.0.13 and 1.2.0 */
    1420    png_bytep big_row_buf;         /* buffer to save current (unfiltered) row */
     1483   png_bytep big_row_buf;        /* buffer to save current (unfiltered) row */
    14211484
    14221485#if defined(PNG_READ_DITHER_SUPPORTED)
    14231486/* The following three members were added at version 1.0.14 and 1.2.4 */
    1424    png_bytep dither_sort;            /* working sort array */
    1425    png_bytep index_to_palette;       /* where the original index currently is */
    1426                                      /* in the palette */
    1427    png_bytep palette_to_index;       /* which original index points to this */
    1428                                      /* palette color */
     1487   png_bytep dither_sort;        /* working sort array */
     1488   png_bytep index_to_palette;   /* where the original index currently is */
     1489                                 /* in the palette */
     1490   png_bytep palette_to_index;   /* which original index points to this */
     1491                                 /* palette color */
    14291492#endif
    14301493
     
    14391502/* New member added in libpng-1.0.25 and 1.2.17 */
    14401503#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
    1441    /* storage for unknown chunk that the library doesn't recognize. */
     1504   /* Storage for unknown chunk that the library doesn't recognize. */
    14421505   png_unknown_chunk unknown_chunk;
    14431506#endif
     
    14451508/* New members added in libpng-1.2.26 */
    14461509  png_uint_32 old_big_row_buf_size, old_prev_row_size;
     1510
     1511/* New member added in libpng-1.2.30 */
     1512  png_charp chunkdata;  /* buffer for reading chunk data */
     1513
    14471514};
    14481515
     
    14511518 * do not agree upon the version number.
    14521519 */
    1453 typedef png_structp version_1_2_29;
     1520typedef png_structp version_1_2_40;
    14541521
    14551522typedef png_struct FAR * FAR * png_structpp;
     
    15551622
    15561623#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
    1557 /* read the information before the actual image data. */
     1624/* Read the information before the actual image data. */
    15581625extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr,
    15591626   png_infop info_ptr));
     
    15681635/* "time.h" functions are not supported on WindowsCE */
    15691636#if defined(PNG_WRITE_tIME_SUPPORTED)
    1570 /* convert from a struct tm to png_time */
     1637/* Convert from a struct tm to png_time */
    15711638extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime,
    15721639   struct tm FAR * ttime));
    15731640
    1574 /* convert from time_t to png_time.  Uses gmtime() */
     1641/* Convert from time_t to png_time.  Uses gmtime() */
    15751642extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime,
    15761643   time_t ttime));
     
    16921759
    16931760#if defined(PNG_READ_16_TO_8_SUPPORTED)
    1694 /* strip the second byte of information from a 16-bit depth file. */
     1761/* Strip the second byte of information from a 16-bit depth file. */
    16951762extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr));
    16961763#endif
     
    17281795#endif
    17291796
    1730 /* optional update palette with requested transformations */
     1797/* Optional update palette with requested transformations */
    17311798extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr));
    17321799
    1733 /* optional call to update the users info structure */
     1800/* Optional call to update the users info structure */
    17341801extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr,
    17351802   png_infop info_ptr));
    17361803
    17371804#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
    1738 /* read one or more rows of image data. */
     1805/* Read one or more rows of image data. */
    17391806extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr,
    17401807   png_bytepp row, png_bytepp display_row, png_uint_32 num_rows));
     
    17421809
    17431810#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
    1744 /* read a row of data. */
     1811/* Read a row of data. */
    17451812extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr,
    17461813   png_bytep row,
     
    17491816
    17501817#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
    1751 /* read the whole image into memory at once. */
     1818/* Read the whole image into memory at once. */
    17521819extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr,
    17531820   png_bytepp image));
    17541821#endif
    17551822
    1756 /* write a row of image data */
     1823/* Write a row of image data */
    17571824extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr,
    17581825   png_bytep row));
    17591826
    1760 /* write a few rows of image data */
     1827/* Write a few rows of image data */
    17611828extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr,
    17621829   png_bytepp row, png_uint_32 num_rows));
    17631830
    1764 /* write the image data */
     1831/* Write the image data */
    17651832extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr,
    17661833   png_bytepp image));
    17671834
    1768 /* writes the end of the PNG file. */
     1835/* Writes the end of the PNG file. */
    17691836extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr,
    17701837   png_infop info_ptr));
    17711838
    17721839#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
    1773 /* read the end of the PNG file. */
     1840/* Read the end of the PNG file. */
    17741841extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr,
    17751842   png_infop info_ptr));
    17761843#endif
    17771844
    1778 /* free any memory associated with the png_info_struct */
     1845/* Free any memory associated with the png_info_struct */
    17791846extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr,
    17801847   png_infopp info_ptr_ptr));
    17811848
    1782 /* free any memory associated with the png_struct and the png_info_structs */
     1849/* Free any memory associated with the png_struct and the png_info_structs */
    17831850extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp
    17841851   png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr));
    17851852
    1786 /* free all memory used by the read (old method - NOT DLL EXPORTED) */
     1853/* Free all memory used by the read (old method - NOT DLL EXPORTED) */
    17871854extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
    17881855   png_infop end_info_ptr));
    17891856
    1790 /* free any memory associated with the png_struct and the png_info_structs */
     1857/* Free any memory associated with the png_struct and the png_info_structs */
    17911858extern PNG_EXPORT(void,png_destroy_write_struct)
    17921859   PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr));
    17931860
    1794 /* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
     1861/* Free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
    17951862extern void png_write_destroy PNGARG((png_structp png_ptr));
    17961863
    1797 /* set the libpng method of handling chunk CRC errors */
     1864/* Set the libpng method of handling chunk CRC errors */
    17981865extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr,
    17991866   int crit_action, int ancil_action));
     
    18231890 */
    18241891
    1825 /* set the filtering method(s) used by libpng.  Currently, the only valid
     1892/* Set the filtering method(s) used by libpng.  Currently, the only valid
    18261893 * value for "method" is 0.
    18271894 */
     
    19512018 * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time
    19522019 * output_flush_fn will be ignored (and thus can be NULL).
     2020 * It is probably a mistake to use NULL for output_flush_fn if
     2021 * write_data_fn is not also NULL unless you have built libpng with
     2022 * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's
     2023 * default flush function, which uses the standard *FILE structure, will
     2024 * be used.
    19532025 */
    19542026extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr,
     
    20152087   png_progressive_end_ptr end_fn));
    20162088
    2017 /* returns the user pointer associated with the push read functions */
     2089/* Returns the user pointer associated with the push read functions */
    20182090extern PNG_EXPORT(png_voidp,png_get_progressive_ptr)
    20192091   PNGARG((png_structp png_ptr));
    20202092
    2021 /* function to be called when data becomes available */
     2093/* Function to be called when data becomes available */
    20222094extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr,
    20232095   png_infop info_ptr, png_bytep buffer, png_size_t buffer_size));
    20242096
    2025 /* function that combines rows.  Not very much different than the
     2097/* Function that combines rows.  Not very much different than the
    20262098 * png_combine_row() call.  Is this even used?????
    20272099 */
     
    20412113#endif
    20422114
    2043 /* frees a pointer allocated by png_malloc() */
     2115/* Frees a pointer allocated by png_malloc() */
    20442116extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr));
    20452117
     
    20582130#ifdef PNG_FREE_ME_SUPPORTED
    20592131/* Reassign responsibility for freeing existing data, whether allocated
    2060  * by libpng or by the application */
     2132 * by libpng or by the application
     2133 */
    20612134extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr,
    20622135   png_infop info_ptr, int freer, png_uint_32 mask));
    20632136#endif
    2064 /* assignments for png_data_freer */
     2137/* Assignments for png_data_freer */
    20652138#define PNG_DESTROY_WILL_FREE_DATA 1
    20662139#define PNG_SET_WILL_FREE_DATA 1
     
    21462219#if defined(PNG_INFO_IMAGE_SUPPORTED)
    21472220/* Returns row_pointers, which is an array of pointers to scanlines that was
    2148 returned from png_read_png(). */
     2221 * returned from png_read_png().
     2222 */
    21492223extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr,
    21502224png_infop info_ptr));
    21512225/* Set row_pointers, which is an array of pointers to scanlines for use
    2152 by png_write_png(). */
     2226 * by png_write_png().
     2227 */
    21532228extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr,
    21542229   png_infop info_ptr, png_bytepp row_pointers));
     
    24512526#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */
    24522527
    2453 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
    2454 /* provide a list of chunks and how they are to be handled, if the built-in
     2528#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
     2529/* Provide a list of chunks and how they are to be handled, if the built-in
    24552530   handling or default unknown chunk handling is not desired.  Any chunks not
    24562531   listed will be handled in the default manner.  The IHDR and IEND chunks
     
    24632538extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp
    24642539   png_ptr, int keep, png_bytep chunk_list, int num_chunks));
     2540PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep
     2541   chunk_name));
     2542#endif
     2543#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
    24652544extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr,
    24662545   png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns));
     
    24702549   png_ptr, png_infop info_ptr, png_unknown_chunkpp entries));
    24712550#endif
    2472 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
    2473 PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep
    2474    chunk_name));
    2475 #endif
    24762551
    24772552/* Png_free_data() will turn off the "valid" flag for anything it frees.
    2478    If you need to turn it off for a chunk that your application has freed,
    2479    you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */
     2553 * If you need to turn it off for a chunk that your application has freed,
     2554 * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK);
     2555 */
    24802556extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr,
    24812557   png_infop info_ptr, int mask));
     
    25032579#include <crtdbg.h>
    25042580#if (PNG_DEBUG > 1)
    2505 #define png_debug(l,m)  _RPT0(_CRT_WARN,m)
    2506 #define png_debug1(l,m,p1)  _RPT1(_CRT_WARN,m,p1)
    2507 #define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m,p1,p2)
     2581#ifndef _DEBUG
     2582#  define _DEBUG
     2583#endif
     2584#ifndef png_debug
     2585#define png_debug(l,m)  _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE)
     2586#endif
     2587#ifndef png_debug1
     2588#define png_debug1(l,m,p1)  _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1)
     2589#endif
     2590#ifndef png_debug2
     2591#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2)
     2592#endif
    25082593#endif
    25092594#else /* PNG_DEBUG_FILE || !_MSC_VER */
     
    25112596#define PNG_DEBUG_FILE stderr
    25122597#endif /* PNG_DEBUG_FILE */
     2598
    25132599#if (PNG_DEBUG > 1)
    2514 #define png_debug(l,m) \
    2515 { \
    2516      int num_tabs=l; \
    2517      fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \
    2518        (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \
    2519 }
    2520 #define png_debug1(l,m,p1) \
    2521 { \
    2522      int num_tabs=l; \
    2523      fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \
    2524        (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \
    2525 }
    2526 #define png_debug2(l,m,p1,p2) \
    2527 { \
    2528      int num_tabs=l; \
    2529      fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \
    2530        (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \
    2531 }
     2600/* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on non-ISO
     2601 * compilers.
     2602 */
     2603#  ifdef __STDC__
     2604#    ifndef png_debug
     2605#      define png_debug(l,m) \
     2606       { \
     2607       int num_tabs=l; \
     2608       fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
     2609         (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \
     2610       }
     2611#    endif
     2612#    ifndef png_debug1
     2613#      define png_debug1(l,m,p1) \
     2614       { \
     2615       int num_tabs=l; \
     2616       fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
     2617         (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \
     2618       }
     2619#    endif
     2620#    ifndef png_debug2
     2621#      define png_debug2(l,m,p1,p2) \
     2622       { \
     2623       int num_tabs=l; \
     2624       fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
     2625         (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \
     2626       }
     2627#    endif
     2628#  else /* __STDC __ */
     2629#    ifndef png_debug
     2630#      define png_debug(l,m) \
     2631       { \
     2632       int num_tabs=l; \
     2633       char format[256]; \
     2634       snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
     2635         (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
     2636         m,PNG_STRING_NEWLINE); \
     2637       fprintf(PNG_DEBUG_FILE,format); \
     2638       }
     2639#    endif
     2640#    ifndef png_debug1
     2641#      define png_debug1(l,m,p1) \
     2642       { \
     2643       int num_tabs=l; \
     2644       char format[256]; \
     2645       snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
     2646         (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
     2647         m,PNG_STRING_NEWLINE); \
     2648       fprintf(PNG_DEBUG_FILE,format,p1); \
     2649       }
     2650#    endif
     2651#    ifndef png_debug2
     2652#      define png_debug2(l,m,p1,p2) \
     2653       { \
     2654       int num_tabs=l; \
     2655       char format[256]; \
     2656       snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
     2657         (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
     2658         m,PNG_STRING_NEWLINE); \
     2659       fprintf(PNG_DEBUG_FILE,format,p1,p2); \
     2660       }
     2661#    endif
     2662#  endif /* __STDC __ */
    25322663#endif /* (PNG_DEBUG > 1) */
     2664
    25332665#endif /* _MSC_VER */
    25342666#endif /* (PNG_DEBUG > 0) */
     
    26252757/* png.c, pnggccrd.c, or pngvcrd.c */
    26262758extern PNG_EXPORT(int,png_mmx_support) PNGARG((void));
     2759#endif /* PNG_1_0_X */
    26272760#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
    26282761
    26292762/* Strip the prepended error numbers ("#nnn ") from error and warning
    2630  * messages before passing them to the error or warning handler. */
     2763 * messages before passing them to the error or warning handler.
     2764 */
    26312765#ifdef PNG_ERROR_NUMBERS_SUPPORTED
    26322766extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp
    26332767   png_ptr, png_uint_32 strip_mode));
    26342768#endif
    2635 
    2636 #endif /* PNG_1_0_X */
    26372769
    26382770/* Added at libpng-1.2.6 */
     
    26462778#endif
    26472779
    2648 /* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */
     2780
     2781/* Maintainer: Put new public prototypes here ^, in libpng.3, and in
     2782 * project defs
     2783 */
    26492784
    26502785#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
     
    26752810       (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
    26762811
    2677 #else  /* standard method using integer division */
     2812#else  /* Standard method using integer division */
    26782813
    26792814#  define png_composite(composite, fg, alpha, bg)                            \
     
    27582893#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
    27592894
    2760 /* flags for the transformations the PNG library does on the image data */
     2895/* Flags for the transformations the PNG library does on the image data */
    27612896#define PNG_BGR                0x0001
    27622897#define PNG_INTERLACE          0x0002
     
    27922927                       /*  0x40000000L  unused */
    27932928
    2794 /* flags for png_create_struct */
     2929/* Flags for png_create_struct */
    27952930#define PNG_STRUCT_PNG   0x0001
    27962931#define PNG_STRUCT_INFO  0x0002
     
    28022937#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))
    28032938
    2804 /* flags for the png_ptr->flags rather than declaring a byte for each one */
     2939/* Flags for the png_ptr->flags rather than declaring a byte for each one */
    28052940#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY     0x0001
    28062941#define PNG_FLAG_ZLIB_CUSTOM_LEVEL        0x0002
     
    28442979                                     PNG_FLAG_CRC_CRITICAL_MASK)
    28452980
    2846 /* save typing and make code easier to understand */
     2981/* Save typing and make code easier to understand */
    28472982
    28482983#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \
     
    28572992
    28582993/* PNG_OUT_OF_RANGE returns true if value is outside the range
    2859    ideal-delta..ideal+delta.  Each argument is evaluated twice.
    2860    "ideal" and "delta" should be constants, normally simple
    2861    integers, "value" a variable. Added to libpng-1.2.6 JB */
     2994 * ideal-delta..ideal+delta.  Each argument is evaluated twice.
     2995 * "ideal" and "delta" should be constants, normally simple
     2996 * integers, "value" a variable. Added to libpng-1.2.6 JB
     2997 */
    28622998#define PNG_OUT_OF_RANGE(value, ideal, delta) \
    28632999        ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) )
    28643000
    2865 /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
     3001/* Variables declared in png.c - only it needs to define PNG_NO_EXTERN */
    28663002#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
    2867 /* place to hold the signature string for a PNG file. */
     3003/* Place to hold the signature string for a PNG file. */
    28683004#ifdef PNG_USE_GLOBAL_ARRAYS
    28693005   PNG_EXPORT_VAR (PNG_CONST png_byte FARDATA) png_sig[8];
     
    29843120
    29853121/* Next four functions are used internally as callbacks.  PNGAPI is required
    2986  * but not PNG_EXPORT.  PNGAPI added at libpng version 1.2.3. */
     3122 * but not PNG_EXPORT.  PNGAPI added at libpng version 1.2.3.
     3123 */
    29873124
    29883125PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr,
     
    30273164#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \
    30283165    defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED)
    3029 PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr,
    3030    int comp_type, png_charp chunkdata, png_size_t chunklength,
     3166PNG_EXTERN void png_decompress_chunk PNGARG((png_structp png_ptr,
     3167   int comp_type, png_size_t chunklength,
    30313168   png_size_t prefix_length, png_size_t *data_length));
    30323169#endif
     
    30493186#endif
    30503187
    3051 /* simple function to write the signature */
     3188/* Simple function to write the signature */
    30523189PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr));
    30533190
    3054 /* write various chunks */
     3191/* Write various chunks */
    30553192
    30563193/* Write the IHDR chunk, and update the png_struct with the necessary
     
    32043341#endif
    32053342
    3206 /* combine a row of data, dealing with alpha, etc. if requested */
     3343/* Combine a row of data, dealing with alpha, etc. if requested */
    32073344PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row,
    32083345   int mask));
    32093346
    32103347#if defined(PNG_READ_INTERLACING_SUPPORTED)
    3211 /* expand an interlaced row */
     3348/* Expand an interlaced row */
    32123349/* OLD pre-1.0.9 interface:
    32133350PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info,
     
    32203357
    32213358#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
    3222 /* grab pixels out of a row for an interlaced pass */
     3359/* Grab pixels out of a row for an interlaced pass */
    32233360PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info,
    32243361   png_bytep row, int pass));
    32253362#endif
    32263363
    3227 /* unfilter a row */
     3364/* Unfilter a row */
    32283365PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr,
    32293366   png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter));
     
    32363373PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr,
    32373374   png_bytep filtered_row));
    3238 /* finish a row while reading, dealing with interlacing passes, etc. */
     3375/* Finish a row while reading, dealing with interlacing passes, etc. */
    32393376PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr));
    32403377
    3241 /* initialize the row buffers, etc. */
     3378/* Initialize the row buffers, etc. */
    32423379PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr));
    3243 /* optional call to update the users info structure */
     3380/* Optional call to update the users info structure */
    32443381PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr,
    32453382   png_infop info_ptr));
    32463383
    3247 /* these are the functions that do the transformations */
     3384/* These are the functions that do the transformations */
    32483385#if defined(PNG_READ_FILLER_SUPPORTED)
    32493386PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info,
     
    33673504 */
    33683505
    3369 /* decode the IHDR chunk */
     3506/* Decode the IHDR chunk */
    33703507PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr,
    33713508   png_uint_32 length));
     
    34663603   png_bytep chunk_name));
    34673604
    3468 /* handle the transformations for reading and writing */
     3605/* Handle the transformations for reading and writing */
    34693606PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr));
    34703607PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr));
     
    35573694#endif  /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
    35583695
     3696/* Read the chunk header (length + type name) */
     3697PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr));
     3698
     3699/* Added at libpng version 1.2.34 */
     3700#if defined(PNG_cHRM_SUPPORTED)
     3701PNG_EXTERN int png_check_cHRM_fixed  PNGARG((png_structp png_ptr,
     3702   png_fixed_point int_white_x, png_fixed_point int_white_y,
     3703   png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
     3704   int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
     3705   png_fixed_point int_blue_y));
     3706#endif
     3707
     3708#if defined(PNG_cHRM_SUPPORTED)
     3709#if !defined(PNG_NO_CHECK_cHRM)
     3710/* Added at libpng version 1.2.34 */
     3711PNG_EXTERN void png_64bit_product (long v1, long v2, unsigned long *hi_product,
     3712   unsigned long *lo_product);
     3713#endif
     3714#endif
     3715
    35593716/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
    35603717
     
    35663723
    35673724#endif /* PNG_VERSION_INFO_ONLY */
    3568 /* do not put anything past this line */
     3725/* Do not put anything past this line */
    35693726#endif /* PNG_H */
  • trunk/src/3rdparty/libpng/pngconf.h

    r2 r561  
    22/* pngconf.h - machine configurable file for libpng
    33 *
    4  * libpng version 1.2.29 - May 8, 2008
    5  * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2008 Glenn Randers-Pehrson
     4 * libpng version 1.2.40 - September 10, 2009
     5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
    76 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    87 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     8 *
     9 * This code is released under the libpng license.
     10 * For conditions of distribution and use, see the disclaimer
     11 * and license in png.h
    912 */
    1013
     
    2023#define PNG_1_2_X
    2124
    22 /* 
     25/*
    2326 * PNG_USER_CONFIG has to be defined on the compiler command line. This
    2427 * includes the resource compiler for Windows DLL configurations.
     
    4043/*
    4144 * Added at libpng-1.2.8
    42  * 
     45 *
    4346 * If you create a private DLL you need to define in "pngusr.h" the followings:
    4447 * #define PNG_USER_PRIVATEBUILD <Describes by whom and why this version of
     
    5154 *  e.g. // private DLL "libpng13gx.dll"
    5255 *       #define PNG_USER_DLLFNAME_POSTFIX "gx"
    53  * 
    54  * The following macros are also at your disposal if you want to complete the 
     56 *
     57 * The following macros are also at your disposal if you want to complete the
    5558 * DLL VERSIONINFO structure.
    5659 * - PNG_USER_VERSIONINFO_COMMENTS
     
    148151 *   PNG_BUILD_DLL -- (ignored) building the dll
    149152 *   (no define)   -- (ignored) building an application, linking to the dll
    150  *   PNG_STATIC    -- (ignored) building the static lib, or building an 
     153 *   PNG_STATIC    -- (ignored) building the static lib, or building an
    151154 *                    application that links to the static lib.
    152  *   ALL_STATIC    -- (ignored) building various static libs, or building an 
     155 *   ALL_STATIC    -- (ignored) building various static libs, or building an
    153156 *                    application that links to the static libs.
    154157 * Thus,
     
    163166 *   PNG_STATIC
    164167 *   (nothing) == PNG_USE_DLL
    165  * 
     168 *
    166169 * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent
    167  *   of auto-import in binutils, we no longer need to worry about 
     170 *   of auto-import in binutils, we no longer need to worry about
    168171 *   __declspec(dllexport) / __declspec(dllimport) and friends.  Therefore,
    169172 *   we don't need to worry about PNG_STATIC or ALL_STATIC when it comes
    170  *   to __declspec() stuff.  However, we DO need to worry about 
     173 *   to __declspec() stuff.  However, we DO need to worry about
    171174 *   PNG_BUILD_DLL and PNG_STATIC because those change some defaults
    172175 *   such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed.
     
    212215#          define PNG_DLL
    213216#        endif
    214 #      endif 
    215 #    endif 
     217#      endif
     218#    endif
    216219#  endif
    217220#endif
     
    234237   /* Console I/O functions are not supported on WindowsCE */
    235238#  define PNG_NO_CONSOLE_IO
     239   /* abort() may not be supported on some/all Windows CE platforms */
     240#  define PNG_ABORT() exit(-1)
    236241#  ifdef PNG_DEBUG
    237242#    undef PNG_DEBUG
    238 #  endif
    239 #  ifndef PNG_ABORT
    240 #    define PNG_ABORT() exit(3)
    241243#  endif
    242244#endif
     
    316318/* This is an attempt to force a single setjmp behaviour on Linux.  If
    317319 * the X config stuff didn't define _BSD_SOURCE we wouldn't need this.
    318  */
    319 
    320 #  ifdef __linux__
    321 #    ifdef _BSD_SOURCE
    322 #      define PNG_SAVE_BSD_SOURCE
    323 #      undef _BSD_SOURCE
    324 #    endif
    325 #    ifdef _SETJMP_H
    326      /* If you encounter a compiler error here, see the explanation
    327       * near the end of INSTALL.
    328       */
    329          __pngconf.h__ already includes setjmp.h;
    330          __dont__ include it again.;
    331 #    endif
    332 #  endif /* __linux__ */
     320 *
     321 * You can bypass this test if you know that your application uses exactly
     322 * the same setjmp.h that was included when libpng was built.  Only define
     323 * PNG_SKIP_SETJMP_CHECK while building your application, prior to the
     324 * application's '#include "png.h"'. Don't define PNG_SKIP_SETJMP_CHECK
     325 * while building a separate libpng library for general use.
     326 */
     327
     328#  ifndef PNG_SKIP_SETJMP_CHECK
     329#    ifdef __linux__
     330#      ifdef _BSD_SOURCE
     331#        define PNG_SAVE_BSD_SOURCE
     332#        undef _BSD_SOURCE
     333#      endif
     334#      ifdef _SETJMP_H
     335       /* If you encounter a compiler error here, see the explanation
     336        * near the end of INSTALL.
     337        */
     338           __pngconf.h__ in libpng already includes setjmp.h;
     339           __dont__ include it again.;
     340#      endif
     341#    endif /* __linux__ */
     342#  endif /* PNG_SKIP_SETJMP_CHECK */
    333343
    334344   /* include setjmp.h for error handling */
     
    345355#endif /* PNG_SETJMP_SUPPORTED */
    346356
    347 #ifdef BSD
     357#if defined(BSD) && !defined(VXWORKS)
    348358#  include <strings.h>
    349359#else
     
    481491 * libpng-1.2.x, to support old apps that malloc the png_text structure
    482492 * instead of calling png_set_text() and letting libpng malloc it.  It
    483  * was turned on by default in libpng-1.3.0.
     493 * will be turned on by default in libpng-1.4.0.
    484494 */
    485495
     
    515525#  define PNG_NO_READ_UNKNOWN_CHUNKS
    516526#  define PNG_NO_WRITE_UNKNOWN_CHUNKS
     527#  define PNG_NO_HANDLE_AS_UNKNOWN
    517528#  define PNG_NO_READ_USER_CHUNKS
    518529#  define PNG_NO_READ_iCCP
     
    544555#endif
    545556
    546 #if defined(PNG_READ_SUPPORTED)
     557#ifdef PNG_READ_SUPPORTED
    547558
    548559#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
     
    632643#endif /* PNG_READ_SUPPORTED */
    633644
    634 #if defined(PNG_WRITE_SUPPORTED)
     645#ifdef PNG_WRITE_SUPPORTED
    635646
    636647# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \
     
    735746#endif
    736747
    737 /* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0 
     748/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0
    738749 * and removed from version 1.2.20.  The following will be removed
    739750 * from libpng-1.4.0
     
    802813#endif
    803814
     815/* Added at libpng-1.2.34 and 1.4.0 */
     816#ifndef PNG_STRING_NEWLINE
     817#define PNG_STRING_NEWLINE "\n"
     818#endif
     819
    804820/* These are currently experimental features, define them if you want */
    805821
     
    928944#  define PNG_READ_zTXt_SUPPORTED
    929945#  define PNG_zTXt_SUPPORTED
    930 #endif
    931 #ifndef PNG_NO_READ_UNKNOWN_CHUNKS
    932 #  define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
    933 #  ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
    934 #    define PNG_UNKNOWN_CHUNKS_SUPPORTED
    935 #  endif
    936 #  ifndef PNG_NO_HANDLE_AS_UNKNOWN
    937 #    define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
    938 #  endif
    939 #endif
    940 #if !defined(PNG_NO_READ_USER_CHUNKS) && \
    941      defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
    942 #  define PNG_READ_USER_CHUNKS_SUPPORTED
    943 #  define PNG_USER_CHUNKS_SUPPORTED
    944 #  ifdef PNG_NO_READ_UNKNOWN_CHUNKS
    945 #    undef PNG_NO_READ_UNKNOWN_CHUNKS
    946 #  endif
    947 #  ifdef PNG_NO_HANDLE_AS_UNKNOWN
    948 #    undef PNG_NO_HANDLE_AS_UNKNOWN
    949 #  endif
    950946#endif
    951947#ifndef PNG_NO_READ_OPT_PLTE
     
    960956#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
    961957
     958#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
     959#  define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
     960#  ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
     961#    define PNG_UNKNOWN_CHUNKS_SUPPORTED
     962#  endif
     963#endif
     964#if !defined(PNG_NO_READ_USER_CHUNKS) && \
     965     defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
     966#  define PNG_READ_USER_CHUNKS_SUPPORTED
     967#  define PNG_USER_CHUNKS_SUPPORTED
     968#  ifdef PNG_NO_READ_UNKNOWN_CHUNKS
     969#    undef PNG_NO_READ_UNKNOWN_CHUNKS
     970#  endif
     971#  ifdef PNG_NO_HANDLE_AS_UNKNOWN
     972#    undef PNG_NO_HANDLE_AS_UNKNOWN
     973#  endif
     974#endif
     975
     976#ifndef PNG_NO_HANDLE_AS_UNKNOWN
     977#  ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
     978#    define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
     979#  endif
     980#endif
     981
     982#ifdef PNG_WRITE_SUPPORTED
    962983#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
    963984
     
    10691090#  ifndef PNG_zTXt_SUPPORTED
    10701091#    define PNG_zTXt_SUPPORTED
    1071 #  endif
    1072 #endif
    1073 #ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
    1074 #  define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
    1075 #  ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
    1076 #    define PNG_UNKNOWN_CHUNKS_SUPPORTED
    1077 #  endif
    1078 #  ifndef PNG_NO_HANDLE_AS_UNKNOWN
    1079 #     ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
    1080 #       define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
    1081 #     endif
    10821092#  endif
    10831093#endif
     
    10911101
    10921102#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
     1103
     1104#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
     1105#  define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
     1106#  ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
     1107#    define PNG_UNKNOWN_CHUNKS_SUPPORTED
     1108#  endif
     1109#endif
     1110
     1111#ifndef PNG_NO_HANDLE_AS_UNKNOWN
     1112#  ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
     1113#    define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
     1114#  endif
     1115#endif
     1116#endif /* PNG_WRITE_SUPPORTED */
    10931117
    10941118/* Turn this off to disable png_read_png() and
     
    11271151#ifdef PNG_SIZE_T
    11281152   typedef PNG_SIZE_T png_size_t;
    1129 #  define png_sizeof(x) png_convert_size(sizeof (x))
     1153#  define png_sizeof(x) png_convert_size(sizeof(x))
    11301154#else
    11311155   typedef size_t png_size_t;
    1132 #  define png_sizeof(x) sizeof (x)
     1156#  define png_sizeof(x) sizeof(x)
    11331157#endif
    11341158
     
    12371261#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
    12381262/* SPC -  Is this stuff deprecated? */
    1239 /* It'll be removed as of libpng-1.3.0 - GR-P */
     1263/* It'll be removed as of libpng-1.4.0 - GR-P */
    12401264/* libpng typedefs for types in zlib. If zlib changes
    12411265 * or another compression library is used, then change these.
     
    13101334#  undef PNG_IMPEXP
    13111335#  define PNG_IMPEXP
    1312 #endif 
     1336#endif
    13131337
    13141338/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
     
    13341358
    13351359#  ifndef PNGAPI
    1336 #     if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
     1360#     if (defined(__GNUC__) && defined(__arm__)) || defined (__ARMCC__)
     1361#        define PNGAPI
     1362#     elif defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))  || defined(__WINSCW__)
    13371363#        define PNGAPI __cdecl
    13381364#     else
  • trunk/src/3rdparty/libpng/pngerror.c

    r2 r561  
    22/* pngerror.c - stub functions for i/o and memory allocation
    33 *
    4  * Last changed in libpng 1.2.22 [October 13, 2007]
    5  * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2007 Glenn Randers-Pehrson
     4 * Last changed in libpng 1.2.37 [June 4, 2009]
     5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
    76 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    87 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     8 *
     9 * This code is released under the libpng license.
     10 * For conditions of distribution and use, see the disclaimer
     11 * and license in png.h
    912 *
    1013 * This file provides a location for all error handling.  Users who
     
    1619#define PNG_INTERNAL
    1720#include "png.h"
    18 
    1921#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
     22
    2023static void /* PRIVATE */
    2124png_default_error PNGARG((png_structp png_ptr,
     
    4548       if (*error_message == '#')
    4649       {
     50           /* Strip "#nnnn " from beginning of error message. */
    4751           int offset;
    48            for (offset=1; offset<15; offset++)
    49               if (*(error_message+offset) == ' ')
     52           for (offset = 1; offset<15; offset++)
     53              if (error_message[offset] == ' ')
    5054                  break;
    5155           if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
    5256           {
    5357              int i;
    54               for (i=0; i<offset-1; i++)
    55                  msg[i]=error_message[i+1];
    56               msg[i]='\0';
    57               error_message=msg;
     58              for (i = 0; i < offset - 1; i++)
     59                 msg[i] = error_message[i + 1];
     60              msg[i - 1] = '\0';
     61              error_message = msg;
    5862           }
    5963           else
    60               error_message+=offset;
     64              error_message += offset;
    6165       }
    6266       else
     
    6468           if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
    6569           {
    66               msg[0]='0';
    67               msg[1]='\0';
    68               error_message=msg;
     70              msg[0] = '0';
     71              msg[1] = '\0';
     72              error_message = msg;
    6973           }
    7074       }
     
    111115       if (*warning_message == '#')
    112116       {
    113            for (offset=1; offset<15; offset++)
    114               if (*(warning_message+offset) == ' ')
     117           for (offset = 1; offset < 15; offset++)
     118              if (warning_message[offset] == ' ')
    115119                  break;
    116120       }
    117121     }
    118      if (png_ptr != NULL && png_ptr->warning_fn != NULL)
    119         (*(png_ptr->warning_fn))(png_ptr, warning_message+offset);
    120    }
    121    else
    122       png_default_warning(png_ptr, warning_message+offset);
     122   }
     123   if (png_ptr != NULL && png_ptr->warning_fn != NULL)
     124      (*(png_ptr->warning_fn))(png_ptr, warning_message + offset);
     125   else
     126      png_default_warning(png_ptr, warning_message + offset);
    123127}
    124128#endif /* PNG_NO_WARNINGS */
     
    168172      buffer[iout++] = ':';
    169173      buffer[iout++] = ' ';
    170       png_memcpy(buffer+iout, error_message, PNG_MAX_ERROR_TEXT);
    171       buffer[iout+PNG_MAX_ERROR_TEXT-1] = '\0';
     174      png_memcpy(buffer + iout, error_message, PNG_MAX_ERROR_TEXT);
     175      buffer[iout + PNG_MAX_ERROR_TEXT - 1] = '\0';
    172176   }
    173177}
     
    217221   if (*error_message == '#')
    218222   {
     223     /* Strip "#nnnn " from beginning of error message. */
    219224     int offset;
    220225     char error_number[16];
    221      for (offset=0; offset<15; offset++)
    222      {
    223          error_number[offset] = *(error_message+offset+1);
    224          if (*(error_message+offset) == ' ')
     226     for (offset = 0; offset<15; offset++)
     227     {
     228         error_number[offset] = error_message[offset + 1];
     229         if (error_message[offset] == ' ')
    225230             break;
    226231     }
    227      if((offset > 1) && (offset < 15))
    228      {
    229        error_number[offset-1]='\0';
    230        fprintf(stderr, "libpng error no. %s: %s\n", error_number,
    231           error_message+offset);
     232     if ((offset > 1) && (offset < 15))
     233     {
     234       error_number[offset - 1] = '\0';
     235       fprintf(stderr, "libpng error no. %s: %s",
     236          error_number, error_message + offset + 1);
     237       fprintf(stderr, PNG_STRING_NEWLINE);
    232238     }
    233239     else
    234        fprintf(stderr, "libpng error: %s, offset=%d\n", error_message,offset);
    235    }
    236    else
    237 #endif
    238    fprintf(stderr, "libpng error: %s\n", error_message);
     240     {
     241       fprintf(stderr, "libpng error: %s, offset=%d",
     242          error_message, offset);
     243       fprintf(stderr, PNG_STRING_NEWLINE);
     244     }
     245   }
     246   else
     247#endif
     248   {
     249      fprintf(stderr, "libpng error: %s", error_message);
     250      fprintf(stderr, PNG_STRING_NEWLINE);
     251   }
    239252#endif
    240253
     
    256269#endif
    257270#ifdef PNG_NO_CONSOLE_IO
    258    error_message = error_message; /* make compiler happy */
     271   error_message = error_message; /* Make compiler happy */
    259272#endif
    260273}
     
    275288     int offset;
    276289     char warning_number[16];
    277      for (offset=0; offset<15; offset++)
    278      {
    279         warning_number[offset]=*(warning_message+offset+1);
    280         if (*(warning_message+offset) == ' ')
     290     for (offset = 0; offset < 15; offset++)
     291     {
     292        warning_number[offset] = warning_message[offset + 1];
     293        if (warning_message[offset] == ' ')
    281294            break;
    282295     }
    283      if((offset > 1) && (offset < 15))
    284      {
    285        warning_number[offset-1]='\0';
    286        fprintf(stderr, "libpng warning no. %s: %s\n", warning_number,
    287           warning_message+offset);
     296     if ((offset > 1) && (offset < 15))
     297     {
     298       warning_number[offset + 1] = '\0';
     299       fprintf(stderr, "libpng warning no. %s: %s",
     300          warning_number, warning_message + offset);
     301       fprintf(stderr, PNG_STRING_NEWLINE);
    288302     }
    289303     else
    290        fprintf(stderr, "libpng warning: %s\n", warning_message);
     304     {
     305       fprintf(stderr, "libpng warning: %s",
     306          warning_message);
     307       fprintf(stderr, PNG_STRING_NEWLINE);
     308     }
    291309   }
    292310   else
    293311#  endif
    294      fprintf(stderr, "libpng warning: %s\n", warning_message);
     312   {
     313     fprintf(stderr, "libpng warning: %s", warning_message);
     314     fprintf(stderr, PNG_STRING_NEWLINE);
     315   }
    295316#else
    296    warning_message = warning_message; /* make compiler happy */
    297 #endif
    298    png_ptr = png_ptr; /* make compiler happy */
     317   warning_message = warning_message; /* Make compiler happy */
     318#endif
     319   png_ptr = png_ptr; /* Make compiler happy */
    299320}
    300321#endif /* PNG_NO_WARNINGS */
     
    334355png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
    335356{
    336    if(png_ptr != NULL)
     357   if (png_ptr != NULL)
    337358   {
    338359     png_ptr->flags &=
  • trunk/src/3rdparty/libpng/pngget.c

    r2 r561  
    22/* pngget.c - retrieval of values from info struct
    33 *
    4  * Last changed in libpng 1.2.15 January 5, 2007
    5  * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2007 Glenn Randers-Pehrson
     4 * Last changed in libpng 1.2.37 [June 4, 2009]
     5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
    76 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    87 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     8 *
     9 * This code is released under the libpng license.
     10 * For conditions of distribution and use, see the disclaimer
     11 * and license in png.h
     12 *
    913 */
    1014
    1115#define PNG_INTERNAL
    1216#include "png.h"
    13 
    1417#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
    1518
     
    1922   if (png_ptr != NULL && info_ptr != NULL)
    2023      return(info_ptr->valid & flag);
     24
    2125   else
    2226      return(0);
     
    2832   if (png_ptr != NULL && info_ptr != NULL)
    2933      return(info_ptr->rowbytes);
     34
    3035   else
    3136      return(0);
     
    3843   if (png_ptr != NULL && info_ptr != NULL)
    3944      return(info_ptr->row_pointers);
     45
    4046   else
    4147      return(0);
     
    4450
    4551#ifdef PNG_EASY_ACCESS_SUPPORTED
    46 /* easy access to info, added in libpng-0.99 */
     52/* Easy access to info, added in libpng-0.99 */
    4753png_uint_32 PNGAPI
    4854png_get_image_width(png_structp png_ptr, png_infop info_ptr)
    4955{
    5056   if (png_ptr != NULL && info_ptr != NULL)
    51    {
    5257      return info_ptr->width;
    53    }
     58
    5459   return (0);
    5560}
     
    5964{
    6065   if (png_ptr != NULL && info_ptr != NULL)
    61    {
    6266      return info_ptr->height;
    63    }
     67
    6468   return (0);
    6569}
     
    6973{
    7074   if (png_ptr != NULL && info_ptr != NULL)
    71    {
    7275      return info_ptr->bit_depth;
    73    }
     76
    7477   return (0);
    7578}
     
    7982{
    8083   if (png_ptr != NULL && info_ptr != NULL)
    81    {
    8284      return info_ptr->color_type;
    83    }
     85
    8486   return (0);
    8587}
     
    8991{
    9092   if (png_ptr != NULL && info_ptr != NULL)
    91    {
    9293      return info_ptr->filter_type;
    93    }
     94
    9495   return (0);
    9596}
     
    99100{
    100101   if (png_ptr != NULL && info_ptr != NULL)
    101    {
    102102      return info_ptr->interlace_type;
    103    }
     103
    104104   return (0);
    105105}
     
    109109{
    110110   if (png_ptr != NULL && info_ptr != NULL)
    111    {
    112111      return info_ptr->compression_type;
    113    }
     112
    114113   return (0);
    115114}
     
    122121   if (info_ptr->valid & PNG_INFO_pHYs)
    123122   {
    124       png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter");
    125       if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
     123      png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter");
     124
     125      if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
    126126          return (0);
    127       else return (info_ptr->x_pixels_per_unit);
     127
     128      else
     129          return (info_ptr->x_pixels_per_unit);
    128130   }
    129131#else
     
    140142   if (info_ptr->valid & PNG_INFO_pHYs)
    141143   {
    142       png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter");
    143       if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
     144      png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter");
     145
     146      if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
    144147          return (0);
    145       else return (info_ptr->y_pixels_per_unit);
     148
     149      else
     150          return (info_ptr->y_pixels_per_unit);
    146151   }
    147152#else
     
    158163   if (info_ptr->valid & PNG_INFO_pHYs)
    159164   {
    160       png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter");
    161       if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
     165      png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
     166
     167      if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
    162168         info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
    163169          return (0);
    164       else return (info_ptr->x_pixels_per_unit);
     170
     171      else
     172          return (info_ptr->x_pixels_per_unit);
    165173   }
    166174#else
     
    176184   if (png_ptr != NULL && info_ptr != NULL)
    177185#if defined(PNG_pHYs_SUPPORTED)
     186
    178187   if (info_ptr->valid & PNG_INFO_pHYs)
    179188   {
    180       png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio");
     189      png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
    181190      if (info_ptr->x_pixels_per_unit == 0)
    182191         return ((float)0.0);
     
    186195   }
    187196#else
    188    return (0.0);
     197      return (0.0);
    189198#endif
    190199   return ((float)0.0);
     
    197206   if (png_ptr != NULL && info_ptr != NULL)
    198207#if defined(PNG_oFFs_SUPPORTED)
     208
    199209   if (info_ptr->valid & PNG_INFO_oFFs)
    200210   {
    201       png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
    202       if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
     211      png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
     212
     213      if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
    203214          return (0);
    204       else return (info_ptr->x_offset);
     215
     216      else
     217          return (info_ptr->x_offset);
    205218   }
    206219#else
    207    return (0);
     220      return (0);
    208221#endif
    209222   return (0);
     
    214227{
    215228   if (png_ptr != NULL && info_ptr != NULL)
     229
    216230#if defined(PNG_oFFs_SUPPORTED)
    217231   if (info_ptr->valid & PNG_INFO_oFFs)
    218232   {
    219       png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
    220       if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
     233      png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
     234
     235      if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
    221236          return (0);
    222       else return (info_ptr->y_offset);
     237
     238      else
     239          return (info_ptr->y_offset);
    223240   }
    224241#else
     
    232249{
    233250   if (png_ptr != NULL && info_ptr != NULL)
     251
    234252#if defined(PNG_oFFs_SUPPORTED)
    235253   if (info_ptr->valid & PNG_INFO_oFFs)
    236254   {
    237       png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
    238       if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
     255      png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
     256
     257      if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
    239258          return (0);
    240       else return (info_ptr->x_offset);
     259
     260      else
     261          return (info_ptr->x_offset);
    241262   }
    242263#else
     
    250271{
    251272   if (png_ptr != NULL && info_ptr != NULL)
     273
    252274#if defined(PNG_oFFs_SUPPORTED)
    253275   if (info_ptr->valid & PNG_INFO_oFFs)
    254276   {
    255       png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
    256       if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
     277      png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
     278
     279      if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
    257280          return (0);
    258       else return (info_ptr->y_offset);
     281
     282      else
     283          return (info_ptr->y_offset);
    259284   }
    260285#else
     
    309334   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
    310335   {
    311       png_debug1(1, "in %s retrieval function\n", "pHYs");
     336      png_debug1(1, "in %s retrieval function", "pHYs");
    312337      if (res_x != NULL)
    313338      {
     
    324349         *unit_type = (int)info_ptr->phys_unit_type;
    325350         retval |= PNG_INFO_pHYs;
    326          if(*unit_type == 1)
     351         if (*unit_type == 1)
    327352         {
    328353            if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
     
    366391      && background != NULL)
    367392   {
    368       png_debug1(1, "in %s retrieval function\n", "bKGD");
     393      png_debug1(1, "in %s retrieval function", "bKGD");
    369394      *background = &(info_ptr->background);
    370395      return (PNG_INFO_bKGD);
     
    383408   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
    384409   {
    385       png_debug1(1, "in %s retrieval function\n", "cHRM");
     410      png_debug1(1, "in %s retrieval function", "cHRM");
    386411      if (white_x != NULL)
    387412         *white_x = (double)info_ptr->x_white;
     
    414439   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
    415440   {
    416       png_debug1(1, "in %s retrieval function\n", "cHRM");
     441      png_debug1(1, "in %s retrieval function", "cHRM");
    417442      if (white_x != NULL)
    418443         *white_x = info_ptr->int_x_white;
     
    446471      && file_gamma != NULL)
    447472   {
    448       png_debug1(1, "in %s retrieval function\n", "gAMA");
     473      png_debug1(1, "in %s retrieval function", "gAMA");
    449474      *file_gamma = (double)info_ptr->gamma;
    450475      return (PNG_INFO_gAMA);
     
    461486      && int_file_gamma != NULL)
    462487   {
    463       png_debug1(1, "in %s retrieval function\n", "gAMA");
     488      png_debug1(1, "in %s retrieval function", "gAMA");
    464489      *int_file_gamma = info_ptr->int_gamma;
    465490      return (PNG_INFO_gAMA);
     
    477502      && file_srgb_intent != NULL)
    478503   {
    479       png_debug1(1, "in %s retrieval function\n", "sRGB");
     504      png_debug1(1, "in %s retrieval function", "sRGB");
    480505      *file_srgb_intent = (int)info_ptr->srgb_intent;
    481506      return (PNG_INFO_sRGB);
     
    494519      && name != NULL && profile != NULL && proflen != NULL)
    495520   {
    496       png_debug1(1, "in %s retrieval function\n", "iCCP");
     521      png_debug1(1, "in %s retrieval function", "iCCP");
    497522      *name = info_ptr->iccp_name;
    498523      *profile = info_ptr->iccp_profile;
    499       /* compression_type is a dummy so the API won't have to change
    500          if we introduce multiple compression types later. */
     524      /* Compression_type is a dummy so the API won't have to change
     525       * if we introduce multiple compression types later.
     526       */
    501527      *proflen = (int)info_ptr->iccp_proflen;
    502528      *compression_type = (int)info_ptr->iccp_compression;
     
    528554      && hist != NULL)
    529555   {
    530       png_debug1(1, "in %s retrieval function\n", "hIST");
     556      png_debug1(1, "in %s retrieval function", "hIST");
    531557      *hist = info_ptr->hist;
    532558      return (PNG_INFO_hIST);
     
    546572      bit_depth != NULL && color_type != NULL)
    547573   {
    548       png_debug1(1, "in %s retrieval function\n", "IHDR");
     574      png_debug1(1, "in %s retrieval function", "IHDR");
    549575      *width = info_ptr->width;
    550576      *height = info_ptr->height;
    551577      *bit_depth = info_ptr->bit_depth;
    552578      if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16)
    553         png_error(png_ptr, "Invalid bit depth");
     579         png_error(png_ptr, "Invalid bit depth");
     580
    554581      *color_type = info_ptr->color_type;
     582
    555583      if (info_ptr->color_type > 6)
    556         png_error(png_ptr, "Invalid color type");
     584         png_error(png_ptr, "Invalid color type");
     585
    557586      if (compression_type != NULL)
    558587         *compression_type = info_ptr->compression_type;
     588
    559589      if (filter_type != NULL)
    560590         *filter_type = info_ptr->filter_type;
     591
    561592      if (interlace_type != NULL)
    562593         *interlace_type = info_ptr->interlace_type;
    563594
    564       /* check for potential overflow of rowbytes */
     595      /* Check for potential overflow of rowbytes */
    565596      if (*width == 0 || *width > PNG_UINT_31_MAX)
    566597        png_error(png_ptr, "Invalid image width");
     598
    567599      if (*height == 0 || *height > PNG_UINT_31_MAX)
    568600        png_error(png_ptr, "Invalid image height");
     601
    569602      if (info_ptr->width > (PNG_UINT_32_MAX
    570603                 >> 3)      /* 8-byte RGBA pixels */
     
    577610            "Width too large for libpng to process image data.");
    578611      }
     612
    579613      return (1);
    580614   }
     
    590624      && offset_x != NULL && offset_y != NULL && unit_type != NULL)
    591625   {
    592       png_debug1(1, "in %s retrieval function\n", "oFFs");
     626      png_debug1(1, "in %s retrieval function", "oFFs");
    593627      *offset_x = info_ptr->x_offset;
    594628      *offset_y = info_ptr->y_offset;
     
    607641{
    608642   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
    609       && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
    610       nparams != NULL && units != NULL && params != NULL)
    611    {
    612       png_debug1(1, "in %s retrieval function\n", "pCAL");
     643       && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
     644       nparams != NULL && units != NULL && params != NULL)
     645   {
     646      png_debug1(1, "in %s retrieval function", "pCAL");
    613647      *purpose = info_ptr->pcal_purpose;
    614648      *X0 = info_ptr->pcal_X0;
     
    631665{
    632666    if (png_ptr != NULL && info_ptr != NULL &&
    633        (info_ptr->valid & PNG_INFO_sCAL))
     667        (info_ptr->valid & PNG_INFO_sCAL))
    634668    {
    635669        *unit = info_ptr->scal_unit;
     
    647681{
    648682    if (png_ptr != NULL && info_ptr != NULL &&
    649        (info_ptr->valid & PNG_INFO_sCAL))
     683        (info_ptr->valid & PNG_INFO_sCAL))
    650684    {
    651685        *unit = info_ptr->scal_unit;
     
    670704      (info_ptr->valid & PNG_INFO_pHYs))
    671705   {
    672       png_debug1(1, "in %s retrieval function\n", "pHYs");
     706      png_debug1(1, "in %s retrieval function", "pHYs");
     707
    673708      if (res_x != NULL)
    674709      {
     
    676711         retval |= PNG_INFO_pHYs;
    677712      }
     713
    678714      if (res_y != NULL)
    679715      {
     
    681717         retval |= PNG_INFO_pHYs;
    682718      }
     719
    683720      if (unit_type != NULL)
    684721      {
     
    698735       && palette != NULL)
    699736   {
    700       png_debug1(1, "in %s retrieval function\n", "PLTE");
     737      png_debug1(1, "in %s retrieval function", "PLTE");
    701738      *palette = info_ptr->palette;
    702739      *num_palette = info_ptr->num_palette;
    703       png_debug1(3, "num_palette = %d\n", *num_palette);
     740      png_debug1(3, "num_palette = %d", *num_palette);
    704741      return (PNG_INFO_PLTE);
    705742   }
     
    714751      && sig_bit != NULL)
    715752   {
    716       png_debug1(1, "in %s retrieval function\n", "sBIT");
     753      png_debug1(1, "in %s retrieval function", "sBIT");
    717754      *sig_bit = &(info_ptr->sig_bit);
    718755      return (PNG_INFO_sBIT);
     
    729766   if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
    730767   {
    731       png_debug1(1, "in %s retrieval function\n",
     768      png_debug1(1, "in %s retrieval function",
    732769         (png_ptr->chunk_name[0] == '\0' ? "text"
    733770             : (png_const_charp)png_ptr->chunk_name));
     771
    734772      if (text_ptr != NULL)
    735773         *text_ptr = info_ptr->text;
     774
    736775      if (num_text != NULL)
    737776         *num_text = info_ptr->num_text;
     777
    738778      return ((png_uint_32)info_ptr->num_text);
    739779   }
     
    751791       && mod_time != NULL)
    752792   {
    753       png_debug1(1, "in %s retrieval function\n", "tIME");
     793      png_debug1(1, "in %s retrieval function", "tIME");
    754794      *mod_time = &(info_ptr->mod_time);
    755795      return (PNG_INFO_tIME);
     
    767807   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
    768808   {
    769       png_debug1(1, "in %s retrieval function\n", "tRNS");
     809      png_debug1(1, "in %s retrieval function", "tRNS");
    770810      if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
    771811      {
     
    775815             retval |= PNG_INFO_tRNS;
    776816          }
     817
    777818          if (trans_values != NULL)
    778819             *trans_values = &(info_ptr->trans_values);
     
    785826             retval |= PNG_INFO_tRNS;
    786827          }
    787           if(trans != NULL)
     828
     829          if (trans != NULL)
    788830             *trans = NULL;
    789831      }
    790       if(num_trans != NULL)
     832      if (num_trans != NULL)
    791833      {
    792834         *num_trans = info_ptr->num_trans;
     
    838880#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
    839881#ifndef PNG_1_0_X
    840 /* this function was added to libpng 1.2.0 and should exist by default */
     882/* This function was added to libpng 1.2.0 and should exist by default */
    841883png_uint_32 PNGAPI
    842884png_get_asm_flags (png_structp png_ptr)
    843885{
    844     /* obsolete, to be removed from libpng-1.4.0 */
     886    /* Obsolete, to be removed from libpng-1.4.0 */
    845887    return (png_ptr? 0L: 0L);
    846888}
    847889
    848 /* this function was added to libpng 1.2.0 and should exist by default */
     890/* This function was added to libpng 1.2.0 and should exist by default */
    849891png_uint_32 PNGAPI
    850892png_get_asm_flagmask (int flag_select)
    851893{
    852     /* obsolete, to be removed from libpng-1.4.0 */
     894    /* Obsolete, to be removed from libpng-1.4.0 */
    853895    flag_select=flag_select;
    854896    return 0L;
     
    856898
    857899    /* GRR:  could add this:   && defined(PNG_MMX_CODE_SUPPORTED) */
    858 /* this function was added to libpng 1.2.0 */
     900/* This function was added to libpng 1.2.0 */
    859901png_uint_32 PNGAPI
    860902png_get_mmx_flagmask (int flag_select, int *compilerID)
    861903{
    862     /* obsolete, to be removed from libpng-1.4.0 */
     904    /* Obsolete, to be removed from libpng-1.4.0 */
    863905    flag_select=flag_select;
    864906    *compilerID = -1;   /* unknown (i.e., no asm/MMX code compiled) */
     
    866908}
    867909
    868 /* this function was added to libpng 1.2.0 */
     910/* This function was added to libpng 1.2.0 */
    869911png_byte PNGAPI
    870912png_get_mmx_bitdepth_threshold (png_structp png_ptr)
    871913{
    872     /* obsolete, to be removed from libpng-1.4.0 */
     914    /* Obsolete, to be removed from libpng-1.4.0 */
    873915    return (png_ptr? 0: 0);
    874916}
    875917
    876 /* this function was added to libpng 1.2.0 */
     918/* This function was added to libpng 1.2.0 */
    877919png_uint_32 PNGAPI
    878920png_get_mmx_rowbytes_threshold (png_structp png_ptr)
    879921{
    880     /* obsolete, to be removed from libpng-1.4.0 */
     922    /* Obsolete, to be removed from libpng-1.4.0 */
    881923    return (png_ptr? 0L: 0L);
    882924}
     
    885927
    886928#ifdef PNG_SET_USER_LIMITS_SUPPORTED
    887 /* these functions were added to libpng 1.2.6 */
     929/* These functions were added to libpng 1.2.6 */
    888930png_uint_32 PNGAPI
    889931png_get_user_width_max (png_structp png_ptr)
     
    897939}
    898940#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
    899  
     941
    900942
    901943#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
  • trunk/src/3rdparty/libpng/pngmem.c

    r2 r561  
    22/* pngmem.c - stub functions for memory allocation
    33 *
    4  * Last changed in libpng 1.2.27 [April 29, 2008]
    5  * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2008 Glenn Randers-Pehrson
     4 * Last changed in libpng 1.2.37 [June 4, 2009]
     5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
    76 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    87 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     8 *
     9 * This code is released under the libpng license.
     10 * For conditions of distribution and use, see the disclaimer
     11 * and license in png.h
    912 *
    1013 * This file provides a location for all memory allocation.  Users who
     
    1720#define PNG_INTERNAL
    1821#include "png.h"
    19 
    2022#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
    2123
    2224/* Borland DOS special memory handler */
    2325#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
    24 /* if you change this, be sure to change the one in png.h also */
     26/* If you change this, be sure to change the one in png.h also */
    2527
    2628/* Allocate memory for a png_struct.  The malloc and memset can be replaced
     
    4244
    4345   if (type == PNG_STRUCT_INFO)
    44      size = png_sizeof(png_info);
     46      size = png_sizeof(png_info);
    4547   else if (type == PNG_STRUCT_PNG)
    46      size = png_sizeof(png_struct);
    47    else
    48      return (png_get_copyright(NULL));
    49 
    50 #ifdef PNG_USER_MEM_SUPPORTED
    51    if(malloc_fn != NULL)
     48      size = png_sizeof(png_struct);
     49   else
     50      return (png_get_copyright(NULL));
     51
     52#ifdef PNG_USER_MEM_SUPPORTED
     53   if (malloc_fn != NULL)
    5254   {
    5355      png_struct dummy_struct;
     
    5860   else
    5961#endif /* PNG_USER_MEM_SUPPORTED */
    60       struct_ptr = (png_voidp)farmalloc(size);
     62   struct_ptr = (png_voidp)farmalloc(size);
    6163   if (struct_ptr != NULL)
    6264      png_memset(struct_ptr, 0, size);
     
    8183   {
    8284#ifdef PNG_USER_MEM_SUPPORTED
    83       if(free_fn != NULL)
     85      if (free_fn != NULL)
    8486      {
    8587         png_struct dummy_struct;
     
    123125
    124126#ifdef PNG_USER_MEM_SUPPORTED
    125    if(png_ptr->malloc_fn != NULL)
    126        ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
    127    else
    128        ret = (png_malloc_default(png_ptr, size));
     127   if (png_ptr->malloc_fn != NULL)
     128      ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
     129   else
     130      ret = (png_malloc_default(png_ptr, size));
    129131   if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
    130132       png_error(png_ptr, "Out of memory!");
     
    151153
    152154   if (size != (size_t)size)
    153      ret = NULL;
     155      ret = NULL;
    154156   else if (size == (png_uint_32)65536L)
    155157   {
    156158      if (png_ptr->offset_table == NULL)
    157159      {
    158          /* try to see if we need to do any of this fancy stuff */
     160         /* Try to see if we need to do any of this fancy stuff */
    159161         ret = farmalloc(size);
    160162         if (ret == NULL || ((png_size_t)ret & 0xffff))
     
    172174            }
    173175
    174             if(png_ptr->zlib_window_bits > 14)
     176            if (png_ptr->zlib_window_bits > 14)
    175177               num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14));
    176178            else
     
    211213            png_ptr->offset_table = table;
    212214            png_ptr->offset_table_ptr = farmalloc(num_blocks *
    213                png_sizeof (png_bytep));
     215               png_sizeof(png_bytep));
    214216
    215217            if (png_ptr->offset_table_ptr == NULL)
     
    271273}
    272274
    273 /* free a pointer allocated by png_malloc().  In the default
    274    configuration, png_ptr is not used, but is passed in case it
    275    is needed.  If ptr is NULL, return without taking any action. */
     275/* Free a pointer allocated by png_malloc().  In the default
     276 * configuration, png_ptr is not used, but is passed in case it
     277 * is needed.  If ptr is NULL, return without taking any action.
     278 */
    276279void PNGAPI
    277280png_free(png_structp png_ptr, png_voidp ptr)
     
    286289      return;
    287290   }
    288    else png_free_default(png_ptr, ptr);
     291   else
     292      png_free_default(png_ptr, ptr);
    289293}
    290294
     
    294298#endif /* PNG_USER_MEM_SUPPORTED */
    295299
    296    if(png_ptr == NULL || ptr == NULL) return;
     300   if (png_ptr == NULL || ptr == NULL)
     301      return;
    297302
    298303   if (png_ptr->offset_table != NULL)
     
    354359
    355360#ifdef PNG_USER_MEM_SUPPORTED
    356    if(malloc_fn != NULL)
     361   if (malloc_fn != NULL)
    357362   {
    358363      png_struct dummy_struct;
     
    370375#else
    371376# if defined(_MSC_VER) && defined(MAXSEG_64K)
    372    struct_ptr = (png_voidp)halloc(size,1);
     377   struct_ptr = (png_voidp)halloc(size, 1);
    373378# else
    374379   struct_ptr = (png_voidp)malloc(size);
     
    399404   {
    400405#ifdef PNG_USER_MEM_SUPPORTED
    401       if(free_fn != NULL)
     406      if (free_fn != NULL)
    402407      {
    403408         png_struct dummy_struct;
     
    421426
    422427/* Allocate memory.  For reasonable files, size should never exceed
    423    64K.  However, zlib may allocate more then 64K if you don't tell
    424    it not to.  See zconf.h and png.h for more information.  zlib does
    425    need to allocate exactly 64K, so whatever you call here must
    426    have the ability to do that. */
     428 * 64K.  However, zlib may allocate more then 64K if you don't tell
     429 * it not to.  See zconf.h and png.h for more information.  zlib does
     430 * need to allocate exactly 64K, so whatever you call here must
     431 * have the ability to do that.
     432 */
     433
    427434
    428435png_voidp PNGAPI
     
    435442      return (NULL);
    436443
    437    if(png_ptr->malloc_fn != NULL)
    438        ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
    439    else
    440        ret = (png_malloc_default(png_ptr, size));
     444   if (png_ptr->malloc_fn != NULL)
     445      ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
     446   else
     447      ret = (png_malloc_default(png_ptr, size));
    441448   if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
    442449       png_error(png_ptr, "Out of Memory!");
     
    465472#endif
    466473
    467  /* Check for overflow */
     474   /* Check for overflow */
    468475#if defined(__TURBOC__) && !defined(__FLAT__)
    469  if (size != (unsigned long)size)
    470    ret = NULL;
    471  else
    472    ret = farmalloc(size);
     476   if (size != (unsigned long)size)
     477      ret = NULL;
     478   else
     479      ret = farmalloc(size);
    473480#else
    474481# if defined(_MSC_VER) && defined(MAXSEG_64K)
    475  if (size != (unsigned long)size)
    476    ret = NULL;
    477  else
    478    ret = halloc(size, 1);
     482   if (size != (unsigned long)size)
     483      ret = NULL;
     484   else
     485      ret = halloc(size, 1);
    479486# else
    480  if (size != (size_t)size)
    481    ret = NULL;
    482  else
    483    ret = malloc((size_t)size);
     487   if (size != (size_t)size)
     488      ret = NULL;
     489   else
     490      ret = malloc((size_t)size);
    484491# endif
    485492#endif
     
    494501
    495502/* Free a pointer allocated by png_malloc().  If ptr is NULL, return
    496    without taking any action. */
     503 * without taking any action.
     504 */
    497505void PNGAPI
    498506png_free(png_structp png_ptr, png_voidp ptr)
     
    507515      return;
    508516   }
    509    else png_free_default(png_ptr, ptr);
     517   else
     518      png_free_default(png_ptr, ptr);
    510519}
    511520void PNGAPI
     
    543552   png_voidp ptr;
    544553   png_uint_32 save_flags;
    545    if(png_ptr == NULL) return (NULL);
    546 
    547    save_flags=png_ptr->flags;
     554   if (png_ptr == NULL)
     555      return (NULL);
     556
     557   save_flags = png_ptr->flags;
    548558   png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
    549559   ptr = (png_voidp)png_malloc((png_structp)png_ptr, size);
     
    561571   size = (png_size_t)length;
    562572   if ((png_uint_32)size != length)
    563       png_error(png_ptr,"Overflow in png_memcpy_check.");
     573      png_error(png_ptr, "Overflow in png_memcpy_check.");
    564574
    565575   return(png_memcpy (s1, s2, size));
     
    574584   size = (png_size_t)length;
    575585   if ((png_uint_32)size != length)
    576       png_error(png_ptr,"Overflow in png_memset_check.");
     586      png_error(png_ptr, "Overflow in png_memset_check.");
    577587
    578588   return (png_memset (s1, value, size));
     
    588598  malloc_fn, png_free_ptr free_fn)
    589599{
    590    if(png_ptr != NULL) {
    591    png_ptr->mem_ptr = mem_ptr;
    592    png_ptr->malloc_fn = malloc_fn;
    593    png_ptr->free_fn = free_fn;
     600   if (png_ptr != NULL)
     601   {
     602      png_ptr->mem_ptr = mem_ptr;
     603      png_ptr->malloc_fn = malloc_fn;
     604      png_ptr->free_fn = free_fn;
    594605   }
    595606}
     
    602613png_get_mem_ptr(png_structp png_ptr)
    603614{
    604    if(png_ptr == NULL) return (NULL);
     615   if (png_ptr == NULL)
     616      return (NULL);
    605617   return ((png_voidp)png_ptr->mem_ptr);
    606618}
  • trunk/src/3rdparty/libpng/pngpread.c

    r2 r561  
    22/* pngpread.c - read a png file in push mode
    33 *
    4  * Last changed in libpng 1.2.27 [April 29, 2008]
    5  * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2008 Glenn Randers-Pehrson
     4 * Last changed in libpng 1.2.38 [July 16, 2009]
     5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
    76 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    87 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     8 *
     9 * This code is released under the libpng license.
     10 * For conditions of distribution and use, see the disclaimer
     11 * and license in png.h
    912 */
    1013
    1114#define PNG_INTERNAL
    1215#include "png.h"
    13 
    1416#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
    1517
    16 /* push model modes */
     18/* Push model modes */
    1719#define PNG_READ_SIG_MODE   0
    1820#define PNG_READ_CHUNK_MODE 1
     
    2931   png_bytep buffer, png_size_t buffer_size)
    3032{
    31    if(png_ptr == NULL || info_ptr == NULL) return;
     33   if (png_ptr == NULL || info_ptr == NULL)
     34      return;
     35
    3236   png_push_restore_buffer(png_ptr, buffer, buffer_size);
    3337
     
    4448png_process_some_data(png_structp png_ptr, png_infop info_ptr)
    4549{
    46    if(png_ptr == NULL) return;
     50   if (png_ptr == NULL)
     51      return;
     52
    4753   switch (png_ptr->process_mode)
    4854   {
     
    5258         break;
    5359      }
     60
    5461      case PNG_READ_CHUNK_MODE:
    5562      {
     
    5764         break;
    5865      }
     66
    5967      case PNG_READ_IDAT_MODE:
    6068      {
     
    6270         break;
    6371      }
     72
    6473#if defined(PNG_READ_tEXt_SUPPORTED)
    6574      case PNG_READ_tEXt_MODE:
     
    6877         break;
    6978      }
     79
    7080#endif
    7181#if defined(PNG_READ_zTXt_SUPPORTED)
     
    7585         break;
    7686      }
     87
    7788#endif
    7889#if defined(PNG_READ_iTXt_SUPPORTED)
     
    8293         break;
    8394      }
     95
    8496#endif
    8597      case PNG_SKIP_MODE:
     
    88100         break;
    89101      }
     102
    90103      default:
    91104      {
     
    115128   png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]),
    116129      num_to_check);
    117    png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes+num_to_check);
     130   png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes + num_to_check);
    118131
    119132   if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))
     
    211224
    212225      png_push_fill_buffer(png_ptr, chunk_length, 4);
    213       png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length);
     226      png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
    214227      png_reset_crc(png_ptr);
    215228      png_crc_read(png_ptr, png_ptr->chunk_name, 4);
     229      png_check_chunk_name(png_ptr, png_ptr->chunk_name);
    216230      png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
    217231   }
    218232
    219233   if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
    220      if(png_ptr->mode & PNG_AFTER_IDAT)
     234     if (png_ptr->mode & PNG_AFTER_IDAT)
    221235        png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
    222236
    223237   if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
    224238   {
    225       if (png_ptr->push_length + 4 > png_ptr->buffer_size)
    226       {
    227          if (png_ptr->push_length != 13)
    228             png_error(png_ptr, "Invalid IHDR length");
    229          png_push_save_buffer(png_ptr);
    230          return;
    231       }
     239      if (png_ptr->push_length != 13)
     240         png_error(png_ptr, "Invalid IHDR length");
     241
     242      if (png_ptr->push_length + 4 > png_ptr->buffer_size)
     243      {
     244         png_push_save_buffer(png_ptr);
     245         return;
     246      }
     247
    232248      png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length);
    233249   }
     250
    234251   else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
    235252   {
     
    239256         return;
    240257      }
     258
    241259      png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length);
    242260
     
    244262      png_push_have_end(png_ptr, info_ptr);
    245263   }
     264
    246265#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
    247266   else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name))
     
    252271         return;
    253272      }
     273
    254274      if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
    255275         png_ptr->mode |= PNG_HAVE_IDAT;
     276
    256277      png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);
     278
    257279      if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
    258280         png_ptr->mode |= PNG_HAVE_PLTE;
     281
    259282      else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
    260283      {
    261284         if (!(png_ptr->mode & PNG_HAVE_IHDR))
    262285            png_error(png_ptr, "Missing IHDR before IDAT");
     286
    263287         else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
    264288                  !(png_ptr->mode & PNG_HAVE_PLTE))
     
    266290      }
    267291   }
     292
    268293#endif
    269294   else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
     
    276301      png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length);
    277302   }
     303
    278304   else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
    279305   {
     
    282308       * is called after the image has been read - we have an error).
    283309       */
    284      if (!(png_ptr->mode & PNG_HAVE_IHDR))
    285        png_error(png_ptr, "Missing IHDR before IDAT");
    286      else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
    287          !(png_ptr->mode & PNG_HAVE_PLTE))
    288        png_error(png_ptr, "Missing PLTE before IDAT");
     310
     311      if (!(png_ptr->mode & PNG_HAVE_IHDR))
     312         png_error(png_ptr, "Missing IHDR before IDAT");
     313
     314      else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
     315          !(png_ptr->mode & PNG_HAVE_PLTE))
     316         png_error(png_ptr, "Missing PLTE before IDAT");
    289317
    290318      if (png_ptr->mode & PNG_HAVE_IDAT)
    291319      {
    292320         if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
    293            if (png_ptr->push_length == 0)
    294               return;
     321            if (png_ptr->push_length == 0)
     322               return;
    295323
    296324         if (png_ptr->mode & PNG_AFTER_IDAT)
     
    306334      return;
    307335   }
     336
    308337#if defined(PNG_READ_gAMA_SUPPORTED)
    309338   else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4))
     
    314343         return;
    315344      }
     345
    316346      png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length);
    317347   }
     348
    318349#endif
    319350#if defined(PNG_READ_sBIT_SUPPORTED)
     
    325356         return;
    326357      }
     358
    327359      png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length);
    328360   }
     361
    329362#endif
    330363#if defined(PNG_READ_cHRM_SUPPORTED)
     
    336369         return;
    337370      }
     371
    338372      png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length);
    339373   }
     374
    340375#endif
    341376#if defined(PNG_READ_sRGB_SUPPORTED)
     
    347382         return;
    348383      }
     384
    349385      png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length);
    350386   }
     387
    351388#endif
    352389#if defined(PNG_READ_iCCP_SUPPORTED)
     
    358395         return;
    359396      }
     397
    360398      png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length);
    361399   }
     400
    362401#endif
    363402#if defined(PNG_READ_sPLT_SUPPORTED)
     
    369408         return;
    370409      }
     410
    371411      png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length);
    372412   }
     413
    373414#endif
    374415#if defined(PNG_READ_tRNS_SUPPORTED)
     
    380421         return;
    381422      }
     423
    382424      png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length);
    383425   }
     426
    384427#endif
    385428#if defined(PNG_READ_bKGD_SUPPORTED)
     
    391434         return;
    392435      }
     436
    393437      png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length);
    394438   }
     439
    395440#endif
    396441#if defined(PNG_READ_hIST_SUPPORTED)
     
    402447         return;
    403448      }
     449
    404450      png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length);
    405451   }
     452
    406453#endif
    407454#if defined(PNG_READ_pHYs_SUPPORTED)
     
    413460         return;
    414461      }
     462
    415463      png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length);
    416464   }
     465
    417466#endif
    418467#if defined(PNG_READ_oFFs_SUPPORTED)
     
    424473         return;
    425474      }
     475
    426476      png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length);
    427477   }
    428478#endif
     479
    429480#if defined(PNG_READ_pCAL_SUPPORTED)
    430481   else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4))
     
    435486         return;
    436487      }
     488
    437489      png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length);
    438490   }
     491
    439492#endif
    440493#if defined(PNG_READ_sCAL_SUPPORTED)
     
    446499         return;
    447500      }
     501
    448502      png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length);
    449503   }
     504
    450505#endif
    451506#if defined(PNG_READ_tIME_SUPPORTED)
     
    457512         return;
    458513      }
     514
    459515      png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length);
    460516   }
     517
    461518#endif
    462519#if defined(PNG_READ_tEXt_SUPPORTED)
     
    468525         return;
    469526      }
     527
    470528      png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length);
    471529   }
     530
    472531#endif
    473532#if defined(PNG_READ_zTXt_SUPPORTED)
     
    479538         return;
    480539      }
     540
    481541      png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);
    482542   }
     543
    483544#endif
    484545#if defined(PNG_READ_iTXt_SUPPORTED)
     
    490551         return;
    491552      }
     553
    492554      png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
    493555   }
     556
    494557#endif
    495558   else
     
    566629   png_bytep ptr;
    567630
    568    if(png_ptr == NULL) return;
     631   if (png_ptr == NULL)
     632      return;
     633
    569634   ptr = buffer;
    570635   if (png_ptr->save_buffer_size)
     
    590655      if (length < png_ptr->current_buffer_size)
    591656         save_size = length;
     657
    592658      else
    593659         save_size = png_ptr->current_buffer_size;
     
    607673      if (png_ptr->save_buffer_ptr != png_ptr->save_buffer)
    608674      {
    609          png_size_t i,istop;
     675         png_size_t i, istop;
    610676         png_bytep sp;
    611677         png_bytep dp;
     
    630696        png_error(png_ptr, "Potential overflow of save_buffer");
    631697      }
     698
    632699      new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256;
    633700      old_buffer = png_ptr->save_buffer;
     
    676743
    677744      png_push_fill_buffer(png_ptr, chunk_length, 4);
    678       png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length);
     745      png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
    679746      png_reset_crc(png_ptr);
    680747      png_crc_read(png_ptr, png_ptr->chunk_name, 4);
     
    698765      {
    699766         save_size = (png_size_t)png_ptr->idat_size;
    700          /* check for overflow */
    701          if((png_uint_32)save_size != png_ptr->idat_size)
     767
     768         /* Check for overflow */
     769         if ((png_uint_32)save_size != png_ptr->idat_size)
    702770            png_error(png_ptr, "save_size overflowed in pngpread");
    703771      }
     
    706774
    707775      png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size);
     776
    708777      if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
    709778         png_process_IDAT_data(png_ptr, png_ptr->save_buffer_ptr, save_size);
     779
    710780      png_ptr->idat_size -= save_size;
    711781      png_ptr->buffer_size -= save_size;
     
    720790      {
    721791         save_size = (png_size_t)png_ptr->idat_size;
    722          /* check for overflow */
    723          if((png_uint_32)save_size != png_ptr->idat_size)
     792
     793         /* Check for overflow */
     794         if ((png_uint_32)save_size != png_ptr->idat_size)
    724795            png_error(png_ptr, "save_size overflowed in pngpread");
    725796      }
     
    761832   png_ptr->zstream.next_in = buffer;
    762833   png_ptr->zstream.avail_in = (uInt)buffer_length;
    763    for(;;)
     834   for (;;)
    764835   {
    765836      ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
     
    770841            if (png_ptr->zstream.avail_in)
    771842               png_error(png_ptr, "Extra compressed data");
     843
    772844            if (!(png_ptr->zstream.avail_out))
    773845            {
     
    781853         else if (ret == Z_BUF_ERROR)
    782854            break;
     855
    783856         else
    784857            png_error(png_ptr, "Decompression Error");
     
    802875         png_ptr->zstream.next_out = png_ptr->row_buf;
    803876      }
     877
    804878      else
    805879         break;
     
    830904
    831905#if defined(PNG_READ_INTERLACING_SUPPORTED)
    832    /* blow up interlaced rows to full size */
     906   /* Blow up interlaced rows to full size */
    833907   if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
    834908   {
     
    848922            {
    849923               png_push_have_row(png_ptr, png_ptr->row_buf + 1);
    850                png_read_push_finish_row(png_ptr); /* updates png_ptr->pass */
    851             }
    852             if (png_ptr->pass == 2) /* pass 1 might be empty */
     924               png_read_push_finish_row(png_ptr); /* Updates png_ptr->pass */
     925            }
     926
     927            if (png_ptr->pass == 2) /* Pass 1 might be empty */
    853928            {
    854929               for (i = 0; i < 4 && png_ptr->pass == 2; i++)
     
    858933               }
    859934            }
     935
    860936            if (png_ptr->pass == 4 && png_ptr->height <= 4)
    861937            {
     
    866942               }
    867943            }
     944
    868945            if (png_ptr->pass == 6 && png_ptr->height <= 4)
    869946            {
     
    871948                png_read_push_finish_row(png_ptr);
    872949            }
     950
    873951            break;
    874952         }
     953
    875954         case 1:
    876955         {
     
    881960               png_read_push_finish_row(png_ptr);
    882961            }
    883             if (png_ptr->pass == 2) /* skip top 4 generated rows */
     962
     963            if (png_ptr->pass == 2) /* Skip top 4 generated rows */
    884964            {
    885965               for (i = 0; i < 4 && png_ptr->pass == 2; i++)
     
    889969               }
    890970            }
     971
    891972            break;
    892973         }
     974
    893975         case 2:
    894976         {
    895977            int i;
     978
    896979            for (i = 0; i < 4 && png_ptr->pass == 2; i++)
    897980            {
     
    899982               png_read_push_finish_row(png_ptr);
    900983            }
     984
    901985            for (i = 0; i < 4 && png_ptr->pass == 2; i++)
    902986            {
     
    904988               png_read_push_finish_row(png_ptr);
    905989            }
    906             if (png_ptr->pass == 4) /* pass 3 might be empty */
     990
     991            if (png_ptr->pass == 4) /* Pass 3 might be empty */
    907992            {
    908993               for (i = 0; i < 2 && png_ptr->pass == 4; i++)
     
    912997               }
    913998            }
     999
    9141000            break;
    9151001         }
     1002
    9161003         case 3:
    9171004         {
    9181005            int i;
     1006
    9191007            for (i = 0; i < 4 && png_ptr->pass == 3; i++)
    9201008            {
     
    9221010               png_read_push_finish_row(png_ptr);
    9231011            }
    924             if (png_ptr->pass == 4) /* skip top two generated rows */
     1012
     1013            if (png_ptr->pass == 4) /* Skip top two generated rows */
    9251014            {
    9261015               for (i = 0; i < 2 && png_ptr->pass == 4; i++)
     
    9301019               }
    9311020            }
     1021
    9321022            break;
    9331023         }
     1024
    9341025         case 4:
    9351026         {
    9361027            int i;
     1028
    9371029            for (i = 0; i < 2 && png_ptr->pass == 4; i++)
    9381030            {
     
    9401032               png_read_push_finish_row(png_ptr);
    9411033            }
     1034
    9421035            for (i = 0; i < 2 && png_ptr->pass == 4; i++)
    9431036            {
     
    9451038               png_read_push_finish_row(png_ptr);
    9461039            }
    947             if (png_ptr->pass == 6) /* pass 5 might be empty */
     1040
     1041            if (png_ptr->pass == 6) /* Pass 5 might be empty */
    9481042            {
    9491043               png_push_have_row(png_ptr, png_bytep_NULL);
    9501044               png_read_push_finish_row(png_ptr);
    9511045            }
     1046
    9521047            break;
    9531048         }
     1049
    9541050         case 5:
    9551051         {
    9561052            int i;
     1053
    9571054            for (i = 0; i < 2 && png_ptr->pass == 5; i++)
    9581055            {
     
    9601057               png_read_push_finish_row(png_ptr);
    9611058            }
    962             if (png_ptr->pass == 6) /* skip top generated row */
     1059
     1060            if (png_ptr->pass == 6) /* Skip top generated row */
    9631061            {
    9641062               png_push_have_row(png_ptr, png_bytep_NULL);
    9651063               png_read_push_finish_row(png_ptr);
    9661064            }
     1065
    9671066            break;
    9681067         }
     
    9711070            png_push_have_row(png_ptr, png_ptr->row_buf + 1);
    9721071            png_read_push_finish_row(png_ptr);
     1072
    9731073            if (png_ptr->pass != 6)
    9741074               break;
     1075
    9751076            png_push_have_row(png_ptr, png_bytep_NULL);
    9761077            png_read_push_finish_row(png_ptr);
     
    9901091{
    9911092#ifdef PNG_USE_LOCAL_ARRAYS
    992    /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    993 
    994    /* start of interlace block */
     1093   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
     1094
     1095   /* Start of interlace block */
    9951096   PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
    9961097
    997    /* offset to next interlace block */
     1098   /* Offset to next interlace block */
    9981099   PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
    9991100
    1000    /* start of interlace block in the y direction */
     1101   /* Start of interlace block in the y direction */
    10011102   PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
    10021103
    1003    /* offset to next interlace block in the y direction */
     1104   /* Offset to next interlace block in the y direction */
    10041105   PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
    10051106
     
    10141115      return;
    10151116
     1117#if defined(PNG_READ_INTERLACING_SUPPORTED)
    10161118   if (png_ptr->interlaced)
    10171119   {
     
    10211123      do
    10221124      {
    1023          int pass;
    1024          pass = png_ptr->pass;
    1025          pass++;
    1026          if ((pass == 1 && png_ptr->width < 5) ||
    1027              (pass == 3 && png_ptr->width < 3) ||
    1028              (pass == 5 && png_ptr->width < 2))
    1029            pass++;
    1030 
    1031          if (pass > 7)
    1032             pass--;
    1033          png_ptr->pass = (png_byte) pass;
    1034          if (pass < 7)
    1035            {
    1036              png_ptr->iwidth = (png_ptr->width +
    1037                 png_pass_inc[pass] - 1 -
    1038                 png_pass_start[pass]) /
    1039                 png_pass_inc[pass];
    1040 
    1041              png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,
    1042                 png_ptr->iwidth) + 1;
    1043 
    1044              if (png_ptr->transformations & PNG_INTERLACE)
    1045                 break;
    1046 
    1047              png_ptr->num_rows = (png_ptr->height +
    1048                 png_pass_yinc[pass] - 1 -
    1049                 png_pass_ystart[pass]) /
    1050                 png_pass_yinc[pass];
    1051            }
    1052          else
    1053            break;
     1125         png_ptr->pass++;
     1126         if ((png_ptr->pass == 1 && png_ptr->width < 5) ||
     1127             (png_ptr->pass == 3 && png_ptr->width < 3) ||
     1128             (png_ptr->pass == 5 && png_ptr->width < 2))
     1129           png_ptr->pass++;
     1130
     1131         if (png_ptr->pass > 7)
     1132            png_ptr->pass--;
     1133
     1134         if (png_ptr->pass >= 7)
     1135            break;
     1136
     1137         png_ptr->iwidth = (png_ptr->width +
     1138            png_pass_inc[png_ptr->pass] - 1 -
     1139            png_pass_start[png_ptr->pass]) /
     1140            png_pass_inc[png_ptr->pass];
     1141
     1142         png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,
     1143            png_ptr->iwidth) + 1;
     1144
     1145         if (png_ptr->transformations & PNG_INTERLACE)
     1146            break;
     1147
     1148         png_ptr->num_rows = (png_ptr->height +
     1149            png_pass_yinc[png_ptr->pass] - 1 -
     1150            png_pass_ystart[png_ptr->pass]) /
     1151            png_pass_yinc[png_ptr->pass];
    10541152
    10551153      } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0);
    10561154   }
     1155#endif /* PNG_READ_INTERLACING_SUPPORTED */
    10571156}
    10581157
     
    10651164      {
    10661165         png_error(png_ptr, "Out of place tEXt");
    1067          info_ptr = info_ptr; /* to quiet some compiler warnings */
     1166         info_ptr = info_ptr; /* To quiet some compiler warnings */
    10681167      }
    10691168
     
    10801179
    10811180   png_ptr->current_text = (png_charp)png_malloc(png_ptr,
    1082          (png_uint_32)(length+1));
     1181      (png_uint_32)(length + 1));
    10831182   png_ptr->current_text[length] = '\0';
    10841183   png_ptr->current_text_ptr = png_ptr->current_text;
     
    10971196      if (png_ptr->buffer_size < png_ptr->current_text_left)
    10981197         text_size = png_ptr->buffer_size;
     1198
    10991199      else
    11001200         text_size = png_ptr->current_text_left;
     1201
    11011202      png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size);
    11021203      png_ptr->current_text_left -= text_size;
     
    11261227
    11271228      for (text = key; *text; text++)
    1128          /* empty loop */ ;
     1229         /* Empty loop */ ;
    11291230
    11301231      if (text < key + png_ptr->current_text_size)
     
    11611262      {
    11621263         png_error(png_ptr, "Out of place zTXt");
    1163          info_ptr = info_ptr; /* to quiet some compiler warnings */
     1264         info_ptr = info_ptr; /* To quiet some compiler warnings */
    11641265      }
    11651266
     
    11781279
    11791280   png_ptr->current_text = (png_charp)png_malloc(png_ptr,
    1180        (png_uint_32)(length+1));
     1281      (png_uint_32)(length + 1));
    11811282   png_ptr->current_text[length] = '\0';
    11821283   png_ptr->current_text_ptr = png_ptr->current_text;
     
    11951296      if (png_ptr->buffer_size < (png_uint_32)png_ptr->current_text_left)
    11961297         text_size = png_ptr->buffer_size;
     1298
    11971299      else
    11981300         text_size = png_ptr->current_text_left;
     1301
    11991302      png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size);
    12001303      png_ptr->current_text_left -= text_size;
     
    12201323
    12211324      for (text = key; *text; text++)
    1222          /* empty loop */ ;
     1325         /* Empty loop */ ;
    12231326
    12241327      /* zTXt can't have zero text */
     
    12321335      text++;
    12331336
    1234       if (*text != PNG_TEXT_COMPRESSION_zTXt) /* check compression byte */
     1337      if (*text != PNG_TEXT_COMPRESSION_zTXt) /* Check compression byte */
    12351338      {
    12361339         png_ptr->current_text = NULL;
     
    12691372            {
    12701373               text = (png_charp)png_malloc(png_ptr,
    1271                   (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out
    1272                      + key_size + 1));
     1374                     (png_uint_32)(png_ptr->zbuf_size
     1375                     - png_ptr->zstream.avail_out + key_size + 1));
     1376
    12731377               png_memcpy(text + key_size, png_ptr->zbuf,
    12741378                  png_ptr->zbuf_size - png_ptr->zstream.avail_out);
     1379
    12751380               png_memcpy(text, key, key_size);
     1381
    12761382               text_size = key_size + png_ptr->zbuf_size -
    12771383                  png_ptr->zstream.avail_out;
     1384
    12781385               *(text + text_size) = '\0';
    12791386            }
     
    12841391               tmp = text;
    12851392               text = (png_charp)png_malloc(png_ptr, text_size +
    1286                   (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out
    1287                    + 1));
     1393                  (png_uint_32)(png_ptr->zbuf_size
     1394                  - png_ptr->zstream.avail_out + 1));
     1395
    12881396               png_memcpy(text, tmp, text_size);
    12891397               png_free(png_ptr, tmp);
     1398
    12901399               png_memcpy(text + text_size, png_ptr->zbuf,
    12911400                  png_ptr->zbuf_size - png_ptr->zstream.avail_out);
     1401
    12921402               text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out;
    12931403               *(text + text_size) = '\0';
     
    13531463      {
    13541464         png_error(png_ptr, "Out of place iTXt");
    1355          info_ptr = info_ptr; /* to quiet some compiler warnings */
     1465         info_ptr = info_ptr; /* To quiet some compiler warnings */
    13561466      }
    13571467
     
    13681478
    13691479   png_ptr->current_text = (png_charp)png_malloc(png_ptr,
    1370          (png_uint_32)(length+1));
     1480      (png_uint_32)(length + 1));
    13711481   png_ptr->current_text[length] = '\0';
    13721482   png_ptr->current_text_ptr = png_ptr->current_text;
     
    13861496      if (png_ptr->buffer_size < png_ptr->current_text_left)
    13871497         text_size = png_ptr->buffer_size;
     1498
    13881499      else
    13891500         text_size = png_ptr->current_text_left;
     1501
    13901502      png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size);
    13911503      png_ptr->current_text_left -= text_size;
     
    14181530
    14191531      for (lang = key; *lang; lang++)
    1420          /* empty loop */ ;
     1532         /* Empty loop */ ;
    14211533
    14221534      if (lang < key + png_ptr->current_text_size - 3)
     
    14241536
    14251537      comp_flag = *lang++;
    1426       lang++;     /* skip comp_type, always zero */
     1538      lang++;     /* Skip comp_type, always zero */
    14271539
    14281540      for (lang_key = lang; *lang_key; lang_key++)
    1429          /* empty loop */ ;
    1430       lang_key++;        /* skip NUL separator */
     1541         /* Empty loop */ ;
     1542
     1543      lang_key++;        /* Skip NUL separator */
    14311544
    14321545      text=lang_key;
     1546
    14331547      if (lang_key < key + png_ptr->current_text_size - 1)
    14341548      {
    14351549        for (; *text; text++)
    1436            /* empty loop */ ;
     1550           /* Empty loop */ ;
    14371551      }
    14381552
     
    14421556      text_ptr = (png_textp)png_malloc(png_ptr,
    14431557         (png_uint_32)png_sizeof(png_text));
     1558
    14441559      text_ptr->compression = comp_flag + 2;
    14451560      text_ptr->key = key;
     
    14691584   length)
    14701585{
    1471    png_uint_32 skip=0;
    1472    png_check_chunk_name(png_ptr, png_ptr->chunk_name);
     1586   png_uint_32 skip = 0;
    14731587
    14741588   if (!(png_ptr->chunk_name[0] & 0x20))
    14751589   {
    14761590#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
    1477      if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
    1478           PNG_HANDLE_CHUNK_ALWAYS
     1591      if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
     1592         PNG_HANDLE_CHUNK_ALWAYS
    14791593#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
    1480           && png_ptr->read_user_chunk_fn == NULL
    1481 #endif
    1482         )
    1483 #endif
    1484         png_chunk_error(png_ptr, "unknown critical chunk");
    1485 
    1486      info_ptr = info_ptr; /* to quiet some compiler warnings */
     1594         && png_ptr->read_user_chunk_fn == NULL
     1595#endif
     1596         )
     1597#endif
     1598         png_chunk_error(png_ptr, "unknown critical chunk");
     1599
     1600      info_ptr = info_ptr; /* To quiet some compiler warnings */
    14871601   }
    14881602
     
    15011615                 (png_charp)png_ptr->chunk_name,
    15021616                 png_sizeof(png_ptr->unknown_chunk.name));
    1503       png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name)-1]='\0';
     1617      png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name) - 1]
     1618        = '\0';
    15041619
    15051620      png_ptr->unknown_chunk.size = (png_size_t)length;
     1621
    15061622      if (length == 0)
    15071623         png_ptr->unknown_chunk.data = NULL;
     1624
    15081625      else
    15091626      {
    1510          png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length);
     1627         png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr,
     1628       (png_uint_32)length);
    15111629         png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length);
    15121630      }
     1631
    15131632#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
    1514       if(png_ptr->read_user_chunk_fn != NULL)
    1515       {
    1516          /* callback to user unknown chunk handler */
     1633      if (png_ptr->read_user_chunk_fn != NULL)
     1634      {
     1635         /* Callback to user unknown chunk handler */
    15171636         int ret;
    15181637         ret = (*(png_ptr->read_user_chunk_fn))
    15191638           (png_ptr, &png_ptr->unknown_chunk);
     1639
    15201640         if (ret < 0)
    15211641            png_chunk_error(png_ptr, "error in user chunk");
     1642
    15221643         if (ret == 0)
    15231644         {
    15241645            if (!(png_ptr->chunk_name[0] & 0x20))
    1525                if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
     1646               if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
    15261647                    PNG_HANDLE_CHUNK_ALWAYS)
    15271648                  png_chunk_error(png_ptr, "unknown critical chunk");
     
    15301651         }
    15311652      }
     1653
    15321654      else
    15331655#endif
     
    15361658      png_ptr->unknown_chunk.data = NULL;
    15371659   }
     1660
    15381661   else
    15391662#endif
     
    15721695      {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
    15731696#endif
    1574    if(png_ptr == NULL) return;
     1697   if (png_ptr == NULL)
     1698      return;
     1699
    15751700   if (new_row != NULL)    /* new_row must == png_ptr->row_buf here. */
    15761701      png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]);
     
    15821707   png_progressive_end_ptr end_fn)
    15831708{
    1584    if(png_ptr == NULL) return;
     1709   if (png_ptr == NULL)
     1710      return;
     1711
    15851712   png_ptr->info_fn = info_fn;
    15861713   png_ptr->row_fn = row_fn;
     
    15931720png_get_progressive_ptr(png_structp png_ptr)
    15941721{
    1595    if(png_ptr == NULL) return (NULL);
     1722   if (png_ptr == NULL)
     1723      return (NULL);
     1724
    15961725   return png_ptr->io_ptr;
    15971726}
  • trunk/src/3rdparty/libpng/pngread.c

    r2 r561  
    22/* pngread.c - read a PNG file
    33 *
    4  * Last changed in libpng 1.2.25 [February 18, 2008]
    5  * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2008 Glenn Randers-Pehrson
     4 * Last changed in libpng 1.2.37 [June 4, 2009]
     5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
    76 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    87 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     8 *
     9 * This code is released under the libpng license.
     10 * For conditions of distribution and use, see the disclaimer
     11 * and license in png.h
    912 *
    1013 * This file contains routines that an application calls directly to
     
    1417#define PNG_INTERNAL
    1518#include "png.h"
    16 
    1719#if defined(PNG_READ_SUPPORTED)
    1820
     
    3638#endif /* PNG_USER_MEM_SUPPORTED */
    3739
     40#ifdef PNG_SETJMP_SUPPORTED
     41   volatile
     42#endif
    3843   png_structp png_ptr;
    3944
     
    4651   int i;
    4752
    48    png_debug(1, "in png_create_read_struct\n");
     53   png_debug(1, "in png_create_read_struct");
    4954#ifdef PNG_USER_MEM_SUPPORTED
    5055   png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
     
    5661      return (NULL);
    5762
    58    /* added at libpng-1.2.6 */
     63   /* Added at libpng-1.2.6 */
    5964#ifdef PNG_SET_USER_LIMITS_SUPPORTED
    6065   png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
     
    7075   {
    7176      png_free(png_ptr, png_ptr->zbuf);
    72       png_ptr->zbuf=NULL;
     77      png_ptr->zbuf = NULL;
    7378#ifdef PNG_USER_MEM_SUPPORTED
    7479      png_destroy_struct_2((png_voidp)png_ptr,
     
    8085   }
    8186#ifdef USE_FAR_KEYWORD
    82    png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf));
     87   png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf));
    8388#endif
    8489#endif
     
    9095   png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
    9196
    92    if(user_png_ver)
    93    {
    94      i=0;
     97   if (user_png_ver)
     98   {
     99     i = 0;
    95100     do
    96101     {
    97        if(user_png_ver[i] != png_libpng_ver[i])
     102       if (user_png_ver[i] != png_libpng_ver[i])
    98103          png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
    99104     } while (png_libpng_ver[i++]);
     
    101106   else
    102107        png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
    103    
     108
    104109
    105110   if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
     
    129134#endif
    130135#ifdef PNG_ERROR_NUMBERS_SUPPORTED
    131         png_ptr->flags=0;
     136        png_ptr->flags = 0;
    132137#endif
    133138        png_error(png_ptr,
     
    136141   }
    137142
    138    /* initialize zbuf - compression buffer */
     143   /* Initialize zbuf - compression buffer */
    139144   png_ptr->zbuf_size = PNG_ZBUF_SIZE;
    140145   png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
     
    165170   if (setjmp(jmpbuf))
    166171      PNG_ABORT();
    167    png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf));
     172   png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf));
    168173#else
    169174   if (setjmp(png_ptr->jmpbuf))
     
    191196{
    192197   /* We only come here via pre-1.0.12-compiled applications */
    193    if(png_ptr == NULL) return;
     198   if (png_ptr == NULL)
     199      return;
    194200#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
    195    if(png_sizeof(png_struct) > png_struct_size ||
     201   if (png_sizeof(png_struct) > png_struct_size ||
    196202      png_sizeof(png_info) > png_info_size)
    197203   {
    198204      char msg[80];
    199       png_ptr->warning_fn=NULL;
     205      png_ptr->warning_fn = NULL;
    200206      if (user_png_ver)
    201207      {
     
    211217   }
    212218#endif
    213    if(png_sizeof(png_struct) > png_struct_size)
     219   if (png_sizeof(png_struct) > png_struct_size)
    214220     {
    215        png_ptr->error_fn=NULL;
     221       png_ptr->error_fn = NULL;
    216222#ifdef PNG_ERROR_NUMBERS_SUPPORTED
    217        png_ptr->flags=0;
     223       png_ptr->flags = 0;
    218224#endif
    219225       png_error(png_ptr,
    220226       "The png struct allocated by the application for reading is too small.");
    221227     }
    222    if(png_sizeof(png_info) > png_info_size)
     228   if (png_sizeof(png_info) > png_info_size)
    223229     {
    224        png_ptr->error_fn=NULL;
     230       png_ptr->error_fn = NULL;
    225231#ifdef PNG_ERROR_NUMBERS_SUPPORTED
    226        png_ptr->flags=0;
     232       png_ptr->flags = 0;
    227233#endif
    228234       png_error(png_ptr,
     
    241247#endif
    242248
    243    int i=0;
     249   int i = 0;
    244250
    245251   png_structp png_ptr=*ptr_ptr;
    246252
    247    if(png_ptr == NULL) return;
     253   if (png_ptr == NULL)
     254      return;
    248255
    249256   do
    250257   {
    251      if(user_png_ver[i] != png_libpng_ver[i])
     258     if (user_png_ver[i] != png_libpng_ver[i])
    252259     {
    253260#ifdef PNG_LEGACY_SUPPORTED
    254261       png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
    255262#else
    256        png_ptr->warning_fn=NULL;
     263       png_ptr->warning_fn = NULL;
    257264       png_warning(png_ptr,
    258265        "Application uses deprecated png_read_init() and should be recompiled.");
     
    262269   } while (png_libpng_ver[i++]);
    263270
    264    png_debug(1, "in png_read_init_3\n");
     271   png_debug(1, "in png_read_init_3");
    265272
    266273#ifdef PNG_SETJMP_SUPPORTED
    267    /* save jump buffer and error functions */
    268    png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf));
    269 #endif
    270 
    271    if(png_sizeof(png_struct) > png_struct_size)
    272      {
    273        png_destroy_struct(png_ptr);
    274        *ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
    275        png_ptr = *ptr_ptr;
    276      }
    277 
    278    /* reset all variables to 0 */
    279    png_memset(png_ptr, 0, png_sizeof (png_struct));
     274   /* Save jump buffer and error functions */
     275   png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf));
     276#endif
     277
     278   if (png_sizeof(png_struct) > png_struct_size)
     279   {
     280      png_destroy_struct(png_ptr);
     281      *ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
     282      png_ptr = *ptr_ptr;
     283   }
     284
     285   /* Reset all variables to 0 */
     286   png_memset(png_ptr, 0, png_sizeof(png_struct));
    280287
    281288#ifdef PNG_SETJMP_SUPPORTED
    282    /* restore jump buffer */
    283    png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf));
    284 #endif
    285 
    286    /* added at libpng-1.2.6 */
     289   /* Restore jump buffer */
     290   png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf));
     291#endif
     292
     293   /* Added at libpng-1.2.6 */
    287294#ifdef PNG_SET_USER_LIMITS_SUPPORTED
    288295   png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
     
    290297#endif
    291298
    292    /* initialize zbuf - compression buffer */
     299   /* Initialize zbuf - compression buffer */
    293300   png_ptr->zbuf_size = PNG_ZBUF_SIZE;
    294301   png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
     
    325332png_read_info(png_structp png_ptr, png_infop info_ptr)
    326333{
    327    if(png_ptr == NULL || info_ptr == NULL) return;
    328    png_debug(1, "in png_read_info\n");
     334   if (png_ptr == NULL || info_ptr == NULL)
     335      return;
     336   png_debug(1, "in png_read_info");
    329337   /* If we haven't checked all of the PNG signature bytes, do so now. */
    330338   if (png_ptr->sig_bytes < 8)
     
    348356   }
    349357
    350    for(;;)
     358   for (;;)
    351359   {
    352360#ifdef PNG_USE_LOCAL_ARRAYS
     
    407415#endif
    408416#endif /* PNG_USE_LOCAL_ARRAYS */
    409       png_byte chunk_length[4];
    410       png_uint_32 length;
    411 
    412       png_read_data(png_ptr, chunk_length, 4);
    413       length = png_get_uint_31(png_ptr,chunk_length);
    414 
    415       png_reset_crc(png_ptr);
    416       png_crc_read(png_ptr, png_ptr->chunk_name, 4);
    417 
    418       png_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name,
    419          length);
     417      png_uint_32 length = png_read_chunk_header(png_ptr);
     418      PNG_CONST png_bytep chunk_name = png_ptr->chunk_name;
    420419
    421420      /* This should be a binary subdivision search or a hash for
    422421       * matching the chunk name rather than a linear search.
    423422       */
    424       if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
    425         if(png_ptr->mode & PNG_AFTER_IDAT)
     423      if (!png_memcmp(chunk_name, png_IDAT, 4))
     424        if (png_ptr->mode & PNG_AFTER_IDAT)
    426425          png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
    427426
    428       if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
     427      if (!png_memcmp(chunk_name, png_IHDR, 4))
    429428         png_handle_IHDR(png_ptr, info_ptr, length);
    430       else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
     429      else if (!png_memcmp(chunk_name, png_IEND, 4))
    431430         png_handle_IEND(png_ptr, info_ptr, length);
    432431#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
    433       else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name))
    434       {
    435          if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
     432      else if (png_handle_as_unknown(png_ptr, chunk_name))
     433      {
     434         if (!png_memcmp(chunk_name, png_IDAT, 4))
    436435            png_ptr->mode |= PNG_HAVE_IDAT;
    437436         png_handle_unknown(png_ptr, info_ptr, length);
    438          if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
     437         if (!png_memcmp(chunk_name, png_PLTE, 4))
    439438            png_ptr->mode |= PNG_HAVE_PLTE;
    440          else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
     439         else if (!png_memcmp(chunk_name, png_IDAT, 4))
    441440         {
    442441            if (!(png_ptr->mode & PNG_HAVE_IHDR))
     
    449448      }
    450449#endif
    451       else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
     450      else if (!png_memcmp(chunk_name, png_PLTE, 4))
    452451         png_handle_PLTE(png_ptr, info_ptr, length);
    453       else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
     452      else if (!png_memcmp(chunk_name, png_IDAT, 4))
    454453      {
    455454         if (!(png_ptr->mode & PNG_HAVE_IHDR))
     
    464463      }
    465464#if defined(PNG_READ_bKGD_SUPPORTED)
    466       else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4))
     465      else if (!png_memcmp(chunk_name, png_bKGD, 4))
    467466         png_handle_bKGD(png_ptr, info_ptr, length);
    468467#endif
    469468#if defined(PNG_READ_cHRM_SUPPORTED)
    470       else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4))
     469      else if (!png_memcmp(chunk_name, png_cHRM, 4))
    471470         png_handle_cHRM(png_ptr, info_ptr, length);
    472471#endif
    473472#if defined(PNG_READ_gAMA_SUPPORTED)
    474       else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4))
     473      else if (!png_memcmp(chunk_name, png_gAMA, 4))
    475474         png_handle_gAMA(png_ptr, info_ptr, length);
    476475#endif
    477476#if defined(PNG_READ_hIST_SUPPORTED)
    478       else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4))
     477      else if (!png_memcmp(chunk_name, png_hIST, 4))
    479478         png_handle_hIST(png_ptr, info_ptr, length);
    480479#endif
    481480#if defined(PNG_READ_oFFs_SUPPORTED)
    482       else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4))
     481      else if (!png_memcmp(chunk_name, png_oFFs, 4))
    483482         png_handle_oFFs(png_ptr, info_ptr, length);
    484483#endif
    485484#if defined(PNG_READ_pCAL_SUPPORTED)
    486       else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4))
     485      else if (!png_memcmp(chunk_name, png_pCAL, 4))
    487486         png_handle_pCAL(png_ptr, info_ptr, length);
    488487#endif
    489488#if defined(PNG_READ_sCAL_SUPPORTED)
    490       else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4))
     489      else if (!png_memcmp(chunk_name, png_sCAL, 4))
    491490         png_handle_sCAL(png_ptr, info_ptr, length);
    492491#endif
    493492#if defined(PNG_READ_pHYs_SUPPORTED)
    494       else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4))
     493      else if (!png_memcmp(chunk_name, png_pHYs, 4))
    495494         png_handle_pHYs(png_ptr, info_ptr, length);
    496495#endif
    497496#if defined(PNG_READ_sBIT_SUPPORTED)
    498       else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4))
     497      else if (!png_memcmp(chunk_name, png_sBIT, 4))
    499498         png_handle_sBIT(png_ptr, info_ptr, length);
    500499#endif
    501500#if defined(PNG_READ_sRGB_SUPPORTED)
    502       else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4))
     501      else if (!png_memcmp(chunk_name, png_sRGB, 4))
    503502         png_handle_sRGB(png_ptr, info_ptr, length);
    504503#endif
    505504#if defined(PNG_READ_iCCP_SUPPORTED)
    506       else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4))
     505      else if (!png_memcmp(chunk_name, png_iCCP, 4))
    507506         png_handle_iCCP(png_ptr, info_ptr, length);
    508507#endif
    509508#if defined(PNG_READ_sPLT_SUPPORTED)
    510       else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4))
     509      else if (!png_memcmp(chunk_name, png_sPLT, 4))
    511510         png_handle_sPLT(png_ptr, info_ptr, length);
    512511#endif
    513512#if defined(PNG_READ_tEXt_SUPPORTED)
    514       else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
     513      else if (!png_memcmp(chunk_name, png_tEXt, 4))
    515514         png_handle_tEXt(png_ptr, info_ptr, length);
    516515#endif
    517516#if defined(PNG_READ_tIME_SUPPORTED)
    518       else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4))
     517      else if (!png_memcmp(chunk_name, png_tIME, 4))
    519518         png_handle_tIME(png_ptr, info_ptr, length);
    520519#endif
    521520#if defined(PNG_READ_tRNS_SUPPORTED)
    522       else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4))
     521      else if (!png_memcmp(chunk_name, png_tRNS, 4))
    523522         png_handle_tRNS(png_ptr, info_ptr, length);
    524523#endif
    525524#if defined(PNG_READ_zTXt_SUPPORTED)
    526       else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
     525      else if (!png_memcmp(chunk_name, png_zTXt, 4))
    527526         png_handle_zTXt(png_ptr, info_ptr, length);
    528527#endif
    529528#if defined(PNG_READ_iTXt_SUPPORTED)
    530       else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
     529      else if (!png_memcmp(chunk_name, png_iTXt, 4))
    531530         png_handle_iTXt(png_ptr, info_ptr, length);
    532531#endif
     
    537536#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
    538537
    539 /* optional call to update the users info_ptr structure */
     538/* Optional call to update the users info_ptr structure */
    540539void PNGAPI
    541540png_read_update_info(png_structp png_ptr, png_infop info_ptr)
    542541{
    543    png_debug(1, "in png_read_update_info\n");
    544    if(png_ptr == NULL) return;
     542   png_debug(1, "in png_read_update_info");
     543   if (png_ptr == NULL)
     544      return;
    545545   if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
    546546      png_read_start_row(png_ptr);
     
    560560png_start_read_image(png_structp png_ptr)
    561561{
    562    png_debug(1, "in png_start_read_image\n");
    563    if(png_ptr == NULL) return;
     562   png_debug(1, "in png_start_read_image");
     563   if (png_ptr == NULL)
     564      return;
    564565   if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
    565566      png_read_start_row(png_ptr);
     
    574575   PNG_CONST PNG_IDAT;
    575576   PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
    576      0xff};
     577      0xff};
    577578   PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
    578579#endif
    579580   int ret;
    580    if(png_ptr == NULL) return;
    581    png_debug2(1, "in png_read_row (row %lu, pass %d)\n",
     581   if (png_ptr == NULL)
     582      return;
     583   png_debug2(1, "in png_read_row (row %lu, pass %d)",
    582584      png_ptr->row_number, png_ptr->pass);
    583585   if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
     
    585587   if (png_ptr->row_number == 0 && png_ptr->pass == 0)
    586588   {
    587    /* check for transforms that have been set but were defined out */
     589   /* Check for transforms that have been set but were defined out */
    588590#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED)
    589591   if (png_ptr->transformations & PNG_INVERT_MONO)
     
    617619
    618620#if defined(PNG_READ_INTERLACING_SUPPORTED)
    619    /* if interlaced and we do not need a new row, combine row and return */
     621   /* If interlaced and we do not need a new row, combine row and return */
    620622   if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
    621623   {
     
    704706         while (!png_ptr->idat_size)
    705707         {
    706             png_byte chunk_length[4];
    707 
    708708            png_crc_finish(png_ptr, 0);
    709709
    710             png_read_data(png_ptr, chunk_length, 4);
    711             png_ptr->idat_size = png_get_uint_31(png_ptr,chunk_length);
    712 
    713             png_reset_crc(png_ptr);
    714             png_crc_read(png_ptr, png_ptr->chunk_name, 4);
     710            png_ptr->idat_size = png_read_chunk_header(png_ptr);
    715711            if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
    716712               png_error(png_ptr, "Not enough image data");
     
    748744       png_ptr->row_info.width);
    749745
    750    if(png_ptr->row_buf[0])
     746   if (png_ptr->row_buf[0])
    751747   png_read_filter_row(png_ptr, &(png_ptr->row_info),
    752748      png_ptr->row_buf + 1, png_ptr->prev_row + 1,
     
    757753
    758754#if defined(PNG_MNG_FEATURES_SUPPORTED)
    759    if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
     755   if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
    760756      (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
    761757   {
     
    770766
    771767#if defined(PNG_READ_INTERLACING_SUPPORTED)
    772    /* blow up interlaced rows to full size */
     768   /* Blow up interlaced rows to full size */
    773769   if (png_ptr->interlaced &&
    774770      (png_ptr->transformations & PNG_INTERLACE))
    775771   {
    776772      if (png_ptr->pass < 6)
    777 /*       old interface (pre-1.0.9):
    778          png_do_read_interlace(&(png_ptr->row_info),
    779             png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations);
    780  */
     773         /* Old interface (pre-1.0.9):
     774          * png_do_read_interlace(&(png_ptr->row_info),
     775            png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations);
     776          */
    781777         png_do_read_interlace(png_ptr);
    782778
     
    836832   png_bytepp dp;
    837833
    838    png_debug(1, "in png_read_rows\n");
    839    if(png_ptr == NULL) return;
     834   png_debug(1, "in png_read_rows");
     835   if (png_ptr == NULL)
     836      return;
    840837   rp = row;
    841838   dp = display_row;
     
    848845         png_read_row(png_ptr, rptr, dptr);
    849846      }
    850    else if(rp != NULL)
     847   else if (rp != NULL)
    851848      for (i = 0; i < num_rows; i++)
    852849      {
     
    855852         rp++;
    856853      }
    857    else if(dp != NULL)
     854   else if (dp != NULL)
    858855      for (i = 0; i < num_rows; i++)
    859856      {
     
    881878png_read_image(png_structp png_ptr, png_bytepp image)
    882879{
    883    png_uint_32 i,image_height;
     880   png_uint_32 i, image_height;
    884881   int pass, j;
    885882   png_bytepp rp;
    886883
    887    png_debug(1, "in png_read_image\n");
    888    if(png_ptr == NULL) return;
     884   png_debug(1, "in png_read_image");
     885   if (png_ptr == NULL)
     886      return;
    889887
    890888#ifdef PNG_READ_INTERLACING_SUPPORTED
     
    921919png_read_end(png_structp png_ptr, png_infop info_ptr)
    922920{
    923    png_byte chunk_length[4];
    924    png_uint_32 length;
    925 
    926    png_debug(1, "in png_read_end\n");
    927    if(png_ptr == NULL) return;
     921   png_debug(1, "in png_read_end");
     922   if (png_ptr == NULL)
     923      return;
    928924   png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */
    929925
     
    987983#endif
    988984#endif /* PNG_USE_LOCAL_ARRAYS */
    989 
    990       png_read_data(png_ptr, chunk_length, 4);
    991       length = png_get_uint_31(png_ptr,chunk_length);
    992 
    993       png_reset_crc(png_ptr);
    994       png_crc_read(png_ptr, png_ptr->chunk_name, 4);
    995 
    996       png_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name);
    997 
    998       if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
     985      png_uint_32 length = png_read_chunk_header(png_ptr);
     986      PNG_CONST png_bytep chunk_name = png_ptr->chunk_name;
     987
     988      if (!png_memcmp(chunk_name, png_IHDR, 4))
    999989         png_handle_IHDR(png_ptr, info_ptr, length);
    1000       else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
     990      else if (!png_memcmp(chunk_name, png_IEND, 4))
    1001991         png_handle_IEND(png_ptr, info_ptr, length);
    1002992#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
    1003       else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name))
    1004       {
    1005          if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
     993      else if (png_handle_as_unknown(png_ptr, chunk_name))
     994      {
     995         if (!png_memcmp(chunk_name, png_IDAT, 4))
    1006996         {
    1007997            if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
     
    1009999         }
    10101000         png_handle_unknown(png_ptr, info_ptr, length);
    1011          if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
     1001         if (!png_memcmp(chunk_name, png_PLTE, 4))
    10121002            png_ptr->mode |= PNG_HAVE_PLTE;
    10131003      }
    10141004#endif
    1015       else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
     1005      else if (!png_memcmp(chunk_name, png_IDAT, 4))
    10161006      {
    10171007         /* Zero length IDATs are legal after the last IDAT has been
     
    10221012         png_crc_finish(png_ptr, length);
    10231013      }
    1024       else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
     1014      else if (!png_memcmp(chunk_name, png_PLTE, 4))
    10251015         png_handle_PLTE(png_ptr, info_ptr, length);
    10261016#if defined(PNG_READ_bKGD_SUPPORTED)
    1027       else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4))
     1017      else if (!png_memcmp(chunk_name, png_bKGD, 4))
    10281018         png_handle_bKGD(png_ptr, info_ptr, length);
    10291019#endif
    10301020#if defined(PNG_READ_cHRM_SUPPORTED)
    1031       else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4))
     1021      else if (!png_memcmp(chunk_name, png_cHRM, 4))
    10321022         png_handle_cHRM(png_ptr, info_ptr, length);
    10331023#endif
    10341024#if defined(PNG_READ_gAMA_SUPPORTED)
    1035       else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4))
     1025      else if (!png_memcmp(chunk_name, png_gAMA, 4))
    10361026         png_handle_gAMA(png_ptr, info_ptr, length);
    10371027#endif
    10381028#if defined(PNG_READ_hIST_SUPPORTED)
    1039       else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4))
     1029      else if (!png_memcmp(chunk_name, png_hIST, 4))
    10401030         png_handle_hIST(png_ptr, info_ptr, length);
    10411031#endif
    10421032#if defined(PNG_READ_oFFs_SUPPORTED)
    1043       else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4))
     1033      else if (!png_memcmp(chunk_name, png_oFFs, 4))
    10441034         png_handle_oFFs(png_ptr, info_ptr, length);
    10451035#endif
    10461036#if defined(PNG_READ_pCAL_SUPPORTED)
    1047       else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4))
     1037      else if (!png_memcmp(chunk_name, png_pCAL, 4))
    10481038         png_handle_pCAL(png_ptr, info_ptr, length);
    10491039#endif
    10501040#if defined(PNG_READ_sCAL_SUPPORTED)
    1051       else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4))
     1041      else if (!png_memcmp(chunk_name, png_sCAL, 4))
    10521042         png_handle_sCAL(png_ptr, info_ptr, length);
    10531043#endif
    10541044#if defined(PNG_READ_pHYs_SUPPORTED)
    1055       else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4))
     1045      else if (!png_memcmp(chunk_name, png_pHYs, 4))
    10561046         png_handle_pHYs(png_ptr, info_ptr, length);
    10571047#endif
    10581048#if defined(PNG_READ_sBIT_SUPPORTED)
    1059       else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4))
     1049      else if (!png_memcmp(chunk_name, png_sBIT, 4))
    10601050         png_handle_sBIT(png_ptr, info_ptr, length);
    10611051#endif
    10621052#if defined(PNG_READ_sRGB_SUPPORTED)
    1063       else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4))
     1053      else if (!png_memcmp(chunk_name, png_sRGB, 4))
    10641054         png_handle_sRGB(png_ptr, info_ptr, length);
    10651055#endif
    10661056#if defined(PNG_READ_iCCP_SUPPORTED)
    1067       else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4))
     1057      else if (!png_memcmp(chunk_name, png_iCCP, 4))
    10681058         png_handle_iCCP(png_ptr, info_ptr, length);
    10691059#endif
    10701060#if defined(PNG_READ_sPLT_SUPPORTED)
    1071       else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4))
     1061      else if (!png_memcmp(chunk_name, png_sPLT, 4))
    10721062         png_handle_sPLT(png_ptr, info_ptr, length);
    10731063#endif
    10741064#if defined(PNG_READ_tEXt_SUPPORTED)
    1075       else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
     1065      else if (!png_memcmp(chunk_name, png_tEXt, 4))
    10761066         png_handle_tEXt(png_ptr, info_ptr, length);
    10771067#endif
    10781068#if defined(PNG_READ_tIME_SUPPORTED)
    1079       else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4))
     1069      else if (!png_memcmp(chunk_name, png_tIME, 4))
    10801070         png_handle_tIME(png_ptr, info_ptr, length);
    10811071#endif
    10821072#if defined(PNG_READ_tRNS_SUPPORTED)
    1083       else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4))
     1073      else if (!png_memcmp(chunk_name, png_tRNS, 4))
    10841074         png_handle_tRNS(png_ptr, info_ptr, length);
    10851075#endif
    10861076#if defined(PNG_READ_zTXt_SUPPORTED)
    1087       else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
     1077      else if (!png_memcmp(chunk_name, png_zTXt, 4))
    10881078         png_handle_zTXt(png_ptr, info_ptr, length);
    10891079#endif
    10901080#if defined(PNG_READ_iTXt_SUPPORTED)
    1091       else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
     1081      else if (!png_memcmp(chunk_name, png_iTXt, 4))
    10921082         png_handle_iTXt(png_ptr, info_ptr, length);
    10931083#endif
     
    10981088#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
    10991089
    1100 /* free all memory used by the read */
     1090/* Free all memory used by the read */
    11011091void PNGAPI
    11021092png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
     
    11101100#endif
    11111101
    1112    png_debug(1, "in png_destroy_read_struct\n");
     1102   png_debug(1, "in png_destroy_read_struct");
    11131103   if (png_ptr_ptr != NULL)
    1114    {
    11151104      png_ptr = *png_ptr_ptr;
    1116    }
    11171105   if (png_ptr == NULL)
    11181106      return;
     
    11601148   }
    11611149
     1150   if (png_ptr != NULL)
     1151   {
    11621152#ifdef PNG_USER_MEM_SUPPORTED
    1163    png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,
    1164        (png_voidp)mem_ptr);
     1153      png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,
     1154          (png_voidp)mem_ptr);
    11651155#else
    1166    png_destroy_struct((png_voidp)png_ptr);
    1167 #endif
    1168    *png_ptr_ptr = NULL;
    1169 }
    1170 
    1171 /* free all memory used by the read (old method) */
     1156      png_destroy_struct((png_voidp)png_ptr);
     1157#endif
     1158      *png_ptr_ptr = NULL;
     1159   }
     1160}
     1161
     1162/* Free all memory used by the read (old method) */
    11721163void /* PRIVATE */
    11731164png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr)
     
    11831174#endif
    11841175
    1185    png_debug(1, "in png_read_destroy\n");
     1176   png_debug(1, "in png_read_destroy");
    11861177   if (info_ptr != NULL)
    11871178      png_info_destroy(png_ptr, info_ptr);
     
    11931184   png_free(png_ptr, png_ptr->big_row_buf);
    11941185   png_free(png_ptr, png_ptr->prev_row);
     1186   png_free(png_ptr, png_ptr->chunkdata);
    11951187#if defined(PNG_READ_DITHER_SUPPORTED)
    11961188   png_free(png_ptr, png_ptr->palette_lookup);
     
    12891281    */
    12901282#ifdef PNG_SETJMP_SUPPORTED
    1291    png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf));
     1283   png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf));
    12921284#endif
    12931285
     
    12991291#endif
    13001292
    1301    png_memset(png_ptr, 0, png_sizeof (png_struct));
     1293   png_memset(png_ptr, 0, png_sizeof(png_struct));
    13021294
    13031295   png_ptr->error_fn = error_fn;
     
    13091301
    13101302#ifdef PNG_SETJMP_SUPPORTED
    1311    png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf));
     1303   png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf));
    13121304#endif
    13131305
     
    13171309png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn)
    13181310{
    1319    if(png_ptr == NULL) return;
     1311   if (png_ptr == NULL)
     1312      return;
    13201313   png_ptr->read_row_fn = read_row_fn;
    13211314}
     
    13311324   int row;
    13321325
    1333    if(png_ptr == NULL) return;
     1326   if (png_ptr == NULL)
     1327      return;
    13341328#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
    1335    /* invert the alpha channel from opacity to transparency
     1329   /* Invert the alpha channel from opacity to transparency
    13361330    */
    13371331   if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
     
    13441338   png_read_info(png_ptr, info_ptr);
    13451339   if (info_ptr->height > PNG_UINT_32_MAX/png_sizeof(png_bytep))
    1346       png_error(png_ptr,"Image is too high to process with png_read_png()");
     1340      png_error(png_ptr, "Image is too high to process with png_read_png()");
    13471341
    13481342   /* -------------- image transformations start here ------------------- */
    13491343
    13501344#if defined(PNG_READ_16_TO_8_SUPPORTED)
    1351    /* tell libpng to strip 16 bit/color files down to 8 bits per color
     1345   /* Tell libpng to strip 16 bit/color files down to 8 bits per color.
    13521346    */
    13531347   if (transforms & PNG_TRANSFORM_STRIP_16)
    1354        png_set_strip_16(png_ptr);
     1348      png_set_strip_16(png_ptr);
    13551349#endif
    13561350
     
    13601354    */
    13611355   if (transforms & PNG_TRANSFORM_STRIP_ALPHA)
    1362        png_set_strip_alpha(png_ptr);
     1356      png_set_strip_alpha(png_ptr);
    13631357#endif
    13641358
     
    13681362    */
    13691363   if (transforms & PNG_TRANSFORM_PACKING)
    1370        png_set_packing(png_ptr);
     1364      png_set_packing(png_ptr);
    13711365#endif
    13721366
     
    13761370    */
    13771371   if (transforms & PNG_TRANSFORM_PACKSWAP)
    1378        png_set_packswap(png_ptr);
     1372      png_set_packswap(png_ptr);
    13791373#endif
    13801374
     
    13861380    */
    13871381   if (transforms & PNG_TRANSFORM_EXPAND)
    1388        if ((png_ptr->bit_depth < 8) ||
    1389            (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ||
    1390            (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)))
     1382      if ((png_ptr->bit_depth < 8) ||
     1383          (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ||
     1384          (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)))
    13911385         png_set_expand(png_ptr);
    13921386#endif
     
    13961390
    13971391#if defined(PNG_READ_INVERT_SUPPORTED)
    1398    /* invert monochrome files to have 0 as white and 1 as black
     1392   /* Invert monochrome files to have 0 as white and 1 as black
    13991393    */
    14001394   if (transforms & PNG_TRANSFORM_INVERT_MONO)
    1401        png_set_invert_mono(png_ptr);
     1395      png_set_invert_mono(png_ptr);
    14021396#endif
    14031397
     
    14181412
    14191413#if defined(PNG_READ_BGR_SUPPORTED)
    1420    /* flip the RGB pixels to BGR (or RGBA to BGRA)
     1414   /* Flip the RGB pixels to BGR (or RGBA to BGRA)
    14211415    */
    14221416   if (transforms & PNG_TRANSFORM_BGR)
    1423        png_set_bgr(png_ptr);
     1417      png_set_bgr(png_ptr);
    14241418#endif
    14251419
    14261420#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
    1427    /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR)
     1421   /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR)
    14281422    */
    14291423   if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
     
    14321426
    14331427#if defined(PNG_READ_SWAP_SUPPORTED)
    1434    /* swap bytes of 16 bit files to least significant byte first
     1428   /* Swap bytes of 16 bit files to least significant byte first
    14351429    */
    14361430   if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
    1437        png_set_swap(png_ptr);
     1431      png_set_swap(png_ptr);
    14381432#endif
    14391433
     
    14511445   png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
    14521446#endif
    1453    if(info_ptr->row_pointers == NULL)
     1447   if (info_ptr->row_pointers == NULL)
    14541448   {
    14551449      info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
    14561450         info_ptr->height * png_sizeof(png_bytep));
     1451      png_memset(info_ptr->row_pointers, 0, info_ptr->height
     1452         * png_sizeof(png_bytep));
    14571453#ifdef PNG_FREE_ME_SUPPORTED
    14581454      info_ptr->free_me |= PNG_FREE_ROWS;
    14591455#endif
    14601456      for (row = 0; row < (int)info_ptr->height; row++)
    1461       {
    14621457         info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr,
    14631458            png_get_rowbytes(png_ptr, info_ptr));
    1464       }
    14651459   }
    14661460
     
    14681462   info_ptr->valid |= PNG_INFO_IDAT;
    14691463
    1470    /* read rest of file, and get additional chunks in info_ptr - REQUIRED */
     1464   /* Read rest of file, and get additional chunks in info_ptr - REQUIRED */
    14711465   png_read_end(png_ptr, info_ptr);
    14721466
    1473    transforms = transforms; /* quiet compiler warnings */
     1467   transforms = transforms; /* Quiet compiler warnings */
    14741468   params = params;
    14751469
  • trunk/src/3rdparty/libpng/pngrio.c

    r2 r561  
    22/* pngrio.c - functions for data input
    33 *
    4  * Last changed in libpng 1.2.13 November 13, 2006
    5  * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2006 Glenn Randers-Pehrson
     4 * Last changed in libpng 1.2.37 [June 4, 2009]
     5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
    76 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    87 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     8 *
     9 * This code is released under the libpng license.
     10 * For conditions of distribution and use, see the disclaimer
     11 * and license in png.h
    912 *
    1013 * This file provides a location for all input.  Users who need
     
    1821#define PNG_INTERNAL
    1922#include "png.h"
    20 
    2123#if defined(PNG_READ_SUPPORTED)
    2224
    2325/* Read the data from whatever input you are using.  The default routine
    24    reads from a file pointer.  Note that this routine sometimes gets called
    25    with very small lengths, so you should implement some kind of simple
    26    buffering if you are using unbuffered reads.  This should never be asked
    27    to read more then 64K on a 16 bit machine. */
     26 * reads from a file pointer.  Note that this routine sometimes gets called
     27 * with very small lengths, so you should implement some kind of simple
     28 * buffering if you are using unbuffered reads.  This should never be asked
     29 * to read more then 64K on a 16 bit machine.
     30 */
    2831void /* PRIVATE */
    2932png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
    3033{
    31    png_debug1(4,"reading %d bytes\n", (int)length);
     34   png_debug1(4, "reading %d bytes", (int)length);
    3235   if (png_ptr->read_data_fn != NULL)
    3336      (*(png_ptr->read_data_fn))(png_ptr, data, length);
     
    3841#if !defined(PNG_NO_STDIO)
    3942/* This is the function that does the actual reading of data.  If you are
    40    not reading from a standard C stream, you should create a replacement
    41    read_data function and use it at run time with png_set_read_fn(), rather
    42    than changing the library. */
     43 * not reading from a standard C stream, you should create a replacement
     44 * read_data function and use it at run time with png_set_read_fn(), rather
     45 * than changing the library.
     46 */
    4347#ifndef USE_FAR_KEYWORD
    4448void PNGAPI
     
    4751   png_size_t check;
    4852
    49    if(png_ptr == NULL) return;
     53   if (png_ptr == NULL)
     54      return;
    5055   /* fread() returns 0 on error, so it is OK to store this in a png_size_t
    5156    * instead of an int, which is what fread() actually returns.
     
    6368}
    6469#else
    65 /* this is the model-independent version. Since the standard I/O library
     70/* This is the model-independent version. Since the standard I/O library
    6671   can't handle far buffers in the medium and small models, we have to copy
    6772   the data.
     
    7883   png_FILE_p io_ptr;
    7984
    80    if(png_ptr == NULL) return;
     85   if (png_ptr == NULL)
     86      return;
    8187   /* Check if data really is near. If so, use usual code. */
    8288   n_data = (png_byte *)CVT_PTR_NOCHECK(data);
     
    107113#endif
    108114         png_memcpy(data, buf, read); /* copy far buffer to near buffer */
    109          if(err != read)
     115         if (err != read)
    110116            break;
    111117         else
     
    123129
    124130/* This function allows the application to supply a new input function
    125    for libpng if standard C streams aren't being used.
    126 
    127    This function takes as its arguments:
    128    png_ptr      - pointer to a png input data structure
    129    io_ptr       - pointer to user supplied structure containing info about
    130                   the input functions.  May be NULL.
    131    read_data_fn - pointer to a new input function that takes as its
    132                   arguments a pointer to a png_struct, a pointer to
    133                   a location where input data can be stored, and a 32-bit
    134                   unsigned int that is the number of bytes to be read.
    135                   To exit and output any fatal error messages the new write
    136                   function should call png_error(png_ptr, "Error msg"). */
     131 * for libpng if standard C streams aren't being used.
     132 *
     133 * This function takes as its arguments:
     134 * png_ptr      - pointer to a png input data structure
     135 * io_ptr       - pointer to user supplied structure containing info about
     136 *                the input functions.  May be NULL.
     137 * read_data_fn - pointer to a new input function that takes as its
     138 *                arguments a pointer to a png_struct, a pointer to
     139 *                a location where input data can be stored, and a 32-bit
     140 *                unsigned int that is the number of bytes to be read.
     141 *                To exit and output any fatal error messages the new write
     142 *                function should call png_error(png_ptr, "Error msg").
     143 *                May be NULL, in which case libpng's default function will
     144 *                be used.
     145 */
    137146void PNGAPI
    138147png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
    139148   png_rw_ptr read_data_fn)
    140149{
    141    if(png_ptr == NULL) return;
     150   if (png_ptr == NULL)
     151      return;
    142152   png_ptr->io_ptr = io_ptr;
    143153
  • trunk/src/3rdparty/libpng/pngrtran.c

    r2 r561  
    22/* pngrtran.c - transforms the data in a row for PNG readers
    33 *
    4  * Last changed in libpng 1.2.27 [April 29, 2008]
    5  * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2008 Glenn Randers-Pehrson
     4 * Last changed in libpng 1.2.38 [July 16, 2009]
     5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
    76 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    87 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     8 *
     9 * This code is released under the libpng license.
     10 * For conditions of distribution and use, see the disclaimer
     11 * and license in png.h
    912 *
    1013 * This file contains functions optionally called by an application
     
    1619#define PNG_INTERNAL
    1720#include "png.h"
    18 
    1921#if defined(PNG_READ_SUPPORTED)
    2022
     
    2325png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
    2426{
    25    png_debug(1, "in png_set_crc_action\n");
     27   png_debug(1, "in png_set_crc_action");
    2628   /* Tell libpng how we react to CRC errors in critical chunks */
    27    if(png_ptr == NULL) return;
     29   if (png_ptr == NULL)
     30      return;
    2831   switch (crit_action)
    2932   {
    30       case PNG_CRC_NO_CHANGE:                        /* leave setting as is */
     33      case PNG_CRC_NO_CHANGE:                        /* Leave setting as is */
    3134         break;
    32       case PNG_CRC_WARN_USE:                               /* warn/use data */
     35
     36      case PNG_CRC_WARN_USE:                               /* Warn/use data */
    3337         png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;
    3438         png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE;
    3539         break;
    36       case PNG_CRC_QUIET_USE:                             /* quiet/use data */
     40
     41      case PNG_CRC_QUIET_USE:                             /* Quiet/use data */
    3742         png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;
    3843         png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE |
    3944                           PNG_FLAG_CRC_CRITICAL_IGNORE;
    4045         break;
    41       case PNG_CRC_WARN_DISCARD:    /* not a valid action for critical data */
    42          png_warning(png_ptr, "Can't discard critical data on CRC error.");
    43       case PNG_CRC_ERROR_QUIT:                                /* error/quit */
     46
     47      case PNG_CRC_WARN_DISCARD:    /* Not a valid action for critical data */
     48         png_warning(png_ptr,
     49            "Can't discard critical data on CRC error.");
     50      case PNG_CRC_ERROR_QUIT:                                /* Error/quit */
     51
    4452      case PNG_CRC_DEFAULT:
    4553      default:
     
    5058   switch (ancil_action)
    5159   {
    52       case PNG_CRC_NO_CHANGE:                       /* leave setting as is */
     60      case PNG_CRC_NO_CHANGE:                       /* Leave setting as is */
    5361         break;
    54       case PNG_CRC_WARN_USE:                              /* warn/use data */
     62
     63      case PNG_CRC_WARN_USE:                              /* Warn/use data */
    5564         png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;
    5665         png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE;
    5766         break;
    58       case PNG_CRC_QUIET_USE:                            /* quiet/use data */
     67
     68      case PNG_CRC_QUIET_USE:                            /* Quiet/use data */
    5969         png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;
    6070         png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE |
    6171                           PNG_FLAG_CRC_ANCILLARY_NOWARN;
    6272         break;
    63       case PNG_CRC_ERROR_QUIT:                               /* error/quit */
     73
     74      case PNG_CRC_ERROR_QUIT:                               /* Error/quit */
    6475         png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;
    6576         png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN;
    6677         break;
    67       case PNG_CRC_WARN_DISCARD:                      /* warn/discard data */
     78
     79      case PNG_CRC_WARN_DISCARD:                      /* Warn/discard data */
     80
    6881      case PNG_CRC_DEFAULT:
    6982      default:
     
    7588#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
    7689    defined(PNG_FLOATING_POINT_SUPPORTED)
    77 /* handle alpha and tRNS via a background color */
     90/* Handle alpha and tRNS via a background color */
    7891void PNGAPI
    7992png_set_background(png_structp png_ptr,
     
    8194   int need_expand, double background_gamma)
    8295{
    83    png_debug(1, "in png_set_background\n");
    84    if(png_ptr == NULL) return;
     96   png_debug(1, "in png_set_background");
     97   if (png_ptr == NULL)
     98      return;
    8599   if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)
    86100   {
     
    99113
    100114#if defined(PNG_READ_16_TO_8_SUPPORTED)
    101 /* strip 16 bit depth files to 8 bit depth */
     115/* Strip 16 bit depth files to 8 bit depth */
    102116void PNGAPI
    103117png_set_strip_16(png_structp png_ptr)
    104118{
    105    png_debug(1, "in png_set_strip_16\n");
    106    if(png_ptr == NULL) return;
     119   png_debug(1, "in png_set_strip_16");
     120   if (png_ptr == NULL)
     121      return;
    107122   png_ptr->transformations |= PNG_16_TO_8;
    108123}
     
    113128png_set_strip_alpha(png_structp png_ptr)
    114129{
    115    png_debug(1, "in png_set_strip_alpha\n");
    116    if(png_ptr == NULL) return;
     130   png_debug(1, "in png_set_strip_alpha");
     131   if (png_ptr == NULL)
     132      return;
    117133   png_ptr->flags |= PNG_FLAG_STRIP_ALPHA;
    118134}
     
    143159   int full_dither)
    144160{
    145    png_debug(1, "in png_set_dither\n");
    146    if(png_ptr == NULL) return;
     161   png_debug(1, "in png_set_dither");
     162   if (png_ptr == NULL)
     163      return;
    147164   png_ptr->transformations |= PNG_DITHER;
    148165
     
    152169
    153170      png_ptr->dither_index = (png_bytep)png_malloc(png_ptr,
    154          (png_uint_32)(num_palette * png_sizeof (png_byte)));
     171         (png_uint_32)(num_palette * png_sizeof(png_byte)));
    155172      for (i = 0; i < num_palette; i++)
    156173         png_ptr->dither_index[i] = (png_byte)i;
     
    162179      {
    163180         /* This is easy enough, just throw out the least used colors.
    164             Perhaps not the best solution, but good enough. */
     181          * Perhaps not the best solution, but good enough.
     182          */
    165183
    166184         int i;
    167185
    168          /* initialize an array to sort colors */
     186         /* Initialize an array to sort colors */
    169187         png_ptr->dither_sort = (png_bytep)png_malloc(png_ptr,
    170             (png_uint_32)(num_palette * png_sizeof (png_byte)));
    171 
    172          /* initialize the dither_sort array */
     188            (png_uint_32)(num_palette * png_sizeof(png_byte)));
     189
     190         /* Initialize the dither_sort array */
    173191         for (i = 0; i < num_palette; i++)
    174192            png_ptr->dither_sort[i] = (png_byte)i;
    175193
    176194         /* Find the least used palette entries by starting a
    177             bubble sort, and running it until we have sorted
    178             out enough colors.  Note that we don't care about
    179             sorting all the colors, just finding which are
    180             least used. */
     195          * bubble sort, and running it until we have sorted
     196          * out enough colors.  Note that we don't care about
     197          * sorting all the colors, just finding which are
     198          * least used.
     199          */
    181200
    182201         for (i = num_palette - 1; i >= maximum_colors; i--)
    183202         {
    184             int done; /* to stop early if the list is pre-sorted */
     203            int done; /* To stop early if the list is pre-sorted */
    185204            int j;
    186205
     
    203222         }
    204223
    205          /* swap the palette around, and set up a table, if necessary */
     224         /* Swap the palette around, and set up a table, if necessary */
    206225         if (full_dither)
    207226         {
    208227            int j = num_palette;
    209228
    210             /* put all the useful colors within the max, but don't
    211                move the others */
     229            /* Put all the useful colors within the max, but don't
     230             * move the others.
     231             */
    212232            for (i = 0; i < maximum_colors; i++)
    213233            {
     
    225245            int j = num_palette;
    226246
    227             /* move all the used colors inside the max limit, and
    228                develop a translation table */
     247            /* Move all the used colors inside the max limit, and
     248             * develop a translation table.
     249             */
    229250            for (i = 0; i < maximum_colors; i++)
    230251            {
    231                /* only move the colors we need to */
     252               /* Only move the colors we need to */
    232253               if ((int)png_ptr->dither_sort[i] >= maximum_colors)
    233254               {
     
    241262                  palette[j] = palette[i];
    242263                  palette[i] = tmp_color;
    243                   /* indicate where the color went */
     264                  /* Indicate where the color went */
    244265                  png_ptr->dither_index[j] = (png_byte)i;
    245266                  png_ptr->dither_index[i] = (png_byte)j;
     
    247268            }
    248269
    249             /* find closest color for those colors we are not using */
     270            /* Find closest color for those colors we are not using */
    250271            for (i = 0; i < num_palette; i++)
    251272            {
     
    254275                  int min_d, k, min_k, d_index;
    255276
    256                   /* find the closest color to one we threw out */
     277                  /* Find the closest color to one we threw out */
    257278                  d_index = png_ptr->dither_index[i];
    258279                  min_d = PNG_COLOR_DIST(palette[d_index], palette[0]);
     
    269290                     }
    270291                  }
    271                   /* point to closest color */
     292                  /* Point to closest color */
    272293                  png_ptr->dither_index[i] = (png_byte)min_k;
    273294               }
     
    275296         }
    276297         png_free(png_ptr, png_ptr->dither_sort);
    277          png_ptr->dither_sort=NULL;
     298         png_ptr->dither_sort = NULL;
    278299      }
    279300      else
    280301      {
    281302         /* This is much harder to do simply (and quickly).  Perhaps
    282             we need to go through a median cut routine, but those
    283             don't always behave themselves with only a few colors
    284             as input.  So we will just find the closest two colors,
    285             and throw out one of them (chosen somewhat randomly).
    286             [We don't understand this at all, so if someone wants to
    287              work on improving it, be our guest - AED, GRP]
    288             */
     303          * we need to go through a median cut routine, but those
     304          * don't always behave themselves with only a few colors
     305          * as input.  So we will just find the closest two colors,
     306          * and throw out one of them (chosen somewhat randomly).
     307          * [We don't understand this at all, so if someone wants to
     308          *  work on improving it, be our guest - AED, GRP]
     309          */
    289310         int i;
    290311         int max_d;
     
    293314         png_dsortpp hash;
    294315
    295          t=NULL;
    296 
    297          /* initialize palette index arrays */
     316         t = NULL;
     317
     318         /* Initialize palette index arrays */
    298319         png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
    299             (png_uint_32)(num_palette * png_sizeof (png_byte)));
     320            (png_uint_32)(num_palette * png_sizeof(png_byte)));
    300321         png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
    301             (png_uint_32)(num_palette * png_sizeof (png_byte)));
    302 
    303          /* initialize the sort array */
     322            (png_uint_32)(num_palette * png_sizeof(png_byte)));
     323
     324         /* Initialize the sort array */
    304325         for (i = 0; i < num_palette; i++)
    305326         {
     
    309330
    310331         hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 *
    311             png_sizeof (png_dsortp)));
    312          for (i = 0; i < 769; i++)
    313             hash[i] = NULL;
    314 /*         png_memset(hash, 0, 769 * png_sizeof (png_dsortp)); */
     332            png_sizeof(png_dsortp)));
     333         png_memset(hash, 0, 769 * png_sizeof(png_dsortp));
    315334
    316335         num_new_palette = num_palette;
    317336
    318          /* initial wild guess at how far apart the farthest pixel
    319             pair we will be eliminating will be.  Larger
    320             numbers mean more areas will be allocated, Smaller
    321             numbers run the risk of not saving enough data, and
    322             having to do this all over again.
    323 
    324             I have not done extensive checking on this number.
    325             */
     337         /* Initial wild guess at how far apart the farthest pixel
     338          * pair we will be eliminating will be.  Larger
     339          * numbers mean more areas will be allocated, Smaller
     340          * numbers run the risk of not saving enough data, and
     341          * having to do this all over again.
     342          *
     343          * I have not done extensive checking on this number.
     344          */
    326345         max_d = 96;
    327346
     
    437456         png_free(png_ptr, png_ptr->palette_to_index);
    438457         png_free(png_ptr, png_ptr->index_to_palette);
    439          png_ptr->palette_to_index=NULL;
    440          png_ptr->index_to_palette=NULL;
     458         png_ptr->palette_to_index = NULL;
     459         png_ptr->index_to_palette = NULL;
    441460      }
    442461      num_palette = maximum_colors;
     
    458477      int num_blue = (1 << PNG_DITHER_BLUE_BITS);
    459478      png_size_t num_entries = ((png_size_t)1 << total_bits);
    460 
    461479      png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr,
    462          (png_uint_32)(num_entries * png_sizeof (png_byte)));
    463 
     480         (png_uint_32)(num_entries * png_sizeof(png_byte)));
    464481      png_memset(png_ptr->palette_lookup, 0, num_entries *
    465          png_sizeof (png_byte));
     482         png_sizeof(png_byte));
    466483
    467484      distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries *
     
    527544png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
    528545{
    529    png_debug(1, "in png_set_gamma\n");
    530    if(png_ptr == NULL) return;
     546   png_debug(1, "in png_set_gamma");
     547   if (png_ptr == NULL)
     548      return;
    531549   if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) ||
    532550       (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) ||
     
    546564png_set_expand(png_structp png_ptr)
    547565{
    548    png_debug(1, "in png_set_expand\n");
    549    if(png_ptr == NULL) return;
     566   png_debug(1, "in png_set_expand");
     567   if (png_ptr == NULL)
     568      return;
    550569   png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
    551570   png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
     
    573592png_set_palette_to_rgb(png_structp png_ptr)
    574593{
    575    png_debug(1, "in png_set_palette_to_rgb\n");
    576    if(png_ptr == NULL) return;
     594   png_debug(1, "in png_set_palette_to_rgb");
     595   if (png_ptr == NULL)
     596      return;
    577597   png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
    578598   png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
     
    584604png_set_expand_gray_1_2_4_to_8(png_structp png_ptr)
    585605{
    586    png_debug(1, "in png_set_expand_gray_1_2_4_to_8\n");
    587    if(png_ptr == NULL) return;
     606   png_debug(1, "in png_set_expand_gray_1_2_4_to_8");
     607   if (png_ptr == NULL)
     608      return;
    588609   png_ptr->transformations |= PNG_EXPAND;
    589610   png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
     
    597618png_set_gray_1_2_4_to_8(png_structp png_ptr)
    598619{
    599    png_debug(1, "in png_set_gray_1_2_4_to_8\n");
    600    if(png_ptr == NULL) return;
     620   png_debug(1, "in png_set_gray_1_2_4_to_8");
     621   if (png_ptr == NULL)
     622      return;
    601623   png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
    602624}
     
    608630png_set_tRNS_to_alpha(png_structp png_ptr)
    609631{
    610    png_debug(1, "in png_set_tRNS_to_alpha\n");
     632   png_debug(1, "in png_set_tRNS_to_alpha");
    611633   png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
    612634   png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
     
    618640png_set_gray_to_rgb(png_structp png_ptr)
    619641{
    620    png_debug(1, "in png_set_gray_to_rgb\n");
     642   png_debug(1, "in png_set_gray_to_rgb");
    621643   png_ptr->transformations |= PNG_GRAY_TO_RGB;
    622644   png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
     
    634656   double green)
    635657{
    636       int red_fixed = (int)((float)red*100000.0 + 0.5);
    637       int green_fixed = (int)((float)green*100000.0 + 0.5);
    638       if(png_ptr == NULL) return;
    639       png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed);
     658   int red_fixed = (int)((float)red*100000.0 + 0.5);
     659   int green_fixed = (int)((float)green*100000.0 + 0.5);
     660   if (png_ptr == NULL)
     661      return;
     662   png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed);
    640663}
    641664#endif
     
    645668   png_fixed_point red, png_fixed_point green)
    646669{
    647    png_debug(1, "in png_set_rgb_to_gray\n");
    648    if(png_ptr == NULL) return;
     670   png_debug(1, "in png_set_rgb_to_gray");
     671   if (png_ptr == NULL)
     672      return;
    649673   switch(error_action)
    650674   {
    651675      case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY;
    652676              break;
     677
    653678      case 2: png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN;
    654679              break;
     680
    655681      case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR;
    656682   }
     
    660686#else
    661687   {
    662       png_warning(png_ptr, "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED.");
     688      png_warning(png_ptr,
     689        "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED.");
    663690      png_ptr->transformations &= ~PNG_RGB_TO_GRAY;
    664691   }
     
    666693   {
    667694      png_uint_16 red_int, green_int;
    668       if(red < 0 || green < 0)
     695      if (red < 0 || green < 0)
    669696      {
    670697         red_int   =  6968; /* .212671 * 32768 + .5 */
    671698         green_int = 23434; /* .715160 * 32768 + .5 */
    672699      }
    673       else if(red + green < 100000L)
    674       {
    675         red_int = (png_uint_16)(((png_uint_32)red*32768L)/100000L);
    676         green_int = (png_uint_16)(((png_uint_32)green*32768L)/100000L);
     700      else if (red + green < 100000L)
     701      {
     702         red_int = (png_uint_16)(((png_uint_32)red*32768L)/100000L);
     703         green_int = (png_uint_16)(((png_uint_32)green*32768L)/100000L);
    677704      }
    678705      else
     
    684711      png_ptr->rgb_to_gray_red_coeff   = red_int;
    685712      png_ptr->rgb_to_gray_green_coeff = green_int;
    686       png_ptr->rgb_to_gray_blue_coeff  = (png_uint_16)(32768-red_int-green_int);
     713      png_ptr->rgb_to_gray_blue_coeff  =
     714         (png_uint_16)(32768 - red_int - green_int);
    687715   }
    688716}
     
    690718
    691719#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
    692     defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
    693     defined(PNG_LEGACY_SUPPORTED)
     720    defined(PNG_LEGACY_SUPPORTED) || \
     721    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
    694722void PNGAPI
    695723png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
    696724   read_user_transform_fn)
    697725{
    698    png_debug(1, "in png_set_read_user_transform_fn\n");
    699    if(png_ptr == NULL) return;
     726   png_debug(1, "in png_set_read_user_transform_fn");
     727   if (png_ptr == NULL)
     728      return;
    700729#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
    701730   png_ptr->transformations |= PNG_USER_TRANSFORM;
     
    703732#endif
    704733#ifdef PNG_LEGACY_SUPPORTED
    705    if(read_user_transform_fn)
     734   if (read_user_transform_fn)
    706735      png_warning(png_ptr,
    707736        "This version of libpng does not support user transforms");
     
    716745png_init_read_transformations(png_structp png_ptr)
    717746{
    718    png_debug(1, "in png_init_read_transformations\n");
     747   png_debug(1, "in png_init_read_transformations");
    719748#if defined(PNG_USELESS_TESTS_SUPPORTED)
    720    if(png_ptr != NULL)
     749   if (png_ptr != NULL)
    721750#endif
    722751  {
     
    730759#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
    731760   /* Detect gray background and attempt to enable optimization
    732     * for gray --> RGB case */
    733    /* Note:  if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or
     761    * for gray --> RGB case
     762    *
     763    * Note:  if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or
    734764    * RGB_ALPHA (in which case need_expand is superfluous anyway), the
    735765    * background color might actually be gray yet not be flagged as such.
     
    758788      if (!(color_type & PNG_COLOR_MASK_COLOR))  /* i.e., GRAY or GRAY_ALPHA */
    759789      {
    760          /* expand background and tRNS chunks */
     790         /* Expand background and tRNS chunks */
    761791         switch (png_ptr->bit_depth)
    762792         {
     
    772802               }
    773803               break;
     804
    774805            case 2:
    775806               png_ptr->background.gray *= (png_uint_16)0x55;
     
    783814               }
    784815               break;
     816
    785817            case 4:
    786818               png_ptr->background.gray *= (png_uint_16)0x11;
     
    794826               }
    795827               break;
     828
    796829            case 8:
     830
    797831            case 16:
    798832               png_ptr->background.red = png_ptr->background.green
     
    817851#endif
    818852           {
    819            /* invert the alpha channel (in tRNS) unless the pixels are
    820               going to be expanded, in which case leave it for later */
    821               int i,istop;
     853           /* Invert the alpha channel (in tRNS) unless the pixels are
     854            * going to be expanded, in which case leave it for later
     855            */
     856              int i, istop;
    822857              istop=(int)png_ptr->num_trans;
    823858              for (i=0; i<istop; i++)
     
    840875         < PNG_GAMMA_THRESHOLD))
    841876   {
    842     int i,k;
     877    int i, k;
    843878    k=0;
    844879    for (i=0; i<png_ptr->num_trans; i++)
    845880    {
    846881      if (png_ptr->trans[i] != 0 && png_ptr->trans[i] != 0xff)
    847         k=1; /* partial transparency is present */
     882        k=1; /* Partial transparency is present */
    848883    }
    849884    if (k == 0)
     
    860895         if (color_type == PNG_COLOR_TYPE_PALETTE)
    861896         {
    862            /* could skip if no transparency and
    863            */
     897           /* Could skip if no transparency */
    864898            png_color back, back_1;
    865899            png_colorp palette = png_ptr->palette;
     
    886920                     gs = 1.0;
    887921                     break;
     922
    888923                  case PNG_BACKGROUND_GAMMA_FILE:
    889924                     g = 1.0 / (png_ptr->gamma);
    890925                     gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma);
    891926                     break;
     927
    892928                  case PNG_BACKGROUND_GAMMA_UNIQUE:
    893929                     g = 1.0 / (png_ptr->background_gamma);
     
    9781014                  gs = 1.0;
    9791015                  break;
     1016
    9801017               case PNG_BACKGROUND_GAMMA_FILE:
    9811018                  g = 1.0 / (png_ptr->gamma);
    9821019                  gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma);
    9831020                  break;
     1021
    9841022               case PNG_BACKGROUND_GAMMA_UNIQUE:
    9851023                  g = 1.0 / (png_ptr->background_gamma);
     
    10231061      }
    10241062      else
    1025       /* transformation does not include PNG_BACKGROUND */
     1063      /* Transformation does not include PNG_BACKGROUND */
    10261064#endif /* PNG_READ_BACKGROUND_SUPPORTED */
    10271065      if (color_type == PNG_COLOR_TYPE_PALETTE)
     
    11111149#if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \
    11121150 && !defined(PNG_READ_BACKGROUND_SUPPORTED)
    1113    if(png_ptr)
     1151   if (png_ptr)
    11141152      return;
    11151153#endif
     
    11231161png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
    11241162{
    1125    png_debug(1, "in png_read_transform_info\n");
     1163   png_debug(1, "in png_read_transform_info");
    11261164#if defined(PNG_READ_EXPAND_SUPPORTED)
    11271165   if (png_ptr->transformations & PNG_EXPAND)
     
    11431181            if (png_ptr->transformations & PNG_EXPAND_tRNS)
    11441182              info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
    1145 #if 0 /* Removed from libpng-1.2.27 */
    1146             else
    1147               info_ptr->color_type |= PNG_COLOR_MASK_COLOR;
    1148 #endif
    11491183         }
    11501184         if (info_ptr->bit_depth < 8)
     
    11951229   {
    11961230      if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) ||
    1197          (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) &&
    1198          png_ptr->palette_lookup && info_ptr->bit_depth == 8)
     1231          (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) &&
     1232          png_ptr->palette_lookup && info_ptr->bit_depth == 8)
    11991233      {
    12001234         info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
     
    12301264   {
    12311265      info_ptr->channels++;
    1232       /* if adding a true alpha channel not just filler */
     1266      /* If adding a true alpha channel not just filler */
    12331267#if !defined(PNG_1_0_X)
    12341268      if (png_ptr->transformations & PNG_ADD_ALPHA)
     
    12401274#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \
    12411275defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
    1242    if(png_ptr->transformations & PNG_USER_TRANSFORM)
     1276   if (png_ptr->transformations & PNG_USER_TRANSFORM)
    12431277     {
    1244        if(info_ptr->bit_depth < png_ptr->user_transform_depth)
     1278       if (info_ptr->bit_depth < png_ptr->user_transform_depth)
    12451279         info_ptr->bit_depth = png_ptr->user_transform_depth;
    1246        if(info_ptr->channels < png_ptr->user_transform_channels)
     1280       if (info_ptr->channels < png_ptr->user_transform_channels)
    12471281         info_ptr->channels = png_ptr->user_transform_channels;
    12481282     }
     
    12521286      info_ptr->bit_depth);
    12531287
    1254    info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,info_ptr->width);
     1288   info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, info_ptr->width);
    12551289
    12561290#if !defined(PNG_READ_EXPAND_SUPPORTED)
    1257    if(png_ptr)
     1291   if (png_ptr)
    12581292      return;
    12591293#endif
     
    12671301png_do_read_transformations(png_structp png_ptr)
    12681302{
    1269    png_debug(1, "in png_do_read_transformations\n");
     1303   png_debug(1, "in png_do_read_transformations");
    12701304   if (png_ptr->row_buf == NULL)
    12711305   {
     
    12741308
    12751309      png_snprintf2(msg, 50,
    1276          "NULL row buffer for row %ld, pass %d", png_ptr->row_number,
     1310         "NULL row buffer for row %ld, pass %d", (long)png_ptr->row_number,
    12771311         png_ptr->pass);
    12781312      png_error(png_ptr, msg);
     
    12851319      /* Application has failed to call either png_read_start_image()
    12861320       * or png_read_update_info() after setting transforms that expand
    1287        * pixels.  This check added to libpng-1.2.19 */
     1321       * pixels.  This check added to libpng-1.2.19
     1322       */
    12881323#if (PNG_WARN_UNINITIALIZED_ROW==1)
    12891324      png_error(png_ptr, "Uninitialized row");
     
    13251360      int rgb_error =
    13261361         png_do_rgb_to_gray(png_ptr, &(png_ptr->row_info), png_ptr->row_buf + 1);
    1327       if(rgb_error)
     1362      if (rgb_error)
    13281363      {
    13291364         png_ptr->rgb_to_gray_status=1;
    1330          if((png_ptr->transformations & PNG_RGB_TO_GRAY) ==
     1365         if ((png_ptr->transformations & PNG_RGB_TO_GRAY) ==
    13311366             PNG_RGB_TO_GRAY_WARN)
    13321367            png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel");
    1333          if((png_ptr->transformations & PNG_RGB_TO_GRAY) ==
     1368         if ((png_ptr->transformations & PNG_RGB_TO_GRAY) ==
    13341369             PNG_RGB_TO_GRAY_ERR)
    13351370            png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel");
     
    13381373#endif
    13391374
    1340 /*
    1341 From Andreas Dilger e-mail to png-implement, 26 March 1998:
    1342 
    1343   In most cases, the "simple transparency" should be done prior to doing
    1344   gray-to-RGB, or you will have to test 3x as many bytes to check if a
    1345   pixel is transparent.  You would also need to make sure that the
    1346   transparency information is upgraded to RGB.
    1347 
    1348   To summarize, the current flow is:
    1349   - Gray + simple transparency -> compare 1 or 2 gray bytes and composite
    1350                                   with background "in place" if transparent,
    1351                                   convert to RGB if necessary
    1352   - Gray + alpha -> composite with gray background and remove alpha bytes,
    1353                                   convert to RGB if necessary
    1354 
    1355   To support RGB backgrounds for gray images we need:
    1356   - Gray + simple transparency -> convert to RGB + simple transparency, compare
    1357                                   3 or 6 bytes and composite with background
    1358                                   "in place" if transparent (3x compare/pixel
    1359                                   compared to doing composite with gray bkgrnd)
    1360   - Gray + alpha -> convert to RGB + alpha, composite with background and
    1361                                   remove alpha bytes (3x float operations/pixel
    1362                                   compared with composite on gray background)
    1363 
    1364   Greg's change will do this.  The reason it wasn't done before is for
    1365   performance, as this increases the per-pixel operations.  If we would check
    1366   in advance if the background was gray or RGB, and position the gray-to-RGB
    1367   transform appropriately, then it would save a lot of work/time.
     1375/* From Andreas Dilger e-mail to png-implement, 26 March 1998:
     1376 *
     1377 *   In most cases, the "simple transparency" should be done prior to doing
     1378 *   gray-to-RGB, or you will have to test 3x as many bytes to check if a
     1379 *   pixel is transparent.  You would also need to make sure that the
     1380 *   transparency information is upgraded to RGB.
     1381 *
     1382 *   To summarize, the current flow is:
     1383 *   - Gray + simple transparency -> compare 1 or 2 gray bytes and composite
     1384 *                                   with background "in place" if transparent,
     1385 *                                   convert to RGB if necessary
     1386 *   - Gray + alpha -> composite with gray background and remove alpha bytes,
     1387 *                                   convert to RGB if necessary
     1388 *
     1389 *   To support RGB backgrounds for gray images we need:
     1390 *   - Gray + simple transparency -> convert to RGB + simple transparency,
     1391 *                                   compare 3 or 6 bytes and composite with
     1392 *                                   background "in place" if transparent
     1393 *                                   (3x compare/pixel compared to doing
     1394 *                                   composite with gray bkgrnd)
     1395 *   - Gray + alpha -> convert to RGB + alpha, composite with background and
     1396 *                                   remove alpha bytes (3x float
     1397 *                                   operations/pixel compared with composite
     1398 *                                   on gray background)
     1399 *
     1400 *  Greg's change will do this.  The reason it wasn't done before is for
     1401 *  performance, as this increases the per-pixel operations.  If we would check
     1402 *  in advance if the background was gray or RGB, and position the gray-to-RGB
     1403 *  transform appropriately, then it would save a lot of work/time.
    13681404 */
    13691405
    13701406#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
    1371    /* if gray -> RGB, do so now only if background is non-gray; else do later
    1372     * for performance reasons */
     1407   /* If gray -> RGB, do so now only if background is non-gray; else do later
     1408    * for performance reasons
     1409    */
    13731410   if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
    13741411       !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
     
    13951432   if ((png_ptr->transformations & PNG_GAMMA) &&
    13961433#if defined(PNG_READ_BACKGROUND_SUPPORTED)
    1397       !((png_ptr->transformations & PNG_BACKGROUND) &&
    1398       ((png_ptr->num_trans != 0) ||
    1399       (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) &&
    1400 #endif
    1401       (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE))
     1434       !((png_ptr->transformations & PNG_BACKGROUND) &&
     1435       ((png_ptr->num_trans != 0) ||
     1436       (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) &&
     1437#endif
     1438       (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE))
    14021439      png_do_gamma(&(png_ptr->row_info), png_ptr->row_buf + 1,
    1403          png_ptr->gamma_table, png_ptr->gamma_16_table,
    1404          png_ptr->gamma_shift);
     1440          png_ptr->gamma_table, png_ptr->gamma_16_table,
     1441          png_ptr->gamma_shift);
    14051442#endif
    14061443
     
    14151452      png_do_dither((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1,
    14161453         png_ptr->palette_lookup, png_ptr->dither_index);
    1417       if(png_ptr->row_info.rowbytes == (png_uint_32)0)
     1454      if (png_ptr->row_info.rowbytes == (png_uint_32)0)
    14181455         png_error(png_ptr, "png_do_dither returned rowbytes=0");
    14191456   }
     
    14471484
    14481485#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
    1449    /* if gray -> RGB, do so now only if we did not do so above */
     1486   /* If gray -> RGB, do so now only if we did not do so above */
    14501487   if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
    14511488       (png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
     
    14771514   if (png_ptr->transformations & PNG_USER_TRANSFORM)
    14781515    {
    1479       if(png_ptr->read_user_transform_fn != NULL)
    1480         (*(png_ptr->read_user_transform_fn)) /* user read transform function */
    1481           (png_ptr,                    /* png_ptr */
    1482            &(png_ptr->row_info),       /* row_info:    */
    1483              /*  png_uint_32 width;          width of row */
    1484              /*  png_uint_32 rowbytes;       number of bytes in row */
    1485              /*  png_byte color_type;        color type of pixels */
    1486              /*  png_byte bit_depth;         bit depth of samples */
    1487              /*  png_byte channels;          number of channels (1-4) */
    1488              /*  png_byte pixel_depth;       bits per pixel (depth*channels) */
    1489            png_ptr->row_buf + 1);      /* start of pixel data for row */
     1516      if (png_ptr->read_user_transform_fn != NULL)
     1517         (*(png_ptr->read_user_transform_fn)) /* User read transform function */
     1518            (png_ptr,                    /* png_ptr */
     1519               &(png_ptr->row_info),     /* row_info: */
     1520               /*  png_uint_32 width;       width of row */
     1521               /*  png_uint_32 rowbytes;    number of bytes in row */
     1522               /*  png_byte color_type;     color type of pixels */
     1523               /*  png_byte bit_depth;      bit depth of samples */
     1524               /*  png_byte channels;       number of channels (1-4) */
     1525               /*  png_byte pixel_depth;    bits per pixel (depth*channels) */
     1526               png_ptr->row_buf + 1);    /* start of pixel data for row */
    14901527#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
    1491       if(png_ptr->user_transform_depth)
     1528      if (png_ptr->user_transform_depth)
    14921529         png_ptr->row_info.bit_depth = png_ptr->user_transform_depth;
    1493       if(png_ptr->user_transform_channels)
     1530      if (png_ptr->user_transform_channels)
    14941531         png_ptr->row_info.channels = png_ptr->user_transform_channels;
    14951532#endif
     
    15131550png_do_unpack(png_row_infop row_info, png_bytep row)
    15141551{
    1515    png_debug(1, "in png_do_unpack\n");
     1552   png_debug(1, "in png_do_unpack");
    15161553#if defined(PNG_USELESS_TESTS_SUPPORTED)
    15171554   if (row != NULL && row_info != NULL && row_info->bit_depth < 8)
     
    15451582            break;
    15461583         }
     1584
    15471585         case 2:
    15481586         {
     
    15661604            break;
    15671605         }
     1606
    15681607         case 4:
    15691608         {
     
    16031642png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
    16041643{
    1605    png_debug(1, "in png_do_unshift\n");
     1644   png_debug(1, "in png_do_unshift");
    16061645   if (
    16071646#if defined(PNG_USELESS_TESTS_SUPPORTED)
     
    16571696            break;
    16581697         }
     1698
    16591699         case 4:
    16601700         {
     
    16721712            break;
    16731713         }
     1714
    16741715         case 8:
    16751716         {
     
    16841725            break;
    16851726         }
     1727
    16861728         case 16:
    16871729         {
     
    17051747
    17061748#if defined(PNG_READ_16_TO_8_SUPPORTED)
    1707 /* chop rows of bit depth 16 down to 8 */
     1749/* Chop rows of bit depth 16 down to 8 */
    17081750void /* PRIVATE */
    17091751png_do_chop(png_row_infop row_info, png_bytep row)
    17101752{
    1711    png_debug(1, "in png_do_chop\n");
     1753   png_debug(1, "in png_do_chop");
    17121754#if defined(PNG_USELESS_TESTS_SUPPORTED)
    17131755   if (row != NULL && row_info != NULL && row_info->bit_depth == 16)
     
    17291771       * What the ideal calculation should be:
    17301772       *   *dp = (((((png_uint_32)(*sp) << 8) |
    1731        *          (png_uint_32)(*(sp + 1))) * 255 + 127) / (png_uint_32)65535L;
     1773       *          (png_uint_32)(*(sp + 1))) * 255 + 127)
     1774       *          / (png_uint_32)65535L;
    17321775       *
    17331776       * GRR: no, I think this is what it really should be:
    17341777       *   *dp = (((((png_uint_32)(*sp) << 8) |
    1735        *           (png_uint_32)(*(sp + 1))) + 128L) / (png_uint_32)257L;
     1778       *           (png_uint_32)(*(sp + 1))) + 128L)
     1779       *           / (png_uint_32)257L;
    17361780       *
    17371781       * GRR: here's the exact calculation with shifts:
    1738        *   temp = (((png_uint_32)(*sp) << 8) | (png_uint_32)(*(sp + 1))) + 128L;
     1782       *   temp = (((png_uint_32)(*sp) << 8) |
     1783       *           (png_uint_32)(*(sp + 1))) + 128L;
    17391784       *   *dp = (temp - (temp >> 8)) >> 8;
    17401785       *
     
    17631808png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
    17641809{
    1765    png_debug(1, "in png_do_read_swap_alpha\n");
     1810   png_debug(1, "in png_do_read_swap_alpha");
    17661811#if defined(PNG_USELESS_TESTS_SUPPORTED)
    17671812   if (row != NULL && row_info != NULL)
     
    18551900png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
    18561901{
    1857    png_debug(1, "in png_do_read_invert_alpha\n");
     1902   png_debug(1, "in png_do_read_invert_alpha");
    18581903#if defined(PNG_USELESS_TESTS_SUPPORTED)
    18591904   if (row != NULL && row_info != NULL)
     
    19612006   png_byte lo_filler = (png_byte)(filler & 0xff);
    19622007
    1963    png_debug(1, "in png_do_read_filler\n");
     2008   png_debug(1, "in png_do_read_filler");
    19642009   if (
    19652010#if defined(PNG_USELESS_TESTS_SUPPORTED)
     
    19682013       row_info->color_type == PNG_COLOR_TYPE_GRAY)
    19692014   {
    1970       if(row_info->bit_depth == 8)
     2015      if (row_info->bit_depth == 8)
    19712016      {
    19722017         /* This changes the data from G to GX */
     
    20002045         }
    20012046      }
    2002       else if(row_info->bit_depth == 16)
     2047      else if (row_info->bit_depth == 16)
    20032048      {
    20042049         /* This changes the data from GG to GGXX */
     
    20402085   else if (row_info->color_type == PNG_COLOR_TYPE_RGB)
    20412086   {
    2042       if(row_info->bit_depth == 8)
     2087      if (row_info->bit_depth == 8)
    20432088      {
    20442089         /* This changes the data from RGB to RGBX */
     
    20762121         }
    20772122      }
    2078       else if(row_info->bit_depth == 16)
     2123      else if (row_info->bit_depth == 16)
    20792124      {
    20802125         /* This changes the data from RRGGBB to RRGGBBXX */
     
    21262171
    21272172#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
    2128 /* expand grayscale files to RGB, with or without alpha */
     2173/* Expand grayscale files to RGB, with or without alpha */
    21292174void /* PRIVATE */
    21302175png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
     
    21332178   png_uint_32 row_width = row_info->width;
    21342179
    2135    png_debug(1, "in png_do_gray_to_rgb\n");
     2180   png_debug(1, "in png_do_gray_to_rgb");
    21362181   if (row_info->bit_depth >= 8 &&
    21372182#if defined(PNG_USELESS_TESTS_SUPPORTED)
     
    22032248      row_info->pixel_depth = (png_byte)(row_info->channels *
    22042249         row_info->bit_depth);
    2205       row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width);
     2250      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
    22062251   }
    22072252}
     
    22092254
    22102255#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
    2211 /* reduce RGB files to grayscale, with or without alpha
     2256/* Reduce RGB files to grayscale, with or without alpha
    22122257 * using the equation given in Poynton's ColorFAQ at
    2213  * <http://www.inforamp.net/~poynton/>
    2214  * Copyright (c) 1998-01-04 Charles Poynton poynton at inforamp.net
     2258 * <http://www.inforamp.net/~poynton/>  (THIS LINK IS DEAD June 2008)
     2259 * New link:
     2260 * <http://www.poynton.com/notes/colour_and_gamma/>
     2261 * Charles Poynton poynton at poynton.com
    22152262 *
    22162263 *     Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
     
    22372284   int rgb_error = 0;
    22382285
    2239    png_debug(1, "in png_do_rgb_to_gray\n");
     2286   png_debug(1, "in png_do_rgb_to_gray");
    22402287   if (
    22412288#if defined(PNG_USELESS_TESTS_SUPPORTED)
     
    22632310                  png_byte green = png_ptr->gamma_to_1[*(sp++)];
    22642311                  png_byte blue  = png_ptr->gamma_to_1[*(sp++)];
    2265                   if(red != green || red != blue)
     2312                  if (red != green || red != blue)
    22662313                  {
    22672314                     rgb_error |= 1;
    22682315                     *(dp++) = png_ptr->gamma_from_1[
    2269                        (rc*red+gc*green+bc*blue)>>15];
     2316                       (rc*red + gc*green + bc*blue)>>15];
    22702317                  }
    22712318                  else
    2272                      *(dp++) = *(sp-1);
     2319                     *(dp++) = *(sp - 1);
    22732320               }
    22742321            }
     
    22832330                  png_byte green = *(sp++);
    22842331                  png_byte blue  = *(sp++);
    2285                   if(red != green || red != blue)
     2332                  if (red != green || red != blue)
    22862333                  {
    22872334                     rgb_error |= 1;
    2288                      *(dp++) = (png_byte)((rc*red+gc*green+bc*blue)>>15);
     2335                     *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15);
    22892336                  }
    22902337                  else
    2291                      *(dp++) = *(sp-1);
     2338                     *(dp++) = *(sp - 1);
    22922339               }
    22932340            }
     
    23102357                  blue  = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
    23112358
    2312                   if(red == green && red == blue)
     2359                  if (red == green && red == blue)
    23132360                     w = red;
    23142361                  else
     
    23442391                  blue  = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
    23452392
    2346                   if(red != green || red != blue)
     2393                  if (red != green || red != blue)
    23472394                     rgb_error |= 1;
    23482395                  gray16  = (png_uint_16)((rc*red + gc*green + bc*blue)>>15);
     
    23672414                  png_byte green = png_ptr->gamma_to_1[*(sp++)];
    23682415                  png_byte blue  = png_ptr->gamma_to_1[*(sp++)];
    2369                   if(red != green || red != blue)
     2416                  if (red != green || red != blue)
    23702417                     rgb_error |= 1;
    23712418                  *(dp++) =  png_ptr->gamma_from_1
     
    23842431                  png_byte green = *(sp++);
    23852432                  png_byte blue  = *(sp++);
    2386                   if(red != green || red != blue)
     2433                  if (red != green || red != blue)
    23872434                     rgb_error |= 1;
    23882435                  *(dp++) =  (png_byte)((rc*red + gc*green + bc*blue)>>15);
     
    24072454                  blue  = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
    24082455
    2409                   if(red == green && red == blue)
     2456                  if (red == green && red == blue)
    24102457                     w = red;
    24112458                  else
     
    24412488                  green = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2;
    24422489                  blue  = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2;
    2443                   if(red != green || red != blue)
     2490                  if (red != green || red != blue)
    24442491                     rgb_error |= 1;
    24452492                  gray16  = (png_uint_16)((rc*red + gc*green + bc*blue)>>15);
     
    24562503      row_info->pixel_depth = (png_byte)(row_info->channels *
    24572504         row_info->bit_depth);
    2458       row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width);
     2505      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
    24592506   }
    24602507   return rgb_error;
     
    24752522   int v;
    24762523
    2477    png_debug(1, "in png_do_build_grayscale_palette\n");
     2524   png_debug(1, "in png_do_build_grayscale_palette");
    24782525   if (palette == NULL)
    24792526      return;
     
    24852532         color_inc = 0xff;
    24862533         break;
     2534
    24872535      case 2:
    24882536         num_palette = 4;
    24892537         color_inc = 0x55;
    24902538         break;
     2539
    24912540      case 4:
    24922541         num_palette = 16;
    24932542         color_inc = 0x11;
    24942543         break;
     2544
    24952545      case 8:
    24962546         num_palette = 256;
    24972547         color_inc = 1;
    24982548         break;
     2549
    24992550      default:
    25002551         num_palette = 0;
     
    25172568   int num_palette)
    25182569{
    2519    png_debug(1, "in png_correct_palette\n");
     2570   png_debug(1, "in png_correct_palette");
    25202571#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
    25212572    defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
     
    26742725         }
    26752726      }
    2676       else /* assume grayscale palette (what else could it be?) */
     2727      else /* Assume grayscale palette (what else could it be?) */
    26772728      {
    26782729         int i;
     
    27142765   int shift;
    27152766
    2716    png_debug(1, "in png_do_background\n");
     2767   png_debug(1, "in png_do_background");
    27172768   if (background != NULL &&
    27182769#if defined(PNG_USELESS_TESTS_SUPPORTED)
     
    27502801                  break;
    27512802               }
     2803
    27522804               case 2:
    27532805               {
     
    28062858                  break;
    28072859               }
     2860
    28082861               case 4:
    28092862               {
     
    28622915                  break;
    28632916               }
     2917
    28642918               case 8:
    28652919               {
     
    28942948                  break;
    28952949               }
     2950
    28962951               case 16:
    28972952               {
     
    29072962                        if (v == trans_values->gray)
    29082963                        {
    2909                            /* background is already in screen gamma */
     2964                           /* Background is already in screen gamma */
    29102965                           *sp = (png_byte)((background->gray >> 8) & 0xff);
    29112966                           *(sp + 1) = (png_byte)(background->gray & 0xff);
     
    29402995            break;
    29412996         }
     2997
    29422998         case PNG_COLOR_TYPE_RGB:
    29432999         {
     
    29973053                        b == trans_values->blue)
    29983054                     {
    2999                         /* background is already in screen gamma */
     3055                        /* Background is already in screen gamma */
    30003056                        *sp = (png_byte)((background->red >> 8) & 0xff);
    30013057                        *(sp + 1) = (png_byte)(background->red & 0xff);
     
    30443100            break;
    30453101         }
     3102
    30463103         case PNG_COLOR_TYPE_GRAY_ALPHA:
    30473104         {
     
    30643121                     else if (a == 0)
    30653122                     {
    3066                         /* background is already in screen gamma */
     3123                        /* Background is already in screen gamma */
    30673124                        *dp = (png_byte)background->gray;
    30683125                     }
     
    31313188#endif
    31323189                     {
    3133                         /* background is already in screen gamma */
     3190                        /* Background is already in screen gamma */
    31343191                        *dp = (png_byte)((background->gray >> 8) & 0xff);
    31353192                        *(dp + 1) = (png_byte)(background->gray & 0xff);
     
    31863243            break;
    31873244         }
     3245
    31883246         case PNG_COLOR_TYPE_RGB_ALPHA:
    31893247         {
     
    32083266                     else if (a == 0)
    32093267                     {
    3210                         /* background is already in screen gamma */
     3268                        /* Background is already in screen gamma */
    32113269                        *dp = (png_byte)background->red;
    32123270                        *(dp + 1) = (png_byte)background->green;
     
    32893347                     else if (a == 0)
    32903348                     {
    3291                         /* background is already in screen gamma */
     3349                        /* Background is already in screen gamma */
    32923350                        *dp = (png_byte)((background->red >> 8) & 0xff);
    32933351                        *(dp + 1) = (png_byte)(background->red & 0xff);
     
    33743432         row_info->pixel_depth = (png_byte)(row_info->channels *
    33753433            row_info->bit_depth);
    3376          row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width);
     3434         row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
    33773435      }
    33783436   }
     
    33963454   png_uint_32 row_width=row_info->width;
    33973455
    3398    png_debug(1, "in png_do_gamma\n");
     3456   png_debug(1, "in png_do_gamma");
    33993457   if (
    34003458#if defined(PNG_USELESS_TESTS_SUPPORTED)
     
    34443502            break;
    34453503         }
     3504
    34463505         case PNG_COLOR_TYPE_RGB_ALPHA:
    34473506         {
     
    34813540            break;
    34823541         }
     3542
    34833543         case PNG_COLOR_TYPE_GRAY_ALPHA:
    34843544         {
     
    35053565            break;
    35063566         }
     3567
    35073568         case PNG_COLOR_TYPE_GRAY:
    35083569         {
     
    35253586               }
    35263587            }
     3588
    35273589            if (row_info->bit_depth == 4)
    35283590            {
     
    35383600               }
    35393601            }
     3602
    35403603            else if (row_info->bit_depth == 8)
    35413604            {
     
    35473610               }
    35483611            }
     3612
    35493613            else if (row_info->bit_depth == 16)
    35503614            {
     
    35783642   png_uint_32 row_width=row_info->width;
    35793643
    3580    png_debug(1, "in png_do_expand_palette\n");
     3644   png_debug(1, "in png_do_expand_palette");
    35813645   if (
    35823646#if defined(PNG_USELESS_TESTS_SUPPORTED)
     
    36123676               break;
    36133677            }
     3678
    36143679            case 2:
    36153680            {
     
    36333698               break;
    36343699            }
     3700
    36353701            case 4:
    36363702            {
     
    36973763                  sp--;
    36983764               }
     3765
    36993766               row_info->bit_depth = 8;
    37003767               row_info->pixel_depth = 24;
     
    37213788   png_uint_32 row_width=row_info->width;
    37223789
    3723    png_debug(1, "in png_do_expand\n");
     3790   png_debug(1, "in png_do_expand");
    37243791#if defined(PNG_USELESS_TESTS_SUPPORTED)
    37253792   if (row != NULL && row_info != NULL)
     
    37583825                  break;
    37593826               }
     3827
    37603828               case 2:
    37613829               {
     
    37813849                  break;
    37823850               }
     3851
    37833852               case 4:
    37843853               {
     
    38043873               }
    38053874            }
     3875
    38063876            row_info->bit_depth = 8;
    38073877            row_info->pixel_depth = 8;
     
    38253895               }
    38263896            }
     3897
    38273898            else if (row_info->bit_depth == 16)
    38283899            {
     
    38333904               for (i = 0; i < row_width; i++)
    38343905               {
    3835                   if (*(sp-1) == gray_high && *(sp) == gray_low)
     3906                  if (*(sp - 1) == gray_high && *(sp) == gray_low)
    38363907                  {
    38373908                     *dp-- = 0;
     
    38473918               }
    38483919            }
     3920
    38493921            row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
    38503922            row_info->channels = 2;
     
    39123984         row_info->channels = 4;
    39133985         row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2);
    3914          row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width);
     3986         row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
    39153987      }
    39163988   }
     
    39273999   png_uint_32 row_width=row_info->width;
    39284000
    3929    png_debug(1, "in png_do_dither\n");
     4001   png_debug(1, "in png_do_dither");
    39304002#if defined(PNG_USELESS_TESTS_SUPPORTED)
    39314003   if (row != NULL && row_info != NULL)
     
    39444016            b = *sp++;
    39454017
    3946             /* this looks real messy, but the compiler will reduce
    3947                it down to a reasonable formula.  For example, with
    3948                5 bits per color, we get:
    3949                p = (((r >> 3) & 0x1f) << 10) |
    3950                   (((g >> 3) & 0x1f) << 5) |
    3951                   ((b >> 3) & 0x1f);
    3952                */
     4018            /* This looks real messy, but the compiler will reduce
     4019             * it down to a reasonable formula.  For example, with
     4020             * 5 bits per color, we get:
     4021             * p = (((r >> 3) & 0x1f) << 10) |
     4022             *    (((g >> 3) & 0x1f) << 5) |
     4023             *    ((b >> 3) & 0x1f);
     4024             */
    39534025            p = (((r >> (8 - PNG_DITHER_RED_BITS)) &
    39544026               ((1 << PNG_DITHER_RED_BITS) - 1)) <<
     
    39654037         row_info->channels = 1;
    39664038         row_info->pixel_depth = row_info->bit_depth;
    3967          row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width);
     4039         row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
    39684040      }
    39694041      else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&
     
    39944066         row_info->channels = 1;
    39954067         row_info->pixel_depth = row_info->bit_depth;
    3996          row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width);
     4068         row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
    39974069      }
    39984070      else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE &&
     
    40224094png_build_gamma_table(png_structp png_ptr)
    40234095{
    4024   png_debug(1, "in png_build_gamma_table\n");
     4096  png_debug(1, "in png_build_gamma_table");
    40254097
    40264098  if (png_ptr->bit_depth <= 8)
     
    40314103     if (png_ptr->screen_gamma > .000001)
    40324104        g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma);
     4105
    40334106     else
    40344107        g = 1.0;
     
    40634136           (png_uint_32)256);
    40644137
    4065         if(png_ptr->screen_gamma > 0.000001)
     4138        if (png_ptr->screen_gamma > 0.000001)
    40664139           g = 1.0 / png_ptr->screen_gamma;
     4140
    40674141        else
    4068            g = png_ptr->gamma;   /* probably doing rgb_to_gray */
     4142           g = png_ptr->gamma;   /* Probably doing rgb_to_gray */
    40694143
    40704144        for (i = 0; i < 256; i++)
     
    40874161     {
    40884162        sig_bit = (int)png_ptr->sig_bit.red;
     4163
    40894164        if ((int)png_ptr->sig_bit.green > sig_bit)
    40904165           sig_bit = png_ptr->sig_bit.green;
     4166
    40914167        if ((int)png_ptr->sig_bit.blue > sig_bit)
    40924168           sig_bit = png_ptr->sig_bit.blue;
     
    40994175     if (sig_bit > 0)
    41004176        shift = 16 - sig_bit;
     4177
    41014178     else
    41024179        shift = 0;
     
    41104187     if (shift > 8)
    41114188        shift = 8;
     4189
    41124190     if (shift < 0)
    41134191        shift = 0;
     
    41234201
    41244202     png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr,
    4125         (png_uint_32)(num * png_sizeof (png_uint_16p)));
     4203        (png_uint_32)(num * png_sizeof(png_uint_16p)));
     4204     png_memset(png_ptr->gamma_16_table, 0, num * png_sizeof(png_uint_16p));
    41264205
    41274206     if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND))
     
    41334212        {
    41344213           png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
    4135               (png_uint_32)(256 * png_sizeof (png_uint_16)));
     4214              (png_uint_32)(256 * png_sizeof(png_uint_16)));
    41364215        }
    41374216
     
    41634242        {
    41644243           png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
    4165               (png_uint_32)(256 * png_sizeof (png_uint_16)));
     4244              (png_uint_32)(256 * png_sizeof(png_uint_16)));
    41664245
    41674246           ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4);
     4247
    41684248           for (j = 0; j < 256; j++)
    41694249           {
     
    41834263
    41844264        png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr,
    4185            (png_uint_32)(num * png_sizeof (png_uint_16p )));
     4265           (png_uint_32)(num * png_sizeof(png_uint_16p )));
     4266        png_memset(png_ptr->gamma_16_to_1, 0, num * png_sizeof(png_uint_16p));
    41864267
    41874268        for (i = 0; i < num; i++)
    41884269        {
    41894270           png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr,
    4190               (png_uint_32)(256 * png_sizeof (png_uint_16)));
     4271              (png_uint_32)(256 * png_sizeof(png_uint_16)));
    41914272
    41924273           ig = (((png_uint_32)i *
     
    42004281        }
    42014282
    4202         if(png_ptr->screen_gamma > 0.000001)
     4283        if (png_ptr->screen_gamma > 0.000001)
    42034284           g = 1.0 / png_ptr->screen_gamma;
     4285
    42044286        else
    4205            g = png_ptr->gamma;   /* probably doing rgb_to_gray */
     4287           g = png_ptr->gamma;   /* Probably doing rgb_to_gray */
    42064288
    42074289        png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr,
    4208            (png_uint_32)(num * png_sizeof (png_uint_16p)));
     4290           (png_uint_32)(num * png_sizeof(png_uint_16p)));
     4291        png_memset(png_ptr->gamma_16_from_1, 0,
     4292           num * png_sizeof(png_uint_16p));
    42094293
    42104294        for (i = 0; i < num; i++)
    42114295        {
    42124296           png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr,
    4213               (png_uint_32)(256 * png_sizeof (png_uint_16)));
     4297              (png_uint_32)(256 * png_sizeof(png_uint_16)));
    42144298
    42154299           ig = (((png_uint_32)i *
    42164300              (png_uint_32)png_gamma_shift[shift]) >> 4);
     4301
    42174302           for (j = 0; j < 256; j++)
    42184303           {
     
    42314316
    42324317#if defined(PNG_MNG_FEATURES_SUPPORTED)
    4233 /* undoes intrapixel differencing  */
     4318/* Undoes intrapixel differencing  */
    42344319void /* PRIVATE */
    42354320png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
    42364321{
    4237    png_debug(1, "in png_do_read_intrapixel\n");
     4322   png_debug(1, "in png_do_read_intrapixel");
    42384323   if (
    42394324#if defined(PNG_USELESS_TESTS_SUPPORTED)
     
    42514336         if (row_info->color_type == PNG_COLOR_TYPE_RGB)
    42524337            bytes_per_pixel = 3;
     4338
    42534339         else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
    42544340            bytes_per_pixel = 4;
     4341
    42554342         else
    42564343            return;
     
    42694356         if (row_info->color_type == PNG_COLOR_TYPE_RGB)
    42704357            bytes_per_pixel = 6;
     4358
    42714359         else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
    42724360            bytes_per_pixel = 8;
     4361
    42734362         else
    42744363            return;
     
    42764365         for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
    42774366         {
    4278             png_uint_32 s0   = (*(rp  ) << 8) | *(rp+1);
    4279             png_uint_32 s1   = (*(rp+2) << 8) | *(rp+3);
    4280             png_uint_32 s2   = (*(rp+4) << 8) | *(rp+5);
    4281             png_uint_32 red  = (png_uint_32)((s0+s1+65536L) & 0xffffL);
    4282             png_uint_32 blue = (png_uint_32)((s2+s1+65536L) & 0xffffL);
     4367            png_uint_32 s0   = (*(rp    ) << 8) | *(rp + 1);
     4368            png_uint_32 s1   = (*(rp + 2) << 8) | *(rp + 3);
     4369            png_uint_32 s2   = (*(rp + 4) << 8) | *(rp + 5);
     4370            png_uint_32 red  = (png_uint_32)((s0 + s1 + 65536L) & 0xffffL);
     4371            png_uint_32 blue = (png_uint_32)((s2 + s1 + 65536L) & 0xffffL);
    42834372            *(rp  ) = (png_byte)((red >> 8) & 0xff);
    42844373            *(rp+1) = (png_byte)(red & 0xff);
  • trunk/src/3rdparty/libpng/pngrutil.c

    r2 r561  
    22/* pngrutil.c - utilities to read a PNG file
    33 *
    4  * Last changed in libpng 1.2.27 [April 29, 2008]
    5  * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2008 Glenn Randers-Pehrson
     4 * Last changed in libpng 1.2.38 [July 16, 2009]
     5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
    76 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    87 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     8 *
     9 * This code is released under the libpng license.
     10 * For conditions of distribution and use, see the disclaimer
     11 * and license in png.h
    912 *
    1013 * This file contains routines that are only called from within
     
    1417#define PNG_INTERNAL
    1518#include "png.h"
    16 
    1719#if defined(PNG_READ_SUPPORTED)
    1820
     
    2325#ifdef PNG_FLOATING_POINT_SUPPORTED
    2426#  if defined(WIN32_WCE_OLD)
    25 /* strtod() function is not supported on WindowsCE */
     27/* The strtod() function is not supported on WindowsCE */
    2628__inline double png_strtod(png_structp png_ptr, PNG_CONST char *nptr, char **endptr)
    2729{
     
    3133
    3234   len = MultiByteToWideChar(CP_ACP, 0, nptr, -1, NULL, 0);
    33    str = (wchar_t *)png_malloc(png_ptr, len * sizeof(wchar_t));
     35   str = (wchar_t *)png_malloc(png_ptr, len * png_sizeof(wchar_t));
    3436   if ( NULL != str )
    3537   {
     
    5052png_get_uint_31(png_structp png_ptr, png_bytep buf)
    5153{
     54#ifdef PNG_READ_BIG_ENDIAN_SUPPORTED
    5255   png_uint_32 i = png_get_uint_32(buf);
     56#else
     57   /* Avoid an extra function call by inlining the result. */
     58   png_uint_32 i = ((png_uint_32)(*buf) << 24) +
     59      ((png_uint_32)(*(buf + 1)) << 16) +
     60      ((png_uint_32)(*(buf + 2)) << 8) +
     61      (png_uint_32)(*(buf + 3));
     62#endif
    5363   if (i > PNG_UINT_31_MAX)
    5464     png_error(png_ptr, "PNG unsigned integer out of range.");
     
    7080/* Grab a signed 32-bit integer from a buffer in big-endian format.  The
    7181 * data is stored in the PNG file in two's complement format, and it is
    72  * assumed that the machine format for signed integers is the same. */
     82 * assumed that the machine format for signed integers is the same.
     83 */
    7384png_int_32 PNGAPI
    7485png_get_int_32(png_bytep buf)
     
    93104#endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */
    94105
     106/* Read the chunk header (length + type name).
     107 * Put the type name into png_ptr->chunk_name, and return the length.
     108 */
     109png_uint_32 /* PRIVATE */
     110png_read_chunk_header(png_structp png_ptr)
     111{
     112   png_byte buf[8];
     113   png_uint_32 length;
     114
     115   /* Read the length and the chunk name */
     116   png_read_data(png_ptr, buf, 8);
     117   length = png_get_uint_31(png_ptr, buf);
     118
     119   /* Put the chunk name into png_ptr->chunk_name */
     120   png_memcpy(png_ptr->chunk_name, buf + 4, 4);
     121
     122   png_debug2(0, "Reading %s chunk, length = %lu",
     123      png_ptr->chunk_name, length);
     124
     125   /* Reset the crc and run it over the chunk name */
     126   png_reset_crc(png_ptr);
     127   png_calculate_crc(png_ptr, png_ptr->chunk_name, 4);
     128
     129   /* Check to see if chunk name is valid */
     130   png_check_chunk_name(png_ptr, png_ptr->chunk_name);
     131
     132   return length;
     133}
     134
    95135/* Read data, and (optionally) run it through the CRC. */
    96136void /* PRIVATE */
    97137png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length)
    98138{
    99    if(png_ptr == NULL) return;
     139   if (png_ptr == NULL)
     140      return;
    100141   png_read_data(png_ptr, buf, length);
    101142   png_calculate_crc(png_ptr, buf, length);
     
    103144
    104145/* Optionally skip data and then check the CRC.  Depending on whether we
    105    are reading a ancillary or critical chunk, and how the program has set
    106    things up, we may calculate the CRC on the data and print a message.
    107    Returns '1' if there was a CRC error, '0' otherwise. */
     146 * are reading a ancillary or critical chunk, and how the program has set
     147 * things up, we may calculate the CRC on the data and print a message.
     148 * Returns '1' if there was a CRC error, '0' otherwise.
     149 */
    108150int /* PRIVATE */
    109151png_crc_finish(png_structp png_ptr, png_uint_32 skip)
     
    124166   {
    125167      if (((png_ptr->chunk_name[0] & 0x20) &&                /* Ancillary */
    126            !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) ||
     168          !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) ||
    127169          (!(png_ptr->chunk_name[0] & 0x20) &&             /* Critical  */
    128170          (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE)))
     
    141183
    142184/* Compare the CRC stored in the PNG file with that calculated by libpng from
    143    the data it has read thus far. */
     185 * the data it has read thus far.
     186 */
    144187int /* PRIVATE */
    145188png_crc_error(png_structp png_ptr)
     
    181224 * trailing part (the malloc area passed in is freed).
    182225 */
    183 png_charp /* PRIVATE */
     226void /* PRIVATE */
    184227png_decompress_chunk(png_structp png_ptr, int comp_type,
    185                               png_charp chunkdata, png_size_t chunklength,
     228                              png_size_t chunklength,
    186229                              png_size_t prefix_size, png_size_t *newlength)
    187230{
     
    193236   {
    194237      int ret = Z_OK;
    195       png_ptr->zstream.next_in = (png_bytep)(chunkdata + prefix_size);
     238      png_ptr->zstream.next_in = (png_bytep)(png_ptr->chunkdata + prefix_size);
    196239      png_ptr->zstream.avail_in = (uInt)(chunklength - prefix_size);
    197240      png_ptr->zstream.next_out = png_ptr->zbuf;
     
    219262               if (text ==  NULL)
    220263                 {
    221                     png_free(png_ptr,chunkdata);
    222                     png_error(png_ptr,"Not enough memory to decompress chunk");
     264                    png_free(png_ptr, png_ptr->chunkdata);
     265                    png_ptr->chunkdata = NULL;
     266                    png_error(png_ptr, "Not enough memory to decompress chunk");
    223267                 }
    224                png_memcpy(text, chunkdata, prefix_size);
     268               png_memcpy(text, png_ptr->chunkdata, prefix_size);
    225269            }
    226270
     
    228272
    229273            /* Copy what we can of the error message into the text chunk */
    230             text_size = (png_size_t)(chunklength - (text - chunkdata) - 1);
    231             text_size = png_sizeof(msg) > text_size ? text_size :
    232                png_sizeof(msg);
     274            text_size = (png_size_t)(chunklength -
     275              (text - png_ptr->chunkdata) - 1);
     276            if (text_size > png_sizeof(msg))
     277               text_size = png_sizeof(msg);
    233278            png_memcpy(text + prefix_size, msg, text_size);
    234279            break;
     
    242287               text = (png_charp)png_malloc_warn(png_ptr, text_size + 1);
    243288               if (text ==  NULL)
    244                  {
    245                     png_free(png_ptr,chunkdata);
    246                     png_error(png_ptr,"Not enough memory to decompress chunk.");
    247                  }
     289               {
     290                  png_free(png_ptr, png_ptr->chunkdata);
     291                  png_ptr->chunkdata = NULL;
     292                  png_error(png_ptr,
     293                    "Not enough memory to decompress chunk.");
     294               }
    248295               png_memcpy(text + prefix_size, png_ptr->zbuf,
    249296                    text_size - prefix_size);
    250                png_memcpy(text, chunkdata, prefix_size);
     297               png_memcpy(text, png_ptr->chunkdata, prefix_size);
    251298               *(text + text_size) = 0x00;
    252299            }
     
    262309               {
    263310                  png_free(png_ptr, tmp);
    264                   png_free(png_ptr, chunkdata);
    265                   png_error(png_ptr,"Not enough memory to decompress chunk..");
     311                  png_free(png_ptr, png_ptr->chunkdata);
     312                  png_ptr->chunkdata = NULL;
     313                  png_error(png_ptr,
     314                    "Not enough memory to decompress chunk..");
    266315               }
    267316               png_memcpy(text, tmp, text_size);
     
    290339                "Buffer error in compressed datastream in %s chunk",
    291340                png_ptr->chunk_name);
     341
    292342         else if (ret == Z_DATA_ERROR)
    293343            png_snprintf(umsg, 52,
    294344                "Data error in compressed datastream in %s chunk",
    295345                png_ptr->chunk_name);
     346
    296347         else
    297348            png_snprintf(umsg, 52,
    298349                "Incomplete compressed datastream in %s chunk",
    299350                png_ptr->chunk_name);
     351
    300352         png_warning(png_ptr, umsg);
    301353#else
     
    303355            "Incomplete compressed datastream in chunk other than IDAT");
    304356#endif
    305          text_size=prefix_size;
     357         text_size = prefix_size;
    306358         if (text ==  NULL)
    307359         {
     
    309361            if (text == NULL)
    310362              {
    311                 png_free(png_ptr, chunkdata);
    312                 png_error(png_ptr,"Not enough memory for text.");
     363                png_free(png_ptr, png_ptr->chunkdata);
     364                png_ptr->chunkdata = NULL;
     365                png_error(png_ptr, "Not enough memory for text.");
    313366              }
    314             png_memcpy(text, chunkdata, prefix_size);
     367            png_memcpy(text, png_ptr->chunkdata, prefix_size);
    315368         }
    316369         *(text + text_size) = 0x00;
     
    320373      png_ptr->zstream.avail_in = 0;
    321374
    322       png_free(png_ptr, chunkdata);
    323       chunkdata = text;
     375      png_free(png_ptr, png_ptr->chunkdata);
     376      png_ptr->chunkdata = text;
    324377      *newlength=text_size;
    325378   }
     
    329382      char umsg[50];
    330383
    331       png_snprintf(umsg, 50,
    332          "Unknown zTXt compression type %d", comp_type);
     384      png_snprintf(umsg, 50, "Unknown zTXt compression type %d", comp_type);
    333385      png_warning(png_ptr, umsg);
    334386#else
     
    336388#endif
    337389
    338       *(chunkdata + prefix_size) = 0x00;
    339       *newlength=prefix_size;
    340    }
    341 
    342    return chunkdata;
    343 }
    344 #endif
    345 
    346 /* read and check the IDHR chunk */
     390      *(png_ptr->chunkdata + prefix_size) = 0x00;
     391      *newlength = prefix_size;
     392   }
     393}
     394#endif
     395
     396/* Read and check the IDHR chunk */
    347397void /* PRIVATE */
    348398png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
     
    353403   int interlace_type;
    354404
    355    png_debug(1, "in png_handle_IHDR\n");
     405   png_debug(1, "in png_handle_IHDR");
    356406
    357407   if (png_ptr->mode & PNG_HAVE_IHDR)
    358408      png_error(png_ptr, "Out of place IHDR");
    359409
    360    /* check the length */
     410   /* Check the length */
    361411   if (length != 13)
    362412      png_error(png_ptr, "Invalid IHDR chunk");
     
    375425   interlace_type = buf[12];
    376426
    377    /* set internal variables */
     427   /* Set internal variables */
    378428   png_ptr->width = width;
    379429   png_ptr->height = height;
     
    386436   png_ptr->compression_type = (png_byte)compression_type;
    387437
    388    /* find number of channels */
     438   /* Find number of channels */
    389439   switch (png_ptr->color_type)
    390440   {
     
    393443         png_ptr->channels = 1;
    394444         break;
     445
    395446      case PNG_COLOR_TYPE_RGB:
    396447         png_ptr->channels = 3;
    397448         break;
     449
    398450      case PNG_COLOR_TYPE_GRAY_ALPHA:
    399451         png_ptr->channels = 2;
    400452         break;
     453
    401454      case PNG_COLOR_TYPE_RGB_ALPHA:
    402455         png_ptr->channels = 4;
     
    404457   }
    405458
    406    /* set up other useful info */
     459   /* Set up other useful info */
    407460   png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth *
    408461   png_ptr->channels);
    409    png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->width);
    410    png_debug1(3,"bit_depth = %d\n", png_ptr->bit_depth);
    411    png_debug1(3,"channels = %d\n", png_ptr->channels);
    412    png_debug1(3,"rowbytes = %lu\n", png_ptr->rowbytes);
     462   png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->width);
     463   png_debug1(3, "bit_depth = %d", png_ptr->bit_depth);
     464   png_debug1(3, "channels = %d", png_ptr->channels);
     465   png_debug1(3, "rowbytes = %lu", png_ptr->rowbytes);
    413466   png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth,
    414467      color_type, interlace_type, compression_type, filter_type);
    415468}
    416469
    417 /* read and check the palette */
     470/* Read and check the palette */
    418471void /* PRIVATE */
    419472png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
     
    425478#endif
    426479
    427    png_debug(1, "in png_handle_PLTE\n");
     480   png_debug(1, "in png_handle_PLTE");
    428481
    429482   if (!(png_ptr->mode & PNG_HAVE_IHDR))
    430483      png_error(png_ptr, "Missing IHDR before PLTE");
     484
    431485   else if (png_ptr->mode & PNG_HAVE_IDAT)
    432486   {
     
    435489      return;
    436490   }
     491
    437492   else if (png_ptr->mode & PNG_HAVE_PLTE)
    438493      png_error(png_ptr, "Duplicate PLTE chunk");
     
    463518         return;
    464519      }
     520
    465521      else
    466522      {
     
    487543
    488544      png_crc_read(png_ptr, buf, 3);
    489       /* don't depend upon png_color being any order */
     545      /* Don't depend upon png_color being any order */
    490546      palette[i].red = buf[0];
    491547      palette[i].green = buf[1];
     
    495551
    496552   /* If we actually NEED the PLTE chunk (ie for a paletted image), we do
    497       whatever the normal CRC configuration tells us.  However, if we
    498       have an RGB image, the PLTE can be considered ancillary, so
    499       we will act as though it is. */
     553    * whatever the normal CRC configuration tells us.  However, if we
     554    * have an RGB image, the PLTE can be considered ancillary, so
     555    * we will act as though it is.
     556    */
    500557#if !defined(PNG_READ_OPT_PLTE_SUPPORTED)
    501558   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
     
    557614png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
    558615{
    559    png_debug(1, "in png_handle_IEND\n");
     616   png_debug(1, "in png_handle_IEND");
    560617
    561618   if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT))
     
    572629   png_crc_finish(png_ptr, length);
    573630
    574    info_ptr =info_ptr; /* quiet compiler warnings about unused info_ptr */
     631   info_ptr = info_ptr; /* Quiet compiler warnings about unused info_ptr */
    575632}
    576633
     
    585642   png_byte buf[4];
    586643
    587    png_debug(1, "in png_handle_gAMA\n");
     644   png_debug(1, "in png_handle_gAMA");
    588645
    589646   if (!(png_ptr->mode & PNG_HAVE_IHDR))
     
    622679
    623680   igamma = (png_fixed_point)png_get_uint_32(buf);
    624    /* check for zero gamma */
     681   /* Check for zero gamma */
    625682   if (igamma == 0)
    626683      {
     
    637694           "Ignoring incorrect gAMA value when sRGB is also present");
    638695#ifndef PNG_NO_CONSOLE_IO
    639          fprintf(stderr, "gamma = (%d/100000)\n", (int)igamma);
     696         fprintf(stderr, "gamma = (%d/100000)", (int)igamma);
    640697#endif
    641698         return;
     
    663720   png_byte buf[4];
    664721
    665    png_debug(1, "in png_handle_sBIT\n");
     722   png_debug(1, "in png_handle_sBIT");
    666723
    667724   buf[0] = buf[1] = buf[2] = buf[3] = 0;
     
    726783png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
    727784{
    728    png_byte buf[4];
     785   png_byte buf[32];
    729786#ifdef PNG_FLOATING_POINT_SUPPORTED
    730787   float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
     
    735792   png_uint_32 uint_x, uint_y;
    736793
    737    png_debug(1, "in png_handle_cHRM\n");
     794   png_debug(1, "in png_handle_cHRM");
    738795
    739796   if (!(png_ptr->mode & PNG_HAVE_IHDR))
     
    767824   }
    768825
    769    png_crc_read(png_ptr, buf, 4);
     826   png_crc_read(png_ptr, buf, 32);
     827   if (png_crc_finish(png_ptr, 0))
     828      return;
     829
    770830   uint_x = png_get_uint_32(buf);
    771 
    772    png_crc_read(png_ptr, buf, 4);
    773    uint_y = png_get_uint_32(buf);
    774 
    775    if (uint_x > 80000L || uint_y > 80000L ||
    776       uint_x + uint_y > 100000L)
    777    {
    778       png_warning(png_ptr, "Invalid cHRM white point");
    779       png_crc_finish(png_ptr, 24);
    780       return;
    781    }
     831   uint_y = png_get_uint_32(buf + 4);
    782832   int_x_white = (png_fixed_point)uint_x;
    783833   int_y_white = (png_fixed_point)uint_y;
    784834
    785    png_crc_read(png_ptr, buf, 4);
    786    uint_x = png_get_uint_32(buf);
    787 
    788    png_crc_read(png_ptr, buf, 4);
    789    uint_y = png_get_uint_32(buf);
    790 
    791    if (uint_x + uint_y > 100000L)
    792    {
    793       png_warning(png_ptr, "Invalid cHRM red point");
    794       png_crc_finish(png_ptr, 16);
    795       return;
    796    }
     835   uint_x = png_get_uint_32(buf + 8);
     836   uint_y = png_get_uint_32(buf + 12);
    797837   int_x_red = (png_fixed_point)uint_x;
    798838   int_y_red = (png_fixed_point)uint_y;
    799839
    800    png_crc_read(png_ptr, buf, 4);
    801    uint_x = png_get_uint_32(buf);
    802 
    803    png_crc_read(png_ptr, buf, 4);
    804    uint_y = png_get_uint_32(buf);
    805 
    806    if (uint_x + uint_y > 100000L)
    807    {
    808       png_warning(png_ptr, "Invalid cHRM green point");
    809       png_crc_finish(png_ptr, 8);
    810       return;
    811    }
     840   uint_x = png_get_uint_32(buf + 16);
     841   uint_y = png_get_uint_32(buf + 20);
    812842   int_x_green = (png_fixed_point)uint_x;
    813843   int_y_green = (png_fixed_point)uint_y;
    814844
    815    png_crc_read(png_ptr, buf, 4);
    816    uint_x = png_get_uint_32(buf);
    817 
    818    png_crc_read(png_ptr, buf, 4);
    819    uint_y = png_get_uint_32(buf);
    820 
    821    if (uint_x + uint_y > 100000L)
    822    {
    823       png_warning(png_ptr, "Invalid cHRM blue point");
    824       png_crc_finish(png_ptr, 0);
    825       return;
    826    }
     845   uint_x = png_get_uint_32(buf + 24);
     846   uint_y = png_get_uint_32(buf + 28);
    827847   int_x_blue = (png_fixed_point)uint_x;
    828848   int_y_blue = (png_fixed_point)uint_y;
     
    855875#ifndef PNG_NO_CONSOLE_IO
    856876#ifdef PNG_FLOATING_POINT_SUPPORTED
    857             fprintf(stderr,"wx=%f, wy=%f, rx=%f, ry=%f\n",
     877            fprintf(stderr, "wx=%f, wy=%f, rx=%f, ry=%f\n",
    858878               white_x, white_y, red_x, red_y);
    859             fprintf(stderr,"gx=%f, gy=%f, bx=%f, by=%f\n",
     879            fprintf(stderr, "gx=%f, gy=%f, bx=%f, by=%f\n",
    860880               green_x, green_y, blue_x, blue_y);
    861881#else
    862             fprintf(stderr,"wx=%ld, wy=%ld, rx=%ld, ry=%ld\n",
     882            fprintf(stderr, "wx=%ld, wy=%ld, rx=%ld, ry=%ld\n",
    863883               int_x_white, int_y_white, int_x_red, int_y_red);
    864             fprintf(stderr,"gx=%ld, gy=%ld, bx=%ld, by=%ld\n",
     884            fprintf(stderr, "gx=%ld, gy=%ld, bx=%ld, by=%ld\n",
    865885               int_x_green, int_y_green, int_x_blue, int_y_blue);
    866886#endif
    867887#endif /* PNG_NO_CONSOLE_IO */
    868888         }
    869          png_crc_finish(png_ptr, 0);
    870889         return;
    871890      }
     
    881900      int_y_green, int_x_blue, int_y_blue);
    882901#endif
    883    if (png_crc_finish(png_ptr, 0))
    884       return;
    885902}
    886903#endif
     
    893910   png_byte buf[1];
    894911
    895    png_debug(1, "in png_handle_sRGB\n");
     912   png_debug(1, "in png_handle_sRGB");
    896913
    897914   if (!(png_ptr->mode & PNG_HAVE_IHDR))
     
    926943
    927944   intent = buf[0];
    928    /* check for bad intent */
     945   /* Check for bad intent */
    929946   if (intent >= PNG_sRGB_INTENT_LAST)
    930947   {
     
    950967#ifndef PNG_NO_CONSOLE_IO
    951968#  ifdef PNG_FIXED_POINT_SUPPORTED
    952          fprintf(stderr,"incorrect gamma=(%d/100000)\n",(int)png_ptr->int_gamma);
     969         fprintf(stderr, "incorrect gamma=(%d/100000)\n",
     970            (int)png_ptr->int_gamma);
    953971#  else
    954972#    ifdef PNG_FLOATING_POINT_SUPPORTED
    955          fprintf(stderr,"incorrect gamma=%f\n",png_ptr->gamma);
     973         fprintf(stderr, "incorrect gamma=%f\n", png_ptr->gamma);
    956974#    endif
    957975#  endif
     
    9881006/* Note: this does not properly handle chunks that are > 64K under DOS */
    9891007{
    990    png_charp chunkdata;
    9911008   png_byte compression_type;
    9921009   png_bytep pC;
     
    9961013   png_size_t slength, prefix_length, data_length;
    9971014
    998    png_debug(1, "in png_handle_iCCP\n");
     1015   png_debug(1, "in png_handle_iCCP");
    9991016
    10001017   if (!(png_ptr->mode & PNG_HAVE_IHDR))
     
    10261043#endif
    10271044
    1028    chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
     1045   png_free(png_ptr, png_ptr->chunkdata);
     1046   png_ptr->chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
    10291047   slength = (png_size_t)length;
    1030    png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
     1048   png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
    10311049
    10321050   if (png_crc_finish(png_ptr, skip))
    10331051   {
    1034       png_free(png_ptr, chunkdata);
    1035       return;
    1036    }
    1037 
    1038    chunkdata[slength] = 0x00;
    1039 
    1040    for (profile = chunkdata; *profile; profile++)
    1041       /* empty loop to find end of name */ ;
     1052      png_free(png_ptr, png_ptr->chunkdata);
     1053      png_ptr->chunkdata = NULL;
     1054      return;
     1055   }
     1056
     1057   png_ptr->chunkdata[slength] = 0x00;
     1058
     1059   for (profile = png_ptr->chunkdata; *profile; profile++)
     1060      /* Empty loop to find end of name */ ;
    10421061
    10431062   ++profile;
    10441063
    1045    /* there should be at least one zero (the compression type byte)
    1046       following the separator, and we should be on it  */
    1047    if ( profile >= chunkdata + slength - 1)
    1048    {
    1049       png_free(png_ptr, chunkdata);
     1064   /* There should be at least one zero (the compression type byte)
     1065    * following the separator, and we should be on it
     1066    */
     1067   if ( profile >= png_ptr->chunkdata + slength - 1)
     1068   {
     1069      png_free(png_ptr, png_ptr->chunkdata);
     1070      png_ptr->chunkdata = NULL;
    10501071      png_warning(png_ptr, "Malformed iCCP chunk");
    10511072      return;
    10521073   }
    10531074
    1054    /* compression_type should always be zero */
     1075   /* Compression_type should always be zero */
    10551076   compression_type = *profile++;
    10561077   if (compression_type)
    10571078   {
    10581079      png_warning(png_ptr, "Ignoring nonzero compression type in iCCP chunk");
    1059       compression_type=0x00;  /* Reset it to zero (libpng-1.0.6 through 1.0.8
     1080      compression_type = 0x00;  /* Reset it to zero (libpng-1.0.6 through 1.0.8
    10601081                                 wrote nonzero) */
    10611082   }
    10621083
    1063    prefix_length = profile - chunkdata;
    1064    chunkdata = png_decompress_chunk(png_ptr, compression_type, chunkdata,
    1065                                     slength, prefix_length, &data_length);
     1084   prefix_length = profile - png_ptr->chunkdata;
     1085   png_decompress_chunk(png_ptr, compression_type,
     1086     slength, prefix_length, &data_length);
    10661087
    10671088   profile_length = data_length - prefix_length;
     
    10691090   if ( prefix_length > data_length || profile_length < 4)
    10701091   {
    1071       png_free(png_ptr, chunkdata);
     1092      png_free(png_ptr, png_ptr->chunkdata);
     1093      png_ptr->chunkdata = NULL;
    10721094      png_warning(png_ptr, "Profile size field missing from iCCP chunk");
    10731095      return;
     
    10751097
    10761098   /* Check the profile_size recorded in the first 32 bits of the ICC profile */
    1077    pC = (png_bytep)(chunkdata+prefix_length);
    1078    profile_size = ((*(pC  ))<<24) |
    1079                   ((*(pC+1))<<16) |
    1080                   ((*(pC+2))<< 8) |
    1081                   ((*(pC+3))    );
    1082 
    1083    if(profile_size < profile_length)
     1099   pC = (png_bytep)(png_ptr->chunkdata + prefix_length);
     1100   profile_size = ((*(pC    ))<<24) |
     1101                  ((*(pC + 1))<<16) |
     1102                  ((*(pC + 2))<< 8) |
     1103                  ((*(pC + 3))    );
     1104
     1105   if (profile_size < profile_length)
    10841106      profile_length = profile_size;
    10851107
    1086    if(profile_size > profile_length)
    1087    {
    1088       png_free(png_ptr, chunkdata);
     1108   if (profile_size > profile_length)
     1109   {
     1110      png_free(png_ptr, png_ptr->chunkdata);
     1111      png_ptr->chunkdata = NULL;
    10891112      png_warning(png_ptr, "Ignoring truncated iCCP profile.");
    10901113      return;
    10911114   }
    10921115
    1093    png_set_iCCP(png_ptr, info_ptr, chunkdata, compression_type,
    1094                 chunkdata + prefix_length, profile_length);
    1095    png_free(png_ptr, chunkdata);
     1116   png_set_iCCP(png_ptr, info_ptr, png_ptr->chunkdata,
     1117     compression_type, png_ptr->chunkdata + prefix_length, profile_length);
     1118   png_free(png_ptr, png_ptr->chunkdata);
     1119   png_ptr->chunkdata = NULL;
    10961120}
    10971121#endif /* PNG_READ_iCCP_SUPPORTED */
     
    11021126/* Note: this does not properly handle chunks that are > 64K under DOS */
    11031127{
    1104    png_bytep chunkdata;
    11051128   png_bytep entry_start;
    11061129   png_sPLT_t new_palette;
     
    11121135   png_size_t slength;
    11131136
    1114    png_debug(1, "in png_handle_sPLT\n");
     1137   png_debug(1, "in png_handle_sPLT");
     1138
    11151139
    11161140   if (!(png_ptr->mode & PNG_HAVE_IHDR))
     
    11321156#endif
    11331157
    1134    chunkdata = (png_bytep)png_malloc(png_ptr, length + 1);
     1158   png_free(png_ptr, png_ptr->chunkdata);
     1159   png_ptr->chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
    11351160   slength = (png_size_t)length;
    1136    png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
     1161   png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
    11371162
    11381163   if (png_crc_finish(png_ptr, skip))
    11391164   {
    1140       png_free(png_ptr, chunkdata);
    1141       return;
    1142    }
    1143 
    1144    chunkdata[slength] = 0x00;
    1145 
    1146    for (entry_start = chunkdata; *entry_start; entry_start++)
    1147       /* empty loop to find end of name */ ;
     1165      png_free(png_ptr, png_ptr->chunkdata);
     1166      png_ptr->chunkdata = NULL;
     1167      return;
     1168   }
     1169
     1170   png_ptr->chunkdata[slength] = 0x00;
     1171
     1172   for (entry_start = (png_bytep)png_ptr->chunkdata; *entry_start; entry_start++)
     1173      /* Empty loop to find end of name */ ;
    11481174   ++entry_start;
    11491175
    1150    /* a sample depth should follow the separator, and we should be on it  */
    1151    if (entry_start > chunkdata + slength - 2)
    1152    {
    1153       png_free(png_ptr, chunkdata);
     1176   /* A sample depth should follow the separator, and we should be on it  */
     1177   if (entry_start > (png_bytep)png_ptr->chunkdata + slength - 2)
     1178   {
     1179      png_free(png_ptr, png_ptr->chunkdata);
     1180      png_ptr->chunkdata = NULL;
    11541181      png_warning(png_ptr, "malformed sPLT chunk");
    11551182      return;
     
    11581185   new_palette.depth = *entry_start++;
    11591186   entry_size = (new_palette.depth == 8 ? 6 : 10);
    1160    data_length = (slength - (entry_start - chunkdata));
    1161 
    1162    /* integrity-check the data length */
     1187   data_length = (slength - (entry_start - (png_bytep)png_ptr->chunkdata));
     1188
     1189   /* Integrity-check the data length */
    11631190   if (data_length % entry_size)
    11641191   {
    1165       png_free(png_ptr, chunkdata);
     1192      png_free(png_ptr, png_ptr->chunkdata);
     1193      png_ptr->chunkdata = NULL;
    11661194      png_warning(png_ptr, "sPLT chunk has bad length");
    11671195      return;
     
    11691197
    11701198   new_palette.nentries = (png_int_32) ( data_length / entry_size);
    1171    if ((png_uint_32) new_palette.nentries > (png_uint_32) (PNG_SIZE_MAX /
    1172        png_sizeof(png_sPLT_entry)))
     1199   if ((png_uint_32) new_palette.nentries >
     1200       (png_uint_32) (PNG_SIZE_MAX / png_sizeof(png_sPLT_entry)))
    11731201   {
    11741202       png_warning(png_ptr, "sPLT chunk too long");
     
    12271255#endif
    12281256
    1229    /* discard all chunk data except the name and stash that */
    1230    new_palette.name = (png_charp)chunkdata;
     1257   /* Discard all chunk data except the name and stash that */
     1258   new_palette.name = png_ptr->chunkdata;
    12311259
    12321260   png_set_sPLT(png_ptr, info_ptr, &new_palette, 1);
    12331261
    1234    png_free(png_ptr, chunkdata);
     1262   png_free(png_ptr, png_ptr->chunkdata);
     1263   png_ptr->chunkdata = NULL;
    12351264   png_free(png_ptr, new_palette.entries);
    12361265}
     
    12431272   png_byte readbuf[PNG_MAX_PALETTE_LENGTH];
    12441273
    1245    png_debug(1, "in png_handle_tRNS\n");
     1274   png_debug(1, "in png_handle_tRNS");
    12461275
    12471276   if (!(png_ptr->mode & PNG_HAVE_IHDR))
     
    13391368   png_byte buf[6];
    13401369
    1341    png_debug(1, "in png_handle_bKGD\n");
     1370   png_debug(1, "in png_handle_bKGD");
    13421371
    13431372   if (!(png_ptr->mode & PNG_HAVE_IHDR))
     
    13901419      if (info_ptr && info_ptr->num_palette)
    13911420      {
    1392           if(buf[0] > info_ptr->num_palette)
     1421          if (buf[0] >= info_ptr->num_palette)
    13931422          {
    13941423             png_warning(png_ptr, "Incorrect bKGD chunk index value");
     
    14281457   png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH];
    14291458
    1430    png_debug(1, "in png_handle_hIST\n");
     1459   png_debug(1, "in png_handle_hIST");
    14311460
    14321461   if (!(png_ptr->mode & PNG_HAVE_IHDR))
     
    14831512   int unit_type;
    14841513
    1485    png_debug(1, "in png_handle_pHYs\n");
     1514   png_debug(1, "in png_handle_pHYs");
    14861515
    14871516   if (!(png_ptr->mode & PNG_HAVE_IHDR))
     
    15261555   int unit_type;
    15271556
    1528    png_debug(1, "in png_handle_oFFs\n");
     1557   png_debug(1, "in png_handle_oFFs");
    15291558
    15301559   if (!(png_ptr->mode & PNG_HAVE_IHDR))
     
    15621591
    15631592#if defined(PNG_READ_pCAL_SUPPORTED)
    1564 /* read the pCAL chunk (described in the PNG Extensions document) */
     1593/* Read the pCAL chunk (described in the PNG Extensions document) */
    15651594void /* PRIVATE */
    15661595png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
    15671596{
    1568    png_charp purpose;
    15691597   png_int_32 X0, X1;
    15701598   png_byte type, nparams;
     
    15741602   int i;
    15751603
    1576    png_debug(1, "in png_handle_pCAL\n");
     1604   png_debug(1, "in png_handle_pCAL");
    15771605
    15781606   if (!(png_ptr->mode & PNG_HAVE_IHDR))
     
    15911619   }
    15921620
    1593    png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)\n",
     1621   png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)",
    15941622      length + 1);
    1595    purpose = (png_charp)png_malloc_warn(png_ptr, length + 1);
    1596    if (purpose == NULL)
     1623   png_free(png_ptr, png_ptr->chunkdata);
     1624   png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
     1625   if (png_ptr->chunkdata == NULL)
    15971626     {
    15981627       png_warning(png_ptr, "No memory for pCAL purpose.");
     
    16001629     }
    16011630   slength = (png_size_t)length;
    1602    png_crc_read(png_ptr, (png_bytep)purpose, slength);
     1631   png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
    16031632
    16041633   if (png_crc_finish(png_ptr, 0))
    16051634   {
    1606       png_free(png_ptr, purpose);
    1607       return;
    1608    }
    1609 
    1610    purpose[slength] = 0x00; /* null terminate the last string */
    1611 
    1612    png_debug(3, "Finding end of pCAL purpose string\n");
    1613    for (buf = purpose; *buf; buf++)
    1614       /* empty loop */ ;
    1615 
    1616    endptr = purpose + slength;
     1635      png_free(png_ptr, png_ptr->chunkdata);
     1636      png_ptr->chunkdata = NULL;
     1637      return;
     1638   }
     1639
     1640   png_ptr->chunkdata[slength] = 0x00; /* Null terminate the last string */
     1641
     1642   png_debug(3, "Finding end of pCAL purpose string");
     1643   for (buf = png_ptr->chunkdata; *buf; buf++)
     1644      /* Empty loop */ ;
     1645
     1646   endptr = png_ptr->chunkdata + slength;
    16171647
    16181648   /* We need to have at least 12 bytes after the purpose string
     
    16211651   {
    16221652      png_warning(png_ptr, "Invalid pCAL data");
    1623       png_free(png_ptr, purpose);
    1624       return;
    1625    }
    1626 
    1627    png_debug(3, "Reading pCAL X0, X1, type, nparams, and units\n");
     1653      png_free(png_ptr, png_ptr->chunkdata);
     1654      png_ptr->chunkdata = NULL;
     1655      return;
     1656   }
     1657
     1658   png_debug(3, "Reading pCAL X0, X1, type, nparams, and units");
    16281659   X0 = png_get_int_32((png_bytep)buf+1);
    16291660   X1 = png_get_int_32((png_bytep)buf+5);
     
    16321663   units = buf + 11;
    16331664
    1634    png_debug(3, "Checking pCAL equation type and number of parameters\n");
     1665   png_debug(3, "Checking pCAL equation type and number of parameters");
    16351666   /* Check that we have the right number of parameters for known
    16361667      equation types. */
     
    16411672   {
    16421673      png_warning(png_ptr, "Invalid pCAL parameters for equation type");
    1643       png_free(png_ptr, purpose);
     1674      png_free(png_ptr, png_ptr->chunkdata);
     1675      png_ptr->chunkdata = NULL;
    16441676      return;
    16451677   }
     
    16521684      /* Empty loop to move past the units string. */ ;
    16531685
    1654    png_debug(3, "Allocating pCAL parameters array\n");
    1655    params = (png_charpp)png_malloc_warn(png_ptr, (png_uint_32)(nparams
    1656       *png_sizeof(png_charp))) ;
     1686   png_debug(3, "Allocating pCAL parameters array");
     1687   params = (png_charpp)png_malloc_warn(png_ptr,
     1688      (png_uint_32)(nparams * png_sizeof(png_charp))) ;
    16571689   if (params == NULL)
    16581690     {
    1659        png_free(png_ptr, purpose);
     1691       png_free(png_ptr, png_ptr->chunkdata);
     1692       png_ptr->chunkdata = NULL;
    16601693       png_warning(png_ptr, "No memory for pCAL params.");
    16611694       return;
     
    16671700      buf++; /* Skip the null string terminator from previous parameter. */
    16681701
    1669       png_debug1(3, "Reading pCAL parameter %d\n", i);
     1702      png_debug1(3, "Reading pCAL parameter %d", i);
    16701703      for (params[i] = buf; buf <= endptr && *buf != 0x00; buf++)
    16711704         /* Empty loop to move past each parameter string */ ;
     
    16751708      {
    16761709         png_warning(png_ptr, "Invalid pCAL data");
    1677          png_free(png_ptr, purpose);
     1710         png_free(png_ptr, png_ptr->chunkdata);
     1711         png_ptr->chunkdata = NULL;
    16781712         png_free(png_ptr, params);
    16791713         return;
     
    16811715   }
    16821716
    1683    png_set_pCAL(png_ptr, info_ptr, purpose, X0, X1, type, nparams,
     1717   png_set_pCAL(png_ptr, info_ptr, png_ptr->chunkdata, X0, X1, type, nparams,
    16841718      units, params);
    16851719
    1686    png_free(png_ptr, purpose);
     1720   png_free(png_ptr, png_ptr->chunkdata);
     1721   png_ptr->chunkdata = NULL;
    16871722   png_free(png_ptr, params);
    16881723}
     
    16901725
    16911726#if defined(PNG_READ_sCAL_SUPPORTED)
    1692 /* read the sCAL chunk */
     1727/* Read the sCAL chunk */
    16931728void /* PRIVATE */
    16941729png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
    16951730{
    1696    png_charp buffer, ep;
     1731   png_charp ep;
    16971732#ifdef PNG_FLOATING_POINT_SUPPORTED
    16981733   double width, height;
     
    17051740   png_size_t slength;
    17061741
    1707    png_debug(1, "in png_handle_sCAL\n");
     1742   png_debug(1, "in png_handle_sCAL");
    17081743
    17091744   if (!(png_ptr->mode & PNG_HAVE_IHDR))
     
    17221757   }
    17231758
    1724    png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)\n",
     1759   png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)",
    17251760      length + 1);
    1726    buffer = (png_charp)png_malloc_warn(png_ptr, length + 1);
    1727    if (buffer == NULL)
    1728      {
    1729        png_warning(png_ptr, "Out of memory while processing sCAL chunk");
    1730        return;
    1731      }
     1761   png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
     1762   if (png_ptr->chunkdata == NULL)
     1763   {
     1764      png_warning(png_ptr, "Out of memory while processing sCAL chunk");
     1765      return;
     1766   }
    17321767   slength = (png_size_t)length;
    1733    png_crc_read(png_ptr, (png_bytep)buffer, slength);
     1768   png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
    17341769
    17351770   if (png_crc_finish(png_ptr, 0))
    17361771   {
    1737       png_free(png_ptr, buffer);
    1738       return;
    1739    }
    1740 
    1741    buffer[slength] = 0x00; /* null terminate the last string */
    1742 
    1743    ep = buffer + 1;        /* skip unit byte */
     1772      png_free(png_ptr, png_ptr->chunkdata);
     1773      png_ptr->chunkdata = NULL;
     1774      return;
     1775   }
     1776
     1777   png_ptr->chunkdata[slength] = 0x00; /* Null terminate the last string */
     1778
     1779   ep = png_ptr->chunkdata + 1;        /* Skip unit byte */
    17441780
    17451781#ifdef PNG_FLOATING_POINT_SUPPORTED
     
    17471783   if (*vp)
    17481784   {
    1749        png_warning(png_ptr, "malformed width string in sCAL chunk");
    1750        return;
     1785      png_warning(png_ptr, "malformed width string in sCAL chunk");
     1786      return;
    17511787   }
    17521788#else
     
    17541790   swidth = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1);
    17551791   if (swidth == NULL)
    1756      {
    1757        png_warning(png_ptr, "Out of memory while processing sCAL chunk width");
    1758        return;
    1759      }
     1792   {
     1793      png_warning(png_ptr, "Out of memory while processing sCAL chunk width");
     1794      return;
     1795   }
    17601796   png_memcpy(swidth, ep, (png_size_t)png_strlen(ep));
    17611797#endif
    17621798#endif
    17631799
    1764    for (ep = buffer; *ep; ep++)
    1765       /* empty loop */ ;
     1800   for (ep = png_ptr->chunkdata; *ep; ep++)
     1801      /* Empty loop */ ;
    17661802   ep++;
    17671803
    1768    if (buffer + slength < ep)
    1769    {
    1770        png_warning(png_ptr, "Truncated sCAL chunk");
     1804   if (png_ptr->chunkdata + slength < ep)
     1805   {
     1806      png_warning(png_ptr, "Truncated sCAL chunk");
    17711807#if defined(PNG_FIXED_POINT_SUPPORTED) && \
    17721808    !defined(PNG_FLOATING_POINT_SUPPORTED)
    1773        png_free(png_ptr, swidth);
    1774 #endif
    1775       png_free(png_ptr, buffer);
    1776        return;
     1809      png_free(png_ptr, swidth);
     1810#endif
     1811      png_free(png_ptr, png_ptr->chunkdata);
     1812      png_ptr->chunkdata = NULL;
     1813      return;
    17771814   }
    17781815
     
    17811818   if (*vp)
    17821819   {
    1783        png_warning(png_ptr, "malformed height string in sCAL chunk");
    1784        return;
     1820      png_warning(png_ptr, "malformed height string in sCAL chunk");
     1821      return;
    17851822   }
    17861823#else
     
    17881825   sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1);
    17891826   if (sheight == NULL)
    1790      {
    1791        png_warning(png_ptr, "Out of memory while processing sCAL chunk height");
    1792        return;
    1793      }
     1827   {
     1828      png_warning(png_ptr, "Out of memory while processing sCAL chunk height");
     1829      return;
     1830   }
    17941831   png_memcpy(sheight, ep, (png_size_t)png_strlen(ep));
    17951832#endif
    17961833#endif
    17971834
    1798    if (buffer + slength < ep
     1835   if (png_ptr->chunkdata + slength < ep
    17991836#ifdef PNG_FLOATING_POINT_SUPPORTED
    18001837      || width <= 0. || height <= 0.
     
    18031840   {
    18041841      png_warning(png_ptr, "Invalid sCAL data");
    1805       png_free(png_ptr, buffer);
     1842      png_free(png_ptr, png_ptr->chunkdata);
     1843      png_ptr->chunkdata = NULL;
    18061844#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
    18071845      png_free(png_ptr, swidth);
     
    18131851
    18141852#ifdef PNG_FLOATING_POINT_SUPPORTED
    1815    png_set_sCAL(png_ptr, info_ptr, buffer[0], width, height);
     1853   png_set_sCAL(png_ptr, info_ptr, png_ptr->chunkdata[0], width, height);
    18161854#else
    18171855#ifdef PNG_FIXED_POINT_SUPPORTED
    1818    png_set_sCAL_s(png_ptr, info_ptr, buffer[0], swidth, sheight);
    1819 #endif
    1820 #endif
    1821 
    1822    png_free(png_ptr, buffer);
     1856   png_set_sCAL_s(png_ptr, info_ptr, png_ptr->chunkdata[0], swidth, sheight);
     1857#endif
     1858#endif
     1859
     1860   png_free(png_ptr, png_ptr->chunkdata);
     1861   png_ptr->chunkdata = NULL;
    18231862#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
    18241863   png_free(png_ptr, swidth);
     
    18351874   png_time mod_time;
    18361875
    1837    png_debug(1, "in png_handle_tIME\n");
     1876   png_debug(1, "in png_handle_tIME");
    18381877
    18391878   if (!(png_ptr->mode & PNG_HAVE_IHDR))
     
    18831922   int ret;
    18841923
    1885    png_debug(1, "in png_handle_tEXt\n");
     1924   png_debug(1, "in png_handle_tEXt");
     1925
    18861926
    18871927   if (!(png_ptr->mode & PNG_HAVE_IHDR))
     
    19001940#endif
    19011941
    1902    key = (png_charp)png_malloc_warn(png_ptr, length + 1);
    1903    if (key == NULL)
     1942   png_free(png_ptr, png_ptr->chunkdata);
     1943
     1944   png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
     1945   if (png_ptr->chunkdata == NULL)
    19041946   {
    19051947     png_warning(png_ptr, "No memory to process text chunk.");
     
    19071949   }
    19081950   slength = (png_size_t)length;
    1909    png_crc_read(png_ptr, (png_bytep)key, slength);
     1951   png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
    19101952
    19111953   if (png_crc_finish(png_ptr, skip))
    19121954   {
    1913       png_free(png_ptr, key);
    1914       return;
    1915    }
     1955      png_free(png_ptr, png_ptr->chunkdata);
     1956      png_ptr->chunkdata = NULL;
     1957      return;
     1958   }
     1959
     1960   key = png_ptr->chunkdata;
    19161961
    19171962   key[slength] = 0x00;
    19181963
    19191964   for (text = key; *text; text++)
    1920       /* empty loop to find end of key */ ;
     1965      /* Empty loop to find end of key */ ;
    19211966
    19221967   if (text != key + slength)
     
    19281973   {
    19291974     png_warning(png_ptr, "Not enough memory to process text chunk.");
    1930      png_free(png_ptr, key);
     1975     png_free(png_ptr, png_ptr->chunkdata);
     1976     png_ptr->chunkdata = NULL;
    19311977     return;
    19321978   }
     
    19411987   text_ptr->text_length = png_strlen(text);
    19421988
    1943    ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
    1944 
    1945    png_free(png_ptr, key);
     1989   ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
     1990
     1991   png_free(png_ptr, png_ptr->chunkdata);
     1992   png_ptr->chunkdata = NULL;
    19461993   png_free(png_ptr, text_ptr);
    19471994   if (ret)
     
    19511998
    19521999#if defined(PNG_READ_zTXt_SUPPORTED)
    1953 /* note: this does not correctly handle chunks that are > 64K under DOS */
     2000/* Note: this does not correctly handle chunks that are > 64K under DOS */
    19542001void /* PRIVATE */
    19552002png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
    19562003{
    19572004   png_textp text_ptr;
    1958    png_charp chunkdata;
    19592005   png_charp text;
    19602006   int comp_type;
     
    19622008   png_size_t slength, prefix_len, data_len;
    19632009
    1964    png_debug(1, "in png_handle_zTXt\n");
     2010   png_debug(1, "in png_handle_zTXt");
     2011
     2012
    19652013   if (!(png_ptr->mode & PNG_HAVE_IHDR))
    19662014      png_error(png_ptr, "Missing IHDR before zTXt");
     
    19742022   if (length > (png_uint_32)65535L)
    19752023   {
    1976      png_warning(png_ptr,"zTXt chunk too large to fit in memory");
     2024     png_warning(png_ptr, "zTXt chunk too large to fit in memory");
    19772025     png_crc_finish(png_ptr, length);
    19782026     return;
     
    19802028#endif
    19812029
    1982    chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
    1983    if (chunkdata == NULL)
    1984    {
    1985      png_warning(png_ptr,"Out of memory processing zTXt chunk.");
     2030   png_free(png_ptr, png_ptr->chunkdata);
     2031   png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
     2032   if (png_ptr->chunkdata == NULL)
     2033   {
     2034     png_warning(png_ptr, "Out of memory processing zTXt chunk.");
    19862035     return;
    19872036   }
    19882037   slength = (png_size_t)length;
    1989    png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
     2038   png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
    19902039   if (png_crc_finish(png_ptr, 0))
    19912040   {
    1992       png_free(png_ptr, chunkdata);
    1993       return;
    1994    }
    1995 
    1996    chunkdata[slength] = 0x00;
    1997 
    1998    for (text = chunkdata; *text; text++)
    1999       /* empty loop */ ;
     2041      png_free(png_ptr, png_ptr->chunkdata);
     2042      png_ptr->chunkdata = NULL;
     2043      return;
     2044   }
     2045
     2046   png_ptr->chunkdata[slength] = 0x00;
     2047
     2048   for (text = png_ptr->chunkdata; *text; text++)
     2049      /* Empty loop */ ;
    20002050
    20012051   /* zTXt must have some text after the chunkdataword */
    2002    if (text >= chunkdata + slength - 2)
     2052   if (text >= png_ptr->chunkdata + slength - 2)
    20032053   {
    20042054      png_warning(png_ptr, "Truncated zTXt chunk");
    2005       png_free(png_ptr, chunkdata);
     2055      png_free(png_ptr, png_ptr->chunkdata);
     2056      png_ptr->chunkdata = NULL;
    20062057      return;
    20072058   }
     
    20142065          comp_type = PNG_TEXT_COMPRESSION_zTXt;
    20152066       }
    2016        text++;        /* skip the compression_method byte */
    2017    }
    2018    prefix_len = text - chunkdata;
    2019 
    2020    chunkdata = (png_charp)png_decompress_chunk(png_ptr, comp_type, chunkdata,
    2021                                     (png_size_t)length, prefix_len, &data_len);
     2067       text++;        /* Skip the compression_method byte */
     2068   }
     2069   prefix_len = text - png_ptr->chunkdata;
     2070
     2071   png_decompress_chunk(png_ptr, comp_type,
     2072     (png_size_t)length, prefix_len, &data_len);
    20222073
    20232074   text_ptr = (png_textp)png_malloc_warn(png_ptr,
    2024      (png_uint_32)png_sizeof(png_text));
     2075      (png_uint_32)png_sizeof(png_text));
    20252076   if (text_ptr == NULL)
    20262077   {
    2027      png_warning(png_ptr,"Not enough memory to process zTXt chunk.");
    2028      png_free(png_ptr, chunkdata);
     2078     png_warning(png_ptr, "Not enough memory to process zTXt chunk.");
     2079     png_free(png_ptr, png_ptr->chunkdata);
     2080     png_ptr->chunkdata = NULL;
    20292081     return;
    20302082   }
    20312083   text_ptr->compression = comp_type;
    2032    text_ptr->key = chunkdata;
     2084   text_ptr->key = png_ptr->chunkdata;
    20332085#ifdef PNG_iTXt_SUPPORTED
    20342086   text_ptr->lang = NULL;
     
    20362088   text_ptr->itxt_length = 0;
    20372089#endif
    2038    text_ptr->text = chunkdata + prefix_len;
     2090   text_ptr->text = png_ptr->chunkdata + prefix_len;
    20392091   text_ptr->text_length = data_len;
    20402092
    2041    ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
     2093   ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
    20422094
    20432095   png_free(png_ptr, text_ptr);
    2044    png_free(png_ptr, chunkdata);
     2096   png_free(png_ptr, png_ptr->chunkdata);
     2097   png_ptr->chunkdata = NULL;
    20452098   if (ret)
    20462099     png_error(png_ptr, "Insufficient memory to store zTXt chunk.");
     
    20492102
    20502103#if defined(PNG_READ_iTXt_SUPPORTED)
    2051 /* note: this does not correctly handle chunks that are > 64K under DOS */
     2104/* Note: this does not correctly handle chunks that are > 64K under DOS */
    20522105void /* PRIVATE */
    20532106png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
    20542107{
    20552108   png_textp text_ptr;
    2056    png_charp chunkdata;
    20572109   png_charp key, lang, text, lang_key;
    20582110   int comp_flag;
     
    20612113   png_size_t slength, prefix_len, data_len;
    20622114
    2063    png_debug(1, "in png_handle_iTXt\n");
     2115   png_debug(1, "in png_handle_iTXt");
     2116
    20642117
    20652118   if (!(png_ptr->mode & PNG_HAVE_IHDR))
     
    20742127   if (length > (png_uint_32)65535L)
    20752128   {
    2076      png_warning(png_ptr,"iTXt chunk too large to fit in memory");
     2129     png_warning(png_ptr, "iTXt chunk too large to fit in memory");
    20772130     png_crc_finish(png_ptr, length);
    20782131     return;
     
    20802133#endif
    20812134
    2082    chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
    2083    if (chunkdata == NULL)
     2135   png_free(png_ptr, png_ptr->chunkdata);
     2136   png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
     2137   if (png_ptr->chunkdata == NULL)
    20842138   {
    20852139     png_warning(png_ptr, "No memory to process iTXt chunk.");
     
    20872141   }
    20882142   slength = (png_size_t)length;
    2089    png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
     2143   png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
    20902144   if (png_crc_finish(png_ptr, 0))
    20912145   {
    2092       png_free(png_ptr, chunkdata);
    2093       return;
    2094    }
    2095 
    2096    chunkdata[slength] = 0x00;
    2097 
    2098    for (lang = chunkdata; *lang; lang++)
    2099       /* empty loop */ ;
    2100    lang++;        /* skip NUL separator */
     2146      png_free(png_ptr, png_ptr->chunkdata);
     2147      png_ptr->chunkdata = NULL;
     2148      return;
     2149   }
     2150
     2151   png_ptr->chunkdata[slength] = 0x00;
     2152
     2153   for (lang = png_ptr->chunkdata; *lang; lang++)
     2154      /* Empty loop */ ;
     2155   lang++;        /* Skip NUL separator */
    21012156
    21022157   /* iTXt must have a language tag (possibly empty), two compression bytes,
    2103       translated keyword (possibly empty), and possibly some text after the
    2104       keyword */
    2105 
    2106    if (lang >= chunkdata + slength - 3)
     2158    * translated keyword (possibly empty), and possibly some text after the
     2159    * keyword
     2160    */
     2161
     2162   if (lang >= png_ptr->chunkdata + slength - 3)
    21072163   {
    21082164      png_warning(png_ptr, "Truncated iTXt chunk");
    2109       png_free(png_ptr, chunkdata);
     2165      png_free(png_ptr, png_ptr->chunkdata);
     2166      png_ptr->chunkdata = NULL;
    21102167      return;
    21112168   }
     
    21172174
    21182175   for (lang_key = lang; *lang_key; lang_key++)
    2119       /* empty loop */ ;
    2120    lang_key++;        /* skip NUL separator */
    2121 
    2122    if (lang_key >= chunkdata + slength)
     2176      /* Empty loop */ ;
     2177   lang_key++;        /* Skip NUL separator */
     2178
     2179   if (lang_key >= png_ptr->chunkdata + slength)
    21232180   {
    21242181      png_warning(png_ptr, "Truncated iTXt chunk");
    2125       png_free(png_ptr, chunkdata);
     2182      png_free(png_ptr, png_ptr->chunkdata);
     2183      png_ptr->chunkdata = NULL;
    21262184      return;
    21272185   }
    21282186
    21292187   for (text = lang_key; *text; text++)
    2130       /* empty loop */ ;
    2131    text++;        /* skip NUL separator */
    2132    if (text >= chunkdata + slength)
     2188      /* Empty loop */ ;
     2189   text++;        /* Skip NUL separator */
     2190   if (text >= png_ptr->chunkdata + slength)
    21332191   {
    21342192      png_warning(png_ptr, "Malformed iTXt chunk");
    2135       png_free(png_ptr, chunkdata);
    2136       return;
    2137    }
    2138 
    2139    prefix_len = text - chunkdata;
    2140 
    2141    key=chunkdata;
     2193      png_free(png_ptr, png_ptr->chunkdata);
     2194      png_ptr->chunkdata = NULL;
     2195      return;
     2196   }
     2197
     2198   prefix_len = text - png_ptr->chunkdata;
     2199
     2200   key=png_ptr->chunkdata;
    21422201   if (comp_flag)
    2143        chunkdata = png_decompress_chunk(png_ptr, comp_type, chunkdata,
    2144           (size_t)length, prefix_len, &data_len);
     2202       png_decompress_chunk(png_ptr, comp_type,
     2203         (size_t)length, prefix_len, &data_len);
    21452204   else
    2146        data_len=png_strlen(chunkdata + prefix_len);
     2205       data_len = png_strlen(png_ptr->chunkdata + prefix_len);
    21472206   text_ptr = (png_textp)png_malloc_warn(png_ptr,
    21482207      (png_uint_32)png_sizeof(png_text));
    21492208   if (text_ptr == NULL)
    21502209   {
    2151      png_warning(png_ptr,"Not enough memory to process iTXt chunk.");
    2152      png_free(png_ptr, chunkdata);
     2210     png_warning(png_ptr, "Not enough memory to process iTXt chunk.");
     2211     png_free(png_ptr, png_ptr->chunkdata);
     2212     png_ptr->chunkdata = NULL;
    21532213     return;
    21542214   }
    21552215   text_ptr->compression = (int)comp_flag + 1;
    2156    text_ptr->lang_key = chunkdata+(lang_key-key);
    2157    text_ptr->lang = chunkdata+(lang-key);
     2216   text_ptr->lang_key = png_ptr->chunkdata + (lang_key - key);
     2217   text_ptr->lang = png_ptr->chunkdata + (lang - key);
    21582218   text_ptr->itxt_length = data_len;
    21592219   text_ptr->text_length = 0;
    2160    text_ptr->key = chunkdata;
    2161    text_ptr->text = chunkdata + prefix_len;
    2162 
    2163    ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
     2220   text_ptr->key = png_ptr->chunkdata;
     2221   text_ptr->text = png_ptr->chunkdata + prefix_len;
     2222
     2223   ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
    21642224
    21652225   png_free(png_ptr, text_ptr);
    2166    png_free(png_ptr, chunkdata);
     2226   png_free(png_ptr, png_ptr->chunkdata);
     2227   png_ptr->chunkdata = NULL;
    21672228   if (ret)
    21682229     png_error(png_ptr, "Insufficient memory to store iTXt chunk.");
     
    21802241   png_uint_32 skip = 0;
    21812242
    2182    png_debug(1, "in png_handle_unknown\n");
     2243   png_debug(1, "in png_handle_unknown");
     2244
    21832245
    21842246   if (png_ptr->mode & PNG_HAVE_IDAT)
     
    21872249      PNG_CONST PNG_IDAT;
    21882250#endif
    2189       if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))  /* not an IDAT */
     2251      if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))  /* Not an IDAT */
    21902252         png_ptr->mode |= PNG_AFTER_IDAT;
    21912253   }
    21922254
    2193    png_check_chunk_name(png_ptr, png_ptr->chunk_name);
    2194 
    21952255   if (!(png_ptr->chunk_name[0] & 0x20))
    21962256   {
    2197 #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
    2198       if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
     2257#if defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
     2258      if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
    21992259           PNG_HANDLE_CHUNK_ALWAYS
    22002260#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
     
    22072267
    22082268#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
    2209    if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) ||
    2210        (png_ptr->read_user_chunk_fn != NULL))
     2269   if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
     2270#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
     2271       || (png_ptr->read_user_chunk_fn != NULL)
     2272#endif
     2273        )
    22112274   {
    22122275#ifdef PNG_MAX_MALLOC_64K
     
    22192282#endif
    22202283       png_memcpy((png_charp)png_ptr->unknown_chunk.name,
    2221                   (png_charp)png_ptr->chunk_name, 
     2284                  (png_charp)png_ptr->chunk_name,
    22222285                  png_sizeof(png_ptr->unknown_chunk.name));
    22232286       png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name)-1] = '\0';
     
    22312294       }
    22322295#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
    2233        if(png_ptr->read_user_chunk_fn != NULL)
     2296       if (png_ptr->read_user_chunk_fn != NULL)
    22342297       {
    2235           /* callback to user unknown chunk handler */
     2298          /* Callback to user unknown chunk handler */
    22362299          int ret;
    22372300          ret = (*(png_ptr->read_user_chunk_fn))
     
    22422305          {
    22432306             if (!(png_ptr->chunk_name[0] & 0x20))
    2244                 if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
     2307#if defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
     2308                if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
    22452309                     PNG_HANDLE_CHUNK_ALWAYS)
     2310#endif
    22462311                   png_chunk_error(png_ptr, "unknown critical chunk");
    22472312             png_set_unknown_chunks(png_ptr, info_ptr,
     
    22622327
    22632328#if !defined(PNG_READ_USER_CHUNKS_SUPPORTED)
    2264    info_ptr = info_ptr; /* quiet compiler warnings about unused info_ptr */
     2329   info_ptr = info_ptr; /* Quiet compiler warnings about unused info_ptr */
    22652330#endif
    22662331}
     
    22772342png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name)
    22782343{
    2279    png_debug(1, "in png_check_chunk_name\n");
     2344   png_debug(1, "in png_check_chunk_name");
    22802345   if (isnonalpha(chunk_name[0]) || isnonalpha(chunk_name[1]) ||
    22812346       isnonalpha(chunk_name[2]) || isnonalpha(chunk_name[3]))
     
    22992364png_combine_row(png_structp png_ptr, png_bytep row, int mask)
    23002365{
    2301    png_debug(1,"in png_combine_row\n");
     2366   png_debug(1, "in png_combine_row");
    23022367   if (mask == 0xff)
    23032368   {
     
    25102575   png_uint_32 transformations = png_ptr->transformations;
    25112576#ifdef PNG_USE_LOCAL_ARRAYS
    2512    /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    2513    /* offset to next interlace block */
     2577   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
     2578   /* Offset to next interlace block */
    25142579   PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
    25152580#endif
    25162581
    2517    png_debug(1,"in png_do_read_interlace\n");
     2582   png_debug(1, "in png_do_read_interlace");
    25182583   if (row != NULL && row_info != NULL)
    25192584   {
     
    27162781      }
    27172782      row_info->width = final_width;
    2718       row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width);
     2783      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, final_width);
    27192784   }
    27202785#if !defined(PNG_READ_PACKSWAP_SUPPORTED)
    2721    transformations = transformations; /* silence compiler warning */
     2786   transformations = transformations; /* Silence compiler warning */
    27222787#endif
    27232788}
     
    27282793   png_bytep prev_row, int filter)
    27292794{
    2730    png_debug(1, "in png_read_filter_row\n");
    2731    png_debug2(2,"row = %lu, filter = %d\n", png_ptr->row_number, filter);
     2795   png_debug(1, "in png_read_filter_row");
     2796   png_debug2(2, "row = %lu, filter = %d", png_ptr->row_number, filter);
    27322797   switch (filter)
    27332798   {
     
    28032868         }
    28042869
    2805          for (i = 0; i < istop; i++)   /* use leftover rp,pp */
     2870         for (i = 0; i < istop; i++)   /* Use leftover rp,pp */
    28062871         {
    28072872            int a, b, c, pa, pb, pc, p;
     
    28332898             */
    28342899
    2835             p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
     2900            p = (pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c;
    28362901
    28372902            *rp = (png_byte)(((int)(*rp) + p) & 0xff);
     
    28422907      default:
    28432908         png_warning(png_ptr, "Ignoring bad adaptive filter type");
    2844          *row=0;
     2909         *row = 0;
    28452910         break;
    28462911   }
    28472912}
    28482913
     2914#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
    28492915void /* PRIVATE */
    28502916png_read_finish_row(png_structp png_ptr)
     
    28522918#ifdef PNG_USE_LOCAL_ARRAYS
    28532919#ifdef PNG_READ_INTERLACING_SUPPORTED
    2854    /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    2855 
    2856    /* start of interlace block */
     2920   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
     2921
     2922   /* Start of interlace block */
    28572923   PNG_CONST int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
    28582924
    2859    /* offset to next interlace block */
     2925   /* Offset to next interlace block */
    28602926   PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
    28612927
    2862    /* start of interlace block in the y direction */
     2928   /* Start of interlace block in the y direction */
    28632929   PNG_CONST int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
    28642930
    2865    /* offset to next interlace block in the y direction */
     2931   /* Offset to next interlace block in the y direction */
    28662932   PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
    28672933#endif /* PNG_READ_INTERLACING_SUPPORTED */
    28682934#endif
    28692935
    2870    png_debug(1, "in png_read_finish_row\n");
     2936   png_debug(1, "in png_read_finish_row");
    28712937   png_ptr->row_number++;
    28722938   if (png_ptr->row_number < png_ptr->num_rows)
     
    29202986      png_ptr->zstream.next_out = (Byte *)&extra;
    29212987      png_ptr->zstream.avail_out = (uInt)1;
    2922       for(;;)
     2988      for (;;)
    29232989      {
    29242990         if (!(png_ptr->zstream.avail_in))
     
    29783044   png_ptr->mode |= PNG_AFTER_IDAT;
    29793045}
     3046#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
    29803047
    29813048void /* PRIVATE */
     
    29843051#ifdef PNG_USE_LOCAL_ARRAYS
    29853052#ifdef PNG_READ_INTERLACING_SUPPORTED
    2986    /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    2987 
    2988    /* start of interlace block */
     3053   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
     3054
     3055   /* Start of interlace block */
    29893056   PNG_CONST int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
    29903057
    2991    /* offset to next interlace block */
     3058   /* Offset to next interlace block */
    29923059   PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
    29933060
    2994    /* start of interlace block in the y direction */
     3061   /* Start of interlace block in the y direction */
    29953062   PNG_CONST int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
    29963063
    2997    /* offset to next interlace block in the y direction */
     3064   /* Offset to next interlace block in the y direction */
    29983065   PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
    29993066#endif
     
    30013068
    30023069   int max_pixel_depth;
    3003    png_uint_32 row_bytes;
    3004 
    3005    png_debug(1, "in png_read_start_row\n");
     3070   png_size_t row_bytes;
     3071
     3072   png_debug(1, "in png_read_start_row");
    30063073   png_ptr->zstream.avail_in = 0;
    30073074   png_init_read_transformations(png_ptr);
     
    30203087         png_pass_inc[png_ptr->pass];
    30213088
    3022          row_bytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->iwidth) + 1;
    3023 
    3024          png_ptr->irowbytes = (png_size_t)row_bytes;
    3025          if((png_uint_32)png_ptr->irowbytes != row_bytes)
    3026             png_error(png_ptr, "Rowbytes overflow in png_read_start_row");
     3089         png_ptr->irowbytes =
     3090            PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1;
    30273091   }
    30283092   else
     
    31263190#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \
    31273191defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
    3128    if(png_ptr->transformations & PNG_USER_TRANSFORM)
     3192   if (png_ptr->transformations & PNG_USER_TRANSFORM)
    31293193     {
    3130        int user_pixel_depth=png_ptr->user_transform_depth*
     3194       int user_pixel_depth = png_ptr->user_transform_depth*
    31313195         png_ptr->user_transform_channels;
    3132        if(user_pixel_depth > max_pixel_depth)
     3196       if (user_pixel_depth > max_pixel_depth)
    31333197         max_pixel_depth=user_pixel_depth;
    31343198     }
    31353199#endif
    31363200
    3137    /* align the width on the next larger 8 pixels.  Mainly used
    3138       for interlacing */
     3201   /* Align the width on the next larger 8 pixels.  Mainly used
     3202    * for interlacing
     3203    */
    31393204   row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7));
    3140    /* calculate the maximum bytes needed, adding a byte and a pixel
    3141       for safety's sake */
    3142    row_bytes = PNG_ROWBYTES(max_pixel_depth,row_bytes) +
     3205   /* Calculate the maximum bytes needed, adding a byte and a pixel
     3206    * for safety's sake
     3207    */
     3208   row_bytes = PNG_ROWBYTES(max_pixel_depth, row_bytes) +
    31433209      1 + ((max_pixel_depth + 7) >> 3);
    31443210#ifdef PNG_MAX_MALLOC_64K
     
    31473213#endif
    31483214
    3149    if(row_bytes + 64 > png_ptr->old_big_row_buf_size)
    3150    {
    3151      png_free(png_ptr,png_ptr->big_row_buf);
    3152      png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64);
    3153      png_ptr->row_buf = png_ptr->big_row_buf+32;
    3154      png_ptr->old_big_row_buf_size = row_bytes+64;
     3215   if (row_bytes + 64 > png_ptr->old_big_row_buf_size)
     3216   {
     3217     png_free(png_ptr, png_ptr->big_row_buf);
     3218     png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes + 64);
     3219     if (png_ptr->interlaced)
     3220       png_memset(png_ptr->big_row_buf, 0, row_bytes + 64);
     3221     png_ptr->row_buf = png_ptr->big_row_buf + 32;
     3222     png_ptr->old_big_row_buf_size = row_bytes + 64;
    31553223   }
    31563224
    31573225#ifdef PNG_MAX_MALLOC_64K
    3158    if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L)
     3226   if ((png_uint_32)row_bytes + 1 > (png_uint_32)65536L)
    31593227      png_error(png_ptr, "This image requires a row greater than 64KB");
    31603228#endif
    3161    if ((png_uint_32)png_ptr->rowbytes > (png_uint_32)(PNG_SIZE_MAX - 1))
     3229   if ((png_uint_32)row_bytes > (png_uint_32)(PNG_SIZE_MAX - 1))
    31623230      png_error(png_ptr, "Row has too many bytes to allocate in memory.");
    31633231
    3164    if(png_ptr->rowbytes+1 > png_ptr->old_prev_row_size)
    3165    {
    3166      png_free(png_ptr,png_ptr->prev_row);
    3167      png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)(
    3168         png_ptr->rowbytes + 1));
    3169      png_ptr->old_prev_row_size = png_ptr->rowbytes+1;
    3170    }
    3171 
    3172    png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
    3173 
    3174    png_debug1(3, "width = %lu,\n", png_ptr->width);
    3175    png_debug1(3, "height = %lu,\n", png_ptr->height);
    3176    png_debug1(3, "iwidth = %lu,\n", png_ptr->iwidth);
    3177    png_debug1(3, "num_rows = %lu\n", png_ptr->num_rows);
    3178    png_debug1(3, "rowbytes = %lu,\n", png_ptr->rowbytes);
    3179    png_debug1(3, "irowbytes = %lu,\n", png_ptr->irowbytes);
     3232   if (row_bytes + 1 > png_ptr->old_prev_row_size)
     3233   {
     3234      png_free(png_ptr, png_ptr->prev_row);
     3235      png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)(
     3236        row_bytes + 1));
     3237      png_memset_check(png_ptr, png_ptr->prev_row, 0, row_bytes + 1);
     3238      png_ptr->old_prev_row_size = row_bytes + 1;
     3239   }
     3240
     3241   png_ptr->rowbytes = row_bytes;
     3242
     3243   png_debug1(3, "width = %lu,", png_ptr->width);
     3244   png_debug1(3, "height = %lu,", png_ptr->height);
     3245   png_debug1(3, "iwidth = %lu,", png_ptr->iwidth);
     3246   png_debug1(3, "num_rows = %lu,", png_ptr->num_rows);
     3247   png_debug1(3, "rowbytes = %lu,", png_ptr->rowbytes);
     3248   png_debug1(3, "irowbytes = %lu", png_ptr->irowbytes);
    31803249
    31813250   png_ptr->flags |= PNG_FLAG_ROW_INIT;
  • trunk/src/3rdparty/libpng/pngset.c

    r2 r561  
    22/* pngset.c - storage of image information into info struct
    33 *
    4  * Last changed in libpng 1.2.27 [April 29, 2008]
    5  * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2008 Glenn Randers-Pehrson
     4 * Last changed in libpng 1.2.40 [September 10, 2009]
     5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
    76 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    87 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     8 *
     9 * This code is released under the libpng license.
     10 * For conditions of distribution and use, see the disclaimer
     11 * and license in png.h
    912 *
    1013 * The functions here are used during reads to store data from the file
     
    1619#define PNG_INTERNAL
    1720#include "png.h"
    18 
    1921#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
    2022
     
    2325png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
    2426{
    25    png_debug1(1, "in %s storage function\n", "bKGD");
     27   png_debug1(1, "in %s storage function", "bKGD");
     28
    2629   if (png_ptr == NULL || info_ptr == NULL)
    2730      return;
     
    3942   double green_x, double green_y, double blue_x, double blue_y)
    4043{
    41    png_debug1(1, "in %s storage function\n", "cHRM");
    42    if (png_ptr == NULL || info_ptr == NULL)
    43       return;
    44    if (!(white_x || white_y || red_x || red_y || green_x || green_y ||
    45        blue_x || blue_y))
    46    {
    47       png_warning(png_ptr,
    48         "Ignoring attempt to set all-zero chromaticity values");
    49       return;
    50    }
    51    if (white_x < 0.0 || white_y < 0.0 ||
    52          red_x < 0.0 ||   red_y < 0.0 ||
    53        green_x < 0.0 || green_y < 0.0 ||
    54         blue_x < 0.0 ||  blue_y < 0.0)
    55    {
    56       png_warning(png_ptr,
    57         "Ignoring attempt to set negative chromaticity value");
    58       return;
    59    }
    60    if (white_x > 21474.83 || white_y > 21474.83 ||
    61          red_x > 21474.83 ||   red_y > 21474.83 ||
    62        green_x > 21474.83 || green_y > 21474.83 ||
    63         blue_x > 21474.83 ||  blue_y > 21474.83)
    64    {
    65       png_warning(png_ptr,
    66         "Ignoring attempt to set chromaticity value exceeding 21474.83");
    67       return;
    68    }
     44   png_debug1(1, "in %s storage function", "cHRM");
     45
     46   if (png_ptr == NULL || info_ptr == NULL)
     47      return;
    6948
    7049   info_ptr->x_white = (float)white_x;
     
    8867   info_ptr->valid |= PNG_INFO_cHRM;
    8968}
    90 #endif
     69#endif /* PNG_FLOATING_POINT_SUPPORTED */
     70
    9171#ifdef PNG_FIXED_POINT_SUPPORTED
    9272void PNGAPI
     
    9676   png_fixed_point blue_x, png_fixed_point blue_y)
    9777{
    98    png_debug1(1, "in %s storage function\n", "cHRM");
    99    if (png_ptr == NULL || info_ptr == NULL)
    100       return;
    101 
    102    if (!(white_x || white_y || red_x || red_y || green_x || green_y ||
    103        blue_x || blue_y))
    104    {
    105       png_warning(png_ptr,
    106         "Ignoring attempt to set all-zero chromaticity values");
    107       return;
    108    }
    109    if (white_x < 0 || white_y < 0 ||
    110          red_x < 0 ||   red_y < 0 ||
    111        green_x < 0 || green_y < 0 ||
    112         blue_x < 0 ||  blue_y < 0)
    113    {
    114       png_warning(png_ptr,
    115         "Ignoring attempt to set negative chromaticity value");
    116       return;
    117    }
    118    if (white_x > (png_fixed_point) PNG_UINT_31_MAX ||
    119        white_y > (png_fixed_point) PNG_UINT_31_MAX ||
    120          red_x > (png_fixed_point) PNG_UINT_31_MAX ||
    121          red_y > (png_fixed_point) PNG_UINT_31_MAX ||
    122        green_x > (png_fixed_point) PNG_UINT_31_MAX ||
    123        green_y > (png_fixed_point) PNG_UINT_31_MAX ||
    124         blue_x > (png_fixed_point) PNG_UINT_31_MAX ||
    125         blue_y > (png_fixed_point) PNG_UINT_31_MAX )
    126    {
    127       png_warning(png_ptr,
    128         "Ignoring attempt to set chromaticity value exceeding 21474.83");
    129       return;
    130    }
    131    info_ptr->int_x_white = white_x;
    132    info_ptr->int_y_white = white_y;
    133    info_ptr->int_x_red   = red_x;
    134    info_ptr->int_y_red   = red_y;
    135    info_ptr->int_x_green = green_x;
    136    info_ptr->int_y_green = green_y;
    137    info_ptr->int_x_blue  = blue_x;
    138    info_ptr->int_y_blue  = blue_y;
    139 #ifdef PNG_FLOATING_POINT_SUPPORTED
    140    info_ptr->x_white = (float)(white_x/100000.);
    141    info_ptr->y_white = (float)(white_y/100000.);
    142    info_ptr->x_red   = (float)(  red_x/100000.);
    143    info_ptr->y_red   = (float)(  red_y/100000.);
    144    info_ptr->x_green = (float)(green_x/100000.);
    145    info_ptr->y_green = (float)(green_y/100000.);
    146    info_ptr->x_blue  = (float)( blue_x/100000.);
    147    info_ptr->y_blue  = (float)( blue_y/100000.);
    148 #endif
    149    info_ptr->valid |= PNG_INFO_cHRM;
    150 }
    151 #endif
    152 #endif
     78   png_debug1(1, "in %s storage function", "cHRM fixed");
     79
     80   if (png_ptr == NULL || info_ptr == NULL)
     81      return;
     82
     83#if !defined(PNG_NO_CHECK_cHRM)
     84   if (png_check_cHRM_fixed(png_ptr,
     85      white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y))
     86#endif
     87   {
     88      info_ptr->int_x_white = white_x;
     89      info_ptr->int_y_white = white_y;
     90      info_ptr->int_x_red   = red_x;
     91      info_ptr->int_y_red   = red_y;
     92      info_ptr->int_x_green = green_x;
     93      info_ptr->int_y_green = green_y;
     94      info_ptr->int_x_blue  = blue_x;
     95      info_ptr->int_y_blue  = blue_y;
     96#ifdef  PNG_FLOATING_POINT_SUPPORTED
     97      info_ptr->x_white = (float)(white_x/100000.);
     98      info_ptr->y_white = (float)(white_y/100000.);
     99      info_ptr->x_red   = (float)(  red_x/100000.);
     100      info_ptr->y_red   = (float)(  red_y/100000.);
     101      info_ptr->x_green = (float)(green_x/100000.);
     102      info_ptr->y_green = (float)(green_y/100000.);
     103      info_ptr->x_blue  = (float)( blue_x/100000.);
     104      info_ptr->y_blue  = (float)( blue_y/100000.);
     105#endif
     106      info_ptr->valid |= PNG_INFO_cHRM;
     107   }
     108}
     109#endif /* PNG_FIXED_POINT_SUPPORTED */
     110#endif /* PNG_cHRM_SUPPORTED */
    153111
    154112#if defined(PNG_gAMA_SUPPORTED)
     
    157115png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
    158116{
    159    double gamma;
    160    png_debug1(1, "in %s storage function\n", "gAMA");
     117   double png_gamma;
     118
     119   png_debug1(1, "in %s storage function", "gAMA");
     120
    161121   if (png_ptr == NULL || info_ptr == NULL)
    162122      return;
     
    166126   {
    167127      png_warning(png_ptr, "Limiting gamma to 21474.83");
    168       gamma=21474.83;
     128      png_gamma=21474.83;
    169129   }
    170130   else
    171       gamma=file_gamma;
    172    info_ptr->gamma = (float)gamma;
     131      png_gamma = file_gamma;
     132   info_ptr->gamma = (float)png_gamma;
    173133#ifdef PNG_FIXED_POINT_SUPPORTED
    174    info_ptr->int_gamma = (int)(gamma*100000.+.5);
     134   info_ptr->int_gamma = (int)(png_gamma*100000.+.5);
    175135#endif
    176136   info_ptr->valid |= PNG_INFO_gAMA;
    177    if(gamma == 0.0)
     137   if (png_gamma == 0.0)
    178138      png_warning(png_ptr, "Setting gamma=0");
    179139}
     
    183143   int_gamma)
    184144{
    185    png_fixed_point gamma;
    186 
    187    png_debug1(1, "in %s storage function\n", "gAMA");
    188    if (png_ptr == NULL || info_ptr == NULL)
    189       return;
    190 
    191    if (int_gamma > (png_fixed_point) PNG_UINT_31_MAX)
    192    {
    193      png_warning(png_ptr, "Limiting gamma to 21474.83");
    194      gamma=PNG_UINT_31_MAX;
     145   png_fixed_point png_gamma;
     146
     147   png_debug1(1, "in %s storage function", "gAMA");
     148
     149   if (png_ptr == NULL || info_ptr == NULL)
     150      return;
     151
     152   if (int_gamma > (png_fixed_point)PNG_UINT_31_MAX)
     153   {
     154      png_warning(png_ptr, "Limiting gamma to 21474.83");
     155      png_gamma=PNG_UINT_31_MAX;
    195156   }
    196157   else
    197158   {
    198      if (int_gamma < 0)
    199      {
    200        png_warning(png_ptr, "Setting negative gamma to zero");
    201        gamma=0;
    202      }
    203      else
    204        gamma=int_gamma;
     159      if (int_gamma < 0)
     160      {
     161         png_warning(png_ptr, "Setting negative gamma to zero");
     162         png_gamma = 0;
     163      }
     164      else
     165         png_gamma = int_gamma;
    205166   }
    206167#ifdef PNG_FLOATING_POINT_SUPPORTED
    207    info_ptr->gamma = (float)(gamma/100000.);
     168   info_ptr->gamma = (float)(png_gamma/100000.);
    208169#endif
    209170#ifdef PNG_FIXED_POINT_SUPPORTED
    210    info_ptr->int_gamma = gamma;
     171   info_ptr->int_gamma = png_gamma;
    211172#endif
    212173   info_ptr->valid |= PNG_INFO_gAMA;
    213    if(gamma == 0)
     174   if (png_gamma == 0)
    214175      png_warning(png_ptr, "Setting gamma=0");
    215176}
     
    222183   int i;
    223184
    224    png_debug1(1, "in %s storage function\n", "hIST");
    225    if (png_ptr == NULL || info_ptr == NULL)
    226       return;
     185   png_debug1(1, "in %s storage function", "hIST");
     186
     187   if (png_ptr == NULL || info_ptr == NULL)
     188      return;
     189
    227190   if (info_ptr->num_palette == 0 || info_ptr->num_palette
    228191       > PNG_MAX_PALETTE_LENGTH)
    229192   {
    230        png_warning(png_ptr,
    231           "Invalid palette size, hIST allocation skipped.");
    232        return;
     193      png_warning(png_ptr,
     194         "Invalid palette size, hIST allocation skipped.");
     195      return;
    233196   }
    234197
     
    236199   png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);
    237200#endif
    238    /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in version
    239       1.2.1 */
     201   /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in
     202    * version 1.2.1
     203    */
    240204   png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr,
    241       (png_uint_32)(PNG_MAX_PALETTE_LENGTH * png_sizeof (png_uint_16)));
     205      (png_uint_32)(PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16)));
    242206   if (png_ptr->hist == NULL)
    243      {
    244        png_warning(png_ptr, "Insufficient memory for hIST chunk data.");
    245        return;
    246      }
     207   {
     208      png_warning(png_ptr, "Insufficient memory for hIST chunk data.");
     209      return;
     210   }
    247211
    248212   for (i = 0; i < info_ptr->num_palette; i++)
    249        png_ptr->hist[i] = hist[i];
     213      png_ptr->hist[i] = hist[i];
    250214   info_ptr->hist = png_ptr->hist;
    251215   info_ptr->valid |= PNG_INFO_hIST;
     
    265229   int filter_type)
    266230{
    267    png_debug1(1, "in %s storage function\n", "IHDR");
    268    if (png_ptr == NULL || info_ptr == NULL)
    269       return;
    270 
    271    /* check for width and height valid values */
     231   png_debug1(1, "in %s storage function", "IHDR");
     232
     233   if (png_ptr == NULL || info_ptr == NULL)
     234      return;
     235
     236   /* Check for width and height valid values */
    272237   if (width == 0 || height == 0)
    273238      png_error(png_ptr, "Image width or height is zero in IHDR");
     
    289254      png_warning(png_ptr, "Width is too large for libpng to process pixels");
    290255
    291    /* check other values */
     256   /* Check other values */
    292257   if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 &&
    293       bit_depth != 8 && bit_depth != 16)
     258       bit_depth != 8 && bit_depth != 16)
    294259      png_error(png_ptr, "Invalid bit depth in IHDR");
    295260
    296261   if (color_type < 0 || color_type == 1 ||
    297       color_type == 5 || color_type > 6)
     262       color_type == 5 || color_type > 6)
    298263      png_error(png_ptr, "Invalid color type in IHDR");
    299264
     
    320285    * 5. The color_type is RGB or RGBA
    321286    */
    322    if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted)
    323       png_warning(png_ptr,"MNG features are not allowed in a PNG datastream");
    324    if(filter_type != PNG_FILTER_TYPE_BASE)
    325    {
    326      if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
    327         (filter_type == PNG_INTRAPIXEL_DIFFERENCING) &&
    328         ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&
    329         (color_type == PNG_COLOR_TYPE_RGB ||
     287   if ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted)
     288      png_warning(png_ptr, "MNG features are not allowed in a PNG datastream");
     289   if (filter_type != PNG_FILTER_TYPE_BASE)
     290   {
     291     if (!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
     292         (filter_type == PNG_INTRAPIXEL_DIFFERENCING) &&
     293         ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&
     294         (color_type == PNG_COLOR_TYPE_RGB ||
    330295         color_type == PNG_COLOR_TYPE_RGB_ALPHA)))
    331296        png_error(png_ptr, "Unknown filter method in IHDR");
    332      if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)
     297     if (png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)
    333298        png_warning(png_ptr, "Invalid filter method in IHDR");
    334299   }
    335300#else
    336    if(filter_type != PNG_FILTER_TYPE_BASE)
     301   if (filter_type != PNG_FILTER_TYPE_BASE)
    337302      png_error(png_ptr, "Unknown filter method in IHDR");
    338303#endif
     
    355320   info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
    356321
    357    /* check for potential overflow */
     322   /* Check for potential overflow */
    358323   if (width > (PNG_UINT_32_MAX
    359324                 >> 3)      /* 8-byte RGBA pixels */
     
    364329      info_ptr->rowbytes = (png_size_t)0;
    365330   else
    366       info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,width);
     331      info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);
    367332}
    368333
     
    372337   png_int_32 offset_x, png_int_32 offset_y, int unit_type)
    373338{
    374    png_debug1(1, "in %s storage function\n", "oFFs");
     339   png_debug1(1, "in %s storage function", "oFFs");
     340
    375341   if (png_ptr == NULL || info_ptr == NULL)
    376342      return;
     
    392358   int i;
    393359
    394    png_debug1(1, "in %s storage function\n", "pCAL");
     360   png_debug1(1, "in %s storage function", "pCAL");
     361
    395362   if (png_ptr == NULL || info_ptr == NULL)
    396363      return;
    397364
    398365   length = png_strlen(purpose) + 1;
    399    png_debug1(3, "allocating purpose for info (%lu bytes)\n", length);
     366   png_debug1(3, "allocating purpose for info (%lu bytes)",
     367     (unsigned long)length);
    400368   info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length);
    401369   if (info_ptr->pcal_purpose == NULL)
    402      {
    403        png_warning(png_ptr, "Insufficient memory for pCAL purpose.");
    404        return;
    405      }
     370   {
     371      png_warning(png_ptr, "Insufficient memory for pCAL purpose.");
     372      return;
     373   }
    406374   png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length);
    407375
    408    png_debug(3, "storing X0, X1, type, and nparams in info\n");
     376   png_debug(3, "storing X0, X1, type, and nparams in info");
    409377   info_ptr->pcal_X0 = X0;
    410378   info_ptr->pcal_X1 = X1;
     
    413381
    414382   length = png_strlen(units) + 1;
    415    png_debug1(3, "allocating units for info (%lu bytes)\n", length);
     383   png_debug1(3, "allocating units for info (%lu bytes)",
     384     (unsigned long)length);
    416385   info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length);
    417386   if (info_ptr->pcal_units == NULL)
    418      {
    419        png_warning(png_ptr, "Insufficient memory for pCAL units.");
    420        return;
    421      }
     387   {
     388      png_warning(png_ptr, "Insufficient memory for pCAL units.");
     389      return;
     390   }
    422391   png_memcpy(info_ptr->pcal_units, units, (png_size_t)length);
    423392
     
    425394      (png_uint_32)((nparams + 1) * png_sizeof(png_charp)));
    426395   if (info_ptr->pcal_params == NULL)
    427      {
    428        png_warning(png_ptr, "Insufficient memory for pCAL params.");
    429        return;
    430      }
    431 
    432    info_ptr->pcal_params[nparams] = NULL;
     396   {
     397      png_warning(png_ptr, "Insufficient memory for pCAL params.");
     398      return;
     399   }
     400
     401   png_memset(info_ptr->pcal_params, 0, (nparams + 1) * png_sizeof(png_charp));
    433402
    434403   for (i = 0; i < nparams; i++)
    435404   {
    436405      length = png_strlen(params[i]) + 1;
    437       png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, length);
     406      png_debug2(3, "allocating parameter %d for info (%lu bytes)", i,
     407        (unsigned long)length);
    438408      info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length);
    439409      if (info_ptr->pcal_params[i] == NULL)
    440         {
    441           png_warning(png_ptr, "Insufficient memory for pCAL parameter.");
    442           return;
    443         }
     410      {
     411         png_warning(png_ptr, "Insufficient memory for pCAL parameter.");
     412         return;
     413      }
    444414      png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length);
    445415   }
     
    458428             int unit, double width, double height)
    459429{
    460    png_debug1(1, "in %s storage function\n", "sCAL");
     430   png_debug1(1, "in %s storage function", "sCAL");
     431
    461432   if (png_ptr == NULL || info_ptr == NULL)
    462433      return;
     
    476447   png_uint_32 length;
    477448
    478    png_debug1(1, "in %s storage function\n", "sCAL");
     449   png_debug1(1, "in %s storage function", "sCAL");
     450
    479451   if (png_ptr == NULL || info_ptr == NULL)
    480452      return;
     
    483455
    484456   length = png_strlen(swidth) + 1;
    485    png_debug1(3, "allocating unit for info (%d bytes)\n", length);
     457   png_debug1(3, "allocating unit for info (%u bytes)",
     458      (unsigned int)length);
    486459   info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length);
    487460   if (info_ptr->scal_s_width == NULL)
     
    494467
    495468   length = png_strlen(sheight) + 1;
    496    png_debug1(3, "allocating unit for info (%d bytes)\n", length);
     469   png_debug1(3, "allocating unit for info (%u bytes)",
     470      (unsigned int)length);
    497471   info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length);
    498472   if (info_ptr->scal_s_height == NULL)
    499473   {
    500474      png_free (png_ptr, info_ptr->scal_s_width);
     475      info_ptr->scal_s_width = NULL;
    501476      png_warning(png_ptr,
    502477       "Memory allocation failed while processing sCAL.");
     
    518493   png_uint_32 res_x, png_uint_32 res_y, int unit_type)
    519494{
    520    png_debug1(1, "in %s storage function\n", "pHYs");
     495   png_debug1(1, "in %s storage function", "pHYs");
     496
    521497   if (png_ptr == NULL || info_ptr == NULL)
    522498      return;
     
    534510{
    535511
    536    png_debug1(1, "in %s storage function\n", "PLTE");
     512   png_debug1(1, "in %s storage function", "PLTE");
     513
    537514   if (png_ptr == NULL || info_ptr == NULL)
    538515      return;
    539516
    540517   if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH)
    541      {
    542        if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
     518   {
     519      if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
    543520         png_error(png_ptr, "Invalid palette length");
    544        else
    545        {
     521      else
     522      {
    546523         png_warning(png_ptr, "Invalid palette length");
    547524         return;
    548        }
    549      }
     525      }
     526   }
    550527
    551528   /*
     
    559536
    560537   /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead
    561       of num_palette entries,
    562       in case of an invalid PNG file that has too-large sample values. */
     538    * of num_palette entries, in case of an invalid PNG file that has
     539    * too-large sample values.
     540    */
    563541   png_ptr->palette = (png_colorp)png_malloc(png_ptr,
    564542      PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color));
    565543   png_memset(png_ptr->palette, 0, PNG_MAX_PALETTE_LENGTH *
    566544      png_sizeof(png_color));
    567    png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof (png_color));
     545   png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof(png_color));
    568546   info_ptr->palette = png_ptr->palette;
    569547   info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
     
    583561   png_color_8p sig_bit)
    584562{
    585    png_debug1(1, "in %s storage function\n", "sBIT");
    586    if (png_ptr == NULL || info_ptr == NULL)
    587       return;
    588 
    589    png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof (png_color_8));
     563   png_debug1(1, "in %s storage function", "sBIT");
     564
     565   if (png_ptr == NULL || info_ptr == NULL)
     566      return;
     567
     568   png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof(png_color_8));
    590569   info_ptr->valid |= PNG_INFO_sBIT;
    591570}
     
    596575png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent)
    597576{
    598    png_debug1(1, "in %s storage function\n", "sRGB");
     577   png_debug1(1, "in %s storage function", "sRGB");
     578
    599579   if (png_ptr == NULL || info_ptr == NULL)
    600580      return;
     
    620600   float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
    621601#endif
    622 #ifdef PNG_FIXED_POINT_SUPPORTED
    623602   png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x,
    624603      int_green_y, int_blue_x, int_blue_y;
    625604#endif
    626 #endif
    627    png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM");
     605   png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM");
     606
    628607   if (png_ptr == NULL || info_ptr == NULL)
    629608      return;
     
    643622
    644623#if defined(PNG_cHRM_SUPPORTED)
    645 #ifdef PNG_FIXED_POINT_SUPPORTED
    646624   int_white_x = 31270L;
    647625   int_white_y = 32900L;
     
    653631   int_blue_y  =  6000L;
    654632
    655    png_set_cHRM_fixed(png_ptr, info_ptr,
    656       int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y,
    657       int_blue_x, int_blue_y);
    658 #endif
    659633#ifdef PNG_FLOATING_POINT_SUPPORTED
    660634   white_x = (float).3127;
     
    666640   blue_x  = (float).15;
    667641   blue_y  = (float).06;
    668 
    669    png_set_cHRM(png_ptr, info_ptr,
    670       white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y);
    671 #endif
    672 #endif
    673 }
    674 #endif
     642#endif
     643
     644#if !defined(PNG_NO_CHECK_cHRM)
     645   if (png_check_cHRM_fixed(png_ptr,
     646       int_white_x, int_white_y, int_red_x, int_red_y, int_green_x,
     647       int_green_y, int_blue_x, int_blue_y))
     648#endif
     649   {
     650#ifdef PNG_FIXED_POINT_SUPPORTED
     651      png_set_cHRM_fixed(png_ptr, info_ptr,
     652          int_white_x, int_white_y, int_red_x, int_red_y, int_green_x,
     653          int_green_y, int_blue_x, int_blue_y);
     654#endif
     655#ifdef PNG_FLOATING_POINT_SUPPORTED
     656      png_set_cHRM(png_ptr, info_ptr,
     657          white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y);
     658#endif
     659   }
     660#endif /* cHRM */
     661}
     662#endif /* sRGB */
    675663
    676664
     
    685673   png_uint_32 length;
    686674
    687    png_debug1(1, "in %s storage function\n", "iCCP");
     675   png_debug1(1, "in %s storage function", "iCCP");
     676
    688677   if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)
    689678      return;
     
    701690   {
    702691      png_free (png_ptr, new_iccp_name);
    703       png_warning(png_ptr, "Insufficient memory to process iCCP profile.");
     692      png_warning(png_ptr,
     693      "Insufficient memory to process iCCP profile.");
    704694      return;
    705695   }
     
    724714void PNGAPI
    725715png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
    726    int num_text)
     716             int num_text)
    727717{
    728718   int ret;
    729    ret=png_set_text_2(png_ptr, info_ptr, text_ptr, num_text);
     719   ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text);
    730720   if (ret)
    731      png_error(png_ptr, "Insufficient memory to store text");
     721      png_error(png_ptr, "Insufficient memory to store text");
    732722}
    733723
    734724int /* PRIVATE */
    735725png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
    736    int num_text)
     726               int num_text)
    737727{
    738728   int i;
    739729
    740    png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ?
     730   png_debug1(1, "in %s storage function", ((png_ptr == NULL ||
     731      png_ptr->chunk_name[0] == '\0') ?
    741732      "text" : (png_const_charp)png_ptr->chunk_name));
    742733
     
    758749         old_text = info_ptr->text;
    759750         info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
    760             (png_uint_32)(info_ptr->max_text * png_sizeof (png_text)));
     751            (png_uint_32)(info_ptr->max_text * png_sizeof(png_text)));
    761752         if (info_ptr->text == NULL)
    762            {
    763              png_free(png_ptr, old_text);
    764              return(1);
    765            }
     753         {
     754            png_free(png_ptr, old_text);
     755            return(1);
     756         }
    766757         png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max *
    767758            png_sizeof(png_text)));
     
    773764         info_ptr->num_text = 0;
    774765         info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
    775             (png_uint_32)(info_ptr->max_text * png_sizeof (png_text)));
     766            (png_uint_32)(info_ptr->max_text * png_sizeof(png_text)));
    776767         if (info_ptr->text == NULL)
    777            return(1);
     768            return(1);
    778769#ifdef PNG_FREE_ME_SUPPORTED
    779770         info_ptr->free_me |= PNG_FREE_TEXT;
    780771#endif
    781772      }
    782       png_debug1(3, "allocated %d entries for info_ptr->text\n",
     773      png_debug1(3, "allocated %d entries for info_ptr->text",
    783774         info_ptr->max_text);
    784775   }
    785776   for (i = 0; i < num_text; i++)
    786777   {
    787       png_size_t text_length,key_len;
    788       png_size_t lang_len,lang_key_len;
     778      png_size_t text_length, key_len;
     779      png_size_t lang_len, lang_key_len;
    789780      png_textp textp = &(info_ptr->text[info_ptr->num_text]);
    790781
     
    794785      key_len = png_strlen(text_ptr[i].key);
    795786
    796       if(text_ptr[i].compression <= 0)
    797       {
    798         lang_len = 0;
    799         lang_key_len = 0;
     787      if (text_ptr[i].compression <= 0)
     788      {
     789         lang_len = 0;
     790         lang_key_len = 0;
    800791      }
    801792      else
    802793#ifdef PNG_iTXt_SUPPORTED
    803794      {
    804         /* set iTXt data */
    805         if (text_ptr[i].lang != NULL)
    806           lang_len = png_strlen(text_ptr[i].lang);
    807         else
    808           lang_len = 0;
    809         if (text_ptr[i].lang_key != NULL)
    810           lang_key_len = png_strlen(text_ptr[i].lang_key);
    811         else
    812           lang_key_len = 0;
     795         /* Set iTXt data */
     796         if (text_ptr[i].lang != NULL)
     797            lang_len = png_strlen(text_ptr[i].lang);
     798         else
     799            lang_len = 0;
     800         if (text_ptr[i].lang_key != NULL)
     801            lang_key_len = png_strlen(text_ptr[i].lang_key);
     802         else
     803            lang_key_len = 0;
    813804      }
    814805#else
    815806      {
    816         png_warning(png_ptr, "iTXt chunk not supported.");
    817         continue;
     807         png_warning(png_ptr, "iTXt chunk not supported.");
     808         continue;
    818809      }
    819810#endif
     
    823814         text_length = 0;
    824815#ifdef PNG_iTXt_SUPPORTED
    825          if(text_ptr[i].compression > 0)
     816         if (text_ptr[i].compression > 0)
    826817            textp->compression = PNG_ITXT_COMPRESSION_NONE;
    827818         else
     
    836827
    837828      textp->key = (png_charp)png_malloc_warn(png_ptr,
    838          (png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4));
     829         (png_uint_32)
     830         (key_len + text_length + lang_len + lang_key_len + 4));
    839831      if (textp->key == NULL)
    840         return(1);
    841       png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n",
    842          (png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4),
    843          (int)textp->key);
    844 
    845       png_memcpy(textp->key, text_ptr[i].key,
    846          (png_size_t)(key_len));
    847       *(textp->key+key_len) = '\0';
     832         return(1);
     833      png_debug2(2, "Allocated %lu bytes at %x in png_set_text",
     834                 (png_uint_32)
     835                 (key_len + lang_len + lang_key_len + text_length + 4),
     836                 (int)textp->key);
     837
     838      png_memcpy(textp->key, text_ptr[i].key,(png_size_t)(key_len));
     839      *(textp->key + key_len) = '\0';
    848840#ifdef PNG_iTXt_SUPPORTED
    849841      if (text_ptr[i].compression > 0)
    850842      {
    851          textp->lang=textp->key + key_len + 1;
     843         textp->lang = textp->key + key_len + 1;
    852844         png_memcpy(textp->lang, text_ptr[i].lang, lang_len);
    853          *(textp->lang+lang_len) = '\0';
    854          textp->lang_key=textp->lang + lang_len + 1;
     845         *(textp->lang + lang_len) = '\0';
     846         textp->lang_key = textp->lang + lang_len + 1;
    855847         png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len);
    856          *(textp->lang_key+lang_key_len) = '\0';
    857          textp->text=textp->lang_key + lang_key_len + 1;
     848         *(textp->lang_key + lang_key_len) = '\0';
     849         textp->text = textp->lang_key + lang_key_len + 1;
    858850      }
    859851      else
     
    864856         textp->lang_key=NULL;
    865857#endif
    866          textp->text=textp->key + key_len + 1;
    867       }
    868       if(text_length)
     858         textp->text = textp->key + key_len + 1;
     859      }
     860      if (text_length)
    869861         png_memcpy(textp->text, text_ptr[i].text,
    870862            (png_size_t)(text_length));
    871       *(textp->text+text_length) = '\0';
     863      *(textp->text + text_length) = '\0';
    872864
    873865#ifdef PNG_iTXt_SUPPORTED
    874       if(textp->compression > 0)
     866      if (textp->compression > 0)
    875867      {
    876868         textp->text_length = 0;
     
    886878      }
    887879      info_ptr->num_text++;
    888       png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text);
     880      png_debug1(3, "transferred text chunk %d", info_ptr->num_text);
    889881   }
    890882   return(0);
     
    896888png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
    897889{
    898    png_debug1(1, "in %s storage function\n", "tIME");
     890   png_debug1(1, "in %s storage function", "tIME");
     891
    899892   if (png_ptr == NULL || info_ptr == NULL ||
    900893       (png_ptr->mode & PNG_WROTE_tIME))
    901894      return;
    902895
    903    png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof (png_time));
     896   png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof(png_time));
    904897   info_ptr->valid |= PNG_INFO_tIME;
    905898}
     
    911904   png_bytep trans, int num_trans, png_color_16p trans_values)
    912905{
    913    png_debug1(1, "in %s storage function\n", "tRNS");
    914    if (png_ptr == NULL || info_ptr == NULL)
    915       return;
    916 
    917    png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
     906   png_debug1(1, "in %s storage function", "tRNS");
     907
     908   if (png_ptr == NULL || info_ptr == NULL)
     909      return;
    918910
    919911   if (trans != NULL)
     
    925917        */
    926918
     919#ifdef PNG_FREE_ME_SUPPORTED
     920       png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
     921#endif
     922
    927923       /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */
    928924       png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr,
    929925           (png_uint_32)PNG_MAX_PALETTE_LENGTH);
    930926       if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH)
    931          png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans);
     927          png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans);
    932928   }
    933929
     
    941937          (int)trans_values->green > sample_max ||
    942938          (int)trans_values->blue > sample_max)))
    943         png_warning(png_ptr,
    944            "tRNS chunk has out-of-range samples for bit_depth");
     939         png_warning(png_ptr,
     940            "tRNS chunk has out-of-range samples for bit_depth");
    945941      png_memcpy(&(info_ptr->trans_values), trans_values,
    946942         png_sizeof(png_color_16));
    947943      if (num_trans == 0)
    948         num_trans = 1;
     944         num_trans = 1;
    949945   }
    950946
     
    966962png_set_sPLT(png_structp png_ptr,
    967963             png_infop info_ptr, png_sPLT_tp entries, int nentries)
    968 {
    969     png_sPLT_tp np;
    970     int i;
    971 
    972     if (png_ptr == NULL || info_ptr == NULL)
    973        return;
    974 
    975     np = (png_sPLT_tp)png_malloc_warn(png_ptr,
    976         (info_ptr->splt_palettes_num + nentries) * png_sizeof(png_sPLT_t));
    977     if (np == NULL)
    978     {
     964/*
     965 *  entries        - array of png_sPLT_t structures
     966 *                   to be added to the list of palettes
     967 *                   in the info structure.
     968 *  nentries       - number of palette structures to be
     969 *                   added.
     970 */
     971{
     972   png_sPLT_tp np;
     973   int i;
     974
     975   if (png_ptr == NULL || info_ptr == NULL)
     976      return;
     977
     978   np = (png_sPLT_tp)png_malloc_warn(png_ptr,
     979       (info_ptr->splt_palettes_num + nentries) *
     980        (png_uint_32)png_sizeof(png_sPLT_t));
     981   if (np == NULL)
     982   {
    979983      png_warning(png_ptr, "No memory for sPLT palettes.");
    980       return;
    981     }
    982 
    983     png_memcpy(np, info_ptr->splt_palettes,
    984            info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t));
    985     png_free(png_ptr, info_ptr->splt_palettes);
    986     info_ptr->splt_palettes=NULL;
    987 
    988     for (i = 0; i < nentries; i++)
    989     {
    990         png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;
    991         png_sPLT_tp from = entries + i;
    992         png_uint_32 length;
    993 
    994         length = png_strlen(from->name) + 1;
     984     return;
     985   }
     986
     987   png_memcpy(np, info_ptr->splt_palettes,
     988          info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t));
     989   png_free(png_ptr, info_ptr->splt_palettes);
     990   info_ptr->splt_palettes=NULL;
     991
     992   for (i = 0; i < nentries; i++)
     993   {
     994      png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;
     995      png_sPLT_tp from = entries + i;
     996      png_uint_32 length;
     997
     998      length = png_strlen(from->name) + 1;
    995999        to->name = (png_charp)png_malloc_warn(png_ptr, length);
    996         if (to->name == NULL)
    997         {
    998            png_warning(png_ptr,
    999              "Out of memory while processing sPLT chunk");
    1000            continue;
    1001         }
    1002         png_memcpy(to->name, from->name, length);
    1003         to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr,
    1004             from->nentries * png_sizeof(png_sPLT_entry));
    1005         if (to->entries == NULL)
    1006         {
    1007            png_warning(png_ptr,
    1008              "Out of memory while processing sPLT chunk");
    1009            png_free(png_ptr,to->name);
    1010            to->name = NULL;
    1011            continue;
    1012         }
    1013         png_memcpy(to->entries, from->entries,
    1014             from->nentries * png_sizeof(png_sPLT_entry));
    1015         to->nentries = from->nentries;
    1016         to->depth = from->depth;
    1017     }
    1018 
    1019     info_ptr->splt_palettes = np;
    1020     info_ptr->splt_palettes_num += nentries;
    1021     info_ptr->valid |= PNG_INFO_sPLT;
     1000      if (to->name == NULL)
     1001      {
     1002         png_warning(png_ptr,
     1003           "Out of memory while processing sPLT chunk");
     1004         continue;
     1005      }
     1006      png_memcpy(to->name, from->name, length);
     1007      to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr,
     1008            (png_uint_32)(from->nentries * png_sizeof(png_sPLT_entry)));
     1009      if (to->entries == NULL)
     1010      {
     1011         png_warning(png_ptr,
     1012           "Out of memory while processing sPLT chunk");
     1013         png_free(png_ptr, to->name);
     1014         to->name = NULL;
     1015         continue;
     1016      }
     1017      png_memcpy(to->entries, from->entries,
     1018          from->nentries * png_sizeof(png_sPLT_entry));
     1019      to->nentries = from->nentries;
     1020      to->depth = from->depth;
     1021   }
     1022
     1023   info_ptr->splt_palettes = np;
     1024   info_ptr->splt_palettes_num += nentries;
     1025   info_ptr->valid |= PNG_INFO_sPLT;
    10221026#ifdef PNG_FREE_ME_SUPPORTED
    1023     info_ptr->free_me |= PNG_FREE_SPLT;
     1027   info_ptr->free_me |= PNG_FREE_SPLT;
    10241028#endif
    10251029}
    10261030#endif /* PNG_sPLT_SUPPORTED */
    10271031
    1028 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
     1032#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
    10291033void PNGAPI
    10301034png_set_unknown_chunks(png_structp png_ptr,
    10311035   png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)
    10321036{
    1033     png_unknown_chunkp np;
    1034     int i;
    1035 
    1036     if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0)
    1037         return;
    1038 
    1039     np = (png_unknown_chunkp)png_malloc_warn(png_ptr,
    1040         (info_ptr->unknown_chunks_num + num_unknowns) *
    1041         png_sizeof(png_unknown_chunk));
    1042     if (np == NULL)
    1043     {
    1044        png_warning(png_ptr,
    1045           "Out of memory while processing unknown chunk.");
    1046        return;
    1047     }
    1048 
    1049     png_memcpy(np, info_ptr->unknown_chunks,
    1050            info_ptr->unknown_chunks_num * png_sizeof(png_unknown_chunk));
    1051     png_free(png_ptr, info_ptr->unknown_chunks);
    1052     info_ptr->unknown_chunks=NULL;
    1053 
    1054     for (i = 0; i < num_unknowns; i++)
    1055     {
    1056        png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
    1057        png_unknown_chunkp from = unknowns + i;
    1058 
    1059        png_memcpy((png_charp)to->name,
    1060                   (png_charp)from->name,
    1061                   png_sizeof(from->name));
    1062        to->name[png_sizeof(to->name)-1] = '\0';
    1063        to->size = from->size;
    1064        /* note our location in the read or write sequence */
    1065        to->location = (png_byte)(png_ptr->mode & 0xff);
    1066 
    1067        if (from->size == 0)
    1068           to->data=NULL;
    1069        else
    1070        {
    1071           to->data = (png_bytep)png_malloc_warn(png_ptr, from->size);
    1072           if (to->data == NULL)
    1073           {
    1074              png_warning(png_ptr,
    1075               "Out of memory while processing unknown chunk.");
    1076              to->size=0;
    1077           }
    1078           else
    1079              png_memcpy(to->data, from->data, from->size);
    1080        }
    1081     }
    1082 
    1083     info_ptr->unknown_chunks = np;
    1084     info_ptr->unknown_chunks_num += num_unknowns;
     1037   png_unknown_chunkp np;
     1038   int i;
     1039
     1040   if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0)
     1041      return;
     1042
     1043   np = (png_unknown_chunkp)png_malloc_warn(png_ptr,
     1044       (png_uint_32)((info_ptr->unknown_chunks_num + num_unknowns) *
     1045       png_sizeof(png_unknown_chunk)));
     1046   if (np == NULL)
     1047   {
     1048      png_warning(png_ptr,
     1049         "Out of memory while processing unknown chunk.");
     1050      return;
     1051   }
     1052
     1053   png_memcpy(np, info_ptr->unknown_chunks,
     1054          info_ptr->unknown_chunks_num * png_sizeof(png_unknown_chunk));
     1055   png_free(png_ptr, info_ptr->unknown_chunks);
     1056   info_ptr->unknown_chunks=NULL;
     1057
     1058   for (i = 0; i < num_unknowns; i++)
     1059   {
     1060      png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
     1061      png_unknown_chunkp from = unknowns + i;
     1062
     1063      png_memcpy((png_charp)to->name,
     1064                 (png_charp)from->name,
     1065                 png_sizeof(from->name));
     1066      to->name[png_sizeof(to->name)-1] = '\0';
     1067      to->size = from->size;
     1068      /* Note our location in the read or write sequence */
     1069      to->location = (png_byte)(png_ptr->mode & 0xff);
     1070
     1071      if (from->size == 0)
     1072         to->data=NULL;
     1073      else
     1074      {
     1075         to->data = (png_bytep)png_malloc_warn(png_ptr,
     1076           (png_uint_32)from->size);
     1077         if (to->data == NULL)
     1078         {
     1079            png_warning(png_ptr,
     1080             "Out of memory while processing unknown chunk.");
     1081            to->size = 0;
     1082         }
     1083         else
     1084            png_memcpy(to->data, from->data, from->size);
     1085      }
     1086   }
     1087
     1088   info_ptr->unknown_chunks = np;
     1089   info_ptr->unknown_chunks_num += num_unknowns;
    10851090#ifdef PNG_FREE_ME_SUPPORTED
    1086     info_ptr->free_me |= PNG_FREE_UNKN;
     1091   info_ptr->free_me |= PNG_FREE_UNKN;
    10871092#endif
    10881093}
     
    10911096   int chunk, int location)
    10921097{
    1093    if(png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk <
     1098   if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk <
    10941099         (int)info_ptr->unknown_chunks_num)
    10951100      info_ptr->unknown_chunks[chunk].location = (png_byte)location;
     
    11051110   /* This function is deprecated in favor of png_permit_mng_features()
    11061111      and will be removed from libpng-1.3.0 */
    1107    png_debug(1, "in png_permit_empty_plte, DEPRECATED.\n");
     1112
     1113   png_debug(1, "in png_permit_empty_plte, DEPRECATED.");
     1114
    11081115   if (png_ptr == NULL)
    11091116      return;
     
    11191126png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features)
    11201127{
    1121    png_debug(1, "in png_permit_mng_features\n");
     1128   png_debug(1, "in png_permit_mng_features");
     1129
    11221130   if (png_ptr == NULL)
    11231131      return (png_uint_32)0;
     
    11331141   chunk_list, int num_chunks)
    11341142{
    1135     png_bytep new_list, p;
    1136     int i, old_num_chunks;
    1137     if (png_ptr == NULL)
    1138        return;
    1139     if (num_chunks == 0)
    1140     {
    1141       if(keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE)
    1142         png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS;
     1143   png_bytep new_list, p;
     1144   int i, old_num_chunks;
     1145   if (png_ptr == NULL)
     1146      return;
     1147   if (num_chunks == 0)
     1148   {
     1149      if (keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE)
     1150         png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS;
    11431151      else
    1144         png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS;
    1145 
    1146       if(keep == PNG_HANDLE_CHUNK_ALWAYS)
    1147         png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS;
     1152         png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS;
     1153
     1154      if (keep == PNG_HANDLE_CHUNK_ALWAYS)
     1155         png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS;
    11481156      else
    1149         png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS;
    1150       return;
    1151     }
    1152     if (chunk_list == NULL)
    1153       return;
    1154     old_num_chunks=png_ptr->num_chunk_list;
    1155     new_list=(png_bytep)png_malloc(png_ptr,
    1156        (png_uint_32)(5*(num_chunks+old_num_chunks)));
    1157     if(png_ptr->chunk_list != NULL)
    1158     {
    1159        png_memcpy(new_list, png_ptr->chunk_list,
    1160           (png_size_t)(5*old_num_chunks));
    1161        png_free(png_ptr, png_ptr->chunk_list);
    1162        png_ptr->chunk_list=NULL;
    1163     }
    1164     png_memcpy(new_list+5*old_num_chunks, chunk_list,
    1165        (png_size_t)(5*num_chunks));
    1166     for (p=new_list+5*old_num_chunks+4, i=0; i<num_chunks; i++, p+=5)
    1167        *p=(png_byte)keep;
    1168     png_ptr->num_chunk_list=old_num_chunks+num_chunks;
    1169     png_ptr->chunk_list=new_list;
     1157         png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS;
     1158      return;
     1159   }
     1160   if (chunk_list == NULL)
     1161      return;
     1162   old_num_chunks = png_ptr->num_chunk_list;
     1163   new_list=(png_bytep)png_malloc(png_ptr,
     1164      (png_uint_32)
     1165      (5*(num_chunks + old_num_chunks)));
     1166   if (png_ptr->chunk_list != NULL)
     1167   {
     1168      png_memcpy(new_list, png_ptr->chunk_list,
     1169         (png_size_t)(5*old_num_chunks));
     1170      png_free(png_ptr, png_ptr->chunk_list);
     1171      png_ptr->chunk_list=NULL;
     1172   }
     1173   png_memcpy(new_list + 5*old_num_chunks, chunk_list,
     1174      (png_size_t)(5*num_chunks));
     1175   for (p = new_list + 5*old_num_chunks + 4, i = 0; i<num_chunks; i++, p += 5)
     1176      *p=(png_byte)keep;
     1177   png_ptr->num_chunk_list = old_num_chunks + num_chunks;
     1178   png_ptr->chunk_list = new_list;
    11701179#ifdef PNG_FREE_ME_SUPPORTED
    1171     png_ptr->free_me |= PNG_FREE_LIST;
     1180   png_ptr->free_me |= PNG_FREE_LIST;
    11721181#endif
    11731182}
     
    11791188   png_user_chunk_ptr read_user_chunk_fn)
    11801189{
    1181    png_debug(1, "in png_set_read_user_chunk_fn\n");
     1190   png_debug(1, "in png_set_read_user_chunk_fn");
     1191
    11821192   if (png_ptr == NULL)
    11831193      return;
     1194
    11841195   png_ptr->read_user_chunk_fn = read_user_chunk_fn;
    11851196   png_ptr->user_chunk_ptr = user_chunk_ptr;
     
    11911202png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers)
    11921203{
    1193    png_debug1(1, "in %s storage function\n", "rows");
    1194 
    1195    if (png_ptr == NULL || info_ptr == NULL)
    1196       return;
    1197 
    1198    if(info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers))
     1204   png_debug1(1, "in %s storage function", "rows");
     1205
     1206   if (png_ptr == NULL || info_ptr == NULL)
     1207      return;
     1208
     1209   if (info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers))
    11991210      png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
    12001211   info_ptr->row_pointers = row_pointers;
    1201    if(row_pointers)
     1212   if (row_pointers)
    12021213      info_ptr->valid |= PNG_INFO_IDAT;
    12031214}
     
    12061217#ifdef PNG_WRITE_SUPPORTED
    12071218void PNGAPI
    1208 png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size)
     1219png_set_compression_buffer_size(png_structp png_ptr,
     1220    png_uint_32 size)
    12091221{
    12101222    if (png_ptr == NULL)
     
    12281240#ifndef PNG_1_0_X
    12291241#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
    1230 /* function was added to libpng 1.2.0 and should always exist by default */
     1242/* Function was added to libpng 1.2.0 and should always exist by default */
    12311243void PNGAPI
    12321244png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags)
     
    12351247    if (png_ptr != NULL)
    12361248    png_ptr->asm_flags = 0;
    1237 }
    1238 
    1239 /* this function was added to libpng 1.2.0 */
     1249    asm_flags = asm_flags; /* Quiet the compiler */
     1250}
     1251
     1252/* This function was added to libpng 1.2.0 */
    12401253void PNGAPI
    12411254png_set_mmx_thresholds (png_structp png_ptr,
     
    12461259    if (png_ptr == NULL)
    12471260       return;
     1261    /* Quiet the compiler */
     1262    mmx_bitdepth_threshold = mmx_bitdepth_threshold;
     1263    mmx_rowbytes_threshold = mmx_rowbytes_threshold;
    12481264}
    12491265#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
    12501266
    12511267#ifdef PNG_SET_USER_LIMITS_SUPPORTED
    1252 /* this function was added to libpng 1.2.6 */
     1268/* This function was added to libpng 1.2.6 */
    12531269void PNGAPI
    12541270png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max,
    12551271    png_uint_32 user_height_max)
    12561272{
    1257     /* Images with dimensions larger than these limits will be
    1258      * rejected by png_set_IHDR().  To accept any PNG datastream
    1259      * regardless of dimensions, set both limits to 0x7ffffffL.
    1260      */
    1261     if(png_ptr == NULL) return;
    1262     png_ptr->user_width_max = user_width_max;
    1263     png_ptr->user_height_max = user_height_max;
     1273   /* Images with dimensions larger than these limits will be
     1274    * rejected by png_set_IHDR().  To accept any PNG datastream
     1275    * regardless of dimensions, set both limits to 0x7ffffffL.
     1276    */
     1277   if (png_ptr == NULL)
     1278      return;
     1279   png_ptr->user_width_max = user_width_max;
     1280   png_ptr->user_height_max = user_height_max;
    12641281}
    12651282#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
  • trunk/src/3rdparty/libpng/pngtest.c

    r2 r561  
    22/* pngtest.c - a simple test program to test libpng
    33 *
    4  * Last changed in libpng 1.2.27 - [April 29, 2008]
    5  * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2008 Glenn Randers-Pehrson
     4 * Last changed in libpng 1.2.37 [June 4, 2009]
     5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
    76 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    87 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     8 *
     9 * This code is released under the libpng license.
     10 * For conditions of distribution and use, see the disclaimer
     11 * and license in png.h
    912 *
    1013 * This program reads in a PNG image, writes it out again, and then
     
    3841#  include <stdlib.h>
    3942#  define READFILE(file, data, length, check) \
    40      if (ReadFile(file, data, length, &check,NULL)) check = 0
     43     if (ReadFile(file, data, length, &check, NULL)) check = 0
    4144#  define WRITEFILE(file, data, length, check)) \
    4245     if (WriteFile(file, data, length, &check, NULL)) check = 0
     
    4649#  include <stdlib.h>
    4750#  define READFILE(file, data, length, check) \
    48      check=(png_size_t)fread(data,(png_size_t)1,length,file)
     51     check=(png_size_t)fread(data, (png_size_t)1, length, file)
    4952#  define WRITEFILE(file, data, length, check) \
    50      check=(png_size_t)fwrite(data,(png_size_t)1, length, file)
     53     check=(png_size_t)fwrite(data, (png_size_t)1, length, file)
    5154#  define FCLOSE(file) fclose(file)
    5255#endif
     
    6669
    6770#if !PNG_DEBUG
    68 #  define SINGLE_ROWBUF_ALLOC  /* makes buffer overruns easier to nail */
     71#  define SINGLE_ROWBUF_ALLOC  /* Makes buffer overruns easier to nail */
    6972#endif
    7073
     
    8386
    8487#if defined(PNG_TIME_RFC1123_SUPPORTED)
    85 #define PNG_tIME_STRING_LENGTH 30
    86 static int tIME_chunk_present=0;
    87 static char tIME_string[PNG_tIME_STRING_LENGTH] = "no tIME chunk present in file";
     88#define PNG_tIME_STRING_LENGTH 29
     89static int tIME_chunk_present = 0;
     90static char tIME_string[PNG_tIME_STRING_LENGTH] = "tIME chunk is not present";
    8891#endif
    8992
     
    9699#endif
    97100
    98 /* defined so I can write to a file on gui/windowing platforms */
     101/* Defined so I can write to a file on gui/windowing platforms */
    99102/*  #define STDERR stderr  */
    100 #define STDERR stdout   /* for DOS */
    101 
    102 /* example of using row callbacks to make a simple progress meter */
    103 static int status_pass=1;
    104 static int status_dots_requested=0;
    105 static int status_dots=1;
     103#define STDERR stdout   /* For DOS */
    106104
    107105/* In case a system header (e.g., on AIX) defined jmpbuf */
     
    114112#  define png_jmpbuf(png_ptr) png_ptr->jmpbuf
    115113#endif
     114
     115/* Example of using row callbacks to make a simple progress meter */
     116static int status_pass = 1;
     117static int status_dots_requested = 0;
     118static int status_dots = 1;
    116119
    117120void
     
    126129read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
    127130{
    128     if(png_ptr == NULL || row_number > PNG_UINT_31_MAX) return;
    129     if(status_pass != pass)
    130     {
    131        fprintf(stdout,"\n Pass %d: ",pass);
    132        status_pass = pass;
    133        status_dots = 31;
    134     }
    135     status_dots--;
    136     if(status_dots == 0)
    137     {
    138        fprintf(stdout, "\n         ");
    139        status_dots=30;
    140     }
    141     fprintf(stdout, "r");
     131   if (png_ptr == NULL || row_number > PNG_UINT_31_MAX)
     132      return;
     133   if (status_pass != pass)
     134   {
     135      fprintf(stdout, "\n Pass %d: ", pass);
     136      status_pass = pass;
     137      status_dots = 31;
     138   }
     139   status_dots--;
     140   if (status_dots == 0)
     141   {
     142      fprintf(stdout, "\n         ");
     143      status_dots=30;
     144   }
     145   fprintf(stdout, "r");
    142146}
    143147
     
    153157write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
    154158{
    155     if(png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7) return;
    156     fprintf(stdout, "w");
     159   if (png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7)
     160      return;
     161   fprintf(stdout, "w");
    157162}
    158163
     
    160165#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
    161166/* Example of using user transform callback (we don't transform anything,
    162    but merely examine the row filters.  We set this to 256 rather than
    163    5 in case illegal filter values are present.) */
     167 * but merely examine the row filters.  We set this to 256 rather than
     168 * 5 in case illegal filter values are present.)
     169 */
    164170static png_uint_32 filters_used[256];
    165171void
     
    174180count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data)
    175181{
    176     if(png_ptr != NULL && row_info != NULL)
    177       ++filters_used[*(data-1)];
     182   if (png_ptr != NULL && row_info != NULL)
     183      ++filters_used[*(data - 1)];
    178184}
    179185#endif
    180186
    181187#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
    182 /* example of using user transform callback (we don't transform anything,
    183    but merely count the zero samples) */
     188/* Example of using user transform callback (we don't transform anything,
     189 * but merely count the zero samples)
     190 */
    184191
    185192static png_uint_32 zero_samples;
     
    197204{
    198205   png_bytep dp = data;
    199    if(png_ptr == NULL)return;
    200 
    201    /* contents of row_info:
     206   if (png_ptr == NULL)return;
     207
     208   /* Contents of row_info:
    202209    *  png_uint_32 width      width of row
    203210    *  png_uint_32 rowbytes   number of bytes in row
     
    208215    */
    209216
    210 
    211     /* counts the number of zero samples (or zero pixels if color_type is 3 */
    212 
    213     if(row_info->color_type == 0 || row_info->color_type == 3)
     217    /* Counts the number of zero samples (or zero pixels if color_type is 3 */
     218
     219    if (row_info->color_type == 0 || row_info->color_type == 3)
    214220    {
    215        int pos=0;
     221       int pos = 0;
    216222       png_uint_32 n, nstop;
    217        for (n=0, nstop=row_info->width; n<nstop; n++)
     223       for (n = 0, nstop=row_info->width; n<nstop; n++)
    218224       {
    219           if(row_info->bit_depth == 1)
     225          if (row_info->bit_depth == 1)
    220226          {
    221              if(((*dp << pos++ ) & 0x80) == 0) zero_samples++;
    222              if(pos == 8)
     227             if (((*dp << pos++ ) & 0x80) == 0)
     228                zero_samples++;
     229             if (pos == 8)
    223230             {
    224231                pos = 0;
     
    226233             }
    227234          }
    228           if(row_info->bit_depth == 2)
     235          if (row_info->bit_depth == 2)
    229236          {
    230              if(((*dp << (pos+=2)) & 0xc0) == 0) zero_samples++;
    231              if(pos == 8)
     237             if (((*dp << (pos+=2)) & 0xc0) == 0)
     238                zero_samples++;
     239             if (pos == 8)
    232240             {
    233241                pos = 0;
     
    235243             }
    236244          }
    237           if(row_info->bit_depth == 4)
     245          if (row_info->bit_depth == 4)
    238246          {
    239              if(((*dp << (pos+=4)) & 0xf0) == 0) zero_samples++;
    240              if(pos == 8)
     247             if (((*dp << (pos+=4)) & 0xf0) == 0)
     248                zero_samples++;
     249             if (pos == 8)
    241250             {
    242251                pos = 0;
     
    244253             }
    245254          }
    246           if(row_info->bit_depth == 8)
    247              if(*dp++ == 0) zero_samples++;
    248           if(row_info->bit_depth == 16)
     255          if (row_info->bit_depth == 8)
     256             if (*dp++ == 0)
     257                zero_samples++;
     258          if (row_info->bit_depth == 16)
    249259          {
    250              if((*dp | *(dp+1)) == 0) zero_samples++;
     260             if ((*dp | *(dp+1)) == 0)
     261                zero_samples++;
    251262             dp+=2;
    252263          }
    253264       }
    254265    }
    255     else /* other color types */
     266    else /* Other color types */
    256267    {
    257268       png_uint_32 n, nstop;
    258269       int channel;
    259270       int color_channels = row_info->channels;
    260        if(row_info->color_type > 3)color_channels--;
    261 
    262        for (n=0, nstop=row_info->width; n<nstop; n++)
     271       if (row_info->color_type > 3)color_channels--;
     272
     273       for (n = 0, nstop=row_info->width; n<nstop; n++)
    263274       {
    264275          for (channel = 0; channel < color_channels; channel++)
    265276          {
    266              if(row_info->bit_depth == 8)
    267                 if(*dp++ == 0) zero_samples++;
    268              if(row_info->bit_depth == 16)
     277             if (row_info->bit_depth == 8)
     278                if (*dp++ == 0)
     279                   zero_samples++;
     280             if (row_info->bit_depth == 16)
    269281             {
    270                 if((*dp | *(dp+1)) == 0) zero_samples++;
     282                if ((*dp | *(dp+1)) == 0)
     283                   zero_samples++;
    271284                dp+=2;
    272285             }
    273286          }
    274           if(row_info->color_type > 3)
     287          if (row_info->color_type > 3)
    275288          {
    276289             dp++;
    277              if(row_info->bit_depth == 16)dp++;
     290             if (row_info->bit_depth == 16)
     291                dp++;
    278292          }
    279293       }
     
    286300#if defined(PNG_NO_STDIO)
    287301/* START of code to validate stdio-free compilation */
    288 /* These copies of the default read/write functions come from pngrio.c and */
    289 /* pngwio.c.  They allow "don't include stdio" testing of the library. */
    290 /* This is the function that does the actual reading of data.  If you are
    291    not reading from a standard C stream, you should create a replacement
    292    read_data function and use it at run time with png_set_read_fn(), rather
    293    than changing the library. */
     302/* These copies of the default read/write functions come from pngrio.c and
     303 * pngwio.c.  They allow "don't include stdio" testing of the library.
     304 * This is the function that does the actual reading of data.  If you are
     305 * not reading from a standard C stream, you should create a replacement
     306 * read_data function and use it at run time with png_set_read_fn(), rather
     307 * than changing the library.
     308 */
    294309
    295310#ifndef USE_FAR_KEYWORD
     
    310325}
    311326#else
    312 /* this is the model-independent version. Since the standard I/O library
     327/* This is the model-independent version. Since the standard I/O library
    313328   can't handle far buffers in the medium and small models, we have to copy
    314329   the data.
     
    342357         read = MIN(NEAR_BUF_SIZE, remaining);
    343358         READFILE(io_ptr, buf, 1, err);
    344          png_memcpy(data, buf, read); /* copy far buffer to near buffer */
    345          if(err != read)
     359         png_memcpy(data, buf, read); /* Copy far buffer to near buffer */
     360         if (err != read)
    346361            break;
    347362         else
     
    353368   }
    354369   if (check != length)
    355    {
    356370      png_error(png_ptr, "read Error");
    357    }
    358371}
    359372#endif /* USE_FAR_KEYWORD */
     
    363376pngtest_flush(png_structp png_ptr)
    364377{
    365 #if !defined(_WIN32_WCE)
    366    png_FILE_p io_ptr;
    367    io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
    368    if (io_ptr != NULL)
    369       fflush(io_ptr);
    370 #endif
     378   /* Do nothing; fflush() is said to be just a waste of energy. */
     379   png_ptr = png_ptr;  /* Stifle compiler warning */
    371380}
    372381#endif
    373382
    374383/* This is the function that does the actual writing of data.  If you are
    375    not writing to a standard C stream, you should create a replacement
    376    write_data function and use it at run time with png_set_write_fn(), rather
    377    than changing the library. */
     384 * not writing to a standard C stream, you should create a replacement
     385 * write_data function and use it at run time with png_set_write_fn(), rather
     386 * than changing the library.
     387 */
    378388#ifndef USE_FAR_KEYWORD
    379389static void
     
    389399}
    390400#else
    391 /* this is the model-independent version. Since the standard I/O library
     401/* This is the model-independent version. Since the standard I/O library
    392402   can't handle far buffers in the medium and small models, we have to copy
    393403   the data.
     
    420430      {
    421431         written = MIN(NEAR_BUF_SIZE, remaining);
    422          png_memcpy(buf, data, written); /* copy far buffer to near buffer */
     432         png_memcpy(buf, data, written); /* Copy far buffer to near buffer */
    423433         WRITEFILE(io_ptr, buf, written, err);
    424434         if (err != written)
     
    437447}
    438448#endif /* USE_FAR_KEYWORD */
    439 #endif /* PNG_NO_STDIO */
    440 /* END of code to validate stdio-free compilation */
    441449
    442450/* This function is called when there is a warning, but the library thinks
     
    464472   pngtest_warning(png_ptr, message);
    465473   /* We can return because png_error calls the default handler, which is
    466     * actually OK in this case. */
     474    * actually OK in this case.
     475    */
    467476}
     477#endif /* PNG_NO_STDIO */
     478/* END of code to validate stdio-free compilation */
    468479
    469480/* START of code to validate memory allocation and deallocation */
     
    471482
    472483/* Allocate memory.  For reasonable files, size should never exceed
    473    64K.  However, zlib may allocate more then 64K if you don't tell
    474    it not to.  See zconf.h and png.h for more information.  zlib does
    475    need to allocate exactly 64K, so whatever you call here must
    476    have the ability to do that.
    477 
    478    This piece of code can be compiled to validate max 64K allocations
    479    by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K. */
     484 * 64K.  However, zlib may allocate more then 64K if you don't tell
     485 * it not to.  See zconf.h and png.h for more information.  zlib does
     486 * need to allocate exactly 64K, so whatever you call here must
     487 * have the ability to do that.
     488 *
     489 * This piece of code can be compiled to validate max 64K allocations
     490 * by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K.
     491 */
    480492typedef struct memory_information
    481493{
     
    500512
    501513   /* png_malloc has already tested for NULL; png_create_struct calls
    502       png_debug_malloc directly, with png_ptr == NULL which is OK */
     514    * png_debug_malloc directly, with png_ptr == NULL which is OK
     515    */
    503516
    504517   if (size == 0)
     
    512525      png_set_mem_fn(png_ptr, NULL, NULL, NULL);
    513526      pinfo = (memory_infop)png_malloc(png_ptr,
    514          (png_uint_32)png_sizeof (*pinfo));
     527         (png_uint_32)png_sizeof(*pinfo));
    515528      pinfo->size = size;
    516529      current_allocation += size;
     
    521534      pinfo->pointer = (png_voidp)png_malloc(png_ptr, size);
    522535      /* Restore malloc_fn and free_fn */
    523       png_set_mem_fn(png_ptr, png_voidp_NULL, (png_malloc_ptr)png_debug_malloc,
    524          (png_free_ptr)png_debug_free);
     536      png_set_mem_fn(png_ptr,
     537          png_voidp_NULL, (png_malloc_ptr)png_debug_malloc,
     538          (png_free_ptr)png_debug_free);
    525539      if (size != 0 && pinfo->pointer == NULL)
    526540      {
     
    534548      /* Make sure the caller isn't assuming zeroed memory. */
    535549      png_memset(pinfo->pointer, 0xdd, pinfo->size);
    536       if(verbose)
    537          printf("png_malloc %lu bytes at %x\n",(unsigned long)size,
    538           pinfo->pointer);
     550      if (verbose)
     551         printf("png_malloc %lu bytes at %x\n", (unsigned long)size,
     552            pinfo->pointer);
    539553      return (png_voidp)(pinfo->pointer);
    540554   }
     
    571585            png_memset(ptr, 0x55, pinfo->size);
    572586            png_free_default(png_ptr, pinfo);
    573             pinfo=NULL;
     587            pinfo = NULL;
    574588            break;
    575589         }
     
    584598
    585599   /* Finally free the data. */
    586    if(verbose)
    587       printf("Freeing %x\n",ptr);
     600   if (verbose)
     601      printf("Freeing %x\n", ptr);
    588602   png_free_default(png_ptr, ptr);
    589    ptr=NULL;
     603   ptr = NULL;
    590604}
    591605#endif /* PNG_USER_MEM_SUPPORTED && PNG_DEBUG */
    592606/* END of code to test memory allocation/deallocation */
     607
     608
     609/* Demonstration of user chunk support of the sTER and vpAg chunks */
     610#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
     611
     612/* (sTER is a public chunk not yet known by libpng.  vpAg is a private
     613chunk used in ImageMagick to store "virtual page" size).  */
     614
     615static png_uint_32 user_chunk_data[4];
     616
     617    /* 0: sTER mode + 1
     618     * 1: vpAg width
     619     * 2: vpAg height
     620     * 3: vpAg units
     621     */
     622
     623static int read_user_chunk_callback(png_struct *png_ptr,
     624   png_unknown_chunkp chunk)
     625{
     626   png_uint_32
     627     *my_user_chunk_data;
     628
     629   /* Return one of the following:
     630    *    return (-n);  chunk had an error
     631    *    return (0);  did not recognize
     632    *    return (n);  success
     633    *
     634    * The unknown chunk structure contains the chunk data:
     635    * png_byte name[5];
     636    * png_byte *data;
     637    * png_size_t size;
     638    *
     639    * Note that libpng has already taken care of the CRC handling.
     640    */
     641
     642   if (chunk->name[0] == 115 && chunk->name[1] ==  84 &&     /* s  T */
     643       chunk->name[2] ==  69 && chunk->name[3] ==  82)       /* E  R */
     644      {
     645         /* Found sTER chunk */
     646         if (chunk->size != 1)
     647            return (-1); /* Error return */
     648         if (chunk->data[0] != 0 && chunk->data[0] != 1)
     649            return (-1);  /* Invalid mode */
     650         my_user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr);
     651         my_user_chunk_data[0]=chunk->data[0]+1;
     652         return (1);
     653      }
     654
     655   if (chunk->name[0] != 118 || chunk->name[1] != 112 ||    /* v  p */
     656       chunk->name[2] !=  65 || chunk->name[3] != 103)      /* A  g */
     657      return (0); /* Did not recognize */
     658
     659   /* Found ImageMagick vpAg chunk */
     660
     661   if (chunk->size != 9)
     662      return (-1); /* Error return */
     663
     664   my_user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr);
     665
     666   my_user_chunk_data[1]=png_get_uint_31(png_ptr, chunk->data);
     667   my_user_chunk_data[2]=png_get_uint_31(png_ptr, chunk->data + 4);
     668   my_user_chunk_data[3]=(png_uint_32)chunk->data[8];
     669
     670   return (1);
     671
     672}
     673#endif
     674/* END of code to demonstrate user chunk support */
    593675
    594676/* Test one file */
     
    650732   }
    651733
    652    png_debug(0, "Allocating read and write structures\n");
     734   png_debug(0, "Allocating read and write structures");
    653735#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
    654    read_ptr = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
     736   read_ptr =
     737      png_create_read_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
    655738      png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL,
    656739      (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free);
    657740#else
    658    read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
     741   read_ptr =
     742      png_create_read_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
    659743      png_error_ptr_NULL, png_error_ptr_NULL);
    660744#endif
     745#if defined(PNG_NO_STDIO)
    661746   png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error,
    662747       pngtest_warning);
     748#endif
     749
     750#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
     751   user_chunk_data[0] = 0;
     752   user_chunk_data[1] = 0;
     753   user_chunk_data[2] = 0;
     754   user_chunk_data[3] = 0;
     755   png_set_read_user_chunk_fn(read_ptr, user_chunk_data,
     756     read_user_chunk_callback);
     757
     758#endif
    663759#ifdef PNG_WRITE_SUPPORTED
    664760#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
    665    write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
     761   write_ptr =
     762      png_create_write_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
    666763      png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL,
    667764      (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free);
    668765#else
    669    write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
     766   write_ptr =
     767      png_create_write_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
    670768      png_error_ptr_NULL, png_error_ptr_NULL);
    671769#endif
     770#if defined(PNG_NO_STDIO)
    672771   png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error,
    673772       pngtest_warning);
    674773#endif
    675    png_debug(0, "Allocating read_info, write_info and end_info structures\n");
     774#endif
     775   png_debug(0, "Allocating read_info, write_info and end_info structures");
    676776   read_info_ptr = png_create_info_struct(read_ptr);
    677777   end_info_ptr = png_create_info_struct(read_ptr);
     
    682782
    683783#ifdef PNG_SETJMP_SUPPORTED
    684    png_debug(0, "Setting jmpbuf for read struct\n");
     784   png_debug(0, "Setting jmpbuf for read struct");
    685785#ifdef USE_FAR_KEYWORD
    686786   if (setjmp(jmpbuf))
     
    691791      fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname);
    692792      png_free(read_ptr, row_buf);
     793      row_buf = NULL;
    693794      png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
    694795#ifdef PNG_WRITE_SUPPORTED
     
    701802   }
    702803#ifdef USE_FAR_KEYWORD
    703    png_memcpy(png_jmpbuf(read_ptr),jmpbuf,png_sizeof(jmp_buf));
     804   png_memcpy(png_jmpbuf(read_ptr), jmpbuf, png_sizeof(jmp_buf));
    704805#endif
    705806
    706807#ifdef PNG_WRITE_SUPPORTED
    707    png_debug(0, "Setting jmpbuf for write struct\n");
     808   png_debug(0, "Setting jmpbuf for write struct");
    708809#ifdef USE_FAR_KEYWORD
    709810   if (setjmp(jmpbuf))
     
    723824   }
    724825#ifdef USE_FAR_KEYWORD
    725    png_memcpy(png_jmpbuf(write_ptr),jmpbuf,png_sizeof(jmp_buf));
    726 #endif
    727 #endif
    728 #endif
    729 
    730    png_debug(0, "Initializing input and output streams\n");
     826   png_memcpy(png_jmpbuf(write_ptr), jmpbuf, png_sizeof(jmp_buf));
     827#endif
     828#endif
     829#endif
     830
     831   png_debug(0, "Initializing input and output streams");
    731832#if !defined(PNG_NO_STDIO)
    732833   png_init_io(read_ptr, fpin);
     
    745846#  endif
    746847#endif
    747    if(status_dots_requested == 1)
     848   if (status_dots_requested == 1)
    748849   {
    749850#ifdef PNG_WRITE_SUPPORTED
     
    762863#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
    763864   {
    764      int i;
    765      for(i=0; i<256; i++)
    766         filters_used[i]=0;
    767      png_set_read_user_transform_fn(read_ptr, count_filters);
     865      int i;
     866      for (i = 0; i<256; i++)
     867         filters_used[i] = 0;
     868      png_set_read_user_transform_fn(read_ptr, count_filters);
    768869   }
    769870#endif
    770871#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
    771    zero_samples=0;
     872   zero_samples = 0;
    772873   png_set_write_user_transform_fn(write_ptr, count_zero_samples);
    773874#endif
     
    788889#endif
    789890
    790    png_debug(0, "Reading info struct\n");
     891   png_debug(0, "Reading info struct");
    791892   png_read_info(read_ptr, read_info_ptr);
    792893
    793    png_debug(0, "Transferring info struct\n");
     894   png_debug(0, "Transferring info struct");
    794895   {
    795896      int interlace_type, compression_type, filter_type;
     
    824925
    825926      if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma))
    826       {
    827927         png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma);
    828       }
    829928   }
    830929#endif
     
    848947
    849948      if (png_get_gAMA(read_ptr, read_info_ptr, &gamma))
    850       {
    851949         png_set_gAMA(write_ptr, write_info_ptr, gamma);
    852       }
    853    }
    854 #endif
    855 #endif /* floating point */
    856 #endif /* fixed point */
     950   }
     951#endif
     952#endif /* Floating point */
     953#endif /* Fixed point */
    857954#if defined(PNG_iCCP_SUPPORTED)
    858955   {
     
    875972
    876973      if (png_get_sRGB(read_ptr, read_info_ptr, &intent))
    877       {
    878974         png_set_sRGB(write_ptr, write_info_ptr, intent);
    879       }
    880975   }
    881976#endif
     
    885980
    886981      if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette))
    887       {
    888982         png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette);
    889       }
    890983   }
    891984#if defined(PNG_bKGD_SUPPORTED)
     
    904997
    905998      if (png_get_hIST(read_ptr, read_info_ptr, &hist))
    906       {
    907999         png_set_hIST(write_ptr, write_info_ptr, hist);
    908       }
    9091000   }
    9101001#endif
     
    9141005      int unit_type;
    9151006
    916       if (png_get_oFFs(read_ptr, read_info_ptr,&offset_x,&offset_y,&unit_type))
     1007      if (png_get_oFFs(read_ptr, read_info_ptr, &offset_x, &offset_y,
     1008          &unit_type))
    9171009      {
    9181010         png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type);
     
    9411033
    9421034      if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, &unit_type))
    943       {
    9441035         png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type);
    945       }
    9461036   }
    9471037#endif
     
    9511041
    9521042      if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit))
    953       {
    9541043         png_set_sBIT(write_ptr, write_info_ptr, sig_bit);
    955       }
    9561044   }
    9571045#endif
     
    9901078      if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0)
    9911079      {
    992          png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text);
     1080         png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks", num_text);
    9931081         png_set_text(write_ptr, write_info_ptr, text_ptr, num_text);
    9941082      }
     
    10031091         png_set_tIME(write_ptr, write_info_ptr, mod_time);
    10041092#if defined(PNG_TIME_RFC1123_SUPPORTED)
    1005          /* we have to use png_memcpy instead of "=" because the string
    1006             pointed to by png_convert_to_rfc1123() gets free'ed before
    1007             we use it */
     1093         /* We have to use png_memcpy instead of "=" because the string
     1094          * pointed to by png_convert_to_rfc1123() gets free'ed before
     1095          * we use it.
     1096          */
    10081097         png_memcpy(tIME_string,
    1009                     png_convert_to_rfc1123(read_ptr, mod_time), 
     1098                    png_convert_to_rfc1123(read_ptr, mod_time),
    10101099                    png_sizeof(tIME_string));
    1011          tIME_string[png_sizeof(tIME_string)-1] = '\0';
     1100         tIME_string[png_sizeof(tIME_string) - 1] = '\0';
    10121101         tIME_chunk_present++;
    10131102#endif /* PNG_TIME_RFC1123_SUPPORTED */
     
    10271116         /* libpng doesn't reject a tRNS chunk with out-of-range samples */
    10281117         if (!((read_info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
    1029             (int)trans_values->gray > sample_max) ||
    1030             (read_info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
    1031             ((int)trans_values->red > sample_max ||
    1032             (int)trans_values->green > sample_max ||
    1033             (int)trans_values->blue > sample_max))))
    1034            png_set_tRNS(write_ptr, write_info_ptr, trans, num_trans,
    1035               trans_values);
     1118             (int)trans_values->gray > sample_max) ||
     1119             (read_info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
     1120             ((int)trans_values->red > sample_max ||
     1121             (int)trans_values->green > sample_max ||
     1122             (int)trans_values->blue > sample_max))))
     1123            png_set_tRNS(write_ptr, write_info_ptr, trans, num_trans,
     1124               trans_values);
    10361125      }
    10371126   }
     
    10471136         png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns,
    10481137           num_unknowns);
    1049          /* copy the locations from the read_info_ptr.  The automatically
    1050             generated locations in write_info_ptr are wrong because we
    1051             haven't written anything yet */
     1138         /* Copy the locations from the read_info_ptr.  The automatically
     1139          * generated locations in write_info_ptr are wrong because we
     1140          * haven't written anything yet.
     1141          */
    10521142         for (i = 0; i < (png_size_t)num_unknowns; i++)
    10531143           png_set_unknown_chunk_location(write_ptr, write_info_ptr, i,
     
    10581148
    10591149#ifdef PNG_WRITE_SUPPORTED
    1060    png_debug(0, "\nWriting info struct\n");
     1150   png_debug(0, "Writing info struct");
    10611151
    10621152/* If we wanted, we could write info in two steps:
    1063    png_write_info_before_PLTE(write_ptr, write_info_ptr);
     1153 * png_write_info_before_PLTE(write_ptr, write_info_ptr);
    10641154 */
    10651155   png_write_info(write_ptr, write_info_ptr);
     1156
     1157#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
     1158   if (user_chunk_data[0] != 0)
     1159   {
     1160      png_byte png_sTER[5] = {115,  84,  69,  82, '\0'};
     1161
     1162      unsigned char
     1163        ster_chunk_data[1];
     1164
     1165      if (verbose)
     1166         fprintf(STDERR, "\n stereo mode = %lu\n",
     1167           (unsigned long)(user_chunk_data[0] - 1));
     1168      ster_chunk_data[0]=(unsigned char)(user_chunk_data[0] - 1);
     1169      png_write_chunk(write_ptr, png_sTER, ster_chunk_data, 1);
     1170   }
     1171   if (user_chunk_data[1] != 0 || user_chunk_data[2] != 0)
     1172   {
     1173      png_byte png_vpAg[5] = {118, 112,  65, 103, '\0'};
     1174
     1175      unsigned char
     1176        vpag_chunk_data[9];
     1177
     1178      if (verbose)
     1179         fprintf(STDERR, " vpAg = %lu x %lu, units = %lu\n",
     1180           (unsigned long)user_chunk_data[1],
     1181           (unsigned long)user_chunk_data[2],
     1182           (unsigned long)user_chunk_data[3]);
     1183      png_save_uint_32(vpag_chunk_data, user_chunk_data[1]);
     1184      png_save_uint_32(vpag_chunk_data + 4, user_chunk_data[2]);
     1185      vpag_chunk_data[8] = (unsigned char)(user_chunk_data[3] & 0xff);
     1186      png_write_chunk(write_ptr, png_vpAg, vpag_chunk_data, 9);
     1187   }
     1188
     1189#endif
    10661190#endif
    10671191
    10681192#ifdef SINGLE_ROWBUF_ALLOC
    1069    png_debug(0, "\nAllocating row buffer...");
     1193   png_debug(0, "Allocating row buffer...");
    10701194   row_buf = (png_bytep)png_malloc(read_ptr,
    10711195      png_get_rowbytes(read_ptr, read_info_ptr));
    1072    png_debug1(0, "0x%08lx\n\n", (unsigned long)row_buf);
     1196   png_debug1(0, "0x%08lx", (unsigned long)row_buf);
    10731197#endif /* SINGLE_ROWBUF_ALLOC */
    1074    png_debug(0, "Writing row data\n");
     1198   png_debug(0, "Writing row data");
    10751199
    10761200#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
     
    10811205#  endif
    10821206#else
    1083    num_pass=1;
     1207   num_pass = 1;
    10841208#endif
    10851209
     
    10911215   for (pass = 0; pass < num_pass; pass++)
    10921216   {
    1093       png_debug1(0, "Writing row data for pass %d\n",pass);
     1217      png_debug1(0, "Writing row data for pass %d", pass);
    10941218      for (y = 0; y < height; y++)
    10951219      {
    10961220#ifndef SINGLE_ROWBUF_ALLOC
    1097          png_debug2(0, "\nAllocating row buffer (pass %d, y = %ld)...", pass,y);
     1221         png_debug2(0, "Allocating row buffer (pass %d, y = %ld)...", pass, y);
    10981222         row_buf = (png_bytep)png_malloc(read_ptr,
    10991223            png_get_rowbytes(read_ptr, read_info_ptr));
    1100          png_debug2(0, "0x%08lx (%ld bytes)\n", (unsigned long)row_buf,
     1224         png_debug2(0, "0x%08lx (%ld bytes)", (unsigned long)row_buf,
    11011225            png_get_rowbytes(read_ptr, read_info_ptr));
    11021226#endif /* !SINGLE_ROWBUF_ALLOC */
     
    11181242
    11191243#ifndef SINGLE_ROWBUF_ALLOC
    1120          png_debug2(0, "Freeing row buffer (pass %d, y = %ld)\n\n", pass, y);
     1244         png_debug2(0, "Freeing row buffer (pass %d, y = %ld)", pass, y);
    11211245         png_free(read_ptr, row_buf);
     1246         row_buf = NULL;
    11221247#endif /* !SINGLE_ROWBUF_ALLOC */
    11231248      }
     
    11311256#endif
    11321257
    1133    png_debug(0, "Reading and writing end_info data\n");
     1258   png_debug(0, "Reading and writing end_info data");
    11341259
    11351260   png_read_end(read_ptr, end_info_ptr);
     
    11411266      if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0)
    11421267      {
    1143          png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text);
     1268         png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks", num_text);
    11441269         png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text);
    11451270      }
     
    11541279         png_set_tIME(write_ptr, write_end_info_ptr, mod_time);
    11551280#if defined(PNG_TIME_RFC1123_SUPPORTED)
    1156          /* we have to use png_memcpy instead of "=" because the string
     1281         /* We have to use png_memcpy instead of "=" because the string
    11571282            pointed to by png_convert_to_rfc1123() gets free'ed before
    11581283            we use it */
     
    11601285                    png_convert_to_rfc1123(read_ptr, mod_time),
    11611286                    png_sizeof(tIME_string));
    1162          tIME_string[png_sizeof(tIME_string)-1] = '\0';
     1287         tIME_string[png_sizeof(tIME_string) - 1] = '\0';
    11631288         tIME_chunk_present++;
    11641289#endif /* PNG_TIME_RFC1123_SUPPORTED */
     
    11771302         png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns,
    11781303           num_unknowns);
    1179          /* copy the locations from the read_info_ptr.  The automatically
    1180             generated locations in write_end_info_ptr are wrong because we
    1181             haven't written the end_info yet */
     1304         /* Copy the locations from the read_info_ptr.  The automatically
     1305          * generated locations in write_end_info_ptr are wrong because we
     1306          * haven't written the end_info yet.
     1307          */
    11821308         for (i = 0; i < (png_size_t)num_unknowns; i++)
    11831309           png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i,
     
    11911317
    11921318#ifdef PNG_EASY_ACCESS_SUPPORTED
    1193    if(verbose)
     1319   if (verbose)
    11941320   {
    11951321      png_uint_32 iwidth, iheight;
    11961322      iwidth = png_get_image_width(write_ptr, write_info_ptr);
    11971323      iheight = png_get_image_height(write_ptr, write_info_ptr);
    1198       fprintf(STDERR, "Image width = %lu, height = %lu\n",
     1324      fprintf(STDERR, "\n Image width = %lu, height = %lu\n",
    11991325         (unsigned long)iwidth, (unsigned long)iheight);
    12001326   }
    12011327#endif
    12021328
    1203    png_debug(0, "Destroying data structs\n");
     1329   png_debug(0, "Destroying data structs");
    12041330#ifdef SINGLE_ROWBUF_ALLOC
    1205    png_debug(1, "destroying row_buf for read_ptr\n");
     1331   png_debug(1, "destroying row_buf for read_ptr");
    12061332   png_free(read_ptr, row_buf);
    1207    row_buf=NULL;
     1333   row_buf = NULL;
    12081334#endif /* SINGLE_ROWBUF_ALLOC */
    1209    png_debug(1, "destroying read_ptr, read_info_ptr, end_info_ptr\n");
     1335   png_debug(1, "destroying read_ptr, read_info_ptr, end_info_ptr");
    12101336   png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
    12111337#ifdef PNG_WRITE_SUPPORTED
    1212    png_debug(1, "destroying write_end_info_ptr\n");
     1338   png_debug(1, "destroying write_end_info_ptr");
    12131339   png_destroy_info_struct(write_ptr, &write_end_info_ptr);
    1214    png_debug(1, "destroying write_ptr, write_info_ptr\n");
     1340   png_debug(1, "destroying write_ptr, write_info_ptr");
    12151341   png_destroy_write_struct(&write_ptr, &write_info_ptr);
    12161342#endif
    1217    png_debug(0, "Destruction complete.\n");
     1343   png_debug(0, "Destruction complete.");
    12181344
    12191345   FCLOSE(fpin);
    12201346   FCLOSE(fpout);
    12211347
    1222    png_debug(0, "Opening files for comparison\n");
     1348   png_debug(0, "Opening files for comparison");
    12231349#if defined(_WIN32_WCE)
    12241350   MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH);
     
    12441370   }
    12451371
    1246    for(;;)
     1372   for (;;)
    12471373   {
    12481374      png_size_t num_in, num_out;
    12491375
    1250       READFILE(fpin, inbuf, 1, num_in);
    1251       READFILE(fpout, outbuf, 1, num_out);
     1376         READFILE(fpin, inbuf, 1, num_in);
     1377         READFILE(fpout, outbuf, 1, num_out);
    12521378
    12531379      if (num_in != num_out)
     
    12551381         fprintf(STDERR, "\nFiles %s and %s are of a different size\n",
    12561382                 inname, outname);
    1257          if(wrote_question == 0)
     1383         if (wrote_question == 0)
    12581384         {
    12591385            fprintf(STDERR,
    12601386         "   Was %s written with the same maximum IDAT chunk size (%d bytes),",
    1261               inname,PNG_ZBUF_SIZE);
     1387              inname, PNG_ZBUF_SIZE);
    12621388            fprintf(STDERR,
    12631389              "\n   filtering heuristic (libpng default), compression");
     
    12651391              " level (zlib default),\n   and zlib version (%s)?\n\n",
    12661392              ZLIB_VERSION);
    1267             wrote_question=1;
     1393            wrote_question = 1;
    12681394         }
    12691395         FCLOSE(fpin);
     
    12781404      {
    12791405         fprintf(STDERR, "\nFiles %s and %s are different\n", inname, outname);
    1280          if(wrote_question == 0)
     1406         if (wrote_question == 0)
    12811407         {
    12821408            fprintf(STDERR,
    12831409         "   Was %s written with the same maximum IDAT chunk size (%d bytes),",
    1284                  inname,PNG_ZBUF_SIZE);
     1410                 inname, PNG_ZBUF_SIZE);
    12851411            fprintf(STDERR,
    12861412              "\n   filtering heuristic (libpng default), compression");
     
    12881414              " level (zlib default),\n   and zlib version (%s)?\n\n",
    12891415              ZLIB_VERSION);
    1290             wrote_question=1;
     1416            wrote_question = 1;
    12911417         }
    12921418         FCLOSE(fpin);
     
    13021428}
    13031429
    1304 /* input and output filenames */
     1430/* Input and output filenames */
    13051431#ifdef RISCOS
    13061432static PNG_CONST char *inname = "pngtest/png";
     
    13171443   int ierror = 0;
    13181444
    1319    fprintf(STDERR, "Testing libpng version %s\n", PNG_LIBPNG_VER_STRING);
     1445   fprintf(STDERR, "\n Testing libpng version %s\n", PNG_LIBPNG_VER_STRING);
    13201446   fprintf(STDERR, "   with zlib   version %s\n", ZLIB_VERSION);
    1321    fprintf(STDERR,"%s",png_get_copyright(NULL));
     1447   fprintf(STDERR, "%s", png_get_copyright(NULL));
    13221448   /* Show the version of libpng used in building the library */
    1323    fprintf(STDERR," library (%lu):%s",
     1449   fprintf(STDERR, " library (%lu):%s",
    13241450      (unsigned long)png_access_version_number(),
    13251451      png_get_header_version(NULL));
    13261452   /* Show the version of libpng used in building the application */
    1327    fprintf(STDERR," pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER,
     1453   fprintf(STDERR, " pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER,
    13281454      PNG_HEADER_VERSION_STRING);
    1329    fprintf(STDERR," png_sizeof(png_struct)=%ld, png_sizeof(png_info)=%ld\n",
     1455   fprintf(STDERR, " sizeof(png_struct)=%ld, sizeof(png_info)=%ld\n",
    13301456                    (long)png_sizeof(png_struct), (long)png_sizeof(png_info));
    13311457
    13321458   /* Do some consistency checking on the memory allocation settings, I'm
    1333       not sure this matters, but it is nice to know, the first of these
    1334       tests should be impossible because of the way the macros are set
    1335       in pngconf.h */
     1459    * not sure this matters, but it is nice to know, the first of these
     1460    * tests should be impossible because of the way the macros are set
     1461    * in pngconf.h
     1462    */
    13361463#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
    13371464      fprintf(STDERR, " NOTE: Zlib compiled for max 64k, libpng not\n");
     
    13781505   }
    13791506
    1380    if (!multiple && argc == 3+verbose)
    1381      outname = argv[2+verbose];
    1382 
    1383    if ((!multiple && argc > 3+verbose) || (multiple && argc < 2))
     1507   if (!multiple && argc == 3 + verbose)
     1508     outname = argv[2 + verbose];
     1509
     1510   if ((!multiple && argc > 3 + verbose) || (multiple && argc < 2))
    13841511   {
    13851512     fprintf(STDERR,
     
    14051532#endif
    14061533         int kerror;
    1407          fprintf(STDERR, "Testing %s:",argv[i]);
     1534         fprintf(STDERR, "\n Testing %s:", argv[i]);
    14081535         kerror = test_one_file(argv[i], outname);
    14091536         if (kerror == 0)
     
    14161543#endif
    14171544#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
    1418             for (k=0; k<256; k++)
    1419                if(filters_used[k])
     1545            for (k = 0; k<256; k++)
     1546               if (filters_used[k])
    14201547                  fprintf(STDERR, " Filter %d was used %lu times\n",
    1421                      k,(unsigned long)filters_used[k]);
     1548                     k, (unsigned long)filters_used[k]);
    14221549#endif
    14231550#if defined(PNG_TIME_RFC1123_SUPPORTED)
    1424          if(tIME_chunk_present != 0)
    1425             fprintf(STDERR, " tIME = %s\n",tIME_string);
     1551         if (tIME_chunk_present != 0)
     1552            fprintf(STDERR, " tIME = %s\n", tIME_string);
    14261553         tIME_chunk_present = 0;
    14271554#endif /* PNG_TIME_RFC1123_SUPPORTED */
     
    14351562         if (allocation_now != current_allocation)
    14361563            fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
    1437                current_allocation-allocation_now);
     1564               current_allocation - allocation_now);
    14381565         if (current_allocation != 0)
    14391566         {
     
    14441571            while (pinfo != NULL)
    14451572            {
    1446                fprintf(STDERR, " %lu bytes at %x\n", (unsigned long)pinfo->size,
     1573               fprintf(STDERR, " %lu bytes at %x\n",
     1574                 (unsigned long)pinfo->size,
    14471575                 (unsigned int) pinfo->pointer);
    14481576               pinfo = pinfo->next;
     
    14651593   {
    14661594      int i;
    1467       for (i=0; i<3; ++i)
     1595      for (i = 0; i<3; ++i)
    14681596      {
    14691597         int kerror;
     
    14721600#endif
    14731601         if (i == 1) status_dots_requested = 1;
    1474          else if(verbose == 0)status_dots_requested = 0;
     1602         else if (verbose == 0)status_dots_requested = 0;
    14751603         if (i == 0 || verbose == 1 || ierror != 0)
    1476             fprintf(STDERR, "Testing %s:",inname);
     1604            fprintf(STDERR, "\n Testing %s:", inname);
    14771605         kerror = test_one_file(inname, outname);
    1478          if(kerror == 0)
     1606         if (kerror == 0)
    14791607         {
    1480             if(verbose == 1 || i == 2)
     1608            if (verbose == 1 || i == 2)
    14811609            {
    14821610#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
     
    14901618#endif
    14911619#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
    1492                 for (k=0; k<256; k++)
    1493                    if(filters_used[k])
     1620                for (k = 0; k<256; k++)
     1621                   if (filters_used[k])
    14941622                      fprintf(STDERR, " Filter %d was used %lu times\n",
    1495                          k,(unsigned long)filters_used[k]);
     1623                         k,
     1624                         (unsigned long)filters_used[k]);
    14961625#endif
    14971626#if defined(PNG_TIME_RFC1123_SUPPORTED)
    1498              if(tIME_chunk_present != 0)
    1499                 fprintf(STDERR, " tIME = %s\n",tIME_string);
     1627             if (tIME_chunk_present != 0)
     1628                fprintf(STDERR, " tIME = %s\n", tIME_string);
    15001629#endif /* PNG_TIME_RFC1123_SUPPORTED */
    15011630            }
     
    15031632         else
    15041633         {
    1505             if(verbose == 0 && i != 2)
    1506                fprintf(STDERR, "Testing %s:",inname);
     1634            if (verbose == 0 && i != 2)
     1635               fprintf(STDERR, "\n Testing %s:", inname);
    15071636            fprintf(STDERR, " FAIL\n");
    15081637            ierror += kerror;
     
    15111640         if (allocation_now != current_allocation)
    15121641             fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
    1513                current_allocation-allocation_now);
     1642               current_allocation - allocation_now);
    15141643         if (current_allocation != 0)
    15151644         {
     
    15201649             while (pinfo != NULL)
    15211650             {
    1522                 fprintf(STDERR," %lu bytes at %x\n",
     1651                fprintf(STDERR, " %lu bytes at %x\n",
    15231652                   (unsigned long)pinfo->size, (unsigned int)pinfo->pointer);
    15241653                pinfo = pinfo->next;
     
    15431672   t_misc += (t_stop - t_start);
    15441673   t_start = t_stop;
    1545    fprintf(STDERR," CPU time used = %.3f seconds",
     1674   fprintf(STDERR, " CPU time used = %.3f seconds",
    15461675      (t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC);
    1547    fprintf(STDERR," (decoding %.3f,\n",
     1676   fprintf(STDERR, " (decoding %.3f,\n",
    15481677      t_decode/(float)CLOCKS_PER_SEC);
    1549    fprintf(STDERR,"        encoding %.3f ,",
     1678   fprintf(STDERR, "        encoding %.3f ,",
    15501679      t_encode/(float)CLOCKS_PER_SEC);
    1551    fprintf(STDERR," other %.3f seconds)\n\n",
     1680   fprintf(STDERR, " other %.3f seconds)\n\n",
    15521681      t_misc/(float)CLOCKS_PER_SEC);
    15531682#endif
    15541683
    15551684   if (ierror == 0)
    1556       fprintf(STDERR, "libpng passes test\n");
     1685      fprintf(STDERR, " libpng passes test\n");
    15571686   else
    1558       fprintf(STDERR, "libpng FAILS test\n");
     1687      fprintf(STDERR, " libpng FAILS test\n");
    15591688   return (int)(ierror != 0);
    15601689}
    15611690
    15621691/* Generate a compiler error if there is an old png.h in the search path. */
    1563 typedef version_1_2_29 your_png_h_is_not_version_1_2_29;
     1692typedef version_1_2_40 your_png_h_is_not_version_1_2_40;
  • trunk/src/3rdparty/libpng/pngtrans.c

    r2 r561  
    22/* pngtrans.c - transforms the data in a row (used by both readers and writers)
    33 *
    4  * Last changed in libpng 1.2.17 May 15, 2007
    5  * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2007 Glenn Randers-Pehrson
     4 * Last changed in libpng 1.2.36 [May 14, 2009]
     5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
    76 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    87 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     8 *
     9 * This code is released under the libpng license.
     10 * For conditions of distribution and use, see the disclaimer
     11 * and license in png.h
    912 */
    1013
    1114#define PNG_INTERNAL
    1215#include "png.h"
    13 
    1416#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
     17
    1518#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
    16 /* turn on BGR-to-RGB mapping */
     19/* Turn on BGR-to-RGB mapping */
    1720void PNGAPI
    1821png_set_bgr(png_structp png_ptr)
    1922{
    20    png_debug(1, "in png_set_bgr\n");
    21    if(png_ptr == NULL) return;
     23   png_debug(1, "in png_set_bgr");
     24   if (png_ptr == NULL)
     25      return;
    2226   png_ptr->transformations |= PNG_BGR;
    2327}
     
    2529
    2630#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
    27 /* turn on 16 bit byte swapping */
     31/* Turn on 16 bit byte swapping */
    2832void PNGAPI
    2933png_set_swap(png_structp png_ptr)
    3034{
    31    png_debug(1, "in png_set_swap\n");
    32    if(png_ptr == NULL) return;
     35   png_debug(1, "in png_set_swap");
     36   if (png_ptr == NULL)
     37      return;
    3338   if (png_ptr->bit_depth == 16)
    3439      png_ptr->transformations |= PNG_SWAP_BYTES;
     
    3742
    3843#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
    39 /* turn on pixel packing */
     44/* Turn on pixel packing */
    4045void PNGAPI
    4146png_set_packing(png_structp png_ptr)
    4247{
    43    png_debug(1, "in png_set_packing\n");
    44    if(png_ptr == NULL) return;
     48   png_debug(1, "in png_set_packing");
     49   if (png_ptr == NULL)
     50      return;
    4551   if (png_ptr->bit_depth < 8)
    4652   {
     
    5258
    5359#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
    54 /* turn on packed pixel swapping */
     60/* Turn on packed pixel swapping */
    5561void PNGAPI
    5662png_set_packswap(png_structp png_ptr)
    5763{
    58    png_debug(1, "in png_set_packswap\n");
    59    if(png_ptr == NULL) return;
     64   png_debug(1, "in png_set_packswap");
     65   if (png_ptr == NULL)
     66      return;
    6067   if (png_ptr->bit_depth < 8)
    6168      png_ptr->transformations |= PNG_PACKSWAP;
     
    6774png_set_shift(png_structp png_ptr, png_color_8p true_bits)
    6875{
    69    png_debug(1, "in png_set_shift\n");
    70    if(png_ptr == NULL) return;
     76   png_debug(1, "in png_set_shift");
     77   if (png_ptr == NULL)
     78      return;
    7179   png_ptr->transformations |= PNG_SHIFT;
    7280   png_ptr->shift = *true_bits;
     
    7987png_set_interlace_handling(png_structp png_ptr)
    8088{
    81    png_debug(1, "in png_set_interlace handling\n");
     89   png_debug(1, "in png_set_interlace handling");
    8290   if (png_ptr && png_ptr->interlaced)
    8391   {
     
    99107png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
    100108{
    101    png_debug(1, "in png_set_filler\n");
    102    if(png_ptr == NULL) return;
     109   png_debug(1, "in png_set_filler");
     110   if (png_ptr == NULL)
     111      return;
    103112   png_ptr->transformations |= PNG_FILLER;
    104113   png_ptr->filler = (png_byte)filler;
     
    132141png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
    133142{
    134    png_debug(1, "in png_set_add_alpha\n");
    135    if(png_ptr == NULL) return;
     143   png_debug(1, "in png_set_add_alpha");
     144   if (png_ptr == NULL)
     145      return;
    136146   png_set_filler(png_ptr, filler, filler_loc);
    137147   png_ptr->transformations |= PNG_ADD_ALPHA;
     
    146156png_set_swap_alpha(png_structp png_ptr)
    147157{
    148    png_debug(1, "in png_set_swap_alpha\n");
    149    if(png_ptr == NULL) return;
     158   png_debug(1, "in png_set_swap_alpha");
     159   if (png_ptr == NULL)
     160      return;
    150161   png_ptr->transformations |= PNG_SWAP_ALPHA;
    151162}
     
    157168png_set_invert_alpha(png_structp png_ptr)
    158169{
    159    png_debug(1, "in png_set_invert_alpha\n");
    160    if(png_ptr == NULL) return;
     170   png_debug(1, "in png_set_invert_alpha");
     171   if (png_ptr == NULL)
     172      return;
    161173   png_ptr->transformations |= PNG_INVERT_ALPHA;
    162174}
     
    167179png_set_invert_mono(png_structp png_ptr)
    168180{
    169    png_debug(1, "in png_set_invert_mono\n");
    170    if(png_ptr == NULL) return;
     181   png_debug(1, "in png_set_invert_mono");
     182   if (png_ptr == NULL)
     183      return;
    171184   png_ptr->transformations |= PNG_INVERT_MONO;
    172185}
    173186
    174 /* invert monochrome grayscale data */
     187/* Invert monochrome grayscale data */
    175188void /* PRIVATE */
    176189png_do_invert(png_row_infop row_info, png_bytep row)
    177190{
    178    png_debug(1, "in png_do_invert\n");
     191   png_debug(1, "in png_do_invert");
    179192  /* This test removed from libpng version 1.0.13 and 1.2.0:
    180193   *   if (row_info->bit_depth == 1 &&
     
    227240
    228241#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
    229 /* swaps byte order on 16 bit depth images */
     242/* Swaps byte order on 16 bit depth images */
    230243void /* PRIVATE */
    231244png_do_swap(png_row_infop row_info, png_bytep row)
    232245{
    233    png_debug(1, "in png_do_swap\n");
     246   png_debug(1, "in png_do_swap");
    234247   if (
    235248#if defined(PNG_USELESS_TESTS_SUPPORTED)
     
    358371};
    359372
    360 /* swaps pixel packing order within bytes */
     373/* Swaps pixel packing order within bytes */
    361374void /* PRIVATE */
    362375png_do_packswap(png_row_infop row_info, png_bytep row)
    363376{
    364    png_debug(1, "in png_do_packswap\n");
     377   png_debug(1, "in png_do_packswap");
    365378   if (
    366379#if defined(PNG_USELESS_TESTS_SUPPORTED)
     
    390403#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
    391404    defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
    392 /* remove filler or alpha byte(s) */
     405/* Remove filler or alpha byte(s) */
    393406void /* PRIVATE */
    394407png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
    395408{
    396    png_debug(1, "in png_do_strip_filler\n");
     409   png_debug(1, "in png_do_strip_filler");
    397410#if defined(PNG_USELESS_TESTS_SUPPORTED)
    398411   if (row != NULL && row_info != NULL)
     
    405418
    406419      if ((row_info->color_type == PNG_COLOR_TYPE_RGB ||
    407          (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&
    408          (flags & PNG_FLAG_STRIP_ALPHA))) &&
    409          row_info->channels == 4)
     420          (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&
     421          (flags & PNG_FLAG_STRIP_ALPHA))) &&
     422          row_info->channels == 4)
    410423      {
    411424         if (row_info->bit_depth == 8)
     
    548561
    549562#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
    550 /* swaps red and blue bytes within a pixel */
     563/* Swaps red and blue bytes within a pixel */
    551564void /* PRIVATE */
    552565png_do_bgr(png_row_infop row_info, png_bytep row)
    553566{
    554    png_debug(1, "in png_do_bgr\n");
     567   png_debug(1, "in png_do_bgr");
    555568   if (
    556569#if defined(PNG_USELESS_TESTS_SUPPORTED)
     
    625638
    626639#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
    627     defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
    628     defined(PNG_LEGACY_SUPPORTED)
     640    defined(PNG_LEGACY_SUPPORTED) || \
     641    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
    629642void PNGAPI
    630643png_set_user_transform_info(png_structp png_ptr, png_voidp
    631644   user_transform_ptr, int user_transform_depth, int user_transform_channels)
    632645{
    633    png_debug(1, "in png_set_user_transform_info\n");
    634    if(png_ptr == NULL) return;
     646   png_debug(1, "in png_set_user_transform_info");
     647   if (png_ptr == NULL)
     648      return;
    635649#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
    636650   png_ptr->user_transform_ptr = user_transform_ptr;
     
    638652   png_ptr->user_transform_channels = (png_byte)user_transform_channels;
    639653#else
    640    if(user_transform_ptr || user_transform_depth || user_transform_channels)
     654   if (user_transform_ptr || user_transform_depth || user_transform_channels)
    641655      png_warning(png_ptr,
    642656        "This version of libpng does not support user transform info");
     
    653667png_get_user_transform_ptr(png_structp png_ptr)
    654668{
     669   if (png_ptr == NULL)
     670      return (NULL);
    655671#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
    656    if (png_ptr == NULL) return (NULL);
    657672   return ((png_voidp)png_ptr->user_transform_ptr);
    658673#else
  • trunk/src/3rdparty/libpng/pngwio.c

    r2 r561  
    22/* pngwio.c - functions for data output
    33 *
    4  * Last changed in libpng 1.2.13 November 13, 2006
    5  * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2006 Glenn Randers-Pehrson
     4 * Last changed in libpng 1.2.37 [June 4, 2009]
     5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
    76 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    87 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     8 *
     9 * This code is released under the libpng license.
     10 * For conditions of distribution and use, see the disclaimer
     11 * and license in png.h
    912 *
    1013 * This file provides a location for all output.  Users who need
     
    2124
    2225/* Write the data to whatever output you are using.  The default routine
    23    writes to a file pointer.  Note that this routine sometimes gets called
    24    with very small lengths, so you should implement some kind of simple
    25    buffering if you are using unbuffered writes.  This should never be asked
    26    to write more than 64K on a 16 bit machine.  */
     26 * writes to a file pointer.  Note that this routine sometimes gets called
     27 * with very small lengths, so you should implement some kind of simple
     28 * buffering if you are using unbuffered writes.  This should never be asked
     29 * to write more than 64K on a 16 bit machine.
     30 */
    2731
    2832void /* PRIVATE */
     
    3741#if !defined(PNG_NO_STDIO)
    3842/* This is the function that does the actual writing of data.  If you are
    39    not writing to a standard C stream, you should create a replacement
    40    write_data function and use it at run time with png_set_write_fn(), rather
    41    than changing the library. */
     43 * not writing to a standard C stream, you should create a replacement
     44 * write_data function and use it at run time with png_set_write_fn(), rather
     45 * than changing the library.
     46 */
    4247#ifndef USE_FAR_KEYWORD
    4348void PNGAPI
     
    4651   png_uint_32 check;
    4752
    48    if(png_ptr == NULL) return;
     53   if (png_ptr == NULL)
     54      return;
    4955#if defined(_WIN32_WCE)
    5056   if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
     
    5763}
    5864#else
    59 /* this is the model-independent version. Since the standard I/O library
    60    can't handle far buffers in the medium and small models, we have to copy
    61    the data.
    62 */
     65/* This is the model-independent version. Since the standard I/O library
     66 * can't handle far buffers in the medium and small models, we have to copy
     67 * the data.
     68 */
    6369
    6470#define NEAR_BUF_SIZE 1024
     
    7278   png_FILE_p io_ptr;
    7379
    74    if(png_ptr == NULL) return;
     80   if (png_ptr == NULL)
     81      return;
    7582   /* Check if data really is near. If so, use usual code. */
    7683   near_data = (png_byte *)CVT_PTR_NOCHECK(data);
     
    94101      {
    95102         written = MIN(NEAR_BUF_SIZE, remaining);
    96          png_memcpy(buf, data, written); /* copy far buffer to near buffer */
     103         png_memcpy(buf, data, written); /* Copy far buffer to near buffer */
    97104#if defined(_WIN32_WCE)
    98105         if ( !WriteFile(io_ptr, buf, written, &err, NULL) )
     
    103110         if (err != written)
    104111            break;
     112
    105113         else
    106114            check += err;
     115
    107116         data += written;
    108117         remaining -= written;
     
    118127
    119128/* This function is called to output any data pending writing (normally
    120    to disk).  After png_flush is called, there should be no data pending
    121    writing in any buffers. */
     129 * to disk).  After png_flush is called, there should be no data pending
     130 * writing in any buffers.
     131 */
    122132#if defined(PNG_WRITE_FLUSH_SUPPORTED)
    123133void /* PRIVATE */
     
    135145   png_FILE_p io_ptr;
    136146#endif
    137    if(png_ptr == NULL) return;
     147   if (png_ptr == NULL)
     148      return;
    138149#if !defined(_WIN32_WCE)
    139150   io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
    140    if (io_ptr != NULL)
    141       fflush(io_ptr);
     151   fflush(io_ptr);
    142152#endif
    143153}
     
    146156
    147157/* This function allows the application to supply new output functions for
    148    libpng if standard C streams aren't being used.
    149 
    150    This function takes as its arguments:
    151    png_ptr       - pointer to a png output data structure
    152    io_ptr        - pointer to user supplied structure containing info about
    153                    the output functions.  May be NULL.
    154    write_data_fn - pointer to a new output function that takes as its
    155                    arguments a pointer to a png_struct, a pointer to
    156                    data to be written, and a 32-bit unsigned int that is
    157                    the number of bytes to be written.  The new write
    158                    function should call png_error(png_ptr, "Error msg")
    159                    to exit and output any fatal error messages.
    160    flush_data_fn - pointer to a new flush function that takes as its
    161                    arguments a pointer to a png_struct.  After a call to
    162                    the flush function, there should be no data in any buffers
    163                    or pending transmission.  If the output method doesn't do
    164                    any buffering of ouput, a function prototype must still be
    165                    supplied although it doesn't have to do anything.  If
    166                    PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile
    167                    time, output_flush_fn will be ignored, although it must be
    168                    supplied for compatibility. */
     158 * libpng if standard C streams aren't being used.
     159 *
     160 * This function takes as its arguments:
     161 * png_ptr       - pointer to a png output data structure
     162 * io_ptr        - pointer to user supplied structure containing info about
     163 *                 the output functions.  May be NULL.
     164 * write_data_fn - pointer to a new output function that takes as its
     165 *                 arguments a pointer to a png_struct, a pointer to
     166 *                 data to be written, and a 32-bit unsigned int that is
     167 *                 the number of bytes to be written.  The new write
     168 *                 function should call png_error(png_ptr, "Error msg")
     169 *                 to exit and output any fatal error messages.  May be
     170 *                 NULL, in which case libpng's default function will
     171 *                 be used.
     172 * flush_data_fn - pointer to a new flush function that takes as its
     173 *                 arguments a pointer to a png_struct.  After a call to
     174 *                 the flush function, there should be no data in any buffers
     175 *                 or pending transmission.  If the output method doesn't do
     176 *                 any buffering of ouput, a function prototype must still be
     177 *                 supplied although it doesn't have to do anything.  If
     178 *                 PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile
     179 *                 time, output_flush_fn will be ignored, although it must be
     180 *                 supplied for compatibility.  May be NULL, in which case
     181 *                 libpng's default function will be used, if
     182 *                 PNG_WRITE_FLUSH_SUPPORTED is defined.  This is not
     183 *                 a good idea if io_ptr does not point to a standard
     184 *                 *FILE structure.
     185 */
    169186void PNGAPI
    170187png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
    171188   png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
    172189{
    173    if(png_ptr == NULL) return;
     190   if (png_ptr == NULL)
     191      return;
     192
    174193   png_ptr->io_ptr = io_ptr;
    175194
     
    177196   if (write_data_fn != NULL)
    178197      png_ptr->write_data_fn = write_data_fn;
     198
    179199   else
    180200      png_ptr->write_data_fn = png_default_write_data;
     
    187207   if (output_flush_fn != NULL)
    188208      png_ptr->output_flush_fn = output_flush_fn;
     209
    189210   else
    190211      png_ptr->output_flush_fn = png_default_flush;
     
    207228#if defined(USE_FAR_KEYWORD)
    208229#if defined(_MSC_VER)
    209 void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check)
     230void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
    210231{
    211232   void *near_ptr;
     
    213234   FP_OFF(near_ptr) = FP_OFF(ptr);
    214235   far_ptr = (void FAR *)near_ptr;
    215    if(check != 0)
    216       if(FP_SEG(ptr) != FP_SEG(far_ptr))
    217          png_error(png_ptr,"segment lost in conversion");
     236
     237   if (check != 0)
     238      if (FP_SEG(ptr) != FP_SEG(far_ptr))
     239         png_error(png_ptr, "segment lost in conversion");
     240
    218241   return(near_ptr);
    219242}
    220243#  else
    221 void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check)
     244void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
    222245{
    223246   void *near_ptr;
     
    225248   near_ptr = (void FAR *)ptr;
    226249   far_ptr = (void FAR *)near_ptr;
    227    if(check != 0)
    228       if(far_ptr != ptr)
    229          png_error(png_ptr,"segment lost in conversion");
     250
     251   if (check != 0)
     252      if (far_ptr != ptr)
     253         png_error(png_ptr, "segment lost in conversion");
     254
    230255   return(near_ptr);
    231256}
  • trunk/src/3rdparty/libpng/pngwrite.c

    r2 r561  
    22/* pngwrite.c - general routines to write a PNG file
    33 *
    4  * Last changed in libpng 1.2.27 [April 29, 2008]
    5  * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2008 Glenn Randers-Pehrson
     4 * Last changed in libpng 1.2.37 [June 4, 2009]
     5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
    76 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    87 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     8 *
     9 * This code is released under the libpng license.
     10 * For conditions of distribution and use, see the disclaimer
     11 * and license in png.h
    912 */
    1013
    11 /* get internal access to png.h */
     14/* Get internal access to png.h */
    1215#define PNG_INTERNAL
    1316#include "png.h"
     
    2629png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
    2730{
    28    png_debug(1, "in png_write_info_before_PLTE\n");
     31   png_debug(1, "in png_write_info_before_PLTE");
    2932   if (png_ptr == NULL || info_ptr == NULL)
    3033      return;
    3134   if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
    3235   {
    33    png_write_sig(png_ptr); /* write PNG signature */
     36   png_write_sig(png_ptr); /* Write PNG signature */
    3437#if defined(PNG_MNG_FEATURES_SUPPORTED)
    35    if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&(png_ptr->mng_features_permitted))
    36    {
    37       png_warning(png_ptr,"MNG features are not allowed in a PNG datastream");
     38   if ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&(png_ptr->mng_features_permitted))
     39   {
     40      png_warning(png_ptr, "MNG features are not allowed in a PNG datastream");
    3841      png_ptr->mng_features_permitted=0;
    3942   }
    4043#endif
    41    /* write IHDR information. */
     44   /* Write IHDR information. */
    4245   png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height,
    4346      info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type,
     
    4851      0);
    4952#endif
    50    /* the rest of these check to see if the valid field has the appropriate
    51       flag set, and if it does, writes the chunk. */
     53   /* The rest of these check to see if the valid field has the appropriate
     54    * flag set, and if it does, writes the chunk.
     55    */
    5256#if defined(PNG_WRITE_gAMA_SUPPORTED)
    5357   if (info_ptr->valid & PNG_INFO_gAMA)
     
    98102   if (info_ptr->unknown_chunks_num)
    99103   {
    100        png_unknown_chunk *up;
    101 
    102        png_debug(5, "writing extra chunks\n");
    103 
    104        for (up = info_ptr->unknown_chunks;
    105             up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
    106             up++)
    107        {
     104      png_unknown_chunk *up;
     105
     106      png_debug(5, "writing extra chunks");
     107
     108      for (up = info_ptr->unknown_chunks;
     109           up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
     110           up++)
     111      {
    108112         int keep=png_handle_as_unknown(png_ptr, up->name);
    109113         if (keep != PNG_HANDLE_CHUNK_NEVER &&
     
    117121            png_write_chunk(png_ptr, up->name, up->data, up->size);
    118122         }
    119        }
     123      }
    120124   }
    121125#endif
     
    131135#endif
    132136
    133    png_debug(1, "in png_write_info\n");
     137   png_debug(1, "in png_write_info");
    134138
    135139   if (png_ptr == NULL || info_ptr == NULL)
     
    146150#if defined(PNG_WRITE_tRNS_SUPPORTED)
    147151   if (info_ptr->valid & PNG_INFO_tRNS)
    148       {
     152   {
    149153#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
    150          /* invert the alpha channel (in tRNS) */
    151          if ((png_ptr->transformations & PNG_INVERT_ALPHA) &&
    152             info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
    153          {
    154             int j;
    155             for (j=0; j<(int)info_ptr->num_trans; j++)
    156                info_ptr->trans[j] = (png_byte)(255 - info_ptr->trans[j]);
    157          }
     154      /* Invert the alpha channel (in tRNS) */
     155      if ((png_ptr->transformations & PNG_INVERT_ALPHA) &&
     156         info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
     157      {
     158         int j;
     159         for (j=0; j<(int)info_ptr->num_trans; j++)
     160            info_ptr->trans[j] = (png_byte)(255 - info_ptr->trans[j]);
     161      }
    158162#endif
    159163      png_write_tRNS(png_ptr, info_ptr->trans, &(info_ptr->trans_values),
    160164         info_ptr->num_trans, info_ptr->color_type);
    161       }
     165   }
    162166#endif
    163167#if defined(PNG_WRITE_bKGD_SUPPORTED)
     
    180184         info_ptr->pcal_units, info_ptr->pcal_params);
    181185#endif
     186
     187#if defined(PNG_sCAL_SUPPORTED)
     188   if (info_ptr->valid & PNG_INFO_sCAL)
    182189#if defined(PNG_WRITE_sCAL_SUPPORTED)
    183    if (info_ptr->valid & PNG_INFO_sCAL)
    184190#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO)
    185191      png_write_sCAL(png_ptr, (int)info_ptr->scal_unit,
    186192          info_ptr->scal_pixel_width, info_ptr->scal_pixel_height);
    187 #else
     193#else /* !FLOATING_POINT */
    188194#ifdef PNG_FIXED_POINT_SUPPORTED
    189195      png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit,
    190196          info_ptr->scal_s_width, info_ptr->scal_s_height);
    191 #else
     197#endif /* FIXED_POINT */
     198#endif /* FLOATING_POINT */
     199#else  /* !WRITE_sCAL */
    192200      png_warning(png_ptr,
    193201          "png_write_sCAL not supported; sCAL chunk not written.");
    194 #endif
    195 #endif
    196 #endif
     202#endif /* WRITE_sCAL */
     203#endif /* sCAL */
     204
    197205#if defined(PNG_WRITE_pHYs_SUPPORTED)
    198206   if (info_ptr->valid & PNG_INFO_pHYs)
    199207      png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit,
    200208         info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type);
    201 #endif
     209#endif /* pHYs */
     210
    202211#if defined(PNG_WRITE_tIME_SUPPORTED)
    203212   if (info_ptr->valid & PNG_INFO_tIME)
     
    206215      png_ptr->mode |= PNG_WROTE_tIME;
    207216   }
    208 #endif
     217#endif /* tIME */
     218
    209219#if defined(PNG_WRITE_sPLT_SUPPORTED)
    210220   if (info_ptr->valid & PNG_INFO_sPLT)
    211221     for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
    212222       png_write_sPLT(png_ptr, info_ptr->splt_palettes + i);
    213 #endif
     223#endif /* sPLT */
     224
    214225#if defined(PNG_WRITE_TEXT_SUPPORTED)
    215226   /* Check to see if we need to write text chunks */
    216227   for (i = 0; i < info_ptr->num_text; i++)
    217228   {
    218       png_debug2(2, "Writing header text chunk %d, type %d\n", i,
     229      png_debug2(2, "Writing header text chunk %d, type %d", i,
    219230         info_ptr->text[i].compression);
    220       /* an internationalized chunk? */
     231      /* An internationalized chunk? */
    221232      if (info_ptr->text[i].compression > 0)
    222233      {
    223234#if defined(PNG_WRITE_iTXt_SUPPORTED)
    224           /* write international chunk */
     235          /* Write international chunk */
    225236          png_write_iTXt(png_ptr,
    226237                         info_ptr->text[i].compression,
     
    239250      {
    240251#if defined(PNG_WRITE_zTXt_SUPPORTED)
    241          /* write compressed chunk */
     252         /* Write compressed chunk */
    242253         png_write_zTXt(png_ptr, info_ptr->text[i].key,
    243254            info_ptr->text[i].text, 0,
     
    252263      {
    253264#if defined(PNG_WRITE_tEXt_SUPPORTED)
    254          /* write uncompressed chunk */
     265         /* Write uncompressed chunk */
    255266         png_write_tEXt(png_ptr, info_ptr->text[i].key,
    256267                         info_ptr->text[i].text,
    257268                         0);
    258 #else
    259          png_warning(png_ptr, "Unable to write uncompressed text");
    260 #endif
    261269         /* Mark this chunk as written */
    262270         info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
    263       }
    264    }
    265 #endif
     271#else
     272         /* Can't get here */
     273         png_warning(png_ptr, "Unable to write uncompressed text");
     274#endif
     275      }
     276   }
     277#endif /* tEXt */
     278
    266279#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED)
    267280   if (info_ptr->unknown_chunks_num)
     
    269282       png_unknown_chunk *up;
    270283
    271        png_debug(5, "writing extra chunks\n");
     284       png_debug(5, "writing extra chunks");
    272285
    273286       for (up = info_ptr->unknown_chunks;
     
    297310png_write_end(png_structp png_ptr, png_infop info_ptr)
    298311{
    299    png_debug(1, "in png_write_end\n");
     312   png_debug(1, "in png_write_end");
    300313   if (png_ptr == NULL)
    301314      return;
     
    303316      png_error(png_ptr, "No IDATs written into file");
    304317
    305    /* see if user wants us to write information chunks */
     318   /* See if user wants us to write information chunks */
    306319   if (info_ptr != NULL)
    307320   {
    308321#if defined(PNG_WRITE_TEXT_SUPPORTED)
    309       int i; /* local index variable */
     322      int i; /* Local index variable */
    310323#endif
    311324#if defined(PNG_WRITE_tIME_SUPPORTED)
    312       /* check to see if user has supplied a time chunk */
     325      /* Check to see if user has supplied a time chunk */
    313326      if ((info_ptr->valid & PNG_INFO_tIME) &&
    314327         !(png_ptr->mode & PNG_WROTE_tIME))
     
    316329#endif
    317330#if defined(PNG_WRITE_TEXT_SUPPORTED)
    318       /* loop through comment chunks */
     331      /* Loop through comment chunks */
    319332      for (i = 0; i < info_ptr->num_text; i++)
    320333      {
    321          png_debug2(2, "Writing trailer text chunk %d, type %d\n", i,
     334         png_debug2(2, "Writing trailer text chunk %d, type %d", i,
    322335            info_ptr->text[i].compression);
    323          /* an internationalized chunk? */
     336         /* An internationalized chunk? */
    324337         if (info_ptr->text[i].compression > 0)
    325338         {
    326339#if defined(PNG_WRITE_iTXt_SUPPORTED)
    327              /* write international chunk */
     340             /* Write international chunk */
    328341             png_write_iTXt(png_ptr,
    329342                         info_ptr->text[i].compression,
     
    341354         {
    342355#if defined(PNG_WRITE_zTXt_SUPPORTED)
    343             /* write compressed chunk */
     356            /* Write compressed chunk */
    344357            png_write_zTXt(png_ptr, info_ptr->text[i].key,
    345358               info_ptr->text[i].text, 0,
     
    354367         {
    355368#if defined(PNG_WRITE_tEXt_SUPPORTED)
    356             /* write uncompressed chunk */
     369            /* Write uncompressed chunk */
    357370            png_write_tEXt(png_ptr, info_ptr->text[i].key,
    358371               info_ptr->text[i].text, 0);
     
    371384       png_unknown_chunk *up;
    372385
    373        png_debug(5, "writing extra chunks\n");
     386       png_debug(5, "writing extra chunks");
    374387
    375388       for (up = info_ptr->unknown_chunks;
     
    392405   png_ptr->mode |= PNG_AFTER_IDAT;
    393406
    394    /* write end of PNG file */
     407   /* Write end of PNG file */
    395408   png_write_IEND(png_ptr);
     409   /* This flush, added in libpng-1.0.8, removed from libpng-1.0.9beta03,
     410    * and restored again in libpng-1.2.30, may cause some applications that
     411    * do not set png_ptr->output_flush_fn to crash.  If your application
     412    * experiences a problem, please try building libpng with
     413    * PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED defined, and report the event to
     414    * png-mng-implement at lists.sf.net .  This kludge will be removed
     415    * from libpng-1.4.0.
     416    */
     417#if defined(PNG_WRITE_FLUSH_SUPPORTED) && \
     418    defined(PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED)
     419   png_flush(png_ptr);
     420#endif
    396421}
    397422
     
    402427png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime)
    403428{
    404    png_debug(1, "in png_convert_from_struct_tm\n");
     429   png_debug(1, "in png_convert_from_struct_tm");
    405430   ptime->year = (png_uint_16)(1900 + ttime->tm_year);
    406431   ptime->month = (png_byte)(ttime->tm_mon + 1);
     
    416441   struct tm *tbuf;
    417442
    418    png_debug(1, "in png_convert_from_time_t\n");
     443   png_debug(1, "in png_convert_from_time_t");
    419444   tbuf = gmtime(&ttime);
    420445   png_convert_from_struct_tm(ptime, tbuf);
     
    440465{
    441466#endif /* PNG_USER_MEM_SUPPORTED */
    442    png_structp png_ptr;
     467#ifdef PNG_SETJMP_SUPPORTED
     468    volatile
     469#endif
     470    png_structp png_ptr;
    443471#ifdef PNG_SETJMP_SUPPORTED
    444472#ifdef USE_FAR_KEYWORD
     
    447475#endif
    448476   int i;
    449    png_debug(1, "in png_create_write_struct\n");
     477   png_debug(1, "in png_create_write_struct");
    450478#ifdef PNG_USER_MEM_SUPPORTED
    451479   png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
     
    457485      return (NULL);
    458486
    459    /* added at libpng-1.2.6 */
     487   /* Added at libpng-1.2.6 */
    460488#ifdef PNG_SET_USER_LIMITS_SUPPORTED
    461489   png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
     
    471499   {
    472500      png_free(png_ptr, png_ptr->zbuf);
    473       png_ptr->zbuf=NULL;
     501       png_ptr->zbuf=NULL;
    474502      png_destroy_struct(png_ptr);
    475503      return (NULL);
    476504   }
    477505#ifdef USE_FAR_KEYWORD
    478    png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf));
     506   png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf));
    479507#endif
    480508#endif
     
    485513   png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
    486514
    487    if(user_png_ver)
     515   if (user_png_ver)
    488516   {
    489517     i=0;
    490518     do
    491519     {
    492        if(user_png_ver[i] != png_libpng_ver[i])
     520       if (user_png_ver[i] != png_libpng_ver[i])
    493521          png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
    494522     } while (png_libpng_ver[i++]);
     
    528556   }
    529557
    530    /* initialize zbuf - compression buffer */
     558   /* Initialize zbuf - compression buffer */
    531559   png_ptr->zbuf_size = PNG_ZBUF_SIZE;
    532560   png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
     
    548576   if (setjmp(jmpbuf))
    549577      PNG_ABORT();
    550    png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf));
     578   png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf));
    551579#else
    552580   if (setjmp(png_ptr->jmpbuf))
     
    573601{
    574602   /* We only come here via pre-1.0.12-compiled applications */
    575    if(png_ptr == NULL) return;
     603   if (png_ptr == NULL) return;
    576604#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
    577    if(png_sizeof(png_struct) > png_struct_size ||
     605   if (png_sizeof(png_struct) > png_struct_size ||
    578606      png_sizeof(png_info) > png_info_size)
    579607   {
     
    593621   }
    594622#endif
    595    if(png_sizeof(png_struct) > png_struct_size)
     623   if (png_sizeof(png_struct) > png_struct_size)
    596624     {
    597625       png_ptr->error_fn=NULL;
     
    602630       "The png struct allocated by the application for writing is too small.");
    603631     }
    604    if(png_sizeof(png_info) > png_info_size)
     632   if (png_sizeof(png_info) > png_info_size)
    605633     {
    606634       png_ptr->error_fn=NULL;
     
    622650   png_structp png_ptr=*ptr_ptr;
    623651#ifdef PNG_SETJMP_SUPPORTED
    624    jmp_buf tmp_jmp; /* to save current jump buffer */
     652   jmp_buf tmp_jmp; /* To save current jump buffer */
    625653#endif
    626654
     
    639667       png_ptr->warning_fn=NULL;
    640668       png_warning(png_ptr,
    641      "Application uses deprecated png_write_init() and should be recompiled.");
     669 "Application uses deprecated png_write_init() and should be recompiled.");
    642670       break;
    643671#endif
     
    645673   } while (png_libpng_ver[i++]);
    646674
    647    png_debug(1, "in png_write_init_3\n");
     675   png_debug(1, "in png_write_init_3");
    648676
    649677#ifdef PNG_SETJMP_SUPPORTED
    650    /* save jump buffer and error functions */
    651    png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf));
     678   /* Save jump buffer and error functions */
     679   png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf));
    652680#endif
    653681
     
    659687     }
    660688
    661    /* reset all variables to 0 */
    662    png_memset(png_ptr, 0, png_sizeof (png_struct));
    663 
    664    /* added at libpng-1.2.6 */
     689   /* Reset all variables to 0 */
     690   png_memset(png_ptr, 0, png_sizeof(png_struct));
     691
     692   /* Added at libpng-1.2.6 */
    665693#ifdef PNG_SET_USER_LIMITS_SUPPORTED
    666694   png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
     
    669697
    670698#ifdef PNG_SETJMP_SUPPORTED
    671    /* restore jump buffer */
    672    png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf));
     699   /* Restore jump buffer */
     700   png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf));
    673701#endif
    674702
     
    676704      png_flush_ptr_NULL);
    677705
    678    /* initialize zbuf - compression buffer */
     706   /* Initialize zbuf - compression buffer */
    679707   png_ptr->zbuf_size = PNG_ZBUF_SIZE;
    680708   png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
     
    696724   png_uint_32 num_rows)
    697725{
    698    png_uint_32 i; /* row counter */
    699    png_bytepp rp; /* row pointer */
    700 
    701    png_debug(1, "in png_write_rows\n");
    702 
    703    if (png_ptr == NULL)
    704       return;
    705 
    706    /* loop through the rows */
     726   png_uint_32 i; /* Row counter */
     727   png_bytepp rp; /* Row pointer */
     728
     729   png_debug(1, "in png_write_rows");
     730
     731   if (png_ptr == NULL)
     732      return;
     733
     734   /* Loop through the rows */
    707735   for (i = 0, rp = row; i < num_rows; i++, rp++)
    708736   {
     
    717745png_write_image(png_structp png_ptr, png_bytepp image)
    718746{
    719    png_uint_32 i; /* row index */
    720    int pass, num_pass; /* pass variables */
    721    png_bytepp rp; /* points to current row */
    722 
    723    if (png_ptr == NULL)
    724       return;
    725 
    726    png_debug(1, "in png_write_image\n");
     747   png_uint_32 i; /* Row index */
     748   int pass, num_pass; /* Pass variables */
     749   png_bytepp rp; /* Points to current row */
     750
     751   if (png_ptr == NULL)
     752      return;
     753
     754   png_debug(1, "in png_write_image");
    727755#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
    728    /* intialize interlace handling.  If image is not interlaced,
    729       this will set pass to 1 */
     756   /* Initialize interlace handling.  If image is not interlaced,
     757    * this will set pass to 1
     758    */
    730759   num_pass = png_set_interlace_handling(png_ptr);
    731760#else
    732761   num_pass = 1;
    733762#endif
    734    /* loop through passes */
     763   /* Loop through passes */
    735764   for (pass = 0; pass < num_pass; pass++)
    736765   {
    737       /* loop through image */
     766      /* Loop through image */
    738767      for (i = 0, rp = image; i < png_ptr->height; i++, rp++)
    739768      {
     
    743772}
    744773
    745 /* called by user to write a row of image data */
     774/* Called by user to write a row of image data */
    746775void PNGAPI
    747776png_write_row(png_structp png_ptr, png_bytep row)
     
    749778   if (png_ptr == NULL)
    750779      return;
    751    png_debug2(1, "in png_write_row (row %ld, pass %d)\n",
     780   png_debug2(1, "in png_write_row (row %ld, pass %d)",
    752781      png_ptr->row_number, png_ptr->pass);
    753782
    754    /* initialize transformations and other stuff if first time */
     783   /* Initialize transformations and other stuff if first time */
    755784   if (png_ptr->row_number == 0 && png_ptr->pass == 0)
    756785   {
    757    /* make sure we wrote the header info */
    758    if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
    759       png_error(png_ptr,
    760          "png_write_info was never called before png_write_row.");
    761 
    762    /* check for transforms that have been set but were defined out */
     786      /* Make sure we wrote the header info */
     787      if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
     788         png_error(png_ptr,
     789            "png_write_info was never called before png_write_row.");
     790
     791      /* Check for transforms that have been set but were defined out */
    763792#if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED)
    764    if (png_ptr->transformations & PNG_INVERT_MONO)
    765       png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined.");
     793      if (png_ptr->transformations & PNG_INVERT_MONO)
     794         png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined.");
    766795#endif
    767796#if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED)
    768    if (png_ptr->transformations & PNG_FILLER)
    769       png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined.");
     797      if (png_ptr->transformations & PNG_FILLER)
     798         png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined.");
    770799#endif
    771800#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && defined(PNG_READ_PACKSWAP_SUPPORTED)
    772    if (png_ptr->transformations & PNG_PACKSWAP)
    773       png_warning(png_ptr, "PNG_WRITE_PACKSWAP_SUPPORTED is not defined.");
     801      if (png_ptr->transformations & PNG_PACKSWAP)
     802         png_warning(png_ptr, "PNG_WRITE_PACKSWAP_SUPPORTED is not defined.");
    774803#endif
    775804#if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED)
    776    if (png_ptr->transformations & PNG_PACK)
    777       png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined.");
     805      if (png_ptr->transformations & PNG_PACK)
     806         png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined.");
    778807#endif
    779808#if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED)
    780    if (png_ptr->transformations & PNG_SHIFT)
    781       png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined.");
     809      if (png_ptr->transformations & PNG_SHIFT)
     810         png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined.");
    782811#endif
    783812#if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED)
    784    if (png_ptr->transformations & PNG_BGR)
    785       png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined.");
     813      if (png_ptr->transformations & PNG_BGR)
     814         png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined.");
    786815#endif
    787816#if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED)
    788    if (png_ptr->transformations & PNG_SWAP_BYTES)
    789       png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined.");
     817      if (png_ptr->transformations & PNG_SWAP_BYTES)
     818         png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined.");
    790819#endif
    791820
     
    794823
    795824#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
    796    /* if interlaced and not interested in row, return */
     825   /* If interlaced and not interested in row, return */
    797826   if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
    798827   {
     
    852881#endif
    853882
    854    /* set up row info for transformations */
     883   /* Set up row info for transformations */
    855884   png_ptr->row_info.color_type = png_ptr->color_type;
    856885   png_ptr->row_info.width = png_ptr->usr_width;
     
    863892      png_ptr->row_info.width);
    864893
    865    png_debug1(3, "row_info->color_type = %d\n", png_ptr->row_info.color_type);
    866    png_debug1(3, "row_info->width = %lu\n", png_ptr->row_info.width);
    867    png_debug1(3, "row_info->channels = %d\n", png_ptr->row_info.channels);
    868    png_debug1(3, "row_info->bit_depth = %d\n", png_ptr->row_info.bit_depth);
    869    png_debug1(3, "row_info->pixel_depth = %d\n", png_ptr->row_info.pixel_depth);
    870    png_debug1(3, "row_info->rowbytes = %lu\n", png_ptr->row_info.rowbytes);
     894   png_debug1(3, "row_info->color_type = %d", png_ptr->row_info.color_type);
     895   png_debug1(3, "row_info->width = %lu", png_ptr->row_info.width);
     896   png_debug1(3, "row_info->channels = %d", png_ptr->row_info.channels);
     897   png_debug1(3, "row_info->bit_depth = %d", png_ptr->row_info.bit_depth);
     898   png_debug1(3, "row_info->pixel_depth = %d", png_ptr->row_info.pixel_depth);
     899   png_debug1(3, "row_info->rowbytes = %lu", png_ptr->row_info.rowbytes);
    871900
    872901   /* Copy user's row into buffer, leaving room for filter byte. */
     
    875904
    876905#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
    877    /* handle interlacing */
     906   /* Handle interlacing */
    878907   if (png_ptr->interlaced && png_ptr->pass < 6 &&
    879908      (png_ptr->transformations & PNG_INTERLACE))
     
    881910      png_do_write_interlace(&(png_ptr->row_info),
    882911         png_ptr->row_buf + 1, png_ptr->pass);
    883       /* this should always get caught above, but still ... */
     912      /* This should always get caught above, but still ... */
    884913      if (!(png_ptr->row_info.width))
    885914      {
     
    890919#endif
    891920
    892    /* handle other transformations */
     921   /* Handle other transformations */
    893922   if (png_ptr->transformations)
    894923      png_do_write_transformations(png_ptr);
     
    904933    * 5. The color_type is RGB or RGBA
    905934    */
    906    if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
     935   if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
    907936      (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
    908937   {
     
    924953png_set_flush(png_structp png_ptr, int nrows)
    925954{
    926    png_debug(1, "in png_set_flush\n");
     955   png_debug(1, "in png_set_flush");
    927956   if (png_ptr == NULL)
    928957      return;
     
    930959}
    931960
    932 /* flush the current output buffers now */
     961/* Flush the current output buffers now */
    933962void PNGAPI
    934963png_write_flush(png_structp png_ptr)
     
    936965   int wrote_IDAT;
    937966
    938    png_debug(1, "in png_write_flush\n");
     967   png_debug(1, "in png_write_flush");
    939968   if (png_ptr == NULL)
    940969      return;
    941970   /* We have already written out all of the data */
    942971   if (png_ptr->row_number >= png_ptr->num_rows)
    943      return;
     972      return;
    944973
    945974   do
     
    947976      int ret;
    948977
    949       /* compress the data */
     978      /* Compress the data */
    950979      ret = deflate(&png_ptr->zstream, Z_SYNC_FLUSH);
    951980      wrote_IDAT = 0;
    952981
    953       /* check for compression errors */
     982      /* Check for compression errors */
    954983      if (ret != Z_OK)
    955984      {
     
    962991      if (!(png_ptr->zstream.avail_out))
    963992      {
    964          /* write the IDAT and reset the zlib output buffer */
     993         /* Write the IDAT and reset the zlib output buffer */
    965994         png_write_IDAT(png_ptr, png_ptr->zbuf,
    966995                        png_ptr->zbuf_size);
     
    9741003   if (png_ptr->zbuf_size != png_ptr->zstream.avail_out)
    9751004   {
    976       /* write the IDAT and reset the zlib output buffer */
     1005      /* Write the IDAT and reset the zlib output buffer */
    9771006      png_write_IDAT(png_ptr, png_ptr->zbuf,
    9781007                     png_ptr->zbuf_size - png_ptr->zstream.avail_out);
     
    9851014#endif /* PNG_WRITE_FLUSH_SUPPORTED */
    9861015
    987 /* free all memory used by the write */
     1016/* Free all memory used by the write */
    9881017void PNGAPI
    9891018png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
     
    9961025#endif
    9971026
    998    png_debug(1, "in png_destroy_write_struct\n");
     1027   png_debug(1, "in png_destroy_write_struct");
    9991028   if (png_ptr_ptr != NULL)
    10001029   {
     
    10281057           png_free(png_ptr, png_ptr->chunk_list);
    10291058           png_ptr->chunk_list=NULL;
    1030            png_ptr->num_chunk_list=0;
     1059           png_ptr->num_chunk_list = 0;
    10311060        }
    10321061#endif
     
    10611090{
    10621091#ifdef PNG_SETJMP_SUPPORTED
    1063    jmp_buf tmp_jmp; /* save jump buffer */
     1092   jmp_buf tmp_jmp; /* Save jump buffer */
    10641093#endif
    10651094   png_error_ptr error_fn;
     
    10701099#endif
    10711100
    1072    png_debug(1, "in png_write_destroy\n");
    1073    /* free any memory zlib uses */
     1101   png_debug(1, "in png_write_destroy");
     1102   /* Free any memory zlib uses */
    10741103   deflateEnd(&png_ptr->zstream);
    10751104
    1076    /* free our memory.  png_free checks NULL for us. */
     1105   /* Free our memory.  png_free checks NULL for us. */
    10771106   png_free(png_ptr, png_ptr->zbuf);
    10781107   png_free(png_ptr, png_ptr->row_buf);
    1079 #ifndef PNG_NO_WRITE_FILTERING
     1108#ifndef PNG_NO_WRITE_FILTER
    10801109   png_free(png_ptr, png_ptr->prev_row);
    10811110   png_free(png_ptr, png_ptr->sub_row);
     
    10981127
    10991128#ifdef PNG_SETJMP_SUPPORTED
    1100    /* reset structure */
    1101    png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf));
     1129   /* Reset structure */
     1130   png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf));
    11021131#endif
    11031132
     
    11091138#endif
    11101139
    1111    png_memset(png_ptr, 0, png_sizeof (png_struct));
     1140   png_memset(png_ptr, 0, png_sizeof(png_struct));
    11121141
    11131142   png_ptr->error_fn = error_fn;
     
    11191148
    11201149#ifdef PNG_SETJMP_SUPPORTED
    1121    png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf));
     1150   png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf));
    11221151#endif
    11231152}
     
    11271156png_set_filter(png_structp png_ptr, int method, int filters)
    11281157{
    1129    png_debug(1, "in png_set_filter\n");
     1158   png_debug(1, "in png_set_filter");
    11301159   if (png_ptr == NULL)
    11311160      return;
    11321161#if defined(PNG_MNG_FEATURES_SUPPORTED)
    1133    if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
     1162   if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
    11341163      (method == PNG_INTRAPIXEL_DIFFERENCING))
    11351164         method = PNG_FILTER_TYPE_BASE;
     
    12501279   int i;
    12511280
    1252    png_debug(1, "in png_set_filter_heuristics\n");
     1281   png_debug(1, "in png_set_filter_heuristics");
    12531282   if (png_ptr == NULL)
    12541283      return;
     
    13641393png_set_compression_level(png_structp png_ptr, int level)
    13651394{
    1366    png_debug(1, "in png_set_compression_level\n");
     1395   png_debug(1, "in png_set_compression_level");
    13671396   if (png_ptr == NULL)
    13681397      return;
     
    13741403png_set_compression_mem_level(png_structp png_ptr, int mem_level)
    13751404{
    1376    png_debug(1, "in png_set_compression_mem_level\n");
     1405   png_debug(1, "in png_set_compression_mem_level");
    13771406   if (png_ptr == NULL)
    13781407      return;
     
    13841413png_set_compression_strategy(png_structp png_ptr, int strategy)
    13851414{
    1386    png_debug(1, "in png_set_compression_strategy\n");
     1415   png_debug(1, "in png_set_compression_strategy");
    13871416   if (png_ptr == NULL)
    13881417      return;
     
    14011430      png_warning(png_ptr, "Only compression windows >= 256 supported by PNG");
    14021431#ifndef WBITS_8_OK
    1403    /* avoid libpng bug with 256-byte windows */
     1432   /* Avoid libpng bug with 256-byte windows */
    14041433   if (window_bits == 8)
    14051434     {
     
    14151444png_set_compression_method(png_structp png_ptr, int method)
    14161445{
    1417    png_debug(1, "in png_set_compression_method\n");
     1446   png_debug(1, "in png_set_compression_method");
    14181447   if (png_ptr == NULL)
    14191448      return;
     
    14371466   write_user_transform_fn)
    14381467{
    1439    png_debug(1, "in png_set_write_user_transform_fn\n");
     1468   png_debug(1, "in png_set_write_user_transform_fn");
    14401469   if (png_ptr == NULL)
    14411470      return;
     
    14541483      return;
    14551484#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
    1456    /* invert the alpha channel from opacity to transparency */
     1485   /* Invert the alpha channel from opacity to transparency */
    14571486   if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
    1458        png_set_invert_alpha(png_ptr);
     1487      png_set_invert_alpha(png_ptr);
    14591488#endif
    14601489
     
    14651494
    14661495#if defined(PNG_WRITE_INVERT_SUPPORTED)
    1467    /* invert monochrome pixels */
     1496   /* Invert monochrome pixels */
    14681497   if (transforms & PNG_TRANSFORM_INVERT_MONO)
    1469        png_set_invert_mono(png_ptr);
     1498      png_set_invert_mono(png_ptr);
    14701499#endif
    14711500
     
    14761505   if ((transforms & PNG_TRANSFORM_SHIFT)
    14771506               && (info_ptr->valid & PNG_INFO_sBIT))
    1478        png_set_shift(png_ptr, &info_ptr->sig_bit);
     1507      png_set_shift(png_ptr, &info_ptr->sig_bit);
    14791508#endif
    14801509
    14811510#if defined(PNG_WRITE_PACK_SUPPORTED)
    1482    /* pack pixels into bytes */
     1511   /* Pack pixels into bytes */
    14831512   if (transforms & PNG_TRANSFORM_PACKING)
    14841513       png_set_packing(png_ptr);
     
    14861515
    14871516#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
    1488    /* swap location of alpha bytes from ARGB to RGBA */
     1517   /* Swap location of alpha bytes from ARGB to RGBA */
    14891518   if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
    1490        png_set_swap_alpha(png_ptr);
     1519      png_set_swap_alpha(png_ptr);
    14911520#endif
    14921521
    14931522#if defined(PNG_WRITE_FILLER_SUPPORTED)
    1494    /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into
    1495     * RGB (4 channels -> 3 channels). The second parameter is not used.
    1496     */
    1497    if (transforms & PNG_TRANSFORM_STRIP_FILLER)
    1498        png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
     1523   /* Pack XRGB/RGBX/ARGB/RGBA into * RGB (4 channels -> 3 channels) */
     1524   if (transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER)
     1525      png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
     1526   else if (transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE)
     1527      png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
    14991528#endif
    15001529
    15011530#if defined(PNG_WRITE_BGR_SUPPORTED)
    1502    /* flip BGR pixels to RGB */
     1531   /* Flip BGR pixels to RGB */
    15031532   if (transforms & PNG_TRANSFORM_BGR)
    1504        png_set_bgr(png_ptr);
     1533      png_set_bgr(png_ptr);
    15051534#endif
    15061535
    15071536#if defined(PNG_WRITE_SWAP_SUPPORTED)
    1508    /* swap bytes of 16-bit files to most significant byte first */
     1537   /* Swap bytes of 16-bit files to most significant byte first */
    15091538   if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
    1510        png_set_swap(png_ptr);
     1539      png_set_swap(png_ptr);
    15111540#endif
    15121541
    15131542#if defined(PNG_WRITE_PACKSWAP_SUPPORTED)
    1514    /* swap bits of 1, 2, 4 bit packed pixel formats */
     1543   /* Swap bits of 1, 2, 4 bit packed pixel formats */
    15151544   if (transforms & PNG_TRANSFORM_PACKSWAP)
    1516        png_set_packswap(png_ptr);
     1545      png_set_packswap(png_ptr);
    15171546#endif
    15181547
    15191548   /* ----------------------- end of transformations ------------------- */
    15201549
    1521    /* write the bits */
     1550   /* Write the bits */
    15221551   if (info_ptr->valid & PNG_INFO_IDAT)
    15231552       png_write_image(png_ptr, info_ptr->row_pointers);
     
    15261555   png_write_end(png_ptr, info_ptr);
    15271556
    1528    transforms = transforms; /* quiet compiler warnings */
     1557   transforms = transforms; /* Quiet compiler warnings */
    15291558   params = params;
    15301559}
  • trunk/src/3rdparty/libpng/pngwtran.c

    r2 r561  
    22/* pngwtran.c - transforms the data in a row for PNG writers
    33 *
    4  * Last changed in libpng 1.2.9 April 14, 2006
    5  * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2006 Glenn Randers-Pehrson
     4 * Last changed in libpng 1.2.37 [June 4, 2009]
     5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
    76 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    87 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     8 *
     9 * This code is released under the libpng license.
     10 * For conditions of distribution and use, see the disclaimer
     11 * and license in png.h
    912 */
    1013
     
    1922png_do_write_transformations(png_structp png_ptr)
    2023{
    21    png_debug(1, "in png_do_write_transformations\n");
     24   png_debug(1, "in png_do_write_transformations");
    2225
    2326   if (png_ptr == NULL)
     
    2629#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
    2730   if (png_ptr->transformations & PNG_USER_TRANSFORM)
    28       if(png_ptr->write_user_transform_fn != NULL)
    29         (*(png_ptr->write_user_transform_fn)) /* user write transform function */
     31      if (png_ptr->write_user_transform_fn != NULL)
     32        (*(png_ptr->write_user_transform_fn)) /* User write transform function */
    3033          (png_ptr,                    /* png_ptr */
    3134           &(png_ptr->row_info),       /* row_info:     */
     
    8790png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
    8891{
    89    png_debug(1, "in png_do_pack\n");
     92   png_debug(1, "in png_do_pack");
    9093   if (row_info->bit_depth == 8 &&
    9194#if defined(PNG_USELESS_TESTS_SUPPORTED)
     
    213216png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
    214217{
    215    png_debug(1, "in png_do_shift\n");
     218   png_debug(1, "in png_do_shift");
    216219#if defined(PNG_USELESS_TESTS_SUPPORTED)
    217220   if (row != NULL && row_info != NULL &&
     
    249252      }
    250253
    251       /* with low row depths, could only be grayscale, so one channel */
     254      /* With low row depths, could only be grayscale, so one channel */
    252255      if (row_info->bit_depth < 8)
    253256      {
     
    337340png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
    338341{
    339    png_debug(1, "in png_do_write_swap_alpha\n");
     342   png_debug(1, "in png_do_write_swap_alpha");
    340343#if defined(PNG_USELESS_TESTS_SUPPORTED)
    341344   if (row != NULL && row_info != NULL)
     
    425428png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
    426429{
    427    png_debug(1, "in png_do_write_invert_alpha\n");
     430   png_debug(1, "in png_do_write_invert_alpha");
    428431#if defined(PNG_USELESS_TESTS_SUPPORTED)
    429432   if (row != NULL && row_info != NULL)
     
    440443            for (i = 0, sp = dp = row; i < row_width; i++)
    441444            {
    442                /* does nothing
     445               /* Does nothing
    443446               *(dp++) = *(sp++);
    444447               *(dp++) = *(sp++);
     
    458461            for (i = 0, sp = dp = row; i < row_width; i++)
    459462            {
    460                /* does nothing
     463               /* Does nothing
    461464               *(dp++) = *(sp++);
    462465               *(dp++) = *(sp++);
     
    496499            for (i = 0, sp = dp = row; i < row_width; i++)
    497500            {
    498                /* does nothing
     501               /* Does nothing
    499502               *(dp++) = *(sp++);
    500503               *(dp++) = *(sp++);
     
    511514
    512515#if defined(PNG_MNG_FEATURES_SUPPORTED)
    513 /* undoes intrapixel differencing  */
     516/* Undoes intrapixel differencing  */
    514517void /* PRIVATE */
    515518png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
    516519{
    517    png_debug(1, "in png_do_write_intrapixel\n");
     520   png_debug(1, "in png_do_write_intrapixel");
    518521   if (
    519522#if defined(PNG_USELESS_TESTS_SUPPORTED)
     
    559562            png_uint_32 s1   = (*(rp+2) << 8) | *(rp+3);
    560563            png_uint_32 s2   = (*(rp+4) << 8) | *(rp+5);
    561             png_uint_32 red  = (png_uint_32)((s0-s1) & 0xffffL);
    562             png_uint_32 blue = (png_uint_32)((s2-s1) & 0xffffL);
     564            png_uint_32 red  = (png_uint_32)((s0 - s1) & 0xffffL);
     565            png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL);
    563566            *(rp  ) = (png_byte)((red >> 8) & 0xff);
    564567            *(rp+1) = (png_byte)(red & 0xff);
  • trunk/src/3rdparty/libpng/pngwutil.c

    r2 r561  
    22/* pngwutil.c - utilities to write a PNG file
    33 *
    4  * Last changed in libpng 1.2.27 [April 29, 2008]
    5  * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2008 Glenn Randers-Pehrson
     4 * Last changed in libpng 1.2.40 [September 10, 2009]
     5 * Copyright (c) 1998-2009 Glenn Randers-Pehrson
    76 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    87 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
     8 *
     9 * This code is released under the libpng license.
     10 * For conditions of distribution and use, see the disclaimer
     11 * and license in png.h
    912 */
    1013
     
    4851   buf[0] = (png_byte)((i >> 8) & 0xff);
    4952   buf[1] = (png_byte)(i & 0xff);
     53}
     54
     55/* Simple function to write the signature.  If we have already written
     56 * the magic bytes of the signature, or more likely, the PNG stream is
     57 * being embedded into another stream and doesn't need its own signature,
     58 * we should call png_set_sig_bytes() to tell libpng how many of the
     59 * bytes have already been written.
     60 */
     61void /* PRIVATE */
     62png_write_sig(png_structp png_ptr)
     63{
     64   png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
     65
     66   /* Write the rest of the 8 byte signature */
     67   png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes],
     68      (png_size_t)(8 - png_ptr->sig_bytes));
     69   if (png_ptr->sig_bytes < 3)
     70      png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
    5071}
    5172
     
    6384   png_bytep data, png_size_t length)
    6485{
    65    if(png_ptr == NULL) return;
     86   if (png_ptr == NULL)
     87      return;
    6688   png_write_chunk_start(png_ptr, chunk_name, (png_uint_32)length);
    67    png_write_chunk_data(png_ptr, data, length);
     89   png_write_chunk_data(png_ptr, data, (png_size_t)length);
    6890   png_write_chunk_end(png_ptr);
    6991}
     
    7799   png_uint_32 length)
    78100{
    79    png_byte buf[4];
    80    png_debug2(0, "Writing %s chunk (%lu bytes)\n", chunk_name, length);
    81    if(png_ptr == NULL) return;
    82 
    83    /* write the length */
     101   png_byte buf[8];
     102
     103   png_debug2(0, "Writing %s chunk, length = %lu", chunk_name,
     104      (unsigned long)length);
     105
     106   if (png_ptr == NULL)
     107      return;
     108
     109   /* Write the length and the chunk name */
    84110   png_save_uint_32(buf, length);
    85    png_write_data(png_ptr, buf, (png_size_t)4);
    86 
    87    /* write the chunk name */
    88    png_write_data(png_ptr, chunk_name, (png_size_t)4);
    89    /* reset the crc and run it over the chunk name */
     111   png_memcpy(buf + 4, chunk_name, 4);
     112   png_write_data(png_ptr, buf, (png_size_t)8);
     113   /* Put the chunk name into png_ptr->chunk_name */
     114   png_memcpy(png_ptr->chunk_name, chunk_name, 4);
     115   /* Reset the crc and run it over the chunk name */
    90116   png_reset_crc(png_ptr);
    91117   png_calculate_crc(png_ptr, chunk_name, (png_size_t)4);
     
    100126png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length)
    101127{
    102    /* write the data, and run the CRC over it */
    103    if(png_ptr == NULL) return;
     128   /* Write the data, and run the CRC over it */
     129   if (png_ptr == NULL)
     130      return;
    104131   if (data != NULL && length > 0)
    105132   {
     133      png_write_data(png_ptr, data, length);
     134      /* Update the CRC after writing the data,
     135       * in case that the user I/O routine alters it.
     136       */
    106137      png_calculate_crc(png_ptr, data, length);
    107       png_write_data(png_ptr, data, length);
    108138   }
    109139}
     
    115145   png_byte buf[4];
    116146
    117    if(png_ptr == NULL) return;
    118 
    119    /* write the crc */
     147   if (png_ptr == NULL) return;
     148
     149   /* Write the crc in a single operation */
    120150   png_save_uint_32(buf, png_ptr->crc);
    121151
     
    123153}
    124154
    125 /* Simple function to write the signature.  If we have already written
    126  * the magic bytes of the signature, or more likely, the PNG stream is
    127  * being embedded into another stream and doesn't need its own signature,
    128  * we should call png_set_sig_bytes() to tell libpng how many of the
    129  * bytes have already been written.
    130  */
    131 void /* PRIVATE */
    132 png_write_sig(png_structp png_ptr)
    133 {
    134    png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
    135    /* write the rest of the 8 byte signature */
    136    png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes],
    137       (png_size_t)8 - png_ptr->sig_bytes);
    138    if(png_ptr->sig_bytes < 3)
    139       png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
    140 }
    141 
    142155#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_iCCP_SUPPORTED)
    143 /*
    144  * This pair of functions encapsulates the operation of (a) compressing a
     156/* This pair of functions encapsulates the operation of (a) compressing a
    145157 * text string, and (b) issuing it later as a series of chunk data writes.
    146158 * The compression_state structure is shared context for these functions
     
    150162typedef struct
    151163{
    152     char *input;   /* the uncompressed input data */
    153     int input_len;   /* its length */
    154     int num_output_ptr; /* number of output pointers used */
    155     int max_output_ptr; /* size of output_ptr */
    156     png_charpp output_ptr; /* array of pointers to output */
     164   char *input;   /* The uncompressed input data */
     165   int input_len;   /* Its length */
     166   int num_output_ptr; /* Number of output pointers used */
     167   int max_output_ptr; /* Size of output_ptr */
     168   png_charpp output_ptr; /* Array of pointers to output */
    157169} compression_state;
    158170
    159 /* compress given text into storage in the png_ptr structure */
     171/* Compress given text into storage in the png_ptr structure */
    160172static int /* PRIVATE */
    161173png_text_compress(png_structp png_ptr,
     
    171183   comp->input_len = 0;
    172184
    173    /* we may just want to pass the text right through */
     185   /* We may just want to pass the text right through */
    174186   if (compression == PNG_TEXT_COMPRESSION_NONE)
    175187   {
     
    205217    */
    206218
    207    /* set up the compression buffers */
     219   /* Set up the compression buffers */
    208220   png_ptr->zstream.avail_in = (uInt)text_len;
    209221   png_ptr->zstream.next_in = (Bytef *)text;
     
    211223   png_ptr->zstream.next_out = (Bytef *)png_ptr->zbuf;
    212224
    213    /* this is the same compression loop as in png_write_row() */
     225   /* This is the same compression loop as in png_write_row() */
    214226   do
    215227   {
    216       /* compress the data */
     228      /* Compress the data */
    217229      ret = deflate(&png_ptr->zstream, Z_NO_FLUSH);
    218230      if (ret != Z_OK)
    219231      {
    220          /* error */
     232         /* Error */
    221233         if (png_ptr->zstream.msg != NULL)
    222234            png_error(png_ptr, png_ptr->zstream.msg);
     
    224236            png_error(png_ptr, "zlib error");
    225237      }
    226       /* check to see if we need more room */
     238      /* Check to see if we need more room */
    227239      if (!(png_ptr->zstream.avail_out))
    228240      {
    229          /* make sure the output array has room */
     241         /* Make sure the output array has room */
    230242         if (comp->num_output_ptr >= comp->max_output_ptr)
    231243         {
     
    240252               old_ptr = comp->output_ptr;
    241253               comp->output_ptr = (png_charpp)png_malloc(png_ptr,
    242                   (png_uint_32)(comp->max_output_ptr *
    243                   png_sizeof (png_charpp)));
     254                  (png_uint_32)
     255                  (comp->max_output_ptr * png_sizeof(png_charpp)));
    244256               png_memcpy(comp->output_ptr, old_ptr, old_max
    245                   * png_sizeof (png_charp));
     257                  * png_sizeof(png_charp));
    246258               png_free(png_ptr, old_ptr);
    247259            }
    248260            else
    249261               comp->output_ptr = (png_charpp)png_malloc(png_ptr,
    250                   (png_uint_32)(comp->max_output_ptr *
    251                   png_sizeof (png_charp)));
     262                  (png_uint_32)
     263                  (comp->max_output_ptr * png_sizeof(png_charp)));
    252264         }
    253265
    254          /* save the data */
    255          comp->output_ptr[comp->num_output_ptr] = (png_charp)png_malloc(png_ptr,
     266         /* Save the data */
     267         comp->output_ptr[comp->num_output_ptr] =
     268            (png_charp)png_malloc(png_ptr,
    256269            (png_uint_32)png_ptr->zbuf_size);
    257270         png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf,
     
    263276         png_ptr->zstream.next_out = png_ptr->zbuf;
    264277      }
    265    /* continue until we don't have any more to compress */
     278   /* Continue until we don't have any more to compress */
    266279   } while (png_ptr->zstream.avail_in);
    267280
    268    /* finish the compression */
     281   /* Finish the compression */
    269282   do
    270283   {
    271       /* tell zlib we are finished */
     284      /* Tell zlib we are finished */
    272285      ret = deflate(&png_ptr->zstream, Z_FINISH);
    273286
    274287      if (ret == Z_OK)
    275288      {
    276          /* check to see if we need more room */
     289         /* Check to see if we need more room */
    277290         if (!(png_ptr->zstream.avail_out))
    278291         {
    279             /* check to make sure our output array has room */
     292            /* Check to make sure our output array has room */
    280293            if (comp->num_output_ptr >= comp->max_output_ptr)
    281294            {
     
    292305                  comp->output_ptr = (png_charpp)png_malloc(png_ptr,
    293306                     (png_uint_32)(comp->max_output_ptr *
    294                      png_sizeof (png_charpp)));
     307                     png_sizeof(png_charp)));
    295308                  png_memcpy(comp->output_ptr, old_ptr,
    296                      old_max * png_sizeof (png_charp));
     309                     old_max * png_sizeof(png_charp));
    297310                  png_free(png_ptr, old_ptr);
    298311               }
     
    300313                  comp->output_ptr = (png_charpp)png_malloc(png_ptr,
    301314                     (png_uint_32)(comp->max_output_ptr *
    302                      png_sizeof (png_charp)));
     315                     png_sizeof(png_charp)));
    303316            }
    304317
    305             /* save off the data */
     318            /* Save the data */
    306319            comp->output_ptr[comp->num_output_ptr] =
    307                (png_charp)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size);
     320               (png_charp)png_malloc(png_ptr,
     321               (png_uint_32)png_ptr->zbuf_size);
    308322            png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf,
    309323               png_ptr->zbuf_size);
     
    317331      else if (ret != Z_STREAM_END)
    318332      {
    319          /* we got an error */
     333         /* We got an error */
    320334         if (png_ptr->zstream.msg != NULL)
    321335            png_error(png_ptr, png_ptr->zstream.msg);
     
    325339   } while (ret != Z_STREAM_END);
    326340
    327    /* text length is number of buffers plus last buffer */
     341   /* Text length is number of buffers plus last buffer */
    328342   text_len = png_ptr->zbuf_size * comp->num_output_ptr;
    329343   if (png_ptr->zstream.avail_out < png_ptr->zbuf_size)
     
    333347}
    334348
    335 /* ship the compressed text out via chunk writes */
     349/* Ship the compressed text out via chunk writes */
    336350static void /* PRIVATE */
    337351png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
     
    339353   int i;
    340354
    341    /* handle the no-compression case */
     355   /* Handle the no-compression case */
    342356   if (comp->input)
    343357   {
    344        png_write_chunk_data(png_ptr, (png_bytep)comp->input,
     358      png_write_chunk_data(png_ptr, (png_bytep)comp->input,
    345359                            (png_size_t)comp->input_len);
    346        return;
    347    }
    348 
    349    /* write saved output buffers, if any */
     360      return;
     361   }
     362
     363   /* Write saved output buffers, if any */
    350364   for (i = 0; i < comp->num_output_ptr; i++)
    351365   {
    352       png_write_chunk_data(png_ptr,(png_bytep)comp->output_ptr[i],
    353          png_ptr->zbuf_size);
     366      png_write_chunk_data(png_ptr, (png_bytep)comp->output_ptr[i],
     367         (png_size_t)png_ptr->zbuf_size);
    354368      png_free(png_ptr, comp->output_ptr[i]);
    355       comp->output_ptr[i]=NULL;
     369       comp->output_ptr[i]=NULL;
    356370   }
    357371   if (comp->max_output_ptr != 0)
    358372      png_free(png_ptr, comp->output_ptr);
    359       comp->output_ptr=NULL;
    360    /* write anything left in zbuf */
     373       comp->output_ptr=NULL;
     374   /* Write anything left in zbuf */
    361375   if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size)
    362376      png_write_chunk_data(png_ptr, png_ptr->zbuf,
    363          png_ptr->zbuf_size - png_ptr->zstream.avail_out);
    364 
    365    /* reset zlib for another zTXt/iTXt or image data */
     377         (png_size_t)(png_ptr->zbuf_size - png_ptr->zstream.avail_out));
     378
     379   /* Reset zlib for another zTXt/iTXt or image data */
    366380   deflateReset(&png_ptr->zstream);
    367381   png_ptr->zstream.data_type = Z_BINARY;
     
    383397   int ret;
    384398
    385    png_byte buf[13]; /* buffer to store the IHDR info */
    386 
    387    png_debug(1, "in png_write_IHDR\n");
     399   png_byte buf[13]; /* Buffer to store the IHDR info */
     400
     401   png_debug(1, "in png_write_IHDR");
     402
    388403   /* Check that we have valid input data from the application info */
    389404   switch (color_type)
     
    397412            case 8:
    398413            case 16: png_ptr->channels = 1; break;
    399             default: png_error(png_ptr,"Invalid bit depth for grayscale image");
     414            default: png_error(png_ptr, "Invalid bit depth for grayscale image");
    400415         }
    401416         break;
     
    469484#endif
    470485
    471    /* save off the relevent information */
     486   /* Save the relevent information */
    472487   png_ptr->bit_depth = (png_byte)bit_depth;
    473488   png_ptr->color_type = (png_byte)color_type;
     
    482497   png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels);
    483498   png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width);
    484    /* set the usr info, so any transformations can modify it */
     499   /* Set the usr info, so any transformations can modify it */
    485500   png_ptr->usr_width = png_ptr->width;
    486501   png_ptr->usr_bit_depth = png_ptr->bit_depth;
    487502   png_ptr->usr_channels = png_ptr->channels;
    488503
    489    /* pack the header information into the buffer */
     504   /* Pack the header information into the buffer */
    490505   png_save_uint_32(buf, width);
    491506   png_save_uint_32(buf + 4, height);
     
    496511   buf[12] = (png_byte)interlace_type;
    497512
    498    /* write the chunk */
    499    png_write_chunk(png_ptr, png_IHDR, buf, (png_size_t)13);
    500 
    501    /* initialize zlib with PNG info */
     513   /* Write the chunk */
     514   png_write_chunk(png_ptr, (png_bytep)png_IHDR, buf, (png_size_t)13);
     515
     516   /* Initialize zlib with PNG info */
    502517   png_ptr->zstream.zalloc = png_zalloc;
    503518   png_ptr->zstream.zfree = png_zfree;
     
    542557   png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
    543558   /* libpng is not interested in zstream.data_type */
    544    /* set it to a predefined value, to avoid its evaluation inside zlib */
     559   /* Set it to a predefined value, to avoid its evaluation inside zlib */
    545560   png_ptr->zstream.data_type = Z_BINARY;
    546561
     
    548563}
    549564
    550 /* write the palette.  We are careful not to trust png_color to be in the
     565/* Write the palette.  We are careful not to trust png_color to be in the
    551566 * correct order for PNG, so people can redefine it to any convenient
    552567 * structure.
     
    562577   png_byte buf[3];
    563578
    564    png_debug(1, "in png_write_PLTE\n");
     579   png_debug(1, "in png_write_PLTE");
     580
    565581   if ((
    566582#if defined(PNG_MNG_FEATURES_SUPPORTED)
     
    588604
    589605   png_ptr->num_palette = (png_uint_16)num_pal;
    590    png_debug1(3, "num_palette = %d\n", png_ptr->num_palette);
    591 
    592    png_write_chunk_start(png_ptr, png_PLTE, num_pal * 3);
     606   png_debug1(3, "num_palette = %d", png_ptr->num_palette);
     607
     608   png_write_chunk_start(png_ptr, (png_bytep)png_PLTE,
     609     (png_uint_32)(num_pal * 3));
    593610#ifndef PNG_NO_POINTER_INDEXING
    594611   for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++)
     
    614631}
    615632
    616 /* write an IDAT chunk */
     633/* Write an IDAT chunk */
    617634void /* PRIVATE */
    618635png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
     
    621638   PNG_IDAT;
    622639#endif
    623    png_debug(1, "in png_write_IDAT\n");
     640
     641   png_debug(1, "in png_write_IDAT");
    624642
    625643   /* Optimize the CMF field in the zlib stream. */
     
    631649      if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70)
    632650      {
    633          /* Avoid memory underflows and multiplication overflows. */
    634          /* The conditions below are practically always satisfied;
    635             however, they still must be checked. */
     651         /* Avoid memory underflows and multiplication overflows.
     652          *
     653          * The conditions below are practically always satisfied;
     654          * however, they still must be checked.
     655          */
    636656         if (length >= 2 &&
    637657             png_ptr->height < 16384 && png_ptr->width < 16384)
     
    662682   }
    663683
    664    png_write_chunk(png_ptr, png_IDAT, data, length);
     684   png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length);
    665685   png_ptr->mode |= PNG_HAVE_IDAT;
    666686}
    667687
    668 /* write an IEND chunk */
     688/* Write an IEND chunk */
    669689void /* PRIVATE */
    670690png_write_IEND(png_structp png_ptr)
     
    673693   PNG_IEND;
    674694#endif
    675    png_debug(1, "in png_write_IEND\n");
    676    png_write_chunk(png_ptr, png_IEND, png_bytep_NULL,
     695
     696   png_debug(1, "in png_write_IEND");
     697
     698   png_write_chunk(png_ptr, (png_bytep)png_IEND, png_bytep_NULL,
    677699     (png_size_t)0);
    678700   png_ptr->mode |= PNG_HAVE_IEND;
     
    680702
    681703#if defined(PNG_WRITE_gAMA_SUPPORTED)
    682 /* write a gAMA chunk */
     704/* Write a gAMA chunk */
    683705#ifdef PNG_FLOATING_POINT_SUPPORTED
    684706void /* PRIVATE */
     
    691713   png_byte buf[4];
    692714
    693    png_debug(1, "in png_write_gAMA\n");
     715   png_debug(1, "in png_write_gAMA");
     716
    694717   /* file_gamma is saved in 1/100,000ths */
    695718   igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5);
    696719   png_save_uint_32(buf, igamma);
    697    png_write_chunk(png_ptr, png_gAMA, buf, (png_size_t)4);
     720   png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);
    698721}
    699722#endif
     
    707730   png_byte buf[4];
    708731
    709    png_debug(1, "in png_write_gAMA\n");
     732   png_debug(1, "in png_write_gAMA");
     733
    710734   /* file_gamma is saved in 1/100,000ths */
    711735   png_save_uint_32(buf, (png_uint_32)file_gamma);
    712    png_write_chunk(png_ptr, png_gAMA, buf, (png_size_t)4);
     736   png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);
    713737}
    714738#endif
     
    716740
    717741#if defined(PNG_WRITE_sRGB_SUPPORTED)
    718 /* write a sRGB chunk */
     742/* Write a sRGB chunk */
    719743void /* PRIVATE */
    720744png_write_sRGB(png_structp png_ptr, int srgb_intent)
     
    725749   png_byte buf[1];
    726750
    727    png_debug(1, "in png_write_sRGB\n");
    728    if(srgb_intent >= PNG_sRGB_INTENT_LAST)
     751   png_debug(1, "in png_write_sRGB");
     752
     753   if (srgb_intent >= PNG_sRGB_INTENT_LAST)
    729754         png_warning(png_ptr,
    730755            "Invalid sRGB rendering intent specified");
    731756   buf[0]=(png_byte)srgb_intent;
    732    png_write_chunk(png_ptr, png_sRGB, buf, (png_size_t)1);
     757   png_write_chunk(png_ptr, (png_bytep)png_sRGB, buf, (png_size_t)1);
    733758}
    734759#endif
    735760
    736761#if defined(PNG_WRITE_iCCP_SUPPORTED)
    737 /* write an iCCP chunk */
     762/* Write an iCCP chunk */
    738763void /* PRIVATE */
    739764png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
     
    748773   int embedded_profile_len = 0;
    749774
    750    png_debug(1, "in png_write_iCCP\n");
     775   png_debug(1, "in png_write_iCCP");
    751776
    752777   comp.num_output_ptr = 0;
     
    756781   comp.input_len = 0;
    757782
    758    if (name == NULL || (name_len = png_check_keyword(png_ptr, name,
     783   if ((name_len = png_check_keyword(png_ptr, name,
    759784      &new_name)) == 0)
    760    {
    761       png_warning(png_ptr, "Empty keyword in iCCP chunk");
    762785      return;
    763    }
    764786
    765787   if (compression_type != PNG_COMPRESSION_TYPE_BASE)
     
    771793   if (profile_len > 3)
    772794      embedded_profile_len =
    773           ((*( (png_bytep)profile  ))<<24) |
    774           ((*( (png_bytep)profile+1))<<16) |
    775           ((*( (png_bytep)profile+2))<< 8) |
    776           ((*( (png_bytep)profile+3))    );
     795          ((*( (png_bytep)profile    ))<<24) |
     796          ((*( (png_bytep)profile + 1))<<16) |
     797          ((*( (png_bytep)profile + 2))<< 8) |
     798          ((*( (png_bytep)profile + 3))    );
     799
     800   if (embedded_profile_len < 0)
     801   {
     802      png_warning(png_ptr,
     803        "Embedded profile length in iCCP chunk is negative");
     804      png_free(png_ptr, new_name);
     805      return;
     806   }
    777807
    778808   if (profile_len < embedded_profile_len)
    779      {
    780         png_warning(png_ptr,
    781           "Embedded profile length too large in iCCP chunk");
    782         return;
    783      }
     809   {
     810      png_warning(png_ptr,
     811        "Embedded profile length too large in iCCP chunk");
     812      png_free(png_ptr, new_name);
     813      return;
     814   }
    784815
    785816   if (profile_len > embedded_profile_len)
    786      {
    787         png_warning(png_ptr,
    788           "Truncating profile to actual length in iCCP chunk");
    789         profile_len = embedded_profile_len;
    790      }
     817   {
     818      png_warning(png_ptr,
     819        "Truncating profile to actual length in iCCP chunk");
     820      profile_len = embedded_profile_len;
     821   }
    791822
    792823   if (profile_len)
    793        profile_len = png_text_compress(png_ptr, profile, (png_size_t)profile_len,
    794           PNG_COMPRESSION_TYPE_BASE, &comp);
    795 
    796    /* make sure we include the NULL after the name and the compression type */
    797    png_write_chunk_start(png_ptr, png_iCCP,
    798           (png_uint_32)name_len+profile_len+2);
    799    new_name[name_len+1]=0x00;
    800    png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 2);
     824      profile_len = png_text_compress(png_ptr, profile,
     825        (png_size_t)profile_len, PNG_COMPRESSION_TYPE_BASE, &comp);
     826
     827   /* Make sure we include the NULL after the name and the compression type */
     828   png_write_chunk_start(png_ptr, (png_bytep)png_iCCP,
     829          (png_uint_32)(name_len + profile_len + 2));
     830   new_name[name_len + 1] = 0x00;
     831   png_write_chunk_data(png_ptr, (png_bytep)new_name,
     832     (png_size_t)(name_len + 2));
    801833
    802834   if (profile_len)
     
    809841
    810842#if defined(PNG_WRITE_sPLT_SUPPORTED)
    811 /* write a sPLT chunk */
     843/* Write a sPLT chunk */
    812844void /* PRIVATE */
    813845png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
     
    826858#endif
    827859
    828    png_debug(1, "in png_write_sPLT\n");
    829    if (spalette->name == NULL || (name_len = png_check_keyword(png_ptr,
    830       spalette->name, &new_name))==0)
    831    {
    832       png_warning(png_ptr, "Empty keyword in sPLT chunk");
     860   png_debug(1, "in png_write_sPLT");
     861
     862   if ((name_len = png_check_keyword(png_ptr,spalette->name, &new_name))==0)
    833863      return;
    834    }
    835 
    836    /* make sure we include the NULL after the name */
    837    png_write_chunk_start(png_ptr, png_sPLT,
    838           (png_uint_32)(name_len + 2 + palette_size));
    839    png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 1);
    840    png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1);
    841 
    842    /* loop through each palette entry, writing appropriately */
     864
     865   /* Make sure we include the NULL after the name */
     866   png_write_chunk_start(png_ptr, (png_bytep)png_sPLT,
     867     (png_uint_32)(name_len + 2 + palette_size));
     868   png_write_chunk_data(png_ptr, (png_bytep)new_name,
     869     (png_size_t)(name_len + 1));
     870   png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, (png_size_t)1);
     871
     872   /* Loop through each palette entry, writing appropriately */
    843873#ifndef PNG_NO_POINTER_INDEXING
    844    for (ep = spalette->entries; ep<spalette->entries+spalette->nentries; ep++)
    845    {
    846        if (spalette->depth == 8)
    847        {
    848            entrybuf[0] = (png_byte)ep->red;
    849            entrybuf[1] = (png_byte)ep->green;
    850            entrybuf[2] = (png_byte)ep->blue;
    851            entrybuf[3] = (png_byte)ep->alpha;
    852            png_save_uint_16(entrybuf + 4, ep->frequency);
    853        }
    854        else
    855        {
    856            png_save_uint_16(entrybuf + 0, ep->red);
    857            png_save_uint_16(entrybuf + 2, ep->green);
    858            png_save_uint_16(entrybuf + 4, ep->blue);
    859            png_save_uint_16(entrybuf + 6, ep->alpha);
    860            png_save_uint_16(entrybuf + 8, ep->frequency);
    861        }
    862        png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size);
     874   for (ep = spalette->entries; ep<spalette->entries + spalette->nentries; ep++)
     875   {
     876      if (spalette->depth == 8)
     877      {
     878          entrybuf[0] = (png_byte)ep->red;
     879          entrybuf[1] = (png_byte)ep->green;
     880          entrybuf[2] = (png_byte)ep->blue;
     881          entrybuf[3] = (png_byte)ep->alpha;
     882          png_save_uint_16(entrybuf + 4, ep->frequency);
     883      }
     884      else
     885      {
     886          png_save_uint_16(entrybuf + 0, ep->red);
     887          png_save_uint_16(entrybuf + 2, ep->green);
     888          png_save_uint_16(entrybuf + 4, ep->blue);
     889          png_save_uint_16(entrybuf + 6, ep->alpha);
     890          png_save_uint_16(entrybuf + 8, ep->frequency);
     891      }
     892      png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size);
    863893   }
    864894#else
     
    866896   for (i=0; i>spalette->nentries; i++)
    867897   {
    868        if (spalette->depth == 8)
    869        {
    870            entrybuf[0] = (png_byte)ep[i].red;
    871            entrybuf[1] = (png_byte)ep[i].green;
    872            entrybuf[2] = (png_byte)ep[i].blue;
    873            entrybuf[3] = (png_byte)ep[i].alpha;
    874            png_save_uint_16(entrybuf + 4, ep[i].frequency);
    875        }
    876        else
    877        {
    878            png_save_uint_16(entrybuf + 0, ep[i].red);
    879            png_save_uint_16(entrybuf + 2, ep[i].green);
    880            png_save_uint_16(entrybuf + 4, ep[i].blue);
    881            png_save_uint_16(entrybuf + 6, ep[i].alpha);
    882            png_save_uint_16(entrybuf + 8, ep[i].frequency);
    883        }
    884        png_write_chunk_data(png_ptr, entrybuf, entry_size);
     898      if (spalette->depth == 8)
     899      {
     900          entrybuf[0] = (png_byte)ep[i].red;
     901          entrybuf[1] = (png_byte)ep[i].green;
     902          entrybuf[2] = (png_byte)ep[i].blue;
     903          entrybuf[3] = (png_byte)ep[i].alpha;
     904          png_save_uint_16(entrybuf + 4, ep[i].frequency);
     905      }
     906      else
     907      {
     908          png_save_uint_16(entrybuf + 0, ep[i].red);
     909          png_save_uint_16(entrybuf + 2, ep[i].green);
     910          png_save_uint_16(entrybuf + 4, ep[i].blue);
     911          png_save_uint_16(entrybuf + 6, ep[i].alpha);
     912          png_save_uint_16(entrybuf + 8, ep[i].frequency);
     913      }
     914      png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size);
    885915   }
    886916#endif
     
    892922
    893923#if defined(PNG_WRITE_sBIT_SUPPORTED)
    894 /* write the sBIT chunk */
     924/* Write the sBIT chunk */
    895925void /* PRIVATE */
    896926png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type)
     
    902932   png_size_t size;
    903933
    904    png_debug(1, "in png_write_sBIT\n");
    905    /* make sure we don't depend upon the order of PNG_COLOR_8 */
     934   png_debug(1, "in png_write_sBIT");
     935
     936   /* Make sure we don't depend upon the order of PNG_COLOR_8 */
    906937   if (color_type & PNG_COLOR_MASK_COLOR)
    907938   {
     
    943974   }
    944975
    945    png_write_chunk(png_ptr, png_sBIT, buf, size);
     976   png_write_chunk(png_ptr, (png_bytep)png_sBIT, buf, size);
    946977}
    947978#endif
    948979
    949980#if defined(PNG_WRITE_cHRM_SUPPORTED)
    950 /* write the cHRM chunk */
     981/* Write the cHRM chunk */
    951982#ifdef PNG_FLOATING_POINT_SUPPORTED
    952983void /* PRIVATE */
     
    959990#endif
    960991   png_byte buf[32];
    961    png_uint_32 itemp;
    962 
    963    png_debug(1, "in png_write_cHRM\n");
    964    /* each value is saved in 1/100,000ths */
    965    if (white_x < 0 || white_x > 0.8 || white_y < 0 || white_y > 0.8 ||
    966        white_x + white_y > 1.0)
    967    {
    968       png_warning(png_ptr, "Invalid cHRM white point specified");
    969 #if !defined(PNG_NO_CONSOLE_IO)
    970       fprintf(stderr,"white_x=%f, white_y=%f\n",white_x, white_y);
    971 #endif
    972       return;
    973    }
    974    itemp = (png_uint_32)(white_x * 100000.0 + 0.5);
    975    png_save_uint_32(buf, itemp);
    976    itemp = (png_uint_32)(white_y * 100000.0 + 0.5);
    977    png_save_uint_32(buf + 4, itemp);
    978 
    979    if (red_x < 0 ||  red_y < 0 || red_x + red_y > 1.0)
    980    {
    981       png_warning(png_ptr, "Invalid cHRM red point specified");
    982       return;
    983    }
    984    itemp = (png_uint_32)(red_x * 100000.0 + 0.5);
    985    png_save_uint_32(buf + 8, itemp);
    986    itemp = (png_uint_32)(red_y * 100000.0 + 0.5);
    987    png_save_uint_32(buf + 12, itemp);
    988 
    989    if (green_x < 0 || green_y < 0 || green_x + green_y > 1.0)
    990    {
    991       png_warning(png_ptr, "Invalid cHRM green point specified");
    992       return;
    993    }
    994    itemp = (png_uint_32)(green_x * 100000.0 + 0.5);
    995    png_save_uint_32(buf + 16, itemp);
    996    itemp = (png_uint_32)(green_y * 100000.0 + 0.5);
    997    png_save_uint_32(buf + 20, itemp);
    998 
    999    if (blue_x < 0 || blue_y < 0 || blue_x + blue_y > 1.0)
    1000    {
    1001       png_warning(png_ptr, "Invalid cHRM blue point specified");
    1002       return;
    1003    }
    1004    itemp = (png_uint_32)(blue_x * 100000.0 + 0.5);
    1005    png_save_uint_32(buf + 24, itemp);
    1006    itemp = (png_uint_32)(blue_y * 100000.0 + 0.5);
    1007    png_save_uint_32(buf + 28, itemp);
    1008 
    1009    png_write_chunk(png_ptr, png_cHRM, buf, (png_size_t)32);
     992
     993   png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y,
     994      int_green_x, int_green_y, int_blue_x, int_blue_y;
     995
     996   png_debug(1, "in png_write_cHRM");
     997
     998   int_white_x = (png_uint_32)(white_x * 100000.0 + 0.5);
     999   int_white_y = (png_uint_32)(white_y * 100000.0 + 0.5);
     1000   int_red_x   = (png_uint_32)(red_x   * 100000.0 + 0.5);
     1001   int_red_y   = (png_uint_32)(red_y   * 100000.0 + 0.5);
     1002   int_green_x = (png_uint_32)(green_x * 100000.0 + 0.5);
     1003   int_green_y = (png_uint_32)(green_y * 100000.0 + 0.5);
     1004   int_blue_x  = (png_uint_32)(blue_x  * 100000.0 + 0.5);
     1005   int_blue_y  = (png_uint_32)(blue_y  * 100000.0 + 0.5);
     1006
     1007#if !defined(PNG_NO_CHECK_cHRM)
     1008   if (png_check_cHRM_fixed(png_ptr, int_white_x, int_white_y,
     1009      int_red_x, int_red_y, int_green_x, int_green_y, int_blue_x, int_blue_y))
     1010#endif
     1011   {
     1012      /* Each value is saved in 1/100,000ths */
     1013
     1014      png_save_uint_32(buf, int_white_x);
     1015      png_save_uint_32(buf + 4, int_white_y);
     1016
     1017      png_save_uint_32(buf + 8, int_red_x);
     1018      png_save_uint_32(buf + 12, int_red_y);
     1019
     1020      png_save_uint_32(buf + 16, int_green_x);
     1021      png_save_uint_32(buf + 20, int_green_y);
     1022
     1023      png_save_uint_32(buf + 24, int_blue_x);
     1024      png_save_uint_32(buf + 28, int_blue_y);
     1025
     1026      png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32);
     1027   }
    10101028}
    10111029#endif
     
    10221040   png_byte buf[32];
    10231041
    1024    png_debug(1, "in png_write_cHRM\n");
    1025    /* each value is saved in 1/100,000ths */
    1026    if (white_x > 80000L || white_y > 80000L || white_x + white_y > 100000L)
    1027    {
    1028       png_warning(png_ptr, "Invalid fixed cHRM white point specified");
    1029 #if !defined(PNG_NO_CONSOLE_IO)
    1030       fprintf(stderr,"white_x=%ld, white_y=%ld\n",white_x, white_y);
    1031 #endif
    1032       return;
    1033    }
    1034    png_save_uint_32(buf, (png_uint_32)white_x);
    1035    png_save_uint_32(buf + 4, (png_uint_32)white_y);
    1036 
    1037    if (red_x + red_y > 100000L)
    1038    {
    1039       png_warning(png_ptr, "Invalid cHRM fixed red point specified");
    1040       return;
    1041    }
    1042    png_save_uint_32(buf + 8, (png_uint_32)red_x);
    1043    png_save_uint_32(buf + 12, (png_uint_32)red_y);
    1044 
    1045    if (green_x + green_y > 100000L)
    1046    {
    1047       png_warning(png_ptr, "Invalid fixed cHRM green point specified");
    1048       return;
    1049    }
    1050    png_save_uint_32(buf + 16, (png_uint_32)green_x);
    1051    png_save_uint_32(buf + 20, (png_uint_32)green_y);
    1052 
    1053    if (blue_x + blue_y > 100000L)
    1054    {
    1055       png_warning(png_ptr, "Invalid fixed cHRM blue point specified");
    1056       return;
    1057    }
    1058    png_save_uint_32(buf + 24, (png_uint_32)blue_x);
    1059    png_save_uint_32(buf + 28, (png_uint_32)blue_y);
    1060 
    1061    png_write_chunk(png_ptr, png_cHRM, buf, (png_size_t)32);
     1042   png_debug(1, "in png_write_cHRM");
     1043
     1044   /* Each value is saved in 1/100,000ths */
     1045#if !defined(PNG_NO_CHECK_cHRM)
     1046   if (png_check_cHRM_fixed(png_ptr, white_x, white_y, red_x, red_y,
     1047      green_x, green_y, blue_x, blue_y))
     1048#endif
     1049   {
     1050      png_save_uint_32(buf, (png_uint_32)white_x);
     1051      png_save_uint_32(buf + 4, (png_uint_32)white_y);
     1052
     1053      png_save_uint_32(buf + 8, (png_uint_32)red_x);
     1054      png_save_uint_32(buf + 12, (png_uint_32)red_y);
     1055
     1056      png_save_uint_32(buf + 16, (png_uint_32)green_x);
     1057      png_save_uint_32(buf + 20, (png_uint_32)green_y);
     1058
     1059      png_save_uint_32(buf + 24, (png_uint_32)blue_x);
     1060      png_save_uint_32(buf + 28, (png_uint_32)blue_y);
     1061
     1062      png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32);
     1063   }
    10621064}
    10631065#endif
     
    10651067
    10661068#if defined(PNG_WRITE_tRNS_SUPPORTED)
    1067 /* write the tRNS chunk */
     1069/* Write the tRNS chunk */
    10681070void /* PRIVATE */
    10691071png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
     
    10751077   png_byte buf[6];
    10761078
    1077    png_debug(1, "in png_write_tRNS\n");
     1079   png_debug(1, "in png_write_tRNS");
     1080
    10781081   if (color_type == PNG_COLOR_TYPE_PALETTE)
    10791082   {
    10801083      if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette)
    10811084      {
    1082          png_warning(png_ptr,"Invalid number of transparent colors specified");
     1085         png_warning(png_ptr, "Invalid number of transparent colors specified");
    10831086         return;
    10841087      }
    1085       /* write the chunk out as it is */
    1086       png_write_chunk(png_ptr, png_tRNS, trans, (png_size_t)num_trans);
     1088      /* Write the chunk out as it is */
     1089      png_write_chunk(png_ptr, (png_bytep)png_tRNS, trans,
     1090        (png_size_t)num_trans);
    10871091   }
    10881092   else if (color_type == PNG_COLOR_TYPE_GRAY)
    10891093   {
    1090       /* one 16 bit value */
    1091       if(tran->gray >= (1 << png_ptr->bit_depth))
     1094      /* One 16 bit value */
     1095      if (tran->gray >= (1 << png_ptr->bit_depth))
    10921096      {
    10931097         png_warning(png_ptr,
     
    10961100      }
    10971101      png_save_uint_16(buf, tran->gray);
    1098       png_write_chunk(png_ptr, png_tRNS, buf, (png_size_t)2);
     1102      png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)2);
    10991103   }
    11001104   else if (color_type == PNG_COLOR_TYPE_RGB)
    11011105   {
    1102       /* three 16 bit values */
     1106      /* Three 16 bit values */
    11031107      png_save_uint_16(buf, tran->red);
    11041108      png_save_uint_16(buf + 2, tran->green);
    11051109      png_save_uint_16(buf + 4, tran->blue);
    1106       if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))
    1107          {
    1108             png_warning(png_ptr,
    1109               "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8");
    1110             return;
    1111          }
    1112       png_write_chunk(png_ptr, png_tRNS, buf, (png_size_t)6);
     1110      if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))
     1111      {
     1112         png_warning(png_ptr,
     1113           "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8");
     1114         return;
     1115      }
     1116      png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)6);
    11131117   }
    11141118   else
     
    11201124
    11211125#if defined(PNG_WRITE_bKGD_SUPPORTED)
    1122 /* write the background chunk */
     1126/* Write the background chunk */
    11231127void /* PRIVATE */
    11241128png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
     
    11291133   png_byte buf[6];
    11301134
    1131    png_debug(1, "in png_write_bKGD\n");
     1135   png_debug(1, "in png_write_bKGD");
     1136
    11321137   if (color_type == PNG_COLOR_TYPE_PALETTE)
    11331138   {
     
    11371142          (!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) &&
    11381143#endif
    1139          back->index > png_ptr->num_palette)
     1144         back->index >= png_ptr->num_palette)
    11401145      {
    11411146         png_warning(png_ptr, "Invalid background palette index");
     
    11431148      }
    11441149      buf[0] = back->index;
    1145       png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)1);
     1150      png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)1);
    11461151   }
    11471152   else if (color_type & PNG_COLOR_MASK_COLOR)
     
    11501155      png_save_uint_16(buf + 2, back->green);
    11511156      png_save_uint_16(buf + 4, back->blue);
    1152       if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))
    1153          {
    1154             png_warning(png_ptr,
    1155               "Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8");
    1156             return;
    1157          }
    1158       png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)6);
     1157      if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))
     1158      {
     1159         png_warning(png_ptr,
     1160           "Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8");
     1161         return;
     1162      }
     1163      png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)6);
    11591164   }
    11601165   else
    11611166   {
    1162       if(back->gray >= (1 << png_ptr->bit_depth))
     1167      if (back->gray >= (1 << png_ptr->bit_depth))
    11631168      {
    11641169         png_warning(png_ptr,
     
    11671172      }
    11681173      png_save_uint_16(buf, back->gray);
    1169       png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)2);
     1174      png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)2);
    11701175   }
    11711176}
     
    11731178
    11741179#if defined(PNG_WRITE_hIST_SUPPORTED)
    1175 /* write the histogram */
     1180/* Write the histogram */
    11761181void /* PRIVATE */
    11771182png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)
     
    11831188   png_byte buf[3];
    11841189
    1185    png_debug(1, "in png_write_hIST\n");
     1190   png_debug(1, "in png_write_hIST");
     1191
    11861192   if (num_hist > (int)png_ptr->num_palette)
    11871193   {
    1188       png_debug2(3, "num_hist = %d, num_palette = %d\n", num_hist,
     1194      png_debug2(3, "num_hist = %d, num_palette = %d", num_hist,
    11891195         png_ptr->num_palette);
    11901196      png_warning(png_ptr, "Invalid number of histogram entries specified");
     
    11921198   }
    11931199
    1194    png_write_chunk_start(png_ptr, png_hIST, (png_uint_32)(num_hist * 2));
     1200   png_write_chunk_start(png_ptr, (png_bytep)png_hIST,
     1201     (png_uint_32)(num_hist * 2));
    11951202   for (i = 0; i < num_hist; i++)
    11961203   {
     
    12221229   int kwarn=0;
    12231230
    1224    png_debug(1, "in png_check_keyword\n");
     1231   png_debug(1, "in png_check_keyword");
     1232
    12251233   *new_key = NULL;
    12261234
     
    12311239   }
    12321240
    1233    png_debug1(2, "Keyword to be checked is '%s'\n", key);
     1241   png_debug1(2, "Keyword to be checked is '%s'", key);
    12341242
    12351243   *new_key = (png_charp)png_malloc_warn(png_ptr, (png_uint_32)(key_len + 2));
     
    12721280      while (*kp == ' ')
    12731281      {
    1274         *(kp--) = '\0';
    1275         key_len--;
     1282         *(kp--) = '\0';
     1283         key_len--;
    12761284      }
    12771285   }
     
    12851293      while (*kp == ' ')
    12861294      {
    1287         kp++;
    1288         key_len--;
    1289       }
    1290    }
    1291 
    1292    png_debug1(2, "Checking for multiple internal spaces in '%s'\n", kp);
     1295         kp++;
     1296         key_len--;
     1297      }
     1298   }
     1299
     1300   png_debug1(2, "Checking for multiple internal spaces in '%s'", kp);
    12931301
    12941302   /* Remove multiple internal spaces. */
     
    13121320   }
    13131321   *dp = '\0';
    1314    if(kwarn)
     1322   if (kwarn)
    13151323      png_warning(png_ptr, "extra interior spaces removed from keyword");
    13161324
     
    13181326   {
    13191327      png_free(png_ptr, *new_key);
    1320       *new_key=NULL;
     1328       *new_key=NULL;
    13211329      png_warning(png_ptr, "Zero length keyword");
    13221330   }
     
    13251333   {
    13261334      png_warning(png_ptr, "keyword length must be 1 - 79 characters");
    1327       new_key[79] = '\0';
     1335      (*new_key)[79] = '\0';
    13281336      key_len = 79;
    13291337   }
     
    13341342
    13351343#if defined(PNG_WRITE_tEXt_SUPPORTED)
    1336 /* write a tEXt chunk */
     1344/* Write a tEXt chunk */
    13371345void /* PRIVATE */
    13381346png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,
     
    13451353   png_charp new_key;
    13461354
    1347    png_debug(1, "in png_write_tEXt\n");
    1348    if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0)
    1349    {
    1350       png_warning(png_ptr, "Empty keyword in tEXt chunk");
     1355   png_debug(1, "in png_write_tEXt");
     1356
     1357   if ((key_len = png_check_keyword(png_ptr, key, &new_key))==0)
    13511358      return;
    1352    }
    13531359
    13541360   if (text == NULL || *text == '\0')
     
    13571363      text_len = png_strlen(text);
    13581364
    1359    /* make sure we include the 0 after the key */
    1360    png_write_chunk_start(png_ptr, png_tEXt, (png_uint_32)key_len+text_len+1);
     1365   /* Make sure we include the 0 after the key */
     1366   png_write_chunk_start(png_ptr, (png_bytep)png_tEXt,
     1367      (png_uint_32)(key_len + text_len + 1));
    13611368   /*
    13621369    * We leave it to the application to meet PNG-1.0 requirements on the
     
    13651372    * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG.
    13661373    */
    1367    png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1);
     1374   png_write_chunk_data(png_ptr, (png_bytep)new_key,
     1375     (png_size_t)(key_len + 1));
    13681376   if (text_len)
    1369       png_write_chunk_data(png_ptr, (png_bytep)text, text_len);
     1377      png_write_chunk_data(png_ptr, (png_bytep)text, (png_size_t)text_len);
    13701378
    13711379   png_write_chunk_end(png_ptr);
     
    13751383
    13761384#if defined(PNG_WRITE_zTXt_SUPPORTED)
    1377 /* write a compressed text chunk */
     1385/* Write a compressed text chunk */
    13781386void /* PRIVATE */
    13791387png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
     
    13881396   compression_state comp;
    13891397
    1390    png_debug(1, "in png_write_zTXt\n");
     1398   png_debug(1, "in png_write_zTXt");
    13911399
    13921400   comp.num_output_ptr = 0;
     
    13961404   comp.input_len = 0;
    13971405
    1398    if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0)
    1399    {
    1400       png_warning(png_ptr, "Empty keyword in zTXt chunk");
     1406   if ((key_len = png_check_keyword(png_ptr, key, &new_key))==0)
     1407   {
     1408      png_free(png_ptr, new_key);
    14011409      return;
    14021410   }
     
    14111419   text_len = png_strlen(text);
    14121420
    1413    /* compute the compressed data; do it now for the length */
     1421   /* Compute the compressed data; do it now for the length */
    14141422   text_len = png_text_compress(png_ptr, text, text_len, compression,
    14151423       &comp);
    14161424
    1417    /* write start of chunk */
    1418    png_write_chunk_start(png_ptr, png_zTXt, (png_uint_32)
    1419       (key_len+text_len+2));
    1420    /* write key */
    1421    png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1);
     1425   /* Write start of chunk */
     1426   png_write_chunk_start(png_ptr, (png_bytep)png_zTXt,
     1427     (png_uint_32)(key_len+text_len + 2));
     1428   /* Write key */
     1429   png_write_chunk_data(png_ptr, (png_bytep)new_key,
     1430     (png_size_t)(key_len + 1));
    14221431   png_free(png_ptr, new_key);
    14231432
    14241433   buf[0] = (png_byte)compression;
    1425    /* write compression */
     1434   /* Write compression */
    14261435   png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1);
    1427    /* write the compressed data */
     1436   /* Write the compressed data */
    14281437   png_write_compressed_data_out(png_ptr, &comp);
    14291438
    1430    /* close the chunk */
     1439   /* Close the chunk */
    14311440   png_write_chunk_end(png_ptr);
    14321441}
     
    14341443
    14351444#if defined(PNG_WRITE_iTXt_SUPPORTED)
    1436 /* write an iTXt chunk */
     1445/* Write an iTXt chunk */
    14371446void /* PRIVATE */
    14381447png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
     
    14431452#endif
    14441453   png_size_t lang_len, key_len, lang_key_len, text_len;
    1445    png_charp new_lang, new_key;
     1454   png_charp new_lang;
     1455   png_charp new_key = NULL;
    14461456   png_byte cbuf[2];
    14471457   compression_state comp;
    14481458
    1449    png_debug(1, "in png_write_iTXt\n");
     1459   png_debug(1, "in png_write_iTXt");
    14501460
    14511461   comp.num_output_ptr = 0;
     
    14541464   comp.input = NULL;
    14551465
    1456    if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0)
    1457    {
    1458       png_warning(png_ptr, "Empty keyword in iTXt chunk");
     1466   if ((key_len = png_check_keyword(png_ptr, key, &new_key))==0)
    14591467      return;
    1460    }
    1461    if (lang == NULL || (lang_len = png_check_keyword(png_ptr, lang, &new_lang))==0)
     1468
     1469   if ((lang_len = png_check_keyword(png_ptr, lang, &new_lang))==0)
    14621470   {
    14631471      png_warning(png_ptr, "Empty language field in iTXt chunk");
     
    14671475
    14681476   if (lang_key == NULL)
    1469      lang_key_len = 0;
     1477      lang_key_len = 0;
    14701478   else
    1471      lang_key_len = png_strlen(lang_key);
     1479      lang_key_len = png_strlen(lang_key);
    14721480
    14731481   if (text == NULL)
    14741482      text_len = 0;
    14751483   else
    1476      text_len = png_strlen(text);
    1477 
    1478    /* compute the compressed data; do it now for the length */
     1484      text_len = png_strlen(text);
     1485
     1486   /* Compute the compressed data; do it now for the length */
    14791487   text_len = png_text_compress(png_ptr, text, text_len, compression-2,
    14801488      &comp);
    14811489
    14821490
    1483    /* make sure we include the compression flag, the compression byte,
     1491   /* Make sure we include the compression flag, the compression byte,
    14841492    * and the NULs after the key, lang, and lang_key parts */
    14851493
    1486    png_write_chunk_start(png_ptr, png_iTXt,
     1494   png_write_chunk_start(png_ptr, (png_bytep)png_iTXt,
    14871495          (png_uint_32)(
    14881496        5 /* comp byte, comp flag, terminators for key, lang and lang_key */
     
    14921500        + text_len));
    14931501
    1494    /*
    1495     * We leave it to the application to meet PNG-1.0 requirements on the
     1502   /* We leave it to the application to meet PNG-1.0 requirements on the
    14961503    * contents of the text.  PNG-1.0 through PNG-1.2 discourage the use of
    14971504    * any non-Latin-1 characters except for NEWLINE.  ISO PNG will forbid them.
    14981505    * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG.
    14991506    */
    1500    png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1);
    1501 
    1502    /* set the compression flag */
     1507   png_write_chunk_data(png_ptr, (png_bytep)new_key,
     1508     (png_size_t)(key_len + 1));
     1509
     1510   /* Set the compression flag */
    15031511   if (compression == PNG_ITXT_COMPRESSION_NONE || \
    15041512       compression == PNG_TEXT_COMPRESSION_NONE)
     
    15061514   else /* compression == PNG_ITXT_COMPRESSION_zTXt */
    15071515       cbuf[0] = 1;
    1508    /* set the compression method */
     1516   /* Set the compression method */
    15091517   cbuf[1] = 0;
    1510    png_write_chunk_data(png_ptr, cbuf, 2);
     1518   png_write_chunk_data(png_ptr, cbuf, (png_size_t)2);
    15111519
    15121520   cbuf[0] = 0;
    1513    png_write_chunk_data(png_ptr, (new_lang ? (png_bytep)new_lang : cbuf), lang_len + 1);
    1514    png_write_chunk_data(png_ptr, (lang_key ? (png_bytep)lang_key : cbuf), lang_key_len + 1);
     1521   png_write_chunk_data(png_ptr, (new_lang ? (png_bytep)new_lang : cbuf),
     1522     (png_size_t)(lang_len + 1));
     1523   png_write_chunk_data(png_ptr, (lang_key ? (png_bytep)lang_key : cbuf),
     1524     (png_size_t)(lang_key_len + 1));
    15151525   png_write_compressed_data_out(png_ptr, &comp);
    15161526
     
    15221532
    15231533#if defined(PNG_WRITE_oFFs_SUPPORTED)
    1524 /* write the oFFs chunk */
     1534/* Write the oFFs chunk */
    15251535void /* PRIVATE */
    15261536png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset,
     
    15321542   png_byte buf[9];
    15331543
    1534    png_debug(1, "in png_write_oFFs\n");
     1544   png_debug(1, "in png_write_oFFs");
     1545
    15351546   if (unit_type >= PNG_OFFSET_LAST)
    15361547      png_warning(png_ptr, "Unrecognized unit type for oFFs chunk");
     
    15401551   buf[8] = (png_byte)unit_type;
    15411552
    1542    png_write_chunk(png_ptr, png_oFFs, buf, (png_size_t)9);
     1553   png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9);
    15431554}
    15441555#endif
    15451556#if defined(PNG_WRITE_pCAL_SUPPORTED)
    1546 /* write the pCAL chunk (described in the PNG extensions document) */
     1557/* Write the pCAL chunk (described in the PNG extensions document) */
    15471558void /* PRIVATE */
    15481559png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
     
    15581569   int i;
    15591570
    1560    png_debug1(1, "in png_write_pCAL (%d parameters)\n", nparams);
     1571   png_debug1(1, "in png_write_pCAL (%d parameters)", nparams);
     1572
    15611573   if (type >= PNG_EQUATION_LAST)
    15621574      png_warning(png_ptr, "Unrecognized equation type for pCAL chunk");
    15631575
    15641576   purpose_len = png_check_keyword(png_ptr, purpose, &new_purpose) + 1;
    1565    png_debug1(3, "pCAL purpose length = %d\n", (int)purpose_len);
     1577   png_debug1(3, "pCAL purpose length = %d", (int)purpose_len);
    15661578   units_len = png_strlen(units) + (nparams == 0 ? 0 : 1);
    1567    png_debug1(3, "pCAL units length = %d\n", (int)units_len);
     1579   png_debug1(3, "pCAL units length = %d", (int)units_len);
    15681580   total_len = purpose_len + units_len + 10;
    15691581
    1570    params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams
    1571       *png_sizeof(png_uint_32)));
     1582   params_len = (png_uint_32p)png_malloc(png_ptr,
     1583      (png_uint_32)(nparams * png_sizeof(png_uint_32)));
    15721584
    15731585   /* Find the length of each parameter, making sure we don't count the
     
    15761588   {
    15771589      params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1);
    1578       png_debug2(3, "pCAL parameter %d length = %lu\n", i, params_len[i]);
     1590      png_debug2(3, "pCAL parameter %d length = %lu", i,
     1591        (unsigned long) params_len[i]);
    15791592      total_len += (png_size_t)params_len[i];
    15801593   }
    15811594
    1582    png_debug1(3, "pCAL total length = %d\n", (int)total_len);
    1583    png_write_chunk_start(png_ptr, png_pCAL, (png_uint_32)total_len);
    1584    png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len);
     1595   png_debug1(3, "pCAL total length = %d", (int)total_len);
     1596   png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len);
     1597   png_write_chunk_data(png_ptr, (png_bytep)new_purpose,
     1598     (png_size_t)purpose_len);
    15851599   png_save_int_32(buf, X0);
    15861600   png_save_int_32(buf + 4, X1);
     
    16041618
    16051619#if defined(PNG_WRITE_sCAL_SUPPORTED)
    1606 /* write the sCAL chunk */
     1620/* Write the sCAL chunk */
    16071621#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO)
    16081622void /* PRIVATE */
     
    16151629   png_size_t total_len;
    16161630
    1617    png_debug(1, "in png_write_sCAL\n");
     1631   png_debug(1, "in png_write_sCAL");
    16181632
    16191633   buf[0] = (char)unit;
     
    16401654#endif
    16411655
    1642    png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len);
    1643    png_write_chunk(png_ptr, png_sCAL, (png_bytep)buf, total_len);
     1656   png_debug1(3, "sCAL total length = %u", (unsigned int)total_len);
     1657   png_write_chunk(png_ptr, (png_bytep)png_sCAL, (png_bytep)buf, total_len);
    16441658}
    16451659#else
     
    16551669   png_size_t wlen, hlen, total_len;
    16561670
    1657    png_debug(1, "in png_write_sCAL_s\n");
     1671   png_debug(1, "in png_write_sCAL_s");
    16581672
    16591673   wlen = png_strlen(width);
     
    16671681
    16681682   buf[0] = (png_byte)unit;
    1669    png_memcpy(buf + 1, width, wlen + 1);      /* append the '\0' here */
    1670    png_memcpy(buf + wlen + 2, height, hlen);  /* do NOT append the '\0' here */
    1671 
    1672    png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len);
    1673    png_write_chunk(png_ptr, png_sCAL, buf, total_len);
     1683   png_memcpy(buf + 1, width, wlen + 1);      /* Append the '\0' here */
     1684   png_memcpy(buf + wlen + 2, height, hlen);  /* Do NOT append the '\0' here */
     1685
     1686   png_debug1(3, "sCAL total length = %u", (unsigned int)total_len);
     1687   png_write_chunk(png_ptr, (png_bytep)png_sCAL, buf, total_len);
    16741688}
    16751689#endif
     
    16781692
    16791693#if defined(PNG_WRITE_pHYs_SUPPORTED)
    1680 /* write the pHYs chunk */
     1694/* Write the pHYs chunk */
    16811695void /* PRIVATE */
    16821696png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit,
     
    16891703   png_byte buf[9];
    16901704
    1691    png_debug(1, "in png_write_pHYs\n");
     1705   png_debug(1, "in png_write_pHYs");
     1706
    16921707   if (unit_type >= PNG_RESOLUTION_LAST)
    16931708      png_warning(png_ptr, "Unrecognized unit type for pHYs chunk");
     
    16971712   buf[8] = (png_byte)unit_type;
    16981713
    1699    png_write_chunk(png_ptr, png_pHYs, buf, (png_size_t)9);
     1714   png_write_chunk(png_ptr, (png_bytep)png_pHYs, buf, (png_size_t)9);
    17001715}
    17011716#endif
     
    17131728   png_byte buf[7];
    17141729
    1715    png_debug(1, "in png_write_tIME\n");
     1730   png_debug(1, "in png_write_tIME");
     1731
    17161732   if (mod_time->month  > 12 || mod_time->month  < 1 ||
    17171733       mod_time->day    > 31 || mod_time->day    < 1 ||
     
    17291745   buf[6] = mod_time->second;
    17301746
    1731    png_write_chunk(png_ptr, png_tIME, buf, (png_size_t)7);
    1732 }
    1733 #endif
    1734 
    1735 /* initializes the row writing capability of libpng */
     1747   png_write_chunk(png_ptr, (png_bytep)png_tIME, buf, (png_size_t)7);
     1748}
     1749#endif
     1750
     1751/* Initializes the row writing capability of libpng */
    17361752void /* PRIVATE */
    17371753png_write_start_row(png_structp png_ptr)
     
    17391755#ifdef PNG_WRITE_INTERLACING_SUPPORTED
    17401756#ifdef PNG_USE_LOCAL_ARRAYS
    1741    /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    1742 
    1743    /* start of interlace block */
     1757   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
     1758
     1759   /* Start of interlace block */
    17441760   int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
    17451761
    1746    /* offset to next interlace block */
     1762   /* Offset to next interlace block */
    17471763   int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
    17481764
    1749    /* start of interlace block in the y direction */
     1765   /* Start of interlace block in the y direction */
    17501766   int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
    17511767
    1752    /* offset to next interlace block in the y direction */
     1768   /* Offset to next interlace block in the y direction */
    17531769   int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
    17541770#endif
     
    17571773   png_size_t buf_size;
    17581774
    1759    png_debug(1, "in png_write_start_row\n");
     1775   png_debug(1, "in png_write_start_row");
     1776
    17601777   buf_size = (png_size_t)(PNG_ROWBYTES(
    1761       png_ptr->usr_channels*png_ptr->usr_bit_depth,png_ptr->width)+1);
    1762 
    1763    /* set up row buffer */
    1764    png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size);
     1778      png_ptr->usr_channels*png_ptr->usr_bit_depth, png_ptr->width) + 1);
     1779
     1780   /* Set up row buffer */
     1781   png_ptr->row_buf = (png_bytep)png_malloc(png_ptr,
     1782     (png_uint_32)buf_size);
    17651783   png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE;
    17661784
    1767 #ifndef PNG_NO_WRITE_FILTERING
    1768    /* set up filtering buffer, if using this filter */
     1785#ifndef PNG_NO_WRITE_FILTER
     1786   /* Set up filtering buffer, if using this filter */
    17691787   if (png_ptr->do_filter & PNG_FILTER_SUB)
    17701788   {
    17711789      png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
    1772          (png_ptr->rowbytes + 1));
     1790         (png_uint_32)(png_ptr->rowbytes + 1));
    17731791      png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
    17741792   }
     
    17771795   if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH))
    17781796   {
    1779      /* set up previous row buffer */
    1780       png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size);
    1781       png_memset(png_ptr->prev_row, 0, buf_size);
     1797     /* Set up previous row buffer */
     1798     png_ptr->prev_row = (png_bytep)png_malloc(png_ptr,
     1799        (png_uint_32)buf_size);
     1800     png_memset(png_ptr->prev_row, 0, buf_size);
    17821801
    17831802      if (png_ptr->do_filter & PNG_FILTER_UP)
    17841803      {
    17851804         png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
    1786             (png_ptr->rowbytes + 1));
     1805           (png_uint_32)(png_ptr->rowbytes + 1));
    17871806         png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
    17881807      }
     
    17911810      {
    17921811         png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
    1793             (png_ptr->rowbytes + 1));
     1812           (png_uint_32)(png_ptr->rowbytes + 1));
    17941813         png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
    17951814      }
     
    17981817      {
    17991818         png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
    1800             (png_ptr->rowbytes + 1));
     1819           (png_uint_32)(png_ptr->rowbytes + 1));
    18011820         png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
    18021821      }
    1803 #endif /* PNG_NO_WRITE_FILTERING */
    1804    }
     1822   }
     1823#endif /* PNG_NO_WRITE_FILTER */
    18051824
    18061825#ifdef PNG_WRITE_INTERLACING_SUPPORTED
    1807    /* if interlaced, we need to set up width and height of pass */
     1826   /* If interlaced, we need to set up width and height of pass */
    18081827   if (png_ptr->interlaced)
    18091828   {
     
    18371856#ifdef PNG_WRITE_INTERLACING_SUPPORTED
    18381857#ifdef PNG_USE_LOCAL_ARRAYS
    1839    /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    1840 
    1841    /* start of interlace block */
     1858   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
     1859
     1860   /* Start of interlace block */
    18421861   int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
    18431862
    1844    /* offset to next interlace block */
     1863   /* Offset to next interlace block */
    18451864   int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
    18461865
    1847    /* start of interlace block in the y direction */
     1866   /* Start of interlace block in the y direction */
    18481867   int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
    18491868
    1850    /* offset to next interlace block in the y direction */
     1869   /* Offset to next interlace block in the y direction */
    18511870   int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
    18521871#endif
     
    18551874   int ret;
    18561875
    1857    png_debug(1, "in png_write_finish_row\n");
    1858    /* next row */
     1876   png_debug(1, "in png_write_finish_row");
     1877
     1878   /* Next row */
    18591879   png_ptr->row_number++;
    18601880
    1861    /* see if we are done */
     1881   /* See if we are done */
    18621882   if (png_ptr->row_number < png_ptr->num_rows)
    18631883      return;
    18641884
    18651885#ifdef PNG_WRITE_INTERLACING_SUPPORTED
    1866    /* if interlaced, go to next pass */
     1886   /* If interlaced, go to next pass */
    18671887   if (png_ptr->interlaced)
    18681888   {
     
    18741894      else
    18751895      {
    1876          /* loop until we find a non-zero width or height pass */
     1896         /* Loop until we find a non-zero width or height pass */
    18771897         do
    18781898         {
     
    18941914      }
    18951915
    1896       /* reset the row above the image for the next pass */
     1916      /* Reset the row above the image for the next pass */
    18971917      if (png_ptr->pass < 7)
    18981918      {
     
    19001920            png_memset(png_ptr->prev_row, 0,
    19011921               (png_size_t)(PNG_ROWBYTES(png_ptr->usr_channels*
    1902                png_ptr->usr_bit_depth,png_ptr->width))+1);
     1922               png_ptr->usr_bit_depth, png_ptr->width)) + 1);
    19031923         return;
    19041924      }
     
    19061926#endif
    19071927
    1908    /* if we get here, we've just written the last row, so we need
     1928   /* If we get here, we've just written the last row, so we need
    19091929      to flush the compressor */
    19101930   do
    19111931   {
    1912       /* tell the compressor we are done */
     1932      /* Tell the compressor we are done */
    19131933      ret = deflate(&png_ptr->zstream, Z_FINISH);
    1914       /* check for an error */
     1934      /* Check for an error */
    19151935      if (ret == Z_OK)
    19161936      {
    1917          /* check to see if we need more room */
     1937         /* Check to see if we need more room */
    19181938         if (!(png_ptr->zstream.avail_out))
    19191939         {
     
    19321952   } while (ret != Z_STREAM_END);
    19331953
    1934    /* write any extra space */
     1954   /* Write any extra space */
    19351955   if (png_ptr->zstream.avail_out < png_ptr->zbuf_size)
    19361956   {
     
    19551975{
    19561976#ifdef PNG_USE_LOCAL_ARRAYS
    1957    /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    1958 
    1959    /* start of interlace block */
     1977   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
     1978
     1979   /* Start of interlace block */
    19601980   int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
    19611981
    1962    /* offset to next interlace block */
     1982   /* Offset to next interlace block */
    19631983   int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
    19641984#endif
    19651985
    1966    png_debug(1, "in png_do_write_interlace\n");
    1967    /* we don't have to do anything on the last pass (6) */
     1986   png_debug(1, "in png_do_write_interlace");
     1987
     1988   /* We don't have to do anything on the last pass (6) */
    19681989#if defined(PNG_USELESS_TESTS_SUPPORTED)
    19691990   if (row != NULL && row_info != NULL && pass < 6)
     
    19721993#endif
    19731994   {
    1974       /* each pixel depth is handled separately */
     1995      /* Each pixel depth is handled separately */
    19751996      switch (row_info->pixel_depth)
    19761997      {
     
    20832104            png_size_t pixel_bytes;
    20842105
    2085             /* start at the beginning */
     2106            /* Start at the beginning */
    20862107            dp = row;
    2087             /* find out how many bytes each pixel takes up */
     2108            /* Find out how many bytes each pixel takes up */
    20882109            pixel_bytes = (row_info->pixel_depth >> 3);
    2089             /* loop through the row, only looking at the pixels that
     2110            /* Loop through the row, only looking at the pixels that
    20902111               matter */
    20912112            for (i = png_pass_start[pass]; i < row_width;
    20922113               i += png_pass_inc[pass])
    20932114            {
    2094                /* find out where the original pixel is */
     2115               /* Find out where the original pixel is */
    20952116               sp = row + (png_size_t)i * pixel_bytes;
    2096                /* move the pixel */
     2117               /* Move the pixel */
    20972118               if (dp != sp)
    20982119                  png_memcpy(dp, sp, pixel_bytes);
    2099                /* next pixel */
     2120               /* Next pixel */
    21002121               dp += pixel_bytes;
    21012122            }
     
    21032124         }
    21042125      }
    2105       /* set new row width */
     2126      /* Set new row width */
    21062127      row_info->width = (row_info->width +
    21072128         png_pass_inc[pass] - 1 -
     
    21312152   png_byte filter_to_do = png_ptr->do_filter;
    21322153   png_uint_32 row_bytes = row_info->rowbytes;
    2133 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
     2154#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
    21342155   int num_p_filters = (int)png_ptr->num_prev_filters;
    2135 #endif
    2136 
    2137    png_debug(1, "in png_write_find_filter\n");
    2138    /* find out how many bytes offset each pixel is */
     2156#endif
     2157
     2158   png_debug(1, "in png_write_find_filter");
     2159
     2160   /* Find out how many bytes offset each pixel is */
    21392161   bpp = (row_info->pixel_depth + 7) >> 3;
    21402162
     
    22232245   }
    22242246
    2225    /* sub filter */
     2247   /* Sub filter */
    22262248   if (filter_to_do == PNG_FILTER_SUB)
    2227    /* it's the only filter so no testing is needed */
     2249   /* It's the only filter so no testing is needed */
    22282250   {
    22292251      png_bytep rp, lp, dp;
     
    23402362   }
    23412363
    2342    /* up filter */
     2364   /* Up filter */
    23432365   if (filter_to_do == PNG_FILTER_UP)
    23442366   {
     
    24432465   }
    24442466
    2445    /* avg filter */
     2467   /* Avg filter */
    24462468   if (filter_to_do == PNG_FILTER_AVG)
    24472469   {
     
    27442766png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row)
    27452767{
    2746    png_debug(1, "in png_write_filtered_row\n");
    2747    png_debug1(2, "filter = %d\n", filtered_row[0]);
    2748    /* set up the zlib input buffer */
     2768   png_debug(1, "in png_write_filtered_row");
     2769
     2770   png_debug1(2, "filter = %d", filtered_row[0]);
     2771   /* Set up the zlib input buffer */
    27492772
    27502773   png_ptr->zstream.next_in = filtered_row;
    27512774   png_ptr->zstream.avail_in = (uInt)png_ptr->row_info.rowbytes + 1;
    2752    /* repeat until we have compressed all the data */
     2775   /* Repeat until we have compressed all the data */
    27532776   do
    27542777   {
    2755       int ret; /* return of zlib */
    2756 
    2757       /* compress the data */
     2778      int ret; /* Return of zlib */
     2779
     2780      /* Compress the data */
    27582781      ret = deflate(&png_ptr->zstream, Z_NO_FLUSH);
    2759       /* check for compression errors */
     2782      /* Check for compression errors */
    27602783      if (ret != Z_OK)
    27612784      {
     
    27662789      }
    27672790
    2768       /* see if it is time to write another IDAT */
     2791      /* See if it is time to write another IDAT */
    27692792      if (!(png_ptr->zstream.avail_out))
    27702793      {
    2771          /* write the IDAT and reset the zlib output buffer */
     2794         /* Write the IDAT and reset the zlib output buffer */
    27722795         png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);
    27732796         png_ptr->zstream.next_out = png_ptr->zbuf;
    27742797         png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
    27752798      }
    2776    /* repeat until all data has been compressed */
     2799   /* Repeat until all data has been compressed */
    27772800   } while (png_ptr->zstream.avail_in);
    27782801
    2779    /* swap the current and previous rows */
     2802   /* Swap the current and previous rows */
    27802803   if (png_ptr->prev_row != NULL)
    27812804   {
     
    27872810   }
    27882811
    2789    /* finish row - updates counters and flushes zlib if last row */
     2812   /* Finish row - updates counters and flushes zlib if last row */
    27902813   png_write_finish_row(png_ptr);
    27912814
  • trunk/src/3rdparty/libpng/scripts/CMakeLists.txt

    r2 r561  
    1                                              
    2 project(PNG)
     1project(PNG C)
     2cmake_minimum_required(VERSION 2.4.3)
    33
    44# Copyright (C) 2007 Glenn Randers-Pehrson
    5 # For conditions of distribution and use, see copyright notice in png.h
     5
     6# This code is released under the libpng license.
     7# For conditions of distribution and use, see the disclaimer
     8# and license in png.h
    69
    710set(PNGLIB_MAJOR 1)
    811set(PNGLIB_MINOR 2)
    9 set(PNGLIB_RELEASE 29)
     12set(PNGLIB_RELEASE 40)
    1013set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
    1114set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
    1215
     16set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
     17
    1318# needed packages
    1419find_package(ZLIB REQUIRED)
     20include_directories(${ZLIB_INCLUDE_DIR})
     21
    1522if(NOT WIN32)
    1623 find_library(M_LIBRARY
     
    2128   message(STATUS
    2229     "math library 'libm' not found - floating point support disabled")
    23  endif(NOT M_LIBRARY)
    24 else(NOT WIN32)
     30 endif()
     31else()
    2532 # not needed on windows
    2633 set(M_LIBRARY "")
    27 endif(NOT WIN32)
    28 
     34endif()
    2935
    3036# COMMAND LINE OPTIONS
    31 option(PNG_SHARED "Build shared lib" YES)
    32 option(PNG_STATIC "Build static lib" YES)
     37if(DEFINED PNG_SHARED)
     38  option(PNG_SHARED "Build shared lib" ${PNG_SHARED})
     39else()
     40  option(PNG_SHARED "Build shared lib" ON)
     41endif()
     42if(DEFINED PNG_STATIC)
     43  option(PNG_STATIC "Build static lib" ${PNG_STATIC})
     44else()
     45  option(PNG_STATIC "Build static lib" ON)
     46endif()
     47
    3348if(MINGW)
    3449  option(PNG_TESTS  "Build pngtest" NO)
     
    3651  option(PNG_TESTS  "Build pngtest" YES)
    3752endif(MINGW)
     53
    3854option(PNG_NO_CONSOLE_IO "FIXME" YES)
    3955option(PNG_NO_STDIO      "FIXME" YES)
    40 option(PNG_DEBUG         "Build with debug output" YES)
     56option(PNG_DEBUG         "Build with debug output" NO)
    4157option(PNGARG            "FIXME" YES)
    4258#TODO:
     
    5571   endif("uname_output" MATCHES "^.*i[1-9]86.*$")
    5672 endif(uname_executable)
    57 else(NOT WIN32)
     73else()
    5874 # this env var is normally only set on win64
    5975 SET(TEXT "ProgramFiles(x86)")
     
    6177  set(png_asm_tmp "ON")
    6278 endif("$ENV{${TEXT}}" STREQUAL "")
    63 endif(NOT WIN32)
     79endif()
    6480
    6581# SET LIBNAME
    66 # msvc does not append 'lib' - do it here to have consistent name
    67 if(MSVC)
    68  set(PNG_LIB_NAME lib)
    69 endif(MSVC)
    70 set(PNG_LIB_NAME ${PNG_LIB_NAME}png${PNGLIB_MAJOR}${PNGLIB_MINOR})
     82set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
    7183
    7284# to distinguish between debug and release lib
     
    102114endif(MSVC)
    103115
    104 add_definitions(-DZLIB_DLL)
     116if(PNG_SHARED OR  NOT MSVC)
     117        #if building msvc static this has NOT do be defined
     118        add_definitions(-DZLIB_DLL)
     119endif()
    105120
    106121add_definitions(-DLIBPNG_NO_MMX)
     
    109124if(PNG_CONSOLE_IO_SUPPORTED)
    110125 add_definitions(-DPNG_CONSOLE_IO_SUPPORTED)
    111 endif(PNG_CONSOLE_IO_SUPPORTED)
     126endif()
    112127
    113128if(PNG_NO_CONSOLE_IO)
    114129 add_definitions(-DPNG_NO_CONSOLE_IO)
    115 endif(PNG_NO_CONSOLE_IO)
     130endif()
    116131
    117132if(PNG_NO_STDIO)
    118133 add_definitions(-DPNG_NO_STDIO)
    119 endif(PNG_NO_STDIO)
     134endif()
    120135
    121136if(PNG_DEBUG)
    122137 add_definitions(-DPNG_DEBUG)
    123 endif(PNG_DEBUG)
     138endif()
    124139
    125140if(NOT M_LIBRARY AND NOT WIN32)
    126141 add_definitions(-DPNG_NO_FLOATING_POINT_SUPPORTED)
    127 endif(NOT M_LIBRARY AND NOT WIN32)
     142endif()
    128143
    129144# NOW BUILD OUR TARGET
     
    132147if(PNG_SHARED)
    133148 add_library(${PNG_LIB_NAME} SHARED ${libpng_sources})
     149 if(MSVC)
     150   # msvc does not append 'lib' - do it here to have consistent name
     151   set_target_properties(${PNG_LIB_NAME} PROPERTIES PREFIX "lib")
     152 endif()
    134153 target_link_libraries(${PNG_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY})
    135 endif(PNG_SHARED)
     154endif()
     155
    136156if(PNG_STATIC)
    137157# does not work without changing name
    138158 set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static)
    139159 add_library(${PNG_LIB_NAME_STATIC} STATIC ${libpng_sources})
    140 endif(PNG_STATIC)
     160 if(MSVC)
     161   # msvc does not append 'lib' - do it here to have consistent name
     162   set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES PREFIX "lib")
     163 endif()
     164endif()
     165
    141166
    142167if(PNG_SHARED AND WIN32)
    143168 set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
    144 endif(PNG_SHARED AND WIN32)
    145 
    146 if(PNG_TESTS)
     169endif()
     170
     171if(PNG_TESTS AND PNG_SHARED)
    147172# does not work with msvc due to png_lib_ver issue
    148173 add_executable(pngtest ${pngtest_sources})
    149174 target_link_libraries(pngtest ${PNG_LIB_NAME})
    150175#  add_test(pngtest ${PNG_SOURCE_DIR}/pngtest.png)
    151 endif(PNG_TESTS)
     176endif()
    152177
    153178
     
    169194
    170195# SET UP LINKS
    171 set_target_properties(${PNG_LIB_NAME} PROPERTIES
    172 #    VERSION 0.${PNGLIB_RELEASE}.1.2.29
     196if(PNG_SHARED)
     197  set_target_properties(${PNG_LIB_NAME} PROPERTIES
     198#    VERSION 0.${PNGLIB_RELEASE}.1.2.40
    173199     VERSION 0.${PNGLIB_RELEASE}.0
    174200     SOVERSION 0
    175201     CLEAN_DIRECT_OUTPUT 1)
    176 if(NOT WIN32)
    177   # that's uncool on win32 - it overwrites our static import lib...
    178   set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES
    179      OUTPUT_NAME ${PNG_LIB_NAME}
    180      CLEAN_DIRECT_OUTPUT 1)
    181 endif(NOT WIN32)
     202endif()
     203if(PNG_STATIC)
     204  if(NOT WIN32)
     205    # that's uncool on win32 - it overwrites our static import lib...
     206    set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES
     207       OUTPUT_NAME ${PNG_LIB_NAME}
     208       CLEAN_DIRECT_OUTPUT 1)
     209  endif()
     210endif()
     211
    182212# INSTALL
    183 install_targets(/lib ${PNG_LIB_NAME})
    184 if(PNG_STATIC)
    185   install_targets(/lib ${PNG_LIB_NAME_STATIC})
    186 endif(PNG_STATIC)
    187 
     213if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
     214    if(PNG_SHARED)
     215        install(TARGETS ${PNG_LIB_NAME}
     216            RUNTIME DESTINATION bin
     217            LIBRARY DESTINATION lib
     218            ARCHIVE DESTINATION lib)
     219    endif()
     220    if(PNG_STATIC)
     221        install(TARGETS ${PNG_LIB_NAME_STATIC}
     222            LIBRARY DESTINATION lib
     223            ARCHIVE DESTINATION lib)
     224    endif()
     225endif()
     226
     227if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
    188228install(FILES png.h pngconf.h         DESTINATION include)
    189229install(FILES png.h pngconf.h         DESTINATION include/${PNGLIB_NAME})
    190 install(FILES libpng.3 libpngpf.3             DESTINATION man/man3)
    191 install(FILES png.5                           DESTINATION man/man5)
    192 install(FILES ${PNG_BINARY_DIR}/libpng.pc     DESTINATION lib/pkgconfig)
    193 install(FILES ${PNG_BINARY_DIR}/libpng-config      DESTINATION bin)
    194 install(FILES ${PNG_BINARY_DIR}/${PNGLIB_NAME}.pc  DESTINATION lib/pkgconfig)
    195 install(FILES ${PNG_BINARY_DIR}/${PNGLIB_NAME}-config DESTINATION bin)
     230endif()
     231if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
     232    install(FILES libpng.3 libpngpf.3             DESTINATION man/man3)
     233    install(FILES png.5                           DESTINATION man/man5)
     234    install(FILES ${PNG_BINARY_DIR}/libpng.pc     DESTINATION lib/pkgconfig)
     235    install(FILES ${PNG_BINARY_DIR}/libpng-config      DESTINATION bin)
     236    install(FILES ${PNG_BINARY_DIR}/${PNGLIB_NAME}.pc  DESTINATION lib/pkgconfig)
     237    install(FILES ${PNG_BINARY_DIR}/${PNGLIB_NAME}-config DESTINATION bin)
     238endif()
    196239
    197240# what's with libpng.txt and all the extra files?
  • trunk/src/3rdparty/libpng/scripts/descrip.mms

    r2 r561  
    11
    22cc_defs = /inc=$(ZLIBSRC)
    3 c_deb = 
     3c_deb =
    44
    55.ifdef __DECC__
     
    3030
    3131clean :
    32         delete *.obj;*,*.exe;*
     32        delete *.obj;*,*.exe;
    3333
    3434
     
    4545pngrio.obj : png.h, pngconf.h
    4646pngwio.obj : png.h, pngconf.h
    47 pngtest.obj : png.h, pngconf.h
    4847pngtrans.obj : png.h, pngconf.h
    4948pngwrite.obj : png.h, pngconf.h
     
    5150pngwutil.obj : png.h, pngconf.h
    5251
     52pngtest.obj : png.h, pngconf.h
  • trunk/src/3rdparty/libpng/scripts/libpng-config-head.in

    r2 r561  
    55
    66# Copyright (C) 2002 Glenn Randers-Pehrson
    7 # For conditions of distribution and use, see copyright notice in png.h
     7
     8# This code is released under the libpng license.
     9# For conditions of distribution and use, see the disclaimer
     10# and license in png.h
    811
    912# Modeled after libxml-config.
    1013
    11 version=1.2.29
     14version=1.2.40
    1215prefix=""
    1316libdir=""
  • trunk/src/3rdparty/libpng/scripts/libpng-config.in

    r2 r561  
    55
    66# Copyright (C) 2002, 2004, 2006, 2007 Glenn Randers-Pehrson
    7 # For conditions of distribution and use, see copyright notice in png.h
     7
     8# This code is released under the libpng license.
     9# For conditions of distribution and use, see the disclaimer
     10# and license in png.h
    811
    912# Modeled after libxml-config.
     
    1518includedir="@includedir@/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@"
    1619libs="-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@"
    17 all_libs="-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ -lz -lm"
     20all_libs="-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ @LIBS@"
    1821I_opts="-I${includedir}"
    1922L_opts="-L${libdir}"
  • trunk/src/3rdparty/libpng/scripts/libpng.icc

    r2 r561  
    22// IBM VisualAge/C++ version 4.0 or later
    33// Copyright (C) 2000 Cosmin Truta
    4 // For conditions of distribution and use, see copyright notice in png.h
     4//
     5// This code is released under the libpng license.
     6// For conditions of distribution and use, see the disclaimer
     7// and license in png.h
     8//
    59// Notes:
    610//   All modules are compiled in C mode
     
    812//   Expected to work with IBM VAC++ 4.0 or later under OS/2 and Win32
    913//   Can be easily adapted for IBM VAC++ 4.0 or later under AIX
    10 // For conditions of distribution and use, see copyright notice in png.h
    1114
    1215option incl(searchpath, "../zlib"), opt(level, "2"),
  • trunk/src/3rdparty/libpng/scripts/libpng.pc-configure.in

    r2 r561  
    22exec_prefix=@exec_prefix@
    33libdir=@libdir@
    4 includedir=@includedir@/libpng12
     4includedir=@includedir@/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
    55
    66Name: libpng
    77Description: Loads and saves PNG files
    8 Version: 1.2.29
    9 Libs: -L${libdir} -lpng12
     8Version: @PNGLIB_VERSION@
     9Libs: -L${libdir} -lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
     10Libs.private: @LIBS@
    1011Cflags: -I${includedir} @LIBPNG_NO_MMX@
  • trunk/src/3rdparty/libpng/scripts/libpng.pc.in

    r2 r561  
    66Name: libpng
    77Description: Loads and saves PNG files
    8 Version: 1.2.29
     8Version: 1.2.40
    99Libs: -L${libdir} -lpng12
    1010Cflags: -I${includedir}
  • trunk/src/3rdparty/libpng/scripts/makefile.32sunu

    r2 r561  
    44# Copyright (C) 1998 Greg Roelofs
    55# Copyright (C) 1996, 1997 Andreas Dilger
    6 # For conditions of distribution and use, see copyright notice in png.h
     6
     7# This code is released under the libpng license.
     8# For conditions of distribution and use, see the disclaimer
     9# and license in png.h
    710
    811# Library name:
    912LIBNAME=libpng12
    1013PNGMAJ = 0
    11 PNGMIN = 1.2.29
     14PNGMIN = 1.2.40
    1215PNGVER = $(PNGMAJ).$(PNGMIN)
    1316
  • trunk/src/3rdparty/libpng/scripts/makefile.64sunu

    r2 r561  
    44# Copyright (C) 1998 Greg Roelofs
    55# Copyright (C) 1996, 1997 Andreas Dilger
    6 # For conditions of distribution and use, see copyright notice in png.h
     6
     7# This code is released under the libpng license.
     8# For conditions of distribution and use, see the disclaimer
     9# and license in png.h
    710
    811# Library name:
    912LIBNAME=libpng12
    1013PNGMAJ = 0
    11 PNGMIN = 1.2.29
     14PNGMIN = 1.2.40
    1215PNGVER = $(PNGMAJ).$(PNGMIN)
    1316
  • trunk/src/3rdparty/libpng/scripts/makefile.acorn

    r2 r561  
    77Linkflags = -aif -c++ -o $@
    88ObjAsmflags = -throwback -NoCache -depend !Depend
    9 CMHGflags = 
     9CMHGflags =
    1010LibFileflags = -c -l -o $@
    1111Squeezeflags = -o $@
    12 
    1312
    1413# Final targets:
  • trunk/src/3rdparty/libpng/scripts/makefile.aix

    r2 r561  
    11# makefile for libpng using gcc (generic, static library)
    2 # Copyright (C) 2002, 2006 Glenn Randers-Pehrson
     2# Copyright (C) 2002, 2006-2009 Glenn Randers-Pehrson
    33# Copyright (C) 2000 Cosmin Truta
    44# Copyright (C) 2000 Marc O. Gloor (AIX support added, from makefile.gcc)
    55# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
    6 # For conditions of distribution and use, see copyright notice in png.h
     6
     7# This code is released under the libpng license.
     8# For conditions of distribution and use, see the disclaimer
     9# and license in png.h
    710
    811# Location of the zlib library and include files
     
    2124LIBNAME=libpng12
    2225PNGMAJ = 0
    23 PNGMIN = 1.2.29
     26PNGMIN = 1.2.40
    2427PNGVER = $(PNGMAJ).$(PNGMIN)
    2528
     
    4548CRELEASE = -O2
    4649LDRELEASE = -s
    47 WARNMORE=-Wall
     50WARNMORE=-W -Wall
    4851CFLAGS = -I$(ZLIBINC) $(WARNMORE) $(CRELEASE)
    4952LDFLAGS = -L. -L$(ZLIBLIB) -lpng12 -lz -lm $(LDRELEASE)
     
    5558
    5659# Variables
    57 OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \
     60OBJS =  png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \
    5861        pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \
    5962        pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O)
     
    9598        $(RM_F) *.o $(LIBNAME)$(A) pngtest pngout.png
    9699
    97 png$(O): png.h pngconf.h
     100png$(O):      png.h pngconf.h
    98101pngerror$(O): png.h pngconf.h
    99 pngget$(O): png.h pngconf.h
    100 pngmem$(O): png.h pngconf.h
     102pngget$(O):   png.h pngconf.h
     103pngmem$(O):   png.h pngconf.h
    101104pngpread$(O): png.h pngconf.h
    102 pngread$(O): png.h pngconf.h
    103 pngrio$(O): png.h pngconf.h
     105pngread$(O):  png.h pngconf.h
     106pngrio$(O):   png.h pngconf.h
    104107pngrtran$(O): png.h pngconf.h
    105108pngrutil$(O): png.h pngconf.h
    106 pngset$(O): png.h pngconf.h
    107 pngtest$(O): png.h pngconf.h
     109pngset$(O):   png.h pngconf.h
    108110pngtrans$(O): png.h pngconf.h
    109 pngwio$(O): png.h pngconf.h
     111pngwio$(O):   png.h pngconf.h
    110112pngwrite$(O): png.h pngconf.h
    111113pngwtran$(O): png.h pngconf.h
    112114pngwutil$(O): png.h pngconf.h
    113115
     116pngtest$(O):  png.h pngconf.h
  • trunk/src/3rdparty/libpng/scripts/makefile.amiga

    r2 r561  
    22# makefile for libpng and SAS C V6.5x compiler
    33# Copyright (C) 1995-2000 Wolf Faust
    4 # For conditions of distribution and use, see copyright notice in png.h
     4
     5# This code is released under the libpng license.
     6# For conditions of distribution and use, see the disclaimer
     7# and license in png.h
    58#
    69# Note: Use #define PNG_READ_BIG_ENDIAN_SUPPORTED in pngconf.h
  • trunk/src/3rdparty/libpng/scripts/makefile.atari

    r2 r561  
    22# Copyright (C) 2002 Glenn Randers-Pehrson
    33# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
    4 # For conditions of distribution and use, see copyright notice in png.h
    5 # modified for LC56/ATARI assumes libz.lib is in same dir and uses default
     4
     5# This code is released under the libpng license.
     6# For conditions of distribution and use, see the disclaimer
     7# and license in png.h
     8
     9# Modified for LC56/ATARI assumes libz.lib is in same dir and uses default
    610# rules for library management
    711#
  • trunk/src/3rdparty/libpng/scripts/makefile.bc32

    r2 r561  
    1111## Where zlib.h, zconf.h and zlib.lib are
    1212ZLIB_DIR=..\zlib
    13 
    1413
    1514## Compiler, linker and lib stuff
     
    5049LDFLAGS=-L$(ZLIB_DIR) -M $(LDEBUG)
    5150
    52 
    5351## Variables
    5452OBJS = \
     
    8886LIBNAME=libpng.lib
    8987
    90 
    9188## Implicit rules
    9289# Braces let make "batch" calls to the compiler,
     
    10198        $(LD) $(LDFLAGS) $*.obj $(LIBNAME) zlib.lib $(NOEHLIB)
    10299
    103 
    104100## Major targets
    105101all: libpng pngtest
     
    112108        pngtest
    113109
    114 
    115110## Minor Targets
    116111
    117 png.obj: png.c
    118 pngerror.obj: pngerror.c
    119 pngget.obj: pngget.c
    120 pngmem.obj: pngmem.c
    121 pngpread.obj: pngpread.c
    122 pngread.obj: pngread.c
    123 pngrio.obj: pngrio.c
    124 pngrtran.obj: pngrtran.c
    125 pngrutil.obj: pngrutil.c
    126 pngset.obj: pngset.c
    127 pngtrans.obj: pngtrans.c
    128 pngwio.obj: pngwio.c
    129 pngwrite.obj: pngwrite.c
    130 pngwtran.obj: pngwtran.c
    131 pngwutil.obj: pngwutil.c
    132 
     112png.obj: png.c png.h pngconf.h
     113pngerror.obj: pngerror.c png.h pngconf.h
     114pngget.obj: pngget.c png.h pngconf.h
     115pngmem.obj: pngmem.c png.h pngconf.h
     116pngpread.obj: pngpread.c png.h pngconf.h
     117pngread.obj: pngread.c png.h pngconf.h
     118pngrio.obj: pngrio.c png.h pngconf.h
     119pngrtran.obj: pngrtran.c png.h pngconf.h
     120pngrutil.obj: pngrutil.c png.h pngconf.h
     121pngset.obj: pngset.c png.h pngconf.h
     122pngtrans.obj: pngtrans.c png.h pngconf.h
     123pngwio.obj: pngwio.c png.h pngconf.h
     124pngwrite.obj: pngwrite.c png.h pngconf.h
     125pngwtran.obj: pngwtran.c png.h pngconf.h
     126pngwutil.obj: pngwutil.c png.h pngconf.h
     127pngtest.obj: pngtest.c png.h pngconf.h
    133128
    134129$(LIBNAME): $(OBJS)
     
    137132$(LIBOBJS), libpng
    138133|
    139 
    140134
    141135# Cleanup
     
    149143        -del pngout.png
    150144
    151 
    152145# End of makefile for libpng
  • trunk/src/3rdparty/libpng/scripts/makefile.beos

    r2 r561  
    11# makefile for libpng on BeOS x86 ELF with gcc
    22# modified from makefile.linux by Sander Stoks
    3 # Copyright (C) 2002, 2006 Glenn Randers-Pehrson
     3# Copyright (C) 2002, 2006, 2008 Glenn Randers-Pehrson
    44# Copyright (C) 1999 Greg Roelofs
    55# Copyright (C) 1996, 1997 Andreas Dilger
    6 # For conditions of distribution and use, see copyright notice in png.h
     6
     7# This code is released under the libpng license.
     8# For conditions of distribution and use, see the disclaimer
     9# and license in png.h
    710
    811# Library name:
    912LIBNAME=libpng12
    1013PNGMAJ = 0
    11 PNGMIN = 1.2.29
     14PNGMIN = 1.2.40
    1215PNGVER = $(PNGMAJ).$(PNGMIN)
    1316
     
    4245# On BeOS, -O1 is actually better than -O3.  This is a known bug but it's
    4346# still here in R4.5
    44 CFLAGS=-I$(ZLIBINC) -Wall -O1 -funroll-loops \
     47CFLAGS=-I$(ZLIBINC) -W -Wall -O1 -funroll-loops \
    4548        $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
    4649# LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz
     
    224227pngwutil.o pngwutil.pic.o: png.h pngconf.h
    225228pngpread.o pngpread.pic.o: png.h pngconf.h
     229
    226230pngtest.o: png.h pngconf.h
  • trunk/src/3rdparty/libpng/scripts/makefile.bor

    r2 r561  
    1212## Where zlib.h, zconf.h and zlib_MODEL.lib are
    1313ZLIB_DIR=..\zlib
    14 
    1514
    1615## Compiler, linker and lib stuff
     
    5857LDFLAGS=-M -L$(ZLIB_DIR) $(MODEL_ARG) $(LDEBUG)
    5958
     59## Variables
    6060
    61 ## Variables
    6261OBJS = \
    6362        png.obj \
     
    9695LIBNAME=libpng$(MODEL).lib
    9796
     97## Implicit rules
    9898
    99 ## Implicit rules
    10099# Braces let make "batch" calls to the compiler,
    101100# 2 calls instead of 12; space is important.
     
    106105        $(CC) $(CFLAGS) $(LDFLAGS) $*.c $(LIBNAME) zlib_$(MODEL).lib $(NOEHLIB)
    107106
     107## Major targets
    108108
    109 ## Major targets
    110109all: libpng pngtest
    111110
     
    117116        pngtest$(MODEL)
    118117
    119 
    120118## Minor Targets
    121119
    122 png.obj: png.c
    123 pngerror.obj: pngerror.c
    124 pngget.obj: pngget.c
    125 pngmem.obj: pngmem.c
    126 pngpread.obj: pngpread.c
    127 pngread.obj: pngread.c
    128 pngrio.obj: pngrio.c
    129 pngrtran.obj: pngrtran.c
    130 pngrutil.obj: pngrutil.c
    131 pngset.obj: pngset.c
    132 pngtrans.obj: pngtrans.c
    133 pngwio.obj: pngwio.c
    134 pngwrite.obj: pngwrite.c
    135 pngwtran.obj: pngwtran.c
    136 pngwutil.obj: pngwutil.c
    137 
     120png.obj: png.c png.h pngconf.h
     121pngerror.obj: pngerror.c png.h pngconf.h
     122pngget.obj: pngget.c png.h pngconf.h
     123pngmem.obj: pngmem.c png.h pngconf.h
     124pngpread.obj: pngpread.c png.h pngconf.h
     125pngread.obj: pngread.c png.h pngconf.h
     126pngrio.obj: pngrio.c png.h pngconf.h
     127pngrtran.obj: pngrtran.c png.h pngconf.h
     128pngrutil.obj: pngrutil.c png.h pngconf.h
     129pngset.obj: pngset.c png.h pngconf.h
     130pngtrans.obj: pngtrans.c png.h pngconf.h
     131pngwio.obj: pngwio.c png.h pngconf.h
     132pngwrite.obj: pngwrite.c png.h pngconf.h
     133pngwtran.obj: pngwtran.c png.h pngconf.h
     134pngwutil.obj: pngwutil.c png.h pngconf.h
    138135
    139136$(LIBNAME): $(OBJS)
     
    143140|
    144141
    145 
    146142pngtest$(MODEL).obj: pngtest.c
    147143        $(CC) $(CFLAGS) -opngtest$(MODEL) -c pngtest.c
     
    149145pngtest$(MODEL).exe: pngtest$(MODEL).obj
    150146        $(LD) $(LDFLAGS) pngtest$(MODEL).obj $(LIBNAME) zlib_$(MODEL).lib $(NOEHLIB)
    151 
    152147
    153148# Clean up anything else you want
     
    159154        -del *.map
    160155
    161 
    162156# End of makefile for libpng
  • trunk/src/3rdparty/libpng/scripts/makefile.cygwin

    r2 r561  
    44#   statically linked and one dynamically linked.
    55#
    6 # Copyright (C) 2002, 2006, 2007 Soren Anderson, Charles Wilson,
     6# Copyright (C) 2002, 2006-2008 Soren Anderson, Charles Wilson,
    77#    and Glenn Randers-Pehrson, based on makefile for linux-elf w/mmx by:
    88# Copyright (C) 1998-2000 Greg Roelofs
    99# Copyright (C) 1996, 1997 Andreas Dilger
    10 # For conditions of distribution and use, see copyright notice in png.h
     10
     11# This code is released under the libpng license.
     12# For conditions of distribution and use, see the disclaimer
     13# and license in png.h
    1114
    1215# This makefile intends to support building outside the src directory
     
    6164### if you don't need thread safety, but want the asm accel
    6265#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK \
    63 #       $(addprefix -I,$(ZLIBINC)) -Wall -O $(ALIGN) -funroll-loops \
     66#       $(addprefix -I,$(ZLIBINC)) -W -Wall -O $(ALIGN) -funroll-loops \
    6467#       -fomit-frame-pointer)  # $(WARNMORE) -g -DPNG_DEBUG=5
    6568### if you need thread safety and want (minimal) asm accel
    6669#CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \
    67 #       -Wall -O $(ALIGN) -funroll-loops \
     70#       -W -Wall -O $(ALIGN) -funroll-loops \
    6871#       -fomit-frame-pointer)  # $(WARNMORE) -g -DPNG_DEBUG=5
    6972### Normal (non-asm) compilation
    7073CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \
    71         -Wall -O3 $(ALIGN) -funroll-loops -DPNG_NO_MMX_CODE \
     74        -W -Wall -O3 $(ALIGN) -funroll-loops -DPNG_NO_MMX_CODE \
    7275        -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
    7376
     
    7578PNGMAJ = 0
    7679CYGDLL = 12
    77 PNGMIN = 1.2.29
     80PNGMIN = 1.2.40
    7881PNGVER = $(PNGMAJ).$(PNGMIN)
    7982
     
    177180        $(CC) $(CFLAGS) -c $< -o $@
    178181
    179 pngtest.o: pngtest.c
     182pngtest.o: pngtest.c png.h pngconf.h
    180183        $(CC) $(CFLAGS) -c $< -o $@
    181184
  • trunk/src/3rdparty/libpng/scripts/makefile.darwin

    r2 r561  
    11# makefile for libpng on Darwin / Mac OS X
    2 # Copyright (C) 2002, 2004, 2006 Glenn Randers-Pehrson
     2# Copyright (C) 2002, 2004, 2006, 2008 Glenn Randers-Pehrson
    33# Copyright (C) 2001 Christoph Pfisterer
    44# derived from makefile.linux:
    55#  Copyright (C) 1998, 1999 Greg Roelofs
    66#  Copyright (C) 1996, 1997 Andreas Dilger
    7 # For conditions of distribution and use, see copyright notice in png.h
     7
     8# This code is released under the libpng license.
     9# For conditions of distribution and use, see the disclaimer
     10# and license in png.h
    811
    912# where "make install" puts libpng.a, libpng12.dylib, png.h and pngconf.h
     
    1922# Library name:
    2023LIBNAME = libpng12
    21 PNGMAJ = 0
    22 PNGMIN = 1.2.29
     24PNGMAJ = 12
     25PNGMIN = 1.2.40
    2326PNGVER = $(PNGMAJ).$(PNGMIN)
    2427
     
    3942RM_F=/bin/rm -f
    4043
    41 # CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE
    42 CFLAGS=-I$(ZLIBINC) -Wall -O -funroll-loops
     44# CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE
     45CFLAGS=-I$(ZLIBINC) -W -Wall -O -funroll-loops
    4346LDFLAGS=-L. -L$(ZLIBLIB) -lpng12 -lz
    4447
     
    105108        $(CC) -dynamiclib \
    106109         -install_name $(LIBPATH)/$(LIBSOMAJ) \
    107          -current_version $(PNGVER) -compatibility_version $(PNGVER) \
     110         -current_version 0 -compatibility_version 0 \
    108111         -o $(LIBSOVER) \
    109112         $(OBJSDLL) -L$(ZLIBLIB) -lz
  • trunk/src/3rdparty/libpng/scripts/makefile.dec

    r2 r561  
    22# Copyright (C) 2000-2002, 2006 Glenn Randers-Pehrson
    33# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
    4 # For conditions of distribution and use, see copyright notice in png.h
     4
     5# This code is released under the libpng license.
     6# For conditions of distribution and use, see the disclaimer
     7# and license in png.h
    58
    69# Library name:
    710PNGMAJ = 0
    8 PNGMIN = 1.2.29
     11PNGMIN = 1.2.40
    912PNGVER = $(PNGMAJ).$(PNGMIN)
    1013LIBNAME = libpng12
     
    206209pngrtran.o: png.h pngconf.h
    207210pngrutil.o: png.h pngconf.h
    208 pngtest.o: png.h pngconf.h
    209211pngtrans.o: png.h pngconf.h
    210212pngwrite.o: png.h pngconf.h
     
    213215pngpread.o: png.h pngconf.h
    214216
     217pngtest.o: png.h pngconf.h
  • trunk/src/3rdparty/libpng/scripts/makefile.dj2

    r2 r561  
    11# DJGPP (DOS gcc) makefile for libpng
    2 # Copyright (C) 2002 Glenn Randers-Pehrson
     2# Copyright (C) 2002, 2006, 2009 Glenn Randers-Pehrson
    33# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
    4 # For conditions of distribution and use, see copyright notice in png.h
     4
     5# This code is released under the libpng license.
     6# For conditions of distribution and use, see the disclaimer
     7# and license in png.h
    58
    69# where make install will put libpng.a and png.h
     
    4851pngrtran.o: png.h pngconf.h
    4952pngrutil.o: png.h pngconf.h
    50 pngtest.o: png.h pngconf.h
    5153pngtrans.o: png.h pngconf.h
    5254pngwrite.o: png.h pngconf.h
     
    5456pngwutil.o: png.h pngconf.h
    5557
     58pngtest.o: png.h pngconf.h
  • trunk/src/3rdparty/libpng/scripts/makefile.elf

    r2 r561  
    11# makefile for libpng.a and libpng12.so on Linux ELF with gcc
    2 # Copyright (C) 1998, 1999, 2002, 2006 Greg Roelofs and Glenn Randers-Pehrson
     2# Copyright (C) 1998, 1999, 2002, 2006, 2008 Greg Roelofs
     3# and Glenn Randers-Pehrson
    34# Copyright (C) 1996, 1997 Andreas Dilger
    4 # For conditions of distribution and use, see copyright notice in png.h
     5
     6# This code is released under the libpng license.
     7# For conditions of distribution and use, see the disclaimer
     8# and license in png.h
    59
    610# Modified for Debian by Junichi Uekawa and Josselin Mouette
     
    1317LIBNAME = libpng12
    1418PNGMAJ = 0
    15 PNGMIN = 1.2.29
     19PNGMIN = 1.2.40
    1620PNGVER = $(PNGMAJ).$(PNGMIN)
    1721
     
    5458# for pgcc version 2.95.1, -O3 is buggy; don't use it.
    5559
    56 CFLAGS=-Wall -D_REENTRANT -O2 \
     60CFLAGS=-W -Wall -D_REENTRANT -O2 \
    5761        $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
    5862
  • trunk/src/3rdparty/libpng/scripts/makefile.freebsd

    r2 r561  
    11# makefile for libpng under FreeBSD
    2 # Copyright (C) 2002, 2007 Glenn Randers-Pehrson and Andrey A. Chernov
    3 # For conditions of distribution and use, see copyright notice in png.h
     2# Copyright (C) 2002, 2007, 2009 Glenn Randers-Pehrson and Andrey A. Chernov
     3
     4# This code is released under the libpng license.
     5# For conditions of distribution and use, see the disclaimer
     6# and license in png.h
    47
    58PREFIX?=        /usr/local
  • trunk/src/3rdparty/libpng/scripts/makefile.gcc

    r2 r561  
    11# makefile for libpng using gcc (generic, static library)
     2# Copyright (C) 2008 Glenn Randers-Pehrson
    23# Copyright (C) 2000 Cosmin Truta
    34# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
    4 # For conditions of distribution and use, see copyright notice in png.h
     5
     6# This code is released under the libpng license.
     7# For conditions of distribution and use, see the disclaimer
     8# and license in png.h
    59
    610# Location of the zlib library and include files
     
    1923CRELEASE = -O2
    2024LDRELEASE = -s
    21 #CFLAGS = -Wall $(CDEBUG)
    22 CFLAGS = -Wall $(CRELEASE)
     25#CFLAGS = -W -Wall $(CDEBUG)
     26CFLAGS = -W -Wall $(CRELEASE)
    2327#LDFLAGS = $(LDDEBUG)
    2428LDFLAGS = $(LDRELEASE)
     
    3135
    3236# Variables
    33 OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \
    34        pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \
    35        pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O)
     37OBJS =  png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \
     38        pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \
     39        pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O)
    3640
    3741# Targets
     
    6165        $(RM_F) *$(O) libpng$(A) pngtest$(EXE) pngout.png
    6266
    63 png$(O): png.h pngconf.h
     67png$(O):      png.h pngconf.h
    6468pngerror$(O): png.h pngconf.h
    65 pngget$(O): png.h pngconf.h
    66 pngmem$(O): png.h pngconf.h
     69pngget$(O):   png.h pngconf.h
     70pngmem$(O):   png.h pngconf.h
    6771pngpread$(O): png.h pngconf.h
    68 pngread$(O): png.h pngconf.h
    69 pngrio$(O): png.h pngconf.h
     72pngread$(O):  png.h pngconf.h
     73pngrio$(O):   png.h pngconf.h
    7074pngrtran$(O): png.h pngconf.h
    7175pngrutil$(O): png.h pngconf.h
    72 pngset$(O): png.h pngconf.h
    73 pngtest$(O): png.h pngconf.h
     76pngset$(O):   png.h pngconf.h
    7477pngtrans$(O): png.h pngconf.h
    75 pngwio$(O): png.h pngconf.h
     78pngwio$(O):   png.h pngconf.h
    7679pngwrite$(O): png.h pngconf.h
    7780pngwtran$(O): png.h pngconf.h
    7881pngwutil$(O): png.h pngconf.h
    7982
     83pngtest$(O):  png.h pngconf.h
  • trunk/src/3rdparty/libpng/scripts/makefile.gcmmx

    r2 r561  
    11# makefile for libpng.a and libpng12.so on Linux ELF with gcc using MMX
    22# assembler code
    3 # Copyright 2002, 2006 Greg Roelofs and Glenn Randers-Pehrson
     3# Copyright 2002, 2006, 2008 Greg Roelofs and Glenn Randers-Pehrson
    44# Copyright 1998-2001 Greg Roelofs
    55# Copyright 1996-1997 Andreas Dilger
    6 # For conditions of distribution and use, see copyright notice in png.h
     6
     7# This code is released under the libpng license.
     8# For conditions of distribution and use, see the disclaimer
     9# and license in png.h
    710
    811# CAUTION: Do not use this makefile with gcc versions 2.7.2.2 and earlier.
     
    1518LIBNAME = libpng12
    1619PNGMAJ = 0
    17 PNGMIN = 1.2.29
     20PNGMIN = 1.2.40
    1821PNGVER = $(PNGMAJ).$(PNGMIN)
    1922
     
    5962# Remove -DPNG_THREAD_UNSAFE_OK if you need thread safety
    6063### for generic gcc:
    61 CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -Wall -O \
     64CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -W -Wall -O \
    6265        $(ALIGN) -funroll-loops \
    6366        -fomit-frame-pointer  # $(WARNMORE) -g -DPNG_DEBUG=5
    6467### for gcc 2.95.2 on 686:
    65 #CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -Wall -O \
     68#CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -W -Wall -O \
    6669#       -mcpu=i686 -malign-double -ffast-math -fstrict-aliasing \
    67 #       $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer 
     70#       $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer
    6871### for gcc 2.7.2.3 on 486 and up:
    69 #CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -Wall -O \
     72#CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -W -Wall -O \
    7073#       -m486 -malign-double -ffast-math \
    71 #       $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer 
     74#       $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer
    7275
    7376LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm
  • trunk/src/3rdparty/libpng/scripts/makefile.hp64

    r2 r561  
    11# makefile for libpng, HPUX (10.20 and 11.00) using the ANSI/C product.
    2 # Copyright (C) 1999-2002 Glenn Randers-Pehrson
     2# Copyright (C) 1999-2002, 2006, 2009 Glenn Randers-Pehrson
    33# Copyright (C) 1995 Guy Eric Schalnat, Group 42
    44# contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard
    5 # For conditions of distribution and use, see copyright notice in png.h
     5
     6# This code is released under the libpng license.
     7# For conditions of distribution and use, see the disclaimer
     8# and license in png.h
    69
    710# Where the zlib library and include files are located
     
    1922LIBNAME = libpng12
    2023PNGMAJ = 0
    21 PNGMIN = 1.2.29
     24PNGMIN = 1.2.40
    2225PNGVER = $(PNGMAJ).$(PNGMIN)
    2326
     
    228231pngrtran.o: png.h pngconf.h
    229232pngrutil.o: png.h pngconf.h
    230 pngtest.o: png.h pngconf.h
    231233pngtrans.o: png.h pngconf.h
    232234pngwrite.o: png.h pngconf.h
     
    234236pngwutil.o: png.h pngconf.h
    235237pngpread.o: png.h pngconf.h
     238
     239pngtest.o: png.h pngconf.h
  • trunk/src/3rdparty/libpng/scripts/makefile.hpgcc

    r2 r561  
    11# makefile for libpng on HP-UX using GCC with the HP ANSI/C linker.
    2 # Copyright (C) 2002, 2006, 2007 Glenn Randers-Pehrson
     2# Copyright (C) 2002, 2006-2008 Glenn Randers-Pehrson
    33# Copyright (C) 2001, Laurent faillie
    44# Copyright (C) 1998, 1999 Greg Roelofs
    55# Copyright (C) 1996, 1997 Andreas Dilger
    6 # For conditions of distribution and use, see copyright notice in png.h
     6
     7# This code is released under the libpng license.
     8# For conditions of distribution and use, see the disclaimer
     9# and license in png.h
    710
    811# Library name:
    912LIBNAME = libpng12
    1013PNGMAJ = 0
    11 PNGMIN = 1.2.29
     14PNGMIN = 1.2.40
    1215PNGVER = $(PNGMAJ).$(PNGMIN)
    1316
     
    5457# for pgcc version 2.95.1, -O3 is buggy; don't use it.
    5558
    56 CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \
     59CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \
    5760        $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
    5861#LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm
  • trunk/src/3rdparty/libpng/scripts/makefile.hpux

    r2 r561  
    33# Copyright (C) 1995 Guy Eric Schalnat, Group 42
    44# contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard
    5 # For conditions of distribution and use, see copyright notice in png.h
     5
     6# This code is released under the libpng license.
     7# For conditions of distribution and use, see the disclaimer
     8# and license in png.h
    69
    710# Where the zlib library and include files are located
     
    1922LIBNAME = libpng12
    2023PNGMAJ = 0
    21 PNGMIN = 1.2.29
     24PNGMIN = 1.2.40
    2225PNGVER = $(PNGMAJ).$(PNGMIN)
    2326
     
    225228pngrtran.o: png.h pngconf.h
    226229pngrutil.o: png.h pngconf.h
    227 pngtest.o: png.h pngconf.h
    228230pngtrans.o: png.h pngconf.h
    229231pngwrite.o: png.h pngconf.h
     
    231233pngwutil.o: png.h pngconf.h
    232234pngpread.o: png.h pngconf.h
     235
     236pngtest.o: png.h pngconf.h
  • trunk/src/3rdparty/libpng/scripts/makefile.ibmc

    r2 r561  
    11# Makefile for libpng (static)
    22# IBM C version 3.x for Win32 and OS/2
     3# Copyright (C) 2006 Glenn Randers-Pehrson
    34# Copyright (C) 2000 Cosmin Truta
    4 # For conditions of distribution and use, see copyright notice in png.h
     5
     6# This code is released under the libpng license.
     7# For conditions of distribution and use, see the disclaimer
     8# and license in png.h
     9
    510# Notes:
    611#   Derived from makefile.std
     
    5459        $(RM) pngout.png
    5560
    56 png$(O): png.h pngconf.h
     61png$(O):      png.h pngconf.h
    5762pngerror$(O): png.h pngconf.h
    58 pngget$(O): png.h pngconf.h
    59 pngmem$(O): png.h pngconf.h
     63pngget$(O):   png.h pngconf.h
     64pngmem$(O):   png.h pngconf.h
    6065pngpread$(O): png.h pngconf.h
    61 pngread$(O): png.h pngconf.h
    62 pngrio$(O): png.h pngconf.h
     66pngread$(O):  png.h pngconf.h
     67pngrio$(O):   png.h pngconf.h
    6368pngrtran$(O): png.h pngconf.h
    6469pngrutil$(O): png.h pngconf.h
    65 pngset$(O): png.h pngconf.h
    66 pngtest$(O): png.h pngconf.h
     70pngset$(O):   png.h pngconf.h
    6771pngtrans$(O): png.h pngconf.h
    68 pngwio$(O): png.h pngconf.h
     72pngwio$(O):   png.h pngconf.h
    6973pngwrite$(O): png.h pngconf.h
    7074pngwtran$(O): png.h pngconf.h
    7175pngwutil$(O): png.h pngconf.h
     76
     77pngtest$(O):  png.h pngconf.h
  • trunk/src/3rdparty/libpng/scripts/makefile.intel

    r2 r561  
    22# Microsoft Visual C++ with Intel C/C++ Compiler 4.0 and later
    33
     4# Copyright (C) 2006 Glenn Randers-Pehrson
    45# Copyright (C) 2000, Pawel Mrochen, based on makefile.msc which is
    56# copyright 1995 Guy Eric Schalnat, Group 42, Inc.
    6 # For conditions of distribution and use, see copyright notice in png.h
     7
     8# This code is released under the libpng license.
     9# For conditions of distribution and use, see the disclaimer
     10# and license in png.h
    711
    812# To use, do "nmake /f scripts\makefile.intel"
    913
     14# ------------------- Intel C/C++ Compiler 4.0 and later -------------------
    1015
    1116# Where the zlib library and include files are located
     
    2631
    2732# --------------------------------------------------------------------------
    28 
    2933
    3034CC=icl -c
     
    7478        $(CC) $(CFLAGS) $*.c $(ERRFILE)
    7579
    76 pngtest$(O): png.h pngconf.h
    77         $(CC) $(CFLAGS) $*.c $(ERRFILE)
    78 
    7980pngtrans$(O): png.h pngconf.h
    8081        $(CC) $(CFLAGS) $*.c $(ERRFILE)
     
    9697        $(LD) $(LDFLAGS) /OUT:pngtest.exe pngtest.obj libpng.lib $(ZLIBLIB)\zlib.lib
    9798
     99pngtest$(O): png.h pngconf.h
     100        $(CC) $(CFLAGS) $*.c $(ERRFILE)
     101
    98102test: pngtest.exe
    99103        pngtest.exe
  • trunk/src/3rdparty/libpng/scripts/makefile.knr

    r2 r561  
    11# makefile for libpng
    2 # Copyright (C) 2002 Glenn Randers-Pehrson
     2# Copyright (C) 2002, 2006, 2009 Glenn Randers-Pehrson
    33# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
    4 # For conditions of distribution and use, see copyright notice in png.h
     4
     5# This code is released under the libpng license.
     6# For conditions of distribution and use, see the disclaimer
     7# and license in png.h
    58
    69# This makefile requires the file ansi2knr.c, which you can get
     
    5962        ./pngtest
    6063
    61 install: libpng.a
     64install: libpng.a png.h pngconf.h
    6265        -@mkdir $(DESTDIR)$(INCPATH)
    6366        -@mkdir $(DESTDIR)$(INCPATH)/libpng
     
    9396pngrtran.o: png.h pngconf.h
    9497pngrutil.o: png.h pngconf.h
    95 pngtest.o: png.h pngconf.h
    9698pngtrans.o: png.h pngconf.h
    9799pngwrite.o: png.h pngconf.h
    98100pngwtran.o: png.h pngconf.h
    99101pngwutil.o: png.h pngconf.h
     102
     103pngtest.o: png.h pngconf.h
  • trunk/src/3rdparty/libpng/scripts/makefile.linux

    r2 r561  
    11# makefile for libpng.a and libpng12.so on Linux ELF with gcc
    2 # Copyright (C) 1998, 1999, 2002, 2006 Greg Roelofs and Glenn Randers-Pehrson
     2# Copyright (C) 1998, 1999, 2002, 2006, 2008 Greg Roelofs and
     3# Glenn Randers-Pehrson
    34# Copyright (C) 1996, 1997 Andreas Dilger
    4 # For conditions of distribution and use, see copyright notice in png.h
     5
     6# This code is released under the libpng license.
     7# For conditions of distribution and use, see the disclaimer
     8# and license in png.h
    59
    610# Library name:
    711LIBNAME = libpng12
    812PNGMAJ = 0
    9 PNGMIN = 1.2.29
     13PNGMIN = 1.2.40
    1014PNGVER = $(PNGMAJ).$(PNGMIN)
    1115
     
    4852# for pgcc version 2.95.1, -O3 is buggy; don't use it.
    4953
    50 CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \
     54CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \
    5155        $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
    5256
     
    7478DM=$(DESTDIR)$(MANPATH)
    7579
    76 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
     80OBJS =  png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
    7781        pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
    7882        pngwtran.o pngmem.o pngerror.o pngpread.o
  • trunk/src/3rdparty/libpng/scripts/makefile.mingw

    r2 r561  
    44#   statically linked and one dynamically linked.
    55#
    6 # Built from makefile.cygwin
    7 # Copyright (C) 2002, 2006 Soren Anderson, Charles Wilson,
     6# Copyright (C) 2002, 2006, 2008 Soren Anderson, Charles Wilson,
    87#    and Glenn Randers-Pehrson, based on makefile for linux-elf w/mmx by:
    98# Copyright (C) 1998-2000, 2007 Greg Roelofs
    109# Copyright (C) 1996, 1997 Andreas Dilger
    11 # For conditions of distribution and use, see copyright notice in png.h
    12 
     10
     11# This code is released under the libpng license.
     12# For conditions of distribution and use, see the disclaimer
     13# and license in png.h
     14
     15# Built from makefile.cygwin
    1316
    1417# This makefile intends to support building outside the src directory
     
    6164### if you don't need thread safety, but want the asm accel
    6265#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK \
    63 #       $(addprefix -I,$(ZLIBINC)) -Wall -O $(ALIGN) -funroll-loops \
     66#       $(addprefix -I,$(ZLIBINC)) -W -Wall -O $(ALIGN) -funroll-loops \
    6467#       -fomit-frame-pointer)  # $(WARNMORE) -g -DPNG_DEBUG=5
    6568### if you need thread safety and want (minimal) asm accel
    6669#CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \
    67 #       -Wall -O $(ALIGN) -funroll-loops \
     70#       -W -Wall -O $(ALIGN) -funroll-loops \
    6871#       -fomit-frame-pointer)  # $(WARNMORE) -g -DPNG_DEBUG=5
    6972### Normal (non-asm) compilation
    7073CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \
    71         -Wall -O3 $(ALIGN) -funroll-loops -DPNG_NO_MMX_CODE \
     74        -W -Wall -O3 $(ALIGN) -funroll-loops -DPNG_NO_MMX_CODE \
    7275        -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
    7376
     
    7578PNGMAJ = 0
    7679MINGDLL = 12
    77 PNGMIN = 1.2.29
     80PNGMIN = 1.2.40
    7881PNGVER = $(PNGMAJ).$(PNGMIN)
    7982
     
    285288
    286289pngtest.o pngtest.pic.o:        png.h pngconf.h pngtest.c
    287 
    288 
    289 
  • trunk/src/3rdparty/libpng/scripts/makefile.mips

    r2 r561  
    22# Copyright (C) Glenn Randers-Pehrson
    33# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
    4 # For conditions of distribution and use, see copyright notice in png.h
     4
     5# This code is released under the libpng license.
     6# For conditions of distribution and use, see the disclaimer
     7# and license in png.h
    58
    69# where make install puts libpng.a and png.h
     
    7780pngrtran.o: png.h pngconf.h
    7881pngrutil.o: png.h pngconf.h
    79 pngtest.o: png.h pngconf.h
    8082pngtrans.o: png.h pngconf.h
    8183pngwrite.o: png.h pngconf.h
    8284pngwtran.o: png.h pngconf.h
    8385pngwutil.o: png.h pngconf.h
     86
     87pngtest.o: png.h pngconf.h
  • trunk/src/3rdparty/libpng/scripts/makefile.msc

    r2 r561  
    11# makefile for libpng
    22# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
    3 # For conditions of distribution and use, see copyright notice in png.h
     3# Copyright (C) 2006, 2009 Glenn Randers-Pehrson
     4
     5# This code is released under the libpng license.
     6# For conditions of distribution and use, see the disclaimer
     7# and license in png.h
     8
    49# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib
    510
     
    5661        $(CC) -c $(CFLAGS) $*.c $(ERRFILE)
    5762
    58 pngtest$(O): png.h pngconf.h
    59         $(CC) -c $(CFLAGS) $*.c $(ERRFILE)
    60 
    6163pngtrans$(O): png.h pngconf.h
    6264        $(CC) -c $(CFLAGS) $*.c $(ERRFILE)
     
    7779        lib libpng $(OBJS3);
    7880
     81pngtest$(O): png.h pngconf.h
     82        $(CC) -c $(CFLAGS) $*.c $(ERRFILE)
     83
    7984pngtest.exe: pngtest.obj libpng.lib
    8085        $(LD) $(LDFLAGS) pngtest.obj,,,libpng.lib ..\zlib\zlib.lib ;
  • trunk/src/3rdparty/libpng/scripts/makefile.ne12bsd

    r2 r561  
    33# make includes && make install
    44# Copyright (C) 2002 Patrick R.L. Welche
    5 # Copyright (C) 2007 Glenn Randers-Pehrson
    6 # For conditions of distribution and use, see copyright notice in png.h
     5# Copyright (C) 2007, 2009 Glenn Randers-Pehrson
     6
     7# This code is released under the libpng license.
     8# For conditions of distribution and use, see the disclaimer
     9# and license in png.h
    710
    811# You should also run makefile.netbsd
     
    1518LIB=    png12
    1619SHLIB_MAJOR=    0
    17 SHLIB_MINOR=    1.2.29
     20SHLIB_MINOR=    1.2.40
    1821SRCS=   png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
    1922        pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
     
    2427CPPFLAGS+=-I${.CURDIR}
    2528
    26 # something like this for mmx assembler, but it core dumps for me at the moment
     29# We should be able to do something like this instead of the manual
     30# uncommenting, but it core dumps for me at the moment:
    2731# .if ${MACHINE_ARCH} == "i386"
    2832#   CPPFLAGS+=-DPNG_THREAD_UNSAFE_OK
  • trunk/src/3rdparty/libpng/scripts/makefile.netbsd

    r2 r561  
    33# make includes && make install
    44# Copyright (C) 2002 Patrick R.L. Welche
    5 # Copyright (C) 2007 Glenn Randers-Pehrson
    6 # For conditions of distribution and use, see copyright notice in png.h
     5# Copyright (C) 2007, 2009 Glenn Randers-Pehrson
     6
     7# This code is released under the libpng license.
     8# For conditions of distribution and use, see the disclaimer
     9# and license in png.h
    710
    811# You should also run makefile.ne0bsd
     
    1518LIB=    png
    1619SHLIB_MAJOR=    3
    17 SHLIB_MINOR=    1.2.29
     20SHLIB_MINOR=    1.2.40
    1821SRCS=   png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
    1922        pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
     
    2427CPPFLAGS+=-I${.CURDIR}
    2528
    26 # something like this for mmx assembler, but it core dumps for me at the moment
     29# We should be able to do something like this instead of the manual
     30# uncommenting, but it core dumps for me at the moment:
    2731# .if ${MACHINE_ARCH} == "i386"
    2832#   CPPFLAGS+=-DPNG_THREAD_UNSAFE_OK
  • trunk/src/3rdparty/libpng/scripts/makefile.nommx

    r2 r561  
    11# makefile for libpng.a and libpng12.so on Linux ELF with gcc
    2 # Copyright (C) 1998, 1999, 2002, 2006, 2007 Greg Roelofs and
     2# Copyright (C) 1998, 1999, 2002, 2006-2008 Greg Roelofs and
    33# Glenn Randers-Pehrson
    44# Copyright (C) 1996, 1997 Andreas Dilger
    5 # For conditions of distribution and use, see copyright notice in png.h
     5
     6# This code is released under the libpng license.
     7# For conditions of distribution and use, see the disclaimer
     8# and license in png.h
    69
    710# Library name:
    811LIBNAME = libpng12
    912PNGMAJ = 0
    10 PNGMIN = 1.2.29
     13PNGMIN = 1.2.40
    1114PNGVER = $(PNGMAJ).$(PNGMIN)
    1215
     
    4952# for pgcc version 2.95.1, -O3 is buggy; don't use it.
    5053
    51 CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \
     54CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \
    5255        $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
    5356
     
    234237# DO NOT DELETE THIS LINE -- make depend depends on it.
    235238
    236 png.o png.pic.o: png.h pngconf.h
    237 pngerror.o pngerror.pic.o: png.h pngconf.h
    238 pngrio.o pngrio.pic.o: png.h pngconf.h
    239 pngwio.o pngwio.pic.o: png.h pngconf.h
    240 pngmem.o pngmem.pic.o: png.h pngconf.h
    241 pngset.o pngset.pic.o: png.h pngconf.h
    242 pngget.o pngget.pic.o: png.h pngconf.h
    243 pngread.o pngread.pic.o: png.h pngconf.h
    244 pngrtran.o pngrtran.pic.o: png.h pngconf.h
    245 pngrutil.o pngrutil.pic.o: png.h pngconf.h
    246 pngtrans.o pngtrans.pic.o: png.h pngconf.h
    247 pngwrite.o pngwrite.pic.o: png.h pngconf.h
    248 pngwtran.o pngwtran.pic.o: png.h pngconf.h
    249 pngwutil.o pngwutil.pic.o: png.h pngconf.h
    250 pngpread.o pngpread.pic.o: png.h pngconf.h
    251 
    252 pngtest.o: png.h pngconf.h
     239png.o png.pic.o:                png.h pngconf.h png.c
     240pngerror.o pngerror.pic.o:      png.h pngconf.h pngerror.c
     241pngrio.o pngrio.pic.o:          png.h pngconf.h pngrio.c
     242pngwio.o pngwio.pic.o:          png.h pngconf.h pngwio.c
     243pngmem.o pngmem.pic.o:          png.h pngconf.h pngmem.c
     244pngset.o pngset.pic.o:          png.h pngconf.h pngset.c
     245pngget.o pngget.pic.o:          png.h pngconf.h pngget.c
     246pngread.o pngread.pic.o:        png.h pngconf.h pngread.c
     247pngrtran.o pngrtran.pic.o:      png.h pngconf.h pngrtran.c
     248pngrutil.o pngrutil.pic.o:      png.h pngconf.h pngrutil.c
     249pngtrans.o pngtrans.pic.o:      png.h pngconf.h pngtrans.c
     250pngwrite.o pngwrite.pic.o:      png.h pngconf.h pngwrite.c
     251pngwtran.o pngwtran.pic.o:      png.h pngconf.h pngwtran.c
     252pngwutil.o pngwutil.pic.o:      png.h pngconf.h pngwutil.c
     253pngpread.o pngpread.pic.o:      png.h pngconf.h pngpread.c
     254
     255pngtest.o:                      png.h pngconf.h pngtest.c
  • trunk/src/3rdparty/libpng/scripts/makefile.openbsd

    r2 r561  
    11# makefile for libpng
    22# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
    3 # Copyright (C) 2007 Glenn Randers-Pehrson
    4 # For conditions of distribution and use, see copyright notice in png.h
     3# Copyright (C) 2007-2008 Glenn Randers-Pehrson
     4
     5# This code is released under the libpng license.
     6# For conditions of distribution and use, see the disclaimer
     7# and license in png.h
    58
    69PREFIX?= /usr/local
     
    912
    1013SHLIB_MAJOR=    0
    11 SHLIB_MINOR=    1.2.29
     14SHLIB_MINOR=    1.2.40
    1215
    1316LIB=    png
     
    1821HDRS=   png.h pngconf.h
    1922
    20 CFLAGS+= -Wall
    21 CPPFLAGS+= -I${.CURDIR} -DPNG_NO_MMX_CODE 
     23CFLAGS+= -W -Wall
     24CPPFLAGS+= -I${.CURDIR} -DPNG_NO_MMX_CODE
    2225
    2326NOPROFILE= Yes
  • trunk/src/3rdparty/libpng/scripts/makefile.os2

    r2 r561  
    11# makefile for libpng on OS/2 with gcc
    2 # For conditions of distribution and use, see copyright notice in png.h
     2
     3# This code is released under the libpng license.
     4# For conditions of distribution and use, see the disclaimer
     5# and license in png.h
    36
    47# Related files: pngos2.def
     
    1316        -Wmissing-declarations -Wtraditional -Wcast-align \
    1417        -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
    15 CFLAGS=-I$(ZLIBINC) -Wall -O6 -funroll-loops -malign-loops=2 \
     18CFLAGS=-I$(ZLIBINC) -W -Wall -O6 -funroll-loops -malign-loops=2 \
    1619        -malign-functions=2 #$(WARNMORE) -g -DPNG_DEBUG=5
    1720LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lzdll -Zcrtdll
  • trunk/src/3rdparty/libpng/scripts/makefile.sco

    r2 r561  
    55# Copyright (C) 1998 Greg Roelofs
    66# Copyright (C) 1996, 1997 Andreas Dilger
    7 # For conditions of distribution and use, see copyright notice in png.h
     7
     8# This code is released under the libpng license.
     9# For conditions of distribution and use, see the disclaimer
     10# and license in png.h
    811
    912# Library name:
    1013LIBNAME = libpng12
    1114PNGMAJ = 0
    12 PNGMIN = 1.2.29
     15PNGMIN = 1.2.40
    1316PNGVER = $(PNGMAJ).$(PNGMIN)
    1417
  • trunk/src/3rdparty/libpng/scripts/makefile.sggcc

    r2 r561  
    22# Copyright (C) 2001-2002, 2006 Glenn Randers-Pehrson
    33# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
    4 # For conditions of distribution and use, see copyright notice in png.h
     4
     5# This code is released under the libpng license.
     6# For conditions of distribution and use, see the disclaimer
     7# and license in png.h
    58
    69# Library name:
    710LIBNAME=libpng12
    811PNGMAJ = 0
    9 PNGMIN = 1.2.29
     12PNGMIN = 1.2.40
    1013PNGVER = $(PNGMAJ).$(PNGMIN)
    1114
     
    213216
    214217clean:
    215         $(RM_F) libpng.a pngtest pngtesti pngout.png libpng.pc libpng-config \
    216         $(LIBSO) $(LIBSOMAJ)* \
    217         $(OLDSOVER) \
    218         so_locations
     218        $(RM_F) libpng.a pngtest pngtesti pngout.png libpng.pc \
     219        so_locations libpng-config $(LIBSO) $(LIBSOMAJ)* $(OLDSOVER)
    219220
    220221DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
     
    234235pngrtran.o: png.h pngconf.h
    235236pngrutil.o: png.h pngconf.h
    236 pngtest.o: png.h pngconf.h
    237237pngtrans.o: png.h pngconf.h
    238238pngwrite.o: png.h pngconf.h
     
    241241pngpread.o: png.h pngconf.h
    242242
     243pngtest.o: png.h pngconf.h
  • trunk/src/3rdparty/libpng/scripts/makefile.sgi

    r2 r561  
    22# Copyright (C) 2001-2002, 2006, 2007 Glenn Randers-Pehrson
    33# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
    4 # For conditions of distribution and use, see copyright notice in png.h
     4
     5# This code is released under the libpng license.
     6# For conditions of distribution and use, see the disclaimer
     7# and license in png.h
    58
    69# Library name:
    710LIBNAME=libpng12
    811PNGMAJ = 0
    9 PNGMIN = 1.2.29
     12PNGMIN = 1.2.40
    1013PNGVER = $(PNGMAJ).$(PNGMIN)
    1114
     
    237240pngrtran.o: png.h pngconf.h
    238241pngrutil.o: png.h pngconf.h
    239 pngtest.o: png.h pngconf.h
    240242pngtrans.o: png.h pngconf.h
    241243pngwrite.o: png.h pngconf.h
     
    244246pngpread.o: png.h pngconf.h
    245247
     248pngtest.o: png.h pngconf.h
  • trunk/src/3rdparty/libpng/scripts/makefile.so9

    r2 r561  
    22# Updated by Chad Schrock for Solaris 9
    33# Contributed by William L. Sebok, based on makefile.linux
    4 # Copyright (C) 2002, 2006 Glenn Randers-Pehrson
     4# Copyright (C) 2002, 2006, 2008 Glenn Randers-Pehrson
    55# Copyright (C) 1998-2001 Greg Roelofs
    66# Copyright (C) 1996-1997 Andreas Dilger
    7 # For conditions of distribution and use, see copyright notice in png.h
     7
     8# This code is released under the libpng license.
     9# For conditions of distribution and use, see the disclaimer
     10# and license in png.h
    811
    912# Library name:
    1013PNGMAJ = 0
    11 PNGMIN = 1.2.29
     14PNGMIN = 1.2.40
    1215PNGVER = $(PNGMAJ).$(PNGMIN)
    1316LIBNAME = libpng12
     
    4851        -Wmissing-declarations -Wtraditional -Wcast-align \
    4952        -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
    50 #CFLAGS=-I$(ZLIBINC) -Wall -O3 $(WARNMORE) -g -DPNG_DEBUG=5 -DPNG_NO_MMX_CODE
     53#CFLAGS=-I$(ZLIBINC) -W -Wall -O3 $(WARNMORE) -g -DPNG_DEBUG=5 -DPNG_NO_MMX_CODE
    5154CFLAGS=-I$(ZLIBINC) -O3 -DPNG_NO_MMX_CODE
    5255LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng12 -lz -lm
  • trunk/src/3rdparty/libpng/scripts/makefile.solaris

    r2 r561  
    11# makefile for libpng on Solaris 2.x with gcc
    2 # Copyright (C) 2004, 2006, 2007 Glenn Randers-Pehrson
     2# Copyright (C) 2004, 2006-2008 Glenn Randers-Pehrson
    33# Contributed by William L. Sebok, based on makefile.linux
    44# Copyright (C) 1998 Greg Roelofs
    55# Copyright (C) 1996, 1997 Andreas Dilger
    6 # For conditions of distribution and use, see copyright notice in png.h
     6
     7# This code is released under the libpng license.
     8# For conditions of distribution and use, see the disclaimer
     9# and license in png.h
    710
    811# Library name:
    912LIBNAME = libpng12
    1013PNGMAJ = 0
    11 PNGMIN = 1.2.29
     14PNGMIN = 1.2.40
    1215PNGVER = $(PNGMAJ).$(PNGMIN)
    1316
     
    4447        -Wmissing-declarations -Wtraditional -Wcast-align \
    4548        -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
    46 CFLAGS=-I$(ZLIBINC) -Wall -O \
    47         -DPNG_NO_MMX_CODE; \
     49CFLAGS=-I$(ZLIBINC) -W -Wall -O -DPNG_NO_MMX_CODE; \
    4850        # $(WARNMORE) -g -DPNG_DEBUG=5
    4951LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng12 -lz -lm
  • trunk/src/3rdparty/libpng/scripts/makefile.solaris-x86

    r2 r561  
    11# makefile for libpng on Solaris 2.x with gcc
    2 # Copyright (C) 2004, 2006, 2007 Glenn Randers-Pehrson
     2# Copyright (C) 2004, 2006-2008 Glenn Randers-Pehrson
    33# Contributed by William L. Sebok, based on makefile.linux
    44# Copyright (C) 1998 Greg Roelofs
    55# Copyright (C) 1996, 1997 Andreas Dilger
    6 # For conditions of distribution and use, see copyright notice in png.h
     6
     7# This code is released under the libpng license.
     8# For conditions of distribution and use, see the disclaimer
     9# and license in png.h
    710
    811# Library name:
    912LIBNAME = libpng12
    1013PNGMAJ = 0
    11 PNGMIN = 1.2.29
     14PNGMIN = 1.2.40
    1215PNGVER = $(PNGMAJ).$(PNGMIN)
    1316
     
    4447        -Wmissing-declarations -Wtraditional -Wcast-align \
    4548        -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
    46 CFLAGS=-I$(ZLIBINC) -Wall -O \
     49CFLAGS=-I$(ZLIBINC) -W -Wall -O \
    4750        # $(WARNMORE) -g -DPNG_DEBUG=5
    4851LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng12 -lz -lm
  • trunk/src/3rdparty/libpng/scripts/makefile.std

    r2 r561  
    22# Copyright (C) 2002, 2006 Glenn Randers-Pehrson
    33# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
    4 # For conditions of distribution and use, see copyright notice in png.h
     4
     5# This code is released under the libpng license.
     6# For conditions of distribution and use, see the disclaimer
     7# and license in png.h
    58
    69# where make install puts libpng.a and png.h
     
    8487pngrtran.o: png.h pngconf.h
    8588pngrutil.o: png.h pngconf.h
    86 pngtest.o: png.h pngconf.h
    8789pngtrans.o: png.h pngconf.h
    8890pngwrite.o: png.h pngconf.h
     
    9193pngpread.o: png.h pngconf.h
    9294
     95pngtest.o: png.h pngconf.h
  • trunk/src/3rdparty/libpng/scripts/makefile.sunos

    r2 r561  
    22# Copyright (C) 2002, 2006 Glenn Randers-Pehrson
    33# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
    4 # For conditions of distribution and use, see copyright notice in png.h
     4
     5# This code is released under the libpng license.
     6# For conditions of distribution and use, see the disclaimer
     7# and license in png.h
    58
    69# where make install puts libpng.a and png.h
     
    8992pngrtran.o: png.h pngconf.h
    9093pngrutil.o: png.h pngconf.h
    91 pngtest.o: png.h pngconf.h
    9294pngtrans.o: png.h pngconf.h
    9395pngwrite.o: png.h pngconf.h
     
    9698pngpread.o: png.h pngconf.h
    9799
     100pngtest.o: png.h pngconf.h
  • trunk/src/3rdparty/libpng/scripts/makefile.vcawin32

    r2 r561  
    11# makefile for libpng
     2# Copyright (C) 2006,2009 Glenn Randers-Pehrson
    23# Copyright (C) 1998 Tim Wegner
    3 # For conditions of distribution and use, see copyright notice in png.h
     4
     5# This code is released under the libpng license.
     6# For conditions of distribution and use, see the disclaimer
     7# and license in png.h
     8
    49# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib
    510# To use, do "nmake /f scripts\makefile.vcawin32"
    611
    7 # -------- Microsoft Visual C++ 5.0 and later, uses assembler code --------
     12# -------- Microsoft Visual C++ 2.0 and later, no assembler code --------
    813# If you don't want to use assembler (MMX) code, use makefile.vcwin32 instead.
    914
     
    1217LD = link
    1318AR = lib
    14 CFLAGS  = -DPNG_USE_PNGVCRD -nologo -MD -O2 -W3 -I..\zlib
     19CFLAGS  = -nologo -DPNG_USE_PNGVCRD -MD -O2 -W3 -I..\zlib
    1520LDFLAGS = -nologo
    1621ARFLAGS = -nologo
     
    6570        $(CC) -c $(CFLAGS) $*.c $(ERRFILE)
    6671
    67 pngtest$(O): png.h pngconf.h
    68         $(CC) -c $(CFLAGS) $*.c $(ERRFILE)
    69 
    7072pngtrans$(O): png.h pngconf.h
    7173        $(CC) -c $(CFLAGS) $*.c $(ERRFILE)
     
    8486        $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(ERRFILE)
    8587
     88pngtest$(O): png.h pngconf.h
     89        $(CC) -c $(CFLAGS) $*.c $(ERRFILE)
     90
    8691pngtest.exe: pngtest$(O) libpng.lib
    8792        $(LD) $(LDFLAGS) -out:$@ pngtest$(O) libpng.lib ..\zlib\zlib.lib $(ERRFILE)
  • trunk/src/3rdparty/libpng/scripts/makefile.vcwin32

    r2 r561  
    11# makefile for libpng
    22# Copyright (C) 1998 Tim Wegner
    3 # For conditions of distribution and use, see copyright notice in png.h
     3# Copyright (C) 2006,2009 Glenn Randers-Pehrson
     4
     5# This code is released under the libpng license.
     6# For conditions of distribution and use, see the disclaimer
     7# and license in png.h
     8
    49# Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib
    510# To use, do "nmake /f scripts\makefile.vcwin32"
     
    6570        $(CC) -c $(CFLAGS) $*.c $(ERRFILE)
    6671
    67 pngtest$(O): png.h pngconf.h
    68         $(CC) -c $(CFLAGS) $*.c $(ERRFILE)
    69 
    7072pngtrans$(O): png.h pngconf.h
    7173        $(CC) -c $(CFLAGS) $*.c $(ERRFILE)
     
    8486        $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(ERRFILE)
    8587
     88pngtest$(O): png.h pngconf.h
     89        $(CC) -c $(CFLAGS) $*.c $(ERRFILE)
     90
    8691pngtest.exe: pngtest$(O) libpng.lib
    8792        $(LD) $(LDFLAGS) -out:$@ pngtest$(O) libpng.lib ..\zlib\zlib.lib $(ERRFILE)
  • trunk/src/3rdparty/libpng/scripts/makefile.watcom

    r2 r561  
    44# Copyright (C) 2000, Pawel Mrochen, based on makefile.msc which is
    55# copyright 1995 Guy Eric Schalnat, Group 42, Inc.
    6 # For conditions of distribution and use, see copyright notice in png.h
     6
     7# This code is released under the libpng license.
     8# For conditions of distribution and use, see the disclaimer
     9# and license in png.h
    710
    811# To use, do "wmake /f scripts\makefile.watcom"
  • trunk/src/3rdparty/libpng/scripts/makevms.com

    r2 r561  
    5656$   CALL MAKE png.OBJ "cc ''CCOPT' png" -
    5757        png.c png.h pngconf.h
    58 $   CALL MAKE pngpread.OBJ "cc ''CCOPT' pngpread" -
    59                                          pngpread.c png.h pngconf.h
    6058$   CALL MAKE pngset.OBJ "cc ''CCOPT' pngset" -
    6159        pngset.c png.h pngconf.h
     
    6563        pngread.c png.h pngconf.h
    6664$   CALL MAKE pngpread.OBJ "cc ''CCOPT' pngpread" -
    67                                          pngpread.c png.h pngconf.h
     65        pngpread.c png.h pngconf.h
    6866$   CALL MAKE pngrtran.OBJ "cc ''CCOPT' pngrtran" -
    6967        pngrtran.c png.h pngconf.h
  • trunk/src/3rdparty/libpng/scripts/pngos2.def

    r2 r561  
    33;----------------------------------------
    44
    5 ; Version 1.2.29
     5; Version 1.2.40
    66
    77LIBRARY         PNG
  • trunk/src/3rdparty/libpng/scripts/pngw32.def

    r2 r561  
    66
    77EXPORTS
    8 ;Version 1.2.29
     8;Version 1.2.40
    99  png_build_grayscale_palette  @1
    1010  png_check_sig        @2
     
    190190; For compatibility with 1.0.7-1.0.11
    191191; png_info_init @174
     192; png_read_init_3, png_info_init_3, and png_write_init_3 are deprecated.
    192193  png_read_init_3    @175
    193194  png_write_init_3    @176
  • trunk/src/3rdparty/libpng/scripts/smakefile.ppc

    r2 r561  
    22# makefile for libpng and SAS C V6.58/7.00 PPC compiler
    33# Copyright (C) 1998 by Andreas R. Kleinert
    4 # For conditions of distribution and use, see copyright notice in png.h
     4
     5# This code is released under the libpng license.
     6# For conditions of distribution and use, see the disclaimer
     7# and license in png.h
    58
    69CC       = scppc
Note: See TracChangeset for help on using the changeset viewer.