Changeset 561 for trunk/src/3rdparty/libpng
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 86 edited
- 1 copied
-
. (modified) (1 prop)
-
src/3rdparty/libpng/ANNOUNCE (modified) (2 diffs)
-
src/3rdparty/libpng/CHANGES (modified) (14 diffs)
-
src/3rdparty/libpng/INSTALL (modified) (4 diffs)
-
src/3rdparty/libpng/KNOWNBUG (modified) (1 diff)
-
src/3rdparty/libpng/LICENSE (modified) (2 diffs)
-
src/3rdparty/libpng/README (modified) (7 diffs)
-
src/3rdparty/libpng/TODO (modified) (1 diff)
-
src/3rdparty/libpng/Y2KINFO (modified) (2 diffs)
-
src/3rdparty/libpng/configure (modified) (2 diffs)
-
src/3rdparty/libpng/example.c (modified) (30 diffs)
-
src/3rdparty/libpng/libpng-1.2.29.txt (deleted)
-
src/3rdparty/libpng/libpng-1.2.40.txt (copied) (copied from branches/vendor/nokia/qt/4.6.1/src/3rdparty/libpng/libpng-1.2.40.txt )
-
src/3rdparty/libpng/libpng.3 (modified) (23 diffs)
-
src/3rdparty/libpng/libpngpf.3 (modified) (1 diff)
-
src/3rdparty/libpng/png.5 (modified) (1 diff)
-
src/3rdparty/libpng/png.c (modified) (26 diffs)
-
src/3rdparty/libpng/png.h (modified) (62 diffs)
-
src/3rdparty/libpng/pngconf.h (modified) (24 diffs)
-
src/3rdparty/libpng/pngerror.c (modified) (10 diffs)
-
src/3rdparty/libpng/pngget.c (modified) (51 diffs)
-
src/3rdparty/libpng/pngmem.c (modified) (25 diffs)
-
src/3rdparty/libpng/pngpread.c (modified) (91 diffs)
-
src/3rdparty/libpng/pngread.c (modified) (59 diffs)
-
src/3rdparty/libpng/pngrio.c (modified) (8 diffs)
-
src/3rdparty/libpng/pngrtran.c (modified) (151 diffs)
-
src/3rdparty/libpng/pngrutil.c (modified) (124 diffs)
-
src/3rdparty/libpng/pngset.c (modified) (58 diffs)
-
src/3rdparty/libpng/pngtest.c (modified) (81 diffs)
-
src/3rdparty/libpng/pngtrans.c (modified) (19 diffs)
-
src/3rdparty/libpng/pngwio.c (modified) (16 diffs)
-
src/3rdparty/libpng/pngwrite.c (modified) (75 diffs)
-
src/3rdparty/libpng/pngwtran.c (modified) (13 diffs)
-
src/3rdparty/libpng/pngwutil.c (modified) (121 diffs)
-
src/3rdparty/libpng/scripts/CMakeLists.txt (modified) (9 diffs)
-
src/3rdparty/libpng/scripts/descrip.mms (modified) (4 diffs)
-
src/3rdparty/libpng/scripts/libpng-config-head.in (modified) (1 diff)
-
src/3rdparty/libpng/scripts/libpng-config.in (modified) (2 diffs)
-
src/3rdparty/libpng/scripts/libpng.icc (modified) (2 diffs)
-
src/3rdparty/libpng/scripts/libpng.pc-configure.in (modified) (1 diff)
-
src/3rdparty/libpng/scripts/libpng.pc.in (modified) (1 diff)
-
src/3rdparty/libpng/scripts/makefile.32sunu (modified) (1 diff)
-
src/3rdparty/libpng/scripts/makefile.64sunu (modified) (1 diff)
-
src/3rdparty/libpng/scripts/makefile.acorn (modified) (1 diff)
-
src/3rdparty/libpng/scripts/makefile.aix (modified) (5 diffs)
-
src/3rdparty/libpng/scripts/makefile.amiga (modified) (1 diff)
-
src/3rdparty/libpng/scripts/makefile.atari (modified) (1 diff)
-
src/3rdparty/libpng/scripts/makefile.bc32 (modified) (7 diffs)
-
src/3rdparty/libpng/scripts/makefile.beos (modified) (3 diffs)
-
src/3rdparty/libpng/scripts/makefile.bor (modified) (8 diffs)
-
src/3rdparty/libpng/scripts/makefile.cygwin (modified) (4 diffs)
-
src/3rdparty/libpng/scripts/makefile.darwin (modified) (4 diffs)
-
src/3rdparty/libpng/scripts/makefile.dec (modified) (3 diffs)
-
src/3rdparty/libpng/scripts/makefile.dj2 (modified) (3 diffs)
-
src/3rdparty/libpng/scripts/makefile.elf (modified) (3 diffs)
-
src/3rdparty/libpng/scripts/makefile.freebsd (modified) (1 diff)
-
src/3rdparty/libpng/scripts/makefile.gcc (modified) (4 diffs)
-
src/3rdparty/libpng/scripts/makefile.gcmmx (modified) (3 diffs)
-
src/3rdparty/libpng/scripts/makefile.hp64 (modified) (4 diffs)
-
src/3rdparty/libpng/scripts/makefile.hpgcc (modified) (2 diffs)
-
src/3rdparty/libpng/scripts/makefile.hpux (modified) (4 diffs)
-
src/3rdparty/libpng/scripts/makefile.ibmc (modified) (2 diffs)
-
src/3rdparty/libpng/scripts/makefile.intel (modified) (4 diffs)
-
src/3rdparty/libpng/scripts/makefile.knr (modified) (3 diffs)
-
src/3rdparty/libpng/scripts/makefile.linux (modified) (3 diffs)
-
src/3rdparty/libpng/scripts/makefile.mingw (modified) (4 diffs)
-
src/3rdparty/libpng/scripts/makefile.mips (modified) (2 diffs)
-
src/3rdparty/libpng/scripts/makefile.msc (modified) (3 diffs)
-
src/3rdparty/libpng/scripts/makefile.ne12bsd (modified) (3 diffs)
-
src/3rdparty/libpng/scripts/makefile.netbsd (modified) (3 diffs)
-
src/3rdparty/libpng/scripts/makefile.nommx (modified) (3 diffs)
-
src/3rdparty/libpng/scripts/makefile.openbsd (modified) (3 diffs)
-
src/3rdparty/libpng/scripts/makefile.os2 (modified) (2 diffs)
-
src/3rdparty/libpng/scripts/makefile.sco (modified) (1 diff)
-
src/3rdparty/libpng/scripts/makefile.sggcc (modified) (4 diffs)
-
src/3rdparty/libpng/scripts/makefile.sgi (modified) (3 diffs)
-
src/3rdparty/libpng/scripts/makefile.so9 (modified) (2 diffs)
-
src/3rdparty/libpng/scripts/makefile.solaris (modified) (2 diffs)
-
src/3rdparty/libpng/scripts/makefile.solaris-x86 (modified) (2 diffs)
-
src/3rdparty/libpng/scripts/makefile.std (modified) (3 diffs)
-
src/3rdparty/libpng/scripts/makefile.sunos (modified) (3 diffs)
-
src/3rdparty/libpng/scripts/makefile.vcawin32 (modified) (4 diffs)
-
src/3rdparty/libpng/scripts/makefile.vcwin32 (modified) (3 diffs)
-
src/3rdparty/libpng/scripts/makefile.watcom (modified) (1 diff)
-
src/3rdparty/libpng/scripts/makevms.com (modified) (2 diffs)
-
src/3rdparty/libpng/scripts/pngos2.def (modified) (1 diff)
-
src/3rdparty/libpng/scripts/pngw32.def (modified) (2 diffs)
-
src/3rdparty/libpng/scripts/smakefile.ppc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/3rdparty/libpng/ANNOUNCE
r2 r561 1 1 2 Libpng 1.2. 29 - May 8, 20082 Libpng 1.2.40 - September 10, 2009 3 3 4 4 This is a public release of libpng, intended for use in production codes. … … 9 9 "configure" script 10 10 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 15 14 16 15 Source files with LF line endings (for Unix/Linux) without the 17 16 "configure" script 18 17 19 libpng-1.2. 29-no-config.tar.gz20 libpng-1.2. 29-no-config.tar.lzma21 libpng-1.2. 29-no-config.tar.bz218 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 22 21 23 22 Source files with CRLF line endings (for Windows), without the 24 23 "configure" script 25 24 26 lpng12 29.zip27 lpng12 29.7z28 lpng12 29.tar.bz225 lpng1240.zip 26 lpng1240.7z 27 lpng1240.tar.bz2 29 28 30 29 Project files 31 30 32 libpng-1.2. 29-project-netware.zip33 libpng-1.2. 29-project-wince.zip31 libpng-1.2.40-project-netware.zip 32 libpng-1.2.40-project-wince.zip 34 33 35 34 Other information: 36 35 37 libpng-1.2. 29-README.txt38 libpng-1.2. 29-KNOWNBUGS.txt39 libpng-1.2. 29-LICENSE.txt40 libpng-1.2. 29-Y2K-compliance.txt41 libpng-1.2. 29-[previous version]-diff.txt36 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 42 41 43 Changes since the last public release (1.2. 28):42 Changes since the last public release (1.2.39): 44 43 45 version 1.2. 29 [May 8, 2008]44 version 1.2.40 [September 10, 2009] 46 45 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) 55 49 56 50 Send comments/corrections/commendations to png-mng-implement at lists.sf.net 57 (subscription required; visit 51 52 Send comments/corrections/commendations to png-mng-implement at lists.sf.net 53 (subscription required; visit 58 54 https://lists.sourceforge.net/lists/listinfo/png-mng-implement 59 55 to subscribe) or to glennrp at users.sourceforge.net -
trunk/src/3rdparty/libpng/CHANGES
r2 r561 1 1 /* 2 2 CHANGES - changes for libpng 3 3 … … 540 540 Renamed "PNG_GLOBAL_ARRAYS" to "PNG_USE_GLOBAL_ARRAYS" and made available 541 541 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. 543 544 Added PNG_EXPORT_VAR macro to accommodate making DLL's. 544 545 version 1.0.5e [November 30, 1999] … … 1180 1181 Detect buffer overflow in pngpread.c when IDAT is corrupted with extra data. 1181 1182 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, 1183 1184 makefile.solaris, makefile.hpux, makefile.hpgcc, and makefile.so9. 1184 1185 version 1.2.4rc1 and 1.0.14rc1 [July 2, 2002] … … 1301 1302 sequential read support. 1302 1303 Added some "#if PNG_WRITE_SUPPORTED" blocks. 1303 #ifdef'ed out some redundancyin png_malloc_default().1304 Removed some redundancy with #ifdef/#endif in png_malloc_default(). 1304 1305 Use png_malloc instead of png_zalloc to allocate the pallete. 1305 1306 version 1.0.16rc1 and 1.2.6rc1 [August 4, 2004] … … 1371 1372 strip alpha operation in png_do_strip_filler(). 1372 1373 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) 1374 1376 version 1.2.8beta2 [November 2, 2004] 1375 1377 Reduce color_type to a nonalpha type after strip alpha operation in … … 1388 1390 PNG_STRIP_ALPHA info to png_do_strip_filler(), to preserve ABI 1389 1391 compatibility. 1390 Revised handling of SPECIALBUILD, PRIVATEBUILD, 1392 Revised handling of SPECIALBUILD, PRIVATEBUILD, 1391 1393 PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING. 1392 1394 version 1.2.8rc1 [November 24, 2004] … … 1686 1688 version 1.2.16beta2 [January 16, 2007] 1687 1689 Revised scripts/CMakeLists.txt 1688 1690 1689 1691 version 1.0.24, 1.2.16 [January 31, 2007] 1690 1692 No changes. 1691 1693 1692 1694 version 1.2.17beta1 [March 6, 2007] 1693 1695 Revised scripts/CMakeLists.txt to install both shared and static libraries. 1694 1696 Deleted a redundant line from pngset.c. 1695 1697 1696 1698 version 1.2.17beta2 [April 26, 2007] 1697 1699 Relocated misplaced test for png_ptr == NULL in pngpread.c … … 1714 1716 can be free'ed in case of error. Revised unknown chunk handling in 1715 1717 pngrutil.c and pngpread.c to use this structure. 1716 1718 1717 1719 version 1.2.17rc3 [May 8, 2007] 1718 1720 Revised symbol-handling in configure script. … … 1757 1759 1758 1760 version 1.2.19beta7 [May 22, 2007] 1759 Squelched png_squelch_warnings() in pnggccrd.c and added an1760 #ifdef PNG_MMX_CODE_SUPPORTED block around the declarations that caused1761 th e 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. 1762 1764 1763 1765 version 1.2.19beta8 [May 22, 2007] … … 2108 2110 unknown chunks. 2109 2111 Added more information about png_set_keep_unknown_chunks() to the 2110 docume tation.2112 documentation. 2111 2113 Reject tRNS chunk with out-of-range samples instead of masking off 2112 2114 the invalid high bits as done in since libpng-1.2.19beta5. … … 2128 2130 2129 2131 version 1.2.27beta05 [April 19, 2008] 2130 Added MAINT EINERCLEANFILES variable to Makefile.am2132 Added MAINTAINERCLEANFILES variable to Makefile.am 2131 2133 2132 2134 version 1.2.27beta06 [April 21, 2008] … … 2157 2159 Changed $(ECHO) to echo in Makefile.am and Makefile.in 2158 2160 Updated all configure files to autoconf-2.62 2159 #ifdef out pnggcrd.c codeif using MSC_VER2161 Comment out pnggcrd.c code with #ifdef/#endif if using MSC_VER 2160 2162 2161 2163 version 1.2.29rc01 [May 4, 2008] … … 2163 2165 2164 2166 version 1.0.35 and 1.2.29 [May 8, 2008] 2167 No changes. 2168 2169 version 1.0.37 [May 9, 2008] 2170 Updated Makefile.in and configure (omitted version 1.0.36). 2171 2172 version 1.2.30beta01 [May 29, 2008] 2173 Updated libpng.pc-configure.in and libpng-config.in per debian bug reports. 2174 2175 version 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 2179 version 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 2188 version 1.2.30beta04 [July 10, 2008] 2189 Merged more cosmetic whitespace changes from libpng-1.4.0beta19. 2190 2191 version 1.0.38rc01, 1.2.30rc01 [July 18, 2008] 2192 No changes. 2193 2194 version 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 2199 version 1.0.38rc03, 1.2.30rc03 [July 21, 2008] 2200 Changed "purpose" and "buffer" to png_ptr->chunkdata to avoid memory leaking. 2201 2202 version 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 2206 version 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 2213 version 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 2217 version 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 2224 version 1.0.38r08, 1.2.30r08 [August 2, 2008] 2225 Enclose "volatile" declarations in #ifdef PNG_SETJMP_SUPPORTED (Cosmin). 2226 2227 version 1.0.38, 1.2.30 [August 14, 2008] 2228 No changes. 2229 2230 version 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 2234 version 1.2.31rc02 [August 19, 2008] 2235 Added PNG_WRITE_FLUSH_SUPPORTED block around new png_flush() call. 2236 2237 version 1.2.31rc03 [August 19, 2008] 2238 Added PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED block, off by default, around 2239 new png_flush(). 2240 2241 version 1.0.39, 1.2.31 [August 21, 2008] 2242 No changes. 2243 2244 version 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 2251 version 1.0.40, 1.2.32 [September 18, 2008] 2252 No changes. 2253 2254 version 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 2259 version 1.2.33rc01 [October 15, 2008] 2260 No changes. 2261 2262 version 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 2266 version 1.2.33 [October 31, 2008] 2267 No changes. 2268 2269 version 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 2281 version 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 2285 version 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 2289 version 1.2.34beta04 [December 2, 2008] 2290 More merging with png_debug from libpng-1.4.0 to remove newlines. 2291 2292 version 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 2297 version 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 2301 version 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 2306 version 1.0.42rc01, 1.2.34rc01 [December 11, 2008] 2307 No changes. 2308 2309 version 1.0.42, 1.2.34 [December 18, 2008] 2310 No changes. 2311 2312 version 1.2.35beta01 [February 4, 2009] 2313 Zero out some arrays of pointers after png_malloc(). (Tavis Ormandy) 2314 2315 version 1.2.35beta02 [February 4, 2009] 2316 Zero out more arrays of pointers after png_malloc(). 2317 2318 version 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 2322 version 1.2.35rc01 [February 11, 2009] 2323 No changes. 2324 2325 version 1.2.35rc02 [February 12, 2009] 2326 Fix typo in new png_memset call in pngset.c (png_color should be png_charp) 2327 2328 version 1.0.43 and 1.2.35 [February 14, 2009] 2329 No changes. 2330 2331 version 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 2336 version 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 2345 version 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 2351 version 1.2.36beta04 [April 5, 2009] 2352 Fixed potential memory leak of "new_name" in png_write_iCCP() (Ralph Giles) 2353 2354 version 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 2364 version 1.2.36rc01 [April 30, 2009] 2365 No changes. 2366 2367 version 1.0.44 and 1.2.36 [May 7, 2009] 2368 No changes. 2369 2370 version 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 2378 version 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 2386 version 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 2392 version 1.2.37rc01 [May 27, 2009] 2393 No changes. 2394 2395 versions 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 2405 version 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 2418 version 1.0.46 [June 18, 2009] 2419 Removed some editing cruft from scripts/libpng.pc.in and some makefiles. 2420 2421 version 1.2.38rc01 [June 24, 2009] 2422 No changes. 2423 2424 version 1.2.38rc02 [June 29, 2009] 2425 Added a reference to the libpng license in each source file. 2426 2427 version 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 2432 version 1.0.47 and 1.2.38 [July 16, 2009] 2433 No changes. 2434 2435 version 1.2.39beta01 [July 25, 2009] 2436 Added a prototype for png_64bit_product() in png.c 2437 2438 version 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 2442 version 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 2448 version 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 2452 version 1.2.39beta05 [August 1, 2009] 2453 Reject attempt to write iCCP chunk with negative embedded profile length 2454 (JD Chen) 2455 2456 version 1.2.39c01 [August 6, 2009] 2457 No changes. 2458 2459 version 1.2.39 and 1.0.48 [August 13, 2009] 2460 No changes. 2461 2462 version 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 2466 version 1.2.40rc01 [September 2, 2009] 2467 Various bugfixes and improvements to CMakeLists.txt (Philip Lowman) 2468 2469 version 1.2.40 and 1.0.49 [September 10, 2009] 2165 2470 No changes. 2166 2471 … … 2172 2477 2173 2478 Glenn R-P 2479 */ -
trunk/src/3rdparty/libpng/INSTALL
r2 r561 1 1 2 Installing libpng version 1.2. 29 - May 8, 20082 Installing libpng version 1.2.40 - September 10, 2009 3 3 4 4 On Unix/Linux and similar systems, you can simply type … … 45 45 46 46 You can rename the directories that you downloaded (they 47 might be called "libpng-1.2. 29" or "lpng109" and "zlib-1.2.1"47 might be called "libpng-1.2.40" or "lpng109" and "zlib-1.2.1" 48 48 or "zlib121") so that you have directories called "zlib" and "libpng". 49 49 … … 102 102 makefile.std => Generic UNIX makefile (cc, creates static libpng.a) 103 103 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) 105 105 makefile.linux => Linux/ELF makefile 106 (gcc, creates libpng12.so.0.1.2. 29)106 (gcc, creates libpng12.so.0.1.2.40) 107 107 makefile.gcc => Generic makefile (gcc, creates static libpng.a) 108 108 makefile.knr => Archaic UNIX Makefile that converts files with … … 126 126 makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib) 127 127 makefile.sggcc => Silicon Graphics (gcc, 128 creates libpng12.so.0.1.2. 29)128 creates libpng12.so.0.1.2.40) 129 129 makefile.sunos => Sun makefile 130 130 makefile.solaris => Solaris 2.X makefile (gcc, 131 creates libpng12.so.0.1.2. 29)131 creates libpng12.so.0.1.2.40) 132 132 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) 134 134 makefile.so9 => Solaris 9 makefile (gcc, 135 creates libpng12.so.0.1.2. 29)135 creates libpng12.so.0.1.2.40) 136 136 makefile.32sunu => Sun Ultra 32-bit makefile 137 137 makefile.64sunu => Sun Ultra 64-bit makefile -
trunk/src/3rdparty/libpng/KNOWNBUG
r2 r561 1 1 2 Known bugs in libpng version 1.2. 292 Known bugs in libpng version 1.2.40 3 3 4 4 1. February 23, 2006: The custom makefiles don't build libpng with -lz. -
trunk/src/3rdparty/libpng/LICENSE
r2 r561 9 9 this sentence. 10 10 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 11 This code is released under the libpng license. 12 13 libpng versions 1.2.6, August 15, 2004, through 1.2.40, September 10, 2009, are 14 Copyright (c) 2004, 2006-2009 Glenn Randers-Pehrson, and are 13 15 distributed according to the same disclaimer and license as libpng-1.2.5 14 16 with the following individual added to the list of Contributing Authors … … 107 109 Glenn Randers-Pehrson 108 110 glennrp at users.sourceforge.net 109 May 8, 2008 111 September 10, 2009 -
trunk/src/3rdparty/libpng/README
r2 r561 1 README for libpng version 1.2. 29 - May 8, 2008(shared library 12.0)1 README for libpng version 1.2.40 - September 10, 2009 (shared library 12.0) 2 2 See the note about version numbers near the top of png.h 3 3 … … 7 7 libpng-*.tar.lzma, or libpng-*.tar.bz2 if you want UNIX-style line 8 8 endings in the text files, or lpng*.7z or lpng*.zip if you want DOS-style 9 line endings. 9 line endings. You can get UNIX-style line endings from the *.zip file 10 by using "unzip -a" but there seems to be no simple way to recover 11 UNIX-style line endings from the *.7z file. The *.tar.lzma file is 12 recommended for *NIX users instead. 10 13 11 14 Version 0.89 was the first official release of libpng. Don't let the … … 56 59 57 60 The changes made to the library, and bugs fixed are based on discussions 58 on the PNG-implement mailing list61 on the png-mng-implement mailing list 59 62 and not on material submitted privately to Guy, Andreas, or Glenn. They will 60 63 forward any good suggestions to the list. … … 112 115 You can't reach Guy, the original libpng author, at the addresses 113 116 given in previous versions of this document. He and Andreas will read mail 114 addressed to the png- implement list, however.117 addressed to the png-mng-implement list, however. 115 118 116 119 Please do not send general questions about PNG. Send them to … … 119 122 On the other hand, 120 123 please do not send libpng questions to that address, send them to me 121 or to the png- implement list. I'll124 or to the png-mng-implement list. I'll 122 125 get them in the end anyway. If you have a question about something 123 126 in the PNG specification that is related to using libpng, send it … … 192 195 makefile.std => Generic UNIX makefile (cc, creates static libpng.a) 193 196 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) 195 198 makefile.linux => Linux/ELF makefile 196 (gcc, creates libpng12.so.0.1.2. 29)199 (gcc, creates libpng12.so.0.1.2.40) 197 200 makefile.gcmmx => Linux/ELF makefile 198 (gcc, creates libpng12.so.0.1.2. 29,201 (gcc, creates libpng12.so.0.1.2.40, 199 202 uses assembler code tuned for Intel MMX platform) 200 203 makefile.gcc => Generic makefile (gcc, creates static libpng.a) … … 218 221 makefile.sgi => Silicon Graphics IRIX (cc, creates static lib) 219 222 makefile.sggcc => Silicon Graphics 220 (gcc, creates libpng12.so.0.1.2. 29)223 (gcc, creates libpng12.so.0.1.2.40) 221 224 makefile.sunos => Sun makefile 222 225 makefile.solaris => Solaris 2.X makefile 223 (gcc, creates libpng12.so.0.1.2. 29)226 (gcc, creates libpng12.so.0.1.2.40) 224 227 makefile.so9 => Solaris 9 makefile 225 (gcc, creates libpng12.so.0.1.2. 29)228 (gcc, creates libpng12.so.0.1.2.40) 226 229 makefile.32sunu => Sun Ultra 32-bit makefile 227 230 makefile.64sunu => Sun Ultra 64-bit makefile -
trunk/src/3rdparty/libpng/TODO
r2 r561 23 23 background and doing rgb-to-gray transformation. 24 24 Investigate pre-incremented loop counters and other loop constructions. 25 Add interpolated method of handling interlacing. -
trunk/src/3rdparty/libpng/Y2KINFO
r2 r561 2 2 ========================= 3 3 4 May 8, 20084 September 10, 2009 5 5 6 6 Since the PNG Development group is an ad-hoc body, we can't make … … 8 8 9 9 This is your unofficial assurance that libpng from version 0.71 and 10 upward through 1.2. 29are Y2K compliant. It is my belief that earlier10 upward through 1.2.40 are Y2K compliant. It is my belief that earlier 11 11 versions were also Y2K compliant. 12 12 -
trunk/src/3rdparty/libpng/configure
r2 r561 2 2 echo " 3 3 There is no \"configure\" script in this distribution of 4 libpng-1.2. 29.4 libpng-1.2.40. 5 5 6 6 Instead, please copy the appropriate makefile for your system from the … … 9 9 Update, July 2004: you can get a \"configure\" based distribution 10 10 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.bz211 libpng-1.2.40.tar.gz, libpng-1.2.40.tar.lzma, or libpng-1.2.40.tar.bz2 12 12 " 13 13 -
trunk/src/3rdparty/libpng/example.c
r2 r561 3 3 4 4 /* 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] 6 6 * This file has been placed in the public domain by the authors. 7 * Maintained 1998-200 7Glenn Randers-Pehrson7 * Maintained 1998-2009 Glenn Randers-Pehrson 8 8 * Maintained 1996, 1997 Andreas Dilger) 9 9 * Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) … … 92 92 if ((fp = fopen(file_name, "rb")) == NULL) 93 93 return (ERROR); 94 94 95 #else no_open_file /* prototype 2 */ 95 void read_png(FILE *fp, unsigned int sig_read) /* file is already open */96 void read_png(FILE *fp, unsigned int sig_read) /* File is already open */ 96 97 { 97 98 png_structp png_ptr; … … 99 100 png_uint_32 width, height; 100 101 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! */ 102 103 103 104 /* Create and initialize the png_struct with the desired error handler … … 165 166 */ 166 167 png_read_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL); 168 167 169 #else 168 170 /* OK, you're doing it the hard way, with the lower-level functions */ … … 176 178 &interlace_type, int_p_NULL, int_p_NULL); 177 179 178 /* Set up the data transformations you want. Note that these are all179 * optional. Only call them if you want/need them. Many of the180 * transformations only work on specific types of images, and many181 * 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 */ 185 187 png_set_strip_16(png_ptr); 186 188 … … 205 207 /* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */ 206 208 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); 208 210 209 211 /* Expand paletted or RGB images with transparency to full alpha channels … … 229 231 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); 230 232 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 */ 235 238 if (/* We have a user-defined screen gamma value */) 236 239 { … … 245 248 else 246 249 { 247 screen_gamma = 2.2; /* A good guess for a PC monitor sin a dimly250 screen_gamma = 2.2; /* A good guess for a PC monitor in a dimly 248 251 lit room */ 249 252 screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */ … … 278 281 279 282 /* This reduces the image to the application supplied palette */ 280 if (/* we have our own palette */)283 if (/* We have our own palette */) 281 284 { 282 285 /* An array of colors to which the image should be dithered */ … … 298 301 } 299 302 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 */ 301 304 png_set_invert_mono(png_ptr); 302 305 … … 307 310 if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT)) 308 311 { 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) */ 316 319 if (color_type & PNG_COLOR_MASK_COLOR) 317 320 png_set_bgr(png_ptr); 318 321 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) */ 320 323 png_set_swap_alpha(png_ptr); 321 324 322 /* swap bytes of 16 bit files to least significant byte first */325 /* Swap bytes of 16 bit files to least significant byte first */ 323 326 png_set_swap(png_ptr); 324 327 … … 343 346 png_bytep row_pointers[height]; 344 347 348 /* Clear the pointer array */ 345 349 for (row = 0; row < height; row++) 346 { 350 row_pointers[row] = NULL; 351 352 for (row = 0; row < height; row++) 347 353 row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr, 348 354 info_ptr)); 349 }350 355 351 356 /* Now it's time to read the image. One of these methods is REQUIRED */ … … 373 378 png_read_rows(png_ptr, png_bytepp_NULL, &row_pointers[y], 374 379 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 */ 376 381 } 377 382 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 */ 385 389 png_read_end(png_ptr, info_ptr); 386 390 #endif hilevel … … 388 392 /* At this point you have read the entire image */ 389 393 390 /* clean up after the read, and free any memory allocated - REQUIRED */394 /* Clean up after the read, and free any memory allocated - REQUIRED */ 391 395 png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); 392 396 393 /* close the file */397 /* Close the file */ 394 398 fclose(fp); 395 399 396 /* that's it */400 /* That's it */ 397 401 return (OK); 398 402 } 399 403 400 /* progressively read a file */404 /* Progressively read a file */ 401 405 402 406 int … … 463 467 /* This one's new also. Simply give it chunks of data as 464 468 * 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. 466 470 * The library seems to run fine with sizes of 4K, although 467 471 * you can give it much less if necessary (I assume you can … … 477 481 info_callback(png_structp png_ptr, png_infop info) 478 482 { 479 /* do any setup here, including setting any of the transformations480 * 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 set483 * 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 */ 486 490 } 487 491 … … 489 493 png_uint_32 row_num, int pass) 490 494 { 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 507 512 /* Check if row_num is in bounds. */ 508 if ((row_num >= 0) && (row_num < height))513 if ((row_num >= 0) && (row_num < height)) 509 514 { 510 515 /* Get pointer to corresponding row in our … … 516 521 * data to the corresponding row data. 517 522 */ 518 if ((old_row != NULL) && (new_row != NULL))523 if ((old_row != NULL) && (new_row != NULL)) 519 524 png_progressive_combine_row(png_ptr, old_row, new_row); 520 525 } 521 /*522 * The rows and passes are called in order, so you don't really523 * need the row_num and pass, but I'm supplying them because it524 * may make your life easier.525 *526 * For the non-NULL rows of interlaced images, you must call527 * png_progressive_combine_row() passing in the new row and the528 * old row, as demonstrated above. You can call this function for529 * NULL rows (it will just return) and for non-interlaced images530 * (it just does the png_memcpy for you) if it will make the code531 * 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 */ 533 538 534 539 png_progressive_combine_row(png_ptr, old_row, new_row); 535 540 536 /* where old_row is what was displayed for previous rows. Note537 * that the first pass (pass == 0 really) will completely cover538 * the old row, so the rows do not have to be initialized. After539 * the first pass (and only for interlaced images), you will have540 * to pass the current row as new_row, and the function will combine541 * 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 */ 543 548 } 544 549 545 550 end_callback(png_structp png_ptr, png_infop info) 546 551 { 547 /* this function is called when the whole image has been read,548 * including any chunks after the image (up to and including549 * the IEND). You will usually have the same info chunk as you550 * had in the header, although some data may have been added551 * to the comments and time fields.552 *553 * Most people won't do much here, perhaps setting a flag that554 * 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 */ 556 561 } 557 562 558 /* write a png file */563 /* Write a png file */ 559 564 void write_png(char *file_name /* , ... other image information ... */) 560 565 { … … 564 569 png_colorp palette; 565 570 566 /* open the file */571 /* Open the file */ 567 572 fp = fopen(file_name, "wb"); 568 573 if (fp == NULL) … … 598 603 if (setjmp(png_jmpbuf(png_ptr))) 599 604 { 600 /* If we get here, we had a problem reading the file */605 /* If we get here, we had a problem writing the file */ 601 606 fclose(fp); 602 607 png_destroy_write_struct(&png_ptr, &info_ptr); … … 605 610 606 611 /* One of the following I/O initialization functions is REQUIRED */ 612 607 613 #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 */ 609 615 png_init_io(png_ptr, fp); 616 610 617 #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 */ 613 621 png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn, 614 622 user_IO_flush_function); 615 623 /* 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 */ 617 625 618 626 #ifdef hilevel 619 627 /* This is the easy way. Use it if you already have all the 620 * image info living in fo inthe structure. You could "|" many628 * image info living in the structure. You could "|" many 621 629 * PNG_TRANSFORM flags into the png_transforms integer here. 622 630 */ 623 631 png_write_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL); 632 624 633 #else 625 634 /* This is the hard way */ … … 636 645 PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); 637 646 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 */ 639 648 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 ... */ 642 651 png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH); 643 652 /* 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 */ 649 660 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 */ 651 662 sig_bit.red = true_red_bit_depth; 652 663 sig_bit.green = true_green_bit_depth; 653 664 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 */ 655 666 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); 657 668 658 669 … … 679 690 png_set_text(png_ptr, info_ptr, text_ptr, 3); 680 691 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 */ 684 698 685 699 /* Write the file header information. REQUIRED */ … … 693 707 * png_write_info(png_ptr, info_ptr); 694 708 * 695 * However, given the level of known- and unknown-chunk support in 1. 1.0709 * However, given the level of known- and unknown-chunk support in 1.2.0 696 710 * and up, this should no longer be necessary. 697 711 */ … … 703 717 */ 704 718 705 /* set up the transformations you want. Note that these are719 /* Set up the transformations you want. Note that these are 706 720 * all optional. Only call them if you want them. 707 721 */ 708 722 709 /* invert monochrome pixels */723 /* Invert monochrome pixels */ 710 724 png_set_invert_mono(png_ptr); 711 725 … … 715 729 png_set_shift(png_ptr, &sig_bit); 716 730 717 /* pack pixels into bytes */731 /* Pack pixels into bytes */ 718 732 png_set_packing(png_ptr); 719 733 720 /* swap location of alpha bytes from ARGB to RGBA */734 /* Swap location of alpha bytes from ARGB to RGBA */ 721 735 png_set_swap_alpha(png_ptr); 722 736 … … 726 740 png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); 727 741 728 /* flip BGR pixels to RGB */742 /* Flip BGR pixels to RGB */ 729 743 png_set_bgr(png_ptr); 730 744 731 /* swap bytes of 16-bit files to most significant byte first */745 /* Swap bytes of 16-bit files to most significant byte first */ 732 746 png_set_swap(png_ptr); 733 747 734 /* swap bits of 1, 2, 4 bit packed pixel formats */748 /* Swap bits of 1, 2, 4 bit packed pixel formats */ 735 749 png_set_packswap(png_ptr); 736 750 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() */ 738 752 if (interlacing) 739 753 number_passes = png_set_interlace_handling(png_ptr); … … 756 770 757 771 /* 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 */ 759 774 png_write_image(png_ptr, row_pointers); 760 775 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 764 780 /* The number of passes is either 1 for non-interlaced images, 765 781 * or 7 for interlaced images. … … 772 788 /* If you are only writing one row at a time, this works */ 773 789 for (y = 0; y < height; y++) 774 {775 790 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 */ 779 793 780 794 /* 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 public795 * as well. Shouldn't be necessary in 1.2.0 and up as all the public 782 796 * chunks are supported and you can use png_set_unknown_chunks() to 783 797 * register unknown chunks into the info structure to be written out. … … 789 803 790 804 /* 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 */ 795 810 png_free(png_ptr, palette); 796 palette =NULL;811 palette = NULL; 797 812 798 813 /* 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 */ 801 817 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 */ 805 826 png_destroy_write_struct(&png_ptr, &info_ptr); 806 827 807 /* close the file */828 /* Close the file */ 808 829 fclose(fp); 809 830 810 /* that's it */831 /* That's it */ 811 832 return (OK); 812 833 } -
trunk/src/3rdparty/libpng/libpng.3
r2 r561 1 .TH LIBPNG 3 " May 8, 2008"1 .TH LIBPNG 3 "September 10, 2009" 2 2 .SH NAME 3 libpng \- Portable Network Graphics (PNG) Reference Library 1.2. 293 libpng \- Portable Network Graphics (PNG) Reference Library 1.2.40 4 4 .SH SYNOPSIS 5 \fB 6 #include <png.h>\fP 5 \fI\fB 6 7 \fB#include <png.h>\fP 8 9 \fI\fB 7 10 8 11 \fBpng_uint_32 png_access_version_number \fI(void\fP\fB);\fP 9 12 13 \fI\fB 14 10 15 \fBint png_check_sig (png_bytep \fP\fIsig\fP\fB, int \fInum\fP\fB);\fP 11 16 17 \fI\fB 18 12 19 \fBvoid png_chunk_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP 13 20 21 \fI\fB 22 14 23 \fBvoid png_chunk_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP 15 24 25 \fI\fB 26 16 27 \fBvoid png_convert_from_struct_tm (png_timep \fP\fIptime\fP\fB, struct tm FAR * \fIttime\fP\fB);\fP 17 28 29 \fI\fB 30 18 31 \fBvoid png_convert_from_time_t (png_timep \fP\fIptime\fP\fB, time_t \fIttime\fP\fB);\fP 19 32 33 \fI\fB 34 20 35 \fBpng_charp png_convert_to_rfc1123 (png_structp \fP\fIpng_ptr\fP\fB, png_timep \fIptime\fP\fB);\fP 21 36 37 \fI\fB 38 22 39 \fBpng_infop png_create_info_struct (png_structp \fIpng_ptr\fP\fB);\fP 23 40 41 \fI\fB 42 24 43 \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 25 44 45 \fI\fB 46 26 47 \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 27 48 49 \fI\fB 50 28 51 \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 29 52 53 \fI\fB 54 30 55 \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 31 56 57 \fI\fB 58 32 59 \fBint png_debug(int \fP\fIlevel\fP\fB, png_const_charp \fImessage\fP\fB);\fP 33 60 61 \fI\fB 62 34 63 \fBint png_debug1(int \fP\fIlevel\fP\fB, png_const_charp \fP\fImessage\fP\fB, \fIp1\fP\fB);\fP 35 64 65 \fI\fB 66 36 67 \fBint png_debug2(int \fP\fIlevel\fP\fB, png_const_charp \fP\fImessage\fP\fB, \fP\fIp1\fP\fB, \fIp2\fP\fB);\fP 37 68 69 \fI\fB 70 38 71 \fBvoid png_destroy_info_struct (png_structp \fP\fIpng_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP 39 72 73 \fI\fB 74 40 75 \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 41 76 77 \fI\fB 78 42 79 \fBvoid png_destroy_write_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP 43 80 81 \fI\fB 82 44 83 \fBvoid png_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP 45 84 85 \fI\fB 86 46 87 \fBvoid png_free (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP 47 88 89 \fI\fB 90 48 91 \fBvoid png_free_chunk_list (png_structp \fIpng_ptr\fP\fB);\fP 49 92 93 \fI\fB 94 50 95 \fBvoid png_free_default(png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP 51 96 97 \fI\fB 98 52 99 \fBvoid png_free_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fInum\fP\fB);\fP 53 100 101 \fI\fB 102 54 103 \fBpng_byte png_get_bit_depth (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 55 104 105 \fI\fB 106 56 107 \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 57 108 109 \fI\fB 110 58 111 \fBpng_byte png_get_channels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 59 112 113 \fI\fB 114 60 115 \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 61 116 117 \fI\fB 118 62 119 \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 63 120 121 \fI\fB 122 64 123 \fBpng_byte png_get_color_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 65 124 125 \fI\fB 126 66 127 \fBpng_byte png_get_compression_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 67 128 129 \fI\fB 130 68 131 \fBpng_byte png_get_copyright (png_structp \fIpng_ptr\fP\fB);\fP 69 132 133 \fI\fB 134 70 135 \fBpng_voidp png_get_error_ptr (png_structp \fIpng_ptr\fP\fB);\fP 71 136 137 \fI\fB 138 72 139 \fBpng_byte png_get_filter_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 73 140 141 \fI\fB 142 74 143 \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 75 144 145 \fI\fB 146 76 147 \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 77 148 149 \fI\fB 150 78 151 \fBpng_byte png_get_header_ver (png_structp \fIpng_ptr\fP\fB);\fP 79 152 153 \fI\fB 154 80 155 \fBpng_byte png_get_header_version (png_structp \fIpng_ptr\fP\fB);\fP 81 156 157 \fI\fB 158 82 159 \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 83 160 161 \fI\fB 162 84 163 \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 85 164 165 \fI\fB 166 86 167 \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 87 168 169 \fI\fB 170 88 171 \fBpng_uint_32 png_get_image_height (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 89 172 173 \fI\fB 174 90 175 \fBpng_uint_32 png_get_image_width (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 91 176 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 93 186 94 187 \fBpng_byte png_get_interlace_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 95 188 189 \fI\fB 190 96 191 \fBpng_voidp png_get_io_ptr (png_structp \fIpng_ptr\fP\fB);\fP 97 192 193 \fI\fB 194 98 195 \fBpng_byte png_get_libpng_ver (png_structp \fIpng_ptr\fP\fB);\fP 99 196 197 \fI\fB 198 100 199 \fBpng_voidp png_get_mem_ptr(png_structp \fIpng_ptr\fP\fB);\fP 101 200 201 \fI\fB 202 102 203 \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 103 204 205 \fI\fB 206 104 207 \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 105 208 209 \fI\fB 210 106 211 \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 107 212 213 \fI\fB 214 108 215 \fBfloat png_get_pixel_aspect_ratio (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 109 216 217 \fI\fB 218 110 219 \fBpng_uint_32 png_get_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 111 220 221 \fI\fB 222 112 223 \fBpng_voidp png_get_progressive_ptr (png_structp \fIpng_ptr\fP\fB);\fP 113 224 225 \fI\fB 226 114 227 \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 115 228 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 117 236 118 237 \fBpng_bytepp png_get_rows (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 119 238 239 \fI\fB 240 120 241 \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 121 242 243 \fI\fB 244 122 245 \fBpng_bytep png_get_signature (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 123 246 247 \fI\fB 248 124 249 \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 125 250 251 \fI\fB 252 126 253 \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 127 254 255 \fI\fB 256 128 257 \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 129 258 259 \fI\fB 260 130 261 \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 131 262 263 \fI\fB 264 132 265 \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 133 266 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 135 274 136 275 \fBpng_uint_32 png_get_uint_31 (png_bytep \fIbuf\fP\fB);\fP 137 276 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 139 284 140 285 \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 141 286 287 \fI\fB 288 142 289 \fBpng_voidp png_get_user_chunk_ptr (png_structp \fIpng_ptr\fP\fB);\fP 143 290 291 \fI\fB 292 144 293 \fBpng_uint_32 png_get_user_height_max( png_structp \fIpng_ptr\fP\fB);\fP 145 294 295 \fI\fB 296 146 297 \fBpng_voidp png_get_user_transform_ptr (png_structp \fIpng_ptr\fP\fB);\fP 147 298 299 \fI\fB 300 148 301 \fBpng_uint_32 png_get_user_width_max (png_structp \fIpng_ptr\fP\fB);\fP 149 302 303 \fI\fB 304 150 305 \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 151 306 307 \fI\fB 308 152 309 \fBpng_int_32 png_get_x_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 153 310 311 \fI\fB 312 154 313 \fBpng_int_32 png_get_x_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 155 314 315 \fI\fB 316 156 317 \fBpng_uint_32 png_get_x_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 157 318 319 \fI\fB 320 158 321 \fBpng_int_32 png_get_y_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 159 322 323 \fI\fB 324 160 325 \fBpng_int_32 png_get_y_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 161 326 327 \fI\fB 328 162 329 \fBpng_uint_32 png_get_y_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 163 330 331 \fI\fB 332 164 333 \fBpng_uint_32 png_get_compression_buffer_size (png_structp \fIpng_ptr\fP\fB);\fP 165 334 335 \fI\fB 336 166 337 \fBint png_handle_as_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP 167 338 339 \fI\fB 340 168 341 \fBvoid png_init_io (png_structp \fP\fIpng_ptr\fP\fB, FILE \fI*fp\fP\fB);\fP 169 342 343 \fI\fB 344 170 345 \fBDEPRECATED: void png_info_init (png_infop \fIinfo_ptr\fP\fB);\fP 171 346 347 \fI\fB 348 172 349 \fBDEPRECATED: void png_info_init_2 (png_infopp \fP\fIptr_ptr\fP\fB, png_size_t \fIpng_info_struct_size\fP\fB);\fP 173 350 351 \fI\fB 352 174 353 \fBpng_voidp png_malloc (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP 175 354 355 \fI\fB 356 176 357 \fBpng_voidp png_malloc_default(png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP 177 358 359 \fI\fB 360 178 361 \fBvoidp png_memcpy (png_voidp \fP\fIs1\fP\fB, png_voidp \fP\fIs2\fP\fB, png_size_t \fIsize\fP\fB);\fP 179 362 363 \fI\fB 364 180 365 \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 181 366 367 \fI\fB 368 182 369 \fBvoidp png_memset (png_voidp \fP\fIs1\fP\fB, int \fP\fIvalue\fP\fB, png_size_t \fIsize\fP\fB);\fP 183 370 371 \fI\fB 372 184 373 \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 185 374 375 \fI\fB 376 186 377 \fBDEPRECATED: void png_permit_empty_plte (png_structp \fP\fIpng_ptr\fP\fB, int \fIempty_plte_permitted\fP\fB);\fP 187 378 379 \fI\fB 380 188 381 \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 189 382 383 \fI\fB 384 190 385 \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 191 386 387 \fI\fB 388 192 389 \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 193 390 391 \fI\fB 392 194 393 \fBvoid png_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 195 394 395 \fI\fB 396 196 397 \fBvoid png_read_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP 197 398 399 \fI\fB 400 198 401 \fBDEPRECATED: void png_read_init (png_structp \fIpng_ptr\fP\fB);\fP 199 402 403 \fI\fB 404 200 405 \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 201 406 407 \fI\fB 408 202 409 \fBvoid png_read_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 203 410 411 \fI\fB 412 204 413 \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 205 414 415 \fI\fB 416 206 417 \fBvoid png_read_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fIdisplay_row\fP\fB);\fP 207 418 419 \fI\fB 420 208 421 \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 209 422 423 \fI\fB 424 210 425 \fBvoid png_read_update_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 211 426 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 213 434 214 435 \fBvoid png_save_uint_16 (png_bytep \fP\fIbuf\fP\fB, unsigned int \fIi\fP\fB);\fP 215 436 437 \fI\fB 438 216 439 \fBvoid png_save_uint_32 (png_bytep \fP\fIbuf\fP\fB, png_uint_32 \fIi\fP\fB);\fP 217 440 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 219 448 220 449 \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 221 450 451 \fI\fB 452 222 453 \fBvoid png_set_bgr (png_structp \fIpng_ptr\fP\fB);\fP 223 454 455 \fI\fB 456 224 457 \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 225 458 459 \fI\fB 460 226 461 \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 227 462 463 \fI\fB 464 228 465 \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 229 466 467 \fI\fB 468 230 469 \fBvoid png_set_compression_level (png_structp \fP\fIpng_ptr\fP\fB, int \fIlevel\fP\fB);\fP 231 470 471 \fI\fB 472 232 473 \fBvoid png_set_compression_mem_level (png_structp \fP\fIpng_ptr\fP\fB, int \fImem_level\fP\fB);\fP 233 474 475 \fI\fB 476 234 477 \fBvoid png_set_compression_method (png_structp \fP\fIpng_ptr\fP\fB, int \fImethod\fP\fB);\fP 235 478 479 \fI\fB 480 236 481 \fBvoid png_set_compression_strategy (png_structp \fP\fIpng_ptr\fP\fB, int \fIstrategy\fP\fB);\fP 237 482 483 \fI\fB 484 238 485 \fBvoid png_set_compression_window_bits (png_structp \fP\fIpng_ptr\fP\fB, int \fIwindow_bits\fP\fB);\fP 239 486 487 \fI\fB 488 240 489 \fBvoid png_set_crc_action (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcrit_action\fP\fB, int \fIancil_action\fP\fB);\fP 241 490 491 \fI\fB 492 242 493 \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 243 494 495 \fI\fB 496 244 497 \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 245 498 499 \fI\fB 500 246 501 \fBvoid png_set_expand (png_structp \fIpng_ptr\fP\fB);\fP 247 502 503 \fI\fB 504 248 505 \fBvoid png_set_expand_gray_1_2_4_to_8(png_structp \fIpng_ptr\fP\fB);\fP 249 506 507 \fI\fB 508 250 509 \fBvoid png_set_filler (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP 251 510 511 \fI\fB 512 252 513 \fBvoid png_set_filter (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fImethod\fP\fB, int \fIfilters\fP\fB);\fP 253 514 515 \fI\fB 516 254 517 \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 255 518 519 \fI\fB 520 256 521 \fBvoid png_set_flush (png_structp \fP\fIpng_ptr\fP\fB, int \fInrows\fP\fB);\fP 257 522 523 \fI\fB 524 258 525 \fBvoid png_set_gamma (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIscreen_gamma\fP\fB, double \fIdefault_file_gamma\fP\fB);\fP 259 526 527 \fI\fB 528 260 529 \fBvoid png_set_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fIfile_gamma\fP\fB);\fP 261 530 531 \fI\fB 532 262 533 \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 263 534 535 \fI\fB 536 264 537 \fBvoid png_set_gray_1_2_4_to_8(png_structp \fIpng_ptr\fP\fB);\fP 265 538 539 \fI\fB 540 266 541 \fBvoid png_set_gray_to_rgb (png_structp \fIpng_ptr\fP\fB);\fP 267 542 543 \fI\fB 544 268 545 \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 269 546 547 \fI\fB 548 270 549 \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 271 550 551 \fI\fB 552 272 553 \fBint png_set_interlace_handling (png_structp \fIpng_ptr\fP\fB);\fP 273 554 555 \fI\fB 556 274 557 \fBvoid png_set_invalid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fImask\fP\fB);\fP 275 558 559 \fI\fB 560 276 561 \fBvoid png_set_invert_alpha (png_structp \fIpng_ptr\fP\fB);\fP 277 562 563 \fI\fB 564 278 565 \fBvoid png_set_invert_mono (png_structp \fIpng_ptr\fP\fB);\fP 279 566 567 \fI\fB 568 280 569 \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 281 570 571 \fI\fB 572 282 573 \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 283 574 575 \fI\fB 576 284 577 \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 285 578 579 \fI\fB 580 286 581 \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 287 582 583 \fI\fB 584 288 585 \fBvoid png_set_packing (png_structp \fIpng_ptr\fP\fB);\fP 289 586 587 \fI\fB 588 290 589 \fBvoid png_set_packswap (png_structp \fIpng_ptr\fP\fB);\fP 291 590 591 \fI\fB 592 292 593 \fBvoid png_set_palette_to_rgb(png_structp \fIpng_ptr\fP\fB);\fP 293 594 595 \fI\fB 596 294 597 \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 295 598 599 \fI\fB 600 296 601 \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 297 602 603 \fI\fB 604 298 605 \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 299 606 607 \fI\fB 608 300 609 \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 301 610 611 \fI\fB 612 302 613 \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 303 614 615 \fI\fB 616 304 617 \fBvoid png_set_read_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_read_status_ptr \fIread_row_fn\fP\fB);\fP 305 618 619 \fI\fB 620 306 621 \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 307 622 623 \fI\fB 624 308 625 \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 309 626 627 \fI\fB 628 310 629 \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 311 630 631 \fI\fB 632 312 633 \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 313 634 635 \fI\fB 636 314 637 \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 315 638 639 \fI\fB 640 316 641 \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 317 642 643 \fI\fB 644 318 645 \fBvoid png_set_shift (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fItrue_bits\fP\fB);\fP 319 646 647 \fI\fB 648 320 649 \fBvoid png_set_sig_bytes (png_structp \fP\fIpng_ptr\fP\fB, int \fInum_bytes\fP\fB);\fP 321 650 651 \fI\fB 652 322 653 \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 323 654 655 \fI\fB 656 324 657 \fBvoid png_set_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIintent\fP\fB);\fP 325 658 659 \fI\fB 660 326 661 \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 327 662 663 \fI\fB 664 328 665 \fBvoid png_set_strip_16 (png_structp \fIpng_ptr\fP\fB);\fP 329 666 667 \fI\fB 668 330 669 \fBvoid png_set_strip_alpha (png_structp \fIpng_ptr\fP\fB);\fP 331 670 671 \fI\fB 672 332 673 \fBvoid png_set_swap (png_structp \fIpng_ptr\fP\fB);\fP 333 674 675 \fI\fB 676 334 677 \fBvoid png_set_swap_alpha (png_structp \fIpng_ptr\fP\fB);\fP 335 678 679 \fI\fB 680 336 681 \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 337 682 683 \fI\fB 684 338 685 \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 339 686 687 \fI\fB 688 340 689 \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 341 690 691 \fI\fB 692 342 693 \fBvoid png_set_tRNS_to_alpha(png_structp \fIpng_ptr\fP\fB);\fP 343 694 695 \fI\fB 696 344 697 \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 345 698 699 \fI\fB 700 346 701 \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 347 702 703 \fI\fB 704 348 705 \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 349 706 707 \fI\fB 708 350 709 \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 351 710 711 \fI\fB 712 352 713 \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 353 714 715 \fI\fB 716 354 717 \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 355 718 719 \fI\fB 720 356 721 \fBvoid png_set_write_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_write_status_ptr \fIwrite_row_fn\fP\fB);\fP 357 722 723 \fI\fB 724 358 725 \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 359 726 727 \fI\fB 728 360 729 \fBvoid png_set_compression_buffer_size(png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP 361 730 731 \fI\fB 732 362 733 \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 363 734 735 \fI\fB 736 364 737 \fBvoid png_start_read_image (png_structp \fIpng_ptr\fP\fB);\fP 365 738 739 \fI\fB 740 366 741 \fBvoid png_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP 367 742 743 \fI\fB 744 368 745 \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 369 746 747 \fI\fB 748 370 749 \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 371 750 751 \fI\fB 752 372 753 \fBvoid png_write_chunk_end (png_structp \fIpng_ptr\fP\fB);\fP 373 754 755 \fI\fB 756 374 757 \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 375 758 759 \fI\fB 760 376 761 \fBvoid png_write_destroy (png_structp \fIpng_ptr\fP\fB);\fP 377 762 763 \fI\fB 764 378 765 \fBvoid png_write_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 379 766 767 \fI\fB 768 380 769 \fBvoid png_write_flush (png_structp \fIpng_ptr\fP\fB);\fP 381 770 771 \fI\fB 772 382 773 \fBvoid png_write_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP 383 774 775 \fI\fB 776 384 777 \fBDEPRECATED: void png_write_init (png_structp \fIpng_ptr\fP\fB);\fP 385 778 779 \fI\fB 780 386 781 \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 387 782 783 \fI\fB 784 388 785 \fBvoid png_write_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 389 786 787 \fI\fB 788 390 789 \fBvoid png_write_info_before_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 391 790 791 \fI\fB 792 392 793 \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 393 794 795 \fI\fB 796 394 797 \fBvoid png_write_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIrow\fP\fB);\fP 395 798 799 \fI\fB 800 396 801 \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 397 802 803 \fI\fB 804 398 805 \fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP 399 806 807 \fI\fB 808 400 809 \fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP 810 811 \fI\fB 401 812 402 813 .SH DESCRIPTION … … 411 822 libpng.txt - A description on how to use and modify libpng 412 823 413 libpng version 1.2. 29 - May 8, 2008824 libpng version 1.2.40 - September 10, 2009 414 825 Updated and distributed by Glenn Randers-Pehrson 415 826 <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 419 832 420 833 Based on: 421 834 422 libpng versions 0.97, January 1998, through 1.2. 29 - May 8, 2008835 libpng versions 0.97, January 1998, through 1.2.40 - September 10, 2009 423 836 Updated and distributed by Glenn Randers-Pehrson 424 Copyright (c) 1998-200 8Glenn Randers-Pehrson837 Copyright (c) 1998-2009 Glenn Randers-Pehrson 425 838 426 839 libpng 1.0 beta 6 version 0.96 May 28, 1997 … … 552 965 file. Libpng provides a simple check to see if a file is a PNG file. 553 966 To 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. 967 png_sig_cmp(), and it will return 0 (false) if the bytes match the 968 corresponding bytes of the PNG signature, or nonzero (true) otherwise. 969 Of course, the more bytes you pass in, the greater the accuracy of the 970 prediction. 557 971 558 972 If you are intending to keep the file pointer open for use in libpng, … … 731 1145 png_set_read_status_fn(png_ptr, read_row_callback); 732 1146 733 .SS Width and height limits734 735 The PNG specification allows the width and height of an image to be as736 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. If740 you wish to override this limit, you can use741 742 png_set_user_limits(png_ptr, width_max, height_max);743 744 to set your own limits, or use width_max = height_max = 0x7fffffffL745 to allow all valid dimensions (libpng may reject some very large images746 anyway because of potential buffer overflow conditions).747 748 You should put this statement after you create the PNG structure and749 before calling png_read_info(), png_read_png(), or png_process_data().750 If you need to retrieve the limits that are being applied, use751 752 width_max = png_get_user_width_max(png_ptr);753 height_max = png_get_user_height_max(png_ptr);754 755 1147 .SS Unknown-chunk handling 756 1148 … … 758 1150 input PNG stream. Both known and unknown chunks will be read. Normal 759 1151 behavior 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: 1152 various info_ptr members while unknown chunks will be discarded. This 1153 behavior can be wasteful if your application will never use some known 1154 chunk types. To change this, you can call: 762 1155 763 1156 png_set_keep_unknown_chunks(png_ptr, keep, … … 817 1210 #endif 818 1211 1212 .SS User limits 1213 1214 The PNG specification allows the width and height of an image to be as 1215 large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns. 1216 Since very few applications really need to process such large images, 1217 we have imposed an arbitrary 1-million limit on rows and columns. 1218 Larger images will be rejected immediately with a png_error() call. If 1219 you wish to override this limit, you can use 1220 1221 png_set_user_limits(png_ptr, width_max, height_max); 1222 1223 to set your own limits, or use width_max = height_max = 0x7fffffffL 1224 to allow all valid dimensions (libpng may reject some very large images 1225 anyway because of potential buffer overflow conditions). 1226 1227 You should put this statement after you create the PNG structure and 1228 before calling png_read_info(), png_read_png(), or png_process_data(). 1229 If 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); 819 1233 820 1234 .SS The high-level read interface … … 882 1296 row_pointers = png_malloc(png_ptr, 883 1297 height*png_sizeof(png_bytep)); 1298 for (int i=0; i<height, i++) 1299 row_pointers[i]=NULL; /* security precaution */ 884 1300 for (int i=0; i<height, i++) 885 1301 row_pointers[i]=png_malloc(png_ptr, … … 1258 1674 As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was 1259 1675 added. 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 it1261 will be removed from a future version.1262 1263 1676 1264 1677 PNG can have files with 16 bits per channel. If you only can handle … … 2112 2525 PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | 2113 2526 PNG_FILTER_UP | PNG_FILTER_VALUE_UP | 2114 PNG_FILTER_AV E | PNG_FILTER_VALUE_AVE|2527 PNG_FILTER_AVG | PNG_FILTER_VALUE_AVG | 2115 2528 PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH| 2116 2529 PNG_ALL_FILTERS); … … 2202 2615 2203 2616 If you call png_set_IHDR(), the call must appear before any of the 2204 other png_set_*() functions, whichmight require access to some of2617 other png_set_*() functions, because they might require access to some of 2205 2618 the IHDR settings. The remaining png_set_*() functions can be called 2206 2619 in any order. 2620 2621 If you wish, you can reset the compression_type, interlace_type, or 2622 filter_method later by calling png_set_IHDR() again; if you do this, the 2623 width, height, bit_depth, and color_type must be the same in each call. 2207 2624 2208 2625 png_set_PLTE(png_ptr, info_ptr, palette, … … 2267 2684 trans - array of transparent entries for 2268 2685 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 2271 2689 non-paletted images (PNG_INFO_tRNS) 2272 2690 num_trans - number of transparent entries … … 2477 2895 to transparency 2478 2896 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 2480 2903 2481 2904 If you have valid image data in the info structure (you can use … … 2884 3307 void user_flush_data(png_structp png_ptr); 2885 3308 3309 The user_read_data() function is responsible for detecting and 3310 handling end-of-data errors. 3311 2886 3312 Supplying 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. 3313 to using the default C stream functions, which expect the io_ptr to 3314 point to a standard *FILE structure. It is probably a mistake 3315 to use NULL for one of write_data_fn and output_flush_fn but not both 3316 of them, unless you have built libpng with PNG_NO_WRITE_FLUSH defined. 3317 It is an error to read from a write stream, and vice versa. 2889 3318 2890 3319 Error handling in libpng is done through png_error() and png_warning(). … … 2991 3420 .SS Configuring for compiler xxx: 2992 3421 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. 3422 All includes for libpng are in pngconf.h. If you need to add, change 3423 or delete an include, this is the place to do it. 3424 The includes that are not needed outside libpng are protected by the 3425 PNG_INTERNAL definition, which is only defined for those routines inside 3426 libpng itself. The files in libpng proper only include png.h, which 3427 includes pngconf.h. 2998 3428 2999 3429 .SS Configuring zlib: … … 3064 3494 3065 3495 filters = PNG_FILTER_NONE | PNG_FILTER_SUB 3066 PNG_FILTER_UP | PNG_FILTER_AV E|3496 PNG_FILTER_UP | PNG_FILTER_AVG | 3067 3497 PNG_FILTER_PAETH | PNG_ALL_FILTERS; 3068 3498 … … 3186 3616 this version of libpng, but if you insert some they will be printed. 3187 3617 3188 .SH VI I. MNG support3618 .SH VI. MNG support 3189 3619 3190 3620 The MNG specification (available at http://www.libpng.org/pub/mng) allows … … 3211 3641 http://www.libmng.com) instead. 3212 3642 3213 .SH VII I. Changes to Libpng from version 0.883643 .SH VII. Changes to Libpng from version 0.88 3214 3644 3215 3645 It should be noted that versions of libpng later than 0.96 are not … … 3260 3690 png_uint_32 application_vn = PNG_LIBPNG_VER; 3261 3691 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 3694 Support for user memory management was enabled by default. To 3695 accomplish this, the functions png_create_read_struct_2(), 3696 png_create_write_struct_2(), png_set_mem_fn(), png_get_mem_ptr(), 3697 png_malloc_default(), and png_free_default() were added. 3698 3699 Support for certain MNG features was enabled. 3700 3701 Support for numbered error messages was added. However, we never got 3702 around to actually numbering the error messages. The function 3703 png_set_strip_error_numbers() was added (Note: the prototype for this 3704 function was inadvertently removed from png.h in PNG_NO_ASSEMBLER_CODE 3705 builds of libpng-1.2.15. It was restored in libpng-1.2.36). 3706 3707 The png_malloc_warn() function was added at libpng-1.2.3. This issues 3708 a png_warning and returns NULL instead of aborting when it fails to 3709 acquire the requested memory allocation. 3710 3711 Support for setting user limits on image width and height was enabled 3712 by default. The functions png_set_user_limits(), png_get_user_width_max(), 3713 and png_get_user_height_max() were added at libpng-1.2.6. 3714 3715 The png_set_add_alpha() function was added at libpng-1.2.7. 3716 3717 The function png_set_expand_gray_1_2_4_to_8() was added at libpng-1.2.9. 3718 Unlike png_set_gray_1_2_4_to_8(), the new function does not expand the 3719 tRNS chunk to alpha. The png_set_gray_1_2_4_to_8() function is 3720 deprecated. 3721 3722 A number of macro definitions in support of runtime selection of 3723 assembler code features (especially Intel MMX code support) were 3724 added 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 3740 We added the following functions in support of runtime 3741 selection 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 3750 We replaced all of these functions with simple stubs in libpng-1.2.20, 3751 when the Intel assembler code was removed due to a licensing issue. 3752 3753 .SH IX. (Omitted) 3754 3755 .SH X. Detecting libpng 3756 3757 The png_get_io_ptr() function has been present since libpng-0.88, has never 3758 changed, and is unaffected by conditional compilation macros. It is the 3759 best choice for use in configure scripts for detecting the presence of any 3760 libpng 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 3766 Since about February 2009, version 1.2.34, libpng has been under "git" source 3767 control. The git repository was built from old libpng-x.y.z.tar.gz files 3768 going back to version 0.70. You can access the git repository (read only) 3769 at 3770 3771 git://libpng.git.sourceforge.net/gitroot/libpng 3772 3773 or you can browse it via "gitweb" at 3774 3775 http://libpng.git.sourceforge.net/git/gitweb.cgi?p=libpng 3776 3777 Patches can be sent to glennrp at users.sourceforge.net or to 3778 png-mng-implement at lists.sourceforge.net or you can upload them to 3779 the libpng bug tracker at 3780 3781 http://libpng.sourceforge.net 3782 3783 .SH XII. Coding style 3784 3785 Our coding style is similar to the "Allman" style, with curly 3786 braces on separate lines: 3787 3788 if (condition) 3789 { 3790 action; 3791 } 3792 3793 else if (another condition) 3794 { 3795 another action; 3796 } 3797 3798 The braces can be omitted from simple one-line actions: 3799 3800 if (condition) 3801 return (0); 3802 3803 We use 3-space indentation, except for continued statements which 3804 are usually indented the same as the first line of the statement 3805 plus four more spaces. 3806 3807 Comments appear with the leading "/*" at the same indentation as 3808 the statement that follows the comment: 3809 3810 /* Single-line comment */ 3811 statement; 3812 3813 /* Multiple-line 3814 * comment 3815 */ 3816 statement; 3817 3818 Very short comments can be placed at the end of the statement 3819 to which they pertain: 3820 3821 statement; /* comment */ 3822 3823 We don't use C++ style ("//") comments. We have, however, 3824 used them in the past in some now-abandoned MMX assembler 3825 code. 3826 3827 Functions and their curly braces are not indented, and 3828 exported 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 3839 The prototypes for all exported functions appear in png.h, 3840 above the comment that says 3841 3842 /* Maintainer: Put new public prototypes here ... */ 3843 3844 We 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 3852 The prototypes for non-exported functions (except for those in 3853 pngtest) appear in 3854 the PNG_INTERNAL section of png.h 3855 above the comment that says 3856 3857 /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ 3858 3859 The names of all exported functions and variables begin 3860 with "png_", and all publicly visible C preprocessor 3861 macros begin with "PNG_". 3862 3863 We put a space after each comma and after each semicolon 3864 in "for" statments, and we put spaces before and after each 3865 C binary operator and after "for" or "while". We don't 3866 put a space between a typecast and the expression being 3867 cast, nor do we put one between a function name and the 3868 left parenthesis that follows it: 3869 3870 for (i = 2; i > 0; --i) 3871 x[i] = a(x) + (int)b; 3872 3873 We prefer #ifdef and #ifndef to #if defined() and if !defined() 3874 when there is only one macro being tested. 3875 3876 Other rules can be inferred by inspecting the libpng 3877 source. 3878 3879 .SH XIII. Y2K Compliance in libpng 3880 3881 September 10, 2009 3265 3882 3266 3883 Since the PNG Development group is an ad-hoc body, we can't make … … 3268 3885 3269 3886 This is your unofficial assurance that libpng from version 0.71 and 3270 upward through 1.2. 29are Y2K compliant. It is my belief that earlier3887 upward through 1.2.40 are Y2K compliant. It is my belief that earlier 3271 3888 versions were also Y2K compliant. 3272 3889 … … 3500 4117 1.0.35 10 10035 10.so.0.35[.0] 3501 4118 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] 3502 4169 3503 4170 Henceforth the source version will match the shared-library minor … … 3555 4222 Thanks to Frank J. T. Wojcik for helping with the documentation. 3556 4223 3557 Libpng version 1.2. 29 - May 8, 2008:4224 Libpng version 1.2.40 - September 10, 2009: 3558 4225 Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. 3559 4226 Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net). … … 3576 4243 this sentence. 3577 4244 3578 libpng versions 1.2.6, August 15, 2004, through 1.2.29, May 8, 2008, are 4245 This code is released under the libpng license. 4246 4247 libpng versions 1.2.6, August 15, 2004, through 1.2.40, September 10, 2009, are 3579 4248 Copyright (c) 2004,2006-2008 Glenn Randers-Pehrson, and are 3580 4249 distributed according to the same disclaimer and license as libpng-1.2.5 … … 3675 4344 Glenn Randers-Pehrson 3676 4345 glennrp at users.sourceforge.net 3677 May 8, 2008 4346 September 10, 2009 3678 4347 3679 4348 .\" 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" 2 2 .SH NAME 3 libpng \- Portable Network Graphics (PNG) Reference Library 1.2. 293 libpng \- Portable Network Graphics (PNG) Reference Library 1.2.40 4 4 (private functions) 5 5 .SH SYNOPSIS 6 6 \fB#include <png.h>\fP 7 7 8 \fI\fB 9 10 \fI\fB 11 8 12 \fBvoid png_build_gamma_table (png_structp \fIpng_ptr\fP\fB);\fP 9 13 14 \fI\fB 15 16 \fI\fB 17 10 18 \fBvoid png_build_grayscale_palette (int \fP\fIbit_depth\fP\fB, png_colorp \fIpalette\fP\fB);\fP 11 19 20 \fI\fB 21 22 \fI\fB 23 12 24 \fBvoid png_calculate_crc (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIptr\fP\fB, png_size_t \fIlength\fP\fB);\fP 13 25 26 \fI\fB 27 28 \fI\fB 29 14 30 \fBvoid png_check_chunk_name (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP 15 31 32 \fI\fB 33 34 \fI\fB 35 16 36 \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 17 37 38 \fI\fB 39 40 \fI\fB 41 18 42 \fBvoid png_combine_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fImask\fP\fB);\fP 19 43 44 \fI\fB 45 46 \fI\fB 47 20 48 \fBvoid png_correct_palette (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fInum_palette\fP\fB);\fP 21 49 50 \fI\fB 51 52 \fI\fB 53 22 54 \fBint png_crc_error (png_structp \fIpng_ptr\fP\fB);\fP 23 55 56 \fI\fB 57 58 \fI\fB 59 24 60 \fBint png_crc_finish (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIskip\fP\fB);\fP 25 61 62 \fI\fB 63 64 \fI\fB 65 26 66 \fBvoid png_crc_read (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuf\fP\fB, png_size_t \fIlength\fP\fB);\fP 27 67 68 \fI\fB 69 70 \fI\fB 71 28 72 \fBpng_voidp png_create_struct (int \fItype\fP\fB);\fP 29 73 74 \fI\fB 75 76 \fI\fB 77 30 78 \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 31 79 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 33 89 34 90 \fBvoid png_destroy_struct (png_voidp \fIstruct_ptr\fP\fB);\fP 35 91 92 \fI\fB 93 94 \fI\fB 95 36 96 \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 37 97 98 \fI\fB 99 100 \fI\fB 101 38 102 \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 39 103 104 \fI\fB 105 106 \fI\fB 107 40 108 \fBvoid png_do_bgr (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP 41 109 110 \fI\fB 111 112 \fI\fB 113 42 114 \fBvoid png_do_chop (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP 43 115 116 \fI\fB 117 118 \fI\fB 119 44 120 \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 45 121 122 \fI\fB 123 124 \fI\fB 125 46 126 \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 47 127 128 \fI\fB 129 130 \fI\fB 131 48 132 \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 49 133 134 \fI\fB 135 136 \fI\fB 137 50 138 \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 51 139 140 \fI\fB 141 142 \fI\fB 143 52 144 \fBvoid png_do_gray_to_rgb (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP 53 145 146 \fI\fB 147 148 \fI\fB 149 54 150 \fBvoid png_do_invert (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP 55 151 152 \fI\fB 153 154 \fI\fB 155 56 156 \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 57 157 158 \fI\fB 159 160 \fI\fB 161 58 162 \fBvoid png_do_packswap (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP 59 163 164 \fI\fB 165 166 \fI\fB 167 60 168 \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 61 169 170 \fI\fB 171 172 \fI\fB 173 62 174 \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 63 175 176 \fI\fB 177 178 \fI\fB 179 64 180 \fBvoid png_do_read_invert_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP 65 181 182 \fI\fB 183 184 \fI\fB 185 66 186 \fBvoid png_do_read_swap_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP 67 187 188 \fI\fB 189 190 \fI\fB 191 68 192 \fBvoid png_do_read_transformations (png_structp \fIpng_ptr\fP\fB);\fP 69 193 194 \fI\fB 195 196 \fI\fB 197 70 198 \fBint png_do_rgb_to_gray (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP 71 199 200 \fI\fB 201 202 \fI\fB 203 72 204 \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 73 205 206 \fI\fB 207 208 \fI\fB 209 74 210 \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 75 211 212 \fI\fB 213 214 \fI\fB 215 76 216 \fBvoid png_do_swap (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP 77 217 218 \fI\fB 219 220 \fI\fB 221 78 222 \fBvoid png_do_unpack (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP 79 223 224 \fI\fB 225 226 \fI\fB 227 80 228 \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 81 229 230 \fI\fB 231 232 \fI\fB 233 82 234 \fBvoid png_do_write_interlace (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fIpass\fP\fB);\fP 83 235 236 \fI\fB 237 238 \fI\fB 239 84 240 \fBvoid png_do_write_invert_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP 85 241 242 \fI\fB 243 244 \fI\fB 245 86 246 \fBvoid png_do_write_swap_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP 87 247 248 \fI\fB 249 250 \fI\fB 251 88 252 \fBvoid png_do_write_transformations (png_structp \fIpng_ptr\fP\fB);\fP 89 253 254 \fI\fB 255 256 \fI\fB 257 90 258 \fBvoid *png_far_to_near (png_structp png_ptr,png_voidp \fP\fIptr\fP\fB, int \fIcheck\fP\fB);\fP 91 259 260 \fI\fB 261 262 \fI\fB 263 92 264 \fBvoid png_flush (png_structp \fIpng_ptr\fP\fB);\fP 93 265 266 \fI\fB 267 268 \fI\fB 269 94 270 \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 95 271 272 \fI\fB 273 274 \fI\fB 275 96 276 \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 97 277 278 \fI\fB 279 280 \fI\fB 281 98 282 \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 99 283 284 \fI\fB 285 286 \fI\fB 287 100 288 \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 101 289 290 \fI\fB 291 292 \fI\fB 293 102 294 \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 103 295 296 \fI\fB 297 298 \fI\fB 299 104 300 \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 105 301 302 \fI\fB 303 304 \fI\fB 305 106 306 \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 107 307 308 \fI\fB 309 310 \fI\fB 311 108 312 \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 109 313 314 \fI\fB 315 316 \fI\fB 317 110 318 \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 111 319 320 \fI\fB 321 322 \fI\fB 323 112 324 \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 113 325 326 \fI\fB 327 328 \fI\fB 329 114 330 \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 115 331 332 \fI\fB 333 334 \fI\fB 335 116 336 \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 117 337 338 \fI\fB 339 340 \fI\fB 341 118 342 \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 119 343 344 \fI\fB 345 346 \fI\fB 347 120 348 \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 121 349 350 \fI\fB 351 352 \fI\fB 353 122 354 \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 123 355 356 \fI\fB 357 358 \fI\fB 359 124 360 \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 125 361 362 \fI\fB 363 364 \fI\fB 365 126 366 \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 127 367 368 \fI\fB 369 370 \fI\fB 371 128 372 \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 129 373 374 \fI\fB 375 376 \fI\fB 377 130 378 \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 131 379 380 \fI\fB 381 382 \fI\fB 383 132 384 \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 133 385 386 \fI\fB 387 388 \fI\fB 389 134 390 \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 135 391 392 \fI\fB 393 394 \fI\fB 395 136 396 \fBvoid png_info_destroy (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 137 397 398 \fI\fB 399 400 \fI\fB 401 138 402 \fBvoid png_init_mmx_flags (png_structp \fIpng_ptr\fP\fB);\fP 139 403 404 \fI\fB 405 406 \fI\fB 407 140 408 \fBvoid png_init_read_transformations (png_structp \fIpng_ptr\fP\fB);\fP 141 409 410 \fI\fB 411 412 \fI\fB 413 142 414 \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 143 415 416 \fI\fB 417 418 \fI\fB 419 144 420 \fBvoid png_process_some_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 145 421 422 \fI\fB 423 424 \fI\fB 425 146 426 \fBvoid png_push_check_crc (png_structp \fIpng_ptr\fP\fB);\fP 147 427 428 \fI\fB 429 430 \fI\fB 431 148 432 \fBvoid png_push_crc_finish (png_structp \fIpng_ptr\fP\fB);\fP 149 433 434 \fI\fB 435 436 \fI\fB 437 150 438 \fBvoid png_push_crc_skip (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP 151 439 440 \fI\fB 441 442 \fI\fB 443 152 444 \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 153 445 446 \fI\fB 447 448 \fI\fB 449 154 450 \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 155 451 452 \fI\fB 453 454 \fI\fB 455 156 456 \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 157 457 458 \fI\fB 459 460 \fI\fB 461 158 462 \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 159 463 464 \fI\fB 465 466 \fI\fB 467 160 468 \fBvoid png_push_have_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 161 469 470 \fI\fB 471 472 \fI\fB 473 162 474 \fBvoid png_push_have_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 163 475 476 \fI\fB 477 478 \fI\fB 479 164 480 \fBvoid png_push_have_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIrow\fP\fB);\fP 165 481 482 \fI\fB 483 484 \fI\fB 485 166 486 \fBvoid png_push_process_row (png_structp \fIpng_ptr\fP\fB);\fP 167 487 488 \fI\fB 489 490 \fI\fB 491 168 492 \fBvoid png_push_read_chunk (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 169 493 494 \fI\fB 495 496 \fI\fB 497 170 498 \fBvoid png_push_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 171 499 500 \fI\fB 501 502 \fI\fB 503 172 504 \fBvoid png_push_read_IDAT (png_structp \fIpng_ptr\fP\fB);\fP 173 505 506 \fI\fB 507 508 \fI\fB 509 174 510 \fBvoid png_push_read_sig (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 175 511 512 \fI\fB 513 514 \fI\fB 515 176 516 \fBvoid png_push_read_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 177 517 518 \fI\fB 519 520 \fI\fB 521 178 522 \fBvoid png_push_read_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 179 523 524 \fI\fB 525 526 \fI\fB 527 180 528 \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 181 529 530 \fI\fB 531 532 \fI\fB 533 182 534 \fBvoid png_push_save_buffer (png_structp \fIpng_ptr\fP\fB);\fP 183 535 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 184 546 \fBvoid png_read_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP 185 547 548 \fI\fB 549 550 \fI\fB 551 186 552 \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 187 553 554 \fI\fB 555 556 \fI\fB 557 188 558 \fBvoid png_read_finish_row (png_structp \fIpng_ptr\fP\fB);\fP 189 559 560 \fI\fB 561 562 \fI\fB 563 190 564 \fBvoid png_read_push_finish_row (png_structp \fIpng_ptr\fP\fB);\fP 191 565 566 \fI\fB 567 568 \fI\fB 569 192 570 \fBvoid png_read_start_row (png_structp \fIpng_ptr\fP\fB);\fP 193 571 572 \fI\fB 573 574 \fI\fB 575 194 576 \fBvoid png_read_transform_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP 195 577 578 \fI\fB 579 580 \fI\fB 581 196 582 \fBvoid png_reset_crc (png_structp \fIpng_ptr\fP\fB);\fP 197 583 584 \fI\fB 585 586 \fI\fB 587 198 588 \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 199 589 590 \fI\fB 591 592 \fI\fB 593 200 594 \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 201 595 596 \fI\fB 597 598 \fI\fB 599 202 600 \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 203 601 602 \fI\fB 603 604 \fI\fB 605 204 606 \fBvoid png_write_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP 205 607 608 \fI\fB 609 610 \fI\fB 611 206 612 \fBvoid png_write_filtered_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIfiltered_row\fP\fB);\fP 207 613 614 \fI\fB 615 616 \fI\fB 617 208 618 \fBvoid png_write_find_filter (png_structp \fP\fIpng_ptr\fP\fB, png_row_infop \fIrow_info\fP\fB);\fP 209 619 620 \fI\fB 621 622 \fI\fB 623 210 624 \fBvoid png_write_finish_row (png_structp \fIpng_ptr\fP\fB);\fP 211 625 626 \fI\fB 627 628 \fI\fB 629 212 630 \fBvoid png_write_gAMA (png_structp \fP\fIpng_ptr\fP\fB, double \fIfile_gamma\fP\fB);\fP 213 631 632 \fI\fB 633 634 \fI\fB 635 214 636 \fBvoid png_write_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIint_file_gamma\fP\fB);\fP 215 637 638 \fI\fB 639 640 \fI\fB 641 216 642 \fBvoid png_write_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_uint_16p \fP\fIhist\fP\fB, int \fInum_hist\fP\fB);\fP 217 643 644 \fI\fB 645 646 \fI\fB 647 218 648 \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 219 649 650 \fI\fB 651 652 \fI\fB 653 220 654 \fBvoid png_write_IDAT (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP 221 655 656 \fI\fB 657 658 \fI\fB 659 222 660 \fBvoid png_write_IEND (png_structp \fIpng_ptr\fP\fB);\fP 223 661 662 \fI\fB 663 664 \fI\fB 665 224 666 \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 225 667 668 \fI\fB 669 670 \fI\fB 671 226 672 \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 227 673 674 \fI\fB 675 676 \fI\fB 677 228 678 \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 229 679 680 \fI\fB 681 682 \fI\fB 683 230 684 \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 231 685 686 \fI\fB 687 688 \fI\fB 689 232 690 \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 233 691 692 \fI\fB 693 694 \fI\fB 695 234 696 \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 235 697 698 \fI\fB 699 700 \fI\fB 701 236 702 \fBvoid png_write_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fP\fIsbit\fP\fB, int \fIcolor_type\fP\fB);\fP 237 703 704 \fI\fB 705 706 \fI\fB 707 238 708 \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 239 709 710 \fI\fB 711 712 \fI\fB 713 240 714 \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 241 715 716 \fI\fB 717 718 \fI\fB 719 242 720 \fBvoid png_write_sig (png_structp \fIpng_ptr\fP\fB);\fP 243 721 722 \fI\fB 723 724 \fI\fB 725 244 726 \fBvoid png_write_sRGB (png_structp \fP\fIpng_ptr\fP\fB, int \fIintent\fP\fB);\fP 245 727 728 \fI\fB 729 730 \fI\fB 731 246 732 \fBvoid png_write_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_spalette_p \fIpalette\fP\fB);\fP 247 733 734 \fI\fB 735 736 \fI\fB 737 248 738 \fBvoid png_write_start_row (png_structp \fIpng_ptr\fP\fB);\fP 249 739 740 \fI\fB 741 742 \fI\fB 743 250 744 \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 251 745 746 \fI\fB 747 748 \fI\fB 749 252 750 \fBvoid png_write_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_timep \fImod_time\fP\fB);\fP 253 751 752 \fI\fB 753 754 \fI\fB 755 254 756 \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 255 757 758 \fI\fB 759 760 \fI\fB 761 256 762 \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 257 763 764 \fI\fB 765 766 \fI\fB 767 258 768 \fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP 259 769 770 \fI\fB 771 772 \fI\fB 773 260 774 \fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP 775 776 \fI\fB 261 777 262 778 \fI\fB -
trunk/src/3rdparty/libpng/png.5
r2 r561 1 .TH PNG 5 " May 8, 2008"1 .TH PNG 5 "September 10, 2009" 2 2 .SH NAME 3 3 png \- Portable Network Graphics (PNG) format -
trunk/src/3rdparty/libpng/png.c
r2 r561 2 2 /* png.c - location for general purpose libpng functions 3 3 * 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 7 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 7 * (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 9 12 */ 10 13 … … 14 17 15 18 /* 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;19 typedef version_1_2_40 Your_png_h_is_not_version_1_2_40; 17 20 18 21 /* Version information for C files. This had better match the version … … 54 57 55 58 #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 */ 59 62 PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; 60 63 61 /* offset to next interlace block */64 /* Offset to next interlace block */ 62 65 PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; 63 66 64 /* start of interlace block in the y direction */67 /* Start of interlace block in the y direction */ 65 68 PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; 66 69 67 /* offset to next interlace block in the y direction */70 /* Offset to next interlace block in the y direction */ 68 71 PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; 69 72 … … 93 96 png_set_sig_bytes(png_structp png_ptr, int num_bytes) 94 97 { 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"); 97 101 if (num_bytes > 8) 98 102 png_error(png_ptr, "Too many bytes for PNG signature."); … … 145 149 voidpf PNGAPI 146 150 #else 147 voidpf /* private*/151 voidpf /* PRIVATE */ 148 152 #endif 149 153 png_zalloc(voidpf png_ptr, uInt items, uInt size) … … 154 158 png_uint_32 num_bytes; 155 159 156 if(png_ptr == NULL) return (NULL); 160 if (png_ptr == NULL) 161 return (NULL); 157 162 if (items > PNG_UINT_32_MAX/size) 158 163 { … … 184 189 } 185 190 186 /* function to free memory for zlib */191 /* Function to free memory for zlib */ 187 192 #ifdef PNG_1_0_X 188 193 void PNGAPI 189 194 #else 190 void /* private*/195 void /* PRIVATE */ 191 196 #endif 192 197 png_zfree(voidpf png_ptr, voidpf ptr) … … 241 246 png_infop info_ptr; 242 247 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); 245 251 #ifdef PNG_USER_MEM_SUPPORTED 246 252 info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, … … 264 270 { 265 271 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"); 269 276 if (info_ptr_ptr != NULL) 270 277 info_ptr = *info_ptr_ptr; … … 303 310 png_infop info_ptr = *ptr_ptr; 304 311 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)); 318 326 } 319 327 … … 323 331 int freer, png_uint_32 mask) 324 332 { 325 png_debug(1, "in png_data_freer \n");333 png_debug(1, "in png_data_freer"); 326 334 if (png_ptr == NULL || info_ptr == NULL) 327 335 return; 328 if (freer == PNG_DESTROY_WILL_FREE_DATA)336 if (freer == PNG_DESTROY_WILL_FREE_DATA) 329 337 info_ptr->free_me |= mask; 330 else if (freer == PNG_USER_WILL_FREE_DATA)338 else if (freer == PNG_USER_WILL_FREE_DATA) 331 339 info_ptr->free_me &= ~mask; 332 340 else … … 340 348 int num) 341 349 { 342 png_debug(1, "in png_free_data \n");350 png_debug(1, "in png_free_data"); 343 351 if (png_ptr == NULL || info_ptr == NULL) 344 352 return; 345 353 346 354 #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; 362 592 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); 585 594 #endif 586 595 } … … 593 602 png_info_destroy(png_structp png_ptr, png_infop info_ptr) 594 603 { 595 png_debug(1, "in png_info_destroy \n");604 png_debug(1, "in png_info_destroy"); 596 605 597 606 png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); 598 607 599 #if defined(PNG_ UNKNOWN_CHUNKS_SUPPORTED)608 #if defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) 600 609 if (png_ptr->num_chunk_list) 601 610 { 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; 605 614 } 606 615 #endif … … 617 626 png_get_io_ptr(png_structp png_ptr) 618 627 { 619 if(png_ptr == NULL) return (NULL); 628 if (png_ptr == NULL) 629 return (NULL); 620 630 return (png_ptr->io_ptr); 621 631 } … … 632 642 png_init_io(png_structp png_ptr, png_FILE_p fp) 633 643 { 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; 636 647 png_ptr->io_ptr = (png_voidp)fp; 637 648 } … … 649 660 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; 650 661 651 if(png_ptr == NULL) return (NULL); 662 if (png_ptr == NULL) 663 return (NULL); 652 664 if (png_ptr->time_buffer == NULL) 653 665 { … … 670 682 { 671 683 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", 673 685 ptime->day % 32, short_months[(ptime->month - 1) % 12], 674 686 ptime->year, ptime->hour % 24, ptime->minute % 60, … … 678 690 } 679 691 #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", 681 693 ptime->day % 32, short_months[(ptime->month - 1) % 12], 682 694 ptime->year, ptime->hour % 24, ptime->minute % 60, … … 693 705 png_get_copyright(png_structp png_ptr) 694 706 { 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-200 8Glenn 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\ 698 710 Copyright (c) 1996-1997 Andreas Dilger\n\ 699 711 Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n"); … … 712 724 { 713 725 /* 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 */ 715 727 return ((png_charp) PNG_LIBPNG_VER_STRING); 716 728 } … … 720 732 { 721 733 /* 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 */ 723 735 return ((png_charp) PNG_LIBPNG_VER_STRING); 724 736 } … … 728 740 { 729 741 /* 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 */ 731 743 return ((png_charp) PNG_HEADER_VERSION_STRING 732 744 #ifndef PNG_READ_SUPPORTED … … 741 753 png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name) 742 754 { 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 */ 744 756 int i; 745 757 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) 747 759 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) 750 762 if (!png_memcmp(chunk_name, p, 4)) 751 return ((int)*(p +4));763 return ((int)*(p + 4)); 752 764 return 0; 753 765 } … … 758 770 png_reset_zstream(png_structp png_ptr) 759 771 { 760 if (png_ptr == NULL) return Z_STREAM_ERROR; 772 if (png_ptr == NULL) 773 return Z_STREAM_ERROR; 761 774 return (inflateReset(&png_ptr->zstream)); 762 775 } … … 774 787 #if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) 775 788 #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 */ 777 790 int PNGAPI 778 791 png_mmx_support(void) 779 792 { 780 /* obsolete, to be removed from libpng-1.4.0 */793 /* Obsolete, to be removed from libpng-1.4.0 */ 781 794 return -1; 782 795 } … … 791 804 png_convert_size(size_t size) 792 805 { 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); 796 809 } 797 810 #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 831 void /* PRIVATE */ 832 png_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 856 int /* PRIVATE */ 857 png_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 */ 798 926 #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ -
trunk/src/3rdparty/libpng/png.h
r2 r561 1 1 /* png.h - header file for PNG reference library 2 2 * 3 * libpng version 1.2. 29 - May 8, 20084 * Copyright (c) 1998-200 8Glenn Randers-Pehrson3 * libpng version 1.2.40 - September 10, 2009 4 * Copyright (c) 1998-2009 Glenn Randers-Pehrson 5 5 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 6 6 * (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) 7 9 * 8 10 * Authors and maintainers: 9 11 * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat 10 12 * 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: Glenn13 * libpng versions 0.97, January 1998, through 1.2.40 - September 10, 2009: Glenn 12 14 * See also "Contributing Authors", below. 13 15 * … … 193 195 * 1.0.35 10 10035 10.so.0.35[.0] 194 196 * 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] 195 248 * 196 249 * Henceforth the source version will match the shared-library major … … 222 275 * this sentence. 223 276 * 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 226 281 * distributed according to the same disclaimer and license as libpng-1.2.5 227 282 * with the following individual added to the list of Contributing Authors: … … 334 389 * ========================= 335 390 * 336 * May 8, 2008391 * September 10, 2009 337 392 * 338 393 * Since the PNG Development group is an ad-hoc body, we can't make … … 340 395 * 341 396 * This is your unofficial assurance that libpng from version 0.71 and 342 * upward through 1.2. 29are Y2K compliant. It is my belief that earlier397 * upward through 1.2.40 are Y2K compliant. It is my belief that earlier 343 398 * versions were also Y2K compliant. 344 399 * … … 396 451 397 452 /* 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" 399 454 #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" 401 456 402 457 #define PNG_LIBPNG_VER_SONUM 0 … … 406 461 #define PNG_LIBPNG_VER_MAJOR 1 407 462 #define PNG_LIBPNG_VER_MINOR 2 408 #define PNG_LIBPNG_VER_RELEASE 29463 #define PNG_LIBPNG_VER_RELEASE 40 409 464 /* 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 */ 411 467 412 468 #define PNG_LIBPNG_VER_BUILD 0 … … 418 474 #define PNG_LIBPNG_BUILD_STABLE 4 419 475 #define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7 420 476 421 477 /* Release-Specific Flags */ 422 478 #define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with … … 433 489 * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only 434 490 * 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 */ 437 494 438 495 #ifndef PNG_VERSION_INFO_ONLY 439 /* include the compression library's header */496 /* Include the compression library's header */ 440 497 #include "zlib.h" 441 498 #endif 442 499 443 /* include all user configurable info, including optional assembler routines */500 /* Include all user configurable info, including optional assembler routines */ 444 501 #include "pngconf.h" 445 502 … … 449 506 * VS_FF_PRIVATEBUILD File *was not* built using standard release 450 507 * procedures. If this value is given, the StringFileInfo block must 451 * contain a PrivateBuild string. 508 * contain a PrivateBuild string. 452 509 * 453 510 * VS_FF_SPECIALBUILD File *was* built by the original company using 454 511 * standard release procedures but is a variation of the standard 455 512 * 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. 457 514 */ 458 515 … … 516 573 #endif 517 574 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 */ 519 576 #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) 520 577 /* Version information for C files, stored in png.c. This had better match … … 523 580 #ifdef PNG_USE_GLOBAL_ARRAYS 524 581 PNG_EXPORT_VAR (PNG_CONST char) png_libpng_ver[18]; 525 /* need room for 99.99.99beta99z */582 /* Need room for 99.99.99beta99z */ 526 583 #else 527 584 #define png_libpng_ver png_get_header_ver(NULL) … … 642 699 643 700 /* 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 */ 645 703 #define PNG_TEXT_COMPRESSION_NONE_WR -3 646 704 #define PNG_TEXT_COMPRESSION_zTXt_WR -2 … … 669 727 typedef png_time FAR * FAR * png_timepp; 670 728 671 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) 729 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \ 730 defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) 672 731 /* png_unknown_chunk is a structure to hold queued chunks for which there is 673 732 * no specific support. The idea is that we can use this to queue … … 731 790 typedef struct png_info_struct 732 791 { 733 /* the following are necessary for every PNG file */792 /* The following are necessary for every PNG file */ 734 793 png_uint_32 width; /* width of image in pixels (from IHDR) */ 735 794 png_uint_32 height; /* height of image in pixels (from IHDR) */ … … 904 963 #endif 905 964 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. */ 908 968 png_unknown_chunkp unknown_chunks; 909 969 png_size_t unknown_chunks_num; … … 920 980 921 981 #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). */ 923 983 png_sPLT_tp splt_palettes; 924 984 png_uint_32 splt_palettes_num; … … 1135 1195 #define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ 1136 1196 #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 */ 1138 1201 1139 1202 /* Flags for MNG supported features */ … … 1205 1268 png_bytep prev_row; /* buffer to save previous (unfiltered) row */ 1206 1269 png_bytep row_buf; /* buffer to save current (unfiltered) row */ 1207 #ifndef PNG_NO_WRITE_FILTER ING1270 #ifndef PNG_NO_WRITE_FILTER 1208 1271 png_bytep sub_row; /* buffer to save "sub" row when filtering */ 1209 1272 png_bytep up_row; /* buffer to save "up" row when filtering */ … … 1252 1315 1253 1316 #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 */ 1255 1318 png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ 1256 1319 png_uint_32 flush_rows; /* number of rows written since last flush */ … … 1350 1413 1351 1414 #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 */ 1353 1416 #endif 1354 1417 … … 1358 1421 #endif 1359 1422 1360 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)1423 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED 1361 1424 int num_chunk_list; 1362 1425 png_bytep chunk_list; … … 1376 1439 defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ 1377 1440 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 */ 1379 1442 #ifdef PNG_1_0_X 1380 1443 png_byte mng_features_permitted; … … 1412 1475 /* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ 1413 1476 #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 */ 1417 1480 #endif 1418 1481 1419 1482 /* 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 */ 1421 1484 1422 1485 #if defined(PNG_READ_DITHER_SUPPORTED) 1423 1486 /* 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 */ 1429 1492 #endif 1430 1493 … … 1439 1502 /* New member added in libpng-1.0.25 and 1.2.17 */ 1440 1503 #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. */ 1442 1505 png_unknown_chunk unknown_chunk; 1443 1506 #endif … … 1445 1508 /* New members added in libpng-1.2.26 */ 1446 1509 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 1447 1514 }; 1448 1515 … … 1451 1518 * do not agree upon the version number. 1452 1519 */ 1453 typedef png_structp version_1_2_ 29;1520 typedef png_structp version_1_2_40; 1454 1521 1455 1522 typedef png_struct FAR * FAR * png_structpp; … … 1555 1622 1556 1623 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED 1557 /* read the information before the actual image data. */1624 /* Read the information before the actual image data. */ 1558 1625 extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr, 1559 1626 png_infop info_ptr)); … … 1568 1635 /* "time.h" functions are not supported on WindowsCE */ 1569 1636 #if defined(PNG_WRITE_tIME_SUPPORTED) 1570 /* convert from a struct tm to png_time */1637 /* Convert from a struct tm to png_time */ 1571 1638 extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime, 1572 1639 struct tm FAR * ttime)); 1573 1640 1574 /* convert from time_t to png_time. Uses gmtime() */1641 /* Convert from time_t to png_time. Uses gmtime() */ 1575 1642 extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime, 1576 1643 time_t ttime)); … … 1692 1759 1693 1760 #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. */ 1695 1762 extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr)); 1696 1763 #endif … … 1728 1795 #endif 1729 1796 1730 /* optional update palette with requested transformations */1797 /* Optional update palette with requested transformations */ 1731 1798 extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr)); 1732 1799 1733 /* optional call to update the users info structure */1800 /* Optional call to update the users info structure */ 1734 1801 extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr, 1735 1802 png_infop info_ptr)); 1736 1803 1737 1804 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED 1738 /* read one or more rows of image data. */1805 /* Read one or more rows of image data. */ 1739 1806 extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr, 1740 1807 png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); … … 1742 1809 1743 1810 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED 1744 /* read a row of data. */1811 /* Read a row of data. */ 1745 1812 extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr, 1746 1813 png_bytep row, … … 1749 1816 1750 1817 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED 1751 /* read the whole image into memory at once. */1818 /* Read the whole image into memory at once. */ 1752 1819 extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr, 1753 1820 png_bytepp image)); 1754 1821 #endif 1755 1822 1756 /* write a row of image data */1823 /* Write a row of image data */ 1757 1824 extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr, 1758 1825 png_bytep row)); 1759 1826 1760 /* write a few rows of image data */1827 /* Write a few rows of image data */ 1761 1828 extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr, 1762 1829 png_bytepp row, png_uint_32 num_rows)); 1763 1830 1764 /* write the image data */1831 /* Write the image data */ 1765 1832 extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr, 1766 1833 png_bytepp image)); 1767 1834 1768 /* writes the end of the PNG file. */1835 /* Writes the end of the PNG file. */ 1769 1836 extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr, 1770 1837 png_infop info_ptr)); 1771 1838 1772 1839 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED 1773 /* read the end of the PNG file. */1840 /* Read the end of the PNG file. */ 1774 1841 extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr, 1775 1842 png_infop info_ptr)); 1776 1843 #endif 1777 1844 1778 /* free any memory associated with the png_info_struct */1845 /* Free any memory associated with the png_info_struct */ 1779 1846 extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr, 1780 1847 png_infopp info_ptr_ptr)); 1781 1848 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 */ 1783 1850 extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp 1784 1851 png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); 1785 1852 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) */ 1787 1854 extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr, 1788 1855 png_infop end_info_ptr)); 1789 1856 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 */ 1791 1858 extern PNG_EXPORT(void,png_destroy_write_struct) 1792 1859 PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); 1793 1860 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) */ 1795 1862 extern void png_write_destroy PNGARG((png_structp png_ptr)); 1796 1863 1797 /* set the libpng method of handling chunk CRC errors */1864 /* Set the libpng method of handling chunk CRC errors */ 1798 1865 extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr, 1799 1866 int crit_action, int ancil_action)); … … 1823 1890 */ 1824 1891 1825 /* set the filtering method(s) used by libpng. Currently, the only valid1892 /* Set the filtering method(s) used by libpng. Currently, the only valid 1826 1893 * value for "method" is 0. 1827 1894 */ … … 1951 2018 * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time 1952 2019 * 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. 1953 2025 */ 1954 2026 extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr, … … 2015 2087 png_progressive_end_ptr end_fn)); 2016 2088 2017 /* returns the user pointer associated with the push read functions */2089 /* Returns the user pointer associated with the push read functions */ 2018 2090 extern PNG_EXPORT(png_voidp,png_get_progressive_ptr) 2019 2091 PNGARG((png_structp png_ptr)); 2020 2092 2021 /* function to be called when data becomes available */2093 /* Function to be called when data becomes available */ 2022 2094 extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr, 2023 2095 png_infop info_ptr, png_bytep buffer, png_size_t buffer_size)); 2024 2096 2025 /* function that combines rows. Not very much different than the2097 /* Function that combines rows. Not very much different than the 2026 2098 * png_combine_row() call. Is this even used????? 2027 2099 */ … … 2041 2113 #endif 2042 2114 2043 /* frees a pointer allocated by png_malloc() */2115 /* Frees a pointer allocated by png_malloc() */ 2044 2116 extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); 2045 2117 … … 2058 2130 #ifdef PNG_FREE_ME_SUPPORTED 2059 2131 /* Reassign responsibility for freeing existing data, whether allocated 2060 * by libpng or by the application */ 2132 * by libpng or by the application 2133 */ 2061 2134 extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, 2062 2135 png_infop info_ptr, int freer, png_uint_32 mask)); 2063 2136 #endif 2064 /* assignments for png_data_freer */2137 /* Assignments for png_data_freer */ 2065 2138 #define PNG_DESTROY_WILL_FREE_DATA 1 2066 2139 #define PNG_SET_WILL_FREE_DATA 1 … … 2146 2219 #if defined(PNG_INFO_IMAGE_SUPPORTED) 2147 2220 /* 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 */ 2149 2223 extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr, 2150 2224 png_infop info_ptr)); 2151 2225 /* Set row_pointers, which is an array of pointers to scanlines for use 2152 by png_write_png(). */ 2226 * by png_write_png(). 2227 */ 2153 2228 extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr, 2154 2229 png_infop info_ptr, png_bytepp row_pointers)); … … 2451 2526 #endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */ 2452 2527 2453 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)2454 /* provide a list of chunks and how they are to be handled, if the built-in2528 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED 2529 /* Provide a list of chunks and how they are to be handled, if the built-in 2455 2530 handling or default unknown chunk handling is not desired. Any chunks not 2456 2531 listed will be handled in the default manner. The IHDR and IEND chunks … … 2463 2538 extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp 2464 2539 png_ptr, int keep, png_bytep chunk_list, int num_chunks)); 2540 PNG_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) 2465 2544 extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr, 2466 2545 png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)); … … 2470 2549 png_ptr, png_infop info_ptr, png_unknown_chunkpp entries)); 2471 2550 #endif 2472 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED2473 PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep2474 chunk_name));2475 #endif2476 2551 2477 2552 /* 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 */ 2480 2556 extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr, 2481 2557 png_infop info_ptr, int mask)); … … 2503 2579 #include <crtdbg.h> 2504 2580 #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 2508 2593 #endif 2509 2594 #else /* PNG_DEBUG_FILE || !_MSC_VER */ … … 2511 2596 #define PNG_DEBUG_FILE stderr 2512 2597 #endif /* PNG_DEBUG_FILE */ 2598 2513 2599 #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 __ */ 2532 2663 #endif /* (PNG_DEBUG > 1) */ 2664 2533 2665 #endif /* _MSC_VER */ 2534 2666 #endif /* (PNG_DEBUG > 0) */ … … 2625 2757 /* png.c, pnggccrd.c, or pngvcrd.c */ 2626 2758 extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); 2759 #endif /* PNG_1_0_X */ 2627 2760 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ 2628 2761 2629 2762 /* 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 */ 2631 2765 #ifdef PNG_ERROR_NUMBERS_SUPPORTED 2632 2766 extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp 2633 2767 png_ptr, png_uint_32 strip_mode)); 2634 2768 #endif 2635 2636 #endif /* PNG_1_0_X */2637 2769 2638 2770 /* Added at libpng-1.2.6 */ … … 2646 2778 #endif 2647 2779 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 */ 2649 2784 2650 2785 #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED … … 2675 2810 (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } 2676 2811 2677 #else /* standard method using integer division */2812 #else /* Standard method using integer division */ 2678 2813 2679 2814 # define png_composite(composite, fg, alpha, bg) \ … … 2758 2893 #define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */ 2759 2894 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 */ 2761 2896 #define PNG_BGR 0x0001 2762 2897 #define PNG_INTERLACE 0x0002 … … 2792 2927 /* 0x40000000L unused */ 2793 2928 2794 /* flags for png_create_struct */2929 /* Flags for png_create_struct */ 2795 2930 #define PNG_STRUCT_PNG 0x0001 2796 2931 #define PNG_STRUCT_INFO 0x0002 … … 2802 2937 #define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) 2803 2938 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 */ 2805 2940 #define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 2806 2941 #define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002 … … 2844 2979 PNG_FLAG_CRC_CRITICAL_MASK) 2845 2980 2846 /* save typing and make code easier to understand */2981 /* Save typing and make code easier to understand */ 2847 2982 2848 2983 #define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ … … 2857 2992 2858 2993 /* 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 */ 2862 2998 #define PNG_OUT_OF_RANGE(value, ideal, delta) \ 2863 2999 ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) ) 2864 3000 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 */ 2866 3002 #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. */ 2868 3004 #ifdef PNG_USE_GLOBAL_ARRAYS 2869 3005 PNG_EXPORT_VAR (PNG_CONST png_byte FARDATA) png_sig[8]; … … 2984 3120 2985 3121 /* 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 */ 2987 3124 2988 3125 PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr, … … 3027 3164 #if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ 3028 3165 defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) 3029 PNG_EXTERN png_charppng_decompress_chunk PNGARG((png_structp png_ptr,3030 int comp_type, png_ charp chunkdata, png_size_t chunklength,3166 PNG_EXTERN void png_decompress_chunk PNGARG((png_structp png_ptr, 3167 int comp_type, png_size_t chunklength, 3031 3168 png_size_t prefix_length, png_size_t *data_length)); 3032 3169 #endif … … 3049 3186 #endif 3050 3187 3051 /* simple function to write the signature */3188 /* Simple function to write the signature */ 3052 3189 PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr)); 3053 3190 3054 /* write various chunks */3191 /* Write various chunks */ 3055 3192 3056 3193 /* Write the IHDR chunk, and update the png_struct with the necessary … … 3204 3341 #endif 3205 3342 3206 /* combine a row of data, dealing with alpha, etc. if requested */3343 /* Combine a row of data, dealing with alpha, etc. if requested */ 3207 3344 PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row, 3208 3345 int mask)); 3209 3346 3210 3347 #if defined(PNG_READ_INTERLACING_SUPPORTED) 3211 /* expand an interlaced row */3348 /* Expand an interlaced row */ 3212 3349 /* OLD pre-1.0.9 interface: 3213 3350 PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, … … 3220 3357 3221 3358 #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 */ 3223 3360 PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info, 3224 3361 png_bytep row, int pass)); 3225 3362 #endif 3226 3363 3227 /* unfilter a row */3364 /* Unfilter a row */ 3228 3365 PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr, 3229 3366 png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter)); … … 3236 3373 PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr, 3237 3374 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. */ 3239 3376 PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr)); 3240 3377 3241 /* initialize the row buffers, etc. */3378 /* Initialize the row buffers, etc. */ 3242 3379 PNG_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 */ 3244 3381 PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr, 3245 3382 png_infop info_ptr)); 3246 3383 3247 /* these are the functions that do the transformations */3384 /* These are the functions that do the transformations */ 3248 3385 #if defined(PNG_READ_FILLER_SUPPORTED) 3249 3386 PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info, … … 3367 3504 */ 3368 3505 3369 /* decode the IHDR chunk */3506 /* Decode the IHDR chunk */ 3370 3507 PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr, 3371 3508 png_uint_32 length)); … … 3466 3603 png_bytep chunk_name)); 3467 3604 3468 /* handle the transformations for reading and writing */3605 /* Handle the transformations for reading and writing */ 3469 3606 PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr)); 3470 3607 PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr)); … … 3557 3694 #endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ 3558 3695 3696 /* Read the chunk header (length + type name) */ 3697 PNG_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) 3701 PNG_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 */ 3711 PNG_EXTERN void png_64bit_product (long v1, long v2, unsigned long *hi_product, 3712 unsigned long *lo_product); 3713 #endif 3714 #endif 3715 3559 3716 /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ 3560 3717 … … 3566 3723 3567 3724 #endif /* PNG_VERSION_INFO_ONLY */ 3568 /* do not put anything past this line */3725 /* Do not put anything past this line */ 3569 3726 #endif /* PNG_H */ -
trunk/src/3rdparty/libpng/pngconf.h
r2 r561 2 2 /* pngconf.h - machine configurable file for libpng 3 3 * 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 7 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 7 * (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 9 12 */ 10 13 … … 20 23 #define PNG_1_2_X 21 24 22 /* 25 /* 23 26 * PNG_USER_CONFIG has to be defined on the compiler command line. This 24 27 * includes the resource compiler for Windows DLL configurations. … … 40 43 /* 41 44 * Added at libpng-1.2.8 42 * 45 * 43 46 * If you create a private DLL you need to define in "pngusr.h" the followings: 44 47 * #define PNG_USER_PRIVATEBUILD <Describes by whom and why this version of … … 51 54 * e.g. // private DLL "libpng13gx.dll" 52 55 * #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 55 58 * DLL VERSIONINFO structure. 56 59 * - PNG_USER_VERSIONINFO_COMMENTS … … 148 151 * PNG_BUILD_DLL -- (ignored) building the dll 149 152 * (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 151 154 * 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 153 156 * application that links to the static libs. 154 157 * Thus, … … 163 166 * PNG_STATIC 164 167 * (nothing) == PNG_USE_DLL 165 * 168 * 166 169 * 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 168 171 * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore, 169 172 * 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 171 174 * PNG_BUILD_DLL and PNG_STATIC because those change some defaults 172 175 * such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed. … … 212 215 # define PNG_DLL 213 216 # endif 214 # endif 215 # endif 217 # endif 218 # endif 216 219 # endif 217 220 #endif … … 234 237 /* Console I/O functions are not supported on WindowsCE */ 235 238 # define PNG_NO_CONSOLE_IO 239 /* abort() may not be supported on some/all Windows CE platforms */ 240 # define PNG_ABORT() exit(-1) 236 241 # ifdef PNG_DEBUG 237 242 # undef PNG_DEBUG 238 # endif239 # ifndef PNG_ABORT240 # define PNG_ABORT() exit(3)241 243 # endif 242 244 #endif … … 316 318 /* This is an attempt to force a single setjmp behaviour on Linux. If 317 319 * 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 */ 333 343 334 344 /* include setjmp.h for error handling */ … … 345 355 #endif /* PNG_SETJMP_SUPPORTED */ 346 356 347 #if def BSD357 #if defined(BSD) && !defined(VXWORKS) 348 358 # include <strings.h> 349 359 #else … … 481 491 * libpng-1.2.x, to support old apps that malloc the png_text structure 482 492 * instead of calling png_set_text() and letting libpng malloc it. It 483 * w as turned on by default in libpng-1.3.0.493 * will be turned on by default in libpng-1.4.0. 484 494 */ 485 495 … … 515 525 # define PNG_NO_READ_UNKNOWN_CHUNKS 516 526 # define PNG_NO_WRITE_UNKNOWN_CHUNKS 527 # define PNG_NO_HANDLE_AS_UNKNOWN 517 528 # define PNG_NO_READ_USER_CHUNKS 518 529 # define PNG_NO_READ_iCCP … … 544 555 #endif 545 556 546 #if defined(PNG_READ_SUPPORTED)557 #ifdef PNG_READ_SUPPORTED 547 558 548 559 #if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \ … … 632 643 #endif /* PNG_READ_SUPPORTED */ 633 644 634 #if defined(PNG_WRITE_SUPPORTED)645 #ifdef PNG_WRITE_SUPPORTED 635 646 636 647 # if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \ … … 735 746 #endif 736 747 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 738 749 * and removed from version 1.2.20. The following will be removed 739 750 * from libpng-1.4.0 … … 802 813 #endif 803 814 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 804 820 /* These are currently experimental features, define them if you want */ 805 821 … … 928 944 # define PNG_READ_zTXt_SUPPORTED 929 945 # define PNG_zTXt_SUPPORTED 930 #endif931 #ifndef PNG_NO_READ_UNKNOWN_CHUNKS932 # define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED933 # ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED934 # define PNG_UNKNOWN_CHUNKS_SUPPORTED935 # endif936 # ifndef PNG_NO_HANDLE_AS_UNKNOWN937 # define PNG_HANDLE_AS_UNKNOWN_SUPPORTED938 # endif939 #endif940 #if !defined(PNG_NO_READ_USER_CHUNKS) && \941 defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)942 # define PNG_READ_USER_CHUNKS_SUPPORTED943 # define PNG_USER_CHUNKS_SUPPORTED944 # ifdef PNG_NO_READ_UNKNOWN_CHUNKS945 # undef PNG_NO_READ_UNKNOWN_CHUNKS946 # endif947 # ifdef PNG_NO_HANDLE_AS_UNKNOWN948 # undef PNG_NO_HANDLE_AS_UNKNOWN949 # endif950 946 #endif 951 947 #ifndef PNG_NO_READ_OPT_PLTE … … 960 956 #endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */ 961 957 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 962 983 #ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED 963 984 … … 1069 1090 # ifndef PNG_zTXt_SUPPORTED 1070 1091 # define PNG_zTXt_SUPPORTED 1071 # endif1072 #endif1073 #ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS1074 # define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED1075 # ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED1076 # define PNG_UNKNOWN_CHUNKS_SUPPORTED1077 # endif1078 # ifndef PNG_NO_HANDLE_AS_UNKNOWN1079 # ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED1080 # define PNG_HANDLE_AS_UNKNOWN_SUPPORTED1081 # endif1082 1092 # endif 1083 1093 #endif … … 1091 1101 1092 1102 #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 */ 1093 1117 1094 1118 /* Turn this off to disable png_read_png() and … … 1127 1151 #ifdef PNG_SIZE_T 1128 1152 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)) 1130 1154 #else 1131 1155 typedef size_t png_size_t; 1132 # define png_sizeof(x) sizeof (x)1156 # define png_sizeof(x) sizeof(x) 1133 1157 #endif 1134 1158 … … 1237 1261 #if defined(PNG_1_0_X) || defined(PNG_1_2_X) 1238 1262 /* 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 */ 1240 1264 /* libpng typedefs for types in zlib. If zlib changes 1241 1265 * or another compression library is used, then change these. … … 1310 1334 # undef PNG_IMPEXP 1311 1335 # define PNG_IMPEXP 1312 #endif 1336 #endif 1313 1337 1314 1338 /* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall", … … 1334 1358 1335 1359 # 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__) 1337 1363 # define PNGAPI __cdecl 1338 1364 # else -
trunk/src/3rdparty/libpng/pngerror.c
r2 r561 2 2 /* pngerror.c - stub functions for i/o and memory allocation 3 3 * 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 7 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 7 * (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 9 12 * 10 13 * This file provides a location for all error handling. Users who … … 16 19 #define PNG_INTERNAL 17 20 #include "png.h" 18 19 21 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 22 20 23 static void /* PRIVATE */ 21 24 png_default_error PNGARG((png_structp png_ptr, … … 45 48 if (*error_message == '#') 46 49 { 50 /* Strip "#nnnn " from beginning of error message. */ 47 51 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] == ' ') 50 54 break; 51 55 if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) 52 56 { 53 57 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; 58 62 } 59 63 else 60 error_message +=offset;64 error_message += offset; 61 65 } 62 66 else … … 64 68 if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) 65 69 { 66 msg[0] ='0';67 msg[1] ='\0';68 error_message =msg;70 msg[0] = '0'; 71 msg[1] = '\0'; 72 error_message = msg; 69 73 } 70 74 } … … 111 115 if (*warning_message == '#') 112 116 { 113 for (offset =1; offset<15; offset++)114 if ( *(warning_message+offset)== ' ')117 for (offset = 1; offset < 15; offset++) 118 if (warning_message[offset] == ' ') 115 119 break; 116 120 } 117 121 } 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); 123 127 } 124 128 #endif /* PNG_NO_WARNINGS */ … … 168 172 buffer[iout++] = ':'; 169 173 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'; 172 176 } 173 177 } … … 217 221 if (*error_message == '#') 218 222 { 223 /* Strip "#nnnn " from beginning of error message. */ 219 224 int offset; 220 225 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] == ' ') 225 230 break; 226 231 } 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); 232 238 } 233 239 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 } 239 252 #endif 240 253 … … 256 269 #endif 257 270 #ifdef PNG_NO_CONSOLE_IO 258 error_message = error_message; /* make compiler happy */271 error_message = error_message; /* Make compiler happy */ 259 272 #endif 260 273 } … … 275 288 int offset; 276 289 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] == ' ') 281 294 break; 282 295 } 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); 288 302 } 289 303 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 } 291 309 } 292 310 else 293 311 # 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 } 295 316 #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 */ 299 320 } 300 321 #endif /* PNG_NO_WARNINGS */ … … 334 355 png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode) 335 356 { 336 if (png_ptr != NULL)357 if (png_ptr != NULL) 337 358 { 338 359 png_ptr->flags &= -
trunk/src/3rdparty/libpng/pngget.c
r2 r561 2 2 /* pngget.c - retrieval of values from info struct 3 3 * 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 7 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 7 * (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 * 9 13 */ 10 14 11 15 #define PNG_INTERNAL 12 16 #include "png.h" 13 14 17 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 15 18 … … 19 22 if (png_ptr != NULL && info_ptr != NULL) 20 23 return(info_ptr->valid & flag); 24 21 25 else 22 26 return(0); … … 28 32 if (png_ptr != NULL && info_ptr != NULL) 29 33 return(info_ptr->rowbytes); 34 30 35 else 31 36 return(0); … … 38 43 if (png_ptr != NULL && info_ptr != NULL) 39 44 return(info_ptr->row_pointers); 45 40 46 else 41 47 return(0); … … 44 50 45 51 #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 */ 47 53 png_uint_32 PNGAPI 48 54 png_get_image_width(png_structp png_ptr, png_infop info_ptr) 49 55 { 50 56 if (png_ptr != NULL && info_ptr != NULL) 51 {52 57 return info_ptr->width; 53 } 58 54 59 return (0); 55 60 } … … 59 64 { 60 65 if (png_ptr != NULL && info_ptr != NULL) 61 {62 66 return info_ptr->height; 63 } 67 64 68 return (0); 65 69 } … … 69 73 { 70 74 if (png_ptr != NULL && info_ptr != NULL) 71 {72 75 return info_ptr->bit_depth; 73 } 76 74 77 return (0); 75 78 } … … 79 82 { 80 83 if (png_ptr != NULL && info_ptr != NULL) 81 {82 84 return info_ptr->color_type; 83 } 85 84 86 return (0); 85 87 } … … 89 91 { 90 92 if (png_ptr != NULL && info_ptr != NULL) 91 {92 93 return info_ptr->filter_type; 93 } 94 94 95 return (0); 95 96 } … … 99 100 { 100 101 if (png_ptr != NULL && info_ptr != NULL) 101 {102 102 return info_ptr->interlace_type; 103 } 103 104 104 return (0); 105 105 } … … 109 109 { 110 110 if (png_ptr != NULL && info_ptr != NULL) 111 {112 111 return info_ptr->compression_type; 113 } 112 114 113 return (0); 115 114 } … … 122 121 if (info_ptr->valid & PNG_INFO_pHYs) 123 122 { 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) 126 126 return (0); 127 else return (info_ptr->x_pixels_per_unit); 127 128 else 129 return (info_ptr->x_pixels_per_unit); 128 130 } 129 131 #else … … 140 142 if (info_ptr->valid & PNG_INFO_pHYs) 141 143 { 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) 144 147 return (0); 145 else return (info_ptr->y_pixels_per_unit); 148 149 else 150 return (info_ptr->y_pixels_per_unit); 146 151 } 147 152 #else … … 158 163 if (info_ptr->valid & PNG_INFO_pHYs) 159 164 { 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 || 162 168 info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit) 163 169 return (0); 164 else return (info_ptr->x_pixels_per_unit); 170 171 else 172 return (info_ptr->x_pixels_per_unit); 165 173 } 166 174 #else … … 176 184 if (png_ptr != NULL && info_ptr != NULL) 177 185 #if defined(PNG_pHYs_SUPPORTED) 186 178 187 if (info_ptr->valid & PNG_INFO_pHYs) 179 188 { 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"); 181 190 if (info_ptr->x_pixels_per_unit == 0) 182 191 return ((float)0.0); … … 186 195 } 187 196 #else 188 return (0.0);197 return (0.0); 189 198 #endif 190 199 return ((float)0.0); … … 197 206 if (png_ptr != NULL && info_ptr != NULL) 198 207 #if defined(PNG_oFFs_SUPPORTED) 208 199 209 if (info_ptr->valid & PNG_INFO_oFFs) 200 210 { 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) 203 214 return (0); 204 else return (info_ptr->x_offset); 215 216 else 217 return (info_ptr->x_offset); 205 218 } 206 219 #else 207 return (0);220 return (0); 208 221 #endif 209 222 return (0); … … 214 227 { 215 228 if (png_ptr != NULL && info_ptr != NULL) 229 216 230 #if defined(PNG_oFFs_SUPPORTED) 217 231 if (info_ptr->valid & PNG_INFO_oFFs) 218 232 { 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) 221 236 return (0); 222 else return (info_ptr->y_offset); 237 238 else 239 return (info_ptr->y_offset); 223 240 } 224 241 #else … … 232 249 { 233 250 if (png_ptr != NULL && info_ptr != NULL) 251 234 252 #if defined(PNG_oFFs_SUPPORTED) 235 253 if (info_ptr->valid & PNG_INFO_oFFs) 236 254 { 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) 239 258 return (0); 240 else return (info_ptr->x_offset); 259 260 else 261 return (info_ptr->x_offset); 241 262 } 242 263 #else … … 250 271 { 251 272 if (png_ptr != NULL && info_ptr != NULL) 273 252 274 #if defined(PNG_oFFs_SUPPORTED) 253 275 if (info_ptr->valid & PNG_INFO_oFFs) 254 276 { 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) 257 280 return (0); 258 else return (info_ptr->y_offset); 281 282 else 283 return (info_ptr->y_offset); 259 284 } 260 285 #else … … 309 334 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) 310 335 { 311 png_debug1(1, "in %s retrieval function \n", "pHYs");336 png_debug1(1, "in %s retrieval function", "pHYs"); 312 337 if (res_x != NULL) 313 338 { … … 324 349 *unit_type = (int)info_ptr->phys_unit_type; 325 350 retval |= PNG_INFO_pHYs; 326 if (*unit_type == 1)351 if (*unit_type == 1) 327 352 { 328 353 if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); … … 366 391 && background != NULL) 367 392 { 368 png_debug1(1, "in %s retrieval function \n", "bKGD");393 png_debug1(1, "in %s retrieval function", "bKGD"); 369 394 *background = &(info_ptr->background); 370 395 return (PNG_INFO_bKGD); … … 383 408 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) 384 409 { 385 png_debug1(1, "in %s retrieval function \n", "cHRM");410 png_debug1(1, "in %s retrieval function", "cHRM"); 386 411 if (white_x != NULL) 387 412 *white_x = (double)info_ptr->x_white; … … 414 439 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) 415 440 { 416 png_debug1(1, "in %s retrieval function \n", "cHRM");441 png_debug1(1, "in %s retrieval function", "cHRM"); 417 442 if (white_x != NULL) 418 443 *white_x = info_ptr->int_x_white; … … 446 471 && file_gamma != NULL) 447 472 { 448 png_debug1(1, "in %s retrieval function \n", "gAMA");473 png_debug1(1, "in %s retrieval function", "gAMA"); 449 474 *file_gamma = (double)info_ptr->gamma; 450 475 return (PNG_INFO_gAMA); … … 461 486 && int_file_gamma != NULL) 462 487 { 463 png_debug1(1, "in %s retrieval function \n", "gAMA");488 png_debug1(1, "in %s retrieval function", "gAMA"); 464 489 *int_file_gamma = info_ptr->int_gamma; 465 490 return (PNG_INFO_gAMA); … … 477 502 && file_srgb_intent != NULL) 478 503 { 479 png_debug1(1, "in %s retrieval function \n", "sRGB");504 png_debug1(1, "in %s retrieval function", "sRGB"); 480 505 *file_srgb_intent = (int)info_ptr->srgb_intent; 481 506 return (PNG_INFO_sRGB); … … 494 519 && name != NULL && profile != NULL && proflen != NULL) 495 520 { 496 png_debug1(1, "in %s retrieval function \n", "iCCP");521 png_debug1(1, "in %s retrieval function", "iCCP"); 497 522 *name = info_ptr->iccp_name; 498 523 *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 */ 501 527 *proflen = (int)info_ptr->iccp_proflen; 502 528 *compression_type = (int)info_ptr->iccp_compression; … … 528 554 && hist != NULL) 529 555 { 530 png_debug1(1, "in %s retrieval function \n", "hIST");556 png_debug1(1, "in %s retrieval function", "hIST"); 531 557 *hist = info_ptr->hist; 532 558 return (PNG_INFO_hIST); … … 546 572 bit_depth != NULL && color_type != NULL) 547 573 { 548 png_debug1(1, "in %s retrieval function \n", "IHDR");574 png_debug1(1, "in %s retrieval function", "IHDR"); 549 575 *width = info_ptr->width; 550 576 *height = info_ptr->height; 551 577 *bit_depth = info_ptr->bit_depth; 552 578 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 554 581 *color_type = info_ptr->color_type; 582 555 583 if (info_ptr->color_type > 6) 556 png_error(png_ptr, "Invalid color type"); 584 png_error(png_ptr, "Invalid color type"); 585 557 586 if (compression_type != NULL) 558 587 *compression_type = info_ptr->compression_type; 588 559 589 if (filter_type != NULL) 560 590 *filter_type = info_ptr->filter_type; 591 561 592 if (interlace_type != NULL) 562 593 *interlace_type = info_ptr->interlace_type; 563 594 564 /* check for potential overflow of rowbytes */595 /* Check for potential overflow of rowbytes */ 565 596 if (*width == 0 || *width > PNG_UINT_31_MAX) 566 597 png_error(png_ptr, "Invalid image width"); 598 567 599 if (*height == 0 || *height > PNG_UINT_31_MAX) 568 600 png_error(png_ptr, "Invalid image height"); 601 569 602 if (info_ptr->width > (PNG_UINT_32_MAX 570 603 >> 3) /* 8-byte RGBA pixels */ … … 577 610 "Width too large for libpng to process image data."); 578 611 } 612 579 613 return (1); 580 614 } … … 590 624 && offset_x != NULL && offset_y != NULL && unit_type != NULL) 591 625 { 592 png_debug1(1, "in %s retrieval function \n", "oFFs");626 png_debug1(1, "in %s retrieval function", "oFFs"); 593 627 *offset_x = info_ptr->x_offset; 594 628 *offset_y = info_ptr->y_offset; … … 607 641 { 608 642 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"); 613 647 *purpose = info_ptr->pcal_purpose; 614 648 *X0 = info_ptr->pcal_X0; … … 631 665 { 632 666 if (png_ptr != NULL && info_ptr != NULL && 633 (info_ptr->valid & PNG_INFO_sCAL))667 (info_ptr->valid & PNG_INFO_sCAL)) 634 668 { 635 669 *unit = info_ptr->scal_unit; … … 647 681 { 648 682 if (png_ptr != NULL && info_ptr != NULL && 649 (info_ptr->valid & PNG_INFO_sCAL))683 (info_ptr->valid & PNG_INFO_sCAL)) 650 684 { 651 685 *unit = info_ptr->scal_unit; … … 670 704 (info_ptr->valid & PNG_INFO_pHYs)) 671 705 { 672 png_debug1(1, "in %s retrieval function\n", "pHYs"); 706 png_debug1(1, "in %s retrieval function", "pHYs"); 707 673 708 if (res_x != NULL) 674 709 { … … 676 711 retval |= PNG_INFO_pHYs; 677 712 } 713 678 714 if (res_y != NULL) 679 715 { … … 681 717 retval |= PNG_INFO_pHYs; 682 718 } 719 683 720 if (unit_type != NULL) 684 721 { … … 698 735 && palette != NULL) 699 736 { 700 png_debug1(1, "in %s retrieval function \n", "PLTE");737 png_debug1(1, "in %s retrieval function", "PLTE"); 701 738 *palette = info_ptr->palette; 702 739 *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); 704 741 return (PNG_INFO_PLTE); 705 742 } … … 714 751 && sig_bit != NULL) 715 752 { 716 png_debug1(1, "in %s retrieval function \n", "sBIT");753 png_debug1(1, "in %s retrieval function", "sBIT"); 717 754 *sig_bit = &(info_ptr->sig_bit); 718 755 return (PNG_INFO_sBIT); … … 729 766 if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) 730 767 { 731 png_debug1(1, "in %s retrieval function \n",768 png_debug1(1, "in %s retrieval function", 732 769 (png_ptr->chunk_name[0] == '\0' ? "text" 733 770 : (png_const_charp)png_ptr->chunk_name)); 771 734 772 if (text_ptr != NULL) 735 773 *text_ptr = info_ptr->text; 774 736 775 if (num_text != NULL) 737 776 *num_text = info_ptr->num_text; 777 738 778 return ((png_uint_32)info_ptr->num_text); 739 779 } … … 751 791 && mod_time != NULL) 752 792 { 753 png_debug1(1, "in %s retrieval function \n", "tIME");793 png_debug1(1, "in %s retrieval function", "tIME"); 754 794 *mod_time = &(info_ptr->mod_time); 755 795 return (PNG_INFO_tIME); … … 767 807 if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) 768 808 { 769 png_debug1(1, "in %s retrieval function \n", "tRNS");809 png_debug1(1, "in %s retrieval function", "tRNS"); 770 810 if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) 771 811 { … … 775 815 retval |= PNG_INFO_tRNS; 776 816 } 817 777 818 if (trans_values != NULL) 778 819 *trans_values = &(info_ptr->trans_values); … … 785 826 retval |= PNG_INFO_tRNS; 786 827 } 787 if(trans != NULL) 828 829 if (trans != NULL) 788 830 *trans = NULL; 789 831 } 790 if (num_trans != NULL)832 if (num_trans != NULL) 791 833 { 792 834 *num_trans = info_ptr->num_trans; … … 838 880 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED 839 881 #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 */ 841 883 png_uint_32 PNGAPI 842 884 png_get_asm_flags (png_structp png_ptr) 843 885 { 844 /* obsolete, to be removed from libpng-1.4.0 */886 /* Obsolete, to be removed from libpng-1.4.0 */ 845 887 return (png_ptr? 0L: 0L); 846 888 } 847 889 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 */ 849 891 png_uint_32 PNGAPI 850 892 png_get_asm_flagmask (int flag_select) 851 893 { 852 /* obsolete, to be removed from libpng-1.4.0 */894 /* Obsolete, to be removed from libpng-1.4.0 */ 853 895 flag_select=flag_select; 854 896 return 0L; … … 856 898 857 899 /* 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 */ 859 901 png_uint_32 PNGAPI 860 902 png_get_mmx_flagmask (int flag_select, int *compilerID) 861 903 { 862 /* obsolete, to be removed from libpng-1.4.0 */904 /* Obsolete, to be removed from libpng-1.4.0 */ 863 905 flag_select=flag_select; 864 906 *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */ … … 866 908 } 867 909 868 /* this function was added to libpng 1.2.0 */910 /* This function was added to libpng 1.2.0 */ 869 911 png_byte PNGAPI 870 912 png_get_mmx_bitdepth_threshold (png_structp png_ptr) 871 913 { 872 /* obsolete, to be removed from libpng-1.4.0 */914 /* Obsolete, to be removed from libpng-1.4.0 */ 873 915 return (png_ptr? 0: 0); 874 916 } 875 917 876 /* this function was added to libpng 1.2.0 */918 /* This function was added to libpng 1.2.0 */ 877 919 png_uint_32 PNGAPI 878 920 png_get_mmx_rowbytes_threshold (png_structp png_ptr) 879 921 { 880 /* obsolete, to be removed from libpng-1.4.0 */922 /* Obsolete, to be removed from libpng-1.4.0 */ 881 923 return (png_ptr? 0L: 0L); 882 924 } … … 885 927 886 928 #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 */ 888 930 png_uint_32 PNGAPI 889 931 png_get_user_width_max (png_structp png_ptr) … … 897 939 } 898 940 #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ 899 941 900 942 901 943 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ -
trunk/src/3rdparty/libpng/pngmem.c
r2 r561 2 2 /* pngmem.c - stub functions for memory allocation 3 3 * 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 7 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 7 * (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 9 12 * 10 13 * This file provides a location for all memory allocation. Users who … … 17 20 #define PNG_INTERNAL 18 21 #include "png.h" 19 20 22 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 21 23 22 24 /* Borland DOS special memory handler */ 23 25 #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 */ 25 27 26 28 /* Allocate memory for a png_struct. The malloc and memset can be replaced … … 42 44 43 45 if (type == PNG_STRUCT_INFO) 44 size = png_sizeof(png_info);46 size = png_sizeof(png_info); 45 47 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) 52 54 { 53 55 png_struct dummy_struct; … … 58 60 else 59 61 #endif /* PNG_USER_MEM_SUPPORTED */ 60 struct_ptr = (png_voidp)farmalloc(size);62 struct_ptr = (png_voidp)farmalloc(size); 61 63 if (struct_ptr != NULL) 62 64 png_memset(struct_ptr, 0, size); … … 81 83 { 82 84 #ifdef PNG_USER_MEM_SUPPORTED 83 if (free_fn != NULL)85 if (free_fn != NULL) 84 86 { 85 87 png_struct dummy_struct; … … 123 125 124 126 #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)); 129 131 if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) 130 132 png_error(png_ptr, "Out of memory!"); … … 151 153 152 154 if (size != (size_t)size) 153 ret = NULL;155 ret = NULL; 154 156 else if (size == (png_uint_32)65536L) 155 157 { 156 158 if (png_ptr->offset_table == NULL) 157 159 { 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 */ 159 161 ret = farmalloc(size); 160 162 if (ret == NULL || ((png_size_t)ret & 0xffff)) … … 172 174 } 173 175 174 if (png_ptr->zlib_window_bits > 14)176 if (png_ptr->zlib_window_bits > 14) 175 177 num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14)); 176 178 else … … 211 213 png_ptr->offset_table = table; 212 214 png_ptr->offset_table_ptr = farmalloc(num_blocks * 213 png_sizeof (png_bytep));215 png_sizeof(png_bytep)); 214 216 215 217 if (png_ptr->offset_table_ptr == NULL) … … 271 273 } 272 274 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 */ 276 279 void PNGAPI 277 280 png_free(png_structp png_ptr, png_voidp ptr) … … 286 289 return; 287 290 } 288 else png_free_default(png_ptr, ptr); 291 else 292 png_free_default(png_ptr, ptr); 289 293 } 290 294 … … 294 298 #endif /* PNG_USER_MEM_SUPPORTED */ 295 299 296 if(png_ptr == NULL || ptr == NULL) return; 300 if (png_ptr == NULL || ptr == NULL) 301 return; 297 302 298 303 if (png_ptr->offset_table != NULL) … … 354 359 355 360 #ifdef PNG_USER_MEM_SUPPORTED 356 if (malloc_fn != NULL)361 if (malloc_fn != NULL) 357 362 { 358 363 png_struct dummy_struct; … … 370 375 #else 371 376 # if defined(_MSC_VER) && defined(MAXSEG_64K) 372 struct_ptr = (png_voidp)halloc(size, 1);377 struct_ptr = (png_voidp)halloc(size, 1); 373 378 # else 374 379 struct_ptr = (png_voidp)malloc(size); … … 399 404 { 400 405 #ifdef PNG_USER_MEM_SUPPORTED 401 if (free_fn != NULL)406 if (free_fn != NULL) 402 407 { 403 408 png_struct dummy_struct; … … 421 426 422 427 /* 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 427 434 428 435 png_voidp PNGAPI … … 435 442 return (NULL); 436 443 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)); 441 448 if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) 442 449 png_error(png_ptr, "Out of Memory!"); … … 465 472 #endif 466 473 467 /* Check for overflow */474 /* Check for overflow */ 468 475 #if defined(__TURBOC__) && !defined(__FLAT__) 469 if (size != (unsigned long)size)470 ret = NULL;471 else472 ret = farmalloc(size);476 if (size != (unsigned long)size) 477 ret = NULL; 478 else 479 ret = farmalloc(size); 473 480 #else 474 481 # if defined(_MSC_VER) && defined(MAXSEG_64K) 475 if (size != (unsigned long)size)476 ret = NULL;477 else478 ret = halloc(size, 1);482 if (size != (unsigned long)size) 483 ret = NULL; 484 else 485 ret = halloc(size, 1); 479 486 # else 480 if (size != (size_t)size)481 ret = NULL;482 else483 ret = malloc((size_t)size);487 if (size != (size_t)size) 488 ret = NULL; 489 else 490 ret = malloc((size_t)size); 484 491 # endif 485 492 #endif … … 494 501 495 502 /* Free a pointer allocated by png_malloc(). If ptr is NULL, return 496 without taking any action. */ 503 * without taking any action. 504 */ 497 505 void PNGAPI 498 506 png_free(png_structp png_ptr, png_voidp ptr) … … 507 515 return; 508 516 } 509 else png_free_default(png_ptr, ptr); 517 else 518 png_free_default(png_ptr, ptr); 510 519 } 511 520 void PNGAPI … … 543 552 png_voidp ptr; 544 553 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; 548 558 png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; 549 559 ptr = (png_voidp)png_malloc((png_structp)png_ptr, size); … … 561 571 size = (png_size_t)length; 562 572 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."); 564 574 565 575 return(png_memcpy (s1, s2, size)); … … 574 584 size = (png_size_t)length; 575 585 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."); 577 587 578 588 return (png_memset (s1, value, size)); … … 588 598 malloc_fn, png_free_ptr free_fn) 589 599 { 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; 594 605 } 595 606 } … … 602 613 png_get_mem_ptr(png_structp png_ptr) 603 614 { 604 if(png_ptr == NULL) return (NULL); 615 if (png_ptr == NULL) 616 return (NULL); 605 617 return ((png_voidp)png_ptr->mem_ptr); 606 618 } -
trunk/src/3rdparty/libpng/pngpread.c
r2 r561 2 2 /* pngpread.c - read a png file in push mode 3 3 * 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 7 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 7 * (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 9 12 */ 10 13 11 14 #define PNG_INTERNAL 12 15 #include "png.h" 13 14 16 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED 15 17 16 /* push model modes */18 /* Push model modes */ 17 19 #define PNG_READ_SIG_MODE 0 18 20 #define PNG_READ_CHUNK_MODE 1 … … 29 31 png_bytep buffer, png_size_t buffer_size) 30 32 { 31 if(png_ptr == NULL || info_ptr == NULL) return; 33 if (png_ptr == NULL || info_ptr == NULL) 34 return; 35 32 36 png_push_restore_buffer(png_ptr, buffer, buffer_size); 33 37 … … 44 48 png_process_some_data(png_structp png_ptr, png_infop info_ptr) 45 49 { 46 if(png_ptr == NULL) return; 50 if (png_ptr == NULL) 51 return; 52 47 53 switch (png_ptr->process_mode) 48 54 { … … 52 58 break; 53 59 } 60 54 61 case PNG_READ_CHUNK_MODE: 55 62 { … … 57 64 break; 58 65 } 66 59 67 case PNG_READ_IDAT_MODE: 60 68 { … … 62 70 break; 63 71 } 72 64 73 #if defined(PNG_READ_tEXt_SUPPORTED) 65 74 case PNG_READ_tEXt_MODE: … … 68 77 break; 69 78 } 79 70 80 #endif 71 81 #if defined(PNG_READ_zTXt_SUPPORTED) … … 75 85 break; 76 86 } 87 77 88 #endif 78 89 #if defined(PNG_READ_iTXt_SUPPORTED) … … 82 93 break; 83 94 } 95 84 96 #endif 85 97 case PNG_SKIP_MODE: … … 88 100 break; 89 101 } 102 90 103 default: 91 104 { … … 115 128 png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]), 116 129 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); 118 131 119 132 if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) … … 211 224 212 225 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); 214 227 png_reset_crc(png_ptr); 215 228 png_crc_read(png_ptr, png_ptr->chunk_name, 4); 229 png_check_chunk_name(png_ptr, png_ptr->chunk_name); 216 230 png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; 217 231 } 218 232 219 233 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) 221 235 png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; 222 236 223 237 if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) 224 238 { 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 232 248 png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length); 233 249 } 250 234 251 else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) 235 252 { … … 239 256 return; 240 257 } 258 241 259 png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length); 242 260 … … 244 262 png_push_have_end(png_ptr, info_ptr); 245 263 } 264 246 265 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED 247 266 else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) … … 252 271 return; 253 272 } 273 254 274 if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) 255 275 png_ptr->mode |= PNG_HAVE_IDAT; 276 256 277 png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length); 278 257 279 if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) 258 280 png_ptr->mode |= PNG_HAVE_PLTE; 281 259 282 else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) 260 283 { 261 284 if (!(png_ptr->mode & PNG_HAVE_IHDR)) 262 285 png_error(png_ptr, "Missing IHDR before IDAT"); 286 263 287 else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && 264 288 !(png_ptr->mode & PNG_HAVE_PLTE)) … … 266 290 } 267 291 } 292 268 293 #endif 269 294 else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) … … 276 301 png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length); 277 302 } 303 278 304 else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) 279 305 { … … 282 308 * is called after the image has been read - we have an error). 283 309 */ 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"); 289 317 290 318 if (png_ptr->mode & PNG_HAVE_IDAT) 291 319 { 292 320 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; 295 323 296 324 if (png_ptr->mode & PNG_AFTER_IDAT) … … 306 334 return; 307 335 } 336 308 337 #if defined(PNG_READ_gAMA_SUPPORTED) 309 338 else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) … … 314 343 return; 315 344 } 345 316 346 png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length); 317 347 } 348 318 349 #endif 319 350 #if defined(PNG_READ_sBIT_SUPPORTED) … … 325 356 return; 326 357 } 358 327 359 png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length); 328 360 } 361 329 362 #endif 330 363 #if defined(PNG_READ_cHRM_SUPPORTED) … … 336 369 return; 337 370 } 371 338 372 png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length); 339 373 } 374 340 375 #endif 341 376 #if defined(PNG_READ_sRGB_SUPPORTED) … … 347 382 return; 348 383 } 384 349 385 png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length); 350 386 } 387 351 388 #endif 352 389 #if defined(PNG_READ_iCCP_SUPPORTED) … … 358 395 return; 359 396 } 397 360 398 png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length); 361 399 } 400 362 401 #endif 363 402 #if defined(PNG_READ_sPLT_SUPPORTED) … … 369 408 return; 370 409 } 410 371 411 png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length); 372 412 } 413 373 414 #endif 374 415 #if defined(PNG_READ_tRNS_SUPPORTED) … … 380 421 return; 381 422 } 423 382 424 png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length); 383 425 } 426 384 427 #endif 385 428 #if defined(PNG_READ_bKGD_SUPPORTED) … … 391 434 return; 392 435 } 436 393 437 png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length); 394 438 } 439 395 440 #endif 396 441 #if defined(PNG_READ_hIST_SUPPORTED) … … 402 447 return; 403 448 } 449 404 450 png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length); 405 451 } 452 406 453 #endif 407 454 #if defined(PNG_READ_pHYs_SUPPORTED) … … 413 460 return; 414 461 } 462 415 463 png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length); 416 464 } 465 417 466 #endif 418 467 #if defined(PNG_READ_oFFs_SUPPORTED) … … 424 473 return; 425 474 } 475 426 476 png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length); 427 477 } 428 478 #endif 479 429 480 #if defined(PNG_READ_pCAL_SUPPORTED) 430 481 else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) … … 435 486 return; 436 487 } 488 437 489 png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length); 438 490 } 491 439 492 #endif 440 493 #if defined(PNG_READ_sCAL_SUPPORTED) … … 446 499 return; 447 500 } 501 448 502 png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length); 449 503 } 504 450 505 #endif 451 506 #if defined(PNG_READ_tIME_SUPPORTED) … … 457 512 return; 458 513 } 514 459 515 png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length); 460 516 } 517 461 518 #endif 462 519 #if defined(PNG_READ_tEXt_SUPPORTED) … … 468 525 return; 469 526 } 527 470 528 png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length); 471 529 } 530 472 531 #endif 473 532 #if defined(PNG_READ_zTXt_SUPPORTED) … … 479 538 return; 480 539 } 540 481 541 png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length); 482 542 } 543 483 544 #endif 484 545 #if defined(PNG_READ_iTXt_SUPPORTED) … … 490 551 return; 491 552 } 553 492 554 png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length); 493 555 } 556 494 557 #endif 495 558 else … … 566 629 png_bytep ptr; 567 630 568 if(png_ptr == NULL) return; 631 if (png_ptr == NULL) 632 return; 633 569 634 ptr = buffer; 570 635 if (png_ptr->save_buffer_size) … … 590 655 if (length < png_ptr->current_buffer_size) 591 656 save_size = length; 657 592 658 else 593 659 save_size = png_ptr->current_buffer_size; … … 607 673 if (png_ptr->save_buffer_ptr != png_ptr->save_buffer) 608 674 { 609 png_size_t i, istop;675 png_size_t i, istop; 610 676 png_bytep sp; 611 677 png_bytep dp; … … 630 696 png_error(png_ptr, "Potential overflow of save_buffer"); 631 697 } 698 632 699 new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256; 633 700 old_buffer = png_ptr->save_buffer; … … 676 743 677 744 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); 679 746 png_reset_crc(png_ptr); 680 747 png_crc_read(png_ptr, png_ptr->chunk_name, 4); … … 698 765 { 699 766 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) 702 770 png_error(png_ptr, "save_size overflowed in pngpread"); 703 771 } … … 706 774 707 775 png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); 776 708 777 if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) 709 778 png_process_IDAT_data(png_ptr, png_ptr->save_buffer_ptr, save_size); 779 710 780 png_ptr->idat_size -= save_size; 711 781 png_ptr->buffer_size -= save_size; … … 720 790 { 721 791 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) 724 795 png_error(png_ptr, "save_size overflowed in pngpread"); 725 796 } … … 761 832 png_ptr->zstream.next_in = buffer; 762 833 png_ptr->zstream.avail_in = (uInt)buffer_length; 763 for (;;)834 for (;;) 764 835 { 765 836 ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); … … 770 841 if (png_ptr->zstream.avail_in) 771 842 png_error(png_ptr, "Extra compressed data"); 843 772 844 if (!(png_ptr->zstream.avail_out)) 773 845 { … … 781 853 else if (ret == Z_BUF_ERROR) 782 854 break; 855 783 856 else 784 857 png_error(png_ptr, "Decompression Error"); … … 802 875 png_ptr->zstream.next_out = png_ptr->row_buf; 803 876 } 877 804 878 else 805 879 break; … … 830 904 831 905 #if defined(PNG_READ_INTERLACING_SUPPORTED) 832 /* blow up interlaced rows to full size */906 /* Blow up interlaced rows to full size */ 833 907 if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) 834 908 { … … 848 922 { 849 923 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 */ 853 928 { 854 929 for (i = 0; i < 4 && png_ptr->pass == 2; i++) … … 858 933 } 859 934 } 935 860 936 if (png_ptr->pass == 4 && png_ptr->height <= 4) 861 937 { … … 866 942 } 867 943 } 944 868 945 if (png_ptr->pass == 6 && png_ptr->height <= 4) 869 946 { … … 871 948 png_read_push_finish_row(png_ptr); 872 949 } 950 873 951 break; 874 952 } 953 875 954 case 1: 876 955 { … … 881 960 png_read_push_finish_row(png_ptr); 882 961 } 883 if (png_ptr->pass == 2) /* skip top 4 generated rows */ 962 963 if (png_ptr->pass == 2) /* Skip top 4 generated rows */ 884 964 { 885 965 for (i = 0; i < 4 && png_ptr->pass == 2; i++) … … 889 969 } 890 970 } 971 891 972 break; 892 973 } 974 893 975 case 2: 894 976 { 895 977 int i; 978 896 979 for (i = 0; i < 4 && png_ptr->pass == 2; i++) 897 980 { … … 899 982 png_read_push_finish_row(png_ptr); 900 983 } 984 901 985 for (i = 0; i < 4 && png_ptr->pass == 2; i++) 902 986 { … … 904 988 png_read_push_finish_row(png_ptr); 905 989 } 906 if (png_ptr->pass == 4) /* pass 3 might be empty */ 990 991 if (png_ptr->pass == 4) /* Pass 3 might be empty */ 907 992 { 908 993 for (i = 0; i < 2 && png_ptr->pass == 4; i++) … … 912 997 } 913 998 } 999 914 1000 break; 915 1001 } 1002 916 1003 case 3: 917 1004 { 918 1005 int i; 1006 919 1007 for (i = 0; i < 4 && png_ptr->pass == 3; i++) 920 1008 { … … 922 1010 png_read_push_finish_row(png_ptr); 923 1011 } 924 if (png_ptr->pass == 4) /* skip top two generated rows */ 1012 1013 if (png_ptr->pass == 4) /* Skip top two generated rows */ 925 1014 { 926 1015 for (i = 0; i < 2 && png_ptr->pass == 4; i++) … … 930 1019 } 931 1020 } 1021 932 1022 break; 933 1023 } 1024 934 1025 case 4: 935 1026 { 936 1027 int i; 1028 937 1029 for (i = 0; i < 2 && png_ptr->pass == 4; i++) 938 1030 { … … 940 1032 png_read_push_finish_row(png_ptr); 941 1033 } 1034 942 1035 for (i = 0; i < 2 && png_ptr->pass == 4; i++) 943 1036 { … … 945 1038 png_read_push_finish_row(png_ptr); 946 1039 } 947 if (png_ptr->pass == 6) /* pass 5 might be empty */ 1040 1041 if (png_ptr->pass == 6) /* Pass 5 might be empty */ 948 1042 { 949 1043 png_push_have_row(png_ptr, png_bytep_NULL); 950 1044 png_read_push_finish_row(png_ptr); 951 1045 } 1046 952 1047 break; 953 1048 } 1049 954 1050 case 5: 955 1051 { 956 1052 int i; 1053 957 1054 for (i = 0; i < 2 && png_ptr->pass == 5; i++) 958 1055 { … … 960 1057 png_read_push_finish_row(png_ptr); 961 1058 } 962 if (png_ptr->pass == 6) /* skip top generated row */ 1059 1060 if (png_ptr->pass == 6) /* Skip top generated row */ 963 1061 { 964 1062 png_push_have_row(png_ptr, png_bytep_NULL); 965 1063 png_read_push_finish_row(png_ptr); 966 1064 } 1065 967 1066 break; 968 1067 } … … 971 1070 png_push_have_row(png_ptr, png_ptr->row_buf + 1); 972 1071 png_read_push_finish_row(png_ptr); 1072 973 1073 if (png_ptr->pass != 6) 974 1074 break; 1075 975 1076 png_push_have_row(png_ptr, png_bytep_NULL); 976 1077 png_read_push_finish_row(png_ptr); … … 990 1091 { 991 1092 #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 */ 995 1096 PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; 996 1097 997 /* offset to next interlace block */1098 /* Offset to next interlace block */ 998 1099 PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; 999 1100 1000 /* start of interlace block in the y direction */1101 /* Start of interlace block in the y direction */ 1001 1102 PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; 1002 1103 1003 /* offset to next interlace block in the y direction */1104 /* Offset to next interlace block in the y direction */ 1004 1105 PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; 1005 1106 … … 1014 1115 return; 1015 1116 1117 #if defined(PNG_READ_INTERLACING_SUPPORTED) 1016 1118 if (png_ptr->interlaced) 1017 1119 { … … 1021 1123 do 1022 1124 { 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]; 1054 1152 1055 1153 } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0); 1056 1154 } 1155 #endif /* PNG_READ_INTERLACING_SUPPORTED */ 1057 1156 } 1058 1157 … … 1065 1164 { 1066 1165 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 */ 1068 1167 } 1069 1168 … … 1080 1179 1081 1180 png_ptr->current_text = (png_charp)png_malloc(png_ptr, 1082 (png_uint_32)(length+1));1181 (png_uint_32)(length + 1)); 1083 1182 png_ptr->current_text[length] = '\0'; 1084 1183 png_ptr->current_text_ptr = png_ptr->current_text; … … 1097 1196 if (png_ptr->buffer_size < png_ptr->current_text_left) 1098 1197 text_size = png_ptr->buffer_size; 1198 1099 1199 else 1100 1200 text_size = png_ptr->current_text_left; 1201 1101 1202 png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); 1102 1203 png_ptr->current_text_left -= text_size; … … 1126 1227 1127 1228 for (text = key; *text; text++) 1128 /* empty loop */ ;1229 /* Empty loop */ ; 1129 1230 1130 1231 if (text < key + png_ptr->current_text_size) … … 1161 1262 { 1162 1263 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 */ 1164 1265 } 1165 1266 … … 1178 1279 1179 1280 png_ptr->current_text = (png_charp)png_malloc(png_ptr, 1180 (png_uint_32)(length+1));1281 (png_uint_32)(length + 1)); 1181 1282 png_ptr->current_text[length] = '\0'; 1182 1283 png_ptr->current_text_ptr = png_ptr->current_text; … … 1195 1296 if (png_ptr->buffer_size < (png_uint_32)png_ptr->current_text_left) 1196 1297 text_size = png_ptr->buffer_size; 1298 1197 1299 else 1198 1300 text_size = png_ptr->current_text_left; 1301 1199 1302 png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); 1200 1303 png_ptr->current_text_left -= text_size; … … 1220 1323 1221 1324 for (text = key; *text; text++) 1222 /* empty loop */ ;1325 /* Empty loop */ ; 1223 1326 1224 1327 /* zTXt can't have zero text */ … … 1232 1335 text++; 1233 1336 1234 if (*text != PNG_TEXT_COMPRESSION_zTXt) /* check compression byte */1337 if (*text != PNG_TEXT_COMPRESSION_zTXt) /* Check compression byte */ 1235 1338 { 1236 1339 png_ptr->current_text = NULL; … … 1269 1372 { 1270 1373 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 1273 1377 png_memcpy(text + key_size, png_ptr->zbuf, 1274 1378 png_ptr->zbuf_size - png_ptr->zstream.avail_out); 1379 1275 1380 png_memcpy(text, key, key_size); 1381 1276 1382 text_size = key_size + png_ptr->zbuf_size - 1277 1383 png_ptr->zstream.avail_out; 1384 1278 1385 *(text + text_size) = '\0'; 1279 1386 } … … 1284 1391 tmp = text; 1285 1392 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 1288 1396 png_memcpy(text, tmp, text_size); 1289 1397 png_free(png_ptr, tmp); 1398 1290 1399 png_memcpy(text + text_size, png_ptr->zbuf, 1291 1400 png_ptr->zbuf_size - png_ptr->zstream.avail_out); 1401 1292 1402 text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; 1293 1403 *(text + text_size) = '\0'; … … 1353 1463 { 1354 1464 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 */ 1356 1466 } 1357 1467 … … 1368 1478 1369 1479 png_ptr->current_text = (png_charp)png_malloc(png_ptr, 1370 (png_uint_32)(length+1));1480 (png_uint_32)(length + 1)); 1371 1481 png_ptr->current_text[length] = '\0'; 1372 1482 png_ptr->current_text_ptr = png_ptr->current_text; … … 1386 1496 if (png_ptr->buffer_size < png_ptr->current_text_left) 1387 1497 text_size = png_ptr->buffer_size; 1498 1388 1499 else 1389 1500 text_size = png_ptr->current_text_left; 1501 1390 1502 png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); 1391 1503 png_ptr->current_text_left -= text_size; … … 1418 1530 1419 1531 for (lang = key; *lang; lang++) 1420 /* empty loop */ ;1532 /* Empty loop */ ; 1421 1533 1422 1534 if (lang < key + png_ptr->current_text_size - 3) … … 1424 1536 1425 1537 comp_flag = *lang++; 1426 lang++; /* skip comp_type, always zero */1538 lang++; /* Skip comp_type, always zero */ 1427 1539 1428 1540 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 */ 1431 1544 1432 1545 text=lang_key; 1546 1433 1547 if (lang_key < key + png_ptr->current_text_size - 1) 1434 1548 { 1435 1549 for (; *text; text++) 1436 /* empty loop */ ;1550 /* Empty loop */ ; 1437 1551 } 1438 1552 … … 1442 1556 text_ptr = (png_textp)png_malloc(png_ptr, 1443 1557 (png_uint_32)png_sizeof(png_text)); 1558 1444 1559 text_ptr->compression = comp_flag + 2; 1445 1560 text_ptr->key = key; … … 1469 1584 length) 1470 1585 { 1471 png_uint_32 skip=0; 1472 png_check_chunk_name(png_ptr, png_ptr->chunk_name); 1586 png_uint_32 skip = 0; 1473 1587 1474 1588 if (!(png_ptr->chunk_name[0] & 0x20)) 1475 1589 { 1476 1590 #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) 1477 if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=1478 PNG_HANDLE_CHUNK_ALWAYS1591 if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != 1592 PNG_HANDLE_CHUNK_ALWAYS 1479 1593 #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) 1480 && png_ptr->read_user_chunk_fn == NULL1481 #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 */ 1487 1601 } 1488 1602 … … 1501 1615 (png_charp)png_ptr->chunk_name, 1502 1616 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'; 1504 1619 1505 1620 png_ptr->unknown_chunk.size = (png_size_t)length; 1621 1506 1622 if (length == 0) 1507 1623 png_ptr->unknown_chunk.data = NULL; 1624 1508 1625 else 1509 1626 { 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); 1511 1629 png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length); 1512 1630 } 1631 1513 1632 #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 */ 1517 1636 int ret; 1518 1637 ret = (*(png_ptr->read_user_chunk_fn)) 1519 1638 (png_ptr, &png_ptr->unknown_chunk); 1639 1520 1640 if (ret < 0) 1521 1641 png_chunk_error(png_ptr, "error in user chunk"); 1642 1522 1643 if (ret == 0) 1523 1644 { 1524 1645 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) != 1526 1647 PNG_HANDLE_CHUNK_ALWAYS) 1527 1648 png_chunk_error(png_ptr, "unknown critical chunk"); … … 1530 1651 } 1531 1652 } 1653 1532 1654 else 1533 1655 #endif … … 1536 1658 png_ptr->unknown_chunk.data = NULL; 1537 1659 } 1660 1538 1661 else 1539 1662 #endif … … 1572 1695 {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; 1573 1696 #endif 1574 if(png_ptr == NULL) return; 1697 if (png_ptr == NULL) 1698 return; 1699 1575 1700 if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */ 1576 1701 png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]); … … 1582 1707 png_progressive_end_ptr end_fn) 1583 1708 { 1584 if(png_ptr == NULL) return; 1709 if (png_ptr == NULL) 1710 return; 1711 1585 1712 png_ptr->info_fn = info_fn; 1586 1713 png_ptr->row_fn = row_fn; … … 1593 1720 png_get_progressive_ptr(png_structp png_ptr) 1594 1721 { 1595 if(png_ptr == NULL) return (NULL); 1722 if (png_ptr == NULL) 1723 return (NULL); 1724 1596 1725 return png_ptr->io_ptr; 1597 1726 } -
trunk/src/3rdparty/libpng/pngread.c
r2 r561 2 2 /* pngread.c - read a PNG file 3 3 * 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 7 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 7 * (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 9 12 * 10 13 * This file contains routines that an application calls directly to … … 14 17 #define PNG_INTERNAL 15 18 #include "png.h" 16 17 19 #if defined(PNG_READ_SUPPORTED) 18 20 … … 36 38 #endif /* PNG_USER_MEM_SUPPORTED */ 37 39 40 #ifdef PNG_SETJMP_SUPPORTED 41 volatile 42 #endif 38 43 png_structp png_ptr; 39 44 … … 46 51 int i; 47 52 48 png_debug(1, "in png_create_read_struct \n");53 png_debug(1, "in png_create_read_struct"); 49 54 #ifdef PNG_USER_MEM_SUPPORTED 50 55 png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, … … 56 61 return (NULL); 57 62 58 /* added at libpng-1.2.6 */63 /* Added at libpng-1.2.6 */ 59 64 #ifdef PNG_SET_USER_LIMITS_SUPPORTED 60 65 png_ptr->user_width_max=PNG_USER_WIDTH_MAX; … … 70 75 { 71 76 png_free(png_ptr, png_ptr->zbuf); 72 png_ptr->zbuf =NULL;77 png_ptr->zbuf = NULL; 73 78 #ifdef PNG_USER_MEM_SUPPORTED 74 79 png_destroy_struct_2((png_voidp)png_ptr, … … 80 85 } 81 86 #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)); 83 88 #endif 84 89 #endif … … 90 95 png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); 91 96 92 if (user_png_ver)93 { 94 i =0;97 if (user_png_ver) 98 { 99 i = 0; 95 100 do 96 101 { 97 if (user_png_ver[i] != png_libpng_ver[i])102 if (user_png_ver[i] != png_libpng_ver[i]) 98 103 png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; 99 104 } while (png_libpng_ver[i++]); … … 101 106 else 102 107 png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; 103 108 104 109 105 110 if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) … … 129 134 #endif 130 135 #ifdef PNG_ERROR_NUMBERS_SUPPORTED 131 png_ptr->flags =0;136 png_ptr->flags = 0; 132 137 #endif 133 138 png_error(png_ptr, … … 136 141 } 137 142 138 /* initialize zbuf - compression buffer */143 /* Initialize zbuf - compression buffer */ 139 144 png_ptr->zbuf_size = PNG_ZBUF_SIZE; 140 145 png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, … … 165 170 if (setjmp(jmpbuf)) 166 171 PNG_ABORT(); 167 png_memcpy(png_ptr->jmpbuf, jmpbuf,png_sizeof(jmp_buf));172 png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf)); 168 173 #else 169 174 if (setjmp(png_ptr->jmpbuf)) … … 191 196 { 192 197 /* We only come here via pre-1.0.12-compiled applications */ 193 if(png_ptr == NULL) return; 198 if (png_ptr == NULL) 199 return; 194 200 #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 || 196 202 png_sizeof(png_info) > png_info_size) 197 203 { 198 204 char msg[80]; 199 png_ptr->warning_fn =NULL;205 png_ptr->warning_fn = NULL; 200 206 if (user_png_ver) 201 207 { … … 211 217 } 212 218 #endif 213 if (png_sizeof(png_struct) > png_struct_size)219 if (png_sizeof(png_struct) > png_struct_size) 214 220 { 215 png_ptr->error_fn =NULL;221 png_ptr->error_fn = NULL; 216 222 #ifdef PNG_ERROR_NUMBERS_SUPPORTED 217 png_ptr->flags =0;223 png_ptr->flags = 0; 218 224 #endif 219 225 png_error(png_ptr, 220 226 "The png struct allocated by the application for reading is too small."); 221 227 } 222 if (png_sizeof(png_info) > png_info_size)228 if (png_sizeof(png_info) > png_info_size) 223 229 { 224 png_ptr->error_fn =NULL;230 png_ptr->error_fn = NULL; 225 231 #ifdef PNG_ERROR_NUMBERS_SUPPORTED 226 png_ptr->flags =0;232 png_ptr->flags = 0; 227 233 #endif 228 234 png_error(png_ptr, … … 241 247 #endif 242 248 243 int i =0;249 int i = 0; 244 250 245 251 png_structp png_ptr=*ptr_ptr; 246 252 247 if(png_ptr == NULL) return; 253 if (png_ptr == NULL) 254 return; 248 255 249 256 do 250 257 { 251 if (user_png_ver[i] != png_libpng_ver[i])258 if (user_png_ver[i] != png_libpng_ver[i]) 252 259 { 253 260 #ifdef PNG_LEGACY_SUPPORTED 254 261 png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; 255 262 #else 256 png_ptr->warning_fn =NULL;263 png_ptr->warning_fn = NULL; 257 264 png_warning(png_ptr, 258 265 "Application uses deprecated png_read_init() and should be recompiled."); … … 262 269 } while (png_libpng_ver[i++]); 263 270 264 png_debug(1, "in png_read_init_3 \n");271 png_debug(1, "in png_read_init_3"); 265 272 266 273 #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)); 280 287 281 288 #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 */ 287 294 #ifdef PNG_SET_USER_LIMITS_SUPPORTED 288 295 png_ptr->user_width_max=PNG_USER_WIDTH_MAX; … … 290 297 #endif 291 298 292 /* initialize zbuf - compression buffer */299 /* Initialize zbuf - compression buffer */ 293 300 png_ptr->zbuf_size = PNG_ZBUF_SIZE; 294 301 png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, … … 325 332 png_read_info(png_structp png_ptr, png_infop info_ptr) 326 333 { 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"); 329 337 /* If we haven't checked all of the PNG signature bytes, do so now. */ 330 338 if (png_ptr->sig_bytes < 8) … … 348 356 } 349 357 350 for (;;)358 for (;;) 351 359 { 352 360 #ifdef PNG_USE_LOCAL_ARRAYS … … 407 415 #endif 408 416 #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; 420 419 421 420 /* This should be a binary subdivision search or a hash for 422 421 * matching the chunk name rather than a linear search. 423 422 */ 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) 426 425 png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; 427 426 428 if (!png_memcmp( png_ptr->chunk_name, png_IHDR, 4))427 if (!png_memcmp(chunk_name, png_IHDR, 4)) 429 428 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)) 431 430 png_handle_IEND(png_ptr, info_ptr, length); 432 431 #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)) 436 435 png_ptr->mode |= PNG_HAVE_IDAT; 437 436 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)) 439 438 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)) 441 440 { 442 441 if (!(png_ptr->mode & PNG_HAVE_IHDR)) … … 449 448 } 450 449 #endif 451 else if (!png_memcmp( png_ptr->chunk_name, png_PLTE, 4))450 else if (!png_memcmp(chunk_name, png_PLTE, 4)) 452 451 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)) 454 453 { 455 454 if (!(png_ptr->mode & PNG_HAVE_IHDR)) … … 464 463 } 465 464 #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)) 467 466 png_handle_bKGD(png_ptr, info_ptr, length); 468 467 #endif 469 468 #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)) 471 470 png_handle_cHRM(png_ptr, info_ptr, length); 472 471 #endif 473 472 #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)) 475 474 png_handle_gAMA(png_ptr, info_ptr, length); 476 475 #endif 477 476 #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)) 479 478 png_handle_hIST(png_ptr, info_ptr, length); 480 479 #endif 481 480 #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)) 483 482 png_handle_oFFs(png_ptr, info_ptr, length); 484 483 #endif 485 484 #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)) 487 486 png_handle_pCAL(png_ptr, info_ptr, length); 488 487 #endif 489 488 #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)) 491 490 png_handle_sCAL(png_ptr, info_ptr, length); 492 491 #endif 493 492 #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)) 495 494 png_handle_pHYs(png_ptr, info_ptr, length); 496 495 #endif 497 496 #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)) 499 498 png_handle_sBIT(png_ptr, info_ptr, length); 500 499 #endif 501 500 #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)) 503 502 png_handle_sRGB(png_ptr, info_ptr, length); 504 503 #endif 505 504 #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)) 507 506 png_handle_iCCP(png_ptr, info_ptr, length); 508 507 #endif 509 508 #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)) 511 510 png_handle_sPLT(png_ptr, info_ptr, length); 512 511 #endif 513 512 #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)) 515 514 png_handle_tEXt(png_ptr, info_ptr, length); 516 515 #endif 517 516 #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)) 519 518 png_handle_tIME(png_ptr, info_ptr, length); 520 519 #endif 521 520 #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)) 523 522 png_handle_tRNS(png_ptr, info_ptr, length); 524 523 #endif 525 524 #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)) 527 526 png_handle_zTXt(png_ptr, info_ptr, length); 528 527 #endif 529 528 #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)) 531 530 png_handle_iTXt(png_ptr, info_ptr, length); 532 531 #endif … … 537 536 #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ 538 537 539 /* optional call to update the users info_ptr structure */538 /* Optional call to update the users info_ptr structure */ 540 539 void PNGAPI 541 540 png_read_update_info(png_structp png_ptr, png_infop info_ptr) 542 541 { 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; 545 545 if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) 546 546 png_read_start_row(png_ptr); … … 560 560 png_start_read_image(png_structp png_ptr) 561 561 { 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; 564 565 if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) 565 566 png_read_start_row(png_ptr); … … 574 575 PNG_CONST PNG_IDAT; 575 576 PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 576 0xff};577 0xff}; 577 578 PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; 578 579 #endif 579 580 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)", 582 584 png_ptr->row_number, png_ptr->pass); 583 585 if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) … … 585 587 if (png_ptr->row_number == 0 && png_ptr->pass == 0) 586 588 { 587 /* check for transforms that have been set but were defined out */589 /* Check for transforms that have been set but were defined out */ 588 590 #if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED) 589 591 if (png_ptr->transformations & PNG_INVERT_MONO) … … 617 619 618 620 #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 */ 620 622 if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) 621 623 { … … 704 706 while (!png_ptr->idat_size) 705 707 { 706 png_byte chunk_length[4];707 708 708 png_crc_finish(png_ptr, 0); 709 709 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); 715 711 if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) 716 712 png_error(png_ptr, "Not enough image data"); … … 748 744 png_ptr->row_info.width); 749 745 750 if (png_ptr->row_buf[0])746 if (png_ptr->row_buf[0]) 751 747 png_read_filter_row(png_ptr, &(png_ptr->row_info), 752 748 png_ptr->row_buf + 1, png_ptr->prev_row + 1, … … 757 753 758 754 #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) && 760 756 (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) 761 757 { … … 770 766 771 767 #if defined(PNG_READ_INTERLACING_SUPPORTED) 772 /* blow up interlaced rows to full size */768 /* Blow up interlaced rows to full size */ 773 769 if (png_ptr->interlaced && 774 770 (png_ptr->transformations & PNG_INTERLACE)) 775 771 { 776 772 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 */ 781 777 png_do_read_interlace(png_ptr); 782 778 … … 836 832 png_bytepp dp; 837 833 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; 840 837 rp = row; 841 838 dp = display_row; … … 848 845 png_read_row(png_ptr, rptr, dptr); 849 846 } 850 else if (rp != NULL)847 else if (rp != NULL) 851 848 for (i = 0; i < num_rows; i++) 852 849 { … … 855 852 rp++; 856 853 } 857 else if (dp != NULL)854 else if (dp != NULL) 858 855 for (i = 0; i < num_rows; i++) 859 856 { … … 881 878 png_read_image(png_structp png_ptr, png_bytepp image) 882 879 { 883 png_uint_32 i, image_height;880 png_uint_32 i, image_height; 884 881 int pass, j; 885 882 png_bytepp rp; 886 883 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; 889 887 890 888 #ifdef PNG_READ_INTERLACING_SUPPORTED … … 921 919 png_read_end(png_structp png_ptr, png_infop info_ptr) 922 920 { 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; 928 924 png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */ 929 925 … … 987 983 #endif 988 984 #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)) 999 989 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)) 1001 991 png_handle_IEND(png_ptr, info_ptr, length); 1002 992 #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)) 1006 996 { 1007 997 if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) … … 1009 999 } 1010 1000 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)) 1012 1002 png_ptr->mode |= PNG_HAVE_PLTE; 1013 1003 } 1014 1004 #endif 1015 else if (!png_memcmp( png_ptr->chunk_name, png_IDAT, 4))1005 else if (!png_memcmp(chunk_name, png_IDAT, 4)) 1016 1006 { 1017 1007 /* Zero length IDATs are legal after the last IDAT has been … … 1022 1012 png_crc_finish(png_ptr, length); 1023 1013 } 1024 else if (!png_memcmp( png_ptr->chunk_name, png_PLTE, 4))1014 else if (!png_memcmp(chunk_name, png_PLTE, 4)) 1025 1015 png_handle_PLTE(png_ptr, info_ptr, length); 1026 1016 #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)) 1028 1018 png_handle_bKGD(png_ptr, info_ptr, length); 1029 1019 #endif 1030 1020 #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)) 1032 1022 png_handle_cHRM(png_ptr, info_ptr, length); 1033 1023 #endif 1034 1024 #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)) 1036 1026 png_handle_gAMA(png_ptr, info_ptr, length); 1037 1027 #endif 1038 1028 #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)) 1040 1030 png_handle_hIST(png_ptr, info_ptr, length); 1041 1031 #endif 1042 1032 #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)) 1044 1034 png_handle_oFFs(png_ptr, info_ptr, length); 1045 1035 #endif 1046 1036 #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)) 1048 1038 png_handle_pCAL(png_ptr, info_ptr, length); 1049 1039 #endif 1050 1040 #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)) 1052 1042 png_handle_sCAL(png_ptr, info_ptr, length); 1053 1043 #endif 1054 1044 #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)) 1056 1046 png_handle_pHYs(png_ptr, info_ptr, length); 1057 1047 #endif 1058 1048 #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)) 1060 1050 png_handle_sBIT(png_ptr, info_ptr, length); 1061 1051 #endif 1062 1052 #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)) 1064 1054 png_handle_sRGB(png_ptr, info_ptr, length); 1065 1055 #endif 1066 1056 #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)) 1068 1058 png_handle_iCCP(png_ptr, info_ptr, length); 1069 1059 #endif 1070 1060 #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)) 1072 1062 png_handle_sPLT(png_ptr, info_ptr, length); 1073 1063 #endif 1074 1064 #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)) 1076 1066 png_handle_tEXt(png_ptr, info_ptr, length); 1077 1067 #endif 1078 1068 #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)) 1080 1070 png_handle_tIME(png_ptr, info_ptr, length); 1081 1071 #endif 1082 1072 #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)) 1084 1074 png_handle_tRNS(png_ptr, info_ptr, length); 1085 1075 #endif 1086 1076 #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)) 1088 1078 png_handle_zTXt(png_ptr, info_ptr, length); 1089 1079 #endif 1090 1080 #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)) 1092 1082 png_handle_iTXt(png_ptr, info_ptr, length); 1093 1083 #endif … … 1098 1088 #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ 1099 1089 1100 /* free all memory used by the read */1090 /* Free all memory used by the read */ 1101 1091 void PNGAPI 1102 1092 png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, … … 1110 1100 #endif 1111 1101 1112 png_debug(1, "in png_destroy_read_struct \n");1102 png_debug(1, "in png_destroy_read_struct"); 1113 1103 if (png_ptr_ptr != NULL) 1114 {1115 1104 png_ptr = *png_ptr_ptr; 1116 }1117 1105 if (png_ptr == NULL) 1118 1106 return; … … 1160 1148 } 1161 1149 1150 if (png_ptr != NULL) 1151 { 1162 1152 #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); 1165 1155 #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) */ 1172 1163 void /* PRIVATE */ 1173 1164 png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr) … … 1183 1174 #endif 1184 1175 1185 png_debug(1, "in png_read_destroy \n");1176 png_debug(1, "in png_read_destroy"); 1186 1177 if (info_ptr != NULL) 1187 1178 png_info_destroy(png_ptr, info_ptr); … … 1193 1184 png_free(png_ptr, png_ptr->big_row_buf); 1194 1185 png_free(png_ptr, png_ptr->prev_row); 1186 png_free(png_ptr, png_ptr->chunkdata); 1195 1187 #if defined(PNG_READ_DITHER_SUPPORTED) 1196 1188 png_free(png_ptr, png_ptr->palette_lookup); … … 1289 1281 */ 1290 1282 #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)); 1292 1284 #endif 1293 1285 … … 1299 1291 #endif 1300 1292 1301 png_memset(png_ptr, 0, png_sizeof (png_struct));1293 png_memset(png_ptr, 0, png_sizeof(png_struct)); 1302 1294 1303 1295 png_ptr->error_fn = error_fn; … … 1309 1301 1310 1302 #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)); 1312 1304 #endif 1313 1305 … … 1317 1309 png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn) 1318 1310 { 1319 if(png_ptr == NULL) return; 1311 if (png_ptr == NULL) 1312 return; 1320 1313 png_ptr->read_row_fn = read_row_fn; 1321 1314 } … … 1331 1324 int row; 1332 1325 1333 if(png_ptr == NULL) return; 1326 if (png_ptr == NULL) 1327 return; 1334 1328 #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) 1335 /* invert the alpha channel from opacity to transparency1329 /* Invert the alpha channel from opacity to transparency 1336 1330 */ 1337 1331 if (transforms & PNG_TRANSFORM_INVERT_ALPHA) … … 1344 1338 png_read_info(png_ptr, info_ptr); 1345 1339 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()"); 1347 1341 1348 1342 /* -------------- image transformations start here ------------------- */ 1349 1343 1350 1344 #if defined(PNG_READ_16_TO_8_SUPPORTED) 1351 /* tell libpng to strip 16 bit/color files down to 8 bits per color1345 /* Tell libpng to strip 16 bit/color files down to 8 bits per color. 1352 1346 */ 1353 1347 if (transforms & PNG_TRANSFORM_STRIP_16) 1354 png_set_strip_16(png_ptr);1348 png_set_strip_16(png_ptr); 1355 1349 #endif 1356 1350 … … 1360 1354 */ 1361 1355 if (transforms & PNG_TRANSFORM_STRIP_ALPHA) 1362 png_set_strip_alpha(png_ptr);1356 png_set_strip_alpha(png_ptr); 1363 1357 #endif 1364 1358 … … 1368 1362 */ 1369 1363 if (transforms & PNG_TRANSFORM_PACKING) 1370 png_set_packing(png_ptr);1364 png_set_packing(png_ptr); 1371 1365 #endif 1372 1366 … … 1376 1370 */ 1377 1371 if (transforms & PNG_TRANSFORM_PACKSWAP) 1378 png_set_packswap(png_ptr);1372 png_set_packswap(png_ptr); 1379 1373 #endif 1380 1374 … … 1386 1380 */ 1387 1381 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))) 1391 1385 png_set_expand(png_ptr); 1392 1386 #endif … … 1396 1390 1397 1391 #if defined(PNG_READ_INVERT_SUPPORTED) 1398 /* invert monochrome files to have 0 as white and 1 as black1392 /* Invert monochrome files to have 0 as white and 1 as black 1399 1393 */ 1400 1394 if (transforms & PNG_TRANSFORM_INVERT_MONO) 1401 png_set_invert_mono(png_ptr);1395 png_set_invert_mono(png_ptr); 1402 1396 #endif 1403 1397 … … 1418 1412 1419 1413 #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) 1421 1415 */ 1422 1416 if (transforms & PNG_TRANSFORM_BGR) 1423 png_set_bgr(png_ptr);1417 png_set_bgr(png_ptr); 1424 1418 #endif 1425 1419 1426 1420 #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) 1428 1422 */ 1429 1423 if (transforms & PNG_TRANSFORM_SWAP_ALPHA) … … 1432 1426 1433 1427 #if defined(PNG_READ_SWAP_SUPPORTED) 1434 /* swap bytes of 16 bit files to least significant byte first1428 /* Swap bytes of 16 bit files to least significant byte first 1435 1429 */ 1436 1430 if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) 1437 png_set_swap(png_ptr);1431 png_set_swap(png_ptr); 1438 1432 #endif 1439 1433 … … 1451 1445 png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); 1452 1446 #endif 1453 if (info_ptr->row_pointers == NULL)1447 if (info_ptr->row_pointers == NULL) 1454 1448 { 1455 1449 info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr, 1456 1450 info_ptr->height * png_sizeof(png_bytep)); 1451 png_memset(info_ptr->row_pointers, 0, info_ptr->height 1452 * png_sizeof(png_bytep)); 1457 1453 #ifdef PNG_FREE_ME_SUPPORTED 1458 1454 info_ptr->free_me |= PNG_FREE_ROWS; 1459 1455 #endif 1460 1456 for (row = 0; row < (int)info_ptr->height; row++) 1461 {1462 1457 info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr, 1463 1458 png_get_rowbytes(png_ptr, info_ptr)); 1464 }1465 1459 } 1466 1460 … … 1468 1462 info_ptr->valid |= PNG_INFO_IDAT; 1469 1463 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 */ 1471 1465 png_read_end(png_ptr, info_ptr); 1472 1466 1473 transforms = transforms; /* quiet compiler warnings */1467 transforms = transforms; /* Quiet compiler warnings */ 1474 1468 params = params; 1475 1469 -
trunk/src/3rdparty/libpng/pngrio.c
r2 r561 2 2 /* pngrio.c - functions for data input 3 3 * 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 7 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 7 * (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 9 12 * 10 13 * This file provides a location for all input. Users who need … … 18 21 #define PNG_INTERNAL 19 22 #include "png.h" 20 21 23 #if defined(PNG_READ_SUPPORTED) 22 24 23 25 /* 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 */ 28 31 void /* PRIVATE */ 29 32 png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) 30 33 { 31 png_debug1(4, "reading %d bytes\n", (int)length);34 png_debug1(4, "reading %d bytes", (int)length); 32 35 if (png_ptr->read_data_fn != NULL) 33 36 (*(png_ptr->read_data_fn))(png_ptr, data, length); … … 38 41 #if !defined(PNG_NO_STDIO) 39 42 /* 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 */ 43 47 #ifndef USE_FAR_KEYWORD 44 48 void PNGAPI … … 47 51 png_size_t check; 48 52 49 if(png_ptr == NULL) return; 53 if (png_ptr == NULL) 54 return; 50 55 /* fread() returns 0 on error, so it is OK to store this in a png_size_t 51 56 * instead of an int, which is what fread() actually returns. … … 63 68 } 64 69 #else 65 /* this is the model-independent version. Since the standard I/O library70 /* This is the model-independent version. Since the standard I/O library 66 71 can't handle far buffers in the medium and small models, we have to copy 67 72 the data. … … 78 83 png_FILE_p io_ptr; 79 84 80 if(png_ptr == NULL) return; 85 if (png_ptr == NULL) 86 return; 81 87 /* Check if data really is near. If so, use usual code. */ 82 88 n_data = (png_byte *)CVT_PTR_NOCHECK(data); … … 107 113 #endif 108 114 png_memcpy(data, buf, read); /* copy far buffer to near buffer */ 109 if (err != read)115 if (err != read) 110 116 break; 111 117 else … … 123 129 124 130 /* 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 */ 137 146 void PNGAPI 138 147 png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, 139 148 png_rw_ptr read_data_fn) 140 149 { 141 if(png_ptr == NULL) return; 150 if (png_ptr == NULL) 151 return; 142 152 png_ptr->io_ptr = io_ptr; 143 153 -
trunk/src/3rdparty/libpng/pngrtran.c
r2 r561 2 2 /* pngrtran.c - transforms the data in a row for PNG readers 3 3 * 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 7 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 7 * (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 9 12 * 10 13 * This file contains functions optionally called by an application … … 16 19 #define PNG_INTERNAL 17 20 #include "png.h" 18 19 21 #if defined(PNG_READ_SUPPORTED) 20 22 … … 23 25 png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action) 24 26 { 25 png_debug(1, "in png_set_crc_action \n");27 png_debug(1, "in png_set_crc_action"); 26 28 /* Tell libpng how we react to CRC errors in critical chunks */ 27 if(png_ptr == NULL) return; 29 if (png_ptr == NULL) 30 return; 28 31 switch (crit_action) 29 32 { 30 case PNG_CRC_NO_CHANGE: /* leave setting as is */33 case PNG_CRC_NO_CHANGE: /* Leave setting as is */ 31 34 break; 32 case PNG_CRC_WARN_USE: /* warn/use data */ 35 36 case PNG_CRC_WARN_USE: /* Warn/use data */ 33 37 png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; 34 38 png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE; 35 39 break; 36 case PNG_CRC_QUIET_USE: /* quiet/use data */ 40 41 case PNG_CRC_QUIET_USE: /* Quiet/use data */ 37 42 png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; 38 43 png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE | 39 44 PNG_FLAG_CRC_CRITICAL_IGNORE; 40 45 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 44 52 case PNG_CRC_DEFAULT: 45 53 default: … … 50 58 switch (ancil_action) 51 59 { 52 case PNG_CRC_NO_CHANGE: /* leave setting as is */60 case PNG_CRC_NO_CHANGE: /* Leave setting as is */ 53 61 break; 54 case PNG_CRC_WARN_USE: /* warn/use data */ 62 63 case PNG_CRC_WARN_USE: /* Warn/use data */ 55 64 png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; 56 65 png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE; 57 66 break; 58 case PNG_CRC_QUIET_USE: /* quiet/use data */ 67 68 case PNG_CRC_QUIET_USE: /* Quiet/use data */ 59 69 png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; 60 70 png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE | 61 71 PNG_FLAG_CRC_ANCILLARY_NOWARN; 62 72 break; 63 case PNG_CRC_ERROR_QUIT: /* error/quit */ 73 74 case PNG_CRC_ERROR_QUIT: /* Error/quit */ 64 75 png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; 65 76 png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN; 66 77 break; 67 case PNG_CRC_WARN_DISCARD: /* warn/discard data */ 78 79 case PNG_CRC_WARN_DISCARD: /* Warn/discard data */ 80 68 81 case PNG_CRC_DEFAULT: 69 82 default: … … 75 88 #if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ 76 89 defined(PNG_FLOATING_POINT_SUPPORTED) 77 /* handle alpha and tRNS via a background color */90 /* Handle alpha and tRNS via a background color */ 78 91 void PNGAPI 79 92 png_set_background(png_structp png_ptr, … … 81 94 int need_expand, double background_gamma) 82 95 { 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; 85 99 if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN) 86 100 { … … 99 113 100 114 #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 */ 102 116 void PNGAPI 103 117 png_set_strip_16(png_structp png_ptr) 104 118 { 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; 107 122 png_ptr->transformations |= PNG_16_TO_8; 108 123 } … … 113 128 png_set_strip_alpha(png_structp png_ptr) 114 129 { 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; 117 133 png_ptr->flags |= PNG_FLAG_STRIP_ALPHA; 118 134 } … … 143 159 int full_dither) 144 160 { 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; 147 164 png_ptr->transformations |= PNG_DITHER; 148 165 … … 152 169 153 170 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))); 155 172 for (i = 0; i < num_palette; i++) 156 173 png_ptr->dither_index[i] = (png_byte)i; … … 162 179 { 163 180 /* 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 */ 165 183 166 184 int i; 167 185 168 /* initialize an array to sort colors */186 /* Initialize an array to sort colors */ 169 187 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 */ 173 191 for (i = 0; i < num_palette; i++) 174 192 png_ptr->dither_sort[i] = (png_byte)i; 175 193 176 194 /* 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 */ 181 200 182 201 for (i = num_palette - 1; i >= maximum_colors; i--) 183 202 { 184 int done; /* to stop early if the list is pre-sorted */203 int done; /* To stop early if the list is pre-sorted */ 185 204 int j; 186 205 … … 203 222 } 204 223 205 /* swap the palette around, and set up a table, if necessary */224 /* Swap the palette around, and set up a table, if necessary */ 206 225 if (full_dither) 207 226 { 208 227 int j = num_palette; 209 228 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 */ 212 232 for (i = 0; i < maximum_colors; i++) 213 233 { … … 225 245 int j = num_palette; 226 246 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 */ 229 250 for (i = 0; i < maximum_colors; i++) 230 251 { 231 /* only move the colors we need to */252 /* Only move the colors we need to */ 232 253 if ((int)png_ptr->dither_sort[i] >= maximum_colors) 233 254 { … … 241 262 palette[j] = palette[i]; 242 263 palette[i] = tmp_color; 243 /* indicate where the color went */264 /* Indicate where the color went */ 244 265 png_ptr->dither_index[j] = (png_byte)i; 245 266 png_ptr->dither_index[i] = (png_byte)j; … … 247 268 } 248 269 249 /* find closest color for those colors we are not using */270 /* Find closest color for those colors we are not using */ 250 271 for (i = 0; i < num_palette; i++) 251 272 { … … 254 275 int min_d, k, min_k, d_index; 255 276 256 /* find the closest color to one we threw out */277 /* Find the closest color to one we threw out */ 257 278 d_index = png_ptr->dither_index[i]; 258 279 min_d = PNG_COLOR_DIST(palette[d_index], palette[0]); … … 269 290 } 270 291 } 271 /* point to closest color */292 /* Point to closest color */ 272 293 png_ptr->dither_index[i] = (png_byte)min_k; 273 294 } … … 275 296 } 276 297 png_free(png_ptr, png_ptr->dither_sort); 277 png_ptr->dither_sort =NULL;298 png_ptr->dither_sort = NULL; 278 299 } 279 300 else 280 301 { 281 302 /* This is much harder to do simply (and quickly). Perhaps 282 we need to go through a median cut routine, but those283 don't always behave themselves with only a few colors284 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 to287 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 */ 289 310 int i; 290 311 int max_d; … … 293 314 png_dsortpp hash; 294 315 295 t =NULL;296 297 /* initialize palette index arrays */316 t = NULL; 317 318 /* Initialize palette index arrays */ 298 319 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))); 300 321 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 */ 304 325 for (i = 0; i < num_palette; i++) 305 326 { … … 309 330 310 331 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)); 315 334 316 335 num_new_palette = num_palette; 317 336 318 /* initial wild guess at how far apart the farthest pixel319 pair we will be eliminating will be. Larger320 numbers mean more areas will be allocated, Smaller321 numbers run the risk of not saving enough data, and322 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 */ 326 345 max_d = 96; 327 346 … … 437 456 png_free(png_ptr, png_ptr->palette_to_index); 438 457 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; 441 460 } 442 461 num_palette = maximum_colors; … … 458 477 int num_blue = (1 << PNG_DITHER_BLUE_BITS); 459 478 png_size_t num_entries = ((png_size_t)1 << total_bits); 460 461 479 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))); 464 481 png_memset(png_ptr->palette_lookup, 0, num_entries * 465 png_sizeof (png_byte));482 png_sizeof(png_byte)); 466 483 467 484 distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries * … … 527 544 png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma) 528 545 { 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; 531 549 if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) || 532 550 (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) || … … 546 564 png_set_expand(png_structp png_ptr) 547 565 { 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; 550 569 png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); 551 570 png_ptr->flags &= ~PNG_FLAG_ROW_INIT; … … 573 592 png_set_palette_to_rgb(png_structp png_ptr) 574 593 { 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; 577 597 png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); 578 598 png_ptr->flags &= ~PNG_FLAG_ROW_INIT; … … 584 604 png_set_expand_gray_1_2_4_to_8(png_structp png_ptr) 585 605 { 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; 588 609 png_ptr->transformations |= PNG_EXPAND; 589 610 png_ptr->flags &= ~PNG_FLAG_ROW_INIT; … … 597 618 png_set_gray_1_2_4_to_8(png_structp png_ptr) 598 619 { 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; 601 623 png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); 602 624 } … … 608 630 png_set_tRNS_to_alpha(png_structp png_ptr) 609 631 { 610 png_debug(1, "in png_set_tRNS_to_alpha \n");632 png_debug(1, "in png_set_tRNS_to_alpha"); 611 633 png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); 612 634 png_ptr->flags &= ~PNG_FLAG_ROW_INIT; … … 618 640 png_set_gray_to_rgb(png_structp png_ptr) 619 641 { 620 png_debug(1, "in png_set_gray_to_rgb \n");642 png_debug(1, "in png_set_gray_to_rgb"); 621 643 png_ptr->transformations |= PNG_GRAY_TO_RGB; 622 644 png_ptr->flags &= ~PNG_FLAG_ROW_INIT; … … 634 656 double green) 635 657 { 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); 640 663 } 641 664 #endif … … 645 668 png_fixed_point red, png_fixed_point green) 646 669 { 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; 649 673 switch(error_action) 650 674 { 651 675 case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY; 652 676 break; 677 653 678 case 2: png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN; 654 679 break; 680 655 681 case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; 656 682 } … … 660 686 #else 661 687 { 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."); 663 690 png_ptr->transformations &= ~PNG_RGB_TO_GRAY; 664 691 } … … 666 693 { 667 694 png_uint_16 red_int, green_int; 668 if (red < 0 || green < 0)695 if (red < 0 || green < 0) 669 696 { 670 697 red_int = 6968; /* .212671 * 32768 + .5 */ 671 698 green_int = 23434; /* .715160 * 32768 + .5 */ 672 699 } 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); 677 704 } 678 705 else … … 684 711 png_ptr->rgb_to_gray_red_coeff = red_int; 685 712 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); 687 715 } 688 716 } … … 690 718 691 719 #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) 694 722 void PNGAPI 695 723 png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr 696 724 read_user_transform_fn) 697 725 { 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; 700 729 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) 701 730 png_ptr->transformations |= PNG_USER_TRANSFORM; … … 703 732 #endif 704 733 #ifdef PNG_LEGACY_SUPPORTED 705 if (read_user_transform_fn)734 if (read_user_transform_fn) 706 735 png_warning(png_ptr, 707 736 "This version of libpng does not support user transforms"); … … 716 745 png_init_read_transformations(png_structp png_ptr) 717 746 { 718 png_debug(1, "in png_init_read_transformations \n");747 png_debug(1, "in png_init_read_transformations"); 719 748 #if defined(PNG_USELESS_TESTS_SUPPORTED) 720 if (png_ptr != NULL)749 if (png_ptr != NULL) 721 750 #endif 722 751 { … … 730 759 #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) 731 760 /* 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 734 764 * RGB_ALPHA (in which case need_expand is superfluous anyway), the 735 765 * background color might actually be gray yet not be flagged as such. … … 758 788 if (!(color_type & PNG_COLOR_MASK_COLOR)) /* i.e., GRAY or GRAY_ALPHA */ 759 789 { 760 /* expand background and tRNS chunks */790 /* Expand background and tRNS chunks */ 761 791 switch (png_ptr->bit_depth) 762 792 { … … 772 802 } 773 803 break; 804 774 805 case 2: 775 806 png_ptr->background.gray *= (png_uint_16)0x55; … … 783 814 } 784 815 break; 816 785 817 case 4: 786 818 png_ptr->background.gray *= (png_uint_16)0x11; … … 794 826 } 795 827 break; 828 796 829 case 8: 830 797 831 case 16: 798 832 png_ptr->background.red = png_ptr->background.green … … 817 851 #endif 818 852 { 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; 822 857 istop=(int)png_ptr->num_trans; 823 858 for (i=0; i<istop; i++) … … 840 875 < PNG_GAMMA_THRESHOLD)) 841 876 { 842 int i, k;877 int i, k; 843 878 k=0; 844 879 for (i=0; i<png_ptr->num_trans; i++) 845 880 { 846 881 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 */ 848 883 } 849 884 if (k == 0) … … 860 895 if (color_type == PNG_COLOR_TYPE_PALETTE) 861 896 { 862 /* could skip if no transparency and 863 */ 897 /* Could skip if no transparency */ 864 898 png_color back, back_1; 865 899 png_colorp palette = png_ptr->palette; … … 886 920 gs = 1.0; 887 921 break; 922 888 923 case PNG_BACKGROUND_GAMMA_FILE: 889 924 g = 1.0 / (png_ptr->gamma); 890 925 gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); 891 926 break; 927 892 928 case PNG_BACKGROUND_GAMMA_UNIQUE: 893 929 g = 1.0 / (png_ptr->background_gamma); … … 978 1014 gs = 1.0; 979 1015 break; 1016 980 1017 case PNG_BACKGROUND_GAMMA_FILE: 981 1018 g = 1.0 / (png_ptr->gamma); 982 1019 gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); 983 1020 break; 1021 984 1022 case PNG_BACKGROUND_GAMMA_UNIQUE: 985 1023 g = 1.0 / (png_ptr->background_gamma); … … 1023 1061 } 1024 1062 else 1025 /* transformation does not include PNG_BACKGROUND */1063 /* Transformation does not include PNG_BACKGROUND */ 1026 1064 #endif /* PNG_READ_BACKGROUND_SUPPORTED */ 1027 1065 if (color_type == PNG_COLOR_TYPE_PALETTE) … … 1111 1149 #if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \ 1112 1150 && !defined(PNG_READ_BACKGROUND_SUPPORTED) 1113 if (png_ptr)1151 if (png_ptr) 1114 1152 return; 1115 1153 #endif … … 1123 1161 png_read_transform_info(png_structp png_ptr, png_infop info_ptr) 1124 1162 { 1125 png_debug(1, "in png_read_transform_info \n");1163 png_debug(1, "in png_read_transform_info"); 1126 1164 #if defined(PNG_READ_EXPAND_SUPPORTED) 1127 1165 if (png_ptr->transformations & PNG_EXPAND) … … 1143 1181 if (png_ptr->transformations & PNG_EXPAND_tRNS) 1144 1182 info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; 1145 #if 0 /* Removed from libpng-1.2.27 */1146 else1147 info_ptr->color_type |= PNG_COLOR_MASK_COLOR;1148 #endif1149 1183 } 1150 1184 if (info_ptr->bit_depth < 8) … … 1195 1229 { 1196 1230 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) 1199 1233 { 1200 1234 info_ptr->color_type = PNG_COLOR_TYPE_PALETTE; … … 1230 1264 { 1231 1265 info_ptr->channels++; 1232 /* if adding a true alpha channel not just filler */1266 /* If adding a true alpha channel not just filler */ 1233 1267 #if !defined(PNG_1_0_X) 1234 1268 if (png_ptr->transformations & PNG_ADD_ALPHA) … … 1240 1274 #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \ 1241 1275 defined(PNG_READ_USER_TRANSFORM_SUPPORTED) 1242 if (png_ptr->transformations & PNG_USER_TRANSFORM)1276 if (png_ptr->transformations & PNG_USER_TRANSFORM) 1243 1277 { 1244 if (info_ptr->bit_depth < png_ptr->user_transform_depth)1278 if (info_ptr->bit_depth < png_ptr->user_transform_depth) 1245 1279 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) 1247 1281 info_ptr->channels = png_ptr->user_transform_channels; 1248 1282 } … … 1252 1286 info_ptr->bit_depth); 1253 1287 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); 1255 1289 1256 1290 #if !defined(PNG_READ_EXPAND_SUPPORTED) 1257 if (png_ptr)1291 if (png_ptr) 1258 1292 return; 1259 1293 #endif … … 1267 1301 png_do_read_transformations(png_structp png_ptr) 1268 1302 { 1269 png_debug(1, "in png_do_read_transformations \n");1303 png_debug(1, "in png_do_read_transformations"); 1270 1304 if (png_ptr->row_buf == NULL) 1271 1305 { … … 1274 1308 1275 1309 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, 1277 1311 png_ptr->pass); 1278 1312 png_error(png_ptr, msg); … … 1285 1319 /* Application has failed to call either png_read_start_image() 1286 1320 * 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 */ 1288 1323 #if (PNG_WARN_UNINITIALIZED_ROW==1) 1289 1324 png_error(png_ptr, "Uninitialized row"); … … 1325 1360 int rgb_error = 1326 1361 png_do_rgb_to_gray(png_ptr, &(png_ptr->row_info), png_ptr->row_buf + 1); 1327 if (rgb_error)1362 if (rgb_error) 1328 1363 { 1329 1364 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) == 1331 1366 PNG_RGB_TO_GRAY_WARN) 1332 1367 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) == 1334 1369 PNG_RGB_TO_GRAY_ERR) 1335 1370 png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel"); … … 1338 1373 #endif 1339 1374 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. 1368 1404 */ 1369 1405 1370 1406 #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 */ 1373 1410 if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && 1374 1411 !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) … … 1395 1432 if ((png_ptr->transformations & PNG_GAMMA) && 1396 1433 #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)) 1402 1439 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); 1405 1442 #endif 1406 1443 … … 1415 1452 png_do_dither((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1, 1416 1453 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) 1418 1455 png_error(png_ptr, "png_do_dither returned rowbytes=0"); 1419 1456 } … … 1447 1484 1448 1485 #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 */ 1450 1487 if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && 1451 1488 (png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) … … 1477 1514 if (png_ptr->transformations & PNG_USER_TRANSFORM) 1478 1515 { 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 */ 1490 1527 #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) 1491 if (png_ptr->user_transform_depth)1528 if (png_ptr->user_transform_depth) 1492 1529 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) 1494 1531 png_ptr->row_info.channels = png_ptr->user_transform_channels; 1495 1532 #endif … … 1513 1550 png_do_unpack(png_row_infop row_info, png_bytep row) 1514 1551 { 1515 png_debug(1, "in png_do_unpack \n");1552 png_debug(1, "in png_do_unpack"); 1516 1553 #if defined(PNG_USELESS_TESTS_SUPPORTED) 1517 1554 if (row != NULL && row_info != NULL && row_info->bit_depth < 8) … … 1545 1582 break; 1546 1583 } 1584 1547 1585 case 2: 1548 1586 { … … 1566 1604 break; 1567 1605 } 1606 1568 1607 case 4: 1569 1608 { … … 1603 1642 png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits) 1604 1643 { 1605 png_debug(1, "in png_do_unshift \n");1644 png_debug(1, "in png_do_unshift"); 1606 1645 if ( 1607 1646 #if defined(PNG_USELESS_TESTS_SUPPORTED) … … 1657 1696 break; 1658 1697 } 1698 1659 1699 case 4: 1660 1700 { … … 1672 1712 break; 1673 1713 } 1714 1674 1715 case 8: 1675 1716 { … … 1684 1725 break; 1685 1726 } 1727 1686 1728 case 16: 1687 1729 { … … 1705 1747 1706 1748 #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 */ 1708 1750 void /* PRIVATE */ 1709 1751 png_do_chop(png_row_infop row_info, png_bytep row) 1710 1752 { 1711 png_debug(1, "in png_do_chop \n");1753 png_debug(1, "in png_do_chop"); 1712 1754 #if defined(PNG_USELESS_TESTS_SUPPORTED) 1713 1755 if (row != NULL && row_info != NULL && row_info->bit_depth == 16) … … 1729 1771 * What the ideal calculation should be: 1730 1772 * *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; 1732 1775 * 1733 1776 * GRR: no, I think this is what it really should be: 1734 1777 * *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; 1736 1780 * 1737 1781 * 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; 1739 1784 * *dp = (temp - (temp >> 8)) >> 8; 1740 1785 * … … 1763 1808 png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) 1764 1809 { 1765 png_debug(1, "in png_do_read_swap_alpha \n");1810 png_debug(1, "in png_do_read_swap_alpha"); 1766 1811 #if defined(PNG_USELESS_TESTS_SUPPORTED) 1767 1812 if (row != NULL && row_info != NULL) … … 1855 1900 png_do_read_invert_alpha(png_row_infop row_info, png_bytep row) 1856 1901 { 1857 png_debug(1, "in png_do_read_invert_alpha \n");1902 png_debug(1, "in png_do_read_invert_alpha"); 1858 1903 #if defined(PNG_USELESS_TESTS_SUPPORTED) 1859 1904 if (row != NULL && row_info != NULL) … … 1961 2006 png_byte lo_filler = (png_byte)(filler & 0xff); 1962 2007 1963 png_debug(1, "in png_do_read_filler \n");2008 png_debug(1, "in png_do_read_filler"); 1964 2009 if ( 1965 2010 #if defined(PNG_USELESS_TESTS_SUPPORTED) … … 1968 2013 row_info->color_type == PNG_COLOR_TYPE_GRAY) 1969 2014 { 1970 if (row_info->bit_depth == 8)2015 if (row_info->bit_depth == 8) 1971 2016 { 1972 2017 /* This changes the data from G to GX */ … … 2000 2045 } 2001 2046 } 2002 else if (row_info->bit_depth == 16)2047 else if (row_info->bit_depth == 16) 2003 2048 { 2004 2049 /* This changes the data from GG to GGXX */ … … 2040 2085 else if (row_info->color_type == PNG_COLOR_TYPE_RGB) 2041 2086 { 2042 if (row_info->bit_depth == 8)2087 if (row_info->bit_depth == 8) 2043 2088 { 2044 2089 /* This changes the data from RGB to RGBX */ … … 2076 2121 } 2077 2122 } 2078 else if (row_info->bit_depth == 16)2123 else if (row_info->bit_depth == 16) 2079 2124 { 2080 2125 /* This changes the data from RRGGBB to RRGGBBXX */ … … 2126 2171 2127 2172 #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 */ 2129 2174 void /* PRIVATE */ 2130 2175 png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) … … 2133 2178 png_uint_32 row_width = row_info->width; 2134 2179 2135 png_debug(1, "in png_do_gray_to_rgb \n");2180 png_debug(1, "in png_do_gray_to_rgb"); 2136 2181 if (row_info->bit_depth >= 8 && 2137 2182 #if defined(PNG_USELESS_TESTS_SUPPORTED) … … 2203 2248 row_info->pixel_depth = (png_byte)(row_info->channels * 2204 2249 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); 2206 2251 } 2207 2252 } … … 2209 2254 2210 2255 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) 2211 /* reduce RGB files to grayscale, with or without alpha2256 /* Reduce RGB files to grayscale, with or without alpha 2212 2257 * 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 2215 2262 * 2216 2263 * Y = 0.212671 * R + 0.715160 * G + 0.072169 * B … … 2237 2284 int rgb_error = 0; 2238 2285 2239 png_debug(1, "in png_do_rgb_to_gray \n");2286 png_debug(1, "in png_do_rgb_to_gray"); 2240 2287 if ( 2241 2288 #if defined(PNG_USELESS_TESTS_SUPPORTED) … … 2263 2310 png_byte green = png_ptr->gamma_to_1[*(sp++)]; 2264 2311 png_byte blue = png_ptr->gamma_to_1[*(sp++)]; 2265 if (red != green || red != blue)2312 if (red != green || red != blue) 2266 2313 { 2267 2314 rgb_error |= 1; 2268 2315 *(dp++) = png_ptr->gamma_from_1[ 2269 (rc*red +gc*green+bc*blue)>>15];2316 (rc*red + gc*green + bc*blue)>>15]; 2270 2317 } 2271 2318 else 2272 *(dp++) = *(sp -1);2319 *(dp++) = *(sp - 1); 2273 2320 } 2274 2321 } … … 2283 2330 png_byte green = *(sp++); 2284 2331 png_byte blue = *(sp++); 2285 if (red != green || red != blue)2332 if (red != green || red != blue) 2286 2333 { 2287 2334 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); 2289 2336 } 2290 2337 else 2291 *(dp++) = *(sp -1);2338 *(dp++) = *(sp - 1); 2292 2339 } 2293 2340 } … … 2310 2357 blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; 2311 2358 2312 if (red == green && red == blue)2359 if (red == green && red == blue) 2313 2360 w = red; 2314 2361 else … … 2344 2391 blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; 2345 2392 2346 if (red != green || red != blue)2393 if (red != green || red != blue) 2347 2394 rgb_error |= 1; 2348 2395 gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); … … 2367 2414 png_byte green = png_ptr->gamma_to_1[*(sp++)]; 2368 2415 png_byte blue = png_ptr->gamma_to_1[*(sp++)]; 2369 if (red != green || red != blue)2416 if (red != green || red != blue) 2370 2417 rgb_error |= 1; 2371 2418 *(dp++) = png_ptr->gamma_from_1 … … 2384 2431 png_byte green = *(sp++); 2385 2432 png_byte blue = *(sp++); 2386 if (red != green || red != blue)2433 if (red != green || red != blue) 2387 2434 rgb_error |= 1; 2388 2435 *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15); … … 2407 2454 blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; 2408 2455 2409 if (red == green && red == blue)2456 if (red == green && red == blue) 2410 2457 w = red; 2411 2458 else … … 2441 2488 green = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; 2442 2489 blue = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; 2443 if (red != green || red != blue)2490 if (red != green || red != blue) 2444 2491 rgb_error |= 1; 2445 2492 gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); … … 2456 2503 row_info->pixel_depth = (png_byte)(row_info->channels * 2457 2504 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); 2459 2506 } 2460 2507 return rgb_error; … … 2475 2522 int v; 2476 2523 2477 png_debug(1, "in png_do_build_grayscale_palette \n");2524 png_debug(1, "in png_do_build_grayscale_palette"); 2478 2525 if (palette == NULL) 2479 2526 return; … … 2485 2532 color_inc = 0xff; 2486 2533 break; 2534 2487 2535 case 2: 2488 2536 num_palette = 4; 2489 2537 color_inc = 0x55; 2490 2538 break; 2539 2491 2540 case 4: 2492 2541 num_palette = 16; 2493 2542 color_inc = 0x11; 2494 2543 break; 2544 2495 2545 case 8: 2496 2546 num_palette = 256; 2497 2547 color_inc = 1; 2498 2548 break; 2549 2499 2550 default: 2500 2551 num_palette = 0; … … 2517 2568 int num_palette) 2518 2569 { 2519 png_debug(1, "in png_correct_palette \n");2570 png_debug(1, "in png_correct_palette"); 2520 2571 #if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ 2521 2572 defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) … … 2674 2725 } 2675 2726 } 2676 else /* assume grayscale palette (what else could it be?) */2727 else /* Assume grayscale palette (what else could it be?) */ 2677 2728 { 2678 2729 int i; … … 2714 2765 int shift; 2715 2766 2716 png_debug(1, "in png_do_background \n");2767 png_debug(1, "in png_do_background"); 2717 2768 if (background != NULL && 2718 2769 #if defined(PNG_USELESS_TESTS_SUPPORTED) … … 2750 2801 break; 2751 2802 } 2803 2752 2804 case 2: 2753 2805 { … … 2806 2858 break; 2807 2859 } 2860 2808 2861 case 4: 2809 2862 { … … 2862 2915 break; 2863 2916 } 2917 2864 2918 case 8: 2865 2919 { … … 2894 2948 break; 2895 2949 } 2950 2896 2951 case 16: 2897 2952 { … … 2907 2962 if (v == trans_values->gray) 2908 2963 { 2909 /* background is already in screen gamma */2964 /* Background is already in screen gamma */ 2910 2965 *sp = (png_byte)((background->gray >> 8) & 0xff); 2911 2966 *(sp + 1) = (png_byte)(background->gray & 0xff); … … 2940 2995 break; 2941 2996 } 2997 2942 2998 case PNG_COLOR_TYPE_RGB: 2943 2999 { … … 2997 3053 b == trans_values->blue) 2998 3054 { 2999 /* background is already in screen gamma */3055 /* Background is already in screen gamma */ 3000 3056 *sp = (png_byte)((background->red >> 8) & 0xff); 3001 3057 *(sp + 1) = (png_byte)(background->red & 0xff); … … 3044 3100 break; 3045 3101 } 3102 3046 3103 case PNG_COLOR_TYPE_GRAY_ALPHA: 3047 3104 { … … 3064 3121 else if (a == 0) 3065 3122 { 3066 /* background is already in screen gamma */3123 /* Background is already in screen gamma */ 3067 3124 *dp = (png_byte)background->gray; 3068 3125 } … … 3131 3188 #endif 3132 3189 { 3133 /* background is already in screen gamma */3190 /* Background is already in screen gamma */ 3134 3191 *dp = (png_byte)((background->gray >> 8) & 0xff); 3135 3192 *(dp + 1) = (png_byte)(background->gray & 0xff); … … 3186 3243 break; 3187 3244 } 3245 3188 3246 case PNG_COLOR_TYPE_RGB_ALPHA: 3189 3247 { … … 3208 3266 else if (a == 0) 3209 3267 { 3210 /* background is already in screen gamma */3268 /* Background is already in screen gamma */ 3211 3269 *dp = (png_byte)background->red; 3212 3270 *(dp + 1) = (png_byte)background->green; … … 3289 3347 else if (a == 0) 3290 3348 { 3291 /* background is already in screen gamma */3349 /* Background is already in screen gamma */ 3292 3350 *dp = (png_byte)((background->red >> 8) & 0xff); 3293 3351 *(dp + 1) = (png_byte)(background->red & 0xff); … … 3374 3432 row_info->pixel_depth = (png_byte)(row_info->channels * 3375 3433 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); 3377 3435 } 3378 3436 } … … 3396 3454 png_uint_32 row_width=row_info->width; 3397 3455 3398 png_debug(1, "in png_do_gamma \n");3456 png_debug(1, "in png_do_gamma"); 3399 3457 if ( 3400 3458 #if defined(PNG_USELESS_TESTS_SUPPORTED) … … 3444 3502 break; 3445 3503 } 3504 3446 3505 case PNG_COLOR_TYPE_RGB_ALPHA: 3447 3506 { … … 3481 3540 break; 3482 3541 } 3542 3483 3543 case PNG_COLOR_TYPE_GRAY_ALPHA: 3484 3544 { … … 3505 3565 break; 3506 3566 } 3567 3507 3568 case PNG_COLOR_TYPE_GRAY: 3508 3569 { … … 3525 3586 } 3526 3587 } 3588 3527 3589 if (row_info->bit_depth == 4) 3528 3590 { … … 3538 3600 } 3539 3601 } 3602 3540 3603 else if (row_info->bit_depth == 8) 3541 3604 { … … 3547 3610 } 3548 3611 } 3612 3549 3613 else if (row_info->bit_depth == 16) 3550 3614 { … … 3578 3642 png_uint_32 row_width=row_info->width; 3579 3643 3580 png_debug(1, "in png_do_expand_palette \n");3644 png_debug(1, "in png_do_expand_palette"); 3581 3645 if ( 3582 3646 #if defined(PNG_USELESS_TESTS_SUPPORTED) … … 3612 3676 break; 3613 3677 } 3678 3614 3679 case 2: 3615 3680 { … … 3633 3698 break; 3634 3699 } 3700 3635 3701 case 4: 3636 3702 { … … 3697 3763 sp--; 3698 3764 } 3765 3699 3766 row_info->bit_depth = 8; 3700 3767 row_info->pixel_depth = 24; … … 3721 3788 png_uint_32 row_width=row_info->width; 3722 3789 3723 png_debug(1, "in png_do_expand \n");3790 png_debug(1, "in png_do_expand"); 3724 3791 #if defined(PNG_USELESS_TESTS_SUPPORTED) 3725 3792 if (row != NULL && row_info != NULL) … … 3758 3825 break; 3759 3826 } 3827 3760 3828 case 2: 3761 3829 { … … 3781 3849 break; 3782 3850 } 3851 3783 3852 case 4: 3784 3853 { … … 3804 3873 } 3805 3874 } 3875 3806 3876 row_info->bit_depth = 8; 3807 3877 row_info->pixel_depth = 8; … … 3825 3895 } 3826 3896 } 3897 3827 3898 else if (row_info->bit_depth == 16) 3828 3899 { … … 3833 3904 for (i = 0; i < row_width; i++) 3834 3905 { 3835 if (*(sp -1) == gray_high && *(sp) == gray_low)3906 if (*(sp - 1) == gray_high && *(sp) == gray_low) 3836 3907 { 3837 3908 *dp-- = 0; … … 3847 3918 } 3848 3919 } 3920 3849 3921 row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA; 3850 3922 row_info->channels = 2; … … 3912 3984 row_info->channels = 4; 3913 3985 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); 3915 3987 } 3916 3988 } … … 3927 3999 png_uint_32 row_width=row_info->width; 3928 4000 3929 png_debug(1, "in png_do_dither \n");4001 png_debug(1, "in png_do_dither"); 3930 4002 #if defined(PNG_USELESS_TESTS_SUPPORTED) 3931 4003 if (row != NULL && row_info != NULL) … … 3944 4016 b = *sp++; 3945 4017 3946 /* this looks real messy, but the compiler will reduce3947 it down to a reasonable formula. For example, with3948 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 */ 3953 4025 p = (((r >> (8 - PNG_DITHER_RED_BITS)) & 3954 4026 ((1 << PNG_DITHER_RED_BITS) - 1)) << … … 3965 4037 row_info->channels = 1; 3966 4038 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); 3968 4040 } 3969 4041 else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && … … 3994 4066 row_info->channels = 1; 3995 4067 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); 3997 4069 } 3998 4070 else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE && … … 4022 4094 png_build_gamma_table(png_structp png_ptr) 4023 4095 { 4024 png_debug(1, "in png_build_gamma_table \n");4096 png_debug(1, "in png_build_gamma_table"); 4025 4097 4026 4098 if (png_ptr->bit_depth <= 8) … … 4031 4103 if (png_ptr->screen_gamma > .000001) 4032 4104 g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); 4105 4033 4106 else 4034 4107 g = 1.0; … … 4063 4136 (png_uint_32)256); 4064 4137 4065 if (png_ptr->screen_gamma > 0.000001)4138 if (png_ptr->screen_gamma > 0.000001) 4066 4139 g = 1.0 / png_ptr->screen_gamma; 4140 4067 4141 else 4068 g = png_ptr->gamma; /* probably doing rgb_to_gray */4142 g = png_ptr->gamma; /* Probably doing rgb_to_gray */ 4069 4143 4070 4144 for (i = 0; i < 256; i++) … … 4087 4161 { 4088 4162 sig_bit = (int)png_ptr->sig_bit.red; 4163 4089 4164 if ((int)png_ptr->sig_bit.green > sig_bit) 4090 4165 sig_bit = png_ptr->sig_bit.green; 4166 4091 4167 if ((int)png_ptr->sig_bit.blue > sig_bit) 4092 4168 sig_bit = png_ptr->sig_bit.blue; … … 4099 4175 if (sig_bit > 0) 4100 4176 shift = 16 - sig_bit; 4177 4101 4178 else 4102 4179 shift = 0; … … 4110 4187 if (shift > 8) 4111 4188 shift = 8; 4189 4112 4190 if (shift < 0) 4113 4191 shift = 0; … … 4123 4201 4124 4202 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)); 4126 4205 4127 4206 if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND)) … … 4133 4212 { 4134 4213 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))); 4136 4215 } 4137 4216 … … 4163 4242 { 4164 4243 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))); 4166 4245 4167 4246 ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4); 4247 4168 4248 for (j = 0; j < 256; j++) 4169 4249 { … … 4183 4263 4184 4264 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)); 4186 4267 4187 4268 for (i = 0; i < num; i++) 4188 4269 { 4189 4270 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))); 4191 4272 4192 4273 ig = (((png_uint_32)i * … … 4200 4281 } 4201 4282 4202 if (png_ptr->screen_gamma > 0.000001)4283 if (png_ptr->screen_gamma > 0.000001) 4203 4284 g = 1.0 / png_ptr->screen_gamma; 4285 4204 4286 else 4205 g = png_ptr->gamma; /* probably doing rgb_to_gray */4287 g = png_ptr->gamma; /* Probably doing rgb_to_gray */ 4206 4288 4207 4289 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)); 4209 4293 4210 4294 for (i = 0; i < num; i++) 4211 4295 { 4212 4296 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))); 4214 4298 4215 4299 ig = (((png_uint_32)i * 4216 4300 (png_uint_32)png_gamma_shift[shift]) >> 4); 4301 4217 4302 for (j = 0; j < 256; j++) 4218 4303 { … … 4231 4316 4232 4317 #if defined(PNG_MNG_FEATURES_SUPPORTED) 4233 /* undoes intrapixel differencing */4318 /* Undoes intrapixel differencing */ 4234 4319 void /* PRIVATE */ 4235 4320 png_do_read_intrapixel(png_row_infop row_info, png_bytep row) 4236 4321 { 4237 png_debug(1, "in png_do_read_intrapixel \n");4322 png_debug(1, "in png_do_read_intrapixel"); 4238 4323 if ( 4239 4324 #if defined(PNG_USELESS_TESTS_SUPPORTED) … … 4251 4336 if (row_info->color_type == PNG_COLOR_TYPE_RGB) 4252 4337 bytes_per_pixel = 3; 4338 4253 4339 else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) 4254 4340 bytes_per_pixel = 4; 4341 4255 4342 else 4256 4343 return; … … 4269 4356 if (row_info->color_type == PNG_COLOR_TYPE_RGB) 4270 4357 bytes_per_pixel = 6; 4358 4271 4359 else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) 4272 4360 bytes_per_pixel = 8; 4361 4273 4362 else 4274 4363 return; … … 4276 4365 for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) 4277 4366 { 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); 4283 4372 *(rp ) = (png_byte)((red >> 8) & 0xff); 4284 4373 *(rp+1) = (png_byte)(red & 0xff); -
trunk/src/3rdparty/libpng/pngrutil.c
r2 r561 2 2 /* pngrutil.c - utilities to read a PNG file 3 3 * 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 7 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 7 * (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 9 12 * 10 13 * This file contains routines that are only called from within … … 14 17 #define PNG_INTERNAL 15 18 #include "png.h" 16 17 19 #if defined(PNG_READ_SUPPORTED) 18 20 … … 23 25 #ifdef PNG_FLOATING_POINT_SUPPORTED 24 26 # if defined(WIN32_WCE_OLD) 25 /* strtod() function is not supported on WindowsCE */27 /* The strtod() function is not supported on WindowsCE */ 26 28 __inline double png_strtod(png_structp png_ptr, PNG_CONST char *nptr, char **endptr) 27 29 { … … 31 33 32 34 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)); 34 36 if ( NULL != str ) 35 37 { … … 50 52 png_get_uint_31(png_structp png_ptr, png_bytep buf) 51 53 { 54 #ifdef PNG_READ_BIG_ENDIAN_SUPPORTED 52 55 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 53 63 if (i > PNG_UINT_31_MAX) 54 64 png_error(png_ptr, "PNG unsigned integer out of range."); … … 70 80 /* Grab a signed 32-bit integer from a buffer in big-endian format. The 71 81 * 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 */ 73 84 png_int_32 PNGAPI 74 85 png_get_int_32(png_bytep buf) … … 93 104 #endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */ 94 105 106 /* Read the chunk header (length + type name). 107 * Put the type name into png_ptr->chunk_name, and return the length. 108 */ 109 png_uint_32 /* PRIVATE */ 110 png_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 95 135 /* Read data, and (optionally) run it through the CRC. */ 96 136 void /* PRIVATE */ 97 137 png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length) 98 138 { 99 if(png_ptr == NULL) return; 139 if (png_ptr == NULL) 140 return; 100 141 png_read_data(png_ptr, buf, length); 101 142 png_calculate_crc(png_ptr, buf, length); … … 103 144 104 145 /* 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 */ 108 150 int /* PRIVATE */ 109 151 png_crc_finish(png_structp png_ptr, png_uint_32 skip) … … 124 166 { 125 167 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)) || 127 169 (!(png_ptr->chunk_name[0] & 0x20) && /* Critical */ 128 170 (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE))) … … 141 183 142 184 /* 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 */ 144 187 int /* PRIVATE */ 145 188 png_crc_error(png_structp png_ptr) … … 181 224 * trailing part (the malloc area passed in is freed). 182 225 */ 183 png_charp/* PRIVATE */226 void /* PRIVATE */ 184 227 png_decompress_chunk(png_structp png_ptr, int comp_type, 185 png_ charp chunkdata, png_size_t chunklength,228 png_size_t chunklength, 186 229 png_size_t prefix_size, png_size_t *newlength) 187 230 { … … 193 236 { 194 237 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); 196 239 png_ptr->zstream.avail_in = (uInt)(chunklength - prefix_size); 197 240 png_ptr->zstream.next_out = png_ptr->zbuf; … … 219 262 if (text == NULL) 220 263 { 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"); 223 267 } 224 png_memcpy(text, chunkdata, prefix_size);268 png_memcpy(text, png_ptr->chunkdata, prefix_size); 225 269 } 226 270 … … 228 272 229 273 /* 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); 233 278 png_memcpy(text + prefix_size, msg, text_size); 234 279 break; … … 242 287 text = (png_charp)png_malloc_warn(png_ptr, text_size + 1); 243 288 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 } 248 295 png_memcpy(text + prefix_size, png_ptr->zbuf, 249 296 text_size - prefix_size); 250 png_memcpy(text, chunkdata, prefix_size);297 png_memcpy(text, png_ptr->chunkdata, prefix_size); 251 298 *(text + text_size) = 0x00; 252 299 } … … 262 309 { 263 310 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.."); 266 315 } 267 316 png_memcpy(text, tmp, text_size); … … 290 339 "Buffer error in compressed datastream in %s chunk", 291 340 png_ptr->chunk_name); 341 292 342 else if (ret == Z_DATA_ERROR) 293 343 png_snprintf(umsg, 52, 294 344 "Data error in compressed datastream in %s chunk", 295 345 png_ptr->chunk_name); 346 296 347 else 297 348 png_snprintf(umsg, 52, 298 349 "Incomplete compressed datastream in %s chunk", 299 350 png_ptr->chunk_name); 351 300 352 png_warning(png_ptr, umsg); 301 353 #else … … 303 355 "Incomplete compressed datastream in chunk other than IDAT"); 304 356 #endif 305 text_size =prefix_size;357 text_size = prefix_size; 306 358 if (text == NULL) 307 359 { … … 309 361 if (text == NULL) 310 362 { 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."); 313 366 } 314 png_memcpy(text, chunkdata, prefix_size);367 png_memcpy(text, png_ptr->chunkdata, prefix_size); 315 368 } 316 369 *(text + text_size) = 0x00; … … 320 373 png_ptr->zstream.avail_in = 0; 321 374 322 png_free(png_ptr, chunkdata);323 chunkdata = text;375 png_free(png_ptr, png_ptr->chunkdata); 376 png_ptr->chunkdata = text; 324 377 *newlength=text_size; 325 378 } … … 329 382 char umsg[50]; 330 383 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); 333 385 png_warning(png_ptr, umsg); 334 386 #else … … 336 388 #endif 337 389 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 */ 347 397 void /* PRIVATE */ 348 398 png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) … … 353 403 int interlace_type; 354 404 355 png_debug(1, "in png_handle_IHDR \n");405 png_debug(1, "in png_handle_IHDR"); 356 406 357 407 if (png_ptr->mode & PNG_HAVE_IHDR) 358 408 png_error(png_ptr, "Out of place IHDR"); 359 409 360 /* check the length */410 /* Check the length */ 361 411 if (length != 13) 362 412 png_error(png_ptr, "Invalid IHDR chunk"); … … 375 425 interlace_type = buf[12]; 376 426 377 /* set internal variables */427 /* Set internal variables */ 378 428 png_ptr->width = width; 379 429 png_ptr->height = height; … … 386 436 png_ptr->compression_type = (png_byte)compression_type; 387 437 388 /* find number of channels */438 /* Find number of channels */ 389 439 switch (png_ptr->color_type) 390 440 { … … 393 443 png_ptr->channels = 1; 394 444 break; 445 395 446 case PNG_COLOR_TYPE_RGB: 396 447 png_ptr->channels = 3; 397 448 break; 449 398 450 case PNG_COLOR_TYPE_GRAY_ALPHA: 399 451 png_ptr->channels = 2; 400 452 break; 453 401 454 case PNG_COLOR_TYPE_RGB_ALPHA: 402 455 png_ptr->channels = 4; … … 404 457 } 405 458 406 /* set up other useful info */459 /* Set up other useful info */ 407 460 png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth * 408 461 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); 413 466 png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, 414 467 color_type, interlace_type, compression_type, filter_type); 415 468 } 416 469 417 /* read and check the palette */470 /* Read and check the palette */ 418 471 void /* PRIVATE */ 419 472 png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) … … 425 478 #endif 426 479 427 png_debug(1, "in png_handle_PLTE \n");480 png_debug(1, "in png_handle_PLTE"); 428 481 429 482 if (!(png_ptr->mode & PNG_HAVE_IHDR)) 430 483 png_error(png_ptr, "Missing IHDR before PLTE"); 484 431 485 else if (png_ptr->mode & PNG_HAVE_IDAT) 432 486 { … … 435 489 return; 436 490 } 491 437 492 else if (png_ptr->mode & PNG_HAVE_PLTE) 438 493 png_error(png_ptr, "Duplicate PLTE chunk"); … … 463 518 return; 464 519 } 520 465 521 else 466 522 { … … 487 543 488 544 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 */ 490 546 palette[i].red = buf[0]; 491 547 palette[i].green = buf[1]; … … 495 551 496 552 /* 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 */ 500 557 #if !defined(PNG_READ_OPT_PLTE_SUPPORTED) 501 558 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) … … 557 614 png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) 558 615 { 559 png_debug(1, "in png_handle_IEND \n");616 png_debug(1, "in png_handle_IEND"); 560 617 561 618 if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT)) … … 572 629 png_crc_finish(png_ptr, length); 573 630 574 info_ptr = info_ptr; /* quiet compiler warnings about unused info_ptr */631 info_ptr = info_ptr; /* Quiet compiler warnings about unused info_ptr */ 575 632 } 576 633 … … 585 642 png_byte buf[4]; 586 643 587 png_debug(1, "in png_handle_gAMA \n");644 png_debug(1, "in png_handle_gAMA"); 588 645 589 646 if (!(png_ptr->mode & PNG_HAVE_IHDR)) … … 622 679 623 680 igamma = (png_fixed_point)png_get_uint_32(buf); 624 /* check for zero gamma */681 /* Check for zero gamma */ 625 682 if (igamma == 0) 626 683 { … … 637 694 "Ignoring incorrect gAMA value when sRGB is also present"); 638 695 #ifndef PNG_NO_CONSOLE_IO 639 fprintf(stderr, "gamma = (%d/100000) \n", (int)igamma);696 fprintf(stderr, "gamma = (%d/100000)", (int)igamma); 640 697 #endif 641 698 return; … … 663 720 png_byte buf[4]; 664 721 665 png_debug(1, "in png_handle_sBIT \n");722 png_debug(1, "in png_handle_sBIT"); 666 723 667 724 buf[0] = buf[1] = buf[2] = buf[3] = 0; … … 726 783 png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) 727 784 { 728 png_byte buf[ 4];785 png_byte buf[32]; 729 786 #ifdef PNG_FLOATING_POINT_SUPPORTED 730 787 float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; … … 735 792 png_uint_32 uint_x, uint_y; 736 793 737 png_debug(1, "in png_handle_cHRM \n");794 png_debug(1, "in png_handle_cHRM"); 738 795 739 796 if (!(png_ptr->mode & PNG_HAVE_IHDR)) … … 767 824 } 768 825 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 770 830 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); 782 832 int_x_white = (png_fixed_point)uint_x; 783 833 int_y_white = (png_fixed_point)uint_y; 784 834 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); 797 837 int_x_red = (png_fixed_point)uint_x; 798 838 int_y_red = (png_fixed_point)uint_y; 799 839 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); 812 842 int_x_green = (png_fixed_point)uint_x; 813 843 int_y_green = (png_fixed_point)uint_y; 814 844 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); 827 847 int_x_blue = (png_fixed_point)uint_x; 828 848 int_y_blue = (png_fixed_point)uint_y; … … 855 875 #ifndef PNG_NO_CONSOLE_IO 856 876 #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", 858 878 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", 860 880 green_x, green_y, blue_x, blue_y); 861 881 #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", 863 883 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", 865 885 int_x_green, int_y_green, int_x_blue, int_y_blue); 866 886 #endif 867 887 #endif /* PNG_NO_CONSOLE_IO */ 868 888 } 869 png_crc_finish(png_ptr, 0);870 889 return; 871 890 } … … 881 900 int_y_green, int_x_blue, int_y_blue); 882 901 #endif 883 if (png_crc_finish(png_ptr, 0))884 return;885 902 } 886 903 #endif … … 893 910 png_byte buf[1]; 894 911 895 png_debug(1, "in png_handle_sRGB \n");912 png_debug(1, "in png_handle_sRGB"); 896 913 897 914 if (!(png_ptr->mode & PNG_HAVE_IHDR)) … … 926 943 927 944 intent = buf[0]; 928 /* check for bad intent */945 /* Check for bad intent */ 929 946 if (intent >= PNG_sRGB_INTENT_LAST) 930 947 { … … 950 967 #ifndef PNG_NO_CONSOLE_IO 951 968 # 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); 953 971 # else 954 972 # 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); 956 974 # endif 957 975 # endif … … 988 1006 /* Note: this does not properly handle chunks that are > 64K under DOS */ 989 1007 { 990 png_charp chunkdata;991 1008 png_byte compression_type; 992 1009 png_bytep pC; … … 996 1013 png_size_t slength, prefix_length, data_length; 997 1014 998 png_debug(1, "in png_handle_iCCP \n");1015 png_debug(1, "in png_handle_iCCP"); 999 1016 1000 1017 if (!(png_ptr->mode & PNG_HAVE_IHDR)) … … 1026 1043 #endif 1027 1044 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); 1029 1047 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); 1031 1049 1032 1050 if (png_crc_finish(png_ptr, skip)) 1033 1051 { 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 */ ; 1042 1061 1043 1062 ++profile; 1044 1063 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; 1050 1071 png_warning(png_ptr, "Malformed iCCP chunk"); 1051 1072 return; 1052 1073 } 1053 1074 1054 /* compression_type should always be zero */1075 /* Compression_type should always be zero */ 1055 1076 compression_type = *profile++; 1056 1077 if (compression_type) 1057 1078 { 1058 1079 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.81080 compression_type = 0x00; /* Reset it to zero (libpng-1.0.6 through 1.0.8 1060 1081 wrote nonzero) */ 1061 1082 } 1062 1083 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); 1066 1087 1067 1088 profile_length = data_length - prefix_length; … … 1069 1090 if ( prefix_length > data_length || profile_length < 4) 1070 1091 { 1071 png_free(png_ptr, chunkdata); 1092 png_free(png_ptr, png_ptr->chunkdata); 1093 png_ptr->chunkdata = NULL; 1072 1094 png_warning(png_ptr, "Profile size field missing from iCCP chunk"); 1073 1095 return; … … 1075 1097 1076 1098 /* 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) 1084 1106 profile_length = profile_size; 1085 1107 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; 1089 1112 png_warning(png_ptr, "Ignoring truncated iCCP profile."); 1090 1113 return; 1091 1114 } 1092 1115 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; 1096 1120 } 1097 1121 #endif /* PNG_READ_iCCP_SUPPORTED */ … … 1102 1126 /* Note: this does not properly handle chunks that are > 64K under DOS */ 1103 1127 { 1104 png_bytep chunkdata;1105 1128 png_bytep entry_start; 1106 1129 png_sPLT_t new_palette; … … 1112 1135 png_size_t slength; 1113 1136 1114 png_debug(1, "in png_handle_sPLT\n"); 1137 png_debug(1, "in png_handle_sPLT"); 1138 1115 1139 1116 1140 if (!(png_ptr->mode & PNG_HAVE_IHDR)) … … 1132 1156 #endif 1133 1157 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); 1135 1160 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); 1137 1162 1138 1163 if (png_crc_finish(png_ptr, skip)) 1139 1164 { 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 */ ; 1148 1174 ++entry_start; 1149 1175 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; 1154 1181 png_warning(png_ptr, "malformed sPLT chunk"); 1155 1182 return; … … 1158 1185 new_palette.depth = *entry_start++; 1159 1186 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 */ 1163 1190 if (data_length % entry_size) 1164 1191 { 1165 png_free(png_ptr, chunkdata); 1192 png_free(png_ptr, png_ptr->chunkdata); 1193 png_ptr->chunkdata = NULL; 1166 1194 png_warning(png_ptr, "sPLT chunk has bad length"); 1167 1195 return; … … 1169 1197 1170 1198 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))) 1173 1201 { 1174 1202 png_warning(png_ptr, "sPLT chunk too long"); … … 1227 1255 #endif 1228 1256 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; 1231 1259 1232 1260 png_set_sPLT(png_ptr, info_ptr, &new_palette, 1); 1233 1261 1234 png_free(png_ptr, chunkdata); 1262 png_free(png_ptr, png_ptr->chunkdata); 1263 png_ptr->chunkdata = NULL; 1235 1264 png_free(png_ptr, new_palette.entries); 1236 1265 } … … 1243 1272 png_byte readbuf[PNG_MAX_PALETTE_LENGTH]; 1244 1273 1245 png_debug(1, "in png_handle_tRNS \n");1274 png_debug(1, "in png_handle_tRNS"); 1246 1275 1247 1276 if (!(png_ptr->mode & PNG_HAVE_IHDR)) … … 1339 1368 png_byte buf[6]; 1340 1369 1341 png_debug(1, "in png_handle_bKGD \n");1370 png_debug(1, "in png_handle_bKGD"); 1342 1371 1343 1372 if (!(png_ptr->mode & PNG_HAVE_IHDR)) … … 1390 1419 if (info_ptr && info_ptr->num_palette) 1391 1420 { 1392 if (buf[0] >info_ptr->num_palette)1421 if (buf[0] >= info_ptr->num_palette) 1393 1422 { 1394 1423 png_warning(png_ptr, "Incorrect bKGD chunk index value"); … … 1428 1457 png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH]; 1429 1458 1430 png_debug(1, "in png_handle_hIST \n");1459 png_debug(1, "in png_handle_hIST"); 1431 1460 1432 1461 if (!(png_ptr->mode & PNG_HAVE_IHDR)) … … 1483 1512 int unit_type; 1484 1513 1485 png_debug(1, "in png_handle_pHYs \n");1514 png_debug(1, "in png_handle_pHYs"); 1486 1515 1487 1516 if (!(png_ptr->mode & PNG_HAVE_IHDR)) … … 1526 1555 int unit_type; 1527 1556 1528 png_debug(1, "in png_handle_oFFs \n");1557 png_debug(1, "in png_handle_oFFs"); 1529 1558 1530 1559 if (!(png_ptr->mode & PNG_HAVE_IHDR)) … … 1562 1591 1563 1592 #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) */ 1565 1594 void /* PRIVATE */ 1566 1595 png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) 1567 1596 { 1568 png_charp purpose;1569 1597 png_int_32 X0, X1; 1570 1598 png_byte type, nparams; … … 1574 1602 int i; 1575 1603 1576 png_debug(1, "in png_handle_pCAL \n");1604 png_debug(1, "in png_handle_pCAL"); 1577 1605 1578 1606 if (!(png_ptr->mode & PNG_HAVE_IHDR)) … … 1591 1619 } 1592 1620 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)", 1594 1622 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) 1597 1626 { 1598 1627 png_warning(png_ptr, "No memory for pCAL purpose."); … … 1600 1629 } 1601 1630 slength = (png_size_t)length; 1602 png_crc_read(png_ptr, (png_bytep)p urpose, slength);1631 png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); 1603 1632 1604 1633 if (png_crc_finish(png_ptr, 0)) 1605 1634 { 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; 1617 1647 1618 1648 /* We need to have at least 12 bytes after the purpose string … … 1621 1651 { 1622 1652 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"); 1628 1659 X0 = png_get_int_32((png_bytep)buf+1); 1629 1660 X1 = png_get_int_32((png_bytep)buf+5); … … 1632 1663 units = buf + 11; 1633 1664 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"); 1635 1666 /* Check that we have the right number of parameters for known 1636 1667 equation types. */ … … 1641 1672 { 1642 1673 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; 1644 1676 return; 1645 1677 } … … 1652 1684 /* Empty loop to move past the units string. */ ; 1653 1685 1654 png_debug(3, "Allocating pCAL parameters array \n");1655 params = (png_charpp)png_malloc_warn(png_ptr, (png_uint_32)(nparams1656 *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))) ; 1657 1689 if (params == NULL) 1658 1690 { 1659 png_free(png_ptr, purpose); 1691 png_free(png_ptr, png_ptr->chunkdata); 1692 png_ptr->chunkdata = NULL; 1660 1693 png_warning(png_ptr, "No memory for pCAL params."); 1661 1694 return; … … 1667 1700 buf++; /* Skip the null string terminator from previous parameter. */ 1668 1701 1669 png_debug1(3, "Reading pCAL parameter %d \n", i);1702 png_debug1(3, "Reading pCAL parameter %d", i); 1670 1703 for (params[i] = buf; buf <= endptr && *buf != 0x00; buf++) 1671 1704 /* Empty loop to move past each parameter string */ ; … … 1675 1708 { 1676 1709 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; 1678 1712 png_free(png_ptr, params); 1679 1713 return; … … 1681 1715 } 1682 1716 1683 png_set_pCAL(png_ptr, info_ptr, p urpose, X0, X1, type, nparams,1717 png_set_pCAL(png_ptr, info_ptr, png_ptr->chunkdata, X0, X1, type, nparams, 1684 1718 units, params); 1685 1719 1686 png_free(png_ptr, purpose); 1720 png_free(png_ptr, png_ptr->chunkdata); 1721 png_ptr->chunkdata = NULL; 1687 1722 png_free(png_ptr, params); 1688 1723 } … … 1690 1725 1691 1726 #if defined(PNG_READ_sCAL_SUPPORTED) 1692 /* read the sCAL chunk */1727 /* Read the sCAL chunk */ 1693 1728 void /* PRIVATE */ 1694 1729 png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) 1695 1730 { 1696 png_charp buffer,ep;1731 png_charp ep; 1697 1732 #ifdef PNG_FLOATING_POINT_SUPPORTED 1698 1733 double width, height; … … 1705 1740 png_size_t slength; 1706 1741 1707 png_debug(1, "in png_handle_sCAL \n");1742 png_debug(1, "in png_handle_sCAL"); 1708 1743 1709 1744 if (!(png_ptr->mode & PNG_HAVE_IHDR)) … … 1722 1757 } 1723 1758 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)", 1725 1760 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 } 1732 1767 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); 1734 1769 1735 1770 if (png_crc_finish(png_ptr, 0)) 1736 1771 { 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 */ 1744 1780 1745 1781 #ifdef PNG_FLOATING_POINT_SUPPORTED … … 1747 1783 if (*vp) 1748 1784 { 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; 1751 1787 } 1752 1788 #else … … 1754 1790 swidth = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); 1755 1791 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 } 1760 1796 png_memcpy(swidth, ep, (png_size_t)png_strlen(ep)); 1761 1797 #endif 1762 1798 #endif 1763 1799 1764 for (ep = buffer; *ep; ep++)1765 /* empty loop */ ;1800 for (ep = png_ptr->chunkdata; *ep; ep++) 1801 /* Empty loop */ ; 1766 1802 ep++; 1767 1803 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"); 1771 1807 #if defined(PNG_FIXED_POINT_SUPPORTED) && \ 1772 1808 !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; 1777 1814 } 1778 1815 … … 1781 1818 if (*vp) 1782 1819 { 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; 1785 1822 } 1786 1823 #else … … 1788 1825 sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); 1789 1826 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 } 1794 1831 png_memcpy(sheight, ep, (png_size_t)png_strlen(ep)); 1795 1832 #endif 1796 1833 #endif 1797 1834 1798 if ( buffer+ slength < ep1835 if (png_ptr->chunkdata + slength < ep 1799 1836 #ifdef PNG_FLOATING_POINT_SUPPORTED 1800 1837 || width <= 0. || height <= 0. … … 1803 1840 { 1804 1841 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; 1806 1844 #if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) 1807 1845 png_free(png_ptr, swidth); … … 1813 1851 1814 1852 #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); 1816 1854 #else 1817 1855 #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; 1823 1862 #if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) 1824 1863 png_free(png_ptr, swidth); … … 1835 1874 png_time mod_time; 1836 1875 1837 png_debug(1, "in png_handle_tIME \n");1876 png_debug(1, "in png_handle_tIME"); 1838 1877 1839 1878 if (!(png_ptr->mode & PNG_HAVE_IHDR)) … … 1883 1922 int ret; 1884 1923 1885 png_debug(1, "in png_handle_tEXt\n"); 1924 png_debug(1, "in png_handle_tEXt"); 1925 1886 1926 1887 1927 if (!(png_ptr->mode & PNG_HAVE_IHDR)) … … 1900 1940 #endif 1901 1941 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) 1904 1946 { 1905 1947 png_warning(png_ptr, "No memory to process text chunk."); … … 1907 1949 } 1908 1950 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); 1910 1952 1911 1953 if (png_crc_finish(png_ptr, skip)) 1912 1954 { 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; 1916 1961 1917 1962 key[slength] = 0x00; 1918 1963 1919 1964 for (text = key; *text; text++) 1920 /* empty loop to find end of key */ ;1965 /* Empty loop to find end of key */ ; 1921 1966 1922 1967 if (text != key + slength) … … 1928 1973 { 1929 1974 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; 1931 1977 return; 1932 1978 } … … 1941 1987 text_ptr->text_length = png_strlen(text); 1942 1988 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; 1946 1993 png_free(png_ptr, text_ptr); 1947 1994 if (ret) … … 1951 1998 1952 1999 #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 */ 1954 2001 void /* PRIVATE */ 1955 2002 png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) 1956 2003 { 1957 2004 png_textp text_ptr; 1958 png_charp chunkdata;1959 2005 png_charp text; 1960 2006 int comp_type; … … 1962 2008 png_size_t slength, prefix_len, data_len; 1963 2009 1964 png_debug(1, "in png_handle_zTXt\n"); 2010 png_debug(1, "in png_handle_zTXt"); 2011 2012 1965 2013 if (!(png_ptr->mode & PNG_HAVE_IHDR)) 1966 2014 png_error(png_ptr, "Missing IHDR before zTXt"); … … 1974 2022 if (length > (png_uint_32)65535L) 1975 2023 { 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"); 1977 2025 png_crc_finish(png_ptr, length); 1978 2026 return; … … 1980 2028 #endif 1981 2029 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."); 1986 2035 return; 1987 2036 } 1988 2037 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); 1990 2039 if (png_crc_finish(png_ptr, 0)) 1991 2040 { 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 */ ; 2000 2050 2001 2051 /* zTXt must have some text after the chunkdataword */ 2002 if (text >= chunkdata + slength - 2)2052 if (text >= png_ptr->chunkdata + slength - 2) 2003 2053 { 2004 2054 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; 2006 2057 return; 2007 2058 } … … 2014 2065 comp_type = PNG_TEXT_COMPRESSION_zTXt; 2015 2066 } 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); 2022 2073 2023 2074 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)); 2025 2076 if (text_ptr == NULL) 2026 2077 { 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; 2029 2081 return; 2030 2082 } 2031 2083 text_ptr->compression = comp_type; 2032 text_ptr->key = chunkdata;2084 text_ptr->key = png_ptr->chunkdata; 2033 2085 #ifdef PNG_iTXt_SUPPORTED 2034 2086 text_ptr->lang = NULL; … … 2036 2088 text_ptr->itxt_length = 0; 2037 2089 #endif 2038 text_ptr->text = chunkdata + prefix_len;2090 text_ptr->text = png_ptr->chunkdata + prefix_len; 2039 2091 text_ptr->text_length = data_len; 2040 2092 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); 2042 2094 2043 2095 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; 2045 2098 if (ret) 2046 2099 png_error(png_ptr, "Insufficient memory to store zTXt chunk."); … … 2049 2102 2050 2103 #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 */ 2052 2105 void /* PRIVATE */ 2053 2106 png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) 2054 2107 { 2055 2108 png_textp text_ptr; 2056 png_charp chunkdata;2057 2109 png_charp key, lang, text, lang_key; 2058 2110 int comp_flag; … … 2061 2113 png_size_t slength, prefix_len, data_len; 2062 2114 2063 png_debug(1, "in png_handle_iTXt\n"); 2115 png_debug(1, "in png_handle_iTXt"); 2116 2064 2117 2065 2118 if (!(png_ptr->mode & PNG_HAVE_IHDR)) … … 2074 2127 if (length > (png_uint_32)65535L) 2075 2128 { 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"); 2077 2130 png_crc_finish(png_ptr, length); 2078 2131 return; … … 2080 2133 #endif 2081 2134 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) 2084 2138 { 2085 2139 png_warning(png_ptr, "No memory to process iTXt chunk."); … … 2087 2141 } 2088 2142 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); 2090 2144 if (png_crc_finish(png_ptr, 0)) 2091 2145 { 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 */ 2101 2156 2102 2157 /* 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) 2107 2163 { 2108 2164 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; 2110 2167 return; 2111 2168 } … … 2117 2174 2118 2175 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) 2123 2180 { 2124 2181 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; 2126 2184 return; 2127 2185 } 2128 2186 2129 2187 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) 2133 2191 { 2134 2192 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; 2142 2201 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); 2145 2204 else 2146 data_len =png_strlen(chunkdata + prefix_len);2205 data_len = png_strlen(png_ptr->chunkdata + prefix_len); 2147 2206 text_ptr = (png_textp)png_malloc_warn(png_ptr, 2148 2207 (png_uint_32)png_sizeof(png_text)); 2149 2208 if (text_ptr == NULL) 2150 2209 { 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; 2153 2213 return; 2154 2214 } 2155 2215 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); 2158 2218 text_ptr->itxt_length = data_len; 2159 2219 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); 2164 2224 2165 2225 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; 2167 2228 if (ret) 2168 2229 png_error(png_ptr, "Insufficient memory to store iTXt chunk."); … … 2180 2241 png_uint_32 skip = 0; 2181 2242 2182 png_debug(1, "in png_handle_unknown\n"); 2243 png_debug(1, "in png_handle_unknown"); 2244 2183 2245 2184 2246 if (png_ptr->mode & PNG_HAVE_IDAT) … … 2187 2249 PNG_CONST PNG_IDAT; 2188 2250 #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 */ 2190 2252 png_ptr->mode |= PNG_AFTER_IDAT; 2191 2253 } 2192 2254 2193 png_check_chunk_name(png_ptr, png_ptr->chunk_name);2194 2195 2255 if (!(png_ptr->chunk_name[0] & 0x20)) 2196 2256 { 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) != 2199 2259 PNG_HANDLE_CHUNK_ALWAYS 2200 2260 #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) … … 2207 2267 2208 2268 #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 ) 2211 2274 { 2212 2275 #ifdef PNG_MAX_MALLOC_64K … … 2219 2282 #endif 2220 2283 png_memcpy((png_charp)png_ptr->unknown_chunk.name, 2221 (png_charp)png_ptr->chunk_name, 2284 (png_charp)png_ptr->chunk_name, 2222 2285 png_sizeof(png_ptr->unknown_chunk.name)); 2223 2286 png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name)-1] = '\0'; … … 2231 2294 } 2232 2295 #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) 2234 2297 { 2235 /* callback to user unknown chunk handler */2298 /* Callback to user unknown chunk handler */ 2236 2299 int ret; 2237 2300 ret = (*(png_ptr->read_user_chunk_fn)) … … 2242 2305 { 2243 2306 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) != 2245 2309 PNG_HANDLE_CHUNK_ALWAYS) 2310 #endif 2246 2311 png_chunk_error(png_ptr, "unknown critical chunk"); 2247 2312 png_set_unknown_chunks(png_ptr, info_ptr, … … 2262 2327 2263 2328 #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 */ 2265 2330 #endif 2266 2331 } … … 2277 2342 png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name) 2278 2343 { 2279 png_debug(1, "in png_check_chunk_name \n");2344 png_debug(1, "in png_check_chunk_name"); 2280 2345 if (isnonalpha(chunk_name[0]) || isnonalpha(chunk_name[1]) || 2281 2346 isnonalpha(chunk_name[2]) || isnonalpha(chunk_name[3])) … … 2299 2364 png_combine_row(png_structp png_ptr, png_bytep row, int mask) 2300 2365 { 2301 png_debug(1, "in png_combine_row\n");2366 png_debug(1, "in png_combine_row"); 2302 2367 if (mask == 0xff) 2303 2368 { … … 2510 2575 png_uint_32 transformations = png_ptr->transformations; 2511 2576 #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 */ 2514 2579 PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; 2515 2580 #endif 2516 2581 2517 png_debug(1, "in png_do_read_interlace\n");2582 png_debug(1, "in png_do_read_interlace"); 2518 2583 if (row != NULL && row_info != NULL) 2519 2584 { … … 2716 2781 } 2717 2782 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); 2719 2784 } 2720 2785 #if !defined(PNG_READ_PACKSWAP_SUPPORTED) 2721 transformations = transformations; /* silence compiler warning */2786 transformations = transformations; /* Silence compiler warning */ 2722 2787 #endif 2723 2788 } … … 2728 2793 png_bytep prev_row, int filter) 2729 2794 { 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); 2732 2797 switch (filter) 2733 2798 { … … 2803 2868 } 2804 2869 2805 for (i = 0; i < istop; i++) /* use leftover rp,pp */2870 for (i = 0; i < istop; i++) /* Use leftover rp,pp */ 2806 2871 { 2807 2872 int a, b, c, pa, pb, pc, p; … … 2833 2898 */ 2834 2899 2835 p = (pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c;2900 p = (pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c; 2836 2901 2837 2902 *rp = (png_byte)(((int)(*rp) + p) & 0xff); … … 2842 2907 default: 2843 2908 png_warning(png_ptr, "Ignoring bad adaptive filter type"); 2844 *row =0;2909 *row = 0; 2845 2910 break; 2846 2911 } 2847 2912 } 2848 2913 2914 #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED 2849 2915 void /* PRIVATE */ 2850 2916 png_read_finish_row(png_structp png_ptr) … … 2852 2918 #ifdef PNG_USE_LOCAL_ARRAYS 2853 2919 #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 */ 2857 2923 PNG_CONST int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; 2858 2924 2859 /* offset to next interlace block */2925 /* Offset to next interlace block */ 2860 2926 PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; 2861 2927 2862 /* start of interlace block in the y direction */2928 /* Start of interlace block in the y direction */ 2863 2929 PNG_CONST int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; 2864 2930 2865 /* offset to next interlace block in the y direction */2931 /* Offset to next interlace block in the y direction */ 2866 2932 PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; 2867 2933 #endif /* PNG_READ_INTERLACING_SUPPORTED */ 2868 2934 #endif 2869 2935 2870 png_debug(1, "in png_read_finish_row \n");2936 png_debug(1, "in png_read_finish_row"); 2871 2937 png_ptr->row_number++; 2872 2938 if (png_ptr->row_number < png_ptr->num_rows) … … 2920 2986 png_ptr->zstream.next_out = (Byte *)&extra; 2921 2987 png_ptr->zstream.avail_out = (uInt)1; 2922 for (;;)2988 for (;;) 2923 2989 { 2924 2990 if (!(png_ptr->zstream.avail_in)) … … 2978 3044 png_ptr->mode |= PNG_AFTER_IDAT; 2979 3045 } 3046 #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ 2980 3047 2981 3048 void /* PRIVATE */ … … 2984 3051 #ifdef PNG_USE_LOCAL_ARRAYS 2985 3052 #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 */ 2989 3056 PNG_CONST int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; 2990 3057 2991 /* offset to next interlace block */3058 /* Offset to next interlace block */ 2992 3059 PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; 2993 3060 2994 /* start of interlace block in the y direction */3061 /* Start of interlace block in the y direction */ 2995 3062 PNG_CONST int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; 2996 3063 2997 /* offset to next interlace block in the y direction */3064 /* Offset to next interlace block in the y direction */ 2998 3065 PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; 2999 3066 #endif … … 3001 3068 3002 3069 int max_pixel_depth; 3003 png_ uint_32row_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"); 3006 3073 png_ptr->zstream.avail_in = 0; 3007 3074 png_init_read_transformations(png_ptr); … … 3020 3087 png_pass_inc[png_ptr->pass]; 3021 3088 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; 3027 3091 } 3028 3092 else … … 3126 3190 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \ 3127 3191 defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) 3128 if (png_ptr->transformations & PNG_USER_TRANSFORM)3192 if (png_ptr->transformations & PNG_USER_TRANSFORM) 3129 3193 { 3130 int user_pixel_depth =png_ptr->user_transform_depth*3194 int user_pixel_depth = png_ptr->user_transform_depth* 3131 3195 png_ptr->user_transform_channels; 3132 if (user_pixel_depth > max_pixel_depth)3196 if (user_pixel_depth > max_pixel_depth) 3133 3197 max_pixel_depth=user_pixel_depth; 3134 3198 } 3135 3199 #endif 3136 3200 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 */ 3139 3204 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) + 3143 3209 1 + ((max_pixel_depth + 7) >> 3); 3144 3210 #ifdef PNG_MAX_MALLOC_64K … … 3147 3213 #endif 3148 3214 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; 3155 3223 } 3156 3224 3157 3225 #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) 3159 3227 png_error(png_ptr, "This image requires a row greater than 64KB"); 3160 3228 #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)) 3162 3230 png_error(png_ptr, "Row has too many bytes to allocate in memory."); 3163 3231 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); 3180 3249 3181 3250 png_ptr->flags |= PNG_FLAG_ROW_INIT; -
trunk/src/3rdparty/libpng/pngset.c
r2 r561 2 2 /* pngset.c - storage of image information into info struct 3 3 * 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 7 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 7 * (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 9 12 * 10 13 * The functions here are used during reads to store data from the file … … 16 19 #define PNG_INTERNAL 17 20 #include "png.h" 18 19 21 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 20 22 … … 23 25 png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) 24 26 { 25 png_debug1(1, "in %s storage function\n", "bKGD"); 27 png_debug1(1, "in %s storage function", "bKGD"); 28 26 29 if (png_ptr == NULL || info_ptr == NULL) 27 30 return; … … 39 42 double green_x, double green_y, double blue_x, double blue_y) 40 43 { 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; 69 48 70 49 info_ptr->x_white = (float)white_x; … … 88 67 info_ptr->valid |= PNG_INFO_cHRM; 89 68 } 90 #endif 69 #endif /* PNG_FLOATING_POINT_SUPPORTED */ 70 91 71 #ifdef PNG_FIXED_POINT_SUPPORTED 92 72 void PNGAPI … … 96 76 png_fixed_point blue_x, png_fixed_point blue_y) 97 77 { 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 */ 153 111 154 112 #if defined(PNG_gAMA_SUPPORTED) … … 157 115 png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) 158 116 { 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 161 121 if (png_ptr == NULL || info_ptr == NULL) 162 122 return; … … 166 126 { 167 127 png_warning(png_ptr, "Limiting gamma to 21474.83"); 168 gamma=21474.83;128 png_gamma=21474.83; 169 129 } 170 130 else 171 gamma=file_gamma;172 info_ptr->gamma = (float) gamma;131 png_gamma = file_gamma; 132 info_ptr->gamma = (float)png_gamma; 173 133 #ifdef PNG_FIXED_POINT_SUPPORTED 174 info_ptr->int_gamma = (int)( gamma*100000.+.5);134 info_ptr->int_gamma = (int)(png_gamma*100000.+.5); 175 135 #endif 176 136 info_ptr->valid |= PNG_INFO_gAMA; 177 if (gamma == 0.0)137 if (png_gamma == 0.0) 178 138 png_warning(png_ptr, "Setting gamma=0"); 179 139 } … … 183 143 int_gamma) 184 144 { 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; 195 156 } 196 157 else 197 158 { 198 if (int_gamma < 0)199 {200 png_warning(png_ptr, "Setting negative gamma to zero");201 gamma=0;202 }203 else204 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; 205 166 } 206 167 #ifdef PNG_FLOATING_POINT_SUPPORTED 207 info_ptr->gamma = (float)( gamma/100000.);168 info_ptr->gamma = (float)(png_gamma/100000.); 208 169 #endif 209 170 #ifdef PNG_FIXED_POINT_SUPPORTED 210 info_ptr->int_gamma = gamma;171 info_ptr->int_gamma = png_gamma; 211 172 #endif 212 173 info_ptr->valid |= PNG_INFO_gAMA; 213 if (gamma == 0)174 if (png_gamma == 0) 214 175 png_warning(png_ptr, "Setting gamma=0"); 215 176 } … … 222 183 int i; 223 184 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 227 190 if (info_ptr->num_palette == 0 || info_ptr->num_palette 228 191 > PNG_MAX_PALETTE_LENGTH) 229 192 { 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; 233 196 } 234 197 … … 236 199 png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); 237 200 #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 */ 240 204 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))); 242 206 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 } 247 211 248 212 for (i = 0; i < info_ptr->num_palette; i++) 249 png_ptr->hist[i] = hist[i];213 png_ptr->hist[i] = hist[i]; 250 214 info_ptr->hist = png_ptr->hist; 251 215 info_ptr->valid |= PNG_INFO_hIST; … … 265 229 int filter_type) 266 230 { 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 */ 272 237 if (width == 0 || height == 0) 273 238 png_error(png_ptr, "Image width or height is zero in IHDR"); … … 289 254 png_warning(png_ptr, "Width is too large for libpng to process pixels"); 290 255 291 /* check other values */256 /* Check other values */ 292 257 if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && 293 bit_depth != 8 && bit_depth != 16)258 bit_depth != 8 && bit_depth != 16) 294 259 png_error(png_ptr, "Invalid bit depth in IHDR"); 295 260 296 261 if (color_type < 0 || color_type == 1 || 297 color_type == 5 || color_type > 6)262 color_type == 5 || color_type > 6) 298 263 png_error(png_ptr, "Invalid color type in IHDR"); 299 264 … … 320 285 * 5. The color_type is RGB or RGBA 321 286 */ 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 || 330 295 color_type == PNG_COLOR_TYPE_RGB_ALPHA))) 331 296 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) 333 298 png_warning(png_ptr, "Invalid filter method in IHDR"); 334 299 } 335 300 #else 336 if (filter_type != PNG_FILTER_TYPE_BASE)301 if (filter_type != PNG_FILTER_TYPE_BASE) 337 302 png_error(png_ptr, "Unknown filter method in IHDR"); 338 303 #endif … … 355 320 info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); 356 321 357 /* check for potential overflow */322 /* Check for potential overflow */ 358 323 if (width > (PNG_UINT_32_MAX 359 324 >> 3) /* 8-byte RGBA pixels */ … … 364 329 info_ptr->rowbytes = (png_size_t)0; 365 330 else 366 info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);331 info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width); 367 332 } 368 333 … … 372 337 png_int_32 offset_x, png_int_32 offset_y, int unit_type) 373 338 { 374 png_debug1(1, "in %s storage function\n", "oFFs"); 339 png_debug1(1, "in %s storage function", "oFFs"); 340 375 341 if (png_ptr == NULL || info_ptr == NULL) 376 342 return; … … 392 358 int i; 393 359 394 png_debug1(1, "in %s storage function\n", "pCAL"); 360 png_debug1(1, "in %s storage function", "pCAL"); 361 395 362 if (png_ptr == NULL || info_ptr == NULL) 396 363 return; 397 364 398 365 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); 400 368 info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); 401 369 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 } 406 374 png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length); 407 375 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"); 409 377 info_ptr->pcal_X0 = X0; 410 378 info_ptr->pcal_X1 = X1; … … 413 381 414 382 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); 416 385 info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length); 417 386 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 } 422 391 png_memcpy(info_ptr->pcal_units, units, (png_size_t)length); 423 392 … … 425 394 (png_uint_32)((nparams + 1) * png_sizeof(png_charp))); 426 395 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)); 433 402 434 403 for (i = 0; i < nparams; i++) 435 404 { 436 405 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); 438 408 info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length); 439 409 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 } 444 414 png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length); 445 415 } … … 458 428 int unit, double width, double height) 459 429 { 460 png_debug1(1, "in %s storage function\n", "sCAL"); 430 png_debug1(1, "in %s storage function", "sCAL"); 431 461 432 if (png_ptr == NULL || info_ptr == NULL) 462 433 return; … … 476 447 png_uint_32 length; 477 448 478 png_debug1(1, "in %s storage function\n", "sCAL"); 449 png_debug1(1, "in %s storage function", "sCAL"); 450 479 451 if (png_ptr == NULL || info_ptr == NULL) 480 452 return; … … 483 455 484 456 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); 486 459 info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length); 487 460 if (info_ptr->scal_s_width == NULL) … … 494 467 495 468 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); 497 471 info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length); 498 472 if (info_ptr->scal_s_height == NULL) 499 473 { 500 474 png_free (png_ptr, info_ptr->scal_s_width); 475 info_ptr->scal_s_width = NULL; 501 476 png_warning(png_ptr, 502 477 "Memory allocation failed while processing sCAL."); … … 518 493 png_uint_32 res_x, png_uint_32 res_y, int unit_type) 519 494 { 520 png_debug1(1, "in %s storage function\n", "pHYs"); 495 png_debug1(1, "in %s storage function", "pHYs"); 496 521 497 if (png_ptr == NULL || info_ptr == NULL) 522 498 return; … … 534 510 { 535 511 536 png_debug1(1, "in %s storage function\n", "PLTE"); 512 png_debug1(1, "in %s storage function", "PLTE"); 513 537 514 if (png_ptr == NULL || info_ptr == NULL) 538 515 return; 539 516 540 517 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) 543 520 png_error(png_ptr, "Invalid palette length"); 544 else545 {521 else 522 { 546 523 png_warning(png_ptr, "Invalid palette length"); 547 524 return; 548 }549 }525 } 526 } 550 527 551 528 /* … … 559 536 560 537 /* 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 */ 563 541 png_ptr->palette = (png_colorp)png_malloc(png_ptr, 564 542 PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)); 565 543 png_memset(png_ptr->palette, 0, PNG_MAX_PALETTE_LENGTH * 566 544 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)); 568 546 info_ptr->palette = png_ptr->palette; 569 547 info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; … … 583 561 png_color_8p sig_bit) 584 562 { 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)); 590 569 info_ptr->valid |= PNG_INFO_sBIT; 591 570 } … … 596 575 png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent) 597 576 { 598 png_debug1(1, "in %s storage function\n", "sRGB"); 577 png_debug1(1, "in %s storage function", "sRGB"); 578 599 579 if (png_ptr == NULL || info_ptr == NULL) 600 580 return; … … 620 600 float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; 621 601 #endif 622 #ifdef PNG_FIXED_POINT_SUPPORTED623 602 png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, 624 603 int_green_y, int_blue_x, int_blue_y; 625 604 #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 628 607 if (png_ptr == NULL || info_ptr == NULL) 629 608 return; … … 643 622 644 623 #if defined(PNG_cHRM_SUPPORTED) 645 #ifdef PNG_FIXED_POINT_SUPPORTED646 624 int_white_x = 31270L; 647 625 int_white_y = 32900L; … … 653 631 int_blue_y = 6000L; 654 632 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 #endif659 633 #ifdef PNG_FLOATING_POINT_SUPPORTED 660 634 white_x = (float).3127; … … 666 640 blue_x = (float).15; 667 641 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 */ 675 663 676 664 … … 685 673 png_uint_32 length; 686 674 687 png_debug1(1, "in %s storage function\n", "iCCP"); 675 png_debug1(1, "in %s storage function", "iCCP"); 676 688 677 if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL) 689 678 return; … … 701 690 { 702 691 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."); 704 694 return; 705 695 } … … 724 714 void PNGAPI 725 715 png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, 726 int num_text)716 int num_text) 727 717 { 728 718 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); 730 720 if (ret) 731 png_error(png_ptr, "Insufficient memory to store text");721 png_error(png_ptr, "Insufficient memory to store text"); 732 722 } 733 723 734 724 int /* PRIVATE */ 735 725 png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, 736 int num_text)726 int num_text) 737 727 { 738 728 int i; 739 729 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') ? 741 732 "text" : (png_const_charp)png_ptr->chunk_name)); 742 733 … … 758 749 old_text = info_ptr->text; 759 750 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))); 761 752 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 } 766 757 png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max * 767 758 png_sizeof(png_text))); … … 773 764 info_ptr->num_text = 0; 774 765 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))); 776 767 if (info_ptr->text == NULL) 777 return(1);768 return(1); 778 769 #ifdef PNG_FREE_ME_SUPPORTED 779 770 info_ptr->free_me |= PNG_FREE_TEXT; 780 771 #endif 781 772 } 782 png_debug1(3, "allocated %d entries for info_ptr->text \n",773 png_debug1(3, "allocated %d entries for info_ptr->text", 783 774 info_ptr->max_text); 784 775 } 785 776 for (i = 0; i < num_text; i++) 786 777 { 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; 789 780 png_textp textp = &(info_ptr->text[info_ptr->num_text]); 790 781 … … 794 785 key_len = png_strlen(text_ptr[i].key); 795 786 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; 800 791 } 801 792 else 802 793 #ifdef PNG_iTXt_SUPPORTED 803 794 { 804 /* set iTXt data */805 if (text_ptr[i].lang != NULL)806 lang_len = png_strlen(text_ptr[i].lang);807 else808 lang_len = 0;809 if (text_ptr[i].lang_key != NULL)810 lang_key_len = png_strlen(text_ptr[i].lang_key);811 else812 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; 813 804 } 814 805 #else 815 806 { 816 png_warning(png_ptr, "iTXt chunk not supported.");817 continue;807 png_warning(png_ptr, "iTXt chunk not supported."); 808 continue; 818 809 } 819 810 #endif … … 823 814 text_length = 0; 824 815 #ifdef PNG_iTXt_SUPPORTED 825 if (text_ptr[i].compression > 0)816 if (text_ptr[i].compression > 0) 826 817 textp->compression = PNG_ITXT_COMPRESSION_NONE; 827 818 else … … 836 827 837 828 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)); 839 831 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'; 848 840 #ifdef PNG_iTXt_SUPPORTED 849 841 if (text_ptr[i].compression > 0) 850 842 { 851 textp->lang =textp->key + key_len + 1;843 textp->lang = textp->key + key_len + 1; 852 844 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; 855 847 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; 858 850 } 859 851 else … … 864 856 textp->lang_key=NULL; 865 857 #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) 869 861 png_memcpy(textp->text, text_ptr[i].text, 870 862 (png_size_t)(text_length)); 871 *(textp->text +text_length) = '\0';863 *(textp->text + text_length) = '\0'; 872 864 873 865 #ifdef PNG_iTXt_SUPPORTED 874 if (textp->compression > 0)866 if (textp->compression > 0) 875 867 { 876 868 textp->text_length = 0; … … 886 878 } 887 879 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); 889 881 } 890 882 return(0); … … 896 888 png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time) 897 889 { 898 png_debug1(1, "in %s storage function\n", "tIME"); 890 png_debug1(1, "in %s storage function", "tIME"); 891 899 892 if (png_ptr == NULL || info_ptr == NULL || 900 893 (png_ptr->mode & PNG_WROTE_tIME)) 901 894 return; 902 895 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)); 904 897 info_ptr->valid |= PNG_INFO_tIME; 905 898 } … … 911 904 png_bytep trans, int num_trans, png_color_16p trans_values) 912 905 { 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; 918 910 919 911 if (trans != NULL) … … 925 917 */ 926 918 919 #ifdef PNG_FREE_ME_SUPPORTED 920 png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); 921 #endif 922 927 923 /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ 928 924 png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr, 929 925 (png_uint_32)PNG_MAX_PALETTE_LENGTH); 930 926 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); 932 928 } 933 929 … … 941 937 (int)trans_values->green > sample_max || 942 938 (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"); 945 941 png_memcpy(&(info_ptr->trans_values), trans_values, 946 942 png_sizeof(png_color_16)); 947 943 if (num_trans == 0) 948 num_trans = 1;944 num_trans = 1; 949 945 } 950 946 … … 966 962 png_set_sPLT(png_structp png_ptr, 967 963 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 { 979 983 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; 995 999 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; 1022 1026 #ifdef PNG_FREE_ME_SUPPORTED 1023 info_ptr->free_me |= PNG_FREE_SPLT;1027 info_ptr->free_me |= PNG_FREE_SPLT; 1024 1028 #endif 1025 1029 } 1026 1030 #endif /* PNG_sPLT_SUPPORTED */ 1027 1031 1028 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)1032 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED 1029 1033 void PNGAPI 1030 1034 png_set_unknown_chunks(png_structp png_ptr, 1031 1035 png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns) 1032 1036 { 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; 1085 1090 #ifdef PNG_FREE_ME_SUPPORTED 1086 info_ptr->free_me |= PNG_FREE_UNKN;1091 info_ptr->free_me |= PNG_FREE_UNKN; 1087 1092 #endif 1088 1093 } … … 1091 1096 int chunk, int location) 1092 1097 { 1093 if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk <1098 if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk < 1094 1099 (int)info_ptr->unknown_chunks_num) 1095 1100 info_ptr->unknown_chunks[chunk].location = (png_byte)location; … … 1105 1110 /* This function is deprecated in favor of png_permit_mng_features() 1106 1111 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 1108 1115 if (png_ptr == NULL) 1109 1116 return; … … 1119 1126 png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features) 1120 1127 { 1121 png_debug(1, "in png_permit_mng_features\n"); 1128 png_debug(1, "in png_permit_mng_features"); 1129 1122 1130 if (png_ptr == NULL) 1123 1131 return (png_uint_32)0; … … 1133 1141 chunk_list, int num_chunks) 1134 1142 { 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; 1143 1151 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; 1148 1156 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; 1170 1179 #ifdef PNG_FREE_ME_SUPPORTED 1171 png_ptr->free_me |= PNG_FREE_LIST;1180 png_ptr->free_me |= PNG_FREE_LIST; 1172 1181 #endif 1173 1182 } … … 1179 1188 png_user_chunk_ptr read_user_chunk_fn) 1180 1189 { 1181 png_debug(1, "in png_set_read_user_chunk_fn\n"); 1190 png_debug(1, "in png_set_read_user_chunk_fn"); 1191 1182 1192 if (png_ptr == NULL) 1183 1193 return; 1194 1184 1195 png_ptr->read_user_chunk_fn = read_user_chunk_fn; 1185 1196 png_ptr->user_chunk_ptr = user_chunk_ptr; … … 1191 1202 png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) 1192 1203 { 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)) 1199 1210 png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); 1200 1211 info_ptr->row_pointers = row_pointers; 1201 if (row_pointers)1212 if (row_pointers) 1202 1213 info_ptr->valid |= PNG_INFO_IDAT; 1203 1214 } … … 1206 1217 #ifdef PNG_WRITE_SUPPORTED 1207 1218 void PNGAPI 1208 png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size) 1219 png_set_compression_buffer_size(png_structp png_ptr, 1220 png_uint_32 size) 1209 1221 { 1210 1222 if (png_ptr == NULL) … … 1228 1240 #ifndef PNG_1_0_X 1229 1241 #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 */ 1231 1243 void PNGAPI 1232 1244 png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags) … … 1235 1247 if (png_ptr != NULL) 1236 1248 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 */ 1240 1253 void PNGAPI 1241 1254 png_set_mmx_thresholds (png_structp png_ptr, … … 1246 1259 if (png_ptr == NULL) 1247 1260 return; 1261 /* Quiet the compiler */ 1262 mmx_bitdepth_threshold = mmx_bitdepth_threshold; 1263 mmx_rowbytes_threshold = mmx_rowbytes_threshold; 1248 1264 } 1249 1265 #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ 1250 1266 1251 1267 #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 */ 1253 1269 void PNGAPI 1254 1270 png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max, 1255 1271 png_uint_32 user_height_max) 1256 1272 { 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; 1264 1281 } 1265 1282 #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ -
trunk/src/3rdparty/libpng/pngtest.c
r2 r561 2 2 /* pngtest.c - a simple test program to test libpng 3 3 * 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 7 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 7 * (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 9 12 * 10 13 * This program reads in a PNG image, writes it out again, and then … … 38 41 # include <stdlib.h> 39 42 # define READFILE(file, data, length, check) \ 40 if (ReadFile(file, data, length, &check, NULL)) check = 043 if (ReadFile(file, data, length, &check, NULL)) check = 0 41 44 # define WRITEFILE(file, data, length, check)) \ 42 45 if (WriteFile(file, data, length, &check, NULL)) check = 0 … … 46 49 # include <stdlib.h> 47 50 # 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) 49 52 # 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) 51 54 # define FCLOSE(file) fclose(file) 52 55 #endif … … 66 69 67 70 #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 */ 69 72 #endif 70 73 … … 83 86 84 87 #if defined(PNG_TIME_RFC1123_SUPPORTED) 85 #define PNG_tIME_STRING_LENGTH 3086 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 89 static int tIME_chunk_present = 0; 90 static char tIME_string[PNG_tIME_STRING_LENGTH] = "tIME chunk is not present"; 88 91 #endif 89 92 … … 96 99 #endif 97 100 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 */ 99 102 /* #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 */ 106 104 107 105 /* In case a system header (e.g., on AIX) defined jmpbuf */ … … 114 112 # define png_jmpbuf(png_ptr) png_ptr->jmpbuf 115 113 #endif 114 115 /* Example of using row callbacks to make a simple progress meter */ 116 static int status_pass = 1; 117 static int status_dots_requested = 0; 118 static int status_dots = 1; 116 119 117 120 void … … 126 129 read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) 127 130 { 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"); 142 146 } 143 147 … … 153 157 write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) 154 158 { 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"); 157 162 } 158 163 … … 160 165 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) 161 166 /* 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 */ 164 170 static png_uint_32 filters_used[256]; 165 171 void … … 174 180 count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data) 175 181 { 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)]; 178 184 } 179 185 #endif 180 186 181 187 #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 */ 184 191 185 192 static png_uint_32 zero_samples; … … 197 204 { 198 205 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: 202 209 * png_uint_32 width width of row 203 210 * png_uint_32 rowbytes number of bytes in row … … 208 215 */ 209 216 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) 214 220 { 215 int pos =0;221 int pos = 0; 216 222 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++) 218 224 { 219 if (row_info->bit_depth == 1)225 if (row_info->bit_depth == 1) 220 226 { 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) 223 230 { 224 231 pos = 0; … … 226 233 } 227 234 } 228 if (row_info->bit_depth == 2)235 if (row_info->bit_depth == 2) 229 236 { 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) 232 240 { 233 241 pos = 0; … … 235 243 } 236 244 } 237 if (row_info->bit_depth == 4)245 if (row_info->bit_depth == 4) 238 246 { 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) 241 250 { 242 251 pos = 0; … … 244 253 } 245 254 } 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) 249 259 { 250 if((*dp | *(dp+1)) == 0) zero_samples++; 260 if ((*dp | *(dp+1)) == 0) 261 zero_samples++; 251 262 dp+=2; 252 263 } 253 264 } 254 265 } 255 else /* other color types */266 else /* Other color types */ 256 267 { 257 268 png_uint_32 n, nstop; 258 269 int channel; 259 270 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++) 263 274 { 264 275 for (channel = 0; channel < color_channels; channel++) 265 276 { 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) 269 281 { 270 if((*dp | *(dp+1)) == 0) zero_samples++; 282 if ((*dp | *(dp+1)) == 0) 283 zero_samples++; 271 284 dp+=2; 272 285 } 273 286 } 274 if (row_info->color_type > 3)287 if (row_info->color_type > 3) 275 288 { 276 289 dp++; 277 if(row_info->bit_depth == 16)dp++; 290 if (row_info->bit_depth == 16) 291 dp++; 278 292 } 279 293 } … … 286 300 #if defined(PNG_NO_STDIO) 287 301 /* 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 */ 294 309 295 310 #ifndef USE_FAR_KEYWORD … … 310 325 } 311 326 #else 312 /* this is the model-independent version. Since the standard I/O library327 /* This is the model-independent version. Since the standard I/O library 313 328 can't handle far buffers in the medium and small models, we have to copy 314 329 the data. … … 342 357 read = MIN(NEAR_BUF_SIZE, remaining); 343 358 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) 346 361 break; 347 362 else … … 353 368 } 354 369 if (check != length) 355 {356 370 png_error(png_ptr, "read Error"); 357 }358 371 } 359 372 #endif /* USE_FAR_KEYWORD */ … … 363 376 pngtest_flush(png_structp png_ptr) 364 377 { 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 */ 371 380 } 372 381 #endif 373 382 374 383 /* 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 */ 378 388 #ifndef USE_FAR_KEYWORD 379 389 static void … … 389 399 } 390 400 #else 391 /* this is the model-independent version. Since the standard I/O library401 /* This is the model-independent version. Since the standard I/O library 392 402 can't handle far buffers in the medium and small models, we have to copy 393 403 the data. … … 420 430 { 421 431 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 */ 423 433 WRITEFILE(io_ptr, buf, written, err); 424 434 if (err != written) … … 437 447 } 438 448 #endif /* USE_FAR_KEYWORD */ 439 #endif /* PNG_NO_STDIO */440 /* END of code to validate stdio-free compilation */441 449 442 450 /* This function is called when there is a warning, but the library thinks … … 464 472 pngtest_warning(png_ptr, message); 465 473 /* 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 */ 467 476 } 477 #endif /* PNG_NO_STDIO */ 478 /* END of code to validate stdio-free compilation */ 468 479 469 480 /* START of code to validate memory allocation and deallocation */ … … 471 482 472 483 /* 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 */ 480 492 typedef struct memory_information 481 493 { … … 500 512 501 513 /* 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 */ 503 516 504 517 if (size == 0) … … 512 525 png_set_mem_fn(png_ptr, NULL, NULL, NULL); 513 526 pinfo = (memory_infop)png_malloc(png_ptr, 514 (png_uint_32)png_sizeof (*pinfo));527 (png_uint_32)png_sizeof(*pinfo)); 515 528 pinfo->size = size; 516 529 current_allocation += size; … … 521 534 pinfo->pointer = (png_voidp)png_malloc(png_ptr, size); 522 535 /* 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); 525 539 if (size != 0 && pinfo->pointer == NULL) 526 540 { … … 534 548 /* Make sure the caller isn't assuming zeroed memory. */ 535 549 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); 539 553 return (png_voidp)(pinfo->pointer); 540 554 } … … 571 585 png_memset(ptr, 0x55, pinfo->size); 572 586 png_free_default(png_ptr, pinfo); 573 pinfo =NULL;587 pinfo = NULL; 574 588 break; 575 589 } … … 584 598 585 599 /* Finally free the data. */ 586 if (verbose)587 printf("Freeing %x\n", ptr);600 if (verbose) 601 printf("Freeing %x\n", ptr); 588 602 png_free_default(png_ptr, ptr); 589 ptr =NULL;603 ptr = NULL; 590 604 } 591 605 #endif /* PNG_USER_MEM_SUPPORTED && PNG_DEBUG */ 592 606 /* 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 613 chunk used in ImageMagick to store "virtual page" size). */ 614 615 static 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 623 static 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 */ 593 675 594 676 /* Test one file */ … … 650 732 } 651 733 652 png_debug(0, "Allocating read and write structures \n");734 png_debug(0, "Allocating read and write structures"); 653 735 #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, 655 738 png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL, 656 739 (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); 657 740 #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, 659 743 png_error_ptr_NULL, png_error_ptr_NULL); 660 744 #endif 745 #if defined(PNG_NO_STDIO) 661 746 png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error, 662 747 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 663 759 #ifdef PNG_WRITE_SUPPORTED 664 760 #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, 666 763 png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL, 667 764 (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); 668 765 #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, 670 768 png_error_ptr_NULL, png_error_ptr_NULL); 671 769 #endif 770 #if defined(PNG_NO_STDIO) 672 771 png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error, 673 772 pngtest_warning); 674 773 #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"); 676 776 read_info_ptr = png_create_info_struct(read_ptr); 677 777 end_info_ptr = png_create_info_struct(read_ptr); … … 682 782 683 783 #ifdef PNG_SETJMP_SUPPORTED 684 png_debug(0, "Setting jmpbuf for read struct \n");784 png_debug(0, "Setting jmpbuf for read struct"); 685 785 #ifdef USE_FAR_KEYWORD 686 786 if (setjmp(jmpbuf)) … … 691 791 fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname); 692 792 png_free(read_ptr, row_buf); 793 row_buf = NULL; 693 794 png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); 694 795 #ifdef PNG_WRITE_SUPPORTED … … 701 802 } 702 803 #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)); 704 805 #endif 705 806 706 807 #ifdef PNG_WRITE_SUPPORTED 707 png_debug(0, "Setting jmpbuf for write struct \n");808 png_debug(0, "Setting jmpbuf for write struct"); 708 809 #ifdef USE_FAR_KEYWORD 709 810 if (setjmp(jmpbuf)) … … 723 824 } 724 825 #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"); 731 832 #if !defined(PNG_NO_STDIO) 732 833 png_init_io(read_ptr, fpin); … … 745 846 # endif 746 847 #endif 747 if (status_dots_requested == 1)848 if (status_dots_requested == 1) 748 849 { 749 850 #ifdef PNG_WRITE_SUPPORTED … … 762 863 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) 763 864 { 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); 768 869 } 769 870 #endif 770 871 #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) 771 zero_samples =0;872 zero_samples = 0; 772 873 png_set_write_user_transform_fn(write_ptr, count_zero_samples); 773 874 #endif … … 788 889 #endif 789 890 790 png_debug(0, "Reading info struct \n");891 png_debug(0, "Reading info struct"); 791 892 png_read_info(read_ptr, read_info_ptr); 792 893 793 png_debug(0, "Transferring info struct \n");894 png_debug(0, "Transferring info struct"); 794 895 { 795 896 int interlace_type, compression_type, filter_type; … … 824 925 825 926 if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma)) 826 {827 927 png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma); 828 }829 928 } 830 929 #endif … … 848 947 849 948 if (png_get_gAMA(read_ptr, read_info_ptr, &gamma)) 850 {851 949 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 */ 857 954 #if defined(PNG_iCCP_SUPPORTED) 858 955 { … … 875 972 876 973 if (png_get_sRGB(read_ptr, read_info_ptr, &intent)) 877 {878 974 png_set_sRGB(write_ptr, write_info_ptr, intent); 879 }880 975 } 881 976 #endif … … 885 980 886 981 if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette)) 887 {888 982 png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette); 889 }890 983 } 891 984 #if defined(PNG_bKGD_SUPPORTED) … … 904 997 905 998 if (png_get_hIST(read_ptr, read_info_ptr, &hist)) 906 {907 999 png_set_hIST(write_ptr, write_info_ptr, hist); 908 }909 1000 } 910 1001 #endif … … 914 1005 int unit_type; 915 1006 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)) 917 1009 { 918 1010 png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type); … … 941 1033 942 1034 if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, &unit_type)) 943 {944 1035 png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type); 945 }946 1036 } 947 1037 #endif … … 951 1041 952 1042 if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit)) 953 {954 1043 png_set_sBIT(write_ptr, write_info_ptr, sig_bit); 955 }956 1044 } 957 1045 #endif … … 990 1078 if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0) 991 1079 { 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); 993 1081 png_set_text(write_ptr, write_info_ptr, text_ptr, num_text); 994 1082 } … … 1003 1091 png_set_tIME(write_ptr, write_info_ptr, mod_time); 1004 1092 #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 */ 1008 1097 png_memcpy(tIME_string, 1009 png_convert_to_rfc1123(read_ptr, mod_time), 1098 png_convert_to_rfc1123(read_ptr, mod_time), 1010 1099 png_sizeof(tIME_string)); 1011 tIME_string[png_sizeof(tIME_string) -1] = '\0';1100 tIME_string[png_sizeof(tIME_string) - 1] = '\0'; 1012 1101 tIME_chunk_present++; 1013 1102 #endif /* PNG_TIME_RFC1123_SUPPORTED */ … … 1027 1116 /* libpng doesn't reject a tRNS chunk with out-of-range samples */ 1028 1117 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); 1036 1125 } 1037 1126 } … … 1047 1136 png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns, 1048 1137 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 */ 1052 1142 for (i = 0; i < (png_size_t)num_unknowns; i++) 1053 1143 png_set_unknown_chunk_location(write_ptr, write_info_ptr, i, … … 1058 1148 1059 1149 #ifdef PNG_WRITE_SUPPORTED 1060 png_debug(0, " \nWriting info struct\n");1150 png_debug(0, "Writing info struct"); 1061 1151 1062 1152 /* 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); 1064 1154 */ 1065 1155 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 1066 1190 #endif 1067 1191 1068 1192 #ifdef SINGLE_ROWBUF_ALLOC 1069 png_debug(0, " \nAllocating row buffer...");1193 png_debug(0, "Allocating row buffer..."); 1070 1194 row_buf = (png_bytep)png_malloc(read_ptr, 1071 1195 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); 1073 1197 #endif /* SINGLE_ROWBUF_ALLOC */ 1074 png_debug(0, "Writing row data \n");1198 png_debug(0, "Writing row data"); 1075 1199 1076 1200 #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ … … 1081 1205 # endif 1082 1206 #else 1083 num_pass =1;1207 num_pass = 1; 1084 1208 #endif 1085 1209 … … 1091 1215 for (pass = 0; pass < num_pass; pass++) 1092 1216 { 1093 png_debug1(0, "Writing row data for pass %d \n",pass);1217 png_debug1(0, "Writing row data for pass %d", pass); 1094 1218 for (y = 0; y < height; y++) 1095 1219 { 1096 1220 #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); 1098 1222 row_buf = (png_bytep)png_malloc(read_ptr, 1099 1223 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, 1101 1225 png_get_rowbytes(read_ptr, read_info_ptr)); 1102 1226 #endif /* !SINGLE_ROWBUF_ALLOC */ … … 1118 1242 1119 1243 #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); 1121 1245 png_free(read_ptr, row_buf); 1246 row_buf = NULL; 1122 1247 #endif /* !SINGLE_ROWBUF_ALLOC */ 1123 1248 } … … 1131 1256 #endif 1132 1257 1133 png_debug(0, "Reading and writing end_info data \n");1258 png_debug(0, "Reading and writing end_info data"); 1134 1259 1135 1260 png_read_end(read_ptr, end_info_ptr); … … 1141 1266 if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0) 1142 1267 { 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); 1144 1269 png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text); 1145 1270 } … … 1154 1279 png_set_tIME(write_ptr, write_end_info_ptr, mod_time); 1155 1280 #if defined(PNG_TIME_RFC1123_SUPPORTED) 1156 /* we have to use png_memcpy instead of "=" because the string1281 /* We have to use png_memcpy instead of "=" because the string 1157 1282 pointed to by png_convert_to_rfc1123() gets free'ed before 1158 1283 we use it */ … … 1160 1285 png_convert_to_rfc1123(read_ptr, mod_time), 1161 1286 png_sizeof(tIME_string)); 1162 tIME_string[png_sizeof(tIME_string) -1] = '\0';1287 tIME_string[png_sizeof(tIME_string) - 1] = '\0'; 1163 1288 tIME_chunk_present++; 1164 1289 #endif /* PNG_TIME_RFC1123_SUPPORTED */ … … 1177 1302 png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns, 1178 1303 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 */ 1182 1308 for (i = 0; i < (png_size_t)num_unknowns; i++) 1183 1309 png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i, … … 1191 1317 1192 1318 #ifdef PNG_EASY_ACCESS_SUPPORTED 1193 if (verbose)1319 if (verbose) 1194 1320 { 1195 1321 png_uint_32 iwidth, iheight; 1196 1322 iwidth = png_get_image_width(write_ptr, write_info_ptr); 1197 1323 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", 1199 1325 (unsigned long)iwidth, (unsigned long)iheight); 1200 1326 } 1201 1327 #endif 1202 1328 1203 png_debug(0, "Destroying data structs \n");1329 png_debug(0, "Destroying data structs"); 1204 1330 #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"); 1206 1332 png_free(read_ptr, row_buf); 1207 row_buf =NULL;1333 row_buf = NULL; 1208 1334 #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"); 1210 1336 png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); 1211 1337 #ifdef PNG_WRITE_SUPPORTED 1212 png_debug(1, "destroying write_end_info_ptr \n");1338 png_debug(1, "destroying write_end_info_ptr"); 1213 1339 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"); 1215 1341 png_destroy_write_struct(&write_ptr, &write_info_ptr); 1216 1342 #endif 1217 png_debug(0, "Destruction complete. \n");1343 png_debug(0, "Destruction complete."); 1218 1344 1219 1345 FCLOSE(fpin); 1220 1346 FCLOSE(fpout); 1221 1347 1222 png_debug(0, "Opening files for comparison \n");1348 png_debug(0, "Opening files for comparison"); 1223 1349 #if defined(_WIN32_WCE) 1224 1350 MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); … … 1244 1370 } 1245 1371 1246 for (;;)1372 for (;;) 1247 1373 { 1248 1374 png_size_t num_in, num_out; 1249 1375 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); 1252 1378 1253 1379 if (num_in != num_out) … … 1255 1381 fprintf(STDERR, "\nFiles %s and %s are of a different size\n", 1256 1382 inname, outname); 1257 if (wrote_question == 0)1383 if (wrote_question == 0) 1258 1384 { 1259 1385 fprintf(STDERR, 1260 1386 " Was %s written with the same maximum IDAT chunk size (%d bytes),", 1261 inname, PNG_ZBUF_SIZE);1387 inname, PNG_ZBUF_SIZE); 1262 1388 fprintf(STDERR, 1263 1389 "\n filtering heuristic (libpng default), compression"); … … 1265 1391 " level (zlib default),\n and zlib version (%s)?\n\n", 1266 1392 ZLIB_VERSION); 1267 wrote_question =1;1393 wrote_question = 1; 1268 1394 } 1269 1395 FCLOSE(fpin); … … 1278 1404 { 1279 1405 fprintf(STDERR, "\nFiles %s and %s are different\n", inname, outname); 1280 if (wrote_question == 0)1406 if (wrote_question == 0) 1281 1407 { 1282 1408 fprintf(STDERR, 1283 1409 " Was %s written with the same maximum IDAT chunk size (%d bytes),", 1284 inname, PNG_ZBUF_SIZE);1410 inname, PNG_ZBUF_SIZE); 1285 1411 fprintf(STDERR, 1286 1412 "\n filtering heuristic (libpng default), compression"); … … 1288 1414 " level (zlib default),\n and zlib version (%s)?\n\n", 1289 1415 ZLIB_VERSION); 1290 wrote_question =1;1416 wrote_question = 1; 1291 1417 } 1292 1418 FCLOSE(fpin); … … 1302 1428 } 1303 1429 1304 /* input and output filenames */1430 /* Input and output filenames */ 1305 1431 #ifdef RISCOS 1306 1432 static PNG_CONST char *inname = "pngtest/png"; … … 1317 1443 int ierror = 0; 1318 1444 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); 1320 1446 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)); 1322 1448 /* Show the version of libpng used in building the library */ 1323 fprintf(STDERR, " library (%lu):%s",1449 fprintf(STDERR, " library (%lu):%s", 1324 1450 (unsigned long)png_access_version_number(), 1325 1451 png_get_header_version(NULL)); 1326 1452 /* 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, 1328 1454 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", 1330 1456 (long)png_sizeof(png_struct), (long)png_sizeof(png_info)); 1331 1457 1332 1458 /* 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 */ 1336 1463 #if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) 1337 1464 fprintf(STDERR, " NOTE: Zlib compiled for max 64k, libpng not\n"); … … 1378 1505 } 1379 1506 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)) 1384 1511 { 1385 1512 fprintf(STDERR, … … 1405 1532 #endif 1406 1533 int kerror; 1407 fprintf(STDERR, " Testing %s:",argv[i]);1534 fprintf(STDERR, "\n Testing %s:", argv[i]); 1408 1535 kerror = test_one_file(argv[i], outname); 1409 1536 if (kerror == 0) … … 1416 1543 #endif 1417 1544 #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]) 1420 1547 fprintf(STDERR, " Filter %d was used %lu times\n", 1421 k, (unsigned long)filters_used[k]);1548 k, (unsigned long)filters_used[k]); 1422 1549 #endif 1423 1550 #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); 1426 1553 tIME_chunk_present = 0; 1427 1554 #endif /* PNG_TIME_RFC1123_SUPPORTED */ … … 1435 1562 if (allocation_now != current_allocation) 1436 1563 fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n", 1437 current_allocation -allocation_now);1564 current_allocation - allocation_now); 1438 1565 if (current_allocation != 0) 1439 1566 { … … 1444 1571 while (pinfo != NULL) 1445 1572 { 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, 1447 1575 (unsigned int) pinfo->pointer); 1448 1576 pinfo = pinfo->next; … … 1465 1593 { 1466 1594 int i; 1467 for (i =0; i<3; ++i)1595 for (i = 0; i<3; ++i) 1468 1596 { 1469 1597 int kerror; … … 1472 1600 #endif 1473 1601 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; 1475 1603 if (i == 0 || verbose == 1 || ierror != 0) 1476 fprintf(STDERR, " Testing %s:",inname);1604 fprintf(STDERR, "\n Testing %s:", inname); 1477 1605 kerror = test_one_file(inname, outname); 1478 if (kerror == 0)1606 if (kerror == 0) 1479 1607 { 1480 if (verbose == 1 || i == 2)1608 if (verbose == 1 || i == 2) 1481 1609 { 1482 1610 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) … … 1490 1618 #endif 1491 1619 #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]) 1494 1622 fprintf(STDERR, " Filter %d was used %lu times\n", 1495 k,(unsigned long)filters_used[k]); 1623 k, 1624 (unsigned long)filters_used[k]); 1496 1625 #endif 1497 1626 #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); 1500 1629 #endif /* PNG_TIME_RFC1123_SUPPORTED */ 1501 1630 } … … 1503 1632 else 1504 1633 { 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); 1507 1636 fprintf(STDERR, " FAIL\n"); 1508 1637 ierror += kerror; … … 1511 1640 if (allocation_now != current_allocation) 1512 1641 fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n", 1513 current_allocation -allocation_now);1642 current_allocation - allocation_now); 1514 1643 if (current_allocation != 0) 1515 1644 { … … 1520 1649 while (pinfo != NULL) 1521 1650 { 1522 fprintf(STDERR, " %lu bytes at %x\n",1651 fprintf(STDERR, " %lu bytes at %x\n", 1523 1652 (unsigned long)pinfo->size, (unsigned int)pinfo->pointer); 1524 1653 pinfo = pinfo->next; … … 1543 1672 t_misc += (t_stop - t_start); 1544 1673 t_start = t_stop; 1545 fprintf(STDERR, " CPU time used = %.3f seconds",1674 fprintf(STDERR, " CPU time used = %.3f seconds", 1546 1675 (t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC); 1547 fprintf(STDERR, " (decoding %.3f,\n",1676 fprintf(STDERR, " (decoding %.3f,\n", 1548 1677 t_decode/(float)CLOCKS_PER_SEC); 1549 fprintf(STDERR, " encoding %.3f ,",1678 fprintf(STDERR, " encoding %.3f ,", 1550 1679 t_encode/(float)CLOCKS_PER_SEC); 1551 fprintf(STDERR, " other %.3f seconds)\n\n",1680 fprintf(STDERR, " other %.3f seconds)\n\n", 1552 1681 t_misc/(float)CLOCKS_PER_SEC); 1553 1682 #endif 1554 1683 1555 1684 if (ierror == 0) 1556 fprintf(STDERR, " libpng passes test\n");1685 fprintf(STDERR, " libpng passes test\n"); 1557 1686 else 1558 fprintf(STDERR, " libpng FAILS test\n");1687 fprintf(STDERR, " libpng FAILS test\n"); 1559 1688 return (int)(ierror != 0); 1560 1689 } 1561 1690 1562 1691 /* 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;1692 typedef version_1_2_40 your_png_h_is_not_version_1_2_40; -
trunk/src/3rdparty/libpng/pngtrans.c
r2 r561 2 2 /* pngtrans.c - transforms the data in a row (used by both readers and writers) 3 3 * 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 7 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 7 * (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 9 12 */ 10 13 11 14 #define PNG_INTERNAL 12 15 #include "png.h" 13 14 16 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 17 15 18 #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 */ 17 20 void PNGAPI 18 21 png_set_bgr(png_structp png_ptr) 19 22 { 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; 22 26 png_ptr->transformations |= PNG_BGR; 23 27 } … … 25 29 26 30 #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 */ 28 32 void PNGAPI 29 33 png_set_swap(png_structp png_ptr) 30 34 { 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; 33 38 if (png_ptr->bit_depth == 16) 34 39 png_ptr->transformations |= PNG_SWAP_BYTES; … … 37 42 38 43 #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) 39 /* turn on pixel packing */44 /* Turn on pixel packing */ 40 45 void PNGAPI 41 46 png_set_packing(png_structp png_ptr) 42 47 { 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; 45 51 if (png_ptr->bit_depth < 8) 46 52 { … … 52 58 53 59 #if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) 54 /* turn on packed pixel swapping */60 /* Turn on packed pixel swapping */ 55 61 void PNGAPI 56 62 png_set_packswap(png_structp png_ptr) 57 63 { 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; 60 67 if (png_ptr->bit_depth < 8) 61 68 png_ptr->transformations |= PNG_PACKSWAP; … … 67 74 png_set_shift(png_structp png_ptr, png_color_8p true_bits) 68 75 { 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; 71 79 png_ptr->transformations |= PNG_SHIFT; 72 80 png_ptr->shift = *true_bits; … … 79 87 png_set_interlace_handling(png_structp png_ptr) 80 88 { 81 png_debug(1, "in png_set_interlace handling \n");89 png_debug(1, "in png_set_interlace handling"); 82 90 if (png_ptr && png_ptr->interlaced) 83 91 { … … 99 107 png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) 100 108 { 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; 103 112 png_ptr->transformations |= PNG_FILLER; 104 113 png_ptr->filler = (png_byte)filler; … … 132 141 png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc) 133 142 { 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; 136 146 png_set_filler(png_ptr, filler, filler_loc); 137 147 png_ptr->transformations |= PNG_ADD_ALPHA; … … 146 156 png_set_swap_alpha(png_structp png_ptr) 147 157 { 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; 150 161 png_ptr->transformations |= PNG_SWAP_ALPHA; 151 162 } … … 157 168 png_set_invert_alpha(png_structp png_ptr) 158 169 { 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; 161 173 png_ptr->transformations |= PNG_INVERT_ALPHA; 162 174 } … … 167 179 png_set_invert_mono(png_structp png_ptr) 168 180 { 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; 171 184 png_ptr->transformations |= PNG_INVERT_MONO; 172 185 } 173 186 174 /* invert monochrome grayscale data */187 /* Invert monochrome grayscale data */ 175 188 void /* PRIVATE */ 176 189 png_do_invert(png_row_infop row_info, png_bytep row) 177 190 { 178 png_debug(1, "in png_do_invert \n");191 png_debug(1, "in png_do_invert"); 179 192 /* This test removed from libpng version 1.0.13 and 1.2.0: 180 193 * if (row_info->bit_depth == 1 && … … 227 240 228 241 #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 */ 230 243 void /* PRIVATE */ 231 244 png_do_swap(png_row_infop row_info, png_bytep row) 232 245 { 233 png_debug(1, "in png_do_swap \n");246 png_debug(1, "in png_do_swap"); 234 247 if ( 235 248 #if defined(PNG_USELESS_TESTS_SUPPORTED) … … 358 371 }; 359 372 360 /* swaps pixel packing order within bytes */373 /* Swaps pixel packing order within bytes */ 361 374 void /* PRIVATE */ 362 375 png_do_packswap(png_row_infop row_info, png_bytep row) 363 376 { 364 png_debug(1, "in png_do_packswap \n");377 png_debug(1, "in png_do_packswap"); 365 378 if ( 366 379 #if defined(PNG_USELESS_TESTS_SUPPORTED) … … 390 403 #if defined(PNG_WRITE_FILLER_SUPPORTED) || \ 391 404 defined(PNG_READ_STRIP_ALPHA_SUPPORTED) 392 /* remove filler or alpha byte(s) */405 /* Remove filler or alpha byte(s) */ 393 406 void /* PRIVATE */ 394 407 png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) 395 408 { 396 png_debug(1, "in png_do_strip_filler \n");409 png_debug(1, "in png_do_strip_filler"); 397 410 #if defined(PNG_USELESS_TESTS_SUPPORTED) 398 411 if (row != NULL && row_info != NULL) … … 405 418 406 419 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) 410 423 { 411 424 if (row_info->bit_depth == 8) … … 548 561 549 562 #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 */ 551 564 void /* PRIVATE */ 552 565 png_do_bgr(png_row_infop row_info, png_bytep row) 553 566 { 554 png_debug(1, "in png_do_bgr \n");567 png_debug(1, "in png_do_bgr"); 555 568 if ( 556 569 #if defined(PNG_USELESS_TESTS_SUPPORTED) … … 625 638 626 639 #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) 629 642 void PNGAPI 630 643 png_set_user_transform_info(png_structp png_ptr, png_voidp 631 644 user_transform_ptr, int user_transform_depth, int user_transform_channels) 632 645 { 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; 635 649 #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) 636 650 png_ptr->user_transform_ptr = user_transform_ptr; … … 638 652 png_ptr->user_transform_channels = (png_byte)user_transform_channels; 639 653 #else 640 if (user_transform_ptr || user_transform_depth || user_transform_channels)654 if (user_transform_ptr || user_transform_depth || user_transform_channels) 641 655 png_warning(png_ptr, 642 656 "This version of libpng does not support user transform info"); … … 653 667 png_get_user_transform_ptr(png_structp png_ptr) 654 668 { 669 if (png_ptr == NULL) 670 return (NULL); 655 671 #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) 656 if (png_ptr == NULL) return (NULL);657 672 return ((png_voidp)png_ptr->user_transform_ptr); 658 673 #else -
trunk/src/3rdparty/libpng/pngwio.c
r2 r561 2 2 /* pngwio.c - functions for data output 3 3 * 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 7 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 7 * (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 9 12 * 10 13 * This file provides a location for all output. Users who need … … 21 24 22 25 /* 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 */ 27 31 28 32 void /* PRIVATE */ … … 37 41 #if !defined(PNG_NO_STDIO) 38 42 /* 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 */ 42 47 #ifndef USE_FAR_KEYWORD 43 48 void PNGAPI … … 46 51 png_uint_32 check; 47 52 48 if(png_ptr == NULL) return; 53 if (png_ptr == NULL) 54 return; 49 55 #if defined(_WIN32_WCE) 50 56 if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) … … 57 63 } 58 64 #else 59 /* this is the model-independent version. Since the standard I/O library60 can't handle far buffers in the medium and small models, we have to copy61 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 */ 63 69 64 70 #define NEAR_BUF_SIZE 1024 … … 72 78 png_FILE_p io_ptr; 73 79 74 if(png_ptr == NULL) return; 80 if (png_ptr == NULL) 81 return; 75 82 /* Check if data really is near. If so, use usual code. */ 76 83 near_data = (png_byte *)CVT_PTR_NOCHECK(data); … … 94 101 { 95 102 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 */ 97 104 #if defined(_WIN32_WCE) 98 105 if ( !WriteFile(io_ptr, buf, written, &err, NULL) ) … … 103 110 if (err != written) 104 111 break; 112 105 113 else 106 114 check += err; 115 107 116 data += written; 108 117 remaining -= written; … … 118 127 119 128 /* 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 */ 122 132 #if defined(PNG_WRITE_FLUSH_SUPPORTED) 123 133 void /* PRIVATE */ … … 135 145 png_FILE_p io_ptr; 136 146 #endif 137 if(png_ptr == NULL) return; 147 if (png_ptr == NULL) 148 return; 138 149 #if !defined(_WIN32_WCE) 139 150 io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); 140 if (io_ptr != NULL) 141 fflush(io_ptr); 151 fflush(io_ptr); 142 152 #endif 143 153 } … … 146 156 147 157 /* 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 */ 169 186 void PNGAPI 170 187 png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, 171 188 png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) 172 189 { 173 if(png_ptr == NULL) return; 190 if (png_ptr == NULL) 191 return; 192 174 193 png_ptr->io_ptr = io_ptr; 175 194 … … 177 196 if (write_data_fn != NULL) 178 197 png_ptr->write_data_fn = write_data_fn; 198 179 199 else 180 200 png_ptr->write_data_fn = png_default_write_data; … … 187 207 if (output_flush_fn != NULL) 188 208 png_ptr->output_flush_fn = output_flush_fn; 209 189 210 else 190 211 png_ptr->output_flush_fn = png_default_flush; … … 207 228 #if defined(USE_FAR_KEYWORD) 208 229 #if defined(_MSC_VER) 209 void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)230 void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check) 210 231 { 211 232 void *near_ptr; … … 213 234 FP_OFF(near_ptr) = FP_OFF(ptr); 214 235 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 218 241 return(near_ptr); 219 242 } 220 243 # else 221 void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)244 void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check) 222 245 { 223 246 void *near_ptr; … … 225 248 near_ptr = (void FAR *)ptr; 226 249 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 230 255 return(near_ptr); 231 256 } -
trunk/src/3rdparty/libpng/pngwrite.c
r2 r561 2 2 /* pngwrite.c - general routines to write a PNG file 3 3 * 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 7 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 7 * (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 9 12 */ 10 13 11 /* get internal access to png.h */14 /* Get internal access to png.h */ 12 15 #define PNG_INTERNAL 13 16 #include "png.h" … … 26 29 png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr) 27 30 { 28 png_debug(1, "in png_write_info_before_PLTE \n");31 png_debug(1, "in png_write_info_before_PLTE"); 29 32 if (png_ptr == NULL || info_ptr == NULL) 30 33 return; 31 34 if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) 32 35 { 33 png_write_sig(png_ptr); /* write PNG signature */36 png_write_sig(png_ptr); /* Write PNG signature */ 34 37 #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"); 38 41 png_ptr->mng_features_permitted=0; 39 42 } 40 43 #endif 41 /* write IHDR information. */44 /* Write IHDR information. */ 42 45 png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height, 43 46 info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type, … … 48 51 0); 49 52 #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 */ 52 56 #if defined(PNG_WRITE_gAMA_SUPPORTED) 53 57 if (info_ptr->valid & PNG_INFO_gAMA) … … 98 102 if (info_ptr->unknown_chunks_num) 99 103 { 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 { 108 112 int keep=png_handle_as_unknown(png_ptr, up->name); 109 113 if (keep != PNG_HANDLE_CHUNK_NEVER && … … 117 121 png_write_chunk(png_ptr, up->name, up->data, up->size); 118 122 } 119 }123 } 120 124 } 121 125 #endif … … 131 135 #endif 132 136 133 png_debug(1, "in png_write_info \n");137 png_debug(1, "in png_write_info"); 134 138 135 139 if (png_ptr == NULL || info_ptr == NULL) … … 146 150 #if defined(PNG_WRITE_tRNS_SUPPORTED) 147 151 if (info_ptr->valid & PNG_INFO_tRNS) 148 {152 { 149 153 #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 } 158 162 #endif 159 163 png_write_tRNS(png_ptr, info_ptr->trans, &(info_ptr->trans_values), 160 164 info_ptr->num_trans, info_ptr->color_type); 161 }165 } 162 166 #endif 163 167 #if defined(PNG_WRITE_bKGD_SUPPORTED) … … 180 184 info_ptr->pcal_units, info_ptr->pcal_params); 181 185 #endif 186 187 #if defined(PNG_sCAL_SUPPORTED) 188 if (info_ptr->valid & PNG_INFO_sCAL) 182 189 #if defined(PNG_WRITE_sCAL_SUPPORTED) 183 if (info_ptr->valid & PNG_INFO_sCAL)184 190 #if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) 185 191 png_write_sCAL(png_ptr, (int)info_ptr->scal_unit, 186 192 info_ptr->scal_pixel_width, info_ptr->scal_pixel_height); 187 #else 193 #else /* !FLOATING_POINT */ 188 194 #ifdef PNG_FIXED_POINT_SUPPORTED 189 195 png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit, 190 196 info_ptr->scal_s_width, info_ptr->scal_s_height); 191 #else 197 #endif /* FIXED_POINT */ 198 #endif /* FLOATING_POINT */ 199 #else /* !WRITE_sCAL */ 192 200 png_warning(png_ptr, 193 201 "png_write_sCAL not supported; sCAL chunk not written."); 194 #endif 195 #endif 196 #endif 202 #endif /* WRITE_sCAL */ 203 #endif /* sCAL */ 204 197 205 #if defined(PNG_WRITE_pHYs_SUPPORTED) 198 206 if (info_ptr->valid & PNG_INFO_pHYs) 199 207 png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit, 200 208 info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type); 201 #endif 209 #endif /* pHYs */ 210 202 211 #if defined(PNG_WRITE_tIME_SUPPORTED) 203 212 if (info_ptr->valid & PNG_INFO_tIME) … … 206 215 png_ptr->mode |= PNG_WROTE_tIME; 207 216 } 208 #endif 217 #endif /* tIME */ 218 209 219 #if defined(PNG_WRITE_sPLT_SUPPORTED) 210 220 if (info_ptr->valid & PNG_INFO_sPLT) 211 221 for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) 212 222 png_write_sPLT(png_ptr, info_ptr->splt_palettes + i); 213 #endif 223 #endif /* sPLT */ 224 214 225 #if defined(PNG_WRITE_TEXT_SUPPORTED) 215 226 /* Check to see if we need to write text chunks */ 216 227 for (i = 0; i < info_ptr->num_text; i++) 217 228 { 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, 219 230 info_ptr->text[i].compression); 220 /* an internationalized chunk? */231 /* An internationalized chunk? */ 221 232 if (info_ptr->text[i].compression > 0) 222 233 { 223 234 #if defined(PNG_WRITE_iTXt_SUPPORTED) 224 /* write international chunk */235 /* Write international chunk */ 225 236 png_write_iTXt(png_ptr, 226 237 info_ptr->text[i].compression, … … 239 250 { 240 251 #if defined(PNG_WRITE_zTXt_SUPPORTED) 241 /* write compressed chunk */252 /* Write compressed chunk */ 242 253 png_write_zTXt(png_ptr, info_ptr->text[i].key, 243 254 info_ptr->text[i].text, 0, … … 252 263 { 253 264 #if defined(PNG_WRITE_tEXt_SUPPORTED) 254 /* write uncompressed chunk */265 /* Write uncompressed chunk */ 255 266 png_write_tEXt(png_ptr, info_ptr->text[i].key, 256 267 info_ptr->text[i].text, 257 268 0); 258 #else259 png_warning(png_ptr, "Unable to write uncompressed text");260 #endif261 269 /* Mark this chunk as written */ 262 270 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 266 279 #if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) 267 280 if (info_ptr->unknown_chunks_num) … … 269 282 png_unknown_chunk *up; 270 283 271 png_debug(5, "writing extra chunks \n");284 png_debug(5, "writing extra chunks"); 272 285 273 286 for (up = info_ptr->unknown_chunks; … … 297 310 png_write_end(png_structp png_ptr, png_infop info_ptr) 298 311 { 299 png_debug(1, "in png_write_end \n");312 png_debug(1, "in png_write_end"); 300 313 if (png_ptr == NULL) 301 314 return; … … 303 316 png_error(png_ptr, "No IDATs written into file"); 304 317 305 /* see if user wants us to write information chunks */318 /* See if user wants us to write information chunks */ 306 319 if (info_ptr != NULL) 307 320 { 308 321 #if defined(PNG_WRITE_TEXT_SUPPORTED) 309 int i; /* local index variable */322 int i; /* Local index variable */ 310 323 #endif 311 324 #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 */ 313 326 if ((info_ptr->valid & PNG_INFO_tIME) && 314 327 !(png_ptr->mode & PNG_WROTE_tIME)) … … 316 329 #endif 317 330 #if defined(PNG_WRITE_TEXT_SUPPORTED) 318 /* loop through comment chunks */331 /* Loop through comment chunks */ 319 332 for (i = 0; i < info_ptr->num_text; i++) 320 333 { 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, 322 335 info_ptr->text[i].compression); 323 /* an internationalized chunk? */336 /* An internationalized chunk? */ 324 337 if (info_ptr->text[i].compression > 0) 325 338 { 326 339 #if defined(PNG_WRITE_iTXt_SUPPORTED) 327 /* write international chunk */340 /* Write international chunk */ 328 341 png_write_iTXt(png_ptr, 329 342 info_ptr->text[i].compression, … … 341 354 { 342 355 #if defined(PNG_WRITE_zTXt_SUPPORTED) 343 /* write compressed chunk */356 /* Write compressed chunk */ 344 357 png_write_zTXt(png_ptr, info_ptr->text[i].key, 345 358 info_ptr->text[i].text, 0, … … 354 367 { 355 368 #if defined(PNG_WRITE_tEXt_SUPPORTED) 356 /* write uncompressed chunk */369 /* Write uncompressed chunk */ 357 370 png_write_tEXt(png_ptr, info_ptr->text[i].key, 358 371 info_ptr->text[i].text, 0); … … 371 384 png_unknown_chunk *up; 372 385 373 png_debug(5, "writing extra chunks \n");386 png_debug(5, "writing extra chunks"); 374 387 375 388 for (up = info_ptr->unknown_chunks; … … 392 405 png_ptr->mode |= PNG_AFTER_IDAT; 393 406 394 /* write end of PNG file */407 /* Write end of PNG file */ 395 408 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 396 421 } 397 422 … … 402 427 png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime) 403 428 { 404 png_debug(1, "in png_convert_from_struct_tm \n");429 png_debug(1, "in png_convert_from_struct_tm"); 405 430 ptime->year = (png_uint_16)(1900 + ttime->tm_year); 406 431 ptime->month = (png_byte)(ttime->tm_mon + 1); … … 416 441 struct tm *tbuf; 417 442 418 png_debug(1, "in png_convert_from_time_t \n");443 png_debug(1, "in png_convert_from_time_t"); 419 444 tbuf = gmtime(&ttime); 420 445 png_convert_from_struct_tm(ptime, tbuf); … … 440 465 { 441 466 #endif /* PNG_USER_MEM_SUPPORTED */ 442 png_structp png_ptr; 467 #ifdef PNG_SETJMP_SUPPORTED 468 volatile 469 #endif 470 png_structp png_ptr; 443 471 #ifdef PNG_SETJMP_SUPPORTED 444 472 #ifdef USE_FAR_KEYWORD … … 447 475 #endif 448 476 int i; 449 png_debug(1, "in png_create_write_struct \n");477 png_debug(1, "in png_create_write_struct"); 450 478 #ifdef PNG_USER_MEM_SUPPORTED 451 479 png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, … … 457 485 return (NULL); 458 486 459 /* added at libpng-1.2.6 */487 /* Added at libpng-1.2.6 */ 460 488 #ifdef PNG_SET_USER_LIMITS_SUPPORTED 461 489 png_ptr->user_width_max=PNG_USER_WIDTH_MAX; … … 471 499 { 472 500 png_free(png_ptr, png_ptr->zbuf); 473 png_ptr->zbuf=NULL;501 png_ptr->zbuf=NULL; 474 502 png_destroy_struct(png_ptr); 475 503 return (NULL); 476 504 } 477 505 #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)); 479 507 #endif 480 508 #endif … … 485 513 png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); 486 514 487 if (user_png_ver)515 if (user_png_ver) 488 516 { 489 517 i=0; 490 518 do 491 519 { 492 if (user_png_ver[i] != png_libpng_ver[i])520 if (user_png_ver[i] != png_libpng_ver[i]) 493 521 png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; 494 522 } while (png_libpng_ver[i++]); … … 528 556 } 529 557 530 /* initialize zbuf - compression buffer */558 /* Initialize zbuf - compression buffer */ 531 559 png_ptr->zbuf_size = PNG_ZBUF_SIZE; 532 560 png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, … … 548 576 if (setjmp(jmpbuf)) 549 577 PNG_ABORT(); 550 png_memcpy(png_ptr->jmpbuf, jmpbuf,png_sizeof(jmp_buf));578 png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf)); 551 579 #else 552 580 if (setjmp(png_ptr->jmpbuf)) … … 573 601 { 574 602 /* We only come here via pre-1.0.12-compiled applications */ 575 if (png_ptr == NULL) return;603 if (png_ptr == NULL) return; 576 604 #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 || 578 606 png_sizeof(png_info) > png_info_size) 579 607 { … … 593 621 } 594 622 #endif 595 if (png_sizeof(png_struct) > png_struct_size)623 if (png_sizeof(png_struct) > png_struct_size) 596 624 { 597 625 png_ptr->error_fn=NULL; … … 602 630 "The png struct allocated by the application for writing is too small."); 603 631 } 604 if (png_sizeof(png_info) > png_info_size)632 if (png_sizeof(png_info) > png_info_size) 605 633 { 606 634 png_ptr->error_fn=NULL; … … 622 650 png_structp png_ptr=*ptr_ptr; 623 651 #ifdef PNG_SETJMP_SUPPORTED 624 jmp_buf tmp_jmp; /* to save current jump buffer */652 jmp_buf tmp_jmp; /* To save current jump buffer */ 625 653 #endif 626 654 … … 639 667 png_ptr->warning_fn=NULL; 640 668 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."); 642 670 break; 643 671 #endif … … 645 673 } while (png_libpng_ver[i++]); 646 674 647 png_debug(1, "in png_write_init_3 \n");675 png_debug(1, "in png_write_init_3"); 648 676 649 677 #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)); 652 680 #endif 653 681 … … 659 687 } 660 688 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 */ 665 693 #ifdef PNG_SET_USER_LIMITS_SUPPORTED 666 694 png_ptr->user_width_max=PNG_USER_WIDTH_MAX; … … 669 697 670 698 #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)); 673 701 #endif 674 702 … … 676 704 png_flush_ptr_NULL); 677 705 678 /* initialize zbuf - compression buffer */706 /* Initialize zbuf - compression buffer */ 679 707 png_ptr->zbuf_size = PNG_ZBUF_SIZE; 680 708 png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, … … 696 724 png_uint_32 num_rows) 697 725 { 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 */ 707 735 for (i = 0, rp = row; i < num_rows; i++, rp++) 708 736 { … … 717 745 png_write_image(png_structp png_ptr, png_bytepp image) 718 746 { 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"); 727 755 #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 */ 730 759 num_pass = png_set_interlace_handling(png_ptr); 731 760 #else 732 761 num_pass = 1; 733 762 #endif 734 /* loop through passes */763 /* Loop through passes */ 735 764 for (pass = 0; pass < num_pass; pass++) 736 765 { 737 /* loop through image */766 /* Loop through image */ 738 767 for (i = 0, rp = image; i < png_ptr->height; i++, rp++) 739 768 { … … 743 772 } 744 773 745 /* called by user to write a row of image data */774 /* Called by user to write a row of image data */ 746 775 void PNGAPI 747 776 png_write_row(png_structp png_ptr, png_bytep row) … … 749 778 if (png_ptr == NULL) 750 779 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)", 752 781 png_ptr->row_number, png_ptr->pass); 753 782 754 /* initialize transformations and other stuff if first time */783 /* Initialize transformations and other stuff if first time */ 755 784 if (png_ptr->row_number == 0 && png_ptr->pass == 0) 756 785 { 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 */ 763 792 #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."); 766 795 #endif 767 796 #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."); 770 799 #endif 771 800 #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."); 774 803 #endif 775 804 #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."); 778 807 #endif 779 808 #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."); 782 811 #endif 783 812 #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."); 786 815 #endif 787 816 #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."); 790 819 #endif 791 820 … … 794 823 795 824 #if defined(PNG_WRITE_INTERLACING_SUPPORTED) 796 /* if interlaced and not interested in row, return */825 /* If interlaced and not interested in row, return */ 797 826 if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) 798 827 { … … 852 881 #endif 853 882 854 /* set up row info for transformations */883 /* Set up row info for transformations */ 855 884 png_ptr->row_info.color_type = png_ptr->color_type; 856 885 png_ptr->row_info.width = png_ptr->usr_width; … … 863 892 png_ptr->row_info.width); 864 893 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); 871 900 872 901 /* Copy user's row into buffer, leaving room for filter byte. */ … … 875 904 876 905 #if defined(PNG_WRITE_INTERLACING_SUPPORTED) 877 /* handle interlacing */906 /* Handle interlacing */ 878 907 if (png_ptr->interlaced && png_ptr->pass < 6 && 879 908 (png_ptr->transformations & PNG_INTERLACE)) … … 881 910 png_do_write_interlace(&(png_ptr->row_info), 882 911 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 ... */ 884 913 if (!(png_ptr->row_info.width)) 885 914 { … … 890 919 #endif 891 920 892 /* handle other transformations */921 /* Handle other transformations */ 893 922 if (png_ptr->transformations) 894 923 png_do_write_transformations(png_ptr); … … 904 933 * 5. The color_type is RGB or RGBA 905 934 */ 906 if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&935 if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && 907 936 (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) 908 937 { … … 924 953 png_set_flush(png_structp png_ptr, int nrows) 925 954 { 926 png_debug(1, "in png_set_flush \n");955 png_debug(1, "in png_set_flush"); 927 956 if (png_ptr == NULL) 928 957 return; … … 930 959 } 931 960 932 /* flush the current output buffers now */961 /* Flush the current output buffers now */ 933 962 void PNGAPI 934 963 png_write_flush(png_structp png_ptr) … … 936 965 int wrote_IDAT; 937 966 938 png_debug(1, "in png_write_flush \n");967 png_debug(1, "in png_write_flush"); 939 968 if (png_ptr == NULL) 940 969 return; 941 970 /* We have already written out all of the data */ 942 971 if (png_ptr->row_number >= png_ptr->num_rows) 943 return;972 return; 944 973 945 974 do … … 947 976 int ret; 948 977 949 /* compress the data */978 /* Compress the data */ 950 979 ret = deflate(&png_ptr->zstream, Z_SYNC_FLUSH); 951 980 wrote_IDAT = 0; 952 981 953 /* check for compression errors */982 /* Check for compression errors */ 954 983 if (ret != Z_OK) 955 984 { … … 962 991 if (!(png_ptr->zstream.avail_out)) 963 992 { 964 /* write the IDAT and reset the zlib output buffer */993 /* Write the IDAT and reset the zlib output buffer */ 965 994 png_write_IDAT(png_ptr, png_ptr->zbuf, 966 995 png_ptr->zbuf_size); … … 974 1003 if (png_ptr->zbuf_size != png_ptr->zstream.avail_out) 975 1004 { 976 /* write the IDAT and reset the zlib output buffer */1005 /* Write the IDAT and reset the zlib output buffer */ 977 1006 png_write_IDAT(png_ptr, png_ptr->zbuf, 978 1007 png_ptr->zbuf_size - png_ptr->zstream.avail_out); … … 985 1014 #endif /* PNG_WRITE_FLUSH_SUPPORTED */ 986 1015 987 /* free all memory used by the write */1016 /* Free all memory used by the write */ 988 1017 void PNGAPI 989 1018 png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) … … 996 1025 #endif 997 1026 998 png_debug(1, "in png_destroy_write_struct \n");1027 png_debug(1, "in png_destroy_write_struct"); 999 1028 if (png_ptr_ptr != NULL) 1000 1029 { … … 1028 1057 png_free(png_ptr, png_ptr->chunk_list); 1029 1058 png_ptr->chunk_list=NULL; 1030 png_ptr->num_chunk_list =0;1059 png_ptr->num_chunk_list = 0; 1031 1060 } 1032 1061 #endif … … 1061 1090 { 1062 1091 #ifdef PNG_SETJMP_SUPPORTED 1063 jmp_buf tmp_jmp; /* save jump buffer */1092 jmp_buf tmp_jmp; /* Save jump buffer */ 1064 1093 #endif 1065 1094 png_error_ptr error_fn; … … 1070 1099 #endif 1071 1100 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 */ 1074 1103 deflateEnd(&png_ptr->zstream); 1075 1104 1076 /* free our memory. png_free checks NULL for us. */1105 /* Free our memory. png_free checks NULL for us. */ 1077 1106 png_free(png_ptr, png_ptr->zbuf); 1078 1107 png_free(png_ptr, png_ptr->row_buf); 1079 #ifndef PNG_NO_WRITE_FILTER ING1108 #ifndef PNG_NO_WRITE_FILTER 1080 1109 png_free(png_ptr, png_ptr->prev_row); 1081 1110 png_free(png_ptr, png_ptr->sub_row); … … 1098 1127 1099 1128 #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)); 1102 1131 #endif 1103 1132 … … 1109 1138 #endif 1110 1139 1111 png_memset(png_ptr, 0, png_sizeof (png_struct));1140 png_memset(png_ptr, 0, png_sizeof(png_struct)); 1112 1141 1113 1142 png_ptr->error_fn = error_fn; … … 1119 1148 1120 1149 #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)); 1122 1151 #endif 1123 1152 } … … 1127 1156 png_set_filter(png_structp png_ptr, int method, int filters) 1128 1157 { 1129 png_debug(1, "in png_set_filter \n");1158 png_debug(1, "in png_set_filter"); 1130 1159 if (png_ptr == NULL) 1131 1160 return; 1132 1161 #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) && 1134 1163 (method == PNG_INTRAPIXEL_DIFFERENCING)) 1135 1164 method = PNG_FILTER_TYPE_BASE; … … 1250 1279 int i; 1251 1280 1252 png_debug(1, "in png_set_filter_heuristics \n");1281 png_debug(1, "in png_set_filter_heuristics"); 1253 1282 if (png_ptr == NULL) 1254 1283 return; … … 1364 1393 png_set_compression_level(png_structp png_ptr, int level) 1365 1394 { 1366 png_debug(1, "in png_set_compression_level \n");1395 png_debug(1, "in png_set_compression_level"); 1367 1396 if (png_ptr == NULL) 1368 1397 return; … … 1374 1403 png_set_compression_mem_level(png_structp png_ptr, int mem_level) 1375 1404 { 1376 png_debug(1, "in png_set_compression_mem_level \n");1405 png_debug(1, "in png_set_compression_mem_level"); 1377 1406 if (png_ptr == NULL) 1378 1407 return; … … 1384 1413 png_set_compression_strategy(png_structp png_ptr, int strategy) 1385 1414 { 1386 png_debug(1, "in png_set_compression_strategy \n");1415 png_debug(1, "in png_set_compression_strategy"); 1387 1416 if (png_ptr == NULL) 1388 1417 return; … … 1401 1430 png_warning(png_ptr, "Only compression windows >= 256 supported by PNG"); 1402 1431 #ifndef WBITS_8_OK 1403 /* avoid libpng bug with 256-byte windows */1432 /* Avoid libpng bug with 256-byte windows */ 1404 1433 if (window_bits == 8) 1405 1434 { … … 1415 1444 png_set_compression_method(png_structp png_ptr, int method) 1416 1445 { 1417 png_debug(1, "in png_set_compression_method \n");1446 png_debug(1, "in png_set_compression_method"); 1418 1447 if (png_ptr == NULL) 1419 1448 return; … … 1437 1466 write_user_transform_fn) 1438 1467 { 1439 png_debug(1, "in png_set_write_user_transform_fn \n");1468 png_debug(1, "in png_set_write_user_transform_fn"); 1440 1469 if (png_ptr == NULL) 1441 1470 return; … … 1454 1483 return; 1455 1484 #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 */ 1457 1486 if (transforms & PNG_TRANSFORM_INVERT_ALPHA) 1458 png_set_invert_alpha(png_ptr);1487 png_set_invert_alpha(png_ptr); 1459 1488 #endif 1460 1489 … … 1465 1494 1466 1495 #if defined(PNG_WRITE_INVERT_SUPPORTED) 1467 /* invert monochrome pixels */1496 /* Invert monochrome pixels */ 1468 1497 if (transforms & PNG_TRANSFORM_INVERT_MONO) 1469 png_set_invert_mono(png_ptr);1498 png_set_invert_mono(png_ptr); 1470 1499 #endif 1471 1500 … … 1476 1505 if ((transforms & PNG_TRANSFORM_SHIFT) 1477 1506 && (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); 1479 1508 #endif 1480 1509 1481 1510 #if defined(PNG_WRITE_PACK_SUPPORTED) 1482 /* pack pixels into bytes */1511 /* Pack pixels into bytes */ 1483 1512 if (transforms & PNG_TRANSFORM_PACKING) 1484 1513 png_set_packing(png_ptr); … … 1486 1515 1487 1516 #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 */ 1489 1518 if (transforms & PNG_TRANSFORM_SWAP_ALPHA) 1490 png_set_swap_alpha(png_ptr);1519 png_set_swap_alpha(png_ptr); 1491 1520 #endif 1492 1521 1493 1522 #if defined(PNG_WRITE_FILLER_SUPPORTED) 1494 /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into1495 * 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); 1499 1528 #endif 1500 1529 1501 1530 #if defined(PNG_WRITE_BGR_SUPPORTED) 1502 /* flip BGR pixels to RGB */1531 /* Flip BGR pixels to RGB */ 1503 1532 if (transforms & PNG_TRANSFORM_BGR) 1504 png_set_bgr(png_ptr);1533 png_set_bgr(png_ptr); 1505 1534 #endif 1506 1535 1507 1536 #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 */ 1509 1538 if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) 1510 png_set_swap(png_ptr);1539 png_set_swap(png_ptr); 1511 1540 #endif 1512 1541 1513 1542 #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 */ 1515 1544 if (transforms & PNG_TRANSFORM_PACKSWAP) 1516 png_set_packswap(png_ptr);1545 png_set_packswap(png_ptr); 1517 1546 #endif 1518 1547 1519 1548 /* ----------------------- end of transformations ------------------- */ 1520 1549 1521 /* write the bits */1550 /* Write the bits */ 1522 1551 if (info_ptr->valid & PNG_INFO_IDAT) 1523 1552 png_write_image(png_ptr, info_ptr->row_pointers); … … 1526 1555 png_write_end(png_ptr, info_ptr); 1527 1556 1528 transforms = transforms; /* quiet compiler warnings */1557 transforms = transforms; /* Quiet compiler warnings */ 1529 1558 params = params; 1530 1559 } -
trunk/src/3rdparty/libpng/pngwtran.c
r2 r561 2 2 /* pngwtran.c - transforms the data in a row for PNG writers 3 3 * 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 7 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 7 * (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 9 12 */ 10 13 … … 19 22 png_do_write_transformations(png_structp png_ptr) 20 23 { 21 png_debug(1, "in png_do_write_transformations \n");24 png_debug(1, "in png_do_write_transformations"); 22 25 23 26 if (png_ptr == NULL) … … 26 29 #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) 27 30 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 */ 30 33 (png_ptr, /* png_ptr */ 31 34 &(png_ptr->row_info), /* row_info: */ … … 87 90 png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) 88 91 { 89 png_debug(1, "in png_do_pack \n");92 png_debug(1, "in png_do_pack"); 90 93 if (row_info->bit_depth == 8 && 91 94 #if defined(PNG_USELESS_TESTS_SUPPORTED) … … 213 216 png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) 214 217 { 215 png_debug(1, "in png_do_shift \n");218 png_debug(1, "in png_do_shift"); 216 219 #if defined(PNG_USELESS_TESTS_SUPPORTED) 217 220 if (row != NULL && row_info != NULL && … … 249 252 } 250 253 251 /* with low row depths, could only be grayscale, so one channel */254 /* With low row depths, could only be grayscale, so one channel */ 252 255 if (row_info->bit_depth < 8) 253 256 { … … 337 340 png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) 338 341 { 339 png_debug(1, "in png_do_write_swap_alpha \n");342 png_debug(1, "in png_do_write_swap_alpha"); 340 343 #if defined(PNG_USELESS_TESTS_SUPPORTED) 341 344 if (row != NULL && row_info != NULL) … … 425 428 png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) 426 429 { 427 png_debug(1, "in png_do_write_invert_alpha \n");430 png_debug(1, "in png_do_write_invert_alpha"); 428 431 #if defined(PNG_USELESS_TESTS_SUPPORTED) 429 432 if (row != NULL && row_info != NULL) … … 440 443 for (i = 0, sp = dp = row; i < row_width; i++) 441 444 { 442 /* does nothing445 /* Does nothing 443 446 *(dp++) = *(sp++); 444 447 *(dp++) = *(sp++); … … 458 461 for (i = 0, sp = dp = row; i < row_width; i++) 459 462 { 460 /* does nothing463 /* Does nothing 461 464 *(dp++) = *(sp++); 462 465 *(dp++) = *(sp++); … … 496 499 for (i = 0, sp = dp = row; i < row_width; i++) 497 500 { 498 /* does nothing501 /* Does nothing 499 502 *(dp++) = *(sp++); 500 503 *(dp++) = *(sp++); … … 511 514 512 515 #if defined(PNG_MNG_FEATURES_SUPPORTED) 513 /* undoes intrapixel differencing */516 /* Undoes intrapixel differencing */ 514 517 void /* PRIVATE */ 515 518 png_do_write_intrapixel(png_row_infop row_info, png_bytep row) 516 519 { 517 png_debug(1, "in png_do_write_intrapixel \n");520 png_debug(1, "in png_do_write_intrapixel"); 518 521 if ( 519 522 #if defined(PNG_USELESS_TESTS_SUPPORTED) … … 559 562 png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3); 560 563 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); 563 566 *(rp ) = (png_byte)((red >> 8) & 0xff); 564 567 *(rp+1) = (png_byte)(red & 0xff); -
trunk/src/3rdparty/libpng/pngwutil.c
r2 r561 2 2 /* pngwutil.c - utilities to write a PNG file 3 3 * 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 7 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 7 * (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 9 12 */ 10 13 … … 48 51 buf[0] = (png_byte)((i >> 8) & 0xff); 49 52 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 */ 61 void /* PRIVATE */ 62 png_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; 50 71 } 51 72 … … 63 84 png_bytep data, png_size_t length) 64 85 { 65 if(png_ptr == NULL) return; 86 if (png_ptr == NULL) 87 return; 66 88 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); 68 90 png_write_chunk_end(png_ptr); 69 91 } … … 77 99 png_uint_32 length) 78 100 { 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 */ 84 110 png_save_uint_32(buf, length); 85 png_ write_data(png_ptr, buf, (png_size_t)4);86 87 /* write the chunkname */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 */ 90 116 png_reset_crc(png_ptr); 91 117 png_calculate_crc(png_ptr, chunk_name, (png_size_t)4); … … 100 126 png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length) 101 127 { 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; 104 131 if (data != NULL && length > 0) 105 132 { 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 */ 106 137 png_calculate_crc(png_ptr, data, length); 107 png_write_data(png_ptr, data, length);108 138 } 109 139 } … … 115 145 png_byte buf[4]; 116 146 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 */ 120 150 png_save_uint_32(buf, png_ptr->crc); 121 151 … … 123 153 } 124 154 125 /* Simple function to write the signature. If we have already written126 * the magic bytes of the signature, or more likely, the PNG stream is127 * 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 the129 * 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 142 155 #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 145 157 * text string, and (b) issuing it later as a series of chunk data writes. 146 158 * The compression_state structure is shared context for these functions … … 150 162 typedef struct 151 163 { 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 */ 157 169 } compression_state; 158 170 159 /* compress given text into storage in the png_ptr structure */171 /* Compress given text into storage in the png_ptr structure */ 160 172 static int /* PRIVATE */ 161 173 png_text_compress(png_structp png_ptr, … … 171 183 comp->input_len = 0; 172 184 173 /* we may just want to pass the text right through */185 /* We may just want to pass the text right through */ 174 186 if (compression == PNG_TEXT_COMPRESSION_NONE) 175 187 { … … 205 217 */ 206 218 207 /* set up the compression buffers */219 /* Set up the compression buffers */ 208 220 png_ptr->zstream.avail_in = (uInt)text_len; 209 221 png_ptr->zstream.next_in = (Bytef *)text; … … 211 223 png_ptr->zstream.next_out = (Bytef *)png_ptr->zbuf; 212 224 213 /* this is the same compression loop as in png_write_row() */225 /* This is the same compression loop as in png_write_row() */ 214 226 do 215 227 { 216 /* compress the data */228 /* Compress the data */ 217 229 ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); 218 230 if (ret != Z_OK) 219 231 { 220 /* error */232 /* Error */ 221 233 if (png_ptr->zstream.msg != NULL) 222 234 png_error(png_ptr, png_ptr->zstream.msg); … … 224 236 png_error(png_ptr, "zlib error"); 225 237 } 226 /* check to see if we need more room */238 /* Check to see if we need more room */ 227 239 if (!(png_ptr->zstream.avail_out)) 228 240 { 229 /* make sure the output array has room */241 /* Make sure the output array has room */ 230 242 if (comp->num_output_ptr >= comp->max_output_ptr) 231 243 { … … 240 252 old_ptr = comp->output_ptr; 241 253 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))); 244 256 png_memcpy(comp->output_ptr, old_ptr, old_max 245 * png_sizeof (png_charp));257 * png_sizeof(png_charp)); 246 258 png_free(png_ptr, old_ptr); 247 259 } 248 260 else 249 261 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))); 252 264 } 253 265 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, 256 269 (png_uint_32)png_ptr->zbuf_size); 257 270 png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, … … 263 276 png_ptr->zstream.next_out = png_ptr->zbuf; 264 277 } 265 /* continue until we don't have any more to compress */278 /* Continue until we don't have any more to compress */ 266 279 } while (png_ptr->zstream.avail_in); 267 280 268 /* finish the compression */281 /* Finish the compression */ 269 282 do 270 283 { 271 /* tell zlib we are finished */284 /* Tell zlib we are finished */ 272 285 ret = deflate(&png_ptr->zstream, Z_FINISH); 273 286 274 287 if (ret == Z_OK) 275 288 { 276 /* check to see if we need more room */289 /* Check to see if we need more room */ 277 290 if (!(png_ptr->zstream.avail_out)) 278 291 { 279 /* check to make sure our output array has room */292 /* Check to make sure our output array has room */ 280 293 if (comp->num_output_ptr >= comp->max_output_ptr) 281 294 { … … 292 305 comp->output_ptr = (png_charpp)png_malloc(png_ptr, 293 306 (png_uint_32)(comp->max_output_ptr * 294 png_sizeof (png_charpp)));307 png_sizeof(png_charp))); 295 308 png_memcpy(comp->output_ptr, old_ptr, 296 old_max * png_sizeof (png_charp));309 old_max * png_sizeof(png_charp)); 297 310 png_free(png_ptr, old_ptr); 298 311 } … … 300 313 comp->output_ptr = (png_charpp)png_malloc(png_ptr, 301 314 (png_uint_32)(comp->max_output_ptr * 302 png_sizeof (png_charp)));315 png_sizeof(png_charp))); 303 316 } 304 317 305 /* save offthe data */318 /* Save the data */ 306 319 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); 308 322 png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, 309 323 png_ptr->zbuf_size); … … 317 331 else if (ret != Z_STREAM_END) 318 332 { 319 /* we got an error */333 /* We got an error */ 320 334 if (png_ptr->zstream.msg != NULL) 321 335 png_error(png_ptr, png_ptr->zstream.msg); … … 325 339 } while (ret != Z_STREAM_END); 326 340 327 /* text length is number of buffers plus last buffer */341 /* Text length is number of buffers plus last buffer */ 328 342 text_len = png_ptr->zbuf_size * comp->num_output_ptr; 329 343 if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) … … 333 347 } 334 348 335 /* ship the compressed text out via chunk writes */349 /* Ship the compressed text out via chunk writes */ 336 350 static void /* PRIVATE */ 337 351 png_write_compressed_data_out(png_structp png_ptr, compression_state *comp) … … 339 353 int i; 340 354 341 /* handle the no-compression case */355 /* Handle the no-compression case */ 342 356 if (comp->input) 343 357 { 344 png_write_chunk_data(png_ptr, (png_bytep)comp->input,358 png_write_chunk_data(png_ptr, (png_bytep)comp->input, 345 359 (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 */ 350 364 for (i = 0; i < comp->num_output_ptr; i++) 351 365 { 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); 354 368 png_free(png_ptr, comp->output_ptr[i]); 355 comp->output_ptr[i]=NULL;369 comp->output_ptr[i]=NULL; 356 370 } 357 371 if (comp->max_output_ptr != 0) 358 372 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 */ 361 375 if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size) 362 376 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 */ 366 380 deflateReset(&png_ptr->zstream); 367 381 png_ptr->zstream.data_type = Z_BINARY; … … 383 397 int ret; 384 398 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 388 403 /* Check that we have valid input data from the application info */ 389 404 switch (color_type) … … 397 412 case 8: 398 413 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"); 400 415 } 401 416 break; … … 469 484 #endif 470 485 471 /* save offthe relevent information */486 /* Save the relevent information */ 472 487 png_ptr->bit_depth = (png_byte)bit_depth; 473 488 png_ptr->color_type = (png_byte)color_type; … … 482 497 png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels); 483 498 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 */ 485 500 png_ptr->usr_width = png_ptr->width; 486 501 png_ptr->usr_bit_depth = png_ptr->bit_depth; 487 502 png_ptr->usr_channels = png_ptr->channels; 488 503 489 /* pack the header information into the buffer */504 /* Pack the header information into the buffer */ 490 505 png_save_uint_32(buf, width); 491 506 png_save_uint_32(buf + 4, height); … … 496 511 buf[12] = (png_byte)interlace_type; 497 512 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 */ 502 517 png_ptr->zstream.zalloc = png_zalloc; 503 518 png_ptr->zstream.zfree = png_zfree; … … 542 557 png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; 543 558 /* 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 */ 545 560 png_ptr->zstream.data_type = Z_BINARY; 546 561 … … 548 563 } 549 564 550 /* write the palette. We are careful not to trust png_color to be in the565 /* Write the palette. We are careful not to trust png_color to be in the 551 566 * correct order for PNG, so people can redefine it to any convenient 552 567 * structure. … … 562 577 png_byte buf[3]; 563 578 564 png_debug(1, "in png_write_PLTE\n"); 579 png_debug(1, "in png_write_PLTE"); 580 565 581 if (( 566 582 #if defined(PNG_MNG_FEATURES_SUPPORTED) … … 588 604 589 605 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)); 593 610 #ifndef PNG_NO_POINTER_INDEXING 594 611 for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++) … … 614 631 } 615 632 616 /* write an IDAT chunk */633 /* Write an IDAT chunk */ 617 634 void /* PRIVATE */ 618 635 png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length) … … 621 638 PNG_IDAT; 622 639 #endif 623 png_debug(1, "in png_write_IDAT\n"); 640 641 png_debug(1, "in png_write_IDAT"); 624 642 625 643 /* Optimize the CMF field in the zlib stream. */ … … 631 649 if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70) 632 650 { 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 */ 636 656 if (length >= 2 && 637 657 png_ptr->height < 16384 && png_ptr->width < 16384) … … 662 682 } 663 683 664 png_write_chunk(png_ptr, png_IDAT, data, length);684 png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length); 665 685 png_ptr->mode |= PNG_HAVE_IDAT; 666 686 } 667 687 668 /* write an IEND chunk */688 /* Write an IEND chunk */ 669 689 void /* PRIVATE */ 670 690 png_write_IEND(png_structp png_ptr) … … 673 693 PNG_IEND; 674 694 #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, 677 699 (png_size_t)0); 678 700 png_ptr->mode |= PNG_HAVE_IEND; … … 680 702 681 703 #if defined(PNG_WRITE_gAMA_SUPPORTED) 682 /* write a gAMA chunk */704 /* Write a gAMA chunk */ 683 705 #ifdef PNG_FLOATING_POINT_SUPPORTED 684 706 void /* PRIVATE */ … … 691 713 png_byte buf[4]; 692 714 693 png_debug(1, "in png_write_gAMA\n"); 715 png_debug(1, "in png_write_gAMA"); 716 694 717 /* file_gamma is saved in 1/100,000ths */ 695 718 igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5); 696 719 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); 698 721 } 699 722 #endif … … 707 730 png_byte buf[4]; 708 731 709 png_debug(1, "in png_write_gAMA\n"); 732 png_debug(1, "in png_write_gAMA"); 733 710 734 /* file_gamma is saved in 1/100,000ths */ 711 735 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); 713 737 } 714 738 #endif … … 716 740 717 741 #if defined(PNG_WRITE_sRGB_SUPPORTED) 718 /* write a sRGB chunk */742 /* Write a sRGB chunk */ 719 743 void /* PRIVATE */ 720 744 png_write_sRGB(png_structp png_ptr, int srgb_intent) … … 725 749 png_byte buf[1]; 726 750 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) 729 754 png_warning(png_ptr, 730 755 "Invalid sRGB rendering intent specified"); 731 756 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); 733 758 } 734 759 #endif 735 760 736 761 #if defined(PNG_WRITE_iCCP_SUPPORTED) 737 /* write an iCCP chunk */762 /* Write an iCCP chunk */ 738 763 void /* PRIVATE */ 739 764 png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type, … … 748 773 int embedded_profile_len = 0; 749 774 750 png_debug(1, "in png_write_iCCP \n");775 png_debug(1, "in png_write_iCCP"); 751 776 752 777 comp.num_output_ptr = 0; … … 756 781 comp.input_len = 0; 757 782 758 if ( name == NULL ||(name_len = png_check_keyword(png_ptr, name,783 if ((name_len = png_check_keyword(png_ptr, name, 759 784 &new_name)) == 0) 760 {761 png_warning(png_ptr, "Empty keyword in iCCP chunk");762 785 return; 763 }764 786 765 787 if (compression_type != PNG_COMPRESSION_TYPE_BASE) … … 771 793 if (profile_len > 3) 772 794 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 } 777 807 778 808 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 } 784 815 785 816 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 } 791 822 792 823 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)); 801 833 802 834 if (profile_len) … … 809 841 810 842 #if defined(PNG_WRITE_sPLT_SUPPORTED) 811 /* write a sPLT chunk */843 /* Write a sPLT chunk */ 812 844 void /* PRIVATE */ 813 845 png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette) … … 826 858 #endif 827 859 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) 833 863 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 */ 843 873 #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 else855 {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); 863 893 } 864 894 #else … … 866 896 for (i=0; i>spalette->nentries; i++) 867 897 { 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 else877 {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); 885 915 } 886 916 #endif … … 892 922 893 923 #if defined(PNG_WRITE_sBIT_SUPPORTED) 894 /* write the sBIT chunk */924 /* Write the sBIT chunk */ 895 925 void /* PRIVATE */ 896 926 png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type) … … 902 932 png_size_t size; 903 933 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 */ 906 937 if (color_type & PNG_COLOR_MASK_COLOR) 907 938 { … … 943 974 } 944 975 945 png_write_chunk(png_ptr, png_sBIT, buf, size);976 png_write_chunk(png_ptr, (png_bytep)png_sBIT, buf, size); 946 977 } 947 978 #endif 948 979 949 980 #if defined(PNG_WRITE_cHRM_SUPPORTED) 950 /* write the cHRM chunk */981 /* Write the cHRM chunk */ 951 982 #ifdef PNG_FLOATING_POINT_SUPPORTED 952 983 void /* PRIVATE */ … … 959 990 #endif 960 991 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 } 1010 1028 } 1011 1029 #endif … … 1022 1040 png_byte buf[32]; 1023 1041 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 } 1062 1064 } 1063 1065 #endif … … 1065 1067 1066 1068 #if defined(PNG_WRITE_tRNS_SUPPORTED) 1067 /* write the tRNS chunk */1069 /* Write the tRNS chunk */ 1068 1070 void /* PRIVATE */ 1069 1071 png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran, … … 1075 1077 png_byte buf[6]; 1076 1078 1077 png_debug(1, "in png_write_tRNS\n"); 1079 png_debug(1, "in png_write_tRNS"); 1080 1078 1081 if (color_type == PNG_COLOR_TYPE_PALETTE) 1079 1082 { 1080 1083 if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette) 1081 1084 { 1082 png_warning(png_ptr, "Invalid number of transparent colors specified");1085 png_warning(png_ptr, "Invalid number of transparent colors specified"); 1083 1086 return; 1084 1087 } 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); 1087 1091 } 1088 1092 else if (color_type == PNG_COLOR_TYPE_GRAY) 1089 1093 { 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)) 1092 1096 { 1093 1097 png_warning(png_ptr, … … 1096 1100 } 1097 1101 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); 1099 1103 } 1100 1104 else if (color_type == PNG_COLOR_TYPE_RGB) 1101 1105 { 1102 /* three 16 bit values */1106 /* Three 16 bit values */ 1103 1107 png_save_uint_16(buf, tran->red); 1104 1108 png_save_uint_16(buf + 2, tran->green); 1105 1109 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); 1113 1117 } 1114 1118 else … … 1120 1124 1121 1125 #if defined(PNG_WRITE_bKGD_SUPPORTED) 1122 /* write the background chunk */1126 /* Write the background chunk */ 1123 1127 void /* PRIVATE */ 1124 1128 png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type) … … 1129 1133 png_byte buf[6]; 1130 1134 1131 png_debug(1, "in png_write_bKGD\n"); 1135 png_debug(1, "in png_write_bKGD"); 1136 1132 1137 if (color_type == PNG_COLOR_TYPE_PALETTE) 1133 1138 { … … 1137 1142 (!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) && 1138 1143 #endif 1139 back->index > png_ptr->num_palette)1144 back->index >= png_ptr->num_palette) 1140 1145 { 1141 1146 png_warning(png_ptr, "Invalid background palette index"); … … 1143 1148 } 1144 1149 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); 1146 1151 } 1147 1152 else if (color_type & PNG_COLOR_MASK_COLOR) … … 1150 1155 png_save_uint_16(buf + 2, back->green); 1151 1156 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); 1159 1164 } 1160 1165 else 1161 1166 { 1162 if (back->gray >= (1 << png_ptr->bit_depth))1167 if (back->gray >= (1 << png_ptr->bit_depth)) 1163 1168 { 1164 1169 png_warning(png_ptr, … … 1167 1172 } 1168 1173 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); 1170 1175 } 1171 1176 } … … 1173 1178 1174 1179 #if defined(PNG_WRITE_hIST_SUPPORTED) 1175 /* write the histogram */1180 /* Write the histogram */ 1176 1181 void /* PRIVATE */ 1177 1182 png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist) … … 1183 1188 png_byte buf[3]; 1184 1189 1185 png_debug(1, "in png_write_hIST\n"); 1190 png_debug(1, "in png_write_hIST"); 1191 1186 1192 if (num_hist > (int)png_ptr->num_palette) 1187 1193 { 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, 1189 1195 png_ptr->num_palette); 1190 1196 png_warning(png_ptr, "Invalid number of histogram entries specified"); … … 1192 1198 } 1193 1199 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)); 1195 1202 for (i = 0; i < num_hist; i++) 1196 1203 { … … 1222 1229 int kwarn=0; 1223 1230 1224 png_debug(1, "in png_check_keyword\n"); 1231 png_debug(1, "in png_check_keyword"); 1232 1225 1233 *new_key = NULL; 1226 1234 … … 1231 1239 } 1232 1240 1233 png_debug1(2, "Keyword to be checked is '%s' \n", key);1241 png_debug1(2, "Keyword to be checked is '%s'", key); 1234 1242 1235 1243 *new_key = (png_charp)png_malloc_warn(png_ptr, (png_uint_32)(key_len + 2)); … … 1272 1280 while (*kp == ' ') 1273 1281 { 1274 *(kp--) = '\0';1275 key_len--;1282 *(kp--) = '\0'; 1283 key_len--; 1276 1284 } 1277 1285 } … … 1285 1293 while (*kp == ' ') 1286 1294 { 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); 1293 1301 1294 1302 /* Remove multiple internal spaces. */ … … 1312 1320 } 1313 1321 *dp = '\0'; 1314 if (kwarn)1322 if (kwarn) 1315 1323 png_warning(png_ptr, "extra interior spaces removed from keyword"); 1316 1324 … … 1318 1326 { 1319 1327 png_free(png_ptr, *new_key); 1320 *new_key=NULL;1328 *new_key=NULL; 1321 1329 png_warning(png_ptr, "Zero length keyword"); 1322 1330 } … … 1325 1333 { 1326 1334 png_warning(png_ptr, "keyword length must be 1 - 79 characters"); 1327 new_key[79] = '\0';1335 (*new_key)[79] = '\0'; 1328 1336 key_len = 79; 1329 1337 } … … 1334 1342 1335 1343 #if defined(PNG_WRITE_tEXt_SUPPORTED) 1336 /* write a tEXt chunk */1344 /* Write a tEXt chunk */ 1337 1345 void /* PRIVATE */ 1338 1346 png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text, … … 1345 1353 png_charp new_key; 1346 1354 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) 1351 1358 return; 1352 }1353 1359 1354 1360 if (text == NULL || *text == '\0') … … 1357 1363 text_len = png_strlen(text); 1358 1364 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)); 1361 1368 /* 1362 1369 * We leave it to the application to meet PNG-1.0 requirements on the … … 1365 1372 * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. 1366 1373 */ 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)); 1368 1376 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); 1370 1378 1371 1379 png_write_chunk_end(png_ptr); … … 1375 1383 1376 1384 #if defined(PNG_WRITE_zTXt_SUPPORTED) 1377 /* write a compressed text chunk */1385 /* Write a compressed text chunk */ 1378 1386 void /* PRIVATE */ 1379 1387 png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text, … … 1388 1396 compression_state comp; 1389 1397 1390 png_debug(1, "in png_write_zTXt \n");1398 png_debug(1, "in png_write_zTXt"); 1391 1399 1392 1400 comp.num_output_ptr = 0; … … 1396 1404 comp.input_len = 0; 1397 1405 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); 1401 1409 return; 1402 1410 } … … 1411 1419 text_len = png_strlen(text); 1412 1420 1413 /* compute the compressed data; do it now for the length */1421 /* Compute the compressed data; do it now for the length */ 1414 1422 text_len = png_text_compress(png_ptr, text, text_len, compression, 1415 1423 &comp); 1416 1424 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)); 1422 1431 png_free(png_ptr, new_key); 1423 1432 1424 1433 buf[0] = (png_byte)compression; 1425 /* write compression */1434 /* Write compression */ 1426 1435 png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1); 1427 /* write the compressed data */1436 /* Write the compressed data */ 1428 1437 png_write_compressed_data_out(png_ptr, &comp); 1429 1438 1430 /* close the chunk */1439 /* Close the chunk */ 1431 1440 png_write_chunk_end(png_ptr); 1432 1441 } … … 1434 1443 1435 1444 #if defined(PNG_WRITE_iTXt_SUPPORTED) 1436 /* write an iTXt chunk */1445 /* Write an iTXt chunk */ 1437 1446 void /* PRIVATE */ 1438 1447 png_write_iTXt(png_structp png_ptr, int compression, png_charp key, … … 1443 1452 #endif 1444 1453 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; 1446 1456 png_byte cbuf[2]; 1447 1457 compression_state comp; 1448 1458 1449 png_debug(1, "in png_write_iTXt \n");1459 png_debug(1, "in png_write_iTXt"); 1450 1460 1451 1461 comp.num_output_ptr = 0; … … 1454 1464 comp.input = NULL; 1455 1465 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) 1459 1467 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) 1462 1470 { 1463 1471 png_warning(png_ptr, "Empty language field in iTXt chunk"); … … 1467 1475 1468 1476 if (lang_key == NULL) 1469 lang_key_len = 0;1477 lang_key_len = 0; 1470 1478 else 1471 lang_key_len = png_strlen(lang_key);1479 lang_key_len = png_strlen(lang_key); 1472 1480 1473 1481 if (text == NULL) 1474 1482 text_len = 0; 1475 1483 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 */ 1479 1487 text_len = png_text_compress(png_ptr, text, text_len, compression-2, 1480 1488 &comp); 1481 1489 1482 1490 1483 /* make sure we include the compression flag, the compression byte,1491 /* Make sure we include the compression flag, the compression byte, 1484 1492 * and the NULs after the key, lang, and lang_key parts */ 1485 1493 1486 png_write_chunk_start(png_ptr, png_iTXt,1494 png_write_chunk_start(png_ptr, (png_bytep)png_iTXt, 1487 1495 (png_uint_32)( 1488 1496 5 /* comp byte, comp flag, terminators for key, lang and lang_key */ … … 1492 1500 + text_len)); 1493 1501 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 1496 1503 * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of 1497 1504 * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. 1498 1505 * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. 1499 1506 */ 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 */ 1503 1511 if (compression == PNG_ITXT_COMPRESSION_NONE || \ 1504 1512 compression == PNG_TEXT_COMPRESSION_NONE) … … 1506 1514 else /* compression == PNG_ITXT_COMPRESSION_zTXt */ 1507 1515 cbuf[0] = 1; 1508 /* set the compression method */1516 /* Set the compression method */ 1509 1517 cbuf[1] = 0; 1510 png_write_chunk_data(png_ptr, cbuf, 2);1518 png_write_chunk_data(png_ptr, cbuf, (png_size_t)2); 1511 1519 1512 1520 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)); 1515 1525 png_write_compressed_data_out(png_ptr, &comp); 1516 1526 … … 1522 1532 1523 1533 #if defined(PNG_WRITE_oFFs_SUPPORTED) 1524 /* write the oFFs chunk */1534 /* Write the oFFs chunk */ 1525 1535 void /* PRIVATE */ 1526 1536 png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset, … … 1532 1542 png_byte buf[9]; 1533 1543 1534 png_debug(1, "in png_write_oFFs\n"); 1544 png_debug(1, "in png_write_oFFs"); 1545 1535 1546 if (unit_type >= PNG_OFFSET_LAST) 1536 1547 png_warning(png_ptr, "Unrecognized unit type for oFFs chunk"); … … 1540 1551 buf[8] = (png_byte)unit_type; 1541 1552 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); 1543 1554 } 1544 1555 #endif 1545 1556 #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) */ 1547 1558 void /* PRIVATE */ 1548 1559 png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0, … … 1558 1569 int i; 1559 1570 1560 png_debug1(1, "in png_write_pCAL (%d parameters)\n", nparams); 1571 png_debug1(1, "in png_write_pCAL (%d parameters)", nparams); 1572 1561 1573 if (type >= PNG_EQUATION_LAST) 1562 1574 png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); 1563 1575 1564 1576 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); 1566 1578 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); 1568 1580 total_len = purpose_len + units_len + 10; 1569 1581 1570 params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams1571 *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))); 1572 1584 1573 1585 /* Find the length of each parameter, making sure we don't count the … … 1576 1588 { 1577 1589 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]); 1579 1592 total_len += (png_size_t)params_len[i]; 1580 1593 } 1581 1594 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); 1585 1599 png_save_int_32(buf, X0); 1586 1600 png_save_int_32(buf + 4, X1); … … 1604 1618 1605 1619 #if defined(PNG_WRITE_sCAL_SUPPORTED) 1606 /* write the sCAL chunk */1620 /* Write the sCAL chunk */ 1607 1621 #if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) 1608 1622 void /* PRIVATE */ … … 1615 1629 png_size_t total_len; 1616 1630 1617 png_debug(1, "in png_write_sCAL \n");1631 png_debug(1, "in png_write_sCAL"); 1618 1632 1619 1633 buf[0] = (char)unit; … … 1640 1654 #endif 1641 1655 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); 1644 1658 } 1645 1659 #else … … 1655 1669 png_size_t wlen, hlen, total_len; 1656 1670 1657 png_debug(1, "in png_write_sCAL_s \n");1671 png_debug(1, "in png_write_sCAL_s"); 1658 1672 1659 1673 wlen = png_strlen(width); … … 1667 1681 1668 1682 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); 1674 1688 } 1675 1689 #endif … … 1678 1692 1679 1693 #if defined(PNG_WRITE_pHYs_SUPPORTED) 1680 /* write the pHYs chunk */1694 /* Write the pHYs chunk */ 1681 1695 void /* PRIVATE */ 1682 1696 png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit, … … 1689 1703 png_byte buf[9]; 1690 1704 1691 png_debug(1, "in png_write_pHYs\n"); 1705 png_debug(1, "in png_write_pHYs"); 1706 1692 1707 if (unit_type >= PNG_RESOLUTION_LAST) 1693 1708 png_warning(png_ptr, "Unrecognized unit type for pHYs chunk"); … … 1697 1712 buf[8] = (png_byte)unit_type; 1698 1713 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); 1700 1715 } 1701 1716 #endif … … 1713 1728 png_byte buf[7]; 1714 1729 1715 png_debug(1, "in png_write_tIME\n"); 1730 png_debug(1, "in png_write_tIME"); 1731 1716 1732 if (mod_time->month > 12 || mod_time->month < 1 || 1717 1733 mod_time->day > 31 || mod_time->day < 1 || … … 1729 1745 buf[6] = mod_time->second; 1730 1746 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 */ 1736 1752 void /* PRIVATE */ 1737 1753 png_write_start_row(png_structp png_ptr) … … 1739 1755 #ifdef PNG_WRITE_INTERLACING_SUPPORTED 1740 1756 #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 */ 1744 1760 int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; 1745 1761 1746 /* offset to next interlace block */1762 /* Offset to next interlace block */ 1747 1763 int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; 1748 1764 1749 /* start of interlace block in the y direction */1765 /* Start of interlace block in the y direction */ 1750 1766 int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; 1751 1767 1752 /* offset to next interlace block in the y direction */1768 /* Offset to next interlace block in the y direction */ 1753 1769 int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; 1754 1770 #endif … … 1757 1773 png_size_t buf_size; 1758 1774 1759 png_debug(1, "in png_write_start_row\n"); 1775 png_debug(1, "in png_write_start_row"); 1776 1760 1777 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); 1765 1783 png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE; 1766 1784 1767 #ifndef PNG_NO_WRITE_FILTER ING1768 /* set up filtering buffer, if using this filter */1785 #ifndef PNG_NO_WRITE_FILTER 1786 /* Set up filtering buffer, if using this filter */ 1769 1787 if (png_ptr->do_filter & PNG_FILTER_SUB) 1770 1788 { 1771 1789 png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, 1772 (png_ ptr->rowbytes + 1));1790 (png_uint_32)(png_ptr->rowbytes + 1)); 1773 1791 png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; 1774 1792 } … … 1777 1795 if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) 1778 1796 { 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); 1782 1801 1783 1802 if (png_ptr->do_filter & PNG_FILTER_UP) 1784 1803 { 1785 1804 png_ptr->up_row = (png_bytep)png_malloc(png_ptr, 1786 (png_ptr->rowbytes + 1));1805 (png_uint_32)(png_ptr->rowbytes + 1)); 1787 1806 png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; 1788 1807 } … … 1791 1810 { 1792 1811 png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, 1793 (png_ptr->rowbytes + 1));1812 (png_uint_32)(png_ptr->rowbytes + 1)); 1794 1813 png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; 1795 1814 } … … 1798 1817 { 1799 1818 png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr, 1800 (png_ptr->rowbytes + 1));1819 (png_uint_32)(png_ptr->rowbytes + 1)); 1801 1820 png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; 1802 1821 } 1803 #endif /* PNG_NO_WRITE_FILTERING */ 1804 } 1822 } 1823 #endif /* PNG_NO_WRITE_FILTER */ 1805 1824 1806 1825 #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 */ 1808 1827 if (png_ptr->interlaced) 1809 1828 { … … 1837 1856 #ifdef PNG_WRITE_INTERLACING_SUPPORTED 1838 1857 #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 */ 1842 1861 int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; 1843 1862 1844 /* offset to next interlace block */1863 /* Offset to next interlace block */ 1845 1864 int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; 1846 1865 1847 /* start of interlace block in the y direction */1866 /* Start of interlace block in the y direction */ 1848 1867 int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; 1849 1868 1850 /* offset to next interlace block in the y direction */1869 /* Offset to next interlace block in the y direction */ 1851 1870 int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; 1852 1871 #endif … … 1855 1874 int ret; 1856 1875 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 */ 1859 1879 png_ptr->row_number++; 1860 1880 1861 /* see if we are done */1881 /* See if we are done */ 1862 1882 if (png_ptr->row_number < png_ptr->num_rows) 1863 1883 return; 1864 1884 1865 1885 #ifdef PNG_WRITE_INTERLACING_SUPPORTED 1866 /* if interlaced, go to next pass */1886 /* If interlaced, go to next pass */ 1867 1887 if (png_ptr->interlaced) 1868 1888 { … … 1874 1894 else 1875 1895 { 1876 /* loop until we find a non-zero width or height pass */1896 /* Loop until we find a non-zero width or height pass */ 1877 1897 do 1878 1898 { … … 1894 1914 } 1895 1915 1896 /* reset the row above the image for the next pass */1916 /* Reset the row above the image for the next pass */ 1897 1917 if (png_ptr->pass < 7) 1898 1918 { … … 1900 1920 png_memset(png_ptr->prev_row, 0, 1901 1921 (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); 1903 1923 return; 1904 1924 } … … 1906 1926 #endif 1907 1927 1908 /* if we get here, we've just written the last row, so we need1928 /* If we get here, we've just written the last row, so we need 1909 1929 to flush the compressor */ 1910 1930 do 1911 1931 { 1912 /* tell the compressor we are done */1932 /* Tell the compressor we are done */ 1913 1933 ret = deflate(&png_ptr->zstream, Z_FINISH); 1914 /* check for an error */1934 /* Check for an error */ 1915 1935 if (ret == Z_OK) 1916 1936 { 1917 /* check to see if we need more room */1937 /* Check to see if we need more room */ 1918 1938 if (!(png_ptr->zstream.avail_out)) 1919 1939 { … … 1932 1952 } while (ret != Z_STREAM_END); 1933 1953 1934 /* write any extra space */1954 /* Write any extra space */ 1935 1955 if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) 1936 1956 { … … 1955 1975 { 1956 1976 #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 */ 1960 1980 int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; 1961 1981 1962 /* offset to next interlace block */1982 /* Offset to next interlace block */ 1963 1983 int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; 1964 1984 #endif 1965 1985 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) */ 1968 1989 #if defined(PNG_USELESS_TESTS_SUPPORTED) 1969 1990 if (row != NULL && row_info != NULL && pass < 6) … … 1972 1993 #endif 1973 1994 { 1974 /* each pixel depth is handled separately */1995 /* Each pixel depth is handled separately */ 1975 1996 switch (row_info->pixel_depth) 1976 1997 { … … 2083 2104 png_size_t pixel_bytes; 2084 2105 2085 /* start at the beginning */2106 /* Start at the beginning */ 2086 2107 dp = row; 2087 /* find out how many bytes each pixel takes up */2108 /* Find out how many bytes each pixel takes up */ 2088 2109 pixel_bytes = (row_info->pixel_depth >> 3); 2089 /* loop through the row, only looking at the pixels that2110 /* Loop through the row, only looking at the pixels that 2090 2111 matter */ 2091 2112 for (i = png_pass_start[pass]; i < row_width; 2092 2113 i += png_pass_inc[pass]) 2093 2114 { 2094 /* find out where the original pixel is */2115 /* Find out where the original pixel is */ 2095 2116 sp = row + (png_size_t)i * pixel_bytes; 2096 /* move the pixel */2117 /* Move the pixel */ 2097 2118 if (dp != sp) 2098 2119 png_memcpy(dp, sp, pixel_bytes); 2099 /* next pixel */2120 /* Next pixel */ 2100 2121 dp += pixel_bytes; 2101 2122 } … … 2103 2124 } 2104 2125 } 2105 /* set new row width */2126 /* Set new row width */ 2106 2127 row_info->width = (row_info->width + 2107 2128 png_pass_inc[pass] - 1 - … … 2131 2152 png_byte filter_to_do = png_ptr->do_filter; 2132 2153 png_uint_32 row_bytes = row_info->rowbytes; 2133 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)2154 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 2134 2155 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 */ 2139 2161 bpp = (row_info->pixel_depth + 7) >> 3; 2140 2162 … … 2223 2245 } 2224 2246 2225 /* sub filter */2247 /* Sub filter */ 2226 2248 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 */ 2228 2250 { 2229 2251 png_bytep rp, lp, dp; … … 2340 2362 } 2341 2363 2342 /* up filter */2364 /* Up filter */ 2343 2365 if (filter_to_do == PNG_FILTER_UP) 2344 2366 { … … 2443 2465 } 2444 2466 2445 /* avg filter */2467 /* Avg filter */ 2446 2468 if (filter_to_do == PNG_FILTER_AVG) 2447 2469 { … … 2744 2766 png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row) 2745 2767 { 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 */ 2749 2772 2750 2773 png_ptr->zstream.next_in = filtered_row; 2751 2774 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 */ 2753 2776 do 2754 2777 { 2755 int ret; /* return of zlib */2756 2757 /* compress the data */2778 int ret; /* Return of zlib */ 2779 2780 /* Compress the data */ 2758 2781 ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); 2759 /* check for compression errors */2782 /* Check for compression errors */ 2760 2783 if (ret != Z_OK) 2761 2784 { … … 2766 2789 } 2767 2790 2768 /* see if it is time to write another IDAT */2791 /* See if it is time to write another IDAT */ 2769 2792 if (!(png_ptr->zstream.avail_out)) 2770 2793 { 2771 /* write the IDAT and reset the zlib output buffer */2794 /* Write the IDAT and reset the zlib output buffer */ 2772 2795 png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); 2773 2796 png_ptr->zstream.next_out = png_ptr->zbuf; 2774 2797 png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; 2775 2798 } 2776 /* repeat until all data has been compressed */2799 /* Repeat until all data has been compressed */ 2777 2800 } while (png_ptr->zstream.avail_in); 2778 2801 2779 /* swap the current and previous rows */2802 /* Swap the current and previous rows */ 2780 2803 if (png_ptr->prev_row != NULL) 2781 2804 { … … 2787 2810 } 2788 2811 2789 /* finish row - updates counters and flushes zlib if last row */2812 /* Finish row - updates counters and flushes zlib if last row */ 2790 2813 png_write_finish_row(png_ptr); 2791 2814 -
trunk/src/3rdparty/libpng/scripts/CMakeLists.txt
r2 r561 1 2 project(PNG)1 project(PNG C) 2 cmake_minimum_required(VERSION 2.4.3) 3 3 4 4 # 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 6 9 7 10 set(PNGLIB_MAJOR 1) 8 11 set(PNGLIB_MINOR 2) 9 set(PNGLIB_RELEASE 29)12 set(PNGLIB_RELEASE 40) 10 13 set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) 11 14 set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}) 12 15 16 set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) 17 13 18 # needed packages 14 19 find_package(ZLIB REQUIRED) 20 include_directories(${ZLIB_INCLUDE_DIR}) 21 15 22 if(NOT WIN32) 16 23 find_library(M_LIBRARY … … 21 28 message(STATUS 22 29 "math library 'libm' not found - floating point support disabled") 23 endif( NOT M_LIBRARY)24 else( NOT WIN32)30 endif() 31 else() 25 32 # not needed on windows 26 33 set(M_LIBRARY "") 27 endif(NOT WIN32) 28 34 endif() 29 35 30 36 # COMMAND LINE OPTIONS 31 option(PNG_SHARED "Build shared lib" YES) 32 option(PNG_STATIC "Build static lib" YES) 37 if(DEFINED PNG_SHARED) 38 option(PNG_SHARED "Build shared lib" ${PNG_SHARED}) 39 else() 40 option(PNG_SHARED "Build shared lib" ON) 41 endif() 42 if(DEFINED PNG_STATIC) 43 option(PNG_STATIC "Build static lib" ${PNG_STATIC}) 44 else() 45 option(PNG_STATIC "Build static lib" ON) 46 endif() 47 33 48 if(MINGW) 34 49 option(PNG_TESTS "Build pngtest" NO) … … 36 51 option(PNG_TESTS "Build pngtest" YES) 37 52 endif(MINGW) 53 38 54 option(PNG_NO_CONSOLE_IO "FIXME" YES) 39 55 option(PNG_NO_STDIO "FIXME" YES) 40 option(PNG_DEBUG "Build with debug output" YES)56 option(PNG_DEBUG "Build with debug output" NO) 41 57 option(PNGARG "FIXME" YES) 42 58 #TODO: … … 55 71 endif("uname_output" MATCHES "^.*i[1-9]86.*$") 56 72 endif(uname_executable) 57 else( NOT WIN32)73 else() 58 74 # this env var is normally only set on win64 59 75 SET(TEXT "ProgramFiles(x86)") … … 61 77 set(png_asm_tmp "ON") 62 78 endif("$ENV{${TEXT}}" STREQUAL "") 63 endif( NOT WIN32)79 endif() 64 80 65 81 # 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}) 82 set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR}) 71 83 72 84 # to distinguish between debug and release lib … … 102 114 endif(MSVC) 103 115 104 add_definitions(-DZLIB_DLL) 116 if(PNG_SHARED OR NOT MSVC) 117 #if building msvc static this has NOT do be defined 118 add_definitions(-DZLIB_DLL) 119 endif() 105 120 106 121 add_definitions(-DLIBPNG_NO_MMX) … … 109 124 if(PNG_CONSOLE_IO_SUPPORTED) 110 125 add_definitions(-DPNG_CONSOLE_IO_SUPPORTED) 111 endif( PNG_CONSOLE_IO_SUPPORTED)126 endif() 112 127 113 128 if(PNG_NO_CONSOLE_IO) 114 129 add_definitions(-DPNG_NO_CONSOLE_IO) 115 endif( PNG_NO_CONSOLE_IO)130 endif() 116 131 117 132 if(PNG_NO_STDIO) 118 133 add_definitions(-DPNG_NO_STDIO) 119 endif( PNG_NO_STDIO)134 endif() 120 135 121 136 if(PNG_DEBUG) 122 137 add_definitions(-DPNG_DEBUG) 123 endif( PNG_DEBUG)138 endif() 124 139 125 140 if(NOT M_LIBRARY AND NOT WIN32) 126 141 add_definitions(-DPNG_NO_FLOATING_POINT_SUPPORTED) 127 endif( NOT M_LIBRARY AND NOT WIN32)142 endif() 128 143 129 144 # NOW BUILD OUR TARGET … … 132 147 if(PNG_SHARED) 133 148 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() 134 153 target_link_libraries(${PNG_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY}) 135 endif(PNG_SHARED) 154 endif() 155 136 156 if(PNG_STATIC) 137 157 # does not work without changing name 138 158 set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static) 139 159 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() 164 endif() 165 141 166 142 167 if(PNG_SHARED AND WIN32) 143 168 set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL) 144 endif( PNG_SHARED AND WIN32)145 146 if(PNG_TESTS )169 endif() 170 171 if(PNG_TESTS AND PNG_SHARED) 147 172 # does not work with msvc due to png_lib_ver issue 148 173 add_executable(pngtest ${pngtest_sources}) 149 174 target_link_libraries(pngtest ${PNG_LIB_NAME}) 150 175 # add_test(pngtest ${PNG_SOURCE_DIR}/pngtest.png) 151 endif( PNG_TESTS)176 endif() 152 177 153 178 … … 169 194 170 195 # SET UP LINKS 171 set_target_properties(${PNG_LIB_NAME} PROPERTIES 172 # VERSION 0.${PNGLIB_RELEASE}.1.2.29 196 if(PNG_SHARED) 197 set_target_properties(${PNG_LIB_NAME} PROPERTIES 198 # VERSION 0.${PNGLIB_RELEASE}.1.2.40 173 199 VERSION 0.${PNGLIB_RELEASE}.0 174 200 SOVERSION 0 175 201 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) 202 endif() 203 if(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() 210 endif() 211 182 212 # 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 213 if(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() 225 endif() 226 227 if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL ) 188 228 install(FILES png.h pngconf.h DESTINATION include) 189 229 install(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) 230 endif() 231 if(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) 238 endif() 196 239 197 240 # what's with libpng.txt and all the extra files? -
trunk/src/3rdparty/libpng/scripts/descrip.mms
r2 r561 1 1 2 2 cc_defs = /inc=$(ZLIBSRC) 3 c_deb = 3 c_deb = 4 4 5 5 .ifdef __DECC__ … … 30 30 31 31 clean : 32 delete *.obj;*,*.exe; *32 delete *.obj;*,*.exe; 33 33 34 34 … … 45 45 pngrio.obj : png.h, pngconf.h 46 46 pngwio.obj : png.h, pngconf.h 47 pngtest.obj : png.h, pngconf.h48 47 pngtrans.obj : png.h, pngconf.h 49 48 pngwrite.obj : png.h, pngconf.h … … 51 50 pngwutil.obj : png.h, pngconf.h 52 51 52 pngtest.obj : png.h, pngconf.h -
trunk/src/3rdparty/libpng/scripts/libpng-config-head.in
r2 r561 5 5 6 6 # 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 8 11 9 12 # Modeled after libxml-config. 10 13 11 version=1.2. 2914 version=1.2.40 12 15 prefix="" 13 16 libdir="" -
trunk/src/3rdparty/libpng/scripts/libpng-config.in
r2 r561 5 5 6 6 # 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 8 11 9 12 # Modeled after libxml-config. … … 15 18 includedir="@includedir@/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@" 16 19 libs="-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@" 17 all_libs="-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ -lz -lm"20 all_libs="-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ @LIBS@" 18 21 I_opts="-I${includedir}" 19 22 L_opts="-L${libdir}" -
trunk/src/3rdparty/libpng/scripts/libpng.icc
r2 r561 2 2 // IBM VisualAge/C++ version 4.0 or later 3 3 // 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 // 5 9 // Notes: 6 10 // All modules are compiled in C mode … … 8 12 // Expected to work with IBM VAC++ 4.0 or later under OS/2 and Win32 9 13 // 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.h11 14 12 15 option incl(searchpath, "../zlib"), opt(level, "2"), -
trunk/src/3rdparty/libpng/scripts/libpng.pc-configure.in
r2 r561 2 2 exec_prefix=@exec_prefix@ 3 3 libdir=@libdir@ 4 includedir=@includedir@/libpng 124 includedir=@includedir@/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ 5 5 6 6 Name: libpng 7 7 Description: Loads and saves PNG files 8 Version: 1.2.29 9 Libs: -L${libdir} -lpng12 8 Version: @PNGLIB_VERSION@ 9 Libs: -L${libdir} -lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ 10 Libs.private: @LIBS@ 10 11 Cflags: -I${includedir} @LIBPNG_NO_MMX@ -
trunk/src/3rdparty/libpng/scripts/libpng.pc.in
r2 r561 6 6 Name: libpng 7 7 Description: Loads and saves PNG files 8 Version: 1.2. 298 Version: 1.2.40 9 9 Libs: -L${libdir} -lpng12 10 10 Cflags: -I${includedir} -
trunk/src/3rdparty/libpng/scripts/makefile.32sunu
r2 r561 4 4 # Copyright (C) 1998 Greg Roelofs 5 5 # 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 7 10 8 11 # Library name: 9 12 LIBNAME=libpng12 10 13 PNGMAJ = 0 11 PNGMIN = 1.2. 2914 PNGMIN = 1.2.40 12 15 PNGVER = $(PNGMAJ).$(PNGMIN) 13 16 -
trunk/src/3rdparty/libpng/scripts/makefile.64sunu
r2 r561 4 4 # Copyright (C) 1998 Greg Roelofs 5 5 # 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 7 10 8 11 # Library name: 9 12 LIBNAME=libpng12 10 13 PNGMAJ = 0 11 PNGMIN = 1.2. 2914 PNGMIN = 1.2.40 12 15 PNGVER = $(PNGMAJ).$(PNGMIN) 13 16 -
trunk/src/3rdparty/libpng/scripts/makefile.acorn
r2 r561 7 7 Linkflags = -aif -c++ -o $@ 8 8 ObjAsmflags = -throwback -NoCache -depend !Depend 9 CMHGflags = 9 CMHGflags = 10 10 LibFileflags = -c -l -o $@ 11 11 Squeezeflags = -o $@ 12 13 12 14 13 # Final targets: -
trunk/src/3rdparty/libpng/scripts/makefile.aix
r2 r561 1 1 # makefile for libpng using gcc (generic, static library) 2 # Copyright (C) 2002, 2006 Glenn Randers-Pehrson2 # Copyright (C) 2002, 2006-2009 Glenn Randers-Pehrson 3 3 # Copyright (C) 2000 Cosmin Truta 4 4 # Copyright (C) 2000 Marc O. Gloor (AIX support added, from makefile.gcc) 5 5 # 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 7 10 8 11 # Location of the zlib library and include files … … 21 24 LIBNAME=libpng12 22 25 PNGMAJ = 0 23 PNGMIN = 1.2. 2926 PNGMIN = 1.2.40 24 27 PNGVER = $(PNGMAJ).$(PNGMIN) 25 28 … … 45 48 CRELEASE = -O2 46 49 LDRELEASE = -s 47 WARNMORE=-W all50 WARNMORE=-W -Wall 48 51 CFLAGS = -I$(ZLIBINC) $(WARNMORE) $(CRELEASE) 49 52 LDFLAGS = -L. -L$(ZLIBLIB) -lpng12 -lz -lm $(LDRELEASE) … … 55 58 56 59 # Variables 57 OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \60 OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \ 58 61 pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \ 59 62 pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) … … 95 98 $(RM_F) *.o $(LIBNAME)$(A) pngtest pngout.png 96 99 97 png$(O): png.h pngconf.h100 png$(O): png.h pngconf.h 98 101 pngerror$(O): png.h pngconf.h 99 pngget$(O): png.h pngconf.h100 pngmem$(O): png.h pngconf.h102 pngget$(O): png.h pngconf.h 103 pngmem$(O): png.h pngconf.h 101 104 pngpread$(O): png.h pngconf.h 102 pngread$(O): png.h pngconf.h103 pngrio$(O): png.h pngconf.h105 pngread$(O): png.h pngconf.h 106 pngrio$(O): png.h pngconf.h 104 107 pngrtran$(O): png.h pngconf.h 105 108 pngrutil$(O): png.h pngconf.h 106 pngset$(O): png.h pngconf.h 107 pngtest$(O): png.h pngconf.h 109 pngset$(O): png.h pngconf.h 108 110 pngtrans$(O): png.h pngconf.h 109 pngwio$(O): png.h pngconf.h111 pngwio$(O): png.h pngconf.h 110 112 pngwrite$(O): png.h pngconf.h 111 113 pngwtran$(O): png.h pngconf.h 112 114 pngwutil$(O): png.h pngconf.h 113 115 116 pngtest$(O): png.h pngconf.h -
trunk/src/3rdparty/libpng/scripts/makefile.amiga
r2 r561 2 2 # makefile for libpng and SAS C V6.5x compiler 3 3 # 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 5 8 # 6 9 # Note: Use #define PNG_READ_BIG_ENDIAN_SUPPORTED in pngconf.h -
trunk/src/3rdparty/libpng/scripts/makefile.atari
r2 r561 2 2 # Copyright (C) 2002 Glenn Randers-Pehrson 3 3 # 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 6 10 # rules for library management 7 11 # -
trunk/src/3rdparty/libpng/scripts/makefile.bc32
r2 r561 11 11 ## Where zlib.h, zconf.h and zlib.lib are 12 12 ZLIB_DIR=..\zlib 13 14 13 15 14 ## Compiler, linker and lib stuff … … 50 49 LDFLAGS=-L$(ZLIB_DIR) -M $(LDEBUG) 51 50 52 53 51 ## Variables 54 52 OBJS = \ … … 88 86 LIBNAME=libpng.lib 89 87 90 91 88 ## Implicit rules 92 89 # Braces let make "batch" calls to the compiler, … … 101 98 $(LD) $(LDFLAGS) $*.obj $(LIBNAME) zlib.lib $(NOEHLIB) 102 99 103 104 100 ## Major targets 105 101 all: libpng pngtest … … 112 108 pngtest 113 109 114 115 110 ## Minor Targets 116 111 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 112 png.obj: png.c png.h pngconf.h 113 pngerror.obj: pngerror.c png.h pngconf.h 114 pngget.obj: pngget.c png.h pngconf.h 115 pngmem.obj: pngmem.c png.h pngconf.h 116 pngpread.obj: pngpread.c png.h pngconf.h 117 pngread.obj: pngread.c png.h pngconf.h 118 pngrio.obj: pngrio.c png.h pngconf.h 119 pngrtran.obj: pngrtran.c png.h pngconf.h 120 pngrutil.obj: pngrutil.c png.h pngconf.h 121 pngset.obj: pngset.c png.h pngconf.h 122 pngtrans.obj: pngtrans.c png.h pngconf.h 123 pngwio.obj: pngwio.c png.h pngconf.h 124 pngwrite.obj: pngwrite.c png.h pngconf.h 125 pngwtran.obj: pngwtran.c png.h pngconf.h 126 pngwutil.obj: pngwutil.c png.h pngconf.h 127 pngtest.obj: pngtest.c png.h pngconf.h 133 128 134 129 $(LIBNAME): $(OBJS) … … 137 132 $(LIBOBJS), libpng 138 133 | 139 140 134 141 135 # Cleanup … … 149 143 -del pngout.png 150 144 151 152 145 # End of makefile for libpng -
trunk/src/3rdparty/libpng/scripts/makefile.beos
r2 r561 1 1 # makefile for libpng on BeOS x86 ELF with gcc 2 2 # modified from makefile.linux by Sander Stoks 3 # Copyright (C) 2002, 2006 Glenn Randers-Pehrson3 # Copyright (C) 2002, 2006, 2008 Glenn Randers-Pehrson 4 4 # Copyright (C) 1999 Greg Roelofs 5 5 # 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 7 10 8 11 # Library name: 9 12 LIBNAME=libpng12 10 13 PNGMAJ = 0 11 PNGMIN = 1.2. 2914 PNGMIN = 1.2.40 12 15 PNGVER = $(PNGMAJ).$(PNGMIN) 13 16 … … 42 45 # On BeOS, -O1 is actually better than -O3. This is a known bug but it's 43 46 # still here in R4.5 44 CFLAGS=-I$(ZLIBINC) -W all -O1 -funroll-loops \47 CFLAGS=-I$(ZLIBINC) -W -Wall -O1 -funroll-loops \ 45 48 $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 46 49 # LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz … … 224 227 pngwutil.o pngwutil.pic.o: png.h pngconf.h 225 228 pngpread.o pngpread.pic.o: png.h pngconf.h 229 226 230 pngtest.o: png.h pngconf.h -
trunk/src/3rdparty/libpng/scripts/makefile.bor
r2 r561 12 12 ## Where zlib.h, zconf.h and zlib_MODEL.lib are 13 13 ZLIB_DIR=..\zlib 14 15 14 16 15 ## Compiler, linker and lib stuff … … 58 57 LDFLAGS=-M -L$(ZLIB_DIR) $(MODEL_ARG) $(LDEBUG) 59 58 59 ## Variables 60 60 61 ## Variables62 61 OBJS = \ 63 62 png.obj \ … … 96 95 LIBNAME=libpng$(MODEL).lib 97 96 97 ## Implicit rules 98 98 99 ## Implicit rules100 99 # Braces let make "batch" calls to the compiler, 101 100 # 2 calls instead of 12; space is important. … … 106 105 $(CC) $(CFLAGS) $(LDFLAGS) $*.c $(LIBNAME) zlib_$(MODEL).lib $(NOEHLIB) 107 106 107 ## Major targets 108 108 109 ## Major targets110 109 all: libpng pngtest 111 110 … … 117 116 pngtest$(MODEL) 118 117 119 120 118 ## Minor Targets 121 119 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 120 png.obj: png.c png.h pngconf.h 121 pngerror.obj: pngerror.c png.h pngconf.h 122 pngget.obj: pngget.c png.h pngconf.h 123 pngmem.obj: pngmem.c png.h pngconf.h 124 pngpread.obj: pngpread.c png.h pngconf.h 125 pngread.obj: pngread.c png.h pngconf.h 126 pngrio.obj: pngrio.c png.h pngconf.h 127 pngrtran.obj: pngrtran.c png.h pngconf.h 128 pngrutil.obj: pngrutil.c png.h pngconf.h 129 pngset.obj: pngset.c png.h pngconf.h 130 pngtrans.obj: pngtrans.c png.h pngconf.h 131 pngwio.obj: pngwio.c png.h pngconf.h 132 pngwrite.obj: pngwrite.c png.h pngconf.h 133 pngwtran.obj: pngwtran.c png.h pngconf.h 134 pngwutil.obj: pngwutil.c png.h pngconf.h 138 135 139 136 $(LIBNAME): $(OBJS) … … 143 140 | 144 141 145 146 142 pngtest$(MODEL).obj: pngtest.c 147 143 $(CC) $(CFLAGS) -opngtest$(MODEL) -c pngtest.c … … 149 145 pngtest$(MODEL).exe: pngtest$(MODEL).obj 150 146 $(LD) $(LDFLAGS) pngtest$(MODEL).obj $(LIBNAME) zlib_$(MODEL).lib $(NOEHLIB) 151 152 147 153 148 # Clean up anything else you want … … 159 154 -del *.map 160 155 161 162 156 # End of makefile for libpng -
trunk/src/3rdparty/libpng/scripts/makefile.cygwin
r2 r561 4 4 # statically linked and one dynamically linked. 5 5 # 6 # Copyright (C) 2002, 2006 , 2007Soren Anderson, Charles Wilson,6 # Copyright (C) 2002, 2006-2008 Soren Anderson, Charles Wilson, 7 7 # and Glenn Randers-Pehrson, based on makefile for linux-elf w/mmx by: 8 8 # Copyright (C) 1998-2000 Greg Roelofs 9 9 # 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 11 14 12 15 # This makefile intends to support building outside the src directory … … 61 64 ### if you don't need thread safety, but want the asm accel 62 65 #CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK \ 63 # $(addprefix -I,$(ZLIBINC)) -W all -O $(ALIGN) -funroll-loops \66 # $(addprefix -I,$(ZLIBINC)) -W -Wall -O $(ALIGN) -funroll-loops \ 64 67 # -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 65 68 ### if you need thread safety and want (minimal) asm accel 66 69 #CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ 67 # -W all -O $(ALIGN) -funroll-loops \70 # -W -Wall -O $(ALIGN) -funroll-loops \ 68 71 # -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 69 72 ### Normal (non-asm) compilation 70 73 CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ 71 -W all -O3 $(ALIGN) -funroll-loops -DPNG_NO_MMX_CODE \74 -W -Wall -O3 $(ALIGN) -funroll-loops -DPNG_NO_MMX_CODE \ 72 75 -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 73 76 … … 75 78 PNGMAJ = 0 76 79 CYGDLL = 12 77 PNGMIN = 1.2. 2980 PNGMIN = 1.2.40 78 81 PNGVER = $(PNGMAJ).$(PNGMIN) 79 82 … … 177 180 $(CC) $(CFLAGS) -c $< -o $@ 178 181 179 pngtest.o: pngtest.c 182 pngtest.o: pngtest.c png.h pngconf.h 180 183 $(CC) $(CFLAGS) -c $< -o $@ 181 184 -
trunk/src/3rdparty/libpng/scripts/makefile.darwin
r2 r561 1 1 # makefile for libpng on Darwin / Mac OS X 2 # Copyright (C) 2002, 2004, 2006 Glenn Randers-Pehrson2 # Copyright (C) 2002, 2004, 2006, 2008 Glenn Randers-Pehrson 3 3 # Copyright (C) 2001 Christoph Pfisterer 4 4 # derived from makefile.linux: 5 5 # Copyright (C) 1998, 1999 Greg Roelofs 6 6 # 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 8 11 9 12 # where "make install" puts libpng.a, libpng12.dylib, png.h and pngconf.h … … 19 22 # Library name: 20 23 LIBNAME = libpng12 21 PNGMAJ = 022 PNGMIN = 1.2. 2924 PNGMAJ = 12 25 PNGMIN = 1.2.40 23 26 PNGVER = $(PNGMAJ).$(PNGMIN) 24 27 … … 39 42 RM_F=/bin/rm -f 40 43 41 # CFLAGS=-I$(ZLIBINC) -W all -O3 -funroll-loops -DPNG_NO_MMX_CODE42 CFLAGS=-I$(ZLIBINC) -W all -O -funroll-loops44 # CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE 45 CFLAGS=-I$(ZLIBINC) -W -Wall -O -funroll-loops 43 46 LDFLAGS=-L. -L$(ZLIBLIB) -lpng12 -lz 44 47 … … 105 108 $(CC) -dynamiclib \ 106 109 -install_name $(LIBPATH)/$(LIBSOMAJ) \ 107 -current_version $(PNGVER) -compatibility_version $(PNGVER)\110 -current_version 0 -compatibility_version 0 \ 108 111 -o $(LIBSOVER) \ 109 112 $(OBJSDLL) -L$(ZLIBLIB) -lz -
trunk/src/3rdparty/libpng/scripts/makefile.dec
r2 r561 2 2 # Copyright (C) 2000-2002, 2006 Glenn Randers-Pehrson 3 3 # 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 5 8 6 9 # Library name: 7 10 PNGMAJ = 0 8 PNGMIN = 1.2. 2911 PNGMIN = 1.2.40 9 12 PNGVER = $(PNGMAJ).$(PNGMIN) 10 13 LIBNAME = libpng12 … … 206 209 pngrtran.o: png.h pngconf.h 207 210 pngrutil.o: png.h pngconf.h 208 pngtest.o: png.h pngconf.h209 211 pngtrans.o: png.h pngconf.h 210 212 pngwrite.o: png.h pngconf.h … … 213 215 pngpread.o: png.h pngconf.h 214 216 217 pngtest.o: png.h pngconf.h -
trunk/src/3rdparty/libpng/scripts/makefile.dj2
r2 r561 1 1 # DJGPP (DOS gcc) makefile for libpng 2 # Copyright (C) 2002 Glenn Randers-Pehrson2 # Copyright (C) 2002, 2006, 2009 Glenn Randers-Pehrson 3 3 # 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 5 8 6 9 # where make install will put libpng.a and png.h … … 48 51 pngrtran.o: png.h pngconf.h 49 52 pngrutil.o: png.h pngconf.h 50 pngtest.o: png.h pngconf.h51 53 pngtrans.o: png.h pngconf.h 52 54 pngwrite.o: png.h pngconf.h … … 54 56 pngwutil.o: png.h pngconf.h 55 57 58 pngtest.o: png.h pngconf.h -
trunk/src/3rdparty/libpng/scripts/makefile.elf
r2 r561 1 1 # 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 3 4 # 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 5 9 6 10 # Modified for Debian by Junichi Uekawa and Josselin Mouette … … 13 17 LIBNAME = libpng12 14 18 PNGMAJ = 0 15 PNGMIN = 1.2. 2919 PNGMIN = 1.2.40 16 20 PNGVER = $(PNGMAJ).$(PNGMIN) 17 21 … … 54 58 # for pgcc version 2.95.1, -O3 is buggy; don't use it. 55 59 56 CFLAGS=-W all -D_REENTRANT -O2 \60 CFLAGS=-W -Wall -D_REENTRANT -O2 \ 57 61 $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 58 62 -
trunk/src/3rdparty/libpng/scripts/makefile.freebsd
r2 r561 1 1 # 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 4 7 5 8 PREFIX?= /usr/local -
trunk/src/3rdparty/libpng/scripts/makefile.gcc
r2 r561 1 1 # makefile for libpng using gcc (generic, static library) 2 # Copyright (C) 2008 Glenn Randers-Pehrson 2 3 # Copyright (C) 2000 Cosmin Truta 3 4 # 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 5 9 6 10 # Location of the zlib library and include files … … 19 23 CRELEASE = -O2 20 24 LDRELEASE = -s 21 #CFLAGS = -W all $(CDEBUG)22 CFLAGS = -W all $(CRELEASE)25 #CFLAGS = -W -Wall $(CDEBUG) 26 CFLAGS = -W -Wall $(CRELEASE) 23 27 #LDFLAGS = $(LDDEBUG) 24 28 LDFLAGS = $(LDRELEASE) … … 31 35 32 36 # 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)37 OBJS = 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) 36 40 37 41 # Targets … … 61 65 $(RM_F) *$(O) libpng$(A) pngtest$(EXE) pngout.png 62 66 63 png$(O): png.h pngconf.h67 png$(O): png.h pngconf.h 64 68 pngerror$(O): png.h pngconf.h 65 pngget$(O): png.h pngconf.h66 pngmem$(O): png.h pngconf.h69 pngget$(O): png.h pngconf.h 70 pngmem$(O): png.h pngconf.h 67 71 pngpread$(O): png.h pngconf.h 68 pngread$(O): png.h pngconf.h69 pngrio$(O): png.h pngconf.h72 pngread$(O): png.h pngconf.h 73 pngrio$(O): png.h pngconf.h 70 74 pngrtran$(O): png.h pngconf.h 71 75 pngrutil$(O): png.h pngconf.h 72 pngset$(O): png.h pngconf.h 73 pngtest$(O): png.h pngconf.h 76 pngset$(O): png.h pngconf.h 74 77 pngtrans$(O): png.h pngconf.h 75 pngwio$(O): png.h pngconf.h78 pngwio$(O): png.h pngconf.h 76 79 pngwrite$(O): png.h pngconf.h 77 80 pngwtran$(O): png.h pngconf.h 78 81 pngwutil$(O): png.h pngconf.h 79 82 83 pngtest$(O): png.h pngconf.h -
trunk/src/3rdparty/libpng/scripts/makefile.gcmmx
r2 r561 1 1 # makefile for libpng.a and libpng12.so on Linux ELF with gcc using MMX 2 2 # assembler code 3 # Copyright 2002, 2006 Greg Roelofs and Glenn Randers-Pehrson3 # Copyright 2002, 2006, 2008 Greg Roelofs and Glenn Randers-Pehrson 4 4 # Copyright 1998-2001 Greg Roelofs 5 5 # 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 7 10 8 11 # CAUTION: Do not use this makefile with gcc versions 2.7.2.2 and earlier. … … 15 18 LIBNAME = libpng12 16 19 PNGMAJ = 0 17 PNGMIN = 1.2. 2920 PNGMIN = 1.2.40 18 21 PNGVER = $(PNGMAJ).$(PNGMIN) 19 22 … … 59 62 # Remove -DPNG_THREAD_UNSAFE_OK if you need thread safety 60 63 ### for generic gcc: 61 CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -W all -O \64 CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -W -Wall -O \ 62 65 $(ALIGN) -funroll-loops \ 63 66 -fomit-frame-pointer # $(WARNMORE) -g -DPNG_DEBUG=5 64 67 ### for gcc 2.95.2 on 686: 65 #CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -W all -O \68 #CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -W -Wall -O \ 66 69 # -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 68 71 ### for gcc 2.7.2.3 on 486 and up: 69 #CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -W all -O \72 #CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -W -Wall -O \ 70 73 # -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 72 75 73 76 LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm -
trunk/src/3rdparty/libpng/scripts/makefile.hp64
r2 r561 1 1 # makefile for libpng, HPUX (10.20 and 11.00) using the ANSI/C product. 2 # Copyright (C) 1999-2002 Glenn Randers-Pehrson2 # Copyright (C) 1999-2002, 2006, 2009 Glenn Randers-Pehrson 3 3 # Copyright (C) 1995 Guy Eric Schalnat, Group 42 4 4 # 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 6 9 7 10 # Where the zlib library and include files are located … … 19 22 LIBNAME = libpng12 20 23 PNGMAJ = 0 21 PNGMIN = 1.2. 2924 PNGMIN = 1.2.40 22 25 PNGVER = $(PNGMAJ).$(PNGMIN) 23 26 … … 228 231 pngrtran.o: png.h pngconf.h 229 232 pngrutil.o: png.h pngconf.h 230 pngtest.o: png.h pngconf.h231 233 pngtrans.o: png.h pngconf.h 232 234 pngwrite.o: png.h pngconf.h … … 234 236 pngwutil.o: png.h pngconf.h 235 237 pngpread.o: png.h pngconf.h 238 239 pngtest.o: png.h pngconf.h -
trunk/src/3rdparty/libpng/scripts/makefile.hpgcc
r2 r561 1 1 # makefile for libpng on HP-UX using GCC with the HP ANSI/C linker. 2 # Copyright (C) 2002, 2006 , 2007Glenn Randers-Pehrson2 # Copyright (C) 2002, 2006-2008 Glenn Randers-Pehrson 3 3 # Copyright (C) 2001, Laurent faillie 4 4 # Copyright (C) 1998, 1999 Greg Roelofs 5 5 # 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 7 10 8 11 # Library name: 9 12 LIBNAME = libpng12 10 13 PNGMAJ = 0 11 PNGMIN = 1.2. 2914 PNGMIN = 1.2.40 12 15 PNGVER = $(PNGMAJ).$(PNGMIN) 13 16 … … 54 57 # for pgcc version 2.95.1, -O3 is buggy; don't use it. 55 58 56 CFLAGS=-I$(ZLIBINC) -W all -O3 -funroll-loops -DPNG_NO_MMX_CODE \59 CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \ 57 60 $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 58 61 #LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm -
trunk/src/3rdparty/libpng/scripts/makefile.hpux
r2 r561 3 3 # Copyright (C) 1995 Guy Eric Schalnat, Group 42 4 4 # 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 6 9 7 10 # Where the zlib library and include files are located … … 19 22 LIBNAME = libpng12 20 23 PNGMAJ = 0 21 PNGMIN = 1.2. 2924 PNGMIN = 1.2.40 22 25 PNGVER = $(PNGMAJ).$(PNGMIN) 23 26 … … 225 228 pngrtran.o: png.h pngconf.h 226 229 pngrutil.o: png.h pngconf.h 227 pngtest.o: png.h pngconf.h228 230 pngtrans.o: png.h pngconf.h 229 231 pngwrite.o: png.h pngconf.h … … 231 233 pngwutil.o: png.h pngconf.h 232 234 pngpread.o: png.h pngconf.h 235 236 pngtest.o: png.h pngconf.h -
trunk/src/3rdparty/libpng/scripts/makefile.ibmc
r2 r561 1 1 # Makefile for libpng (static) 2 2 # IBM C version 3.x for Win32 and OS/2 3 # Copyright (C) 2006 Glenn Randers-Pehrson 3 4 # 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 5 10 # Notes: 6 11 # Derived from makefile.std … … 54 59 $(RM) pngout.png 55 60 56 png$(O): png.h pngconf.h61 png$(O): png.h pngconf.h 57 62 pngerror$(O): png.h pngconf.h 58 pngget$(O): png.h pngconf.h59 pngmem$(O): png.h pngconf.h63 pngget$(O): png.h pngconf.h 64 pngmem$(O): png.h pngconf.h 60 65 pngpread$(O): png.h pngconf.h 61 pngread$(O): png.h pngconf.h62 pngrio$(O): png.h pngconf.h66 pngread$(O): png.h pngconf.h 67 pngrio$(O): png.h pngconf.h 63 68 pngrtran$(O): png.h pngconf.h 64 69 pngrutil$(O): png.h pngconf.h 65 pngset$(O): png.h pngconf.h 66 pngtest$(O): png.h pngconf.h 70 pngset$(O): png.h pngconf.h 67 71 pngtrans$(O): png.h pngconf.h 68 pngwio$(O): png.h pngconf.h72 pngwio$(O): png.h pngconf.h 69 73 pngwrite$(O): png.h pngconf.h 70 74 pngwtran$(O): png.h pngconf.h 71 75 pngwutil$(O): png.h pngconf.h 76 77 pngtest$(O): png.h pngconf.h -
trunk/src/3rdparty/libpng/scripts/makefile.intel
r2 r561 2 2 # Microsoft Visual C++ with Intel C/C++ Compiler 4.0 and later 3 3 4 # Copyright (C) 2006 Glenn Randers-Pehrson 4 5 # Copyright (C) 2000, Pawel Mrochen, based on makefile.msc which is 5 6 # 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 7 11 8 12 # To use, do "nmake /f scripts\makefile.intel" 9 13 14 # ------------------- Intel C/C++ Compiler 4.0 and later ------------------- 10 15 11 16 # Where the zlib library and include files are located … … 26 31 27 32 # -------------------------------------------------------------------------- 28 29 33 30 34 CC=icl -c … … 74 78 $(CC) $(CFLAGS) $*.c $(ERRFILE) 75 79 76 pngtest$(O): png.h pngconf.h77 $(CC) $(CFLAGS) $*.c $(ERRFILE)78 79 80 pngtrans$(O): png.h pngconf.h 80 81 $(CC) $(CFLAGS) $*.c $(ERRFILE) … … 96 97 $(LD) $(LDFLAGS) /OUT:pngtest.exe pngtest.obj libpng.lib $(ZLIBLIB)\zlib.lib 97 98 99 pngtest$(O): png.h pngconf.h 100 $(CC) $(CFLAGS) $*.c $(ERRFILE) 101 98 102 test: pngtest.exe 99 103 pngtest.exe -
trunk/src/3rdparty/libpng/scripts/makefile.knr
r2 r561 1 1 # makefile for libpng 2 # Copyright (C) 2002 Glenn Randers-Pehrson2 # Copyright (C) 2002, 2006, 2009 Glenn Randers-Pehrson 3 3 # 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 5 8 6 9 # This makefile requires the file ansi2knr.c, which you can get … … 59 62 ./pngtest 60 63 61 install: libpng.a 64 install: libpng.a png.h pngconf.h 62 65 -@mkdir $(DESTDIR)$(INCPATH) 63 66 -@mkdir $(DESTDIR)$(INCPATH)/libpng … … 93 96 pngrtran.o: png.h pngconf.h 94 97 pngrutil.o: png.h pngconf.h 95 pngtest.o: png.h pngconf.h96 98 pngtrans.o: png.h pngconf.h 97 99 pngwrite.o: png.h pngconf.h 98 100 pngwtran.o: png.h pngconf.h 99 101 pngwutil.o: png.h pngconf.h 102 103 pngtest.o: png.h pngconf.h -
trunk/src/3rdparty/libpng/scripts/makefile.linux
r2 r561 1 1 # 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 3 4 # 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 5 9 6 10 # Library name: 7 11 LIBNAME = libpng12 8 12 PNGMAJ = 0 9 PNGMIN = 1.2. 2913 PNGMIN = 1.2.40 10 14 PNGVER = $(PNGMAJ).$(PNGMIN) 11 15 … … 48 52 # for pgcc version 2.95.1, -O3 is buggy; don't use it. 49 53 50 CFLAGS=-I$(ZLIBINC) -W all -O3 -funroll-loops -DPNG_NO_MMX_CODE \54 CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \ 51 55 $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 52 56 … … 74 78 DM=$(DESTDIR)$(MANPATH) 75 79 76 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \80 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ 77 81 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ 78 82 pngwtran.o pngmem.o pngerror.o pngpread.o -
trunk/src/3rdparty/libpng/scripts/makefile.mingw
r2 r561 4 4 # statically linked and one dynamically linked. 5 5 # 6 # Built from makefile.cygwin 7 # Copyright (C) 2002, 2006 Soren Anderson, Charles Wilson, 6 # Copyright (C) 2002, 2006, 2008 Soren Anderson, Charles Wilson, 8 7 # and Glenn Randers-Pehrson, based on makefile for linux-elf w/mmx by: 9 8 # Copyright (C) 1998-2000, 2007 Greg Roelofs 10 9 # 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 13 16 14 17 # This makefile intends to support building outside the src directory … … 61 64 ### if you don't need thread safety, but want the asm accel 62 65 #CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK \ 63 # $(addprefix -I,$(ZLIBINC)) -W all -O $(ALIGN) -funroll-loops \66 # $(addprefix -I,$(ZLIBINC)) -W -Wall -O $(ALIGN) -funroll-loops \ 64 67 # -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 65 68 ### if you need thread safety and want (minimal) asm accel 66 69 #CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ 67 # -W all -O $(ALIGN) -funroll-loops \70 # -W -Wall -O $(ALIGN) -funroll-loops \ 68 71 # -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 69 72 ### Normal (non-asm) compilation 70 73 CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ 71 -W all -O3 $(ALIGN) -funroll-loops -DPNG_NO_MMX_CODE \74 -W -Wall -O3 $(ALIGN) -funroll-loops -DPNG_NO_MMX_CODE \ 72 75 -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 73 76 … … 75 78 PNGMAJ = 0 76 79 MINGDLL = 12 77 PNGMIN = 1.2. 2980 PNGMIN = 1.2.40 78 81 PNGVER = $(PNGMAJ).$(PNGMIN) 79 82 … … 285 288 286 289 pngtest.o pngtest.pic.o: png.h pngconf.h pngtest.c 287 288 289 -
trunk/src/3rdparty/libpng/scripts/makefile.mips
r2 r561 2 2 # Copyright (C) Glenn Randers-Pehrson 3 3 # 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 5 8 6 9 # where make install puts libpng.a and png.h … … 77 80 pngrtran.o: png.h pngconf.h 78 81 pngrutil.o: png.h pngconf.h 79 pngtest.o: png.h pngconf.h80 82 pngtrans.o: png.h pngconf.h 81 83 pngwrite.o: png.h pngconf.h 82 84 pngwtran.o: png.h pngconf.h 83 85 pngwutil.o: png.h pngconf.h 86 87 pngtest.o: png.h pngconf.h -
trunk/src/3rdparty/libpng/scripts/makefile.msc
r2 r561 1 1 # makefile for libpng 2 2 # 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 4 9 # Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib 5 10 … … 56 61 $(CC) -c $(CFLAGS) $*.c $(ERRFILE) 57 62 58 pngtest$(O): png.h pngconf.h59 $(CC) -c $(CFLAGS) $*.c $(ERRFILE)60 61 63 pngtrans$(O): png.h pngconf.h 62 64 $(CC) -c $(CFLAGS) $*.c $(ERRFILE) … … 77 79 lib libpng $(OBJS3); 78 80 81 pngtest$(O): png.h pngconf.h 82 $(CC) -c $(CFLAGS) $*.c $(ERRFILE) 83 79 84 pngtest.exe: pngtest.obj libpng.lib 80 85 $(LD) $(LDFLAGS) pngtest.obj,,,libpng.lib ..\zlib\zlib.lib ; -
trunk/src/3rdparty/libpng/scripts/makefile.ne12bsd
r2 r561 3 3 # make includes && make install 4 4 # 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 7 10 8 11 # You should also run makefile.netbsd … … 15 18 LIB= png12 16 19 SHLIB_MAJOR= 0 17 SHLIB_MINOR= 1.2. 2920 SHLIB_MINOR= 1.2.40 18 21 SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ 19 22 pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ … … 24 27 CPPFLAGS+=-I${.CURDIR} 25 28 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: 27 31 # .if ${MACHINE_ARCH} == "i386" 28 32 # CPPFLAGS+=-DPNG_THREAD_UNSAFE_OK -
trunk/src/3rdparty/libpng/scripts/makefile.netbsd
r2 r561 3 3 # make includes && make install 4 4 # 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 7 10 8 11 # You should also run makefile.ne0bsd … … 15 18 LIB= png 16 19 SHLIB_MAJOR= 3 17 SHLIB_MINOR= 1.2. 2920 SHLIB_MINOR= 1.2.40 18 21 SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ 19 22 pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ … … 24 27 CPPFLAGS+=-I${.CURDIR} 25 28 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: 27 31 # .if ${MACHINE_ARCH} == "i386" 28 32 # CPPFLAGS+=-DPNG_THREAD_UNSAFE_OK -
trunk/src/3rdparty/libpng/scripts/makefile.nommx
r2 r561 1 1 # makefile for libpng.a and libpng12.so on Linux ELF with gcc 2 # Copyright (C) 1998, 1999, 2002, 2006 , 2007Greg Roelofs and2 # Copyright (C) 1998, 1999, 2002, 2006-2008 Greg Roelofs and 3 3 # Glenn Randers-Pehrson 4 4 # 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 6 9 7 10 # Library name: 8 11 LIBNAME = libpng12 9 12 PNGMAJ = 0 10 PNGMIN = 1.2. 2913 PNGMIN = 1.2.40 11 14 PNGVER = $(PNGMAJ).$(PNGMIN) 12 15 … … 49 52 # for pgcc version 2.95.1, -O3 is buggy; don't use it. 50 53 51 CFLAGS=-I$(ZLIBINC) -W all -O3 -funroll-loops -DPNG_NO_MMX_CODE \54 CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \ 52 55 $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 53 56 … … 234 237 # DO NOT DELETE THIS LINE -- make depend depends on it. 235 238 236 png.o png.pic.o: png.h pngconf.h237 pngerror.o pngerror.pic.o: png.h pngconf.h238 pngrio.o pngrio.pic.o: png.h pngconf.h239 pngwio.o pngwio.pic.o: png.h pngconf.h240 pngmem.o pngmem.pic.o: png.h pngconf.h241 pngset.o pngset.pic.o: png.h pngconf.h242 pngget.o pngget.pic.o: png.h pngconf.h243 pngread.o pngread.pic.o: png.h pngconf.h244 pngrtran.o pngrtran.pic.o: png.h pngconf.h245 pngrutil.o pngrutil.pic.o: png.h pngconf.h246 pngtrans.o pngtrans.pic.o: png.h pngconf.h247 pngwrite.o pngwrite.pic.o: png.h pngconf.h248 pngwtran.o pngwtran.pic.o: png.h pngconf.h249 pngwutil.o pngwutil.pic.o: png.h pngconf.h250 pngpread.o pngpread.pic.o: png.h pngconf.h251 252 pngtest.o: png.h pngconf.h239 png.o png.pic.o: png.h pngconf.h png.c 240 pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c 241 pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c 242 pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c 243 pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c 244 pngset.o pngset.pic.o: png.h pngconf.h pngset.c 245 pngget.o pngget.pic.o: png.h pngconf.h pngget.c 246 pngread.o pngread.pic.o: png.h pngconf.h pngread.c 247 pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c 248 pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c 249 pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c 250 pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c 251 pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c 252 pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c 253 pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c 254 255 pngtest.o: png.h pngconf.h pngtest.c -
trunk/src/3rdparty/libpng/scripts/makefile.openbsd
r2 r561 1 1 # makefile for libpng 2 2 # 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 5 8 6 9 PREFIX?= /usr/local … … 9 12 10 13 SHLIB_MAJOR= 0 11 SHLIB_MINOR= 1.2. 2914 SHLIB_MINOR= 1.2.40 12 15 13 16 LIB= png … … 18 21 HDRS= png.h pngconf.h 19 22 20 CFLAGS+= -W all21 CPPFLAGS+= -I${.CURDIR} -DPNG_NO_MMX_CODE 23 CFLAGS+= -W -Wall 24 CPPFLAGS+= -I${.CURDIR} -DPNG_NO_MMX_CODE 22 25 23 26 NOPROFILE= Yes -
trunk/src/3rdparty/libpng/scripts/makefile.os2
r2 r561 1 1 # 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 3 6 4 7 # Related files: pngos2.def … … 13 16 -Wmissing-declarations -Wtraditional -Wcast-align \ 14 17 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion 15 CFLAGS=-I$(ZLIBINC) -W all -O6 -funroll-loops -malign-loops=2 \18 CFLAGS=-I$(ZLIBINC) -W -Wall -O6 -funroll-loops -malign-loops=2 \ 16 19 -malign-functions=2 #$(WARNMORE) -g -DPNG_DEBUG=5 17 20 LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lzdll -Zcrtdll -
trunk/src/3rdparty/libpng/scripts/makefile.sco
r2 r561 5 5 # Copyright (C) 1998 Greg Roelofs 6 6 # 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 8 11 9 12 # Library name: 10 13 LIBNAME = libpng12 11 14 PNGMAJ = 0 12 PNGMIN = 1.2. 2915 PNGMIN = 1.2.40 13 16 PNGVER = $(PNGMAJ).$(PNGMIN) 14 17 -
trunk/src/3rdparty/libpng/scripts/makefile.sggcc
r2 r561 2 2 # Copyright (C) 2001-2002, 2006 Glenn Randers-Pehrson 3 3 # 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 5 8 6 9 # Library name: 7 10 LIBNAME=libpng12 8 11 PNGMAJ = 0 9 PNGMIN = 1.2. 2912 PNGMIN = 1.2.40 10 13 PNGVER = $(PNGMAJ).$(PNGMIN) 11 14 … … 213 216 214 217 clean: 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) 219 220 220 221 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO … … 234 235 pngrtran.o: png.h pngconf.h 235 236 pngrutil.o: png.h pngconf.h 236 pngtest.o: png.h pngconf.h237 237 pngtrans.o: png.h pngconf.h 238 238 pngwrite.o: png.h pngconf.h … … 241 241 pngpread.o: png.h pngconf.h 242 242 243 pngtest.o: png.h pngconf.h -
trunk/src/3rdparty/libpng/scripts/makefile.sgi
r2 r561 2 2 # Copyright (C) 2001-2002, 2006, 2007 Glenn Randers-Pehrson 3 3 # 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 5 8 6 9 # Library name: 7 10 LIBNAME=libpng12 8 11 PNGMAJ = 0 9 PNGMIN = 1.2. 2912 PNGMIN = 1.2.40 10 13 PNGVER = $(PNGMAJ).$(PNGMIN) 11 14 … … 237 240 pngrtran.o: png.h pngconf.h 238 241 pngrutil.o: png.h pngconf.h 239 pngtest.o: png.h pngconf.h240 242 pngtrans.o: png.h pngconf.h 241 243 pngwrite.o: png.h pngconf.h … … 244 246 pngpread.o: png.h pngconf.h 245 247 248 pngtest.o: png.h pngconf.h -
trunk/src/3rdparty/libpng/scripts/makefile.so9
r2 r561 2 2 # Updated by Chad Schrock for Solaris 9 3 3 # Contributed by William L. Sebok, based on makefile.linux 4 # Copyright (C) 2002, 2006 Glenn Randers-Pehrson4 # Copyright (C) 2002, 2006, 2008 Glenn Randers-Pehrson 5 5 # Copyright (C) 1998-2001 Greg Roelofs 6 6 # 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 8 11 9 12 # Library name: 10 13 PNGMAJ = 0 11 PNGMIN = 1.2. 2914 PNGMIN = 1.2.40 12 15 PNGVER = $(PNGMAJ).$(PNGMIN) 13 16 LIBNAME = libpng12 … … 48 51 -Wmissing-declarations -Wtraditional -Wcast-align \ 49 52 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion 50 #CFLAGS=-I$(ZLIBINC) -W all -O3 $(WARNMORE) -g -DPNG_DEBUG=5 -DPNG_NO_MMX_CODE53 #CFLAGS=-I$(ZLIBINC) -W -Wall -O3 $(WARNMORE) -g -DPNG_DEBUG=5 -DPNG_NO_MMX_CODE 51 54 CFLAGS=-I$(ZLIBINC) -O3 -DPNG_NO_MMX_CODE 52 55 LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng12 -lz -lm -
trunk/src/3rdparty/libpng/scripts/makefile.solaris
r2 r561 1 1 # makefile for libpng on Solaris 2.x with gcc 2 # Copyright (C) 2004, 2006 , 2007Glenn Randers-Pehrson2 # Copyright (C) 2004, 2006-2008 Glenn Randers-Pehrson 3 3 # Contributed by William L. Sebok, based on makefile.linux 4 4 # Copyright (C) 1998 Greg Roelofs 5 5 # 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 7 10 8 11 # Library name: 9 12 LIBNAME = libpng12 10 13 PNGMAJ = 0 11 PNGMIN = 1.2. 2914 PNGMIN = 1.2.40 12 15 PNGVER = $(PNGMAJ).$(PNGMIN) 13 16 … … 44 47 -Wmissing-declarations -Wtraditional -Wcast-align \ 45 48 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion 46 CFLAGS=-I$(ZLIBINC) -Wall -O \ 47 -DPNG_NO_MMX_CODE; \ 49 CFLAGS=-I$(ZLIBINC) -W -Wall -O -DPNG_NO_MMX_CODE; \ 48 50 # $(WARNMORE) -g -DPNG_DEBUG=5 49 51 LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng12 -lz -lm -
trunk/src/3rdparty/libpng/scripts/makefile.solaris-x86
r2 r561 1 1 # makefile for libpng on Solaris 2.x with gcc 2 # Copyright (C) 2004, 2006 , 2007Glenn Randers-Pehrson2 # Copyright (C) 2004, 2006-2008 Glenn Randers-Pehrson 3 3 # Contributed by William L. Sebok, based on makefile.linux 4 4 # Copyright (C) 1998 Greg Roelofs 5 5 # 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 7 10 8 11 # Library name: 9 12 LIBNAME = libpng12 10 13 PNGMAJ = 0 11 PNGMIN = 1.2. 2914 PNGMIN = 1.2.40 12 15 PNGVER = $(PNGMAJ).$(PNGMIN) 13 16 … … 44 47 -Wmissing-declarations -Wtraditional -Wcast-align \ 45 48 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion 46 CFLAGS=-I$(ZLIBINC) -W all -O \49 CFLAGS=-I$(ZLIBINC) -W -Wall -O \ 47 50 # $(WARNMORE) -g -DPNG_DEBUG=5 48 51 LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng12 -lz -lm -
trunk/src/3rdparty/libpng/scripts/makefile.std
r2 r561 2 2 # Copyright (C) 2002, 2006 Glenn Randers-Pehrson 3 3 # 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 5 8 6 9 # where make install puts libpng.a and png.h … … 84 87 pngrtran.o: png.h pngconf.h 85 88 pngrutil.o: png.h pngconf.h 86 pngtest.o: png.h pngconf.h87 89 pngtrans.o: png.h pngconf.h 88 90 pngwrite.o: png.h pngconf.h … … 91 93 pngpread.o: png.h pngconf.h 92 94 95 pngtest.o: png.h pngconf.h -
trunk/src/3rdparty/libpng/scripts/makefile.sunos
r2 r561 2 2 # Copyright (C) 2002, 2006 Glenn Randers-Pehrson 3 3 # 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 5 8 6 9 # where make install puts libpng.a and png.h … … 89 92 pngrtran.o: png.h pngconf.h 90 93 pngrutil.o: png.h pngconf.h 91 pngtest.o: png.h pngconf.h92 94 pngtrans.o: png.h pngconf.h 93 95 pngwrite.o: png.h pngconf.h … … 96 98 pngpread.o: png.h pngconf.h 97 99 100 pngtest.o: png.h pngconf.h -
trunk/src/3rdparty/libpng/scripts/makefile.vcawin32
r2 r561 1 1 # makefile for libpng 2 # Copyright (C) 2006,2009 Glenn Randers-Pehrson 2 3 # 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 4 9 # Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib 5 10 # To use, do "nmake /f scripts\makefile.vcawin32" 6 11 7 # -------- Microsoft Visual C++ 5.0 and later, usesassembler code --------12 # -------- Microsoft Visual C++ 2.0 and later, no assembler code -------- 8 13 # If you don't want to use assembler (MMX) code, use makefile.vcwin32 instead. 9 14 … … 12 17 LD = link 13 18 AR = lib 14 CFLAGS = - DPNG_USE_PNGVCRD -nologo-MD -O2 -W3 -I..\zlib19 CFLAGS = -nologo -DPNG_USE_PNGVCRD -MD -O2 -W3 -I..\zlib 15 20 LDFLAGS = -nologo 16 21 ARFLAGS = -nologo … … 65 70 $(CC) -c $(CFLAGS) $*.c $(ERRFILE) 66 71 67 pngtest$(O): png.h pngconf.h68 $(CC) -c $(CFLAGS) $*.c $(ERRFILE)69 70 72 pngtrans$(O): png.h pngconf.h 71 73 $(CC) -c $(CFLAGS) $*.c $(ERRFILE) … … 84 86 $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(ERRFILE) 85 87 88 pngtest$(O): png.h pngconf.h 89 $(CC) -c $(CFLAGS) $*.c $(ERRFILE) 90 86 91 pngtest.exe: pngtest$(O) libpng.lib 87 92 $(LD) $(LDFLAGS) -out:$@ pngtest$(O) libpng.lib ..\zlib\zlib.lib $(ERRFILE) -
trunk/src/3rdparty/libpng/scripts/makefile.vcwin32
r2 r561 1 1 # makefile for libpng 2 2 # 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 4 9 # Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib 5 10 # To use, do "nmake /f scripts\makefile.vcwin32" … … 65 70 $(CC) -c $(CFLAGS) $*.c $(ERRFILE) 66 71 67 pngtest$(O): png.h pngconf.h68 $(CC) -c $(CFLAGS) $*.c $(ERRFILE)69 70 72 pngtrans$(O): png.h pngconf.h 71 73 $(CC) -c $(CFLAGS) $*.c $(ERRFILE) … … 84 86 $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(ERRFILE) 85 87 88 pngtest$(O): png.h pngconf.h 89 $(CC) -c $(CFLAGS) $*.c $(ERRFILE) 90 86 91 pngtest.exe: pngtest$(O) libpng.lib 87 92 $(LD) $(LDFLAGS) -out:$@ pngtest$(O) libpng.lib ..\zlib\zlib.lib $(ERRFILE) -
trunk/src/3rdparty/libpng/scripts/makefile.watcom
r2 r561 4 4 # Copyright (C) 2000, Pawel Mrochen, based on makefile.msc which is 5 5 # 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 7 10 8 11 # To use, do "wmake /f scripts\makefile.watcom" -
trunk/src/3rdparty/libpng/scripts/makevms.com
r2 r561 56 56 $ CALL MAKE png.OBJ "cc ''CCOPT' png" - 57 57 png.c png.h pngconf.h 58 $ CALL MAKE pngpread.OBJ "cc ''CCOPT' pngpread" -59 pngpread.c png.h pngconf.h60 58 $ CALL MAKE pngset.OBJ "cc ''CCOPT' pngset" - 61 59 pngset.c png.h pngconf.h … … 65 63 pngread.c png.h pngconf.h 66 64 $ CALL MAKE pngpread.OBJ "cc ''CCOPT' pngpread" - 67 pngpread.c png.h pngconf.h65 pngpread.c png.h pngconf.h 68 66 $ CALL MAKE pngrtran.OBJ "cc ''CCOPT' pngrtran" - 69 67 pngrtran.c png.h pngconf.h -
trunk/src/3rdparty/libpng/scripts/pngos2.def
r2 r561 3 3 ;---------------------------------------- 4 4 5 ; Version 1.2. 295 ; Version 1.2.40 6 6 7 7 LIBRARY PNG -
trunk/src/3rdparty/libpng/scripts/pngw32.def
r2 r561 6 6 7 7 EXPORTS 8 ;Version 1.2. 298 ;Version 1.2.40 9 9 png_build_grayscale_palette @1 10 10 png_check_sig @2 … … 190 190 ; For compatibility with 1.0.7-1.0.11 191 191 ; png_info_init @174 192 ; png_read_init_3, png_info_init_3, and png_write_init_3 are deprecated. 192 193 png_read_init_3 @175 193 194 png_write_init_3 @176 -
trunk/src/3rdparty/libpng/scripts/smakefile.ppc
r2 r561 2 2 # makefile for libpng and SAS C V6.58/7.00 PPC compiler 3 3 # 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 5 8 6 9 CC = scppc
Note:
See TracChangeset
for help on using the changeset viewer.
