Compare commits

...

27 Commits

Author SHA1 Message Date
Glenn Randers-Pehrson
2ad31ae31f Imported from libpng-1.0.9beta5.tar 2009-04-06 16:05:43 -05:00
Glenn Randers-Pehrson
f6b4f45c7e Imported from libpng-1.0.9beta4.tar 2009-04-06 16:05:41 -05:00
Glenn Randers-Pehrson
d56aca7104 Imported from libpng-1.0.9beta3.tar 2009-04-06 16:05:39 -05:00
Glenn Randers-Pehrson
f5ed0e130c Imported from libpng-1.0.9beta2.tar 2009-04-06 16:05:37 -05:00
Glenn Randers-Pehrson
fbbb5ecb52 Imported from libpng-1.0.9beta10.tar 2009-04-06 16:05:35 -05:00
Glenn Randers-Pehrson
5e5c1e1f56 Imported from libpng-1.0.9beta1.tar 2009-04-06 16:05:33 -05:00
Glenn Randers-Pehrson
32fc5ceb91 Imported from libpng-1.0.8.tar 2009-04-06 16:05:31 -05:00
Glenn Randers-Pehrson
4766a244b2 Imported from libpng-1.0.8rc1.tar 2009-04-06 16:05:29 -05:00
Glenn Randers-Pehrson
a4d54bdb4a Imported from libpng-1.0.8beta4.tar 2009-04-06 16:05:28 -05:00
Glenn Randers-Pehrson
ff9c947a1a Imported from libpng-1.0.8beta3.tar 2009-04-06 16:05:26 -05:00
Glenn Randers-Pehrson
15dac0b14e Imported from libpng-1.0.8beta2.tar 2009-04-06 16:05:24 -05:00
Glenn Randers-Pehrson
316f97a063 Imported from libpng-1.0.8beta1.tar 2009-04-06 16:05:23 -05:00
Glenn Randers-Pehrson
3d5a520610 Imported from libpng-1.0.7.tar 2009-04-06 16:05:21 -05:00
Glenn Randers-Pehrson
98b0ff4998 Imported from libpng-1.0.7rc2.tar 2009-04-06 16:05:19 -05:00
Glenn Randers-Pehrson
1394480f4b Imported from libpng-1.0.7beta18.tar 2009-04-06 16:05:18 -05:00
Glenn Randers-Pehrson
1f2d559f70 Imported from libpng-1.0.7rc1.tar 2009-04-06 16:05:16 -05:00
Glenn Randers-Pehrson
db66d44801 Imported from libpng-1.0.7beta17.tar 2009-04-06 16:05:14 -05:00
Glenn Randers-Pehrson
d436672048 Imported from libpng-1.0.7beta16.tar 2009-04-06 16:05:13 -05:00
Glenn Randers-Pehrson
104622bebb Imported from libpng-1.0.7beta15.tar 2009-04-06 16:05:11 -05:00
Glenn Randers-Pehrson
fc4a143ec6 Imported from libpng-1.0.7beta14.tar 2009-04-06 16:05:09 -05:00
Glenn Randers-Pehrson
ec61c23d56 Imported from libpng-1.0.7beta13.tar 2009-04-06 16:05:08 -05:00
Glenn Randers-Pehrson
1ef65b6742 Imported from libpng-1.0.7beta12.tar 2009-04-06 16:05:07 -05:00
Glenn Randers-Pehrson
752945701e Imported from libpng-1.0.7beta11.tar 2009-04-06 16:05:05 -05:00
Glenn Randers-Pehrson
98c9d73605 Imported from libpng-1.0.6j.tar 2009-04-06 16:05:04 -05:00
Glenn Randers-Pehrson
6942d53c25 Imported from libpng-1.0.6i.tar 2009-04-06 16:05:02 -05:00
Glenn Randers-Pehrson
326320e5a9 Imported from libpng-1.0.6h.tar 2009-04-06 16:05:01 -05:00
Glenn Randers-Pehrson
228bd390ac Imported from libpng-1.0.6g.tar 2009-04-06 16:04:59 -05:00
122 changed files with 20735 additions and 3113 deletions

View File

@@ -1,36 +1,40 @@
Libpng 1.0.6f - April 14, 2000 Libpng 1.0.9beta5 - December 15, 2000
This is not intended to be a public release. It will be replaced This is a public release of libpng, intended for use in production codes.
within a few weeks by a public version or by another test version.
Changes since the last public release (1.0.6): Changes since the last public release (1.0.8):
version 1.0.6d [April 8, 2000] Fixed typo in scripts/makefile.hpux
Changed sprintf() to strcpy() in png_write_sCAL_s() to work without STDIO Fixed seqence-point bug in contrib/pngminus/png2pnm (Martin Zinser)
Added data_length parameter to png_decompress_chunk() function Updated makevms.com in scripts and contrib/* and contrib/* (Martin Zinser)
Revised documentation to remove reference to abandoned png_free_chnk functions Changed "cdrom.com" in documentation to "libpng.org"
Fixed an error in png_rgb_to_gray_fixed() Revised pnggccrd.c to get it all working, and updated makefile.gcmmx (Greg).
Revised example.c, usage of png_destroy_write_struct(). Changed type of "params" from voidp to png_voidp in png_read|write_png().
Renamed makefile.ibmvac3 to makefile.ibmc, added libpng.icc IBM project file Added MNG_EXTENSIONS_SUPPORTED macro and support for some proposed MNG
Added a check for info_ptr->free_me&PNG_FREE_TEXT when free'ing text in png.c features, for testing purposes.
Simplify png_sig_bytes() function to remove use of non-ISO-C strdup(). Make sure PNGAPI and PNG_IMPEXP are defined in pngconf.h.
version 1.0.6f [April 14, 2000] Revised the 3 instances of WRITEFILE in pngtest.c.
Added png_data_freer() function. Updated png.rc in dll/msvc project
In the code that checks for over-length tRNS chunks, added check of Revised makefile.dec to define and use LIBPATH and INCPATH
info_ptr->num_trans as well as png_ptr->num_trans (Matthias Benckmann) Increased size of global png_libpng_ver[] array from 12 to 18 chars.
Minor revisions of libpng.txt/libpng.3. Made global png_libpng_ver[], png_sig[] and png_pass_*[] arrays const.
Check for existing data and free it if the free_me flag is set, in png_set_*() Removed duplicate png_crc_finish() from png_handle_bKGD() function.
and png_handle_*(). Added a warning when application calls png_read_update_info() multiple times.
Only define PNG_WEIGHTED_FILTERS_SUPPORTED when PNG_FLOATING_POINT_SUPPORTED Revised makefile.cygwin
is defined. Fixed bugs in iCCP support in pngrutil.c and pngwutil.c.
Changed several instances of PNG_NO_CONSOLE_ID to PNG_NO_STDIO in pngrutil.c Replaced png_set_empty_plte_permitted() with png_permit_mng_features().
and mentioned the purposes of the two macros in libpng.txt/libpng.3. Relocated "msvc" and "wince" project subdirectories into "projects"
subdirectory and added projects/borland project subdirectory.
Send comments/corrections/commendations to Set VS_FF_PRERELEASE and VS_FF_PATCHED flags in msvc/png.rc when appropriate.
png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu Add error message in png_set_compression_buffer_size() when malloc fails.
Revised PNG_LIBPNG_BUILD_TYPE macro in png.h, used in the msvc project.
Glenn R-P Removed the png_flush() in pngwrite.c that crashes some applications
that don't set png_output_flush_fn.
Added makefile.macosx and makefile.aix to scripts directory.
Change png_chunk_warning to png_warning in png_check_keyword().
Increased the first part of msg buffer from 16 to 18 in png_chunk_error().
Added support for filter method 64 (for PNG datastreams embedded in MNG)
Send comments/corrections/commendations to Send comments/corrections/commendations to
png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu

176
CHANGES
View File

@@ -123,6 +123,7 @@ version 0.90 [January, 1997]
- all chunk handling routines have the same prototypes, so we will - all chunk handling routines have the same prototypes, so we will
be able to handle all chunks via a callback mechanism be able to handle all chunks via a callback mechanism
try to fix Linux "setjmp" buffer size problems try to fix Linux "setjmp" buffer size problems
removed png_large_malloc, png_large_free, and png_realloc functions.
version 0.95 [March, 1997] version 0.95 [March, 1997]
fixed bug in pngwutil.c allocating "up_row" twice and "avg_row" never fixed bug in pngwutil.c allocating "up_row" twice and "avg_row" never
fixed bug in PNG file signature compares when start != 0 fixed bug in PNG file signature compares when start != 0
@@ -259,6 +260,7 @@ version 0.99h [March 6, 1998, evening]
Minor changes to previous minor changes to pngtest.c Minor changes to previous minor changes to pngtest.c
Changed PNG_READ_NOT_FULLY_SUPPORTED to PNG_READ_TRANSFORMS_NOT_SUPPORTED Changed PNG_READ_NOT_FULLY_SUPPORTED to PNG_READ_TRANSFORMS_NOT_SUPPORTED
and added PNG_PROGRESSIVE_READ_NOT_SUPPORTED macro and added PNG_PROGRESSIVE_READ_NOT_SUPPORTED macro
Added user transform capability
version 1.00 [March 7, 1998] version 1.00 [March 7, 1998]
Changed several typedefs in pngrutil.c Changed several typedefs in pngrutil.c
Added makefile.wat (Pawel Mrochen), updated makefile.tc3 (Willem van Schaik) Added makefile.wat (Pawel Mrochen), updated makefile.tc3 (Willem van Schaik)
@@ -377,7 +379,7 @@ version 1.0.2a [December 30, 1998]
Changed "ln -sf" to "ln -s -f" in makefile.s2x, makefile.lnx, and makefile.sco. Changed "ln -sf" to "ln -s -f" in makefile.s2x, makefile.lnx, and makefile.sco.
Removed lines after Dynamic Dependencies" in makefile.aco . Removed lines after Dynamic Dependencies" in makefile.aco .
Revised makefile.dec to make a shared library (Jeremie Petit). Revised makefile.dec to make a shared library (Jeremie Petit).
Removed trailing blanks from all files. Removed trailing blanks from all files.
version 1.0.2a [January 6, 1999] version 1.0.2a [January 6, 1999]
Removed misplaced #endif and #ifdef PNG_NO_EXTERN near the end of png.h Removed misplaced #endif and #ifdef PNG_NO_EXTERN near the end of png.h
Added "if" tests to silence complaints about unused png_ptr in png.h and png.c Added "if" tests to silence complaints about unused png_ptr in png.h and png.c
@@ -390,7 +392,7 @@ version 1.0.3 [January 14, 1999]
version 1.0.3a [August 12, 1999] version 1.0.3a [August 12, 1999]
Added check for PNG_READ_INTERLACE_SUPPORTED in pngread.c; issue a warning Added check for PNG_READ_INTERLACE_SUPPORTED in pngread.c; issue a warning
if an attempt is made to read an interlaced image when it's not supported. if an attempt is made to read an interlaced image when it's not supported.
Added check if png_ptr->trans is defined before free'ing it in pngread.c Added check if png_ptr->trans is defined before freeing it in pngread.c
Modified the Y2K statement to include versions back to version 0.71 Modified the Y2K statement to include versions back to version 0.71
Fixed a bug in the check for valid IHDR bit_depth/color_types in pngrutil.c Fixed a bug in the check for valid IHDR bit_depth/color_types in pngrutil.c
Modified makefile.wat (added -zp8 flag, ".symbolic", changed some comments) Modified makefile.wat (added -zp8 flag, ".symbolic", changed some comments)
@@ -667,7 +669,7 @@ version 1.0.6d [April 7, 2000]
Fixed an error in png_rgb_to_gray_fixed() Fixed an error in png_rgb_to_gray_fixed()
Revised example.c, usage of png_destroy_write_struct(). Revised example.c, usage of png_destroy_write_struct().
Renamed makefile.ibmvac3 to makefile.ibmc, added libpng.icc IBM project file Renamed makefile.ibmvac3 to makefile.ibmc, added libpng.icc IBM project file
Added a check for info_ptr->free_me&PNG_FREE_TEXT when free'ing text in png.c Added a check for info_ptr->free_me&PNG_FREE_TEXT when freeing text in png.c
Simplify png_sig_bytes() function to remove use of non-ISO-C strdup(). Simplify png_sig_bytes() function to remove use of non-ISO-C strdup().
version 1.0.6e [April 9, 2000] version 1.0.6e [April 9, 2000]
Added png_data_freer() function. Added png_data_freer() function.
@@ -687,6 +689,174 @@ version 1.0.6f [April 14, 2000]
Removed superfluous prototype for png_set_itxt from png.h Removed superfluous prototype for png_set_itxt from png.h
Removed "else" from pngread.c, after png_error(), and changed "0" to "length". Removed "else" from pngread.c, after png_error(), and changed "0" to "length".
Changed several png_errors about malformed ancillary chunks to png_warnings. Changed several png_errors about malformed ancillary chunks to png_warnings.
version 1.0.6g [April 24, 2000]
Added png_pass-* arrays to pnggccrd.c when PNG_USE_LOCAL_ARRAYS is defined.
Relocated paragraph about png_set_background() in libpng.3/libpng.txt
and other revisions (Matthias Benckmann)
Relocated info_ptr->free_me, png_ptr->free_me, and other info_ptr and
png_ptr members to restore binary compatibility with libpng-1.0.5
(breaks compatibility with libpng-1.0.6).
version 1.0.6h [April 24, 2000]
Changed shared library so-number pattern from 2.x.y.z to xy.z (this builds
libpng.so.10 & libpng.so.10.6h instead of libpng.so.2 & libpng.so.2.1.0.6h)
This is a temporary change for test purposes.
version 1.0.6i [May 2, 2000]
Rearranged some members at the end of png_info and png_struct, to put
unknown_chunks_num and free_me within the original size of the png_structs
and free_me, png_read_user_fn, and png_free_fn within the original png_info,
because some old applications allocate the structs directly instead of
using png_create_*().
Added documentation of user memory functions in libpng.txt/libpng.3
Modified png_read_png so that it will use user_allocated row_pointers
if present, unless free_me directs that it be freed, and added description
of the use of png_set_rows() and png_get_rows() in libpng.txt/libpng.3.
Added PNG_LEGACY_SUPPORTED macro, and #ifdef out all new (since version
1.00) members of png_struct and png_info, to regain binary compatibility
when you define this macro. Capabilities lost in this event
are user transforms (new in version 1.0.0),the user transform pointer
(new in version 1.0.2), rgb_to_gray (new in 1.0.5), iCCP, sCAL, sPLT,
the high-level interface, and unknown chunks support (all new in 1.0.6).
This was necessary because of old applications that allocate the structs
directly as authors were instructed to do in libpng-0.88 and earlier,
instead of using png_create_*().
Added modes PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT which
can be used to detect codes that directly allocate the structs, and
code to check these modes in png_read_init() and png_write_init() and
generate a libpng error if the modes aren't set and PNG_LEGACY_SUPPORTED
was not defined.
Added makefile.intel and updated makefile.watcom (Pawel Mrochen)
version 1.0.6j [May 3, 2000]
Overloaded png_read_init() and png_write_init() with macros that convert
calls to png_read_init_2() or png_write_init_2() that check the version
and structure sizes.
version 1.0.7beta11 [May 7, 2000]
Removed the new PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT modes
which are no longer used.
Eliminated the three new members of png_text when PNG_NO_iTXt_SUPPORTED
or PNG_LEGACY_SUPPORTED is defined.
Made PNG_NO_ITXT_SUPPORTED the default setting, to avoid memory overrun
when old applications fill the info_ptr->text structure directly.
Added PNGAPI macro, and added it to the definitions of all exported functions.
Relocated version macro definitions ahead of the includes of zlib.h and
pngconf.h in png.h.
version 1.0.7beta12 [May 12, 2000]
Revised pngset.c to avoid a problem with expanding the png_debug macro.
Deleted some extraneous defines from pngconf.h
Made PNG_NO_CONSOLE_IO the default condition when PNG_BUILD_DLL is defined.
Use MSC _RPTn debugging instead of fprintf if _MSC_VER is defined.
Added png_access_version_number() function.
Check for mask&PNG_FREE_CHNK (for TEXT, SCAL, PCAL) in png_free_data().
Expanded libpng.3/libpng.txt information about png_data_freer().
version 1.0.7beta14 [May 17, 2000] (beta13 was not published)
Changed pnggccrd.c and pngvcrd.c to handle bad adaptive filter types as
warnings instead of errors, as pngrutil.c does.
Set the PNG_INFO_IDAT valid flag in png_set_rows() so png_write_png()
will actually write IDATs.
Made the default PNG_USE_LOCAL_ARRAYS depend on PNG_DLL instead of WIN32.
Make png_free_data() ignore its final parameter except when freeing data
that can have multiple instances (text, sPLT, unknowns).
Fixed a new bug in png_set_rows().
Removed info_ptr->valid tests from png_free_data(), as in version 1.0.5.
Added png_set_invalid() function.
Fixed incorrect illustrations of png_destroy_write_struct() in example.c.
version 1.0.7beta15 [May 30, 2000]
Revised the deliberately erroneous Linux setjmp code in pngconf.h to produce
fewer error messages.
Rearranged checks for Z_OK to check the most likely path first in pngpread.c
and pngwutil.c.
Added checks in pngtest.c for png_create_*() returning NULL, and mentioned
in libpng.txt/libpng.3 the need for applications to check this.
Changed names of png_default_*() functions in pngtest to pngtest_*().
Changed return type of png_get_x|y_offset_*() from png_uint_32 to png_int_32.
Fixed some bugs in the unused PNG_INCH_CONVERSIONS functions in pngget.c
Set each pointer to NULL after freeing it in png_free_data().
Worked around a problem in pngconf.h; AIX's strings.h defines an "index"
macro that conflicts with libpng's png_color_16.index. (Dimitri Papadapoulos)
Added "msvc" directory with MSVC++ project files (Simon-Pierre Cadieux).
version 1.0.7beta16 [June 4, 2000]
Revised the workaround of AIX string.h "index" bug.
Added a check for overlength PLTE chunk in pngrutil.c.
Added PNG_NO_POINTER_INDEXING macro to use array-indexing instead of pointer
indexing in pngrutil.c and pngwutil.c to accommodate a buggy compiler.
Added a warning in png_decompress_chunk() when it runs out of data, e.g.
when it tries to read an erroneous PhotoShop iCCP chunk.
Added PNG_USE_DLL macro.
Revised the copyright/disclaimer/license notice.
Added contrib/msvctest directory
version 1.0.7rc1 [June 9, 2000]
Corrected the definition of PNG_TRANSFORM_INVERT_ALPHA (0x0400 not 0x0200)
Added contrib/visupng directory (Willem van Schaik)
version 1.0.7beta18 [June 23, 2000]
Revised PNGAPI definition, and pngvcrd.c to work with __GCC__
and do not redefine PNGAPI if it is passed in via a compiler directive.
Revised visupng/PngFile.c to remove returns from within the Try block.
Removed leading underscores from "_PNG_H" and "_PNG_SAVE_BSD_SOURCE" macros.
Updated contrib/visupng/cexcept.h to version 1.0.0.
Fixed bugs in pngwrite.c and pngwutil.c that prevented writing iCCP chunks.
version 1.0.7rc2 [June 28, 2000]
Updated license to include disclaimers required by UCITA.
Fixed "DJBPP" typo in pnggccrd.c introduced in beta18.
version 1.0.7 [July 1, 2000]
Revised the definition of "trans_values" in libpng.3/libpng.txt
version 1.0.8beta1 [July 8, 2000]
Added png_free(png_ptr, key) two places in pngpread.c to stop memory leaks.
Changed PNG_NO_STDIO to PNG_NO_CONSOLE_IO, several places in pngrutil.c and
pngwutil.c.
Changed PNG_EXPORT_VAR to use PNG_IMPEXP, in pngconf.h.
Removed unused "#include <assert.h>" from png.c
Added WindowsCE support.
Revised pnggccrd.c to work with gcc-2.95.2 and in the Cygwin environment.
version 1.0.8beta2 [July 10, 2000]
Added project files to the wince directory and made further revisions
of pngtest.c, pngrio.c, and pngwio.c in support of WindowsCE.
version 1.0.8beta3 [July 11, 2000]
Only set the PNG_FLAG_FREE_TRNS or PNG_FREE_TRNS flag in png_handle_tRNS()
for indexed-color input files to avoid potential double-freeing trans array
under some unusual conditions; problem was introduced in version 1.0.6f.
Further revisions to pngtest.c and files in the wince subdirectory.
version 1.0.8beta4 [July 14, 2000]
Added the files pngbar.png and pngbar.jpg to the distribution.
Added makefile.cygwin, and cygwin support in pngconf.h
Added PNG_NO_ZALLOC_ZERO macro (makes png_zalloc skip zeroing memory)
version 1.0.8rc1 [July 16, 2000]
Revised png_debug() macros and statements to eliminate compiler warnings.
version 1.0.8 [July 24, 2000]
Added png_flush() in pngwrite.c, after png_write_IEND().
Updated makefile.hpux to build a shared library.
version 1.0.9beta1 [November 10, 2000]
Fixed typo in scripts/makefile.hpux
Updated makevms.com in scripts and contrib/* and contrib/* (Martin Zinser)
Fixed seqence-point bug in contrib/pngminus/png2pnm (Martin Zinser)
Changed "cdrom.com" in documentation to "libpng.org"
Revised pnggccrd.c to get it all working, and updated makefile.gcmmx (Greg).
Changed type of "params" from voidp to png_voidp in png_read|write_png().
Make sure PNGAPI and PNG_IMPEXP are defined in pngconf.h.
Revised the 3 instances of WRITEFILE in pngtest.c.
Relocated "msvc" and "wince" project subdirectories into "dll" subdirectory.
Updated png.rc in dll/msvc project
Revised makefile.dec to define and use LIBPATH and INCPATH
Increased size of global png_libpng_ver[] array from 12 to 18 chars.
Made global png_libpng_ver[], png_sig[] and png_pass_*[] arrays const.
Removed duplicate png_crc_finish() from png_handle_bKGD() function.
Added a warning when application calls png_read_update_info() multiple times.
Revised makefile.cygwin
Fixed bugs in iCCP support in pngrutil.c and pngwutil.c.
Replaced png_set_empty_plte_permitted() with png_permit_mng_features().
version 1.0.9beta2 [November 19, 2000]
Renamed the "dll" subdirectory "projects".
Added borland project files to "projects" subdirectory.
Set VS_FF_PRERELEASE and VS_FF_PATCHED flags in msvc/png.rc when appropriate.
Add error message in png_set_compression_buffer_size() when malloc fails.
version 1.0.9beta3 [November 23, 2000]
Revised PNG_LIBPNG_BUILD_TYPE macro in png.h, used in the msvc project.
Removed the png_flush() in pngwrite.c that crashes some applications
that don't set png_output_flush_fn.
Added makefile.macosx and makefile.aix to scripts directory.
version 1.0.9beta4 [December 1, 2000]
Change png_chunk_warning to png_warning in png_check_keyword().
Increased the first part of msg buffer from 16 to 18 in png_chunk_error().
version 1.0.9beta5 [December 15, 2000]
Added support for filter method 64 (for PNG datastreams embedded in MNG)
Send comments/corrections/commendations to Send comments/corrections/commendations to
png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu

38
INSTALL
View File

@@ -1,5 +1,5 @@
Installing libpng version 1.0.6f - April 14, 2000 Installing libpng version 1.0.9beta5 - December 15, 2000
Before installing libpng, you must first install zlib. zlib Before installing libpng, you must first install zlib. zlib
can usually be found wherever you got libpng. zlib can be can usually be found wherever you got libpng. zlib can be
@@ -10,7 +10,7 @@ zlib.h and zconf.h include files that correspond to the
version of zlib that's installed. version of zlib that's installed.
You can rename the directories that you downloaded (they You can rename the directories that you downloaded (they
might be called "libpng-1.0.6f" or "lpng106" and "zlib-1.1.3" might be called "libpng-1.0.9beta5" or "lpng109" and "zlib-1.1.3"
or "zlib113") so that you have directories called "zlib" and "libpng". or "zlib113") so that you have directories called "zlib" and "libpng".
Your directory structure should look like this: Your directory structure should look like this:
@@ -23,8 +23,14 @@ Your directory structure should look like this:
*.c *.c
contrib contrib
gregbook gregbook
msvctest
pngminus pngminus
pngsuite pngsuite
visupng
projects
borland
msvc
wince
scripts scripts
makefile.* makefile.*
pngtest.png pngtest.png
@@ -40,28 +46,38 @@ If the line endings in the files look funny, you may wish to get the other
distribution of libpng. It is available in both tar.gz (UNIX style line distribution of libpng. It is available in both tar.gz (UNIX style line
endings) and zip (DOS style line endings) formats. endings) and zip (DOS style line endings) formats.
First enter the zlib directory and follow the instructions in zlib/README. If you are building libpng with MSVC, you can enter the libpng\msvc directory
Then come back here and choose the appropriate makefile.sys in the scripts and follow the instructions in msvc\README.txt. You can build libpng for
directory. WindowsCE by entering the libpng\wince directory and following the
instructions in the README* files.
Else enter the zlib directory and follow the instructions in zlib/README,
then come back here and choose the appropriate makefile.sys in the scripts
directory.
The files that are presently available in the scripts directory The files that are presently available in the scripts directory
include include
makefile.std => Generic UNIX makefile (cc, creates static libpng.a) makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
makefile.linux => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.6f) makefile.linux => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.9beta5)
makefile.gcmmx => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.6f, makefile.gcmmx => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.9beta5,
uses assembler code tuned for Intel MMX platform) uses assembler code tuned for Intel MMX platform)
makefile.gcc => Generic makefile (gcc, creates static libpng.a) makefile.gcc => Generic makefile (gcc, creates static libpng.a)
makefile.knr => Archaic UNIX Makefile that converts files with makefile.knr => Archaic UNIX Makefile that converts files with
ansi2knr (Requires ansi2knr.c from ansi2knr (Requires ansi2knr.c from
ftp://ftp.cs.wisc.edu/ghost) ftp://ftp.cs.wisc.edu/ghost)
makefile.aix => AIX makefile
makefile.cygwin => Cygwin/gcc makefile
makefile.dec => DEC Alpha UNIX makefile makefile.dec => DEC Alpha UNIX makefile
makefile.hpux => HPUX (10.20 and 11.00) makefile makefile.hpux => HPUX (10.20 and 11.00) makefile
makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static) makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static)
makefile.intel => Intel C/C++ version 4.0 and later
libpng.icc => Project file for IBM VisualAge/C++ version 4.0 or later libpng.icc => Project file for IBM VisualAge/C++ version 4.0 or later
makefile.macosx => MACOS X Makefile
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib) makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
makefile.sggcc => Silicon Graphics (gcc, creates libpng.so.2.1.0.6f) makefile.sggcc => Silicon Graphics (gcc, creates libpng.so.2.1.0.9beta5)
makefile.sunos => Sun makefile makefile.sunos => Sun makefile
makefile.solaris => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.6f) makefile.solaris => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.9beta5)
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
makefile.mips => MIPS makefile makefile.mips => MIPS makefile
makefile.acorn => Acorn makefile makefile.acorn => Acorn makefile
@@ -114,5 +130,5 @@ put the library in its final resting place (if you want to
do that, run "make install" in the zlib directory first if necessary). do that, run "make install" in the zlib directory first if necessary).
Further information can be found in the README and libpng.txt Further information can be found in the README and libpng.txt
files, in the individual makefiles, in png.h, and the manual pages files, in the individual makefiles, in png.h, in the README files in
libpng.3 and png.5. subdirectories of the LIB directory, and the manual pages libpng.3 and png.5.

View File

@@ -1,47 +1,39 @@
Known bugs and suggested enhancements in libpng-1.0.6 Known bugs and suggested enhancements in libpng-1.0.8
1. April 1, 2000 -- BUG 1: November 28, 2000 -- BUG -- buffer overflow in png_chunk_warning
Under some circumstances old applications that make direct access to A buffer overflow occurs in png_chunk_warning() because 16 bytes
the info_ptr->text and its members might free the same memory that are allocated for "[nn][nn][nn][nn]" which requires 18 bytes.
is also free'ed by libpng during the png_destroy_struct process.
Fixed in libpng-1.0.6-patch-03 and libpng-1.0.6d. The PNG_FREE_TEXT flag Status: Fixed in libpng-1.0.9beta4
bit in info_ptr->free_me is now checked to make sure libpng is responsible
for freeing the memory.
2. April 1, 2000 -- BUG 2: November 3, 2000 -- BUG -- incorrect iCCP chunk is written
The non-ISO-C "strdup()" function is used in png.c The compression_type byte in the iCCP chunk written by libpng is
usually incorrect.
STATUS: The function has been simplified and no longer uses strdup() Status: Fixed in libpng-1.0.9beta1
in libpng-1.0.6-patch-03 and libpng-1.0.6d.
3. March 24, 2000 -- BUG 3. October 12, 2000 -- BUG -- pngtest fails
The png_set_rgb_to_gray_fixed() function is setting incorrect weighting The three WRITEFILE calls in pngtest.c are incorrect. They must be
factors. changed to read
STATUS: Fixed in libpng-1.0.6-patch-02 and libpng-1.0.6d. WRITEFILE((png_FILE_p)png_ptr->io_ptr, data, length, check);
WRITEFILE(io_ptr, near_data, length, check);
WRITEFILE(io_ptr, buf, written, err);
4. March 22, 2000 -- BUG 4. August 28, 2000 -- BUG -- pnggccrd.c
There are some printf() and fprintf() statements active in pngwutil.c The interlacing() function has still not been fully converted and
when PNG_NO_STDIO and PNG_sCAL_SUPPORTED are both defined. will not compile under gcc-2.95.2; it is currently ifdef'ed out.
STATUS: Fixed in libpng-1.0.6-patch-01 and libpng-1.0.6d. The strcpy() STATUS: Fixed in libpng-1.0.9. There were also bugs in pngvcrd.c
function is used instead. which have been fixed. The replacement files are available at the
PNG web site (http://www.libpng.org/pub/png).
5. March 22, 2000 -- BUG 5. March 15, 1998 -- OPTIMIZATION -- Kevin Bracey
The length of the iCCP chunk data is calculated incorrectly; because
it can contain zeroes, strlen() doesn't work.
STATUS: Fixed in libpng-1.0.6-patch-01 and libpng-1.0.6d by adding a
data_length parameter to the png_decompress_chunk() function.
6. March 15, 1998 -- OPTIMIZATION -- Kevin Bracey
Loops need to be optimized everywhere Loops need to be optimized everywhere
@@ -53,10 +45,10 @@ Known bugs and suggested enhancements in libpng-1.0.6
Question whether i-- or --i is better. Question whether i-- or --i is better.
STATUS: Under investigation, postponed until after STATUS: Under investigation, postponed until after
libpng-1.1.0. About 160 loops will be turned around libpng-2.0.0. About 160 loops will be turned around
in libpng-1.1.Nn, for testing. in libpng-2.0.x betaxx, for testing.
7. July 4, 1998 -- ENHANCEMENT -- Glenn R-P 6. July 4, 1998 -- ENHANCEMENT -- Glenn R-P
libpng-1.0.5 and earlier transform colors to gamma=1.0 space for libpng-1.0.5 and earlier transform colors to gamma=1.0 space for
merging with background, and then back to the image's gamma. The merging with background, and then back to the image's gamma. The
@@ -68,14 +60,12 @@ Known bugs and suggested enhancements in libpng-1.0.6
STATUS: under development. STATUS: under development.
8. September 1999 -- ENHANCEMENT -- 7. September 1999 -- ENHANCEMENT --
It should be possible to use libpng without floating-point aritmetic. It should be possible to use libpng without floating-point arithmetic.
STATUS: Under investigation, implementation postponed until after STATUS: Under investigation, implementation postponed until after
libpng-1.0.6. The application interface will change because replacements libpng-2.0.0.
for the png_set_gAMA(), png_set_cHRM(), and corresponding png_get_()
functions will be needed.
Much of this was completed in libpng-1.0.6, but gamma compensation Much of this was completed in libpng-1.0.6, but gamma compensation
is not yet done in fixed-point arithmetic. is not yet done in fixed-point arithmetic.

83
LICENSE
View File

@@ -1,29 +1,62 @@
COPYRIGHT NOTICE:
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. This copy of the libpng notices is provided for your convenience. In case of
(libpng versions 0.5, May 1995, through 0.89c, May 1996) any discrepancy between this copy and the notices in the file png.h that is
included in the libpng distribution, the latter shall prevail.
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
If you modify libpng you may insert additional notices immediately following
this sentence.
libpng versions 1.0.7, July 1, 2000, through 1.0.9beta5, December 15, 2000, are
Copyright (c) 2000 Glenn Randers-Pehrson
and are distributed according to the same disclaimer and license as libpng-1.0.6
with the following individuals added to the list of Contributing Authors
Simon-Pierre Cadieux
Eric S. Raymond
Gilles Vollant
and with the following additions to the disclaimer:
There is no warranty against interference with your enjoyment of the
library or against infringement. There is no warranty that our
efforts or the library will fulfill any of your particular purposes
or needs. This library is provided with all faults, and the entire
risk of satisfactory quality, performance, accuracy, and effort is with
the user.
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-0.96,
with the following individuals added to the list of Contributing Authors:
Tom Lane
Glenn Randers-Pehrson
Willem van Schaik
libpng versions 0.89, June 1996, through 0.96, May 1997, are
Copyright (c) 1996, 1997 Andreas Dilger Copyright (c) 1996, 1997 Andreas Dilger
(libpng versions 0.90, December 1996, through 0.96, May 1997) Distributed according to the same disclaimer and license as libpng-0.88,
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson with the following individuals added to the list of Contributing Authors:
(libpng versions 0.97, January 1998, through 1.0.6f, April 14, 2000)
For the purposes of this copyright and license, "Contributing Authors"
is defined as the following set of individuals:
John Bowler John Bowler
Kevin Bracey Kevin Bracey
Sam Bushell Sam Bushell
Andreas Dilger
Magnus Holmgren Magnus Holmgren
Tom Lane
Dave Martindale
Glenn Randers-Pehrson
Eric S. Raymond
Greg Roelofs Greg Roelofs
Tom Tanner
libpng versions 0.5, May 1995, through 0.88, January 1996, are
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
For the purposes of this copyright and license, "Contributing Authors"
is defined as the following set of individuals:
Andreas Dilger
Dave Martindale
Guy Eric Schalnat Guy Eric Schalnat
Paul Schmidt Paul Schmidt
Tom Tanner
Willem van Schaik
Tim Wegner Tim Wegner
The PNG Reference Library is supplied "AS IS". The Contributing Authors The PNG Reference Library is supplied "AS IS". The Contributing Authors
@@ -38,16 +71,13 @@ Permission is hereby granted to use, copy, modify, and distribute this
source code, or portions hereof, for any purpose, without fee, subject source code, or portions hereof, for any purpose, without fee, subject
to the following restrictions: to the following restrictions:
1. The origin of this source code must not be 1. The origin of this source code must not be misrepresented.
misrepresented.
2. Altered versions must be plainly marked as such 2. Altered versions must be plainly marked as such and must not
and must not be misrepresented as being the be misrepresented as being the original source.
original source.
3. This Copyright notice may not be removed or 3. This Copyright notice may not be removed or altered from any
altered from any source or altered source source or altered source distribution.
distribution.
The Contributing Authors and Group 42, Inc. specifically permit, without The Contributing Authors and Group 42, Inc. specifically permit, without
fee, and encourage the use of this source code as a component to fee, and encourage the use of this source code as a component to
@@ -55,17 +85,18 @@ supporting the PNG file format in commercial products. If you use this
source code in a product, acknowledgment is not required but would be source code in a product, acknowledgment is not required but would be
appreciated. appreciated.
A "png_get_copyright" function is available, for convenient use in "about" A "png_get_copyright" function is available, for convenient use in "about"
boxes and the like: boxes and the like:
printf("%s",png_get_copyright(NULL)); printf("%s",png_get_copyright(NULL));
Also, the PNG logo (in PNG format, of course) is supplied in the Also, the PNG logo (in PNG format, of course) is supplied in the
file "pngnow.png". files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
certification mark of the Open Source Initiative. certification mark of the Open Source Initiative.
Glenn Randers-Pehrson Glenn Randers-Pehrson
randeg@alum.rpi.edu randeg@alum.rpi.edu
April 14, 2000 December 15, 2000

27
README
View File

@@ -1,4 +1,4 @@
README for libpng 1.0.6f - April 14, 2000 (shared library 2.1) README for libpng 1.0.9beta5 - December 15, 2000 (shared library 2.1)
See the note about version numbers near the top of png.h See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng. See INSTALL for instructions on how to install libpng.
@@ -148,7 +148,8 @@ Files in this distribution:
pngerror.c => Error/warning message I/O functions pngerror.c => Error/warning message I/O functions
pngget.c => Functions for retrieving info from struct pngget.c => Functions for retrieving info from struct
pngmem.c => Memory handling functions pngmem.c => Memory handling functions
pngnow.png => PNG logo pngbar.png => PNG logo, 88x31
pngnow.png => PNG logo, 98x31
pngpread.c => Progressive reading functions pngpread.c => Progressive reading functions
pngread.c => Read data/helper high-level functions pngread.c => Read data/helper high-level functions
pngrio.c => Lowest-level data read I/O functions pngrio.c => Lowest-level data read I/O functions
@@ -166,29 +167,42 @@ Files in this distribution:
gregbook => source code for PNG reading and writing, from gregbook => source code for PNG reading and writing, from
Greg Roelofs' "PNG: The Definitive Guide", Greg Roelofs' "PNG: The Definitive Guide",
O'Reilly, 1999 O'Reilly, 1999
msvctest => Builds and runs pngtest using a MSVC workspace
pngminus => Simple pnm2png and png2pnm programs pngminus => Simple pnm2png and png2pnm programs
pngsuite => Test images pngsuite => Test images
visupng => Contains a MSVC workspace for VisualPng
projects => Contains project files and workspaces for building DLL
borland => Contains a Borland workspace for building libpng
and zlib
msvc => Contains a Microsoft Visual C++ (MSVC) workspace
for building libpng and zlib
wince => Contains a Microsoft Visual C++ (Windows CD Toolkit)
workspace for building libpng and zlib on WindowsCE
scripts => Directory containing scripts for building libpng: scripts => Directory containing scripts for building libpng:
descrip.mms => VMS makefile for MMS or MMK descrip.mms => VMS makefile for MMS or MMK
makefile.std => Generic UNIX makefile (cc, creates static libpng.a) makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
makefile.linux => Linux/ELF makefile makefile.linux => Linux/ELF makefile
(gcc, creates libpng.so.2.1.0.6f) (gcc, creates libpng.so.2.1.0.9beta5)
makefile.gcmmx => Linux/ELF makefile (gcc, creates makefile.gcmmx => Linux/ELF makefile (gcc, creates
libpng.so.2.1.0.6f, uses assembler code libpng.so.2.1.0.9beta5, uses assembler code
tuned for Intel MMX platform) tuned for Intel MMX platform)
makefile.gcc => Generic makefile (gcc, creates static libpng.a) makefile.gcc => Generic makefile (gcc, creates static libpng.a)
makefile.knr => Archaic UNIX Makefile that converts files with makefile.knr => Archaic UNIX Makefile that converts files with
ansi2knr (Requires ansi2knr.c from ansi2knr (Requires ansi2knr.c from
ftp://ftp.cs.wisc.edu/ghost) ftp://ftp.cs.wisc.edu/ghost)
makefile.aix => AIX makefile
makefile.cygwin => Cygwin/gcc makefile
makefile.dec => DEC Alpha UNIX makefile makefile.dec => DEC Alpha UNIX makefile
makefile.hpux => HPUX (10.20 and 11.00) makefile makefile.hpux => HPUX (10.20 and 11.00) makefile
makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static) makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static)
makefile.intel => Intel C/C++ version 4.0 and later
libpng.icc => Project file, IBM VisualAge/C++ 4.0 or later libpng.icc => Project file, IBM VisualAge/C++ 4.0 or later
makefile.macosx => MACOS X Makefile
makefile.sgi => Silicon Graphics IRIX (cc, creates static lib) makefile.sgi => Silicon Graphics IRIX (cc, creates static lib)
makefile.sggcc => Silicon Graphics (gcc, creates libpng.so.2.1.0.6f) makefile.sggcc => Silicon Graphics (gcc, creates libpng.so.2.1.0.9beta5)
makefile.sunos => Sun makefile makefile.sunos => Sun makefile
makefile.solaris => Solaris 2.X makefile makefile.solaris => Solaris 2.X makefile
(gcc, creates libpng.so.2.1.0.6f) (gcc, creates libpng.so.2.1.0.9beta5)
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
makefile.mips => MIPS makefile makefile.mips => MIPS makefile
makefile.acorn => Acorn makefile makefile.acorn => Acorn makefile
@@ -220,7 +234,6 @@ Good luck, and happy coding.
-Glenn Randers-Pehrson -Glenn Randers-Pehrson
Internet: randeg@alum.rpi.edu Internet: randeg@alum.rpi.edu
Web: http://www.rpi.edu/~randeg/index.html
-Andreas Eric Dilger -Andreas Eric Dilger
Internet: adilger@enel.ucalgary.ca Internet: adilger@enel.ucalgary.ca

3
TODO
View File

@@ -1,6 +1,7 @@
TODO - list of things to do for libpng: TODO - list of things to do for libpng:
Final bug fixes. Final bug fixes.
Improve API by hiding the png_struct and png_info structs.
Finish work on the no-floating-point version (including gamma compensation) Finish work on the no-floating-point version (including gamma compensation)
Better C++ wrapper/full C++ implementation? Better C++ wrapper/full C++ implementation?
Fix problem with C++ and EXTERN "C". Fix problem with C++ and EXTERN "C".
@@ -16,4 +17,4 @@ Better filter selection
(counting huffman bits/precompression? filter inertia? filter costs?). (counting huffman bits/precompression? filter inertia? filter costs?).
Histogram creation. Histogram creation.
Text conversion between different code pages (Latin-1 -> Mac and DOS). Text conversion between different code pages (Latin-1 -> Mac and DOS).
Improve API by hiding the info_ptr. Should we always malloc 2^bit_depth PLTE/tRNS/hIST entries for safety?

View File

@@ -1,13 +1,13 @@
Y2K compliance in libpng: Y2K compliance in libpng:
========================= =========================
April 14, 2000 December 15, 2000
Since the PNG Development group is an ad-hoc body, we can't make Since the PNG Development group is an ad-hoc body, we can't make
an official declaration. an official declaration.
This is your unofficial assurance that libpng from version 0.71 and This is your unofficial assurance that libpng from version 0.71 and
upward through 1.0.6f are Y2K compliant. It is my belief that earlier upward through 1.0.9beta5 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant. versions were also Y2K compliant.
Libpng only has three year fields. One is a 2-byte unsigned integer Libpng only has three year fields. One is a 2-byte unsigned integer

2
configure vendored
View File

@@ -1,5 +1,5 @@
echo " echo "
There is no \"configure\" script for Libpng-1.0.6f. Instead, please There is no \"configure\" script for Libpng-1.0.9beta5. Instead, please
copy the appropriate makefile for your system from the \"scripts\" copy the appropriate makefile for your system from the \"scripts\"
directory. Read the INSTALL file for more details. directory. Read the INSTALL file for more details.
" "

View File

@@ -40,7 +40,7 @@ ZLIB = /usr/local/lib/libz.a # statically linked against zlib
#XINC = -I/usr/include/X11 # old-style, stock X distributions #XINC = -I/usr/include/X11 # old-style, stock X distributions
#XLIB = -L/usr/lib/X11 -lX11 #XLIB = -L/usr/lib/X11 -lX11
#XINC = -I/usr/openwin/include/X11 # Sun workstations (OpenWindows) #XINC = -I/usr/openwin/include # Sun workstations (OpenWindows)
#XLIB = -L/usr/openwin/lib -lX11 #XLIB = -L/usr/openwin/lib -lX11
XINC = -I/usr/X11R6/include # new X distributions (XFree86, etc.) XINC = -I/usr/X11R6/include # new X distributions (XFree86, etc.)
XLIB = -L/usr/X11R6/lib -lX11 XLIB = -L/usr/X11R6/lib -lX11

View File

@@ -1,104 +0,0 @@
# Sample makefile for rpng-x / rpng2-x / wpng using gcc and make.
# Greg Roelofs
# Last modified: 28 February 2000
#
# The programs built by this makefile are described in the book,
# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and
# Associates, 1999). Go buy a copy, eh? Buy some for friends
# and family, too. (Not that this is a blatant plug or anything.)
#
# Invoke this makefile from a shell prompt in the usual way; for example:
#
# make -f Makefile.unx
#
# This makefile assumes libpng and zlib have already been built or downloaded
# and are both installed in /usr/local/{include,lib} (as indicated by the
# PNG* and Z* macros below). Edit as appropriate--choose only ONE each of
# the PNGINC, PNGLIB, ZINC and ZLIB lines.
#
# This makefile builds statically linked executables (against libpng and zlib,
# that is), but that can be changed by uncommenting the appropriate PNGLIB and
# ZLIB lines.
# macros --------------------------------------------------------------------
PNGINC = -I/usr/local/include
#PNGLIB = -L/usr/local/lib -lpng # dynamically linked against libpng
PNGLIB = /usr/local/lib/libpng.a # statically linked against libpng
# or:
#PNGINC = -I../..
#PNGLIB = -L../.. -lpng
#PNGLIB = ../../libpng.a
ZINC = -I/usr/local/include
#ZLIB = -L/usr/local/lib -lz # dynamically linked against zlib
ZLIB = /usr/local/lib/libz.a # statically linked against zlib
#ZINC = -I../zlib
#ZLIB = -L../zlib -lz
#ZLIB = ../../../zlib/libz.a
XINC = -I/usr/include/X11 # old-style, stock X distributions
XLIB = -L/usr/lib/X11 -lX11
#XINC = -I/usr/openwin/include/X11 # Sun workstations (OpenWindows)
#XLIB = -L/usr/openwin/lib -lX11
#XINC = -I/usr/X11R6/include # new X distributions (XFree86, etc.)
#XLIB = -L/usr/X11R6/lib -lX11
INCS = $(PNGINC) $(ZINC) $(XINC)
RLIBS = $(PNGLIB) $(ZLIB) $(XLIB) -lm
WLIBS = $(PNGLIB) $(ZLIB)
CC = cc -n32
LD = cc -n32
RM = rm -f
CFLAGS = -O -fullwarn $(INCS)
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
# [-ansi, -pedantic and -W can also be used]
LDFLAGS =
O = .o
E =
RPNG = rpng-x
RPNG2 = rpng2-x
WPNG = wpng
ROBJS = $(RPNG)$(O) readpng$(O)
ROBJS2 = $(RPNG2)$(O) readpng2$(O)
WOBJS = $(WPNG)$(O) writepng$(O)
EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
# implicit make rules -------------------------------------------------------
.c$(O):
$(CC) -c $(CFLAGS) $<
# dependencies --------------------------------------------------------------
all: $(EXES)
$(RPNG)$(E): $(ROBJS)
$(LD) $(LDFLAGS) -o $@ $(ROBJS) $(RLIBS)
$(RPNG2)$(E): $(ROBJS2)
$(LD) $(LDFLAGS) -o $@ $(ROBJS2) $(RLIBS)
$(WPNG)$(E): $(WOBJS)
$(LD) $(LDFLAGS) -o $@ $(WOBJS) $(WLIBS)
$(RPNG)$(O): $(RPNG).c readpng.h
$(RPNG2)$(O): $(RPNG2).c readpng2.h
$(WPNG)$(O): $(WPNG).c writepng.h
readpng$(O): readpng.c readpng.h
readpng2$(O): readpng2.c readpng2.h
writepng$(O): writepng.c writepng.h
# maintenance ---------------------------------------------------------------
clean:
$(RM) $(EXES) $(ROBJS) $(ROBJS2) $(WOBJS)

View File

@@ -7,12 +7,25 @@ $!
$! $!
$! Set locations where zlib and libpng sources live. $! Set locations where zlib and libpng sources live.
$! $!
$ zpath = "[-.zlib]" $ zpath = ""
$ pngpath = "[-.libpng]" $ pngpath = ""
$ if f$search("[-.zlib]zlib.h").nes."" then zpath = "[-.zlib]"
$ if f$search("[-.libpng]png.h").nes."" then pngpath = "[-.libpng]"
$! $!
$! USE THESE INSTEAD if building from libpng's [.contrib.gregbook] directory: $ if f$search("[---.zlib]zlib.h").nes."" then zpath = "[---.zlib]"
$! zpath = "[---.zlib]" $ if f$search("[--]png.h").nes."" then pngpath = "[--]"
$! pngpath = "[--]" $!
$ if zpath .eqs. ""
$ then
$ write sys$output "Zlib include not found. Exiting..."
$ exit 2
$ endif
$!
$ if pngpath .eqs. ""
$ then
$ write sys$output "Libpng include not found. Exiting..."
$ exit 2
$ endif
$! $!
$! Look for the compiler used. $! Look for the compiler used.
$! $!

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,22 @@
Microsoft Developer Studio Build File, Format Version 6.00 for
msvctest
Assumes that libpng DLLs and LIBs are in ..\..\projects\msvc\win32\libpng
Assumes that zlib DLLs and LIBs are in ..\..\projects\msvc\win32\zlib
To build:
1) On the main menu Select "Build|Set Active configuration".
Choose the configuration that corresponds to the library you want to test.
This library must have been built using the libpng MS project located in
the "mscv" subdirectory.
2) Select "Build|Clean"
3) Select "Build|Rebuild All"
4) The test results should appear in the "Build" pane of the Output Window.
Simon-Pierre Cadieux
Methodex Computer Systems Inc.

View File

@@ -0,0 +1,247 @@
# Microsoft Developer Studio Project File - Name="msvctest" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=msvctest - Win32 Debug DLL
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "msvctest.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "msvctest.mak" CFG="msvctest - Win32 Debug DLL"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "msvctest - Win32 DLL" (based on "Win32 (x86) Console Application")
!MESSAGE "msvctest - Win32 Debug DLL" (based on "Win32 (x86) Console Application")
!MESSAGE "msvctest - Win32 ASM DLL" (based on "Win32 (x86) Console Application")
!MESSAGE "msvctest - Win32 Debug ASM DLL" (based on "Win32 (x86) Console Application")
!MESSAGE "msvctest - Win32 LIB" (based on "Win32 (x86) Console Application")
!MESSAGE "msvctest - Win32 Debug LIB" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "msvctest - Win32 DLL"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "dll"
# PROP BASE Intermediate_Dir "dll"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "dll"
# PROP Intermediate_Dir "dll"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FD /c
# ADD CPP /nologo /MD /W3 /O1 /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:console /machine:I386
# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll\libpng1.lib /nologo /subsystem:console /machine:I386
# Begin Special Build Tool
OutDir=.\dll
SOURCE="$(InputPath)"
PostBuild_Desc=[Run Test]
PostBuild_Cmds=set path=..\..\projects\msvc\win32\libpng\dll;..\..\projects\msvc\win32\zlib\dll; $(outdir)\msvctest.exe ..\..\pngtest.png
# End Special Build Tool
!ELSEIF "$(CFG)" == "msvctest - Win32 Debug DLL"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "dll_dbg"
# PROP BASE Intermediate_Dir "dll_dbg"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "dll_dbg"
# PROP Intermediate_Dir "dll_dbg"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Zi /Od /I "..\..\..\zlib" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll_dbg\libpng1d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# Begin Special Build Tool
OutDir=.\dll_dbg
SOURCE="$(InputPath)"
PostBuild_Desc=[Run Test]
PostBuild_Cmds=set path=..\..\projects\msvc\win32\libpng\dll_dbg;..\..\projects\msvc\win32\zlib\dll_dbg; $(outdir)\msvctest.exe ..\..\pngtest.png
# End Special Build Tool
!ELSEIF "$(CFG)" == "msvctest - Win32 ASM DLL"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "dll_asm"
# PROP BASE Intermediate_Dir "dll_asm"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "dll_asm"
# PROP Intermediate_Dir "dll_asm"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FD /c
# ADD CPP /nologo /MD /W3 /O1 /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:console /machine:I386
# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll_asm\libpng1a.lib /nologo /subsystem:console /machine:I386
# Begin Special Build Tool
OutDir=.\dll_asm
SOURCE="$(InputPath)"
PostBuild_Desc=[Run Test]
PostBuild_Cmds=set path=..\..\projects\msvc\win32\libpng\dll_asm;..\..\projects\msvc\win32\zlib\dll_asm; $(outdir)\msvctest.exe ..\..\pngtest.png
# End Special Build Tool
!ELSEIF "$(CFG)" == "msvctest - Win32 Debug ASM DLL"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "dll_dbga"
# PROP BASE Intermediate_Dir "dll_dbga"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "dll_dbga"
# PROP Intermediate_Dir "dll_dbga"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Zi /Od /I "..\..\..\zlib" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "PNG_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll_dbga\libpng1b.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# Begin Special Build Tool
OutDir=.\dll_dbga
SOURCE="$(InputPath)"
PostBuild_Desc=[Run Test]
PostBuild_Cmds=set path=..\..\projects\msvc\win32\libpng\dll_dbga;..\..\projects\msvc\win32\zlib\dll_dbga; $(outdir)\msvctest.exe ..\..\pngtest.png
# End Special Build Tool
!ELSEIF "$(CFG)" == "msvctest - Win32 LIB"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "lib"
# PROP BASE Intermediate_Dir "lib"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "lib"
# PROP Intermediate_Dir "lib"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FD /c
# ADD CPP /nologo /W3 /O1 /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:console /machine:I386
# ADD LINK32 ..\..\projects\msvc\win32\libpng\lib\libpng.lib /nologo /subsystem:console /machine:I386
# Begin Special Build Tool
OutDir=.\lib
SOURCE="$(InputPath)"
PostBuild_Desc=[Run Test]
PostBuild_Cmds=$(outdir)\msvctest.exe ..\..\pngtest.png
# End Special Build Tool
!ELSEIF "$(CFG)" == "msvctest - Win32 Debug LIB"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "lib_dbg"
# PROP BASE Intermediate_Dir "lib_dbg"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "lib_dbg"
# PROP Intermediate_Dir "lib_dbg"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Zi /Od /I "..\..\..\zlib" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 ..\..\projects\msvc\win32\libpng\lib_dbg\libpng.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# Begin Special Build Tool
OutDir=.\lib_dbg
SOURCE="$(InputPath)"
PostBuild_Desc=[Run Test]
PostBuild_Cmds=$(outdir)\msvctest.exe ..\..\pngtest.png
# End Special Build Tool
!ENDIF
# Begin Target
# Name "msvctest - Win32 DLL"
# Name "msvctest - Win32 Debug DLL"
# Name "msvctest - Win32 ASM DLL"
# Name "msvctest - Win32 Debug ASM DLL"
# Name "msvctest - Win32 LIB"
# Name "msvctest - Win32 Debug LIB"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\pngtest.c
# End Source File
# Begin Source File
SOURCE=.\README.txt
# PROP Exclude_From_Build 1
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "msvctest"=.\msvctest.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -1,52 +0,0 @@
# Makefile for PngMinus (png2pnm and pnm2png)
# Linux / Unix
CC=cc -O -n32
LD=cc -O -n32
#CC=gcc -O
#LD=gcc -O
LB=ar
RM=rm
CP=cp
PNGPATH = /usr/local
PNGINC = $(PNGPATH)/include
PNGLIB = $(PNGPATH)/lib -lpng
# PNGLIB = $(PNGPATH)/libpng.a
ZPATH = /usr/local
ZINC = $(ZPATH)/include
ZLIB = $(ZPATH)/lib -lz
# ZLIB = $(ZPATH)/libz.a
CCFLAGS=-I$(PNGINC) -I$(ZINC)
LDFLAGS=-L$(PNGLIB) -L$(ZLIB) -lm
C=.c
O=.o
L=.a
E=
# dependencies
all: png2pnm$(E) pnm2png$(E)
png2pnm$(O): png2pnm$(C)
$(CC) -c $(CCFLAGS) png2pnm$(C)
png2pnm$(E): png2pnm$(O)
$(LD) -o png2pnm$(E) png2pnm$(O) $(LDFLAGS)
pnm2png$(O): pnm2png$(C)
$(CC) -c $(CCFLAGS) pnm2png$(C)
pnm2png$(E): pnm2png$(O)
$(LD) -o pnm2png$(E) pnm2png$(O) $(LDFLAGS)
clean:
$(RM) png2pnm$(O)
$(RM) pnm2png$(O)
$(RM) png2pnm$(E)
$(RM) pnm2png$(E)
# End of makefile for png2pnm / pnm2png

View File

@@ -45,9 +45,9 @@ $ call make pnm2png.exe -
$ write sys$output "Building png2pnm..." $ write sys$output "Building png2pnm..."
$ CALL MAKE png2pnm.OBJ "cc ''CCOPT' png2pnm" - $ CALL MAKE png2pnm.OBJ "cc ''CCOPT' png2pnm" -
png2pnm.c png2pnm.c
$ call make pnm2png.exe - $ call make png2pnm.exe -
"LINK pnm2png,lib.opt/opt" - "LINK png2pnm,lib.opt/opt" -
pnm2png.obj png2pnm.obj
$ exit $ exit
$! $!
$! $!

View File

@@ -204,6 +204,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
int row, col; int row, col;
int ret; int ret;
int i; int i;
long dep_16;
/* read and check signature in PNG file */ /* read and check signature in PNG file */
ret = fread (buf, 1, 8, png_file); ret = fread (buf, 1, 8, png_file);
@@ -379,8 +380,10 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
if (raw) if (raw)
fputc ((int) *pix_ptr++ , pnm_file); fputc ((int) *pix_ptr++ , pnm_file);
else else
if (bit_depth == 16) if (bit_depth == 16){
fprintf (pnm_file, "%ld ", ((long) *pix_ptr++ << 8) + (long) *pix_ptr++); dep_16 = (long) *pix_ptr++;
fprintf (pnm_file, "%ld ", (dep_16 << 8) + ((long) *pix_ptr++));
}
else else
fprintf (pnm_file, "%ld ", (long) *pix_ptr++); fprintf (pnm_file, "%ld ", (long) *pix_ptr++);
} }
@@ -397,8 +400,10 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
if (raw) if (raw)
fputc ((int) *pix_ptr++ , alpha_file); fputc ((int) *pix_ptr++ , alpha_file);
else else
if (bit_depth == 16) if (bit_depth == 16){
fprintf (alpha_file, "%ld ", ((long) *pix_ptr++ << 8) + (long) *pix_ptr++); dep_16 = (long) *pix_ptr++;
fprintf (alpha_file, "%ld ", (dep_16 << 8) + (long) *pix_ptr++);
}
else else
fprintf (alpha_file, "%ld ", (long) *pix_ptr++); fprintf (alpha_file, "%ld ", (long) *pix_ptr++);
} }

439
contrib/visupng/PngFile.c Normal file
View File

@@ -0,0 +1,439 @@
//-------------------------------------
// PNGFILE.C -- Image File Functions
//-------------------------------------
// Copyright 2000, Willem van Schaik. For conditions of distribution and
// use, see the copyright/license/disclaimer notice in png.h
#include <windows.h>
#include <commdlg.h>
#include <stdio.h>
#include <stdlib.h>
#include "png.h"
#include "pngfile.h"
#include "cexcept.h"
define_exception_type(const char *);
extern struct exception_context the_exception_context[1];
struct exception_context the_exception_context[1];
png_const_charp msg;
static OPENFILENAME ofn;
static png_structp png_ptr = NULL;
static png_infop info_ptr = NULL;
// cexcept interface
static void
png_cexcept_error(png_structp png_ptr, png_const_charp msg)
{
if(png_ptr)
;
#ifndef PNG_NO_CONSOLE_IO
fprintf(stderr, "libpng error: %s\n", msg);
#endif
{
Throw msg;
}
}
// Windows open-file functions
void PngFileInitialize (HWND hwnd)
{
static TCHAR szFilter[] = TEXT ("PNG Files (*.PNG)\0*.png\0")
TEXT ("All Files (*.*)\0*.*\0\0");
ofn.lStructSize = sizeof (OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.hInstance = NULL;
ofn.lpstrFilter = szFilter;
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 0;
ofn.lpstrFile = NULL; // Set in Open and Close functions
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFileTitle = NULL; // Set in Open and Close functions
ofn.nMaxFileTitle = MAX_PATH;
ofn.lpstrInitialDir = NULL;
ofn.lpstrTitle = NULL;
ofn.Flags = 0; // Set in Open and Close functions
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = TEXT ("png");
ofn.lCustData = 0;
ofn.lpfnHook = NULL;
ofn.lpTemplateName = NULL;
}
BOOL PngFileOpenDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName)
{
ofn.hwndOwner = hwnd;
ofn.lpstrFile = pstrFileName;
ofn.lpstrFileTitle = pstrTitleName;
ofn.Flags = OFN_HIDEREADONLY;
return GetOpenFileName (&ofn);
}
BOOL PngFileSaveDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName)
{
ofn.hwndOwner = hwnd;
ofn.lpstrFile = pstrFileName;
ofn.lpstrFileTitle = pstrTitleName;
ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
return GetSaveFileName (&ofn);
}
// PNG image handler functions
BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
int *piWidth, int *piHeight, int *piChannels, png_color *pBkgColor)
{
static FILE *pfFile;
png_byte pbSig[8];
int iBitDepth;
int iColorType;
double dGamma;
png_color_16 *pBackground;
png_uint_32 ulChannels;
png_uint_32 ulRowBytes;
png_byte *pbImageData = *ppbImageData;
static png_byte **ppbRowPointers = NULL;
int i;
// open the PNG input file
if (!pstrFileName)
{
*ppbImageData = pbImageData = NULL;
return FALSE;
}
if (!(pfFile = fopen(pstrFileName, "rb")))
{
*ppbImageData = pbImageData = NULL;
return FALSE;
}
// first check the eight byte PNG signature
fread(pbSig, 1, 8, pfFile);
if (!png_check_sig(pbSig, 8))
{
*ppbImageData = pbImageData = NULL;
return FALSE;
}
// create the two png(-info) structures
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
(png_error_ptr)png_cexcept_error, (png_error_ptr)NULL);
if (!png_ptr)
{
*ppbImageData = pbImageData = NULL;
return FALSE;
}
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
{
png_destroy_read_struct(&png_ptr, NULL, NULL);
*ppbImageData = pbImageData = NULL;
return FALSE;
}
Try
{
// initialize the png structure
#if !defined(PNG_NO_STDIO)
png_init_io(png_ptr, pfFile);
#else
png_set_read_fn(png_ptr, (png_voidp)pfFile, png_read_data);
#endif
png_set_sig_bytes(png_ptr, 8);
// read all PNG info up to image data
png_read_info(png_ptr, info_ptr);
// get width, height, bit-depth and color-type
png_get_IHDR(png_ptr, info_ptr, piWidth, piHeight, &iBitDepth,
&iColorType, NULL, NULL, NULL);
// expand images of all color-type and bit-depth to 3x8 bit RGB images
// let the library process things like alpha, transparency, background
if (iBitDepth == 16)
png_set_strip_16(png_ptr);
if (iColorType == PNG_COLOR_TYPE_PALETTE)
png_set_expand(png_ptr);
if (iBitDepth < 8)
png_set_expand(png_ptr);
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
png_set_expand(png_ptr);
if (iColorType == PNG_COLOR_TYPE_GRAY ||
iColorType == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(png_ptr);
// set the background color to draw transparent and alpha images over.
if (png_get_bKGD(png_ptr, info_ptr, &pBackground))
{
png_set_background(png_ptr, pBackground, PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
pBkgColor->red = (byte) pBackground->red;
pBkgColor->green = (byte) pBackground->green;
pBkgColor->blue = (byte) pBackground->blue;
}
else
{
pBkgColor = NULL;
}
// if required set gamma conversion
if (png_get_gAMA(png_ptr, info_ptr, &dGamma))
png_set_gamma(png_ptr, (double) 2.2, dGamma);
// after the transformations have been registered update info_ptr data
png_read_update_info(png_ptr, info_ptr);
// get again width, height and the new bit-depth and color-type
png_get_IHDR(png_ptr, info_ptr, piWidth, piHeight, &iBitDepth,
&iColorType, NULL, NULL, NULL);
// row_bytes is the width x number of channels
ulRowBytes = png_get_rowbytes(png_ptr, info_ptr);
ulChannels = png_get_channels(png_ptr, info_ptr);
*piChannels = ulChannels;
// now we can allocate memory to store the image
if (pbImageData)
{
free (pbImageData);
pbImageData = NULL;
}
if ((pbImageData = (png_byte *) malloc(ulRowBytes * (*piHeight)
* sizeof(png_byte))) == NULL)
{
png_error(png_ptr, "Visual PNG: out of memory");
}
*ppbImageData = pbImageData;
// and allocate memory for an array of row-pointers
if ((ppbRowPointers = (png_bytepp) malloc((*piHeight)
* sizeof(png_bytep))) == NULL)
{
png_error(png_ptr, "Visual PNG: out of memory");
}
// set the individual row-pointers to point at the correct offsets
for (i = 0; i < (*piHeight); i++)
ppbRowPointers[i] = pbImageData + i * ulRowBytes;
// now we can go ahead and just read the whole image
png_read_image(png_ptr, ppbRowPointers);
// read the additional chunks in the PNG file (not really needed)
png_read_end(png_ptr, NULL);
// and we're done
free (ppbRowPointers);
ppbRowPointers = NULL;
// yepp, done
}
Catch (msg)
{
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
*ppbImageData = pbImageData = NULL;
if(ppbRowPointers)
free (ppbRowPointers);
fclose(pfFile);
return FALSE;
}
fclose (pfFile);
return TRUE;
}
BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData,
int iWidth, int iHeight, png_color bkgColor)
{
const int ciBitDepth = 8;
const int ciChannels = 3;
static FILE *pfFile;
png_uint_32 ulRowBytes;
static png_byte **ppbRowPointers = NULL;
int i;
// open the PNG output file
if (!pstrFileName)
return FALSE;
if (!(pfFile = fopen(pstrFileName, "wb")))
return FALSE;
// prepare the standard PNG structures
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL,
(png_error_ptr)png_cexcept_error, (png_error_ptr)NULL);
if (!png_ptr)
{
fclose(pfFile);
return FALSE;
}
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
fclose(pfFile);
png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
return FALSE;
}
Try
{
// initialize the png structure
#if !defined(PNG_NO_STDIO)
png_init_io(png_ptr, pfFile);
#else
png_set_write_fn(png_ptr, (png_voidp)pfFile, png_write_data, png_flush);
#endif
// we're going to write a very simple 3x8 bit RGB image
png_set_IHDR(png_ptr, info_ptr, iWidth, iHeight, ciBitDepth,
PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE,
PNG_FILTER_TYPE_BASE);
// write the file header information
png_write_info(png_ptr, info_ptr);
// swap the BGR pixels in the DiData structure to RGB
png_set_bgr(png_ptr);
// row_bytes is the width x number of channels
ulRowBytes = iWidth * ciChannels;
// we can allocate memory for an array of row-pointers
if ((ppbRowPointers = (png_bytepp) malloc(iHeight * sizeof(png_bytep))) == NULL)
Throw "Visualpng: Out of memory";
// set the individual row-pointers to point at the correct offsets
for (i = 0; i < iHeight; i++)
ppbRowPointers[i] = pDiData + i * (((ulRowBytes + 3) >> 2) << 2);
// write out the entire image data in one call
png_write_image (png_ptr, ppbRowPointers);
// write the additional chunks to the PNG file (not really needed)
png_write_end(png_ptr, info_ptr);
// and we're done
free (ppbRowPointers);
ppbRowPointers = NULL;
// clean up after the write, and free any memory allocated
png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
// yepp, done
}
Catch (msg)
{
png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
if(ppbRowPointers)
free (ppbRowPointers);
fclose(pfFile);
return FALSE;
}
fclose (pfFile);
return TRUE;
}
#ifdef PNG_NO_STDIO
static void
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
{
png_size_t check;
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
* instead of an int, which is what fread() actually returns.
*/
check = (png_size_t)fread(data, (png_size_t)1, length,
(FILE *)png_ptr->io_ptr);
if (check != length)
{
png_error(png_ptr, "Read Error");
}
}
static void
png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
{
png_uint_32 check;
check = fwrite(data, 1, length, (FILE *)(png_ptr->io_ptr));
if (check != length)
{
png_error(png_ptr, "Write Error");
}
}
static void
png_flush(png_structp png_ptr)
{
FILE *io_ptr;
io_ptr = (FILE *)CVT_PTR((png_ptr->io_ptr));
if (io_ptr != NULL)
fflush(io_ptr);
}
#endif
//-----------------
// end of source
//-----------------

27
contrib/visupng/PngFile.h Normal file
View File

@@ -0,0 +1,27 @@
//------------------------------------------
// PNGFILE.H -- Header File for pngfile.c
//------------------------------------------
// Copyright 2000, Willem van Schaik. For conditions of distribution and
// use, see the copyright/license/disclaimer notice in png.h
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
void PngFileInitialize (HWND hwnd) ;
BOOL PngFileOpenDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) ;
BOOL PngFileSaveDlg (HWND hwnd, PTSTR pstrFileName, PTSTR pstrTitleName) ;
BOOL PngLoadImage (PTSTR pstrFileName, png_byte **ppbImageData,
int *piWidth, int *piHeight, int *piChannels, png_color *pBkgColor);
BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData,
int iWidth, int iHeight, png_color BkgColor);
#if defined(PNG_NO_STDIO)
static void png_read_data(png_structp png_ptr, png_bytep data, png_size_t length);
static void png_write_data(png_structp png_ptr, png_bytep data, png_size_t length);
static void png_flush(png_structp png_ptr);
#endif

View File

@@ -0,0 +1,58 @@
Microsoft Developer Studio Build File, Format Version 6.00 for VisualPng
------------------------------------------------------------------------
Copyright 2000, Willem van Schaik. For conditions of distribution and
use, see the copyright/license/disclaimer notice in png.h
As a PNG .dll demo VisualPng is finished. More features would only hinder
the program's objective. However, further extensions (like support for other
graphics formats) are in development. To get these, or for pre-compiled
binaries, go to "http://www.schaik.com/png/visualpng.html".
------------------------------------------------------------------------
Assumes that
libpng DLLs and LIBs are in ..\..\projects\msvc\win32\libpng
zlib DLLs and LIBs are in ..\..\projects\msvc\win32\zlib
libpng header files are in ..\..\..\libpng
zlib header files are in ..\..\..\zlib
the pngsuite images are in ..\pngsuite
To build:
1) On the main menu Select "Build|Set Active configuration".
Choose the configuration that corresponds to the library you want to test.
This library must have been built using the libpng MS project located in
the "..\..\mscv" subdirectory.
2) Select "Build|Clean"
3) Select "Build|Rebuild All"
4) After compiling and linking VisualPng will be started to view an image
from the PngSuite directory. Press Ctrl-N (and Ctrl-V) for other images.
To install:
When distributing VisualPng (or a further development) the following options
are available:
1) Build the program with the configuration "Win32 LIB" and you only need to
include the executable from the ./lib directory in your distribution.
2) Build the program with the configuration "Win32 DLL" and you need to put
in your distribution the executable from the ./dll directory and the dll's
libpng1.dll, zlib.dll and msvcrt.dll. These need to be in the user's PATH.
Willem van Schaik
Calgary, June 6th 2000
P.S. VisualPng was written based on preliminary work of:
- Simon-Pierre Cadieux
- Glenn Randers-Pehrson
- Greg Roelofs

961
contrib/visupng/VisualPng.c Normal file
View File

@@ -0,0 +1,961 @@
//------------------------------------
// VisualPng.C -- Shows a PNG image
//------------------------------------
// Copyright 2000, Willem van Schaik. For conditions of distribution and
// use, see the copyright/license/disclaimer notice in png.h
// switches
// defines
#define PROGNAME "VisualPng"
#define LONGNAME "Win32 Viewer for PNG-files"
#define VERSION "1.0 of 2000 June 07"
// constants
#define MARGIN 8
// standard includes
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
// application includes
#include "png.h"
#include "pngfile.h"
#include "resource.h"
// macros
// function prototypes
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK AboutDlgProc (HWND, UINT, WPARAM, LPARAM) ;
BOOL CenterAbout (HWND hwndChild, HWND hwndParent);
BOOL BuildPngList (PTSTR pstrPathName, TCHAR **ppFileList, int *pFileCount,
int *pFileIndex);
BOOL SearchPngList (TCHAR *pFileList, int FileCount, int *pFileIndex,
PTSTR pstrPrevName, PTSTR pstrNextName);
BOOL LoadImageFile(HWND hwnd, PTSTR pstrPathName,
png_byte **ppbImage, int *pxImgSize, int *pyImgSize, int *piChannels,
png_color *pBkgColor);
BOOL DisplayImage (HWND hwnd, BYTE **ppDib,
BYTE **ppDiData, int cxWinSize, int cyWinSize,
BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels,
BOOL bStretched);
BOOL InitBitmap (
BYTE *pDiData, int cxWinSize, int cyWinSize);
BOOL FillBitmap (
BYTE *pDiData, int cxWinSize, int cyWinSize,
BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels,
BOOL bStretched);
// a few global variables
static char *szProgName = PROGNAME;
static char *szAppName = LONGNAME;
static char *szIconName = PROGNAME;
static char szCmdFileName [MAX_PATH];
// MAIN routine
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
HACCEL hAccel;
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
int ixBorders, iyBorders;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon (hInstance, szIconName) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
wndclass.hbrBackground = NULL; // (HBRUSH) GetStockObject (GRAY_BRUSH);
wndclass.lpszMenuName = szProgName;
wndclass.lpszClassName = szProgName;
if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("Error: this program requires Windows NT!"),
szProgName, MB_ICONERROR);
return 0;
}
// if filename given on commandline, store it
if ((szCmdLine != NULL) && (*szCmdLine != '\0'))
if (szCmdLine[0] == '"')
strncpy (szCmdFileName, szCmdLine + 1, strlen(szCmdLine) - 2);
else
strcpy (szCmdFileName, szCmdLine);
else
strcpy (szCmdFileName, "");
// calculate size of window-borders
ixBorders = 2 * (GetSystemMetrics (SM_CXBORDER) +
GetSystemMetrics (SM_CXDLGFRAME));
iyBorders = 2 * (GetSystemMetrics (SM_CYBORDER) +
GetSystemMetrics (SM_CYDLGFRAME)) +
GetSystemMetrics (SM_CYCAPTION) +
GetSystemMetrics (SM_CYMENUSIZE) +
1; /* WvS: don't ask me why? */
hwnd = CreateWindow (szProgName, szAppName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
512 + 2 * MARGIN + ixBorders, 384 + 2 * MARGIN + iyBorders,
// CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL);
ShowWindow (hwnd, iCmdShow);
UpdateWindow (hwnd);
hAccel = LoadAccelerators (hInstance, szProgName);
while (GetMessage (&msg, NULL, 0, 0))
{
if (!TranslateAccelerator (hwnd, hAccel, &msg))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
return msg.wParam;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam,
LPARAM lParam)
{
static HINSTANCE hInstance ;
static HDC hdc;
static PAINTSTRUCT ps;
static HMENU hMenu;
static BITMAPFILEHEADER *pbmfh;
static BITMAPINFOHEADER *pbmih;
static BYTE *pbImage;
static int cxWinSize, cyWinSize;
static int cxImgSize, cyImgSize;
static int cImgChannels;
static png_color bkgColor = {127, 127, 127};
static BOOL bStretched = TRUE;
static BYTE *pDib = NULL;
static BYTE *pDiData = NULL;
static TCHAR szImgPathName [MAX_PATH];
static TCHAR szTitleName [MAX_PATH];
static TCHAR *pPngFileList = NULL;
static int iPngFileCount;
static int iPngFileIndex;
BOOL bOk;
switch (message)
{
case WM_CREATE:
hInstance = ((LPCREATESTRUCT) lParam)->hInstance ;
PngFileInitialize (hwnd);
strcpy (szImgPathName, "");
// in case we process file given on command-line
if (szCmdFileName[0] != '\0')
{
strcpy (szImgPathName, szCmdFileName);
// read the other png-files in the directory for later
// next/previous commands
BuildPngList (szImgPathName, &pPngFileList, &iPngFileCount,
&iPngFileIndex);
// load the image from file
if (!LoadImageFile (hwnd, szImgPathName,
&pbImage, &cxImgSize, &cyImgSize, &cImgChannels, &bkgColor))
return 0;
// invalidate the client area for later update
InvalidateRect (hwnd, NULL, TRUE);
// display the PNG into the DIBitmap
DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize,
pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched);
}
return 0;
case WM_SIZE:
cxWinSize = LOWORD (lParam);
cyWinSize = HIWORD (lParam);
// invalidate the client area for later update
InvalidateRect (hwnd, NULL, TRUE);
// display the PNG into the DIBitmap
DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize,
pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched);
return 0;
case WM_INITMENUPOPUP:
hMenu = GetMenu (hwnd);
if (pbImage)
EnableMenuItem (hMenu, IDM_FILE_SAVE, MF_ENABLED);
else
EnableMenuItem (hMenu, IDM_FILE_SAVE, MF_GRAYED);
return 0;
case WM_COMMAND:
hMenu = GetMenu (hwnd);
switch (LOWORD (wParam))
{
case IDM_FILE_OPEN:
// show the File Open dialog box
if (!PngFileOpenDlg (hwnd, szImgPathName, szTitleName))
return 0;
// read the other png-files in the directory for later
// next/previous commands
BuildPngList (szImgPathName, &pPngFileList, &iPngFileCount,
&iPngFileIndex);
// load the image from file
if (!LoadImageFile (hwnd, szImgPathName,
&pbImage, &cxImgSize, &cyImgSize, &cImgChannels, &bkgColor))
return 0;
// invalidate the client area for later update
InvalidateRect (hwnd, NULL, TRUE);
// display the PNG into the DIBitmap
DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize,
pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched);
return 0;
case IDM_FILE_SAVE:
// show the File Save dialog box
if (!PngFileSaveDlg (hwnd, szImgPathName, szTitleName))
return 0;
// save the PNG to a disk file
SetCursor (LoadCursor (NULL, IDC_WAIT));
ShowCursor (TRUE);
bOk = PngSaveImage (szImgPathName, pDiData, cxWinSize, cyWinSize,
bkgColor);
ShowCursor (FALSE);
SetCursor (LoadCursor (NULL, IDC_ARROW));
if (!bOk)
MessageBox (hwnd, TEXT ("Error in saving the PNG image"),
szProgName, MB_ICONEXCLAMATION | MB_OK);
return 0;
case IDM_FILE_NEXT:
// read next entry in the directory
if (SearchPngList (pPngFileList, iPngFileCount, &iPngFileIndex,
NULL, szImgPathName))
{
if (strcmp (szImgPathName, "") == 0)
return 0;
// load the image from file
if (!LoadImageFile (hwnd, szImgPathName, &pbImage,
&cxImgSize, &cyImgSize, &cImgChannels, &bkgColor))
return 0;
// invalidate the client area for later update
InvalidateRect (hwnd, NULL, TRUE);
// display the PNG into the DIBitmap
DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize,
pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched);
}
return 0;
case IDM_FILE_PREVIOUS:
// read previous entry in the directory
if (SearchPngList (pPngFileList, iPngFileCount, &iPngFileIndex,
szImgPathName, NULL))
{
if (strcmp (szImgPathName, "") == 0)
return 0;
// load the image from file
if (!LoadImageFile (hwnd, szImgPathName, &pbImage, &cxImgSize,
&cyImgSize, &cImgChannels, &bkgColor))
return 0;
// invalidate the client area for later update
InvalidateRect (hwnd, NULL, TRUE);
// display the PNG into the DIBitmap
DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize,
pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched);
}
return 0;
case IDM_FILE_EXIT:
// more cleanup needed...
// free image buffer
if (pDib != NULL)
{
free (pDib);
pDib = NULL;
}
// free file-list
if (pPngFileList != NULL)
{
free (pPngFileList);
pPngFileList = NULL;
}
// let's go ...
exit (0);
return 0;
case IDM_OPTIONS_STRETCH:
bStretched = !bStretched;
if (bStretched)
CheckMenuItem (hMenu, IDM_OPTIONS_STRETCH, MF_CHECKED);
else
CheckMenuItem (hMenu, IDM_OPTIONS_STRETCH, MF_UNCHECKED);
// invalidate the client area for later update
InvalidateRect (hwnd, NULL, TRUE);
// display the PNG into the DIBitmap
DisplayImage (hwnd, &pDib, &pDiData, cxWinSize, cyWinSize,
pbImage, cxImgSize, cyImgSize, cImgChannels, bStretched);
return 0;
case IDM_HELP_ABOUT:
DialogBox (hInstance, TEXT ("AboutBox"), hwnd, AboutDlgProc) ;
return 0;
} // end switch
break;
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps);
if (pDib)
SetDIBitsToDevice (hdc, 0, 0, cxWinSize, cyWinSize, 0, 0,
0, cyWinSize, pDiData, (BITMAPINFO *) pDib, DIB_RGB_COLORS);
EndPaint (hwnd, &ps);
return 0;
case WM_DESTROY:
if (pbmfh)
{
free (pbmfh);
pbmfh = NULL;
}
PostQuitMessage (0);
return 0;
}
return DefWindowProc (hwnd, message, wParam, lParam);
}
BOOL CALLBACK AboutDlgProc (HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG :
ShowWindow (hDlg, SW_HIDE);
CenterAbout (hDlg, GetWindow (hDlg, GW_OWNER));
ShowWindow (hDlg, SW_SHOW);
return TRUE ;
case WM_COMMAND :
switch (LOWORD (wParam))
{
case IDOK :
case IDCANCEL :
EndDialog (hDlg, 0) ;
return TRUE ;
}
break ;
}
return FALSE ;
}
//---------------
// CenterAbout
//---------------
BOOL CenterAbout (HWND hwndChild, HWND hwndParent)
{
RECT rChild, rParent, rWorkArea;
int wChild, hChild, wParent, hParent;
int xNew, yNew;
BOOL bResult;
// Get the Height and Width of the child window
GetWindowRect (hwndChild, &rChild);
wChild = rChild.right - rChild.left;
hChild = rChild.bottom - rChild.top;
// Get the Height and Width of the parent window
GetWindowRect (hwndParent, &rParent);
wParent = rParent.right - rParent.left;
hParent = rParent.bottom - rParent.top;
// Get the limits of the 'workarea'
bResult = SystemParametersInfo(
SPI_GETWORKAREA, // system parameter to query or set
sizeof(RECT),
&rWorkArea,
0);
if (!bResult) {
rWorkArea.left = rWorkArea.top = 0;
rWorkArea.right = GetSystemMetrics(SM_CXSCREEN);
rWorkArea.bottom = GetSystemMetrics(SM_CYSCREEN);
}
// Calculate new X position, then adjust for workarea
xNew = rParent.left + ((wParent - wChild) /2);
if (xNew < rWorkArea.left) {
xNew = rWorkArea.left;
} else if ((xNew+wChild) > rWorkArea.right) {
xNew = rWorkArea.right - wChild;
}
// Calculate new Y position, then adjust for workarea
yNew = rParent.top + ((hParent - hChild) /2);
if (yNew < rWorkArea.top) {
yNew = rWorkArea.top;
} else if ((yNew+hChild) > rWorkArea.bottom) {
yNew = rWorkArea.bottom - hChild;
}
// Set it, and return
return SetWindowPos (hwndChild, NULL, xNew, yNew, 0, 0, SWP_NOSIZE |
SWP_NOZORDER);
}
//----------------
// BuildPngList
//----------------
BOOL BuildPngList (PTSTR pstrPathName, TCHAR **ppFileList, int *pFileCount,
int *pFileIndex)
{
static TCHAR szImgPathName [MAX_PATH];
static TCHAR szImgFileName [MAX_PATH];
static TCHAR szImgFindName [MAX_PATH];
WIN32_FIND_DATA finddata;
HANDLE hFind;
static TCHAR szTmp [MAX_PATH];
BOOL bOk;
int i, ii;
int j, jj;
// free previous file-list
if (*ppFileList != NULL)
{
free (*ppFileList);
*ppFileList = NULL;
}
// extract foldername, filename and search-name
strcpy (szImgPathName, pstrPathName);
strcpy (szImgFileName, strrchr (pstrPathName, '\\') + 1);
strcpy (szImgFindName, szImgPathName);
*(strrchr (szImgFindName, '\\') + 1) = '\0';
strcat (szImgFindName, "*.png");
// first cycle: count number of files in directory for memory allocation
*pFileCount = 0;
hFind = FindFirstFile(szImgFindName, &finddata);
bOk = (hFind != (HANDLE) -1);
while (bOk)
{
*pFileCount += 1;
bOk = FindNextFile(hFind, &finddata);
}
FindClose(hFind);
// allocation memory for file-list
*ppFileList = (TCHAR *) malloc (*pFileCount * MAX_PATH);
// second cycle: read directory and store filenames in file-list
hFind = FindFirstFile(szImgFindName, &finddata);
bOk = (hFind != (HANDLE) -1);
i = 0;
ii = 0;
while (bOk)
{
strcpy (*ppFileList + ii, szImgPathName);
strcpy (strrchr(*ppFileList + ii, '\\') + 1, finddata.cFileName);
if (strcmp(pstrPathName, *ppFileList + ii) == 0)
*pFileIndex = i;
ii += MAX_PATH;
i++;
bOk = FindNextFile(hFind, &finddata);
}
FindClose(hFind);
// finally we must sort the file-list
for (i = 0; i < *pFileCount - 1; i++)
{
ii = i * MAX_PATH;
for (j = i+1; j < *pFileCount; j++)
{
jj = j * MAX_PATH;
if (strcmp (*ppFileList + ii, *ppFileList + jj) > 0)
{
strcpy (szTmp, *ppFileList + jj);
strcpy (*ppFileList + jj, *ppFileList + ii);
strcpy (*ppFileList + ii, szTmp);
// check if this was the current image that we moved
if (*pFileIndex == i)
*pFileIndex = j;
else
if (*pFileIndex == j)
*pFileIndex = i;
}
}
}
return TRUE;
}
//----------------
// SearchPngList
//----------------
BOOL SearchPngList (
TCHAR *pFileList, int FileCount, int *pFileIndex,
PTSTR pstrPrevName, PTSTR pstrNextName)
{
if (FileCount > 0)
{
// get previous entry
if (pstrPrevName != NULL)
{
if (*pFileIndex > 0)
*pFileIndex -= 1;
else
*pFileIndex = FileCount - 1;
strcpy (pstrPrevName, pFileList + (*pFileIndex * MAX_PATH));
}
// get next entry
if (pstrNextName != NULL)
{
if (*pFileIndex < FileCount - 1)
*pFileIndex += 1;
else
*pFileIndex = 0;
strcpy (pstrNextName, pFileList + (*pFileIndex * MAX_PATH));
}
return TRUE;
}
else
{
return FALSE;
}
}
//-----------------
// LoadImageFile
//-----------------
BOOL LoadImageFile (HWND hwnd, PTSTR pstrPathName,
png_byte **ppbImage, int *pxImgSize, int *pyImgSize,
int *piChannels, png_color *pBkgColor)
{
static TCHAR szTmp [MAX_PATH];
// if there's an existing PNG, free the memory
if (*ppbImage)
{
free (*ppbImage);
*ppbImage = NULL;
}
// Load the entire PNG into memory
SetCursor (LoadCursor (NULL, IDC_WAIT));
ShowCursor (TRUE);
PngLoadImage (pstrPathName, ppbImage, pxImgSize, pyImgSize, piChannels,
pBkgColor);
ShowCursor (FALSE);
SetCursor (LoadCursor (NULL, IDC_ARROW));
if (*ppbImage != NULL)
{
sprintf (szTmp, "VisualPng - %s", strrchr(pstrPathName, '\\') + 1);
SetWindowText (hwnd, szTmp);
}
else
{
MessageBox (hwnd, TEXT ("Error in loading the PNG image"),
szProgName, MB_ICONEXCLAMATION | MB_OK);
return FALSE;
}
return TRUE;
}
//----------------
// DisplayImage
//----------------
BOOL DisplayImage (HWND hwnd, BYTE **ppDib,
BYTE **ppDiData, int cxWinSize, int cyWinSize,
BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels,
BOOL bStretched)
{
BYTE *pDib = *ppDib;
BYTE *pDiData = *ppDiData;
// BITMAPFILEHEADER *pbmfh;
BITMAPINFOHEADER *pbmih;
WORD wDIRowBytes;
png_color bkgBlack = {0, 0, 0};
png_color bkgGray = {127, 127, 127};
png_color bkgWhite = {255, 255, 255};
// allocate memory for the Device Independant bitmap
wDIRowBytes = (WORD) ((3 * cxWinSize + 3L) >> 2) << 2;
if (pDib)
{
free (pDib);
pDib = NULL;
}
if (!(pDib = (BYTE *) malloc (sizeof(BITMAPINFOHEADER) +
wDIRowBytes * cyWinSize)))
{
MessageBox (hwnd, TEXT ("Error in displaying the PNG image"),
szProgName, MB_ICONEXCLAMATION | MB_OK);
*ppDib = pDib = NULL;
return FALSE;
}
*ppDib = pDib;
memset (pDib, 0, sizeof(BITMAPINFOHEADER));
// initialize the dib-structure
pbmih = (BITMAPINFOHEADER *) pDib;
pbmih->biSize = sizeof(BITMAPINFOHEADER);
pbmih->biWidth = cxWinSize;
pbmih->biHeight = -((long) cyWinSize);
pbmih->biPlanes = 1;
pbmih->biBitCount = 24;
pbmih->biCompression = 0;
pDiData = pDib + sizeof(BITMAPINFOHEADER);
*ppDiData = pDiData;
// first fill bitmap with gray and image border
InitBitmap (pDiData, cxWinSize, cyWinSize);
// then fill bitmap with image
if (pbImage)
{
FillBitmap (
pDiData, cxWinSize, cyWinSize,
pbImage, cxImgSize, cyImgSize, cImgChannels,
bStretched);
}
return TRUE;
}
//--------------
// InitBitmap
//--------------
BOOL InitBitmap (BYTE *pDiData, int cxWinSize, int cyWinSize)
{
BYTE *dst;
int x, y, col;
// initialize the background with gray
dst = pDiData;
for (y = 0; y < cyWinSize; y++)
{
col = 0;
for (x = 0; x < cxWinSize; x++)
{
// fill with GRAY
*dst++ = 127;
*dst++ = 127;
*dst++ = 127;
col += 3;
}
// rows start on 4 byte boundaries
while ((col % 4) != 0)
{
dst++;
col++;
}
}
return TRUE;
}
//--------------
// FillBitmap
//--------------
BOOL FillBitmap (
BYTE *pDiData, int cxWinSize, int cyWinSize,
BYTE *pbImage, int cxImgSize, int cyImgSize, int cImgChannels,
BOOL bStretched)
{
BYTE *pStretchedImage;
BYTE *pImg;
BYTE *src, *dst;
BYTE r, g, b, a;
const int cDIChannels = 3;
WORD wImgRowBytes;
WORD wDIRowBytes;
int cxNewSize, cyNewSize;
int cxImgPos, cyImgPos;
int xImg, yImg;
int xWin, yWin;
int xOld, yOld;
int xNew, yNew;
if (bStretched)
{
cxNewSize = cxWinSize - 2 * MARGIN;
cyNewSize = cyWinSize - 2 * MARGIN;
// stretch the image to it's window determined size
// the following two are the same, but the first has side-effects
// because of rounding
// if ((cyNewSize / cxNewSize) > (cyImgSize / cxImgSize))
if ((cyNewSize * cxImgSize) > (cyImgSize * cxNewSize))
{
cyNewSize = cxNewSize * cyImgSize / cxImgSize;
cxImgPos = MARGIN;
cyImgPos = (cyWinSize - cyNewSize) / 2;
}
else
{
cxNewSize = cyNewSize * cxImgSize / cyImgSize;
cyImgPos = MARGIN;
cxImgPos = (cxWinSize - cxNewSize) / 2;
}
pStretchedImage = malloc (cImgChannels * cxNewSize * cyNewSize);
pImg = pStretchedImage;
for (yNew = 0; yNew < cyNewSize; yNew++)
{
yOld = yNew * cyImgSize / cyNewSize;
for (xNew = 0; xNew < cxNewSize; xNew++)
{
xOld = xNew * cxImgSize / cxNewSize;
r = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) + 0);
g = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) + 1);
b = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld) + 2);
*pImg++ = r;
*pImg++ = g;
*pImg++ = b;
if (cImgChannels == 4)
{
a = *(pbImage + cImgChannels * ((yOld * cxImgSize) + xOld)
+ 3);
*pImg++ = a;
}
}
}
// calculate row-bytes
wImgRowBytes = cImgChannels * cxNewSize;
wDIRowBytes = (WORD) ((cDIChannels * cxWinSize + 3L) >> 2) << 2;
// copy image to screen
for (yImg = 0, yWin = cyImgPos; yImg < cyNewSize; yImg++, yWin++)
{
if (yWin >= cyWinSize - cyImgPos)
break;
src = pStretchedImage + yImg * wImgRowBytes;
dst = pDiData + yWin * wDIRowBytes + cxImgPos * cDIChannels;
for (xImg = 0, xWin = cxImgPos; xImg < cxNewSize; xImg++, xWin++)
{
if (xWin >= cxWinSize - cxImgPos)
break;
r = *src++;
g = *src++;
b = *src++;
*dst++ = b; /* note the reverse order */
*dst++ = g;
*dst++ = r;
if (cImgChannels == 4)
{
a = *src++;
}
}
}
// free memory
if (pStretchedImage != NULL)
{
free (pStretchedImage);
pStretchedImage = NULL;
}
}
// process the image not-stretched
else
{
// calculate the central position
cxImgPos = (cxWinSize - cxImgSize) / 2;
cyImgPos = (cyWinSize - cyImgSize) / 2;
// check for image larger than window
if (cxImgPos < MARGIN)
cxImgPos = MARGIN;
if (cyImgPos < MARGIN)
cyImgPos = MARGIN;
// calculate both row-bytes
wImgRowBytes = cImgChannels * cxImgSize;
wDIRowBytes = (WORD) ((cDIChannels * cxWinSize + 3L) >> 2) << 2;
// copy image to screen
for (yImg = 0, yWin = cyImgPos; yImg < cyImgSize; yImg++, yWin++)
{
if (yWin >= cyWinSize - MARGIN)
break;
src = pbImage + yImg * wImgRowBytes;
dst = pDiData + yWin * wDIRowBytes + cxImgPos * cDIChannels;
for (xImg = 0, xWin = cxImgPos; xImg < cxImgSize; xImg++, xWin++)
{
if (xWin >= cxWinSize - MARGIN)
break;
r = *src++;
g = *src++;
b = *src++;
*dst++ = b; /* note the reverse order */
*dst++ = g;
*dst++ = r;
if (cImgChannels == 4)
{
a = *src++;
}
}
}
}
return TRUE;
}
//-----------------
// end of source
//-----------------

View File

@@ -0,0 +1,223 @@
# Microsoft Developer Studio Project File - Name="VisualPng" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# Copyright 2000, Willem van Schaik. For conditions of distribution and
# use, see the copyright/license/disclaimer notice in png.h
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=VisualPng - Win32 Debug LIB
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "VisualPng.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "VisualPng.mak" CFG="VisualPng - Win32 Debug LIB"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "VisualPng - Win32 DLL" (based on "Win32 (x86) Application")
!MESSAGE "VisualPng - Win32 Debug DLL" (based on "Win32 (x86) Application")
!MESSAGE "VisualPng - Win32 LIB" (based on "Win32 (x86) Application")
!MESSAGE "VisualPng - Win32 Debug LIB" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "VisualPng - Win32 DLL"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "VisualPng___Win32_DLL"
# PROP BASE Intermediate_Dir "VisualPng___Win32_DLL"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "dll"
# PROP Intermediate_Dir "dll"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /I "libpng" /I "zlib" /D "PNG_USE_DLL" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\libpng" /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "PNG_USE_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 libpng1.lib zlibd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /libpath:"libpng" /libpath:"zlib"
# ADD LINK32 libpng1.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /libpath:"..\..\projects\msvc\win32\libpng\dll"
# Begin Special Build Tool
OutDir=.\dll
SOURCE="$(InputPath)"
PostBuild_Cmds=set path=..\..\projects\msvc\win32\libpng\dll;..\..\projects\msvc\win32\zlib\dll; $(outdir)\VisualPng.exe ..\..\contrib\pngsuite\basn6a16.png
# End Special Build Tool
!ELSEIF "$(CFG)" == "VisualPng - Win32 Debug DLL"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "VisualPng___Win32_Debug_DLL"
# PROP BASE Intermediate_Dir "VisualPng___Win32_Debug_DLL"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "dll_dbg"
# PROP Intermediate_Dir "dll_dbg"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "libpng" /I "zlib" /D "PNG_USE_DLL" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\libpng" /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "PNG_USE_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 libpng1.lib zlibd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept /libpath:"libpng" /libpath:"zlib"
# SUBTRACT BASE LINK32 /nodefaultlib
# ADD LINK32 libpng1d.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept /libpath:"..\..\projects\msvc\win32\libpng\dll_dbg"
# SUBTRACT LINK32 /nodefaultlib
# Begin Special Build Tool
OutDir=.\dll_dbg
SOURCE="$(InputPath)"
PostBuild_Cmds=set path=..\..\projects\msvc\win32\libpng\dll_dbg;..\..\projects\msvc\win32\zlib\dll_dbg; $(outdir)\VisualPng.exe ..\..\contrib\pngsuite\basn6a16.png
# End Special Build Tool
!ELSEIF "$(CFG)" == "VisualPng - Win32 LIB"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "VisualPng___Win32_LIB"
# PROP BASE Intermediate_Dir "VisualPng___Win32_LIB"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "lib"
# PROP Intermediate_Dir "lib"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /I "..\..\..\libpng" /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "PNG_USE_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c
# SUBTRACT BASE CPP /YX
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\libpng" /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 libpng1.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /libpath:"..\..\projects\msvc\win32\libpng\dll"
# ADD LINK32 libpng.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /libpath:"..\..\projects\msvc\win32\libpng\lib"
# Begin Special Build Tool
OutDir=.\lib
SOURCE="$(InputPath)"
PostBuild_Cmds=$(outdir)\VisualPng.exe ..\..\contrib\pngsuite\basn6a16.png
# End Special Build Tool
!ELSEIF "$(CFG)" == "VisualPng - Win32 Debug LIB"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "VisualPng___Win32_Debug_LIB"
# PROP BASE Intermediate_Dir "VisualPng___Win32_Debug_LIB"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "lib_dbg"
# PROP Intermediate_Dir "lib_dbg"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\libpng" /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "PNG_USE_DLL" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\libpng" /I "..\..\..\zlib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "PNG_NO_STDIO" /D "PNG_NO_GLOBAL_ARRAYS" /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 libpng1d.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept /libpath:"..\..\projects\msvc\win32\libpng\dll_dbg"
# SUBTRACT BASE LINK32 /nodefaultlib
# ADD LINK32 libpng.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept /libpath:"..\..\projects\msvc\win32\libpng\lib_dbg"
# SUBTRACT LINK32 /nodefaultlib
# Begin Special Build Tool
OutDir=.\lib_dbg
SOURCE="$(InputPath)"
PostBuild_Cmds=$(outdir)\VisualPng.exe ..\..\contrib\pngsuite\basn6a16.png
# End Special Build Tool
!ENDIF
# Begin Target
# Name "VisualPng - Win32 DLL"
# Name "VisualPng - Win32 Debug DLL"
# Name "VisualPng - Win32 LIB"
# Name "VisualPng - Win32 Debug LIB"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\PngFile.c
# End Source File
# Begin Source File
SOURCE=.\VisualPng.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\cexcept.h
# End Source File
# Begin Source File
SOURCE=.\PngFile.h
# End Source File
# Begin Source File
SOURCE=.\resource.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\VisualPng.ico
# End Source File
# Begin Source File
SOURCE=.\VisualPng.rc
# End Source File
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "VisualPng"=.\VisualPng.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

View File

@@ -0,0 +1,152 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
VISUALPNG MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&Open Image...\tCtrl+O", IDM_FILE_OPEN
MENUITEM "Save &As...", IDM_FILE_SAVE
MENUITEM SEPARATOR
MENUITEM "&Next Image\tCtrl+N", IDM_FILE_NEXT
MENUITEM "Pre&vious Image\tCtrl+V", IDM_FILE_PREVIOUS
MENUITEM SEPARATOR
MENUITEM "E&xit\tAlt+X", IDM_FILE_EXIT
END
POPUP "&Options"
BEGIN
MENUITEM "&Stretch", IDM_OPTIONS_STRETCH, CHECKED
END
POPUP "&Help"
BEGIN
MENUITEM "&About", IDM_HELP_ABOUT
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
VISUALPNG ACCELERATORS DISCARDABLE
BEGIN
"N", IDM_FILE_NEXT, VIRTKEY, CONTROL, NOINVERT
"O", IDM_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT
"P", IDM_FILE_PREVIOUS, VIRTKEY, CONTROL, NOINVERT
"V", IDM_FILE_PREVIOUS, VIRTKEY, CONTROL, NOINVERT
"X", IDM_FILE_EXIT, VIRTKEY, ALT, NOINVERT
END
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
VISUALPNG ICON DISCARDABLE "VisualPng.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
ABOUTBOX DIALOG DISCARDABLE 0, 0, 186, 94
STYLE DS_MODALFRAME | WS_POPUP
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,68,67,50,14
CTEXT "VisualPng 1.0 - June 2000",IDC_STATIC,49,14,88,8
LTEXT "a PNG image viewer",IDC_STATIC,60,30,66,8
LTEXT "(c) Willem van Schaik, 2000",IDC_STATIC,48,52,90,8
LTEXT "to demonstrate the use of libpng in Visual C",
IDC_STATIC,25,38,136,8
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
"ABOUTBOX", DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 87
END
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

244
contrib/visupng/cexcept.h Normal file
View File

@@ -0,0 +1,244 @@
/*===
cexcept.h 1.0.0 (2000-Jun-21-Wed)
Adam M. Costello <amc@cs.berkeley.edu>
An interface for exception-handling in ANSI C, developed jointly with
Cosmin Truta <cosmin@cs.toronto.edu>.
Copyright (c) 2000 Adam M. Costello and Cosmin Truta. Everyone
is hereby granted permission to do whatever they like with this
file, provided that if they modify it they take reasonable steps to
avoid confusing or misleading people about the authors, version,
and terms of use of the derived file. The copyright holders make
no guarantees about the correctness of this file, and are not
responsible for any damage resulting from its use.
If this interface is used by multiple .c files, they shouldn't include
this header file directly. Instead, create a wrapper header file that
includes this header file and then invokes the define_exception_type
macro (see below), and let your .c files include that header file.
The interface consists of one type, one well-known name, and six macros.
define_exception_type(type_name);
This macro is used like an external declaration. It specifies
the type of object that gets copied from the exception thrower to
the exception catcher. The type_name can be any type that can be
assigned to, that is, a non-constant arithmetic type, struct, union,
or pointer. Examples:
define_exception_type(int);
enum exception { out_of_memory, bad_arguments, disk_full };
define_exception_type(enum exception);
struct exception { int code; const char *msg; };
define_exception_type(struct exception);
struct exception_context;
This type may be used after the define_exception_type() macro has
been invoked. A struct exception_context must be known to both
the thrower and the catcher. It is expected that there be one
context for each thread that uses exceptions. It would certainly
be dangerous for multiple threads to access the same context.
One thread can use multiple contexts, but that is likely to be
confusing and not typically useful. The application can allocate
this structure in any way it pleases--automatic, static, or dynamic.
The application programmer should pretend not to know the structure
members, which are subject to change.
struct exception_context *the_exception_context;
The Try/Catch and Throw statements (described below) implicitly
refer to a context, using the name the_exception_context. It is
the application's responsibility to make sure that this name yields
the address of a mutable (non-constant) struct exception_context
wherever those statements are used. Subject to that constraint, the
application may declare a variable of this name anywhere it likes
(inside a function, in a parameter list, or externally), and may
use whatever storage class specifiers (static, extern, etc) or type
qualifiers (const, volatile) it likes. Examples:
static struct exception_context
* const the_exception_context = &foo;
{ struct exception_context *the_exception_context = bar; ... }
int blah(struct exception_context *the_exception_context, ...);
extern struct exception_context the_exception_context[1];
The last example illustrates a trick that avoids creating a pointer
object separate from the structure object.
The name could even be a macro, for example:
struct exception_context ec_array[numthreads];
#define the_exception_context (ec_array + thread_id)
Be aware that the_exception_context is used several times by the
Try/Catch/Throw macros, so it shouldn't be expensive or have side
effects. The expansion must be a drop-in replacement for an
identifier, so it's safest to put parentheses around it.
void init_exception_context(struct exception_context *ec);
For context structures allocated statically (by an external
definition or using the "static" keyword), the implicit
initialization to all zeros is sufficient, but contexts allocated
by other means must be initialized using this macro before they
are used by a Try/Catch statement. It does no harm to initialize
a context more than once (by using this macro on a statically
allocated context, or using this macro twice on the same context),
but a context must not be re-initialized after it has been used by a
Try/Catch statement.
Try statement
Catch (expression) statement
The Try/Catch/Throw macros are capitalized in order to avoid
confusion with the C++ keywords, which have subtly different
semantics.
A Try/Catch statement has a syntax similar to an if/else
statement, except that the parenthesized expression goes after
the second keyword rather than the first. As with if/else,
there are two clauses, each of which may be a simple statement
ending with a semicolon or a brace-enclosed compound statement.
But whereas the else clause is optional, the Catch clause is
required. The expression must be a modifiable lvalue (something
capable of being assigned to) of the exact same type passed to
define_exception_type().
If a Throw that uses the same exception context as the Try/Catch is
executed within the Try clause (typically within a function called
by the Try clause), and the exception is not caught by a nested
Try/Catch statement, then a copy of the exception will be assigned
to the expression, and control will jump to the Catch clause. If no
such Throw is executed, then the assignment is not performed, and
the Catch clause is not executed.
Regardless of whether an exception is caught, the expression is
always evaluated exactly once, which is significant if it has side
effects, for example:
Try foo();
Catch (p[++i].e) { ... }
IMPORTANT: Jumping into or out of a Try clause (for example via
return, break, continue, goto, longjmp) is forbidden--the compiler
will not complain, but bad things will happen at run-time. Jumping
into or out of a Catch clause is okay, and so is jumping around
inside a Try clause. In many cases where one is tempted to return
from a Try clause, it will suffice to use Throw, and then return
from the Catch clause. Another option is to set a flag variable and
use goto to jump to the end of the Try clause, then check the flag
after the Try/Catch statement.
IMPORTANT: The values of any non-volatile automatic variables
changed within the Try clause are undefined after an exception is
caught. Therefore, variables modified inside the Try block whose
values are needed later outside the Try block must either use static
storage or be declared with the "volatile" type qualifier.
Throw expression;
A Throw statement is very much like a return statement, except that
the expression is required. Whereas return jumps back to the place
where the current function was called, Throw jumps back to the Catch
clause of the innermost enclosing Try clause. The expression must
be compatible with the type passed to define_exception_type(). The
exception must be caught, otherwise the program may crash.
Slight limitation: If the expression is a comma-expression it must
be enclosed in parentheses.
Try statement
Catch_anonymous statement
When the value of the exception is not needed, a Try/Catch statement
can use Catch_anonymous instead of Catch (expression).
Everything below this point is for the benefit of the compiler. The
application programmer should pretend not to know any of it, because it
is subject to change.
===*/
#ifndef CEXCEPT_H
#define CEXCEPT_H
#include <setjmp.h>
#define define_exception_type(etype) \
struct exception__state { \
etype *exception; \
jmp_buf env; \
}
struct exception_context { \
struct exception__state *last; \
int caught; \
};
#define init_exception_context(ec) ((void)((ec)->last = 0))
#define Catch(e) exception__catch(&(e))
#define Catch_anonymous exception__catch(0)
#define Try \
{ \
struct exception__state *exception__p, exception__s; \
int exception__i; \
exception__p = the_exception_context->last; \
the_exception_context->last = &exception__s; \
for (exception__i = 0; ; exception__i = 1) \
if (exception__i) { \
if (setjmp(exception__s.env) == 0) { \
if (&exception__s)
#define exception__catch(e_addr) \
else { } \
the_exception_context->caught = 0; \
} \
else the_exception_context->caught = 1; \
the_exception_context->last = exception__p; \
break; \
} \
else exception__s.exception = e_addr; \
} \
if (!the_exception_context->caught) { } \
else
/* Try ends with if(), and Catch begins and ends with else. This */
/* ensures that the Try/Catch syntax is really the same as the */
/* if/else syntax. */
/* */
/* We use &exception__s instead of 1 to appease compilers that */
/* warn about constant expressions inside if(). Most compilers */
/* should still recognize that &exception__s is never zero and avoid */
/* generating test code. */
/* */
/* We use the variable exception__i to start the loop at the bottom, */
/* rather than jump into the loop using a switch statement, to */
/* appease compilers that warn about jumping into loops. */
#define Throw \
for (;; longjmp(the_exception_context->last->env, 1)) \
if (the_exception_context->last->exception) \
*the_exception_context->last->exception =
#endif /* CEXCEPT_H */

View File

@@ -0,0 +1,23 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by VisualPng.rc
//
#define IDM_FILE_OPEN 40001
#define IDM_FILE_SAVE 40002
#define IDM_FILE_NEXT 40003
#define IDM_FILE_PREVIOUS 40004
#define IDM_FILE_EXIT 40005
#define IDM_OPTIONS_BACKGROUND 40006
#define IDM_OPTIONS_STRETCH 40007
#define IDM_HELP_ABOUT 40008
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 113
#define _APS_NEXT_COMMAND_VALUE 40009
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -84,7 +84,7 @@ void read_png(char *file_name) /* We need to open the file */
FILE *fp; FILE *fp;
if ((fp = fopen(file_name, "rb")) == NULL) if ((fp = fopen(file_name, "rb")) == NULL)
return; return (ERROR);
#else no_open_file /* prototype 2 */ #else no_open_file /* prototype 2 */
void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
{ {
@@ -106,7 +106,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
if (png_ptr == NULL) if (png_ptr == NULL)
{ {
fclose(fp); fclose(fp);
return; return (ERROR);
} }
/* Allocate/initialize the memory for image information. REQUIRED. */ /* Allocate/initialize the memory for image information. REQUIRED. */
@@ -115,7 +115,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
{ {
fclose(fp); fclose(fp);
png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL); png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
return; return (ERROR);
} }
/* Set error handling if you are using the setjmp/longjmp method (this is /* Set error handling if you are using the setjmp/longjmp method (this is
@@ -129,7 +129,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
fclose(fp); fclose(fp);
/* If we get here, we had a problem reading the file */ /* If we get here, we had a problem reading the file */
return; return (ERROR);
} }
/* One of the following I/O initialization methods is REQUIRED */ /* One of the following I/O initialization methods is REQUIRED */
@@ -282,7 +282,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
/* This reduces the image to the palette supplied in the file */ /* This reduces the image to the palette supplied in the file */
else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)) else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette))
{ {
png_color16p histogram; png_uint_16p histogram;
png_get_hIST(png_ptr, info_ptr, &histogram); png_get_hIST(png_ptr, info_ptr, &histogram);
@@ -291,7 +291,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
} }
} }
/* invert monocrome files to have 0 as white and 1 as black */ /* invert monochrome files to have 0 as white and 1 as black */
png_set_invert_mono(png_ptr); png_set_invert_mono(png_ptr);
/* If you want to shift the pixel values from the range [0,255] or /* If you want to shift the pixel values from the range [0,255] or
@@ -307,7 +307,8 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
} }
/* flip the RGB pixels to BGR (or RGBA to BGRA) */ /* flip the RGB pixels to BGR (or RGBA to BGRA) */
png_set_bgr(png_ptr); if (color_type & PNG_COLOR_MASK_COLOR)
png_set_bgr(png_ptr);
/* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
png_set_swap_alpha(png_ptr); png_set_swap_alpha(png_ptr);
@@ -386,7 +387,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
fclose(fp); fclose(fp);
/* that's it */ /* that's it */
return; return (OK);
} }
/* progressively read a file */ /* progressively read a file */
@@ -406,7 +407,7 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
if (*png_ptr == NULL) if (*png_ptr == NULL)
{ {
*info_ptr = NULL; *info_ptr = NULL;
return ERROR; return (ERROR);
} }
*info_ptr = png_create_info_struct(png_ptr); *info_ptr = png_create_info_struct(png_ptr);
@@ -414,13 +415,13 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
if (*info_ptr == NULL) if (*info_ptr == NULL)
{ {
png_destroy_read_struct(png_ptr, info_ptr, (png_infopp)NULL); png_destroy_read_struct(png_ptr, info_ptr, (png_infopp)NULL);
return ERROR; return (ERROR);
} }
if (setjmp(png_jmpbuf((*png_ptr)))) if (setjmp(png_jmpbuf((*png_ptr))))
{ {
png_destroy_read_struct(png_ptr, info_ptr, (png_infopp)NULL); png_destroy_read_struct(png_ptr, info_ptr, (png_infopp)NULL);
return ERROR; return (ERROR);
} }
/* This one's new. You will need to provide all three /* This one's new. You will need to provide all three
@@ -438,7 +439,7 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
png_set_progressive_read_fn(*png_ptr, (void *)stream_data, png_set_progressive_read_fn(*png_ptr, (void *)stream_data,
info_callback, row_callback, end_callback); info_callback, row_callback, end_callback);
return OK; return (OK);
} }
int int
@@ -449,7 +450,7 @@ process_data(png_structp *png_ptr, png_infop *info_ptr,
{ {
/* Free the png_ptr and info_ptr memory on error */ /* Free the png_ptr and info_ptr memory on error */
png_destroy_read_struct(png_ptr, info_ptr, (png_infopp)NULL); png_destroy_read_struct(png_ptr, info_ptr, (png_infopp)NULL);
return ERROR; return (ERROR);
} }
/* This one's new also. Simply give it chunks of data as /* This one's new also. Simply give it chunks of data as
@@ -463,7 +464,7 @@ process_data(png_structp *png_ptr, png_infop *info_ptr,
* callback, if you aren't already displaying them there. * callback, if you aren't already displaying them there.
*/ */
png_process_data(*png_ptr, *info_ptr, buffer, length); png_process_data(*png_ptr, *info_ptr, buffer, length);
return OK; return (OK);
} }
info_callback(png_structp png_ptr, png_infop info) info_callback(png_structp png_ptr, png_infop info)
@@ -532,7 +533,7 @@ void write_png(char *file_name /* , ... other image information ... */)
/* open the file */ /* open the file */
fp = fopen(file_name, "wb"); fp = fopen(file_name, "wb");
if (fp == NULL) if (fp == NULL)
return; return (ERROR);
/* Create and initialize the png_struct with the desired error handler /* Create and initialize the png_struct with the desired error handler
* functions. If you want to use the default stderr and longjump method, * functions. If you want to use the default stderr and longjump method,
@@ -546,7 +547,7 @@ void write_png(char *file_name /* , ... other image information ... */)
if (png_ptr == NULL) if (png_ptr == NULL)
{ {
fclose(fp); fclose(fp);
return; return (ERROR);
} }
/* Allocate/initialize the image information data. REQUIRED */ /* Allocate/initialize the image information data. REQUIRED */
@@ -555,7 +556,7 @@ void write_png(char *file_name /* , ... other image information ... */)
{ {
fclose(fp); fclose(fp);
png_destroy_write_struct(&png_ptr, (png_infopp)NULL); png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
return; return (ERROR);
} }
/* Set error handling. REQUIRED if you aren't supplying your own /* Set error handling. REQUIRED if you aren't supplying your own
@@ -565,8 +566,8 @@ void write_png(char *file_name /* , ... other image information ... */)
{ {
/* If we get here, we had a problem reading the file */ /* If we get here, we had a problem reading the file */
fclose(fp); fclose(fp);
png_destroy_write_struct(&png_ptr, (png_infopp)info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr);
return; return (ERROR);
} }
/* One of the following I/O initialization functions is REQUIRED */ /* One of the following I/O initialization functions is REQUIRED */
@@ -671,7 +672,7 @@ void write_png(char *file_name /* , ... other image information ... */)
* all optional. Only call them if you want them. * all optional. Only call them if you want them.
*/ */
/* invert monocrome pixels */ /* invert monochrome pixels */
png_set_invert_mono(png_ptr); png_set_invert_mono(png_ptr);
/* Shift the pixels up to a legal bit depth and fill in /* Shift the pixels up to a legal bit depth and fill in
@@ -754,20 +755,22 @@ void write_png(char *file_name /* , ... other image information ... */)
allocated it with malloc() instead of png_malloc(), use free() instead allocated it with malloc() instead of png_malloc(), use free() instead
of png_free(). */ of png_free(). */
png_free(png_ptr, palette); png_free(png_ptr, palette);
palette=NULL;
/* Similarly, if you png_malloced any data that you passed in with /* Similarly, if you png_malloced any data that you passed in with
png_set_something(), such as a hist or trans array, free it here, png_set_something(), such as a hist or trans array, free it here,
when you can be sure that libpng is through with it. */ when you can be sure that libpng is through with it. */
png_free(png_ptr, trans); png_free(png_ptr, trans);
trans=NULL;
/* clean up after the write, and free any memory allocated */ /* clean up after the write, and free any memory allocated */
png_destroy_write_struct(&png_ptr, (png_infopp)info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr);
/* close the file */ /* close the file */
fclose(fp); fclose(fp);
/* that's it */ /* that's it */
return; return (OK);
} }
#endif /* if 0 */ #endif /* if 0 */

612
libpng.3

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
libpng.txt - A description on how to use and modify libpng libpng.txt - A description on how to use and modify libpng
libpng version 1.0.6f - April 14, 2000 libpng version 1.0.9beta5 - December 15, 2000
Updated and distributed by Glenn Randers-Pehrson Updated and distributed by Glenn Randers-Pehrson
<randeg@alum.rpi.edu> <randeg@alum.rpi.edu>
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
@@ -37,8 +37,7 @@ Libpng was written as a companion to the PNG specification, as a way
of reducing the amount of time and effort it takes to support the PNG of reducing the amount of time and effort it takes to support the PNG
file format in application programs. file format in application programs.
The PNG-1.2 specification is available at <http://www.cdrom.com/pub/png> The PNG-1.2 specification is available at <http://www.libpng.org/pub/png>
(will be moving to <http://www.libpng.org>)
and at <ftp://ftp.uu.net/graphics/png/documents/>. and at <ftp://ftp.uu.net/graphics/png/documents/>.
The PNG-1.0 specification is available The PNG-1.0 specification is available
@@ -49,8 +48,7 @@ documents at <ftp://ftp.uu.net/graphics/png/documents/>.
Other information Other information
about PNG, and the latest version of libpng, can be found at the PNG home about PNG, and the latest version of libpng, can be found at the PNG home
page, <http://www.cdrom.com/pub/png/> (will be moving to page, <http://www.libpng.org/pub/png/>
<http://www.libpng.org>)
and at <ftp://ftp.uu.net/graphics/png/>. and at <ftp://ftp.uu.net/graphics/png/>.
Most users will not have to modify the library significantly; advanced Most users will not have to modify the library significantly; advanced
@@ -69,7 +67,7 @@ majority of the needs of its users.
Libpng uses zlib for its compression and decompression of PNG files. Libpng uses zlib for its compression and decompression of PNG files.
Further information about zlib, and the latest version of zlib, can Further information about zlib, and the latest version of zlib, can
be found at the zlib home page, <ftp://ftp.freesoftware.com/pub/infozip/zlib/>. be found at the zlib home page, <http://www.info-zip.org/pub/infozip/zlib/>.
The zlib compression utility is a general purpose utility that is The zlib compression utility is a general purpose utility that is
useful for more than PNG files, and can be used without libpng. useful for more than PNG files, and can be used without libpng.
See the documentation delivered with zlib for more details. See the documentation delivered with zlib for more details.
@@ -94,9 +92,20 @@ The png_info structure is designed to provide information about the
PNG file. At one time, the fields of png_info were intended to be PNG file. At one time, the fields of png_info were intended to be
directly accessible to the user. However, this tended to cause problems directly accessible to the user. However, this tended to cause problems
with applications using dynamically loaded libraries, and as a result with applications using dynamically loaded libraries, and as a result
a set of interface functions for png_info was developed. The fields a set of interface functions for png_info (the png_get_*() and png_set_*()
of png_info are still available for older applications, but it is functions) was developed. The fields of png_info are still available for
suggested that applications use the new interfaces if at all possible. older applications, but it is suggested that applications use the new
interfaces if at all possible.
Applications that do make direct access to the members of png_struct (except
for png_ptr->jmpbuf) must be recompiled whenever the library is updated,
and applications that make direct access to the members of png_info must
be recompiled if they were compiled or loaded with libpng version 1.0.6,
in which the members were in a different order. In version 1.0.7, the
members of the png_info structure reverted to the old order, as they were
in versions 0.97c through 1.0.5. Starting with version 2.0.0, both
structures are going to be hidden, and the contents of the structures will
only be accessible through the png_get/png_set functions.
The png.h header file is an invaluable reference for programming with libpng. The png.h header file is an invaluable reference for programming with libpng.
And while I'm on the topic, make sure you include the libpng header file: And while I'm on the topic, make sure you include the libpng header file:
@@ -137,13 +146,13 @@ Customizing libpng.
FILE *fp = fopen(file_name, "rb"); FILE *fp = fopen(file_name, "rb");
if (!fp) if (!fp)
{ {
return; return (ERROR);
} }
fread(header, 1, number, fp); fread(header, 1, number, fp);
is_png = !png_sig_cmp(header, 0, number); is_png = !png_sig_cmp(header, 0, number);
if (!is_png) if (!is_png)
{ {
return; return (NOT_PNG);
} }
@@ -155,19 +164,21 @@ pointers to error handling functions, and a pointer to a data struct for
use by the error functions, if necessary (the pointer and functions can use by the error functions, if necessary (the pointer and functions can
be NULL if the default error handlers are to be used). See the section be NULL if the default error handlers are to be used). See the section
on Changes to Libpng below regarding the old initialization functions. on Changes to Libpng below regarding the old initialization functions.
The structure allocation functions quietly return NULL if they fail to
create the structure, so your application should check for that.
png_structp png_ptr = png_create_read_struct png_structp png_ptr = png_create_read_struct
(PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
user_error_fn, user_warning_fn); user_error_fn, user_warning_fn);
if (!png_ptr) if (!png_ptr)
return; return (ERROR);
png_infop info_ptr = png_create_info_struct(png_ptr); png_infop info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) if (!info_ptr)
{ {
png_destroy_read_struct(&png_ptr, png_destroy_read_struct(&png_ptr,
(png_infopp)NULL, (png_infopp)NULL); (png_infopp)NULL, (png_infopp)NULL);
return; return (ERROR);
} }
png_infop end_info = png_create_info_struct(png_ptr); png_infop end_info = png_create_info_struct(png_ptr);
@@ -175,7 +186,7 @@ on Changes to Libpng below regarding the old initialization functions.
{ {
png_destroy_read_struct(&png_ptr, &info_ptr, png_destroy_read_struct(&png_ptr, &info_ptr,
(png_infopp)NULL); (png_infopp)NULL);
return; return (ERROR);
} }
If you want to use your own memory allocation routines, If you want to use your own memory allocation routines,
@@ -210,7 +221,7 @@ free any memory.
png_destroy_read_struct(&png_ptr, &info_ptr, png_destroy_read_struct(&png_ptr, &info_ptr,
&end_info); &end_info);
fclose(fp); fclose(fp);
return; return (ERROR);
} }
If you would rather avoid the complexity of setjmp/longjmp issues, If you would rather avoid the complexity of setjmp/longjmp issues,
@@ -337,14 +348,39 @@ dithering, and setting filler.) If this is the case, simply do this:
png_read_png(png_ptr, info_ptr, png_transforms, NULL) png_read_png(png_ptr, info_ptr, png_transforms, NULL)
where png_transforms is an integer containing the logical-or of some set of where png_transforms is an integer containing the logical OR of
transformation flags. This call is equivalent to png_read_info(), some set of transformation flags. This call is equivalent to png_read_info(),
followed the set of transformations indicated by the transform mask, followed the set of transformations indicated by the transform mask,
followed by png_update_info(), followed by a read of the image bytes then png_read_image(), and finally png_read_end().
to the info_ptr, followed by png_read_end().
(The final parameter of this call is not yet used. Someday it (The final parameter of this call is not yet used. Someday it might point
will point to transformation parameters.) to transformation parameters required by some future input transform.)
After you have called png_read_png(), you can retrieve the image data
with
row_pointers = png_get_rows(png_ptr, info_ptr);
where row_pointers is an array of pointers to the pixel data for each row:
png_bytep row_pointers[height];
If you know your image size and pixel size ahead of time, you can allocate
row_pointers prior to calling png_read_png() with
row_pointers = png_malloc(png_ptr, height*sizeof(png_bytep));
for (int i=0; i<height, i++)
row_pointers[i]=png_malloc(png_ptr, width*pixel_size);
png_set_rows(png_ptr, info_ptr, &row_pointers);
Alternatively you could allocate your image in one big block and define
row_pointers[i] to point into the proper places in your block.
If you use png_set_rows(), the application is responsible for freeing
row_pointers (and row_pointers[i], if they were separately allocated).
If you don't allocate row_pointers ahead of time, png_read_png() will
do it, and it'll be free'ed when you call png_destroy_*().
The low-level read interface The low-level read interface
@@ -399,8 +435,8 @@ in until png_read_end() has read the chunk data following the image.
interlace_type - (PNG_INTERLACE_NONE or interlace_type - (PNG_INTERLACE_NONE or
PNG_INTERLACE_ADAM7) PNG_INTERLACE_ADAM7)
Any or all of interlace_type, compression_type, of Any or all of interlace_type, compression_type, of
filter_type can be filter_type can be NULL if you are not
NULL if you are not interested in their values. interested in their values.
channels = png_get_channels(png_ptr, info_ptr); channels = png_get_channels(png_ptr, info_ptr);
channels - number of channels of info for the channels - number of channels of info for the
@@ -484,8 +520,9 @@ into the info_ptr is returned for any complex types.
&trans_values); &trans_values);
trans - array of transparent entries for trans - array of transparent entries for
palette (PNG_INFO_tRNS) palette (PNG_INFO_tRNS)
trans_values - transparent pixel for non-paletted trans_values - graylevel or color sample values of
images (PNG_INFO_tRNS) the single transparent color for
non-paletted images (PNG_INFO_tRNS)
num_trans - number of transparent entries num_trans - number of transparent entries
(PNG_INFO_tRNS) (PNG_INFO_tRNS)
@@ -516,7 +553,7 @@ into the info_ptr is returned for any complex types.
text_ptr[i].key - keyword for comment. Must contain text_ptr[i].key - keyword for comment. Must contain
1-79 characters. 1-79 characters.
text_ptr[i].text - text comments for current text_ptr[i].text - text comments for current
keyword. Can empty. keyword. Can be empty.
text_ptr[i].text_length - length of text string, text_ptr[i].text_length - length of text string,
after decompression, 0 for iTXt after decompression, 0 for iTXt
text_ptr[i].itxt_length - length of itxt string, text_ptr[i].itxt_length - length of itxt string,
@@ -527,7 +564,7 @@ into the info_ptr is returned for any complex types.
(empty string for unknown). (empty string for unknown).
num_text - number of comments (same as num_comments; num_text - number of comments (same as num_comments;
you can put NULL here to avoid the duplication) you can put NULL here to avoid the duplication)
Note while png_set_text() will accept text, language, and Note while png_set_text() will accept text, language, and
translated keywords that can be NULL pointers, the structure translated keywords that can be NULL pointers, the structure
returned by png_get_text will always contain regular returned by png_get_text will always contain regular
zero-terminated C strings. They might be empty strings but zero-terminated C strings. They might be empty strings but
@@ -680,8 +717,8 @@ transparency information in a tRNS chunk. This is most useful on
grayscale images with bit depths of 2 or 4 or if there is a multiple-image grayscale images with bit depths of 2 or 4 or if there is a multiple-image
viewing application that wishes to treat all images in the same way. viewing application that wishes to treat all images in the same way.
if (color_type == PNG_COLOR_TYPE_PALETTE && if (color_type == PNG_COLOR_TYPE_PALETTE)
bit_depth <= 8) png_set_palette_to_rgb(png_ptr); png_set_palette_to_rgb(png_ptr);
if (color_type == PNG_COLOR_TYPE_GRAY && if (color_type == PNG_COLOR_TYPE_GRAY &&
bit_depth < 8) png_set_gray_1_2_4_to_8(png_ptr); bit_depth < 8) png_set_gray_1_2_4_to_8(png_ptr);
@@ -700,17 +737,6 @@ PNG can have files with 16 bits per channel. If you only can handle
if (bit_depth == 16) if (bit_depth == 16)
png_set_strip_16(png_ptr); png_set_strip_16(png_ptr);
The png_set_background() function tells libpng to composite images
with alpha or simple transparency against the supplied background
color. If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid),
you may use this color, or supply another color more suitable for
the current display (e.g., the background color from a web page). You
need to tell libpng whether the color is in the gamma space of the
display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file
(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one
that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't
know why anyone would use this, but it's here).
If, for some reason, you don't need the alpha channel on an image, If, for some reason, you don't need the alpha channel on an image,
and you want to remove it rather than combining it with the background and you want to remove it rather than combining it with the background
(but the image author certainly had in mind that you *would* combine (but the image author certainly had in mind that you *would* combine
@@ -854,6 +880,17 @@ or as an RGB triplet that may or may not be in the palette (need_expand = 0).
png_set_background(png_ptr, &my_background, png_set_background(png_ptr, &my_background,
PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
The png_set_background() function tells libpng to composite images
with alpha or simple transparency against the supplied background
color. If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid),
you may use this color, or supply another color more suitable for
the current display (e.g., the background color from a web page). You
need to tell libpng whether the color is in the gamma space of the
display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file
(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one
that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't
know why anyone would use this, but it's here).
To properly display PNG images on any kind of system, the application needs To properly display PNG images on any kind of system, the application needs
to know what the display gamma is. Ideally, the user will know this, and to know what the display gamma is. Ideally, the user will know this, and
the application will allow them to set it. One method of allowing the user the application will allow them to set it. One method of allowing the user
@@ -1050,7 +1087,7 @@ If you are doing this just one row at a time, you can do this with
a single row_pointer instead of an array of row_pointers: a single row_pointer instead of an array of row_pointers:
png_bytep row_pointer = row; png_bytep row_pointer = row;
png_read_row(png_ptr, row_pointers, NULL); png_read_row(png_ptr, row_pointer, NULL);
If the file is interlaced (interlace_type != 0 in the IHDR chunk), things If the file is interlaced (interlace_type != 0 in the IHDR chunk), things
get somewhat harder. The only current (PNG Specification version 1.2) get somewhat harder. The only current (PNG Specification version 1.2)
@@ -1143,46 +1180,82 @@ When you are done, you can free all memory allocated by libpng like this:
&end_info); &end_info);
It is also possible to individually free the info_ptr members that It is also possible to individually free the info_ptr members that
point to libpng-allocated storage with the following functions: point to libpng-allocated storage with the following function:
png_free_data(png_ptr, info_ptr, mask, n) png_free_data(png_ptr, info_ptr, mask, n)
mask - identifies data to be freed, a mask mask - identifies data to be freed, a mask
made up by the OR one or more of containing the logical OR of one or
PNG_FREE_PLTE, PNG_FREE_TRNS, more of
PNG_FREE_HIST, PNG_FREE_ICCP, PNG_FREE_PLTE, PNG_FREE_TRNS,
PNG_FREE_SPLT, PNG_FREE_ROWS, PNG_FREE_HIST, PNG_FREE_ICCP,
PNG_FREE_TEXT, PNG_FREE_UNKN, PNG_FREE_PCAL, PNG_FREE_ROWS,
or simply PNG_FREE_ALL PNG_FREE_SCAL, PNG_FREE_SPLT,
n - sequence number of item to be freed PNG_FREE_TEXT, PNG_FREE_UNKN,
(-1 for all items) or simply PNG_FREE_ALL
n - sequence number of item to be freed
(-1 for all items)
These functions may be safely called when the relevant storage has This function may be safely called when the relevant storage has
already been freed, or has not yet been allocated, or was allocated already been freed, or has not yet been allocated, or was allocated
by the user and not by libpng, and will in those by the user and not by libpng, and will in those
cases do nothing. The "n" parameter is ignored if only one item cases do nothing. The "n" parameter is ignored if only one item
of the selected data type, such as PLTE, is allowed. If "n" is not of the selected data type, such as PLTE, is allowed. If "n" is not
-1, and multiple items are allowed for the data type identified in -1, and multiple items are allowed for the data type identified in
the mask, such as text or splt, only the n'th item is freed. the mask, such as text or sPLT, only the n'th item is freed.
The default behavior is only to free data that was allocated internally The default behavior is only to free data that was allocated internally
by libpng. This can be changed, so that libpng will not free the data, by libpng. This can be changed, so that libpng will not free the data,
or so that it will also free data that was passed in via a png_set_*() or so that it will free data that was allocated by the user with png_malloc()
function, with or png_zalloc() and passed in via a png_set_*() function, with
png_data_freer(png_ptr, info_ptr, freer, mask) png_data_freer(png_ptr, info_ptr, freer, mask)
mask - which data elements are affected mask - which data elements are affected
same choices as in png_free_data() same choices as in png_free_data()
freer - one of freer - one of
PNG_DESTROY_WILL_FREE_DATA PNG_DESTROY_WILL_FREE_DATA
PNG_SET_WILL_FREE_DATA PNG_SET_WILL_FREE_DATA
PNG_USER_WILL_FREE_DATA PNG_USER_WILL_FREE_DATA
This function only affects data that has already been allocated. This function only affects data that has already been allocated.
You can call this function after reading the PNG data but before calling You can call this function after reading the PNG data but before calling
any png_set_*() functions, to control whether the user or the png_set_*() any png_set_*() functions, to control whether the user or the png_set_*()
function is responsible for freeing any existing data that might be present, function is responsible for freeing any existing data that might be present,
and again after the png_set_*() functions to control whether the user and again after the png_set_*() functions to control whether the user
or png_destroy_*() is supposed to free the data.. or png_destroy_*() is supposed to free the data. When the user assumes
responsibility for libpng-allocated data, the application must use
png_free() to free it, and when the user transfers responsibility to libpng
for data that the user has allocated, the user must have used png_malloc()
or png_zalloc() to allocate it (the png_zalloc() function is the same
as png_malloc() except that it also zeroes the newly-allocated memory).
If you allocated your row_pointers in a single block, as suggested above in
the description of the high level read interface, you must not transfer
responsibility for freeing it to the png_set_rows or png_read_destroy function,
because they would also try to free the individual row_pointers[i].
If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword
separately, do not transfer responsibility for freeing text_ptr to libpng,
because when libpng fills a png_text structure it combines these members with
the key member, and png_free_data() will free only text_ptr.key. Similarly,
if you transfer responsibility for free'ing text_ptr from libpng to your
application, your application must not separately free those members.
The png_free_data() function will turn off the "valid" flag for anything
it frees. If you need to turn the flag off for a chunk that was freed by your
application instead of by libpng, you can use
png_set_invalid(png_ptr, info_ptr, mask);
mask - identifies the chunks to be made invalid,
containing the logical OR of one or
more of
PNG_INFO_gAMA, PNG_INFO_sBIT,
PNG_INFO_cHRM, PNG_INFO_PLTE,
PNG_INFO_tRNS, PNG_INFO_bKGD,
PNG_INFO_hIST, PNG_INFO_pHYs,
PNG_INFO_oFFs, PNG_INFO_tIME,
PNG_INFO_pCAL, PNG_INFO_sRGB,
PNG_INFO_iCCP, PNG_INFO_sPLT,
PNG_INFO_sCAL, PNG_INFO_IDAT
For a more compact example of reading a PNG image, see the file example.c. For a more compact example of reading a PNG image, see the file example.c.
@@ -1212,20 +1285,20 @@ png_infop info_ptr;
(PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
user_error_fn, user_warning_fn); user_error_fn, user_warning_fn);
if (!png_ptr) if (!png_ptr)
return -1; return (ERROR);
info_ptr = png_create_info_struct(png_ptr); info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) if (!info_ptr)
{ {
png_destroy_read_struct(&png_ptr, (png_infopp)NULL, png_destroy_read_struct(&png_ptr, (png_infopp)NULL,
(png_infopp)NULL); (png_infopp)NULL);
return -1; return (ERROR);
} }
if (setjmp(png_jmpbuf(png_ptr))) if (setjmp(png_jmpbuf(png_ptr)))
{ {
png_destroy_read_struct(&png_ptr, &info_ptr, png_destroy_read_struct(&png_ptr, &info_ptr,
(png_infopp)NULL); (png_infopp)NULL);
return -1; return (ERROR);
} }
/* This one's new. You can provide functions /* This one's new. You can provide functions
@@ -1259,7 +1332,7 @@ png_infop info_ptr;
{ {
png_destroy_read_struct(&png_ptr, &info_ptr, png_destroy_read_struct(&png_ptr, &info_ptr,
(png_infopp)NULL); (png_infopp)NULL);
return -1; return (ERROR);
} }
/* This one's new also. Simply give it a chunk /* This one's new also. Simply give it a chunk
@@ -1373,7 +1446,7 @@ custom writing functions. See the discussion under Customizing libpng.
FILE *fp = fopen(file_name, "wb"); FILE *fp = fopen(file_name, "wb");
if (!fp) if (!fp)
{ {
return; return (ERROR);
} }
Next, png_struct and png_info need to be allocated and initialized. Next, png_struct and png_info need to be allocated and initialized.
@@ -1388,14 +1461,14 @@ both "png_ptr"; you can call them anything you like, such as
(PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr,
user_error_fn, user_warning_fn); user_error_fn, user_warning_fn);
if (!png_ptr) if (!png_ptr)
return; return (ERROR);
png_infop info_ptr = png_create_info_struct(png_ptr); png_infop info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) if (!info_ptr)
{ {
png_destroy_write_struct(&png_ptr, png_destroy_write_struct(&png_ptr,
(png_infopp)NULL); (png_infopp)NULL);
return; return (ERROR);
} }
If you want to use your own memory allocation routines, If you want to use your own memory allocation routines,
@@ -1420,9 +1493,9 @@ section below for more information on the libpng error handling.
if (setjmp(png_jmpbuf(png_ptr))) if (setjmp(png_jmpbuf(png_ptr)))
{ {
png_destroy_write_struct(&png_ptr, &info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr);
fclose(fp); fclose(fp);
return; return (ERROR);
} }
... ...
return; return;
@@ -1469,21 +1542,33 @@ speed/compression ratio. The second parameter to png_set_filter() is
the filter method, for which the only valid value is '0' (as of the the filter method, for which the only valid value is '0' (as of the
July 1999 PNG specification, version 1.2). The third parameter is a July 1999 PNG specification, version 1.2). The third parameter is a
flag that indicates which filter type(s) are to be tested for each flag that indicates which filter type(s) are to be tested for each
scanline. See the Compression Library for details on the specific filter scanline. See the PNG specification for details on the specific filter
types. types.
/* turn on or off filtering, and/or choose /* turn on or off filtering, and/or choose
specific filters */ specific filters. You can use either a single PNG_FILTER_VALUE_NAME
or the logical OR of one or more PNG_FILTER_NAME masks. */
png_set_filter(png_ptr, 0, png_set_filter(png_ptr, 0,
PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE |
PNG_FILTER_PAETH); PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB |
PNG_FILTER_UP | PNG_FILTER_VALUE_UP |
PNG_FILTER_AVE | PNG_FILTER_VALUE_AVE |
PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH|
PNG_ALL_FILTERS);
If an application
wants to start and stop using particular filters during compression,
it should start out with all of the filters (to ensure that the previous
row of pixels will be stored in case it's needed later), and then add
and remove them after the start of compression.
The png_set_compression_*() functions interface to the zlib compression The png_set_compression_*() functions interface to the zlib compression
library, and should mostly be ignored unless you really know what you are library, and should mostly be ignored unless you really know what you are
doing. The only generally useful call is png_set_compression_level() doing. The only generally useful call is png_set_compression_level()
which changes how much time zlib spends on trying to compress the image which changes how much time zlib spends on trying to compress the image
data. See the Compression Library for details on the compression levels. data. See the Compression Library (zlib.h and algorithm.txt, distributed
with zlib) for details on the compression levels.
/* set the zlib compression level */ /* set the zlib compression level */
png_set_compression_level(png_ptr, png_set_compression_level(png_ptr,
@@ -1495,6 +1580,9 @@ data. See the Compression Library for details on the compression levels.
Z_DEFAULT_STRATEGY); Z_DEFAULT_STRATEGY);
png_set_compression_window_bits(png_ptr, 15); png_set_compression_window_bits(png_ptr, 15);
png_set_compression_method(png_ptr, 8); png_set_compression_method(png_ptr, 8);
png_set_compression_buffer_size(png_ptr, 8192)
extern PNG_EXPORT(void,png_set_zbuf_size)
Setting the contents of info for output Setting the contents of info for output
@@ -1607,8 +1695,9 @@ Some of the more important parts of the png_info are:
trans_values); trans_values);
trans - array of transparent entries for trans - array of transparent entries for
palette (PNG_INFO_tRNS) palette (PNG_INFO_tRNS)
trans_values - transparent pixel for non-paletted trans_values - graylevel or color sample values of
images (PNG_INFO_tRNS) the single transparent color for
non-paletted images (PNG_INFO_tRNS)
num_trans - number of transparent entries num_trans - number of transparent entries
(PNG_INFO_tRNS) (PNG_INFO_tRNS)
@@ -1703,18 +1792,17 @@ Some of the more important parts of the png_info are:
A quick word about text and num_text. text is an array of png_text A quick word about text and num_text. text is an array of png_text
structures. num_text is the number of valid structures in the array. structures. num_text is the number of valid structures in the array.
If you want, you can use max_text to hold the size of the array, but Each png_text structure holds a language code, a keyword, a text value,
libpng ignores it for writing (it does use it for reading). Each and a compression type.
png_text structure holds a language code, a keyword, a text value, and
a compression type.
The compression types have the same valid numbers as the compression The compression types have the same valid numbers as the compression
types of the image data. Currently, the only valid number is zero. types of the image data. Currently, the only valid number is zero.
However, you can store text either compressed or uncompressed, unlike However, you can store text either compressed or uncompressed, unlike
images, which always have to be compressed. So if you don't want the images, which always have to be compressed. So if you don't want the
text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE. text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE.
Because compressed-text chunks don't have a language field, if you Because tEXt and zTXt chunks don't have a language field, if you
specify compression any language code will not be written out. specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt
any language code or translated keyword will not be written out.
Until text gets around 1000 bytes, it is not worth compressing it. Until text gets around 1000 bytes, it is not worth compressing it.
After the text has been written out to the file, the compression type After the text has been written out to the file, the compression type
@@ -1758,7 +1846,7 @@ Compressed pairs must have a text string, as only the text string
is compressed anyway, so the compression would be meaningless. is compressed anyway, so the compression would be meaningless.
PNG supports modification time via the png_time structure. Two PNG supports modification time via the png_time structure. Two
conversion routines are proved, png_convert_from_time_t() for conversion routines are provided, png_convert_from_time_t() for
time_t and png_convert_from_struct_tm() for struct tm. The time_t and png_convert_from_struct_tm() for struct tm. The
time_t routine uses gmtime(). You don't have to use either of time_t routine uses gmtime(). You don't have to use either of
these, but if you wish to fill in the png_time structure directly, these, but if you wish to fill in the png_time structure directly,
@@ -1810,18 +1898,18 @@ transformations are permitted, enabled by the following masks.
PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples
PNG_TRANSFORM_STRIP_FILLER Strip out filler bytes. PNG_TRANSFORM_STRIP_FILLER Strip out filler bytes.
If you have valid image data in the info structure, simply do this: If you have valid image data in the info structure (you can use
png_set_rows() to put image data in the info structure), simply do this:
png_write_png(png_ptr, info_ptr, png_transforms, NULL) png_write_png(png_ptr, info_ptr, png_transforms, NULL)
where png_transforms is an integer containing the logical-or of some set of where png_transforms is an integer containing the logical OR of some set of
transformation flags. This call is equivalent to png_write_info(), transformation flags. This call is equivalent to png_write_info(),
followed by the set of transformations indicated by the transform followed the set of transformations indicated by the transform mask,
mask, followed by followed by a write of the image bytes from the then png_write_image(), and finally png_write_end().
info_ptr, followed by png_write_end().
(The final parameter of this call is not yet used. Someday it (The final parameter of this call is not yet used. Someday it might point
may point to output transformation parameters.) to transformation parameters required by some future output transform.)
The low-level write interface The low-level write interface
@@ -1874,8 +1962,8 @@ bytes per pixel).
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
where the 0 is unused, and the location is either PNG_FILLER_BEFORE or where the 0 is unused, and the location is either PNG_FILLER_BEFORE or
PNG_FILLER_AFTER, depending upon whether the filler byte in the is stored PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel
XRGB or RGBX. is stored XRGB or RGBX.
PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as
they can, resulting in, for example, 8 pixels per byte for 1 bit files. they can, resulting in, for example, 8 pixels per byte for 1 bit files.
@@ -1886,7 +1974,7 @@ correctly pack the pixels into a single byte:
PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your
data is of another bit depth, you can write an sBIT chunk into the data is of another bit depth, you can write an sBIT chunk into the
file so that decoders can get the original data if desired. file so that decoders can recover the original data if desired.
/* Set the true bit depth of the image data */ /* Set the true bit depth of the image data */
if (color_type & PNG_COLOR_MASK_COLOR) if (color_type & PNG_COLOR_MASK_COLOR)
@@ -1961,8 +2049,8 @@ callback function.
The user_channels and user_depth parameters of this function are ignored The user_channels and user_depth parameters of this function are ignored
when writing; you can set them to zero as shown. when writing; you can set them to zero as shown.
You can retrieve the pointer via the function You can retrieve the pointer via the function png_get_user_transform_ptr().
png_get_user_transform_ptr(). For example: For example:
voidp write_user_transform_ptr = voidp write_user_transform_ptr =
png_get_user_transform_ptr(png_ptr); png_get_user_transform_ptr(png_ptr);
@@ -2024,7 +2112,7 @@ a single row_pointer instead of an array of row_pointers:
png_write_row(png_ptr, row_pointer); png_write_row(png_ptr, row_pointer);
When the file is interlaced, things can get a good deal more When the file is interlaced, things can get a good deal more
complicated. The only currently (as of January 2000 -- PNG Specification complicated. The only currently (as of the PNG Specification
version 1.2, dated July 1999) defined interlacing scheme for PNG files version 1.2, dated July 1999) defined interlacing scheme for PNG files
is the "Adam7" interlace scheme, that breaks down an is the "Adam7" interlace scheme, that breaks down an
image into seven smaller images of varying size. libpng will build image into seven smaller images of varying size. libpng will build
@@ -2068,42 +2156,45 @@ When you are done, you can free all memory used by libpng like this:
png_destroy_write_struct(&png_ptr, &info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr);
It is also possible to individually free the info_ptr members that It is also possible to individually free the info_ptr members that
point to libpng-allocated storage with the following functions: point to libpng-allocated storage with the following function:
png_free_data(png_ptr, info_ptr, mask, n) png_free_data(png_ptr, info_ptr, mask, n)
mask - identifies data to be freed, a mask mask - identifies data to be freed, a mask
made up by the OR one or more of containing the logical OR of one or
PNG_FREE_PLTE, PNG_FREE_TRNS, more of
PNG_FREE_HIST, PNG_FREE_ICCP, PNG_FREE_PLTE, PNG_FREE_TRNS,
PNG_FREE_SPLT, PNG_FREE_ROWS, PNG_FREE_HIST, PNG_FREE_ICCP,
PNG_FREE_TEXT, PNG_FREE_UNKN, PNG_FREE_PCAL, PNG_FREE_ROWS,
or simply PNG_FREE_ALL PNG_FREE_SCAL, PNG_FREE_SPLT,
n - sequence number of item to be freed PNG_FREE_TEXT, PNG_FREE_UNKN,
(-1 for all items) or simply PNG_FREE_ALL
n - sequence number of item to be freed
(-1 for all items)
These functions may be safely called when the relevant storage has This function may be safely called when the relevant storage has
already been freed, or has not yet been allocated, and will in that already been freed, or has not yet been allocated, or was allocated
case do nothing. The "n" parameter is ignored if only one item by the user and not by libpng, and will in those
cases do nothing. The "n" parameter is ignored if only one item
of the selected data type, such as PLTE, is allowed. If "n" is not of the selected data type, such as PLTE, is allowed. If "n" is not
-1, and multiple items are allowed for the data type identified in -1, and multiple items are allowed for the data type identified in
the mask, such as text or splt, only the n'th item is freed. the mask, such as text or sPLT, only the n'th item is freed.
If you allocated data such as a palette that you passed in to libpng with If you allocated data such as a palette that you passed
png_set_*, you must not free it until just before the call to in to libpng with png_set_*, you must not free it until just before the call to
png_destroy_write_struct(). png_destroy_write_struct().
The default behavior is only to free data that was allocated internally The default behavior is only to free data that was allocated internally
by libpng. This can be changed, so that libpng will not free the data, by libpng. This can be changed, so that libpng will not free the data,
or so that it will free data that was passed in via a png_set_*() function, or so that it will free data that was allocated by the user with png_malloc()
with or png_zalloc() and passed in via a png_set_*() function, with
png_data_freer(png_ptr, info_ptr, freer, mask) png_data_freer(png_ptr, info_ptr, freer, mask)
mask - which data elements are affected mask - which data elements are affected
same choices as in png_free_data() same choices as in png_free_data()
freer - one of freer - one of
PNG_DESTROY_WILL_FREE_DATA PNG_DESTROY_WILL_FREE_DATA
PNG_SET_WILL_FREE_DATA PNG_SET_WILL_FREE_DATA
PNG_USER_WILL_FREE_DATA PNG_USER_WILL_FREE_DATA
For example, to transfer responsibility for some data from a read structure For example, to transfer responsibility for some data from a read structure
to a write structure, you could use to a write structure, you could use
@@ -2115,12 +2206,27 @@ to a write structure, you could use
PNG_DESTROY_WILL_FREE_DATA, PNG_DESTROY_WILL_FREE_DATA,
PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST)
Thereby briefly reassigning responsibility for freeing to the user but thereby briefly reassigning responsibility for freeing to the user but
immediately afterwards reassigning it once more to the write_destroy immediately afterwards reassigning it once more to the write_destroy
function. Having done this, it would then be safe to destroy the read function. Having done this, it would then be safe to destroy the read
structure and continue to use the PLTE, tRNS, and hIST data in the write structure and continue to use the PLTE, tRNS, and hIST data in the write
structure. structure.
This function only affects data that has already been allocated.
You can call this function before calling after the png_set_*() functions
to control whether the user or png_destroy_*() is supposed to free the data.
When the user assumes responsibility for libpng-allocated data, the
application must use
png_free() to free it, and when the user transfers responsibility to libpng
for data that the user has allocated, the user must have used png_malloc()
or png_zalloc() to allocate it.
If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword
separately, do not transfer responsibility for freeing text_ptr to libpng,
because when libpng fills a png_text structure it combines these members with
the key member, and png_free_data() will free only text_ptr.key. Similarly,
if you transfer responsibility for free'ing text_ptr from libpng to your
application, your application must not separately free those members.
For a more compact example of writing a PNG image, see the file example.c. For a more compact example of writing a PNG image, see the file example.c.
V. Modifying/Customizing libpng: V. Modifying/Customizing libpng:
@@ -2132,25 +2238,35 @@ adding new transformations, and generally changing how libpng works.
All of the memory allocation, input/output, and error handling in libpng All of the memory allocation, input/output, and error handling in libpng
goes through callbacks that are user settable. The default routines are goes through callbacks that are user settable. The default routines are
in pngmem.c, pngrio.c, pngwio.c, and pngerror.c respectively. To change in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change
these functions, call the appropriate png_set_*_fn() function. these functions, call the appropriate png_set_*_fn() function.
Memory allocation is done through the functions png_large_malloc(), Memory allocation is done through the functions png_malloc(), png_zalloc(),
png_malloc(), png_realloc(), png_large_free(), and png_free(). These and png_free(). These currently just call the standard C functions. If
currently just call the standard C functions. The large functions must
handle exactly 64K, but they don't have to handle more than that. If
your pointers can't access more then 64K at a time, you will want to set your pointers can't access more then 64K at a time, you will want to set
MAXSEG_64K in zlib.h. Since it is unlikely that the method of handling MAXSEG_64K in zlib.h. Since it is unlikely that the method of handling
memory allocation on a platform will change between applications, these memory allocation on a platform will change between applications, these
functions must be modified in the library at compile time. functions must be modified in the library at compile time. If you prefer
to use a different method of allocating and freeing data, you can use
png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
malloc_fn, png_free_ptr free_fn)
This function also provides a void pointer that can be retrieved via
mem_ptr=png_get_mem_ptr(png_ptr);
Your replacement memory functions must have prototypes as follows:
png_voidp malloc_fn(png_structp png_ptr, png_uint_32 size);
void free_fn(png_structp png_ptr, png_voidp ptr);
Input/Output in libpng is done through png_read() and png_write(), Input/Output in libpng is done through png_read() and png_write(),
which currently just call fread() and fwrite(). The FILE * is stored in which currently just call fread() and fwrite(). The FILE * is stored in
png_struct and is initialized via png_init_io(). If you wish to change png_struct and is initialized via png_init_io(). If you wish to change
the method of I/O, the library supplies callbacks that you can set the method of I/O, the library supplies callbacks that you can set
through the function png_set_read_fn() and png_set_write_fn() at run through the function png_set_read_fn() and png_set_write_fn() at run
time, instead of calling the png_init_io() function. time, instead of calling the png_init_io() function. These functions
These functions
also provide a void pointer that can be retrieved via the function also provide a void pointer that can be retrieved via the function
png_get_io_ptr(). For example: png_get_io_ptr(). For example:
@@ -2164,7 +2280,7 @@ png_get_io_ptr(). For example:
voidp read_io_ptr = png_get_io_ptr(read_ptr); voidp read_io_ptr = png_get_io_ptr(read_ptr);
voidp write_io_ptr = png_get_io_ptr(write_ptr); voidp write_io_ptr = png_get_io_ptr(write_ptr);
The replacement I/O functions should have prototypes as follows: The replacement I/O functions must have prototypes as follows:
void user_read_data(png_structp png_ptr, void user_read_data(png_structp png_ptr,
png_bytep data, png_uint_32 length); png_bytep data, png_uint_32 length);
@@ -2191,8 +2307,8 @@ fprintf() unless the library is compiled with PNG_NO_CONSOLE_IO defined
fprintf() isn't available). If you wish to change the behavior of the error fprintf() isn't available). If you wish to change the behavior of the error
functions, you will need to set up your own message callbacks. These functions, you will need to set up your own message callbacks. These
functions are normally supplied at the time that the png_struct is created. functions are normally supplied at the time that the png_struct is created.
It is also possible to change these functions after png_create_*_struct() It is also possible to redirect errors and warnings to your own replacement
has been called by calling: functions after png_create_*_struct() has been called by calling:
png_set_error_fn(png_structp png_ptr, png_set_error_fn(png_structp png_ptr,
png_voidp error_ptr, png_error_ptr error_fn, png_voidp error_ptr, png_error_ptr error_fn,
@@ -2216,7 +2332,8 @@ as there is no need to check every return code of every function call.
However, there are some uncertainties about the status of local variables However, there are some uncertainties about the status of local variables
after a longjmp, so the user may want to be careful about doing anything after after a longjmp, so the user may want to be careful about doing anything after
setjmp returns non-zero besides returning itself. Consult your compiler setjmp returns non-zero besides returning itself. Consult your compiler
documentation for more details. documentation for more details. For an alternative approach, you may wish
to use the "cexcept" facility (see http://cexcept.sourceforge.net).
Custom chunks Custom chunks
@@ -2246,10 +2363,7 @@ can be found in the comments inside the code itself.
Configuring for 16 bit platforms Configuring for 16 bit platforms
You may need to change the png_large_malloc() and png_large_free() You will want to look into zconf.h to tell zlib (and thus libpng) that
routines in pngmem.c, as these are required to allocate 64K, although
there is already support for many of the common DOS compilers. Also,
you will want to look into zconf.h to tell zlib (and thus libpng) that
it cannot allocate more then 64K at a time. Even if you can, the memory it cannot allocate more then 64K at a time. Even if you can, the memory
won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K. won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
@@ -2318,6 +2432,7 @@ zlib.h for more information on what these mean.
png_set_compression_window_bits(png_ptr, png_set_compression_window_bits(png_ptr,
window_bits); window_bits);
png_set_compression_method(png_ptr, method); png_set_compression_method(png_ptr, method);
png_set_compression_buffer_size(png_ptr, size);
Controlling row filtering Controlling row filtering
@@ -2338,15 +2453,21 @@ to turn filtering on and off, respectively.
Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB, Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB,
PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise
ORed together '|' to specify one or more filters to use. These ORed together with '|' to specify one or more filters to use.
filters are described in more detail in the PNG specification. If These filters are described in more detail in the PNG specification. If
you intend to change the filter type during the course of writing you intend to change the filter type during the course of writing
the image, you should start with flags set for all of the filters the image, you should start with flags set for all of the filters
you intend to use so that libpng can initialize its internal you intend to use so that libpng can initialize its internal
structures appropriately for all of the filter types. structures appropriately for all of the filter types.
filters = PNG_FILTER_NONE | PNG_FILTER_SUB filters = PNG_FILTER_NONE | PNG_FILTER_SUB
| PNG_FILTER_UP; PNG_FILTER_UP | PNG_FILTER_AVE |
PNG_FILTER_PAETH | PNG_ALL_FILTERS;
or
filters = one of PNG_FILTER_VALUE_NONE,
PNG_FILTER_VALUE_SUB, PNG_FILTER_VALUE_UP,
PNG_FILTER_VALUE_AVE, PNG_FILTER_VALUE_PAETH
png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE,
filters); filters);
@@ -2395,7 +2516,7 @@ you can turn off individual capabilities with defines that begin with
PNG_NO_. PNG_NO_.
You can also turn all of the transforms and ancillary chunk capabilities You can also turn all of the transforms and ancillary chunk capabilities
off en masse with compiler directives that define off en masse with compiler directives that define
PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS, PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
or all four, or all four,
along with directives to turn on any of the capabilities that you do along with directives to turn on any of the capabilities that you do
@@ -2460,7 +2581,24 @@ When PNG_DEBUG = 1, the macros are defined, but only png_debug statements
having level = 0 will be printed. There aren't any such statements in having level = 0 will be printed. There aren't any such statements in
this version of libpng, but if you insert some they will be printed. this version of libpng, but if you insert some they will be printed.
VI. Changes to Libpng from version 0.88 VI. MNG support
The MNG specification (available at http://www.libpng.org/pub/mng) allows
certain extensions to PNG for PNG images that are embedded in MNG datastreams.
Libpng can support some of these extensions. To enable them, use the
png_permit_mng_features() function:
feature_set = png_permit_mng_features(png_ptr, mask)
mask is a png_uint_32 containing the logical OR of the
features you want to enable. These include
PNG_FLAG_MNG_EMPTY_PLTE
PNG_FLAG_MNG_FILTER_64
PNG_ALL_MNG_FEATURES
feature_set is a png_32_uint that is the logical AND of
your mask with the set of MNG features that is
supported by the version of libpng that you are using.
VII. Changes to Libpng from version 0.88
It should be noted that versions of libpng later than 0.96 are not It should be noted that versions of libpng later than 0.96 are not
distributed by the original libpng author, Guy Schalnat, nor by distributed by the original libpng author, Guy Schalnat, nor by
@@ -2471,8 +2609,10 @@ still alive and well, but they have moved on to other things.
The old libpng functions png_read_init(), png_write_init(), The old libpng functions png_read_init(), png_write_init(),
png_info_init(), png_read_destroy(), and png_write_destory() have been png_info_init(), png_read_destroy(), and png_write_destory() have been
moved to PNG_INTERNAL in version 0.95 to discourage their use. The moved to PNG_INTERNAL in version 0.95 to discourage their use. These
preferred method of creating and initializing the libpng structures is functions will be removed from libpng version 2.0.0.
The preferred method of creating and initializing the libpng structures is
via the png_create_read_struct(), png_create_write_struct(), and via the png_create_read_struct(), png_create_write_struct(), and
png_create_info_struct() because they isolate the size of the structures png_create_info_struct() because they isolate the size of the structures
from the application, allow version error checking, and also allow the from the application, allow version error checking, and also allow the
@@ -2489,19 +2629,33 @@ png_read_init() as was suggested in libpng-0.88 is no longer supported
because this caused applications that do not use custom error functions because this caused applications that do not use custom error functions
to fail if the png_ptr was not initialized to zero. It is still possible to fail if the png_ptr was not initialized to zero. It is still possible
to set the error callbacks AFTER png_read_init(), or to change them with to set the error callbacks AFTER png_read_init(), or to change them with
png_set_error_fn(), which is essentially the same function, but with a png_set_error_fn(), which is essentially the same function, but with a new
new name to force compilation errors with applications that try to use name to force compilation errors with applications that try to use the old
the old method. method.
VII. Y2K Compliance in libpng Starting with version 1.0.7, you can find out which version of the library
you are using at run-time:
April 14, 2000 png_uint_32 libpng_vn = png_access_version_number();
The number libpng_vn is constructed from the major version, minor
version with leading zero, and release number with leading zero,
(e.g., libpng_vn for version 1.0.7 is 10007).
You can also check which version of png.h you used when compiling your
application:
png_uint_32 application_vn = PNG_LIBPNG_VER;
VIII. Y2K Compliance in libpng
December 15, 2000
Since the PNG Development group is an ad-hoc body, we can't make Since the PNG Development group is an ad-hoc body, we can't make
an official declaration. an official declaration.
This is your unofficial assurance that libpng from version 0.71 and This is your unofficial assurance that libpng from version 0.71 and
upward through 1.0.6f are Y2K compliant. It is my belief that earlier upward through 1.0.9beta5 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant. versions were also Y2K compliant.
Libpng only has three year fields. One is a 2-byte unsigned integer that Libpng only has three year fields. One is a 2-byte unsigned integer that

View File

@@ -1,6 +1,6 @@
.TH LIBPNGPF 3 April 14, 2000 .TH LIBPNGPF 3 "December 15, 2000"
.SH NAME .SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.6f libpng \- Portable Network Graphics (PNG) Reference Library 1.0.9beta5
(private functions) (private functions)
.SH SYNOPSIS .SH SYNOPSIS
\fB#include <png.h>\fP \fB#include <png.h>\fP
@@ -383,10 +383,6 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.6f
\fI\fB \fI\fB
\fBvoid png_read_init (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_read_push_finish_row (png_structp \fIpng_ptr\fP\fB);\fP \fBvoid png_read_push_finish_row (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB \fI\fB
@@ -469,10 +465,6 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.6f
\fI\fB \fI\fB
\fBvoid png_write_init (png_structp \fIpng_ptr\fP\fB);\fP
\fI\fB
\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 \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
\fI\fB \fI\fB

4
png.5
View File

@@ -1,4 +1,4 @@
.TH PNG 5 "April 14, 2000" .TH PNG 5 "December 15, 2000"
.SH NAME .SH NAME
png \- Portable Network Graphics (PNG) format png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION .SH DESCRIPTION
@@ -23,7 +23,7 @@ platforms.
PNG 1.2 specification, July 1999: PNG 1.2 specification, July 1999:
.IP .IP
.br .br
http://www.cdrom.com/pub/png (moving to http://www.libpng.org) http://www.libpng.org/pub/png
.br .br
or ftp://ftp.uu.net/graphics/png/documents or ftp://ftp.uu.net/graphics/png/documents
.LP .LP

326
png.c
View File

@@ -1,31 +1,30 @@
/* png.c - location for general purpose libpng functions /* png.c - location for general purpose libpng functions
* *
* libpng version 1.0.6f - April 14, 2000 * libpng version 1.0.9beta5 - December 15, 2000
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
#define PNG_NO_EXTERN #define PNG_NO_EXTERN
#include <assert.h>
#include "png.h" #include "png.h"
/* Generate a compiler error if there is an old png.h in the search path. */ /* Generate a compiler error if there is an old png.h in the search path. */
typedef version_1_0_6f Your_png_h_is_not_version_1_0_6f; typedef version_1_0_9beta5 Your_png_h_is_not_version_1_0_9beta5;
/* Version information for C files. This had better match the version /* Version information for C files. This had better match the version
* string defined in png.h. */ * string defined in png.h. */
#ifdef PNG_USE_GLOBAL_ARRAYS #ifdef PNG_USE_GLOBAL_ARRAYS
/* png_libpng_ver was changed to a function in version 1.0.5c */ /* png_libpng_ver was changed to a function in version 1.0.5c */
char png_libpng_ver[12] = "1.0.6f"; const char png_libpng_ver[18] = "1.0.9beta5";
/* png_sig was changed to a function in version 1.0.5c */ /* png_sig was changed to a function in version 1.0.5c */
/* Place to hold the signature string for a PNG file. */ /* Place to hold the signature string for a PNG file. */
png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; const png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
/* Invoke global declarations for constant strings for known chunk types */ /* Invoke global declarations for constant strings for known chunk types */
PNG_IHDR; PNG_IHDR;
@@ -53,32 +52,33 @@ PNG_zTXt;
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* start of interlace block */ /* start of interlace block */
int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
/* offset to next interlace block */ /* offset to next interlace block */
int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
/* start of interlace block in the y direction */ /* start of interlace block in the y direction */
int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
/* offset to next interlace block in the y direction */ /* offset to next interlace block in the y direction */
int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
/* width of interlace block (used in assembler routines only) */ /* width of interlace block (used in assembler routines only) */
#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW #ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1};
#endif #endif
/* Height of interlace block. This is not currently used - if you need /* Height of interlace block. This is not currently used - if you need
* it, uncomment it here and in png.h * it, uncomment it here and in png.h
int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
*/ */
/* Mask to determine which pixels are valid in a pass */ /* Mask to determine which pixels are valid in a pass */
int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; const int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
/* Mask to determine which pixels to overwrite while displaying */ /* Mask to determine which pixels to overwrite while displaying */
int FARDATA png_pass_dsp_mask[] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; const int FARDATA png_pass_dsp_mask[]
= {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
#endif #endif
@@ -88,7 +88,7 @@ int FARDATA png_pass_dsp_mask[] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
* or write any of the magic bytes before it starts on the IHDR. * or write any of the magic bytes before it starts on the IHDR.
*/ */
void void PNGAPI
png_set_sig_bytes(png_structp png_ptr, int num_bytes) png_set_sig_bytes(png_structp png_ptr, int num_bytes)
{ {
png_debug(1, "in png_set_sig_bytes\n"); png_debug(1, "in png_set_sig_bytes\n");
@@ -106,7 +106,7 @@ png_set_sig_bytes(png_structp png_ptr, int num_bytes)
* respectively, to be less than, to match, or be greater than the correct * respectively, to be less than, to match, or be greater than the correct
* PNG signature (this is the same behaviour as strcmp, memcmp, etc). * PNG signature (this is the same behaviour as strcmp, memcmp, etc).
*/ */
int int PNGAPI
png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check) png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
{ {
png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
@@ -128,19 +128,20 @@ png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
* to check a partial signature. This function might be removed in the * to check a partial signature. This function might be removed in the
* future - use png_sig_cmp(). Returns true (nonzero) if the file is a PNG. * future - use png_sig_cmp(). Returns true (nonzero) if the file is a PNG.
*/ */
int int PNGAPI
png_check_sig(png_bytep sig, int num) png_check_sig(png_bytep sig, int num)
{ {
return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num)); return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num));
} }
/* Function to allocate memory for zlib. */ /* Function to allocate memory for zlib and clear it to 0. */
voidpf voidpf PNGAPI
png_zalloc(voidpf png_ptr, uInt items, uInt size) png_zalloc(voidpf png_ptr, uInt items, uInt size)
{ {
png_uint_32 num_bytes = (png_uint_32)items * size; png_uint_32 num_bytes = (png_uint_32)items * size;
png_voidp ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes); png_voidp ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes);
#ifndef PNG_NO_ZALLOC_ZERO
if (num_bytes > (png_uint_32)0x8000L) if (num_bytes > (png_uint_32)0x8000L)
{ {
png_memset(ptr, 0, (png_size_t)0x8000L); png_memset(ptr, 0, (png_size_t)0x8000L);
@@ -151,11 +152,12 @@ png_zalloc(voidpf png_ptr, uInt items, uInt size)
{ {
png_memset(ptr, 0, (png_size_t)num_bytes); png_memset(ptr, 0, (png_size_t)num_bytes);
} }
#endif
return ((voidpf)ptr); return ((voidpf)ptr);
} }
/* function to free memory for zlib */ /* function to free memory for zlib */
void void PNGAPI
png_zfree(voidpf png_ptr, voidpf ptr) png_zfree(voidpf png_ptr, voidpf ptr)
{ {
png_free((png_structp)png_ptr, (png_voidp)ptr); png_free((png_structp)png_ptr, (png_voidp)ptr);
@@ -164,7 +166,7 @@ png_zfree(voidpf png_ptr, voidpf ptr)
/* Reset the CRC variable to 32 bits of 1's. Care must be taken /* Reset the CRC variable to 32 bits of 1's. Care must be taken
* in case CRC is > 32 bits to leave the top bits 0. * in case CRC is > 32 bits to leave the top bits 0.
*/ */
void void /* PRIVATE */
png_reset_crc(png_structp png_ptr) png_reset_crc(png_structp png_ptr)
{ {
png_ptr->crc = crc32(0, Z_NULL, 0); png_ptr->crc = crc32(0, Z_NULL, 0);
@@ -175,7 +177,7 @@ png_reset_crc(png_structp png_ptr)
* also check that this data will actually be used before going to the * also check that this data will actually be used before going to the
* trouble of calculating it. * trouble of calculating it.
*/ */
void void /* PRIVATE */
png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length) png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length)
{ {
int need_crc = 1; int need_crc = 1;
@@ -202,7 +204,7 @@ png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length)
* and png_info_init() so that applications that want to use a shared * and png_info_init() so that applications that want to use a shared
* libpng don't have to be recompiled if png_info changes size. * libpng don't have to be recompiled if png_info changes size.
*/ */
png_infop png_infop PNGAPI
png_create_info_struct(png_structp png_ptr) png_create_info_struct(png_structp png_ptr)
{ {
png_infop info_ptr; png_infop info_ptr;
@@ -227,7 +229,7 @@ png_create_info_struct(png_structp png_ptr)
* png_destroy_write_struct() to free an info struct, but this may be * png_destroy_write_struct() to free an info struct, but this may be
* useful for some applications. * useful for some applications.
*/ */
void void PNGAPI
png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr) png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
{ {
png_infop info_ptr = NULL; png_infop info_ptr = NULL;
@@ -253,7 +255,7 @@ png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
* and applications using it are urged to use png_create_info_struct() * and applications using it are urged to use png_create_info_struct()
* instead. * instead.
*/ */
void void PNGAPI
png_info_init(png_infop info_ptr) png_info_init(png_infop info_ptr)
{ {
png_debug(1, "in png_info_init\n"); png_debug(1, "in png_info_init\n");
@@ -261,7 +263,8 @@ png_info_init(png_infop info_ptr)
png_memset(info_ptr, 0, sizeof (png_info)); png_memset(info_ptr, 0, sizeof (png_info));
} }
void #ifdef PNG_FREE_ME_SUPPORTED
void PNGAPI
png_data_freer(png_structp png_ptr, png_infop info_ptr, png_data_freer(png_structp png_ptr, png_infop info_ptr,
int freer, png_uint_32 mask) int freer, png_uint_32 mask)
{ {
@@ -276,8 +279,9 @@ png_data_freer(png_structp png_ptr, png_infop info_ptr,
png_warning(png_ptr, png_warning(png_ptr,
"Unknown freer parameter in png_data_freer."); "Unknown freer parameter in png_data_freer.");
} }
#endif
void void PNGAPI
png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, int num) png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, int num)
{ {
png_debug(1, "in png_free_data\n"); png_debug(1, "in png_free_data\n");
@@ -286,101 +290,124 @@ png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, int num
#if defined(PNG_TEXT_SUPPORTED) #if defined(PNG_TEXT_SUPPORTED)
/* free text item num or (if num == -1) all text items */ /* free text item num or (if num == -1) all text items */
if (mask & info_ptr->free_me & PNG_FREE_TEXT) #ifdef PNG_FREE_ME_SUPPORTED
if ((mask & PNG_FREE_TEXT) & info_ptr->free_me)
#else
if (mask & PNG_FREE_TEXT)
#endif
{ {
if (num != -1) if (num != -1)
{ {
if (info_ptr->text[num].key) if (info_ptr->text && info_ptr->text[num].key)
{ {
png_free(png_ptr, info_ptr->text[num].key); png_free(png_ptr, info_ptr->text[num].key);
info_ptr->text[num].key = NULL; info_ptr->text[num].key = NULL;
} }
} }
else if (info_ptr->text != NULL) else
{ {
int i; int i;
for (i = 0; i < info_ptr->num_text; i++) for (i = 0; i < info_ptr->num_text; i++)
png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i); png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i);
png_free(png_ptr, info_ptr->text); png_free(png_ptr, info_ptr->text);
info_ptr->text = NULL; info_ptr->text = NULL;
info_ptr->num_text=0; info_ptr->num_text=0;
} }
} }
#endif #endif
#if defined(PNG_tRNS_SUPPORTED) #if defined(PNG_tRNS_SUPPORTED)
/* free any tRNS entry */ /* free any tRNS entry */
if (mask & PNG_FREE_TRNS) #ifdef PNG_FREE_ME_SUPPORTED
if ((mask & PNG_FREE_TRNS) & info_ptr->free_me)
#else
if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS))
#endif
{ {
if (info_ptr->valid & PNG_INFO_tRNS) png_free(png_ptr, info_ptr->trans);
{ info_ptr->valid &= ~PNG_INFO_tRNS;
if (info_ptr->free_me & PNG_FREE_TRNS) info_ptr->trans = NULL;
png_free(png_ptr, info_ptr->trans);
info_ptr->valid &= ~PNG_INFO_tRNS;
}
} }
#endif #endif
#if defined(PNG_sCAL_SUPPORTED) #if defined(PNG_sCAL_SUPPORTED)
/* free any sCAL entry */ /* free any sCAL entry */
{ #ifdef PNG_FREE_ME_SUPPORTED
if (info_ptr->valid & PNG_INFO_sCAL) if ((mask & PNG_FREE_SCAL) & info_ptr->free_me)
{ #else
#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) if (mask & PNG_FREE_SCAL)
png_free(png_ptr, info_ptr->scal_s_width);
png_free(png_ptr, info_ptr->scal_s_height);
#endif #endif
info_ptr->valid &= ~PNG_INFO_sCAL; {
} #if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
png_free(png_ptr, info_ptr->scal_s_width);
png_free(png_ptr, info_ptr->scal_s_height);
info_ptr->scal_s_width = NULL;
info_ptr->scal_s_height = NULL;
#endif
info_ptr->valid &= ~PNG_INFO_sCAL;
} }
#endif #endif
#if defined(PNG_pCAL_SUPPORTED) #if defined(PNG_pCAL_SUPPORTED)
/* free any pCAL entry */ /* free any pCAL entry */
#ifdef PNG_FREE_ME_SUPPORTED
if ((mask & PNG_FREE_PCAL) & info_ptr->free_me)
#else
if (mask & PNG_FREE_PCAL)
#endif
{ {
if (info_ptr->valid & PNG_INFO_pCAL) png_free(png_ptr, info_ptr->pcal_purpose);
{ png_free(png_ptr, info_ptr->pcal_units);
png_free(png_ptr, info_ptr->pcal_purpose); info_ptr->pcal_purpose = NULL;
png_free(png_ptr, info_ptr->pcal_units); info_ptr->pcal_units = NULL;
if (info_ptr->pcal_params != NULL) if (info_ptr->pcal_params != NULL)
{ {
int i; int i;
for (i = 0; i < (int)info_ptr->pcal_nparams; i++) for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
{ {
png_free(png_ptr, info_ptr->pcal_params[i]); png_free(png_ptr, info_ptr->pcal_params[i]);
} info_ptr->pcal_params[i]=NULL;
png_free(png_ptr, info_ptr->pcal_params); }
} png_free(png_ptr, info_ptr->pcal_params);
info_ptr->valid &= ~PNG_INFO_pCAL; info_ptr->pcal_params = NULL;
} }
info_ptr->valid &= ~PNG_INFO_pCAL;
} }
#endif #endif
#if defined(PNG_iCCP_SUPPORTED) #if defined(PNG_iCCP_SUPPORTED)
/* free any iCCP entry */ /* free any iCCP entry */
#ifdef PNG_FREE_ME_SUPPORTED
if ((mask & PNG_FREE_ICCP) & info_ptr->free_me)
#else
if (mask & PNG_FREE_ICCP) if (mask & PNG_FREE_ICCP)
#endif
{ {
if (info_ptr->valid & PNG_INFO_iCCP) png_free(png_ptr, info_ptr->iccp_name);
{ png_free(png_ptr, info_ptr->iccp_profile);
if (info_ptr->free_me & PNG_FREE_ICCP) info_ptr->iccp_name = NULL;
{ info_ptr->iccp_profile = NULL;
png_free(png_ptr, info_ptr->iccp_name); info_ptr->valid &= ~PNG_INFO_iCCP;
png_free(png_ptr, info_ptr->iccp_profile);
}
info_ptr->valid &= ~PNG_INFO_iCCP;
}
} }
#endif #endif
#if defined(PNG_sPLT_SUPPORTED) #if defined(PNG_sPLT_SUPPORTED)
/* free a given sPLT entry, or (if num == -1) all sPLT entries */ /* free a given sPLT entry, or (if num == -1) all sPLT entries */
#ifdef PNG_FREE_ME_SUPPORTED
if ((mask & PNG_FREE_SPLT) & info_ptr->free_me)
#else
if (mask & PNG_FREE_SPLT) if (mask & PNG_FREE_SPLT)
#endif
{ {
if (num != -1) if (num != -1)
{ {
png_free(png_ptr, info_ptr->splt_palettes[num].name); if(info_ptr->splt_palettes)
png_free(png_ptr, info_ptr->splt_palettes[num].entries); {
info_ptr->valid &= ~PNG_INFO_sPLT; png_free(png_ptr, info_ptr->splt_palettes[num].name);
png_free(png_ptr, info_ptr->splt_palettes[num].entries);
info_ptr->splt_palettes[num].name = NULL;
info_ptr->splt_palettes[num].entries = NULL;
}
} }
else else
{ {
@@ -391,19 +418,28 @@ if (mask & PNG_FREE_SPLT)
png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i); png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i);
png_free(png_ptr, info_ptr->splt_palettes); png_free(png_ptr, info_ptr->splt_palettes);
info_ptr->splt_palettes = NULL;
info_ptr->splt_palettes_num = 0; info_ptr->splt_palettes_num = 0;
} }
info_ptr->valid &= ~PNG_INFO_sPLT;
} }
} }
#endif #endif
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
#ifdef PNG_FREE_ME_SUPPORTED
if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)
#else
if (mask & PNG_FREE_UNKN) if (mask & PNG_FREE_UNKN)
#endif
{ {
if (num != -1) if (num != -1)
{ {
png_free(png_ptr, info_ptr->unknown_chunks[num].data); if(info_ptr->unknown_chunks)
info_ptr->unknown_chunks[num].data = NULL; {
png_free(png_ptr, info_ptr->unknown_chunks[num].data);
info_ptr->unknown_chunks[num].data = NULL;
}
} }
else else
{ {
@@ -415,6 +451,7 @@ if (mask & PNG_FREE_UNKN)
png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i); png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i);
png_free(png_ptr, info_ptr->unknown_chunks); png_free(png_ptr, info_ptr->unknown_chunks);
info_ptr->unknown_chunks = NULL;
info_ptr->unknown_chunks_num = 0; info_ptr->unknown_chunks_num = 0;
} }
} }
@@ -423,62 +460,78 @@ if (mask & PNG_FREE_UNKN)
#if defined(PNG_hIST_SUPPORTED) #if defined(PNG_hIST_SUPPORTED)
/* free any hIST entry */ /* free any hIST entry */
if (mask & PNG_FREE_HIST) #ifdef PNG_FREE_ME_SUPPORTED
if ((mask & PNG_FREE_HIST) & info_ptr->free_me)
#else
if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST))
#endif
{ {
if (info_ptr->valid & PNG_INFO_hIST) png_free(png_ptr, info_ptr->hist);
{ info_ptr->hist = NULL;
if (info_ptr->free_me & PNG_FREE_HIST) info_ptr->valid &= ~PNG_INFO_hIST;
png_free(png_ptr, info_ptr->hist);
info_ptr->valid &= ~PNG_INFO_hIST;
}
} }
#endif #endif
/* free any PLTE entry that was internally allocated */ /* free any PLTE entry that was internally allocated */
if (mask & PNG_FREE_PLTE) #ifdef PNG_FREE_ME_SUPPORTED
if ((mask & PNG_FREE_PLTE) & info_ptr->free_me)
#else
if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE))
#endif
{ {
if (info_ptr->valid & PNG_INFO_PLTE) png_zfree(png_ptr, info_ptr->palette);
{ info_ptr->palette = NULL;
if (info_ptr->free_me & PNG_FREE_PLTE) info_ptr->valid &= ~PNG_INFO_PLTE;
png_zfree(png_ptr, info_ptr->palette); info_ptr->num_palette = 0;
info_ptr->valid &= ~(PNG_INFO_PLTE);
info_ptr->num_palette = 0;
}
} }
#if defined(PNG_INFO_IMAGE_SUPPORTED) #if defined(PNG_INFO_IMAGE_SUPPORTED)
/* free any image bits attached to the info structure */ /* free any image bits attached to the info structure */
#ifdef PNG_FREE_ME_SUPPORTED
if ((mask & PNG_FREE_ROWS) & info_ptr->free_me)
#else
if (mask & PNG_FREE_ROWS) if (mask & PNG_FREE_ROWS)
#endif
{ {
if (info_ptr->free_me & PNG_FREE_ROWS) if(info_ptr->row_pointers)
{ {
int row; int row;
for (row = 0; row < (int)info_ptr->height; row++) for (row = 0; row < (int)info_ptr->height; row++)
{
png_free(png_ptr, info_ptr->row_pointers[row]); png_free(png_ptr, info_ptr->row_pointers[row]);
info_ptr->row_pointers[row]=NULL;
}
png_free(png_ptr, info_ptr->row_pointers); png_free(png_ptr, info_ptr->row_pointers);
} info_ptr->row_pointers=NULL;
}
info_ptr->valid &= ~PNG_INFO_IDAT;
} }
#endif #endif
#ifdef PNG_FREE_ME_SUPPORTED
if(num == -1) if(num == -1)
info_ptr->free_me &= ~mask; info_ptr->free_me &= ~mask;
else
info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL);
#endif
} }
/* This is an internal routine to free any memory that the info struct is /* This is an internal routine to free any memory that the info struct is
* pointing to before re-using it or freeing the struct itself. Recall * pointing to before re-using it or freeing the struct itself. Recall
* that png_free() checks for NULL pointers for us. * that png_free() checks for NULL pointers for us.
*/ */
void void /* PRIVATE */
png_info_destroy(png_structp png_ptr, png_infop info_ptr) png_info_destroy(png_structp png_ptr, png_infop info_ptr)
{ {
png_debug(1, "in png_info_destroy\n"); png_debug(1, "in png_info_destroy\n");
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
if (png_ptr->num_chunk_list) if (png_ptr->num_chunk_list)
{ {
png_free(png_ptr, png_ptr->chunk_list); png_free(png_ptr, png_ptr->chunk_list);
png_ptr->chunk_list=NULL;
png_ptr->num_chunk_list=0; png_ptr->num_chunk_list=0;
} }
#endif #endif
@@ -490,7 +543,7 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
* functions. The application should free any memory associated with this * functions. The application should free any memory associated with this
* pointer before png_write_destroy() or png_read_destroy() are called. * pointer before png_write_destroy() or png_read_destroy() are called.
*/ */
png_voidp png_voidp PNGAPI
png_get_io_ptr(png_structp png_ptr) png_get_io_ptr(png_structp png_ptr)
{ {
return (png_ptr->io_ptr); return (png_ptr->io_ptr);
@@ -503,8 +556,8 @@ png_get_io_ptr(png_structp png_ptr)
* PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't * PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't
* necessarily available. * necessarily available.
*/ */
void void PNGAPI
png_init_io(png_structp png_ptr, FILE *fp) png_init_io(png_structp png_ptr, png_FILE_p fp)
{ {
png_debug(1, "in png_init_io\n"); png_debug(1, "in png_init_io\n");
png_ptr->io_ptr = (png_voidp)fp; png_ptr->io_ptr = (png_voidp)fp;
@@ -515,7 +568,7 @@ png_init_io(png_structp png_ptr, FILE *fp)
/* Convert the supplied time into an RFC 1123 string suitable for use in /* Convert the supplied time into an RFC 1123 string suitable for use in
* a "Creation Time" or other text-based time string. * a "Creation Time" or other text-based time string.
*/ */
png_charp png_charp PNGAPI
png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
{ {
static PNG_CONST char short_months[12][4] = static PNG_CONST char short_months[12][4] =
@@ -528,6 +581,17 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
sizeof(char))); sizeof(char)));
} }
#if defined(_WIN32_WCE)
{
wchar_t time_buf[29];
wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"),
ptime->day % 32, short_months[(ptime->month - 1) % 12],
ptime->year, ptime->hour % 24, ptime->minute % 60,
ptime->second % 61);
WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 29,
NULL, NULL);
}
#else
#ifdef USE_FAR_KEYWORD #ifdef USE_FAR_KEYWORD
{ {
char near_time_buf[29]; char near_time_buf[29];
@@ -544,28 +608,29 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
ptime->year, ptime->hour % 24, ptime->minute % 60, ptime->year, ptime->hour % 24, ptime->minute % 60,
ptime->second % 61); ptime->second % 61);
#endif #endif
#endif /* _WIN32_WCE */
return ((png_charp)png_ptr->time_buffer); return ((png_charp)png_ptr->time_buffer);
} }
#endif /* PNG_TIME_RFC1123_SUPPORTED */ #endif /* PNG_TIME_RFC1123_SUPPORTED */
#if 0 #if 0
/* Signature string for a PNG file. */ /* Signature string for a PNG file. */
png_bytep png_bytep PNGAPI
png_sig_bytes(void) png_sig_bytes(void)
{ {
return ((png_bytep)"\211\120\116\107\015\012\032\012"); return ((png_bytep)"\211\120\116\107\015\012\032\012");
} }
#endif #endif
png_charp png_charp PNGAPI
png_get_copyright(png_structp png_ptr) png_get_copyright(png_structp png_ptr)
{ {
if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */ if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */
return ("\n libpng version 1.0.6f - April 14, 2000\n\ return ((png_charp) "\n libpng version 1.0.9beta5 - December 15, 2000\n\
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n\ Copyright (c) 1998-2000 Glenn Randers-Pehrson\n\
Copyright (c) 1996, 1997 Andreas Dilger\n\ Copyright (c) 1996, 1997 Andreas Dilger\n\
Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson\n"); Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n");
return (""); return ((png_charp) "");
} }
/* The following return the library version as a short string in the /* The following return the library version as a short string in the
@@ -574,35 +639,35 @@ png_get_copyright(png_structp png_ptr)
* in png.h. * in png.h.
*/ */
png_charp png_charp PNGAPI
png_get_libpng_ver(png_structp png_ptr) png_get_libpng_ver(png_structp png_ptr)
{ {
/* Version of *.c files used when building libpng */ /* Version of *.c files used when building libpng */
if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */ if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
return("1.0.6f"); return((png_charp) "1.0.9beta5");
return("1.0.6f"); return((png_charp) "1.0.9beta5");
} }
png_charp png_charp PNGAPI
png_get_header_ver(png_structp png_ptr) png_get_header_ver(png_structp png_ptr)
{ {
/* Version of *.h files used when building libpng */ /* Version of *.h files used when building libpng */
if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */ if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
return(PNG_LIBPNG_VER_STRING); return((png_charp) PNG_LIBPNG_VER_STRING);
return(PNG_LIBPNG_VER_STRING); return((png_charp) PNG_LIBPNG_VER_STRING);
} }
png_charp png_charp PNGAPI
png_get_header_version(png_structp png_ptr) png_get_header_version(png_structp png_ptr)
{ {
/* Returns longer string containing both version and date */ /* Returns longer string containing both version and date */
if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */ if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
return(PNG_HEADER_VERSION_STRING); return((png_charp) PNG_HEADER_VERSION_STRING);
return(PNG_HEADER_VERSION_STRING); return((png_charp) PNG_HEADER_VERSION_STRING);
} }
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
int int PNGAPI
png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name) png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
{ {
/* check chunk_name and return "keep" value if it's on the list, else 0 */ /* check chunk_name and return "keep" value if it's on the list, else 0 */
@@ -617,3 +682,18 @@ png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
return 0; return 0;
} }
#endif #endif
/* This function, added to libpng-1.0.6g, is untested. */
int PNGAPI
png_reset_zstream(png_structp png_ptr)
{
return (inflateReset(&png_ptr->zstream));
}
/* This function was added to libpng-1.0.7 */
png_uint_32 PNGAPI
png_access_version_number(void)
{
/* Version of *.c files used when building libpng */
return((png_uint_32) 10009L);
}

537
png.h
View File

@@ -1,15 +1,15 @@
/* png.h - header file for PNG reference library /* png.h - header file for PNG reference library
* *
* libpng version 1.0.6f - April 14, 2000 * libpng version 1.0.9beta5 - December 15, 2000
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
* Authors and maintainers: * Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.0.6f - April 14, 2000: Glenn * libpng versions 0.97, January 1998, through 1.0.9beta5 - December 15, 2000: Glenn
* See also "Contributing Authors", below. * See also "Contributing Authors", below.
* *
* Note about libpng version numbers: * Note about libpng version numbers:
@@ -20,43 +20,59 @@
* The following table summarizes matters since version 0.89c, which was * The following table summarizes matters since version 0.89c, which was
* the first widely used release: * the first widely used release:
* *
* source png.h png.h shared-lib * source png.h png.h shared-lib
* version string int version * version string int version
* ------- ------ ----- ---------- * ------- ------ ----- ----------
* 0.89c ("1.0 beta 3") 0.89 89 1.0.89 * 0.89c "1.0 beta 3" 0.89 89 1.0.89
* 0.90 ("1.0 beta 4") 0.90 90 0.90 [should have been 2.0.90] * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90]
* 0.95 ("1.0 beta 5") 0.95 95 0.95 [should have been 2.0.95] * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95]
* 0.96 ("1.0 beta 6") 0.96 96 0.96 [should have been 2.0.96] * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96]
* 0.97b ("1.00.97 beta 7") 1.00.97 97 1.0.1 [should have been 2.0.97] * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97]
* 0.97c 0.97 97 2.0.97 * 0.97c 0.97 97 2.0.97
* 0.98 0.98 98 2.0.98 * 0.98 0.98 98 2.0.98
* 0.99 0.99 98 2.0.99 * 0.99 0.99 98 2.0.99
* 0.99a-m 0.99 99 2.0.99 * 0.99a-m 0.99 99 2.0.99
* 1.00 1.00 100 2.1.0 [100 should be 10000] * 1.00 1.00 100 2.1.0 [100 should be 10000]
* 1.0.0 1.0.0 100 2.1.0 [100 should be 10000] * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000]
* 1.0.1 1.0.1 10001 2.1.0 * 1.0.1 png.h string is 10001 2.1.0
* 1.0.1a-e 1.0.1a-e 10002 2.1.0.1a-e * 1.0.1a-e identical to the 10002 from here on, the shared library
* 1.0.2 1.0.2 10002 2.1.0.2 * 1.0.2 source version) 10002 is 2.V where V is the source code
* 1.0.2a-b 1.0.2a-b 10003 2.1.0.2a-b * 1.0.2a-b 10003 version, except as noted.
* 1.0.3 1.0.3 10003 2.1.0.3 * 1.0.3 10003
* 1.0.3a-d 1.0.3a-d 10004 2.1.0.3a-d * 1.0.3a-d 10004
* 1.0.4 1.0.4 10004 2.1.0.4 * 1.0.4 10004
* 1.0.4a-f 1.0.4a-f 10005 2.1.0.4a-f * 1.0.4a-f 10005
* 1.0.5 (+ 2 patches) 1.0.5 10005 2.1.0.5 * 1.0.5 (+ 2 patches) 10005
* 1.0.5a-d 1.0.5a-d 10006 2.1.0.5a-d * 1.0.5a-d 10006
* 1.0.5e-r 1.0.5e-r 10100 2.1.0.5e-r (not compatible) * 1.0.5e-r 10100 (not source compatible)
* 1.0.5s-v 1.0.5s-v 10006 2.1.0.5s-v (compatible) * 1.0.5s-v 10006 (not binary compatible)
* 1.0.6 (+ 3 patches) 1.0.6 10006 2.1.0.6 * 1.0.6 (+ 3 patches) 10006 (still binary incompatible)
* 1.0.6d-f 1.0.6d-f 10007 2.1.0.6d-f * 1.0.6d-f 10007 (still binary incompatible)
* 1.0.7 1.0.7 10007 2.1.0.7 (still compatible) * 1.0.6g 10007
* 1.0.6h 10007 10.6h (testing xy.z so-numbering)
* 1.0.6i 10007 10.6i
* 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0)
* 1.0.7beta11-18 10007 2.1.0.7beta11-18 (binary compatible)
* 1.0.7rc1-2 10007 2.1.0.7rc1-2 (binary compatible)
* 1.0.7 10007 (still compatible)
* 1.0.8beta1-4 10008 2.1.0.8beta1-4
* 1.0.8rc1 10008 2.1.0.8rc1
* 1.0.8 10008 2.1.0.8
* 1.0.9beta1-5 10009 2.1.0.9beta1-5
* *
* Henceforth the source version will match the shared-library minor * Henceforth the source version will match the shared-library major
* and patch numbers; the shared-library major version number will be * and minor numbers; the shared-library major version number will be
* used for changes in backward compatibility, as it is intended. The * used for changes in backward compatibility, as it is intended. The
* PNG_PNGLIB_VER macro, which is not used within libpng but is available * PNG_PNGLIB_VER macro, which is not used within libpng but is available
* for applications, is an unsigned integer of the form xyyzz corresponding * for applications, is an unsigned integer of the form xyyzz corresponding
* to the source version x.y.z (leading zeros in y and z). Beta versions * to the source version x.y.z (leading zeros in y and z). Beta versions
* are given the previous public release number plus a letter or two. * were given the previous public release number plus a letter, until
* version 1.0.6j; from then on they were given the upcoming public
* release number plus "betaNN" or "rcN".
*
* Binary incompatibility exists only when applications make direct access
* to the info_ptr or png_ptr members through png.h, and the compiled
* application is loaded with a different version of the library.
* *
* See libpng.txt or libpng.3 for more information. The PNG specification * See libpng.txt or libpng.3 for more information. The PNG specification
* is available as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/> * is available as RFC 2083 <ftp://ftp.uu.net/graphics/png/documents/>
@@ -66,32 +82,58 @@
/* /*
* COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
* *
* If you modify libpng you may insert additional notices after this sentence. * If you modify libpng you may insert additional notices immediately following
* this sentence.
* *
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. * libpng versions 1.0.7, July 1, 2000, through 1.0.9beta5, December 15, 2000, are
* (libpng versions 0.5, May 1995, through 0.88, January 1996) * Copyright (c) 2000 Glenn Randers-Pehrson, and are
* Copyright (c) 1996, 1997 Andreas Dilger * distributed according to the same disclaimer and license as libpng-1.0.6
* (libpng versions 0.89c, June 1996, through 0.96, May 1997) * with the following individuals added to the list of Contributing Authors
*
* Simon-Pierre Cadieux
* Eric S. Raymond
* Gilles Vollant
*
* and with the following additions to the disclaimer:
*
* There is no warranty against interference with your enjoyment of the
* library or against infringement. There is no warranty that our
* efforts or the library will fulfill any of your particular purposes
* or needs. This library is provided with all faults, and the entire
* risk of satisfactory quality, performance, accuracy, and effort is with
* the user.
*
* libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
* (libpng versions 0.97, January 1998, through 1.0.6f, April 14, 2000) * Distributed according to the same disclaimer and license as libpng-0.96,
* with the following individuals added to the list of Contributing Authors:
* *
* For the purposes of this copyright and license, "Contributing Authors" * Tom Lane
* is defined as the following set of individuals: * Glenn Randers-Pehrson
* Willem van Schaik
*
* libpng versions 0.89, June 1996, through 0.96, May 1997, are
* Copyright (c) 1996, 1997 Andreas Dilger
* Distributed according to the same disclaimer and license as libpng-0.88,
* with the following individuals added to the list of Contributing Authors:
* *
* John Bowler * John Bowler
* Kevin Bracey * Kevin Bracey
* Sam Bushell * Sam Bushell
* Andreas Dilger
* Magnus Holmgren * Magnus Holmgren
* Tom Lane
* Dave Martindale
* Glenn Randers-Pehrson
* Eric S. Raymond
* Greg Roelofs * Greg Roelofs
* Tom Tanner
*
* libpng versions 0.5, May 1995, through 0.88, January 1996, are
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
*
* For the purposes of this copyright and license, "Contributing Authors"
* is defined as the following set of individuals:
*
* Andreas Dilger
* Dave Martindale
* Guy Eric Schalnat * Guy Eric Schalnat
* Paul Schmidt * Paul Schmidt
* Tom Tanner
* Willem van Schaik
* Tim Wegner * Tim Wegner
* *
* The PNG Reference Library is supplied "AS IS". The Contributing Authors * The PNG Reference Library is supplied "AS IS". The Contributing Authors
@@ -128,7 +170,7 @@
* printf("%s",png_get_copyright(NULL)); * printf("%s",png_get_copyright(NULL));
* *
* Also, the PNG logo (in PNG format, of course) is supplied in the * Also, the PNG logo (in PNG format, of course) is supplied in the
* file "pngnow.png". * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
*/ */
/* /*
@@ -148,13 +190,13 @@
* Y2K compliance in libpng: * Y2K compliance in libpng:
* ========================= * =========================
* *
* April 14, 2000 * December 15, 2000
* *
* Since the PNG Development group is an ad-hoc body, we can't make * Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration. * an official declaration.
* *
* This is your unofficial assurance that libpng from version 0.71 and * This is your unofficial assurance that libpng from version 0.71 and
* upward through 1.0.6f are Y2K compliant. It is my belief that earlier * upward through 1.0.9beta5 are Y2K compliant. It is my belief that earlier
* versions were also Y2K compliant. * versions were also Y2K compliant.
* *
* Libpng only has three year fields. One is a 2-byte unsigned integer * Libpng only has three year fields. One is a 2-byte unsigned integer
@@ -200,8 +242,8 @@
* PNG Development Group * PNG Development Group
*/ */
#ifndef _PNG_H #ifndef PNG_H
#define _PNG_H #define PNG_H
/* This is not the place to learn how to use libpng. The file libpng.txt /* This is not the place to learn how to use libpng. The file libpng.txt
* describes how to use libpng, and the file example.c summarizes it * describes how to use libpng, and the file example.c summarizes it
@@ -209,6 +251,37 @@
* at the actual function definitions and structure components. * at the actual function definitions and structure components.
*/ */
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.0.9beta5"
#define PNG_LIBPNG_VER_SONUM 2
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 0
#define PNG_LIBPNG_VER_RELEASE 9
/* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero: */
#define PNG_LIBPNG_VER_BUILD 5
#define PNG_LIBPNG_BUILD_ALPHA 1
#define PNG_LIBPNG_BUILD_BETA 2
#define PNG_LIBPNG_BUILD_RC 3
#define PNG_LIBPNG_BUILD_STABLE 4
#define PNG_LIBPNG_BUILD_TYPEMASK 7
#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with STABLE only */
#define PNG_LIBPNG_BUILD_TYPE 2
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
* We must not include leading zeros.
* Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
* version 1.0.0 was mis-numbered 100 instead of 10000). From
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */
#define PNG_LIBPNG_VER 10009 /* 1.0.9 */
#ifndef PNG_VERSION_INFO_ONLY
/* include the compression library's header */ /* include the compression library's header */
#include "zlib.h" #include "zlib.h"
@@ -231,25 +304,14 @@ extern "C" {
* which applications aren't expected to use directly. * which applications aren't expected to use directly.
*/ */
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.0.6f"
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
* We must not include leading zeros.
* Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
* version 1.0.0 was mis-numbered 100 instead of 10000). From
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=bugfix */
#define PNG_LIBPNG_VER 10007 /* 1.0.7 */
/* Note to maintainer: update this number in scripts/pngdef.pas as well */
/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
/* Version information for C files, stored in png.c. This had better match /* Version information for C files, stored in png.c. This had better match
* the version above. * the version above.
*/ */
#ifdef PNG_USE_GLOBAL_ARRAYS #ifdef PNG_USE_GLOBAL_ARRAYS
PNG_EXPORT_VAR (char) png_libpng_ver[12]; /* need room for 99.99.99aa */ PNG_EXPORT_VAR (const char) png_libpng_ver[18];
/* need room for 99.99.99beta99z*/
#else #else
#define png_libpng_ver png_get_header_ver(NULL) #define png_libpng_ver png_get_header_ver(NULL)
#endif #endif
@@ -257,17 +319,17 @@ PNG_EXPORT_VAR (char) png_libpng_ver[12]; /* need room for 99.99.99aa */
#ifdef PNG_USE_GLOBAL_ARRAYS #ifdef PNG_USE_GLOBAL_ARRAYS
/* This was removed in version 1.0.5c */ /* This was removed in version 1.0.5c */
/* Structures to facilitate easy interlacing. See png.c for more details */ /* Structures to facilitate easy interlacing. See png.c for more details */
PNG_EXPORT_VAR (int FARDATA) png_pass_start[7]; PNG_EXPORT_VAR (const int FARDATA) png_pass_start[7];
PNG_EXPORT_VAR (int FARDATA) png_pass_inc[7]; PNG_EXPORT_VAR (const int FARDATA) png_pass_inc[7];
PNG_EXPORT_VAR (int FARDATA) png_pass_ystart[7]; PNG_EXPORT_VAR (const int FARDATA) png_pass_ystart[7];
PNG_EXPORT_VAR (int FARDATA) png_pass_yinc[7]; PNG_EXPORT_VAR (const int FARDATA) png_pass_yinc[7];
PNG_EXPORT_VAR (int FARDATA) png_pass_mask[7]; PNG_EXPORT_VAR (const int FARDATA) png_pass_mask[7];
PNG_EXPORT_VAR (int FARDATA) png_pass_dsp_mask[7]; PNG_EXPORT_VAR (const int FARDATA) png_pass_dsp_mask[7];
#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW #ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
extern int FARDATA png_pass_width[7]; /* now used in pngvcrd.c, pnggccrd.c */ PNG_EXPORT_VAR (const int FARDATA) png_pass_width[7];
#endif #endif
/* This isn't currently used. If you need it, see png.c for more details. /* This isn't currently used. If you need it, see png.c for more details.
extern int FARDATA png_pass_height[7]; PNG_EXPORT_VAR (const int FARDATA) png_pass_height[7];
*/ */
#endif #endif
@@ -358,11 +420,13 @@ typedef struct png_text_struct
png_charp text; /* comment, may be an empty string (ie "") png_charp text; /* comment, may be an empty string (ie "")
or a NULL pointer */ or a NULL pointer */
png_size_t text_length; /* length of the text string */ png_size_t text_length; /* length of the text string */
#ifdef PNG_iTXt_SUPPORTED
png_size_t itxt_length; /* length of the itxt string */ png_size_t itxt_length; /* length of the itxt string */
png_charp lang; /* language code, 0-79 characters png_charp lang; /* language code, 0-79 characters
or a NULL pointer */ or a NULL pointer */
png_charp lang_key; /* keyword translated UTF-8 string, 0 or more png_charp lang_key; /* keyword translated UTF-8 string, 0 or more
chars or a NULL pointer */ chars or a NULL pointer */
#endif
} png_text; } png_text;
typedef png_text FAR * png_textp; typedef png_text FAR * png_textp;
typedef png_text FAR * FAR * png_textpp; typedef png_text FAR * FAR * png_textpp;
@@ -467,6 +531,7 @@ typedef struct png_info_struct
png_uint_16 num_trans; /* number of transparent palette color (tRNS) */ png_uint_16 num_trans; /* number of transparent palette color (tRNS) */
png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */ png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */
png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */ png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */
/* The following three should have been named *_method not *_type */
png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */ png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */
png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */ png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
@@ -483,18 +548,13 @@ typedef struct png_info_struct
* and initialize the appropriate fields below. * and initialize the appropriate fields below.
*/ */
png_uint_32 free_me; /* flags items libpng is responsible for freeing */ #if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
#if defined(PNG_gAMA_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED)
/* The gAMA chunk describes the gamma characteristics of the system /* The gAMA chunk describes the gamma characteristics of the system
* on which the image was created, normally in the range [1.0, 2.5]. * on which the image was created, normally in the range [1.0, 2.5].
* Data is valid if (valid & PNG_INFO_gAMA) is non-zero. * Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
*/ */
#ifdef PNG_FLOATING_POINT_SUPPORTED
float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */ float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */
#endif #endif
png_fixed_point int_gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */
#endif
#if defined(PNG_sRGB_SUPPORTED) #if defined(PNG_sRGB_SUPPORTED)
/* GR-P, 0.96a */ /* GR-P, 0.96a */
@@ -514,9 +574,6 @@ typedef struct png_info_struct
int num_text; /* number of comments read/to write */ int num_text; /* number of comments read/to write */
int max_text; /* current size of text array */ int max_text; /* current size of text array */
png_textp text; /* array of comments read/to write */ png_textp text; /* array of comments read/to write */
int num_text_old; /* number of comments read/to write */
png_textp text_old; /* array of comments read/to write, backward
compatible with libpng-1.0.5 and earlier */
#endif /* PNG_TEXT_SUPPORTED */ #endif /* PNG_TEXT_SUPPORTED */
#if defined(PNG_tIME_SUPPORTED) #if defined(PNG_tIME_SUPPORTED)
@@ -592,7 +649,7 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
png_uint_16p hist; png_uint_16p hist;
#endif #endif
#if defined(PNG_cHRM_SUPPORTED) #ifdef PNG_cHRM_SUPPORTED
/* The cHRM chunk describes the CIE color characteristics of the monitor /* The cHRM chunk describes the CIE color characteristics of the monitor
* on which the PNG was created. This data allows the viewer to do gamut * on which the PNG was created. This data allows the viewer to do gamut
* mapping of the input image to ensure that the viewer sees the same * mapping of the input image to ensure that the viewer sees the same
@@ -609,16 +666,6 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
float x_blue; float x_blue;
float y_blue; float y_blue;
#endif #endif
#ifdef PNG_FIXED_POINT_SUPPORTED
png_fixed_point int_x_white;
png_fixed_point int_y_white;
png_fixed_point int_x_red;
png_fixed_point int_y_red;
png_fixed_point int_x_green;
png_fixed_point int_y_green;
png_fixed_point int_x_blue;
png_fixed_point int_y_blue;
#endif
#endif #endif
#if defined(PNG_pCAL_SUPPORTED) #if defined(PNG_pCAL_SUPPORTED)
@@ -628,11 +675,10 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
* range given by [pcal_X0, pcal_X1], and are further transformed by a * range given by [pcal_X0, pcal_X1], and are further transformed by a
* (possibly non-linear) transformation function given by "pcal_type" * (possibly non-linear) transformation function given by "pcal_type"
* and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_ * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_
* defines below, and the PNG-Group's Scientific Visualization extension * defines below, and the PNG-Group's PNG extensions document for a
* chunks document png-scivis-19970203 for a complete description of the * complete description of the transformations and how they should be
* transformations and how they should be implemented, as well as the * implemented, and for a description of the ASCII parameter strings.
* png-extensions document for a description of the ASCII parameter * Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
* strings. Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
*/ */
png_charp pcal_purpose; /* pCAL chunk description string */ png_charp pcal_purpose; /* pCAL chunk description string */
png_int_32 pcal_X0; /* minimum value */ png_int_32 pcal_X0; /* minimum value */
@@ -643,10 +689,21 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
png_byte pcal_nparams; /* number of parameters given in pcal_params */ png_byte pcal_nparams; /* number of parameters given in pcal_params */
#endif #endif
#ifdef PNG_FREE_ME_SUPPORTED
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
#endif
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
/* storage for unknown chunks that the library doesn't recognize. */
png_unknown_chunkp unknown_chunks;
png_size_t unknown_chunks_num;
#endif
#if defined(PNG_iCCP_SUPPORTED) #if defined(PNG_iCCP_SUPPORTED)
/* iCCP chunk data. */ /* iCCP chunk data. */
png_charp iccp_name; /* profile name */ png_charp iccp_name; /* profile name */
png_charp iccp_profile; /* International Color Consortium profile data */ png_charp iccp_profile; /* International Color Consortium profile data */
/* Note to maintainer: should be png_bytep */
png_uint_32 iccp_proflen; /* ICC profile data length */ png_uint_32 iccp_proflen; /* ICC profile data length */
png_byte iccp_compression; /* Always zero */ png_byte iccp_compression; /* Always zero */
#endif #endif
@@ -676,17 +733,27 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
#endif #endif
#endif #endif
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
/* storage for unknown chunks that the library doesn't recognize. */
png_unknown_chunkp unknown_chunks;
png_size_t unknown_chunks_num;
#endif
#if defined(PNG_INFO_IMAGE_SUPPORTED) #if defined(PNG_INFO_IMAGE_SUPPORTED)
/* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) non-zero */ /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) non-zero */
/* Data valid if (valid & PNG_INFO_IDAT) non-zero */ /* Data valid if (valid & PNG_INFO_IDAT) non-zero */
png_bytepp row_pointers; /* the image bits */ png_bytepp row_pointers; /* the image bits */
#endif #endif
#if defined(PNG_FIXED_POINT_SUPPORTED) && defined(PNG_gAMA_SUPPORTED)
png_fixed_point int_gamma; /* gamma of image, if (valid & PNG_INFO_gAMA) */
#endif
#if defined(PNG_cHRM_SUPPORTED) && defined(PNG_FIXED_POINT_SUPPORTED)
png_fixed_point int_x_white;
png_fixed_point int_y_white;
png_fixed_point int_x_red;
png_fixed_point int_y_red;
png_fixed_point int_x_green;
png_fixed_point int_y_green;
png_fixed_point int_x_blue;
png_fixed_point int_y_blue;
#endif
} png_info; } png_info;
typedef png_info FAR * png_infop; typedef png_info FAR * png_infop;
@@ -707,6 +774,9 @@ typedef png_info FAR * FAR * png_infopp;
#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR) #define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR)
#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA) #define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA) #define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
/* aliases */
#define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA
#define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA
/* This is for compression type. PNG 1.0-1.2 only define the single type. */ /* This is for compression type. PNG 1.0-1.2 only define the single type. */
#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */ #define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */
@@ -714,6 +784,7 @@ typedef png_info FAR * FAR * png_infopp;
/* This is for filter type. PNG 1.0-1.2 only define the single type. */ /* This is for filter type. PNG 1.0-1.2 only define the single type. */
#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */ #define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */
#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */
#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE #define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE
/* These are for the interlacing type. These values should NOT be changed. */ /* These are for the interlacing type. These values should NOT be changed. */
@@ -803,30 +874,33 @@ typedef png_row_info FAR * FAR * png_row_infopp;
typedef struct png_struct_def png_struct; typedef struct png_struct_def png_struct;
typedef png_struct FAR * png_structp; typedef png_struct FAR * png_structp;
typedef void (*png_error_ptr) PNGARG((png_structp, png_const_charp)); typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp));
typedef void (*png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t)); typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t));
typedef void (*png_flush_ptr) PNGARG((png_structp)); typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp));
typedef void (*png_read_status_ptr) PNGARG((png_structp, png_uint_32, int)); typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32,
typedef void (*png_write_status_ptr) PNGARG((png_structp, png_uint_32, int)); int));
typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32,
int));
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
typedef void (*png_progressive_info_ptr) PNGARG((png_structp, png_infop)); typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop));
typedef void (*png_progressive_end_ptr) PNGARG((png_structp, png_infop)); typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop));
typedef void (*png_progressive_row_ptr) PNGARG((png_structp, png_bytep, typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
png_uint_32, int)); png_uint_32, int));
#endif #endif
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
typedef void (*png_user_transform_ptr) PNGARG((png_structp, defined(PNG_LEGACY_SUPPORTED)
typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp,
png_row_infop, png_bytep)); png_row_infop, png_bytep));
#endif #endif
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) #if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
typedef int (*png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp)); typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp));
#endif #endif
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
typedef void (*png_unknown_chunk_ptr) PNGARG((png_structp)); typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp));
#endif #endif
/* Transform masks for the high-level interface */ /* Transform masks for the high-level interface */
@@ -841,9 +915,15 @@ typedef void (*png_unknown_chunk_ptr) PNGARG((png_structp));
#define PNG_TRANSFORM_BGR 0x0080 /* read and write */ #define PNG_TRANSFORM_BGR 0x0080 /* read and write */
#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ #define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */
#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ #define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */
#define PNG_TRANSFORM_INVERT_ALPHA 0x0200 /* read and write */ #define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */
#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */ #define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */
/* Flags for MNG supported features */
#define PNG_FLAG_MNG_EMPTY_PLTE 0x01
#define PNG_MODE_EMBEDDED_IN_MNG 0x02
#define PNG_FLAG_MNG_FILTER_64 0x04
#define PNG_ALL_MNG_FEATURES 0x07
typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t)); typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t));
typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp)); typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp));
@@ -874,21 +954,18 @@ struct png_struct_def
png_user_transform_ptr write_user_transform_fn; /* user write transform */ png_user_transform_ptr write_user_transform_fn; /* user write transform */
#endif #endif
/* These were added in libpng-1.0.2 */
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
png_voidp user_transform_ptr; /* user supplied struct for user transform */ png_voidp user_transform_ptr; /* user supplied struct for user transform */
png_byte user_transform_depth; /* bit depth of user transformed pixels */ png_byte user_transform_depth; /* bit depth of user transformed pixels */
png_byte user_transform_channels; /* channels in user transformed pixels */ png_byte user_transform_channels; /* channels in user transformed pixels */
#endif #endif
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
png_voidp user_chunk_ptr;
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
#endif #endif
png_uint_32 mode; /* tells us where we are in the PNG file */ png_uint_32 mode; /* tells us where we are in the PNG file */
png_uint_32 flags; /* flags indicating various things to libpng */ png_uint_32 flags; /* flags indicating various things to libpng */
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
png_uint_32 transformations; /* which transformations to perform */ png_uint_32 transformations; /* which transformations to perform */
z_stream zstream; /* pointer to decompression structure (below) */ z_stream zstream; /* pointer to decompression structure (below) */
@@ -936,14 +1013,18 @@ struct png_struct_def
png_byte sig_bytes; /* magic bytes read/written from start of file */ png_byte sig_bytes; /* magic bytes read/written from start of file */
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
#ifdef PNG_LEGACY_SUPPORTED
png_byte filler; /* filler byte for pixel expansion */
#else
png_uint_16 filler; /* filler bytes for pixel expansion */ png_uint_16 filler; /* filler bytes for pixel expansion */
#endif #endif
#endif
#if defined(PNG_READ_bKGD_SUPPORTED) #if defined(PNG_READ_bKGD_SUPPORTED)
png_byte background_gamma_type; png_byte background_gamma_type;
#ifdef PNG_FLOATING_POINT_SUPPORTED # ifdef PNG_FLOATING_POINT_SUPPORTED
float background_gamma; float background_gamma;
#endif # endif
png_color_16 background; /* background color in screen gamma space */ png_color_16 background; /* background color in screen gamma space */
# if defined(PNG_READ_GAMMA_SUPPORTED) # if defined(PNG_READ_GAMMA_SUPPORTED)
png_color_16 background_1; /* background normalized to gamma 1.0 */ png_color_16 background_1; /* background normalized to gamma 1.0 */
@@ -962,7 +1043,6 @@ struct png_struct_def
float gamma; /* file gamma value */ float gamma; /* file gamma value */
float screen_gamma; /* screen gamma value (display_exponent) */ float screen_gamma; /* screen gamma value (display_exponent) */
#endif #endif
png_fixed_point int_gamma;
#endif #endif
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
@@ -974,7 +1054,7 @@ struct png_struct_def
png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
#endif #endif
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined (PNG_READ_sBIT_SUPPORTED) #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_sBIT_SUPPORTED)
png_color_8 sig_bit; /* significant bits in each available channel */ png_color_8 sig_bit; /* significant bits in each available channel */
#endif #endif
@@ -1054,6 +1134,22 @@ struct png_struct_def
png_free_ptr free_fn; /* function for freeing memory */ png_free_ptr free_fn; /* function for freeing memory */
#endif #endif
/* New members added in libpng-1.0.6 */
#ifdef PNG_FREE_ME_SUPPORTED
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
#endif
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
png_voidp user_chunk_ptr;
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
#endif
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
int num_chunk_list;
png_bytep chunk_list;
#endif
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
png_byte rgb_to_gray_status; png_byte rgb_to_gray_status;
png_uint_16 rgb_to_gray_red_coeff; png_uint_16 rgb_to_gray_red_coeff;
@@ -1061,21 +1157,25 @@ struct png_struct_def
png_uint_16 rgb_to_gray_blue_coeff; png_uint_16 rgb_to_gray_blue_coeff;
#endif #endif
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ #if defined(PNG_MNG_FEATURES_SUPPORTED) || \
defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
png_byte empty_plte_permitted; /* Note to maintainer: change this to png_uint_32 at next opportunity */
png_byte mng_features_permitted;
#endif #endif
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
int num_chunk_list; png_fixed_point int_gamma;
png_bytep chunk_list;
#endif #endif
png_byte filter_type;
}; };
/* This prevents a compiler error in png_get_copyright() in png.c if png.c /* This prevents a compiler error in png_get_copyright() in png.c if png.c
and png.h are both at * version 1.0.6f and png.h are both at * version 1.0.9beta5
*/ */
typedef png_structp version_1_0_6f; typedef png_structp version_1_0_9beta5;
typedef png_struct FAR * FAR * png_structpp; typedef png_struct FAR * FAR * png_structpp;
@@ -1085,6 +1185,9 @@ typedef png_struct FAR * FAR * png_structpp;
* a simple one line description of the use of each function. * a simple one line description of the use of each function.
*/ */
/* Returns the version number of the library */
extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void));
/* Tell lib we have already handled the first <num_bytes> magic bytes. /* Tell lib we have already handled the first <num_bytes> magic bytes.
* Handling more than 8 bytes from the beginning of the file is an error. * Handling more than 8 bytes from the beginning of the file is an error.
*/ */
@@ -1114,6 +1217,15 @@ extern PNG_EXPORT(png_structp,png_create_write_struct)
PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
png_error_ptr error_fn, png_error_ptr warn_fn)); png_error_ptr error_fn, png_error_ptr warn_fn));
extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size)
PNGARG((png_structp png_ptr));
extern PNG_EXPORT(void,png_set_compression_buffer_size)
PNGARG((png_structp png_ptr, png_uint_32 size));
/* Reset the compression stream */
extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr));
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
extern PNG_EXPORT(png_structp,png_create_read_struct_2) extern PNG_EXPORT(png_structp,png_create_read_struct_2)
PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
@@ -1162,6 +1274,8 @@ extern PNG_EXPORT(png_charp,png_convert_to_rfc1123)
PNGARG((png_structp png_ptr, png_timep ptime)); PNGARG((png_structp png_ptr, png_timep ptime));
#endif #endif
#if !defined(_WIN32_WCE)
/* "time.h" functions are not supported on WindowsCE */
#if defined(PNG_WRITE_tIME_SUPPORTED) #if defined(PNG_WRITE_tIME_SUPPORTED)
/* convert from a struct tm to png_time */ /* convert from a struct tm to png_time */
extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime, extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime,
@@ -1171,6 +1285,7 @@ extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime,
extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime, extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime,
time_t ttime)); time_t ttime));
#endif /* PNG_WRITE_tIME_SUPPORTED */ #endif /* PNG_WRITE_tIME_SUPPORTED */
#endif /* _WIN32_WCE */
#if defined(PNG_READ_EXPAND_SUPPORTED) #if defined(PNG_READ_EXPAND_SUPPORTED)
/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ /* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */
@@ -1256,7 +1371,7 @@ extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr));
#endif #endif
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
/* Invert monocrome files */ /* Invert monochrome files */
extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr));
#endif #endif
@@ -1296,6 +1411,7 @@ extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr,
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ #if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */ /* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */
/* Deprecated and will be removed. Use png_permit_mng_features() instead. */
extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr,
int empty_plte_permitted)); int empty_plte_permitted));
#endif #endif
@@ -1504,7 +1620,7 @@ extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr,
#if !defined(PNG_NO_STDIO) #if !defined(PNG_NO_STDIO)
/* Initialize the input/output for the PNG file to the default functions. */ /* Initialize the input/output for the PNG file to the default functions. */
extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, FILE *fp)); extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, png_FILE_p fp));
#endif #endif
/* Replace the (error and abort), and warning functions with user /* Replace the (error and abort), and warning functions with user
@@ -1550,18 +1666,21 @@ extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr,
extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr));
#endif #endif
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_LEGACY_SUPPORTED)
extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp
png_ptr, png_user_transform_ptr read_user_transform_fn)); png_ptr, png_user_transform_ptr read_user_transform_fn));
#endif #endif
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_LEGACY_SUPPORTED)
extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp
png_ptr, png_user_transform_ptr write_user_transform_fn)); png_ptr, png_user_transform_ptr write_user_transform_fn));
#endif #endif
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_LEGACY_SUPPORTED)
extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp
png_ptr, png_voidp user_transform_ptr, int user_transform_depth, png_ptr, png_voidp user_transform_ptr, int user_transform_depth,
int user_transform_channels)); int user_transform_channels));
@@ -1610,27 +1729,30 @@ extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr));
/* Free data that was allocated internally */ /* Free data that was allocated internally */
extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_32 free_me, int num)); png_infop info_ptr, png_uint_32 free_me, int num));
#ifdef PNG_FREE_ME_SUPPORTED
/* Reassign responsibility for freeing existing data, whether allocated /* Reassign responsibility for freeing existing data, whether allocated
* by libpng or by the application */ * by libpng or by the application */
extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr,
png_infop info_ptr, int freer, png_uint_32 mask)); png_infop info_ptr, int freer, png_uint_32 mask));
#endif
/* assignments for png_data_freer */ /* assignments for png_data_freer */
#define PNG_DESTROY_WILL_FREE_DATA 1 #define PNG_DESTROY_WILL_FREE_DATA 1
#define PNG_SET_WILL_FREE_DATA 1 #define PNG_SET_WILL_FREE_DATA 1
#define PNG_USER_WILL_FREE_DATA 2 #define PNG_USER_WILL_FREE_DATA 2
/* Flags for png_ptr->free_me and info_ptr->free_me */ /* Flags for png_ptr->free_me and info_ptr->free_me */
#define PNG_FREE_PLTE 0x0001
#define PNG_FREE_TRNS 0x0002
#define PNG_FREE_TEXT 0x0004
#define PNG_FREE_HIST 0x0008 #define PNG_FREE_HIST 0x0008
#define PNG_FREE_ICCP 0x0010 #define PNG_FREE_ICCP 0x0010
#define PNG_FREE_SPLT 0x0020 #define PNG_FREE_SPLT 0x0020
#define PNG_FREE_ROWS 0x0040 #define PNG_FREE_ROWS 0x0040
#define PNG_FREE_PCAL 0x0080 /* not used any more */ #define PNG_FREE_PCAL 0x0080
#define PNG_FREE_SCAL 0x0100 /* not used any more */ #define PNG_FREE_SCAL 0x0100
#define PNG_FREE_UNKN 0x0200 #define PNG_FREE_UNKN 0x0200
#define PNG_FREE_LIST 0x0400 #define PNG_FREE_LIST 0x0400
#define PNG_FREE_ALL 0x07ff #define PNG_FREE_PLTE 0x1000
#define PNG_FREE_TRNS 0x2000
#define PNG_FREE_TEXT 0x4000
#define PNG_FREE_ALL 0x7fff
#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr,
@@ -1745,13 +1867,13 @@ png_ptr, png_infop info_ptr));
#endif #endif
/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ /* Returns image x, y offset in pixels or microns, from oFFs chunk data. */
extern PNG_EXPORT(png_uint_32, png_get_x_offset_pixels) PNGARG((png_structp extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp
png_ptr, png_infop info_ptr)); png_ptr, png_infop info_ptr));
extern PNG_EXPORT(png_uint_32, png_get_y_offset_pixels) PNGARG((png_structp extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp
png_ptr, png_infop info_ptr)); png_ptr, png_infop info_ptr));
extern PNG_EXPORT(png_uint_32, png_get_x_offset_microns) PNGARG((png_structp extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp
png_ptr, png_infop info_ptr)); png_ptr, png_infop info_ptr));
extern PNG_EXPORT(png_uint_32, png_get_y_offset_microns) PNGARG((png_structp extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp
png_ptr, png_infop info_ptr)); png_ptr, png_infop info_ptr));
#endif /* PNG_EASY_ACCESS_SUPPORTED */ #endif /* PNG_EASY_ACCESS_SUPPORTED */
@@ -1831,12 +1953,13 @@ extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr,
extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, png_infop info_ptr, png_uint_32 *width, png_uint_32 *height,
int *bit_depth, int *color_type, int *interlace_type, int *bit_depth, int *color_type, int *interlace_method,
int *compression_type, int *filter_type)); int *compression_method, int *filter_method));
extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth,
int color_type, int interlace_type, int compression_type, int filter_type)); int color_type, int interlace_method, int compression_method,
int filter_method));
#if defined(PNG_READ_oFFs_SUPPORTED) #if defined(PNG_READ_oFFs_SUPPORTED)
extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr,
@@ -1904,12 +2027,14 @@ extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr,
extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_charpp name, int *compression_type, png_infop info_ptr, png_charpp name, int *compression_type,
png_charpp profile, png_uint_32 *proflen)); png_charpp profile, png_uint_32 *proflen));
/* Note to maintainer: profile should be png_bytepp */
#endif #endif
#if defined(PNG_iCCP_SUPPORTED) #if defined(PNG_iCCP_SUPPORTED)
extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_charp name, int compression_type, png_infop info_ptr, png_charp name, int compression_type,
png_charp profile, png_uint_32 proflen)); png_charp profile, png_uint_32 proflen));
/* Note to maintainer: profile should be png_bytep */
#endif #endif
#if defined(PNG_READ_sPLT_SUPPORTED) #if defined(PNG_READ_sPLT_SUPPORTED)
@@ -2003,19 +2128,28 @@ extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp
png_ptr, int keep, png_bytep chunk_list, int num_chunks)); png_ptr, int keep, png_bytep chunk_list, int num_chunks));
extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)); png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns));
extern PNG_EXPORT(void, png_set_unknown_chunk_location)
PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location));
extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp
png_ptr, png_infop info_ptr, png_unknown_chunkpp entries)); png_ptr, png_infop info_ptr, png_unknown_chunkpp entries));
#endif #endif
/* Png_free_data() will turn off the "valid" flag for anything it frees.
If you need to turn it off for a chunk that your application has freed,
you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */
extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr,
png_infop info_ptr, int mask));
#if defined(PNG_INFO_IMAGE_SUPPORTED) #if defined(PNG_INFO_IMAGE_SUPPORTED)
/* The "params" pointer is currently not used and is for future expansion. */
extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_infop info_ptr,
int transforms, int transforms,
voidp params)); png_voidp params));
extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_infop info_ptr,
int transforms, int transforms,
voidp params)); png_voidp params));
#endif #endif
/* Define PNG_DEBUG at compile time for debugging information. Higher /* Define PNG_DEBUG at compile time for debugging information. Higher
@@ -2025,19 +2159,38 @@ extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr,
*/ */
#ifdef PNG_DEBUG #ifdef PNG_DEBUG
#if (PNG_DEBUG > 0) #if (PNG_DEBUG > 0)
#if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)
#include <crtdbg.h>
#if (PNG_DEBUG > 1)
#define png_debug(l,m) _RPT0(_CRT_WARN,m)
#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m,p1)
#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m,p1,p2)
#endif
#else /* PNG_DEBUG_FILE || !_MSC_VER */
#ifndef PNG_DEBUG_FILE #ifndef PNG_DEBUG_FILE
#define PNG_DEBUG_FILE stderr #define PNG_DEBUG_FILE stderr
#endif /* PNG_DEBUG_FILE */ #endif /* PNG_DEBUG_FILE */
#if (PNG_DEBUG > 1)
#define png_debug(l,m) if (PNG_DEBUG > l) \ #define png_debug(l,m) \
fprintf(PNG_DEBUG_FILE,"%s"m,(l==1 ? "\t" : \ { \
(l==2 ? "\t\t":(l>2 ? "\t\t\t":"")))) int num_tabs=l; \
#define png_debug1(l,m,p1) if (PNG_DEBUG > l) \ fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \
fprintf(PNG_DEBUG_FILE,"%s"m,(l==1 ? "\t" : \ (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \
(l==2 ? "\t\t":(l>2 ? "\t\t\t":""))),p1) }
#define png_debug2(l,m,p1,p2) if (PNG_DEBUG > l) \ #define png_debug1(l,m,p1) \
fprintf(PNG_DEBUG_FILE,"%s"m,(l==1 ? "\t" : \ { \
(l==2 ? "\t\t":(l>2 ? "\t\t\t":""))),p1,p2) int num_tabs=l; \
fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \
}
#define png_debug2(l,m,p1,p2) \
{ \
int num_tabs=l; \
fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \
}
#endif /* (PNG_DEBUG > 1) */
#endif /* _MSC_VER */
#endif /* (PNG_DEBUG > 0) */ #endif /* (PNG_DEBUG > 0) */
#endif /* PNG_DEBUG */ #endif /* PNG_DEBUG */
#ifndef png_debug #ifndef png_debug
@@ -2057,8 +2210,13 @@ extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
#ifdef PNG_MNG_FEATURES_SUPPORTED
extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp
png_ptr, png_uint_32 mng_features_permitted));
#endif
#define PNG_HEADER_VERSION_STRING \ #define PNG_HEADER_VERSION_STRING \
" libpng version 1.0.6f - April 14, 2000 (header)\n" " libpng version 1.0.9beta5 - December 15, 2000 (header)\n"
#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
/* With these routines we avoid an integer divide, which will be slower on /* With these routines we avoid an integer divide, which will be slower on
@@ -2174,8 +2332,12 @@ extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 #define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200
#define PNG_FLAG_CRC_CRITICAL_USE 0x0400 #define PNG_FLAG_CRC_CRITICAL_USE 0x0400
#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 #define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800
#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x1000 #define PNG_FLAG_FREE_PLTE 0x1000
#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x2000 #define PNG_FLAG_FREE_TRNS 0x2000
#define PNG_FLAG_FREE_HIST 0x4000
#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L
#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L
#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L
/* For use in png_set_keep_unknown, png_handle_as_unknown */ /* For use in png_set_keep_unknown, png_handle_as_unknown */
#define HANDLE_CHUNK_AS_DEFAULT 0 #define HANDLE_CHUNK_AS_DEFAULT 0
@@ -2201,7 +2363,7 @@ extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
/* place to hold the signature string for a PNG file. */ /* place to hold the signature string for a PNG file. */
#ifdef PNG_USE_GLOBAL_ARRAYS #ifdef PNG_USE_GLOBAL_ARRAYS
PNG_EXPORT_VAR (png_byte FARDATA) png_sig[8]; PNG_EXPORT_VAR (const png_byte FARDATA) png_sig[8];
#else #else
#define png_sig png_sig_bytes(NULL) #define png_sig png_sig_bytes(NULL)
#endif #endif
@@ -2281,14 +2443,24 @@ PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf));
#endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */ #endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */
/* Initialize png_ptr struct for reading, and allocate any other memory. /* Initialize png_ptr struct for reading, and allocate any other memory.
* (old interface - NOT DLL EXPORTED). * (old interface - DEPRECATED).
*/ */
extern void png_read_init PNGARG((png_structp png_ptr)); extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr));
#define png_read_init(png_ptr) png_read_init_2(png_ptr, \
PNG_LIBPNG_VER_STRING, sizeof(png_struct), sizeof(png_info));
extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr,
png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t
png_info_size));
/* Initialize png_ptr struct for writing, and allocate any other memory. /* Initialize png_ptr struct for writing, and allocate any other memory.
* (old interface - NOT DLL EXPORTED). * (old interface - DEPRECATED).
*/ */
extern void png_write_init PNGARG((png_structp png_ptr)); extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr));
#define png_write_init(png_ptr) png_write_init_2(png_ptr, \
PNG_LIBPNG_VER_STRING, sizeof(png_struct), sizeof(png_info));
extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr,
png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t
png_info_size));
/* Allocate memory for an internal libpng struct */ /* Allocate memory for an internal libpng struct */
PNG_EXTERN png_voidp png_create_struct PNGARG((int type)); PNG_EXTERN png_voidp png_create_struct PNGARG((int type));
@@ -2377,8 +2549,8 @@ PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr));
*/ */
PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width, PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width,
png_uint_32 height, png_uint_32 height,
int bit_depth, int color_type, int compression_type, int filter_type, int bit_depth, int color_type, int compression_method, int filter_method,
int interlace_type)); int interlace_method));
PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette, PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette,
png_uint_32 num_pal)); png_uint_32 num_pal));
@@ -2428,6 +2600,7 @@ PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr,
PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr, PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr,
png_charp name, int compression_type, png_charp name, int compression_type,
png_charp profile, int proflen)); png_charp profile, int proflen));
/* Note to maintainer: profile should be png_bytep */
#endif #endif
#if defined(PNG_WRITE_sPLT_SUPPORTED) #if defined(PNG_WRITE_sPLT_SUPPORTED)
@@ -2830,11 +3003,19 @@ PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr,
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
#ifdef PNG_MNG_FEATURES_SUPPORTED
PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info,
png_bytep row));
PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info,
png_bytep row));
#endif
#endif /* PNG_INTERNAL */ #endif /* PNG_INTERNAL */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* PNG_VERSION_INFO_ONLY */
/* do not put anything past this line */ /* do not put anything past this line */
#endif /* _PNG_H */ #endif /* PNG_H */

View File

@@ -1,11 +1,14 @@
/* pngasmrd.h - assembler version of utilities to read a PNG file /* pngasmrd.h - assembler version of utilities to read a PNG file
* *
* libpng 1.0.6f - April 14, 2000 * libpng 1.0.9beta5 - December 15, 2000
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1999, 2000 Glenn Randers-Pehrson * Copyright (c) 1999, 2000 Glenn Randers-Pehrson
* *
*/ */
#ifndef PNGASMRD_H
#define PNGASMRD_H
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
/* Set this in the makefile for VC++ on Pentium, not in pngconf.h */ /* Set this in the makefile for VC++ on Pentium, not in pngconf.h */
@@ -33,3 +36,4 @@
*/ */
#endif #endif
#endif /* PNGASMRD_H */

BIN
pngbar.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
pngbar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

437
pngconf.h
View File

@@ -1,11 +1,10 @@
/* pngconf.h - machine configurable file for libpng /* pngconf.h - machine configurable file for libpng
* *
* libpng 1.0.6f - April 14, 2000 * libpng 1.0.9beta5 - December 15, 2000
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/ */
/* Any machine specific code is near the front of this file, so if you /* Any machine specific code is near the front of this file, so if you
@@ -34,6 +33,10 @@
#define PNG_ZBUF_SIZE 8192 #define PNG_ZBUF_SIZE 8192
#endif #endif
#ifndef PNG_NO_FLOATING_POINT_SUPPORTED
#define PNG_FLOATING_POINT_SUPPORTED
#endif
/* If you are running on a machine where you cannot allocate more /* If you are running on a machine where you cannot allocate more
* than 64K of memory at once, uncomment this. While libpng will not * than 64K of memory at once, uncomment this. While libpng will not
* normally need that much memory in a chunk (unless you load up a very * normally need that much memory in a chunk (unless you load up a very
@@ -46,6 +49,60 @@
#define PNG_MAX_MALLOC_64K #define PNG_MAX_MALLOC_64K
#endif #endif
/* Special munging to support doing things the 'cygwin' way:
* 'Normal' png-on-win32 defines/defaults:
* PNG_BUILD_DLL -- building dll
* PNG_USE_DLL -- building an application, linking to dll
* (no define) -- building static library, or building an
* application and linking to the static lib
* 'Cygwin' defines/defaults:
* PNG_BUILD_DLL -- building the dll
* (no define) -- building an application, linking to the dll
* PNG_STATIC -- building the static lib, or building an application
* which links to the static lib.
* Thus,
* a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and
* this bit of #ifdefs will define the 'correct' config variables based on
* that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but
* unnecessary.
*/
#if defined(__CYGWIN__)
# if defined(PNG_BUILD_DLL)
# if defined(PNG_USE_DLL)
# undef PNG_USE_DLL
# endif
# if !defined(PNG_DLL)
# define PNG_DLL
# endif
# if defined(PNG_STATIC)
# undef PNG_STATIC
# endif
# else
# if defined(PNG_STATIC)
# if defined(PNG_USE_DLL)
# undef PNG_USE_DLL
# endif
# if defined(PNG_DLL)
# undef PNG_DLL
# endif
# else
# if defined(PNG_USE_DLL)
# if !defined(PNG_DLL)
# define PNG_DLL
# endif
# else
# if defined(PNG_DLL)
# define PNG_USE_DLL
# else
# define PNG_USE_DLL
# define PNG_DLL
# endif
# endif
# endif
# endif
#endif
/* This protects us against compilers that run on a windowing system /* This protects us against compilers that run on a windowing system
* and thus don't have or would rather us not use the stdio types: * and thus don't have or would rather us not use the stdio types:
* stdin, stdout, and stderr. The only one currently used is stderr * stdin, stdout, and stderr. The only one currently used is stderr
@@ -59,6 +116,23 @@
* #define PNG_NO_STDIO * #define PNG_NO_STDIO
*/ */
#if defined(_WIN32_WCE)
#include <windows.h>
/* Console I/O functions are not supported on WindowsCE */
#define PNG_NO_CONSOLE_IO
#ifdef PNG_DEBUG
# undef PNG_DEBUG
#endif
#endif
#ifdef PNG_BUILD_DLL
# ifndef PNG_CONSOLE_IO_SUPPORTED
# ifndef PNG_NO_CONSOLE_IO
# define PNG_NO_CONSOLE_IO
# endif
# endif
#endif
# ifdef PNG_NO_STDIO # ifdef PNG_NO_STDIO
# ifndef PNG_NO_CONSOLE_IO # ifndef PNG_NO_CONSOLE_IO
# define PNG_NO_CONSOLE_IO # define PNG_NO_CONSOLE_IO
@@ -69,7 +143,10 @@
# endif # endif
# endif # endif
# else # else
# include <stdio.h> # if !defined(_WIN32_WCE)
/* "stdio.h" functions are not supported on WindowsCE */
# include <stdio.h>
# endif
# endif # endif
/* This macro protects us against machines that don't have function /* This macro protects us against machines that don't have function
@@ -107,7 +184,7 @@
#endif #endif
/* enough people need this for various reasons to include it here */ /* enough people need this for various reasons to include it here */
#if !defined(MACOS) && !defined(RISCOS) #if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE)
#include <sys/types.h> #include <sys/types.h>
#endif #endif
@@ -119,14 +196,15 @@
/* This is an attempt to force a single setjmp behaviour on Linux. If /* This is an attempt to force a single setjmp behaviour on Linux. If
* the X config stuff didn't define _BSD_SOURCE we wouldn't need this. * the X config stuff didn't define _BSD_SOURCE we wouldn't need this.
*/ */
# ifdef __linux__ # ifdef __linux__
# ifdef _BSD_SOURCE # ifdef _BSD_SOURCE
# define _PNG_SAVE_BSD_SOURCE # define PNG_SAVE_BSD_SOURCE
# undef _BSD_SOURCE # undef _BSD_SOURCE
# endif # endif
# ifdef _SETJMP_H # ifdef _SETJMP_H
__png.h__ already includes setjmp.h __png.h__ already includes setjmp.h;
__dont__ include it again __dont__ include it again.;
# endif # endif
#endif /* __linux__ */ #endif /* __linux__ */
@@ -134,13 +212,19 @@
#include <setjmp.h> #include <setjmp.h>
# ifdef __linux__ # ifdef __linux__
# ifdef _PNG_SAVE_BSD_SOURCE # ifdef PNG_SAVE_BSD_SOURCE
# define _BSD_SOURCE # define _BSD_SOURCE
# undef _PNG_SAVE_BSD_SOURCE # undef PNG_SAVE_BSD_SOURCE
# endif # endif
# endif /* __linux__ */ # endif /* __linux__ */
#endif /* PNG_SETJMP_SUPPORTED */ #endif /* PNG_SETJMP_SUPPORTED */
#if defined(_AIX) && defined(__xlC__)
/* This prevents "AIX/xlC" from generating an "index(s,c)" macro in strings.h
* that conflicts with libpng's png_color_16.index */
#undef __STR__
#endif
#ifdef BSD #ifdef BSD
#include <strings.h> #include <strings.h>
#else #else
@@ -164,7 +248,7 @@
* them inside an appropriate ifdef/endif pair for portability. * them inside an appropriate ifdef/endif pair for portability.
*/ */
#if !defined(PNG_NO_FLOATING_POINT_SUPPORTED) #if defined(PNG_FLOATING_POINT_SUPPORTED)
#if defined(MACOS) #if defined(MACOS)
/* We need to check that <math.h> hasn't already been included earlier /* We need to check that <math.h> hasn't already been included earlier
* as it seems it doesn't agree with <fp.h>, yet we should really use * as it seems it doesn't agree with <fp.h>, yet we should really use
@@ -176,6 +260,12 @@
#else #else
#include <math.h> #include <math.h>
#endif #endif
#if defined(_AMIGA) && defined(__SASC) && defined(_M68881)
/* Amiga SAS/C: We must include builtin FPU functions when compiling using
* MATH=68881
*/
#include <m68881.h>
#endif
#endif #endif
/* Codewarrior on NT has linking problems without this. */ /* Codewarrior on NT has linking problems without this. */
@@ -258,23 +348,70 @@
/* Any features you will not be using can be undef'ed here */ /* Any features you will not be using can be undef'ed here */
/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user /* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user
to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS
on the compile line, then pick and choose which ones to define without * on the compile line, then pick and choose which ones to define without
having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED
if you only want to have a png-compliant reader/writer but don't need * if you only want to have a png-compliant reader/writer but don't need
any of the extra transformations. This saves about 80 kbytes in a * any of the extra transformations. This saves about 80 kbytes in a
typical installation of the library. (PNG_NO_* form added in version * typical installation of the library. (PNG_NO_* form added in version
1.0.1c, for consistency) * 1.0.1c, for consistency)
*/ */
#ifndef PNG_NO_FLOATING_POINT_SUPPORTED /* The size of the png_text structure changed in libpng-1.0.6 when
#define PNG_FLOATING_POINT_SUPPORTED * iTXt is supported. It is turned off by default, to support old apps
* that malloc the png_text structure instead of calling png_set_text()
* and letting libpng malloc it. It will be turned on by default in
* libpng-2.0.0.
*/
#ifndef PNG_iTXt_SUPPORTED
# ifndef PNG_READ_iTXt_SUPPORTED
# define PNG_NO_READ_iTXt
# endif
# ifndef PNG_WRITE_iTXt_SUPPORTED
# define PNG_NO_WRITE_iTXt
# endif
#endif #endif
#ifndef PNG_NO_FIXED_POINT_SUPPORTED /* The following support, added after version 1.0.0, can be turned off here en
* masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility
* with old applications that require the length of png_struct and png_info
* to remain unchanged.
*/
#ifdef PNG_LEGACY_SUPPORTED
#define PNG_NO_FREE_ME
#define PNG_NO_READ_UNKNOWN_CHUNKS
#define PNG_NO_WRITE_UNKNOWN_CHUNKS
#define PNG_NO_READ_USER_CHUNKS
#define PNG_NO_READ_iCCP
#define PNG_NO_WRITE_iCCP
#define PNG_NO_READ_iTXt
#define PNG_NO_WRITE_iTXt
#define PNG_NO_READ_sCAL
#define PNG_NO_WRITE_sCAL
#define PNG_NO_READ_sPLT
#define PNG_NO_WRITE_sPLT
#define PNG_NO_INFO_IMAGE
#define PNG_NO_READ_RGB_TO_GRAY
#define PNG_NO_READ_USER_TRANSFORM
#define PNG_NO_WRITE_USER_TRANSFORM
#define PNG_NO_USER_MEM
#define PNG_NO_READ_EMPTY_PLTE
#define PNG_NO_MNG_FEATURES
#define PNG_NO_FIXED_POINT_SUPPORTED
#endif
/* Ignore attempt to turn off both floating and fixed point support */
#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \
!defined(PNG_NO_FIXED_POINT_SUPPORTED)
#define PNG_FIXED_POINT_SUPPORTED #define PNG_FIXED_POINT_SUPPORTED
#endif #endif
#ifndef PNG_NO_FREE_ME
#define PNG_FREE_ME_SUPPORTED
#endif
#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \ #if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
!defined(PNG_NO_READ_TRANSFORMS) !defined(PNG_NO_READ_TRANSFORMS)
#define PNG_READ_TRANSFORMS_SUPPORTED #define PNG_READ_TRANSFORMS_SUPPORTED
@@ -348,12 +485,18 @@
/* still have interlacing unless you change the following line: */ /* still have interlacing unless you change the following line: */
#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */ #define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */
#ifndef PNG_NO_READ_COMPOSITED_NODIV #ifndef PNG_NO_READ_COMPOSITE_NODIV
#ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel and SGI */ #define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel and SGI */
#endif #endif
#endif
#ifndef PNG_NO_MNG_FEATURES
#define PNG_MNG_FEATURES_SUPPORTED /* Useful for MNG applications */
#endif
/* Deprecated, will be removed */
#ifndef PNG_NO_READ_EMPTY_PLTE #ifndef PNG_NO_READ_EMPTY_PLTE
#define PNG_READ_EMPTY_PLTE_SUPPORTED /* useful for MNG applications */ #define PNG_READ_EMPTY_PLTE_SUPPORTED
#endif #endif
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED #ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
@@ -389,6 +532,13 @@
#endif #endif
#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ #endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
#ifndef PNG_NO_USER_TRANSFORM_PTR
#define PNG_USER_TRANSFORM_PTR_SUPPORTED
#endif
#endif
#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant #define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant
encoders, but can cause trouble encoders, but can cause trouble
if left undefined */ if left undefined */
@@ -402,8 +552,9 @@
#define PNG_WRITE_FLUSH_SUPPORTED #define PNG_WRITE_FLUSH_SUPPORTED
#endif #endif
/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */
#ifndef PNG_NO_WRITE_EMPTY_PLTE #ifndef PNG_NO_WRITE_EMPTY_PLTE
#define PNG_WRITE_EMPTY_PLTE_SUPPORTED /* useful for MNG applications */ #define PNG_WRITE_EMPTY_PLTE_SUPPORTED
#endif #endif
#ifndef PNG_NO_STDIO #ifndef PNG_NO_STDIO
@@ -435,27 +586,17 @@
#define PNG_ASSEMBLER_CODE_SUPPORTED #define PNG_ASSEMBLER_CODE_SUPPORTED
#endif #endif
/* Do not use global arrays (helps with building DLL's)
* They are no longer used in libpng itself, since version 1.0.5c,
* but might be required for some pre-1.0.5c applications.
*/
#ifdef PNG_NO_GLOBAL_ARRAYS
# define PNG_USE_LOCAL_ARRAYS
#else
# if defined(__GNUC__) && defined(WIN32)
# define PNG_NO_GLOBAL_ARRAYS
# define PNG_USE_LOCAL_ARRAYS
# else
# define PNG_USE_GLOBAL_ARRAYS
# endif
#endif
/* These are currently experimental features, define them if you want */ /* These are currently experimental features, define them if you want */
/* very little testing */ /* very little testing */
/* /*
#define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED #define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
#ifndef PNG_NO_USER_MEM
#define PNG_USER_MEM_SUPPORTED #define PNG_USER_MEM_SUPPORTED
#endif
#ifndef PNG_NO_ZALLOC_ZERO
#define PNG_ZALLOC_ZERO
#endif
*/ */
/* This is only for PowerPC big-endian and 680x0 systems */ /* This is only for PowerPC big-endian and 680x0 systems */
@@ -464,6 +605,11 @@
#define PNG_READ_BIG_ENDIAN_SUPPORTED #define PNG_READ_BIG_ENDIAN_SUPPORTED
*/ */
/* Buggy compilers (e.g., gcc 2.7.2.2) need this */
/*
#define PNG_NO_POINTER_INDEXING
*/
/* These functions are turned off by default, as they will be phased out. */ /* These functions are turned off by default, as they will be phased out. */
/* /*
#define PNG_USELESS_TESTS_SUPPORTED #define PNG_USELESS_TESTS_SUPPORTED
@@ -560,7 +706,17 @@
# define PNG_READ_zTXt_SUPPORTED # define PNG_READ_zTXt_SUPPORTED
# define PNG_zTXt_SUPPORTED # define PNG_zTXt_SUPPORTED
#endif #endif
#ifndef PNG_NO_READ_USER_CHUNKS #ifndef PNG_NO_READ_UNKNOWN_CHUNKS
# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
# define PNG_UNKNOWN_CHUNKS_SUPPORTED
# endif
# ifndef PNG_NO_HANDLE_AS_UNKNOWN
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# endif
#endif
#if !defined(PNG_NO_READ_USER_CHUNKS) && \
defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
# define PNG_READ_USER_CHUNKS_SUPPORTED # define PNG_READ_USER_CHUNKS_SUPPORTED
# define PNG_USER_CHUNKS_SUPPORTED # define PNG_USER_CHUNKS_SUPPORTED
# ifdef PNG_NO_READ_UNKNOWN_CHUNKS # ifdef PNG_NO_READ_UNKNOWN_CHUNKS
@@ -570,13 +726,6 @@
# undef PNG_NO_HANDLE_AS_UNKNOWN # undef PNG_NO_HANDLE_AS_UNKNOWN
# endif # endif
#endif #endif
#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
# define PNG_UNKNOWN_CHUNKS_SUPPORTED
# ifndef PNG_NO_HANDLE_AS_UNKNOWN
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# endif
#endif
#ifndef PNG_NO_READ_OPT_PLTE #ifndef PNG_NO_READ_OPT_PLTE
# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */ # define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */
#endif /* optional PLTE chunk in RGB and RGBA images */ #endif /* optional PLTE chunk in RGB and RGBA images */
@@ -725,7 +874,10 @@
/* need the time information for reading tIME chunks */ /* need the time information for reading tIME chunks */
#if defined(PNG_tIME_SUPPORTED) #if defined(PNG_tIME_SUPPORTED)
# include <time.h> # if !defined(_WIN32_WCE)
/* "time.h" functions are not supported on WindowsCE */
# include <time.h>
# endif
#endif #endif
/* Some typedefs to get us started. These should be safe on most of the /* Some typedefs to get us started. These should be safe on most of the
@@ -765,7 +917,7 @@ typedef size_t png_size_t;
#define LDATA 0 #define LDATA 0
#endif #endif
#if !defined(__WIN32__) && !defined(__FLAT__) #if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
#define PNG_MAX_MALLOC_64K #define PNG_MAX_MALLOC_64K
#if (LDATA != 1) #if (LDATA != 1)
#ifndef FAR #ifndef FAR
@@ -779,7 +931,7 @@ typedef size_t png_size_t;
* const if your compiler supports it. (SJT) * const if your compiler supports it. (SJT)
# define FARDATA FAR # define FARDATA FAR
*/ */
#endif /* __WIN32__, __FLAT__ */ #endif /* __WIN32__, __FLAT__, __CYGWIN__ */
#endif /* __BORLANDC__ */ #endif /* __BORLANDC__ */
@@ -822,6 +974,11 @@ typedef png_int_16 FAR * png_int_16p;
typedef PNG_CONST char FAR * png_const_charp; typedef PNG_CONST char FAR * png_const_charp;
typedef char FAR * png_charp; typedef char FAR * png_charp;
typedef png_fixed_point FAR * png_fixed_point_p; typedef png_fixed_point FAR * png_fixed_point_p;
#if defined(_WIN32_WCE)
typedef HANDLE png_FILE_p;
#else
typedef FILE * png_FILE_p;
#endif
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
typedef double FAR * png_doublep; typedef double FAR * png_doublep;
#endif #endif
@@ -850,66 +1007,156 @@ typedef charf * png_zcharp;
typedef charf * FAR * png_zcharpp; typedef charf * FAR * png_zcharpp;
typedef z_stream FAR * png_zstreamp; typedef z_stream FAR * png_zstreamp;
/*
* Define PNG_BUILD_DLL if the module being built is a Windows
* LIBPNG DLL.
*
* Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL.
* It is equivalent to Microsoft predefined macro _DLL which is
* automatically defined when you compile using the share
* version of the CRT (C Run-Time library)
*
* The cygwin mods make this behavior a little different:
* Define PNG_BUILD_DLL if you are building a dll for use with cygwin
* Define PNG_STATIC if you are building a static library for use with cygwin,
* -or- if you are building an application that you want to link to the
* static library.
* PNG_USE_DLL is defined by default (no user action needed) unless one of
* the other flags is defined.
*/
#ifndef PNG_EXPORT #if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL))
/* GRR 20000206: based on zconf.h and MSVC 5.0 docs */ # define PNG_DLL
# if defined(_MSC_VER) && defined(_DLL) #endif
# define PNG_EXPORT(type,symbol) type __declspec(dllexport) symbol /* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib.
* When building a static lib, default to no GLOBAL ARRAYS, but allow
* command-line override
*/
#if defined(__CYGWIN__)
# if !defined(PNG_STATIC)
# if defined(PNG_USE_GLOBAL_ARRAYS)
# undef PNG_USE_GLOBAL_ARRAYS
# endif
# if !defined(PNG_USE_LOCAL_ARRAYS)
# define PNG_USE_LOCAL_ARRAYS
# endif
# else
# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS)
# if defined(PNG_USE_GLOBAL_ARRAYS)
# undef PNG_USE_GLOBAL_ARRAYS
# endif
# endif
# endif
# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
# define PNG_USE_LOCAL_ARRAYS
# endif
#endif
/* Do not use global arrays (helps with building DLL's)
* They are no longer used in libpng itself, since version 1.0.5c,
* but might be required for some pre-1.0.5c applications.
*/
#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL))
# define PNG_USE_LOCAL_ARRAYS
# else
# define PNG_USE_GLOBAL_ARRAYS
# endif
#endif
#ifndef PNGAPI
#if defined(__MINGW32__) || defined(__CYGWIN__) && !defined(PNG_MODULEDEF)
# ifndef PNG_NO_MODULEDEF
# define PNG_NO_MODULEDEF
# endif
#endif
#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF)
# define PNG_IMPEXP
#endif
#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \
(( defined(_Windows) || defined(_WINDOWS) || \
defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \
) && !defined(__CYGWIN__))
# ifdef __GNUC__
# define PNGAPI __cdecl
# else
# define PNGAPI _cdecl
# endif # endif
/* allow for compilation as a DLL under MS Windows */ # if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \
# ifdef __WIN32DLL__ /* Borland? */ 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */)
# define PNG_EXPORT(type,symbol) __declspec(dllexport) type symbol # define PNG_IMPEXP
# endif # endif
/* this variant is used in Mozilla; may correspond to MSVC++ 6.0 changes */ # if !defined(PNG_IMPEXP)
# ifdef ALT_WIN32_DLL
# define PNG_EXPORT(type,symbol) type __attribute__((dllexport)) symbol
# endif
/* allow for compilation as a DLL with Borland C++ 5.0 */ # define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol
# if defined(__BORLANDC__) && defined(_Windows) && defined(__DLL__) # define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol
# define PNG_EXPORT(type,symbol) type _export symbol
# endif
/* allow for compilation as shared lib under BeOS */ /* Borland/Microsoft */
# ifdef __BEOSDLL__ # if defined(_MSC_VER) || defined(__BORLANDC__)
# define PNG_EXPORT(type,symbol) __declspec(export) type symbol # if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500)
# define PNG_EXPORT PNG_EXPORT_TYPE1
# else
# define PNG_EXPORT PNG_EXPORT_TYPE2
# if defined(PNG_BUILD_DLL)
# define PNG_IMPEXP __export
# else
# define PNG_IMPEXP /*__import*/ /* doesn't exist AFAIK in
VC++*/
# endif /* Exists in Borland C++ for
C++ classes (== huge) */
# endif
# endif
# if !defined(PNG_IMPEXP)
# if defined(PNG_BUILD_DLL)
# define PNG_IMPEXP __declspec(dllexport)
# else
# define PNG_IMPEXP __declspec(dllimport)
# endif
# endif
# endif /* PNG_IMPEXP */
#else /* !(DLL || non-cygwin WINDOWS) */
# if defined(__CYGWIN__) && !defined(PNG_DLL)
# if !defined(PNG_IMPEXP)
# define PNG_IMPEXP
# endif
# define PNGAPI __cdecl
# else
# if 0 /* ... other platforms, with other meanings */
# else
# define PNGAPI
# define PNG_IMPEXP
# endif
# endif # endif
#endif #endif
#endif
#ifndef PNGAPI
# define PNGAPI
#endif
#ifndef PNG_IMPEXP
# define PNG_IMPEXP
#endif
#ifndef PNG_EXPORT #ifndef PNG_EXPORT
# define PNG_EXPORT(type,symbol) type symbol # define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol
#endif
#if defined(__MINGW32__) || defined(__CYGWIN32__)
# define PNG_ATTR_DLLIMP
#endif #endif
#ifdef PNG_USE_GLOBAL_ARRAYS
#ifndef PNG_EXPORT_VAR #ifndef PNG_EXPORT_VAR
# if defined(_MSC_VER) && defined(_DLL) /* GRR 20000206 */ # define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type
# define PNG_EXPORT_VAR(type) extern type __declspec(dllexport) #endif
# endif
# ifdef PNG_DECL_DLLEXP
# define PNG_EXPORT_VAR(type) extern __declspec(dllexport) type
# endif
# ifdef PNG_ATTR_DLLEXP
# define PNG_EXPORT_VAR(type) extern type __attribute__((dllexport))
# endif
# ifdef PNG_DECL_DLLIMP
# define PNG_EXPORT_VAR(type) extern __declspec(dllimport) type
# endif
# ifdef PNG_ATTR_DLLIMP
# define PNG_EXPORT_VAR(type) extern type __attribute__((dllimport))
# endif
#endif #endif
#ifndef PNG_EXPORT_VAR /* User may want to use these so they are not in PNG_INTERNAL. Any library
# define PNG_EXPORT_VAR(type) extern type * functions that are passed far data must be model independent.
#endif
/* User may want to use these so not in PNG_INTERNAL. Any library functions
* that are passed far data must be model independent.
*/ */
#ifndef PNG_ABORT #ifndef PNG_ABORT

View File

@@ -1,11 +1,11 @@
/* pngerror.c - stub functions for i/o and memory allocation /* pngerror.c - stub functions for i/o and memory allocation
* *
* libpng 1.0.6f - April 14, 2000 * libpng 1.0.9beta5 - December 15, 2000
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
* This file provides a location for all error handling. Users who * This file provides a location for all error handling. Users who
* need special error handling are expected to write replacement functions * need special error handling are expected to write replacement functions
@@ -16,9 +16,11 @@
#define PNG_INTERNAL #define PNG_INTERNAL
#include "png.h" #include "png.h"
static void png_default_error PNGARG((png_structp png_ptr, static void /* PRIVATE */
png_default_error PNGARG((png_structp png_ptr,
png_const_charp message)); png_const_charp message));
static void png_default_warning PNGARG((png_structp png_ptr, static void /* PRIVATE */
png_default_warning PNGARG((png_structp png_ptr,
png_const_charp message)); png_const_charp message));
/* This function is called whenever there is a fatal error. This function /* This function is called whenever there is a fatal error. This function
@@ -26,7 +28,7 @@ static void png_default_warning PNGARG((png_structp png_ptr,
* you should supply a replacement error function and use png_set_error_fn() * you should supply a replacement error function and use png_set_error_fn()
* to replace the error function at run-time. * to replace the error function at run-time.
*/ */
void void PNGAPI
png_error(png_structp png_ptr, png_const_charp message) png_error(png_structp png_ptr, png_const_charp message)
{ {
if (png_ptr->error_fn != NULL) if (png_ptr->error_fn != NULL)
@@ -42,7 +44,7 @@ png_error(png_structp png_ptr, png_const_charp message)
* you should supply a replacement warning function and use * you should supply a replacement warning function and use
* png_set_error_fn() to replace the warning function at run-time. * png_set_error_fn() to replace the warning function at run-time.
*/ */
void void PNGAPI
png_warning(png_structp png_ptr, png_const_charp message) png_warning(png_structp png_ptr, png_const_charp message)
{ {
if (png_ptr->warning_fn != NULL) if (png_ptr->warning_fn != NULL)
@@ -62,7 +64,7 @@ static PNG_CONST char png_digit[16] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
}; };
static void static void /* PRIVATE */
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp message) png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp message)
{ {
int iout = 0, iin = 0; int iout = 0, iin = 0;
@@ -94,15 +96,15 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp message
} }
} }
void void PNGAPI
png_chunk_error(png_structp png_ptr, png_const_charp message) png_chunk_error(png_structp png_ptr, png_const_charp message)
{ {
char msg[16+64]; char msg[18+64];
png_format_buffer(png_ptr, msg, message); png_format_buffer(png_ptr, msg, message);
png_error(png_ptr, msg); png_error(png_ptr, msg);
} }
void void PNGAPI
png_chunk_warning(png_structp png_ptr, png_const_charp message) png_chunk_warning(png_structp png_ptr, png_const_charp message)
{ {
char msg[16+64]; char msg[16+64];
@@ -115,11 +117,14 @@ png_chunk_warning(png_structp png_ptr, png_const_charp message)
* function is used by default, or if the program supplies NULL for the * function is used by default, or if the program supplies NULL for the
* error function pointer in png_set_error_fn(). * error function pointer in png_set_error_fn().
*/ */
static void static void /* PRIVATE */
png_default_error(png_structp png_ptr, png_const_charp message) png_default_error(png_structp png_ptr, png_const_charp message)
{ {
#ifndef PNG_NO_CONSOLE_IO #ifndef PNG_NO_CONSOLE_IO
fprintf(stderr, "libpng error: %s\n", message); fprintf(stderr, "libpng error: %s\n", message);
#else
if (message)
/* make compiler happy */ ;
#endif #endif
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
@@ -133,7 +138,7 @@ png_default_error(png_structp png_ptr, png_const_charp message)
longjmp(png_ptr->jmpbuf, 1); longjmp(png_ptr->jmpbuf, 1);
# endif # endif
#else #else
if (png_ptr == NULL) if (png_ptr)
/* make compiler happy */ ; /* make compiler happy */ ;
PNG_ABORT(); PNG_ABORT();
#endif #endif
@@ -144,13 +149,16 @@ png_default_error(png_structp png_ptr, png_const_charp message)
* here if you don't want them to. In the default configuration, png_ptr is * here if you don't want them to. In the default configuration, png_ptr is
* not used, but it is passed in case it may be useful. * not used, but it is passed in case it may be useful.
*/ */
static void static void /* PRIVATE */
png_default_warning(png_structp png_ptr, png_const_charp message) png_default_warning(png_structp png_ptr, png_const_charp message)
{ {
#ifndef PNG_NO_CONSOLE_IO #ifndef PNG_NO_CONSOLE_IO
fprintf(stderr, "libpng warning: %s\n", message); fprintf(stderr, "libpng warning: %s\n", message);
#else
if (message)
/* appease compiler */ ;
#endif #endif
if (png_ptr == NULL) if (png_ptr)
return; return;
} }
@@ -159,7 +167,7 @@ png_default_warning(png_structp png_ptr, png_const_charp message)
* return to the calling routine or serious problems will occur. The return * return to the calling routine or serious problems will occur. The return
* method used in the default routine calls longjmp(png_ptr->jmpbuf, 1) * method used in the default routine calls longjmp(png_ptr->jmpbuf, 1)
*/ */
void void PNGAPI
png_set_error_fn(png_structp png_ptr, png_voidp error_ptr, png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
png_error_ptr error_fn, png_error_ptr warning_fn) png_error_ptr error_fn, png_error_ptr warning_fn)
{ {
@@ -173,7 +181,7 @@ png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
* functions. The application should free any memory associated with this * functions. The application should free any memory associated with this
* pointer before png_write_destroy and png_read_destroy are called. * pointer before png_write_destroy and png_read_destroy are called.
*/ */
png_voidp png_voidp PNGAPI
png_get_error_ptr(png_structp png_ptr) png_get_error_ptr(png_structp png_ptr)
{ {
return ((png_voidp)png_ptr->error_ptr); return ((png_voidp)png_ptr->error_ptr);

2948
pnggccrd.c

File diff suppressed because it is too large Load Diff

178
pngget.c
View File

@@ -1,17 +1,17 @@
/* pngget.c - retrieval of values from info struct /* pngget.c - retrieval of values from info struct
* *
* libpng 1.0.6f - April 14, 2000 * libpng 1.0.9beta5 - December 15, 2000
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
#include "png.h" #include "png.h"
png_uint_32 png_uint_32 PNGAPI
png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
@@ -20,7 +20,7 @@ png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
return(0); return(0);
} }
png_uint_32 png_uint_32 PNGAPI
png_get_rowbytes(png_structp png_ptr, png_infop info_ptr) png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
@@ -30,7 +30,7 @@ png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
} }
#if defined(PNG_INFO_IMAGE_SUPPORTED) #if defined(PNG_INFO_IMAGE_SUPPORTED)
png_bytepp png_bytepp PNGAPI
png_get_rows(png_structp png_ptr, png_infop info_ptr) png_get_rows(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
@@ -42,7 +42,7 @@ png_get_rows(png_structp png_ptr, png_infop info_ptr)
#ifdef PNG_EASY_ACCESS_SUPPORTED #ifdef PNG_EASY_ACCESS_SUPPORTED
/* easy access to info, added in libpng-0.99 */ /* easy access to info, added in libpng-0.99 */
png_uint_32 png_uint_32 PNGAPI
png_get_image_width(png_structp png_ptr, png_infop info_ptr) png_get_image_width(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
@@ -52,7 +52,7 @@ png_get_image_width(png_structp png_ptr, png_infop info_ptr)
return (0); return (0);
} }
png_uint_32 png_uint_32 PNGAPI
png_get_image_height(png_structp png_ptr, png_infop info_ptr) png_get_image_height(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
@@ -62,7 +62,7 @@ png_get_image_height(png_structp png_ptr, png_infop info_ptr)
return (0); return (0);
} }
png_byte png_byte PNGAPI
png_get_bit_depth(png_structp png_ptr, png_infop info_ptr) png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
@@ -72,7 +72,7 @@ png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
return (0); return (0);
} }
png_byte png_byte PNGAPI
png_get_color_type(png_structp png_ptr, png_infop info_ptr) png_get_color_type(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
@@ -82,7 +82,7 @@ png_get_color_type(png_structp png_ptr, png_infop info_ptr)
return (0); return (0);
} }
png_byte png_byte PNGAPI
png_get_filter_type(png_structp png_ptr, png_infop info_ptr) png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
@@ -92,7 +92,7 @@ png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
return (0); return (0);
} }
png_byte png_byte PNGAPI
png_get_interlace_type(png_structp png_ptr, png_infop info_ptr) png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
@@ -102,7 +102,7 @@ png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
return (0); return (0);
} }
png_byte png_byte PNGAPI
png_get_compression_type(png_structp png_ptr, png_infop info_ptr) png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
@@ -112,43 +112,48 @@ png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
return (0); return (0);
} }
png_uint_32 png_uint_32 PNGAPI
png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL)
#if defined(PNG_pHYs_SUPPORTED) #if defined(PNG_pHYs_SUPPORTED)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) if (info_ptr->valid & PNG_INFO_pHYs)
{ {
png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter"); png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter");
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
return (0); return (0);
else return (info_ptr->x_pixels_per_unit); else return (info_ptr->x_pixels_per_unit);
} }
else #else
return (0);
#endif #endif
return (0); return (0);
} }
png_uint_32 png_uint_32 PNGAPI
png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL)
#if defined(PNG_pHYs_SUPPORTED) #if defined(PNG_pHYs_SUPPORTED)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) if (info_ptr->valid & PNG_INFO_pHYs)
{ {
png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter"); png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter");
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
return (0); return (0);
else return (info_ptr->y_pixels_per_unit); else return (info_ptr->y_pixels_per_unit);
} }
else #else
return (0);
#endif #endif
return (0); return (0);
} }
png_uint_32 png_uint_32 PNGAPI
png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL)
#if defined(PNG_pHYs_SUPPORTED) #if defined(PNG_pHYs_SUPPORTED)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) if (info_ptr->valid & PNG_INFO_pHYs)
{ {
png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter"); png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter");
if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER || if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
@@ -156,133 +161,144 @@ png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
return (0); return (0);
else return (info_ptr->x_pixels_per_unit); else return (info_ptr->x_pixels_per_unit);
} }
else #else
return (0);
#endif #endif
return (0); return (0);
} }
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
float float PNGAPI
png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr) png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL)
#if defined(PNG_pHYs_SUPPORTED) #if defined(PNG_pHYs_SUPPORTED)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) if (info_ptr->valid & PNG_INFO_pHYs)
{ {
png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio"); png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio");
if (info_ptr->x_pixels_per_unit == 0) if (info_ptr->x_pixels_per_unit == 0)
return ((float)0.0); return ((float)0.0);
else else
return ((float)info_ptr->y_pixels_per_unit return ((float)((float)info_ptr->y_pixels_per_unit
/(float)info_ptr->x_pixels_per_unit); /(float)info_ptr->x_pixels_per_unit));
} }
else #else
return (0.0);
#endif #endif
return ((float)0.0); return ((float)0.0);
} }
#endif #endif
png_uint_32 png_int_32 PNGAPI
png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr) png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL)
#if defined(PNG_oFFs_SUPPORTED) #if defined(PNG_oFFs_SUPPORTED)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) if (info_ptr->valid & PNG_INFO_oFFs)
{ {
png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
return (0); return (0);
else return (info_ptr->x_offset); else return (info_ptr->x_offset);
} }
else #else
return (0);
#endif #endif
return (0); return (0);
} }
png_uint_32 png_int_32 PNGAPI
png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr) png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL)
#if defined(PNG_oFFs_SUPPORTED) #if defined(PNG_oFFs_SUPPORTED)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) if (info_ptr->valid & PNG_INFO_oFFs)
{ {
png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
return (0); return (0);
else return (info_ptr->y_offset); else return (info_ptr->y_offset);
} }
else #else
return (0);
#endif #endif
return (0); return (0);
} }
png_uint_32 png_int_32 PNGAPI
png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr) png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL)
#if defined(PNG_oFFs_SUPPORTED) #if defined(PNG_oFFs_SUPPORTED)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) if (info_ptr->valid & PNG_INFO_oFFs)
{ {
png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns");
if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
return (0); return (0);
else return (info_ptr->x_offset); else return (info_ptr->x_offset);
} }
else #else
return (0);
#endif #endif
return (0); return (0);
} }
png_uint_32 png_int_32 PNGAPI
png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr) png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL)
#if defined(PNG_oFFs_SUPPORTED) #if defined(PNG_oFFs_SUPPORTED)
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) if (info_ptr->valid & PNG_INFO_oFFs)
{ {
png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns");
if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
return (0); return (0);
else return (info_ptr->y_offset); else return (info_ptr->y_offset);
} }
else #else
return (0);
#endif #endif
return (0); return (0);
} }
#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) #if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
png_uint_32 png_uint_32 PNGAPI
png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
{ {
return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr) return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr)
*.0254 +.5); *.0254 +.5));
} }
png_uint_32 png_uint_32 PNGAPI
png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
{ {
return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr) return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr)
*.0254 +.5); *.0254 +.5));
} }
png_uint_32 png_uint_32 PNGAPI
png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
{ {
return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr) return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr)
*.0254 +.5); *.0254 +.5));
} }
float float PNGAPI
png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr) png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
{ {
return ((float)png_get_x_offset_microns(png_ptr, info_ptr) return ((float)png_get_x_offset_microns(png_ptr, info_ptr)
*.00003937); *.00003937);
} }
float float PNGAPI
png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr) png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
{ {
return ((float)png_get_y_offset_microns(png_ptr, info_ptr) return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
*.00003937) *.00003937);
} }
#if defined(PNG_READ_pHYs_SUPPORTED) #if defined(PNG_READ_pHYs_SUPPORTED)
png_uint_32 png_uint_32 PNGAPI
png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
{ {
@@ -305,7 +321,7 @@ png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
{ {
*unit_type = (int)info_ptr->phys_unit_type; *unit_type = (int)info_ptr->phys_unit_type;
retval |= PNG_INFO_pHYs; retval |= PNG_INFO_pHYs;
if(unit_type == 1) if(*unit_type == 1)
{ {
if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50); if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
@@ -321,7 +337,7 @@ png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
#endif /* PNG_EASY_ACCESS_SUPPORTED */ #endif /* PNG_EASY_ACCESS_SUPPORTED */
png_byte png_byte PNGAPI
png_get_channels(png_structp png_ptr, png_infop info_ptr) png_get_channels(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
@@ -330,7 +346,7 @@ png_get_channels(png_structp png_ptr, png_infop info_ptr)
return (0); return (0);
} }
png_bytep png_bytep PNGAPI
png_get_signature(png_structp png_ptr, png_infop info_ptr) png_get_signature(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
@@ -340,7 +356,7 @@ png_get_signature(png_structp png_ptr, png_infop info_ptr)
} }
#if defined(PNG_READ_bKGD_SUPPORTED) #if defined(PNG_READ_bKGD_SUPPORTED)
png_uint_32 png_uint_32 PNGAPI
png_get_bKGD(png_structp png_ptr, png_infop info_ptr, png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
png_color_16p *background) png_color_16p *background)
{ {
@@ -357,7 +373,7 @@ png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
#if defined(PNG_READ_cHRM_SUPPORTED) #if defined(PNG_READ_cHRM_SUPPORTED)
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 png_uint_32 PNGAPI
png_get_cHRM(png_structp png_ptr, png_infop info_ptr, png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
double *white_x, double *white_y, double *red_x, double *red_y, double *white_x, double *white_y, double *red_x, double *red_y,
double *green_x, double *green_y, double *blue_x, double *blue_y) double *green_x, double *green_y, double *blue_x, double *blue_y)
@@ -387,7 +403,7 @@ png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
} }
#endif #endif
#ifdef PNG_FIXED_POINT_SUPPORTED #ifdef PNG_FIXED_POINT_SUPPORTED
png_uint_32 png_uint_32 PNGAPI
png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
@@ -421,7 +437,7 @@ png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
#if defined(PNG_READ_gAMA_SUPPORTED) #if defined(PNG_READ_gAMA_SUPPORTED)
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 png_uint_32 PNGAPI
png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
{ {
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
@@ -434,7 +450,8 @@ png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
return (0); return (0);
} }
#endif #endif
png_uint_32 #ifdef PNG_FIXED_POINT_SUPPORTED
png_uint_32 PNGAPI
png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
png_fixed_point *int_file_gamma) png_fixed_point *int_file_gamma)
{ {
@@ -448,9 +465,10 @@ png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
return (0); return (0);
} }
#endif #endif
#endif
#if defined(PNG_READ_sRGB_SUPPORTED) #if defined(PNG_READ_sRGB_SUPPORTED)
png_uint_32 png_uint_32 PNGAPI
png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
{ {
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
@@ -465,7 +483,7 @@ png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
#endif #endif
#if defined(PNG_READ_iCCP_SUPPORTED) #if defined(PNG_READ_iCCP_SUPPORTED)
png_uint_32 png_uint_32 PNGAPI
png_get_iCCP(png_structp png_ptr, png_infop info_ptr, png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
png_charpp name, int *compression_type, png_charpp name, int *compression_type,
png_charpp profile, png_uint_32 *proflen) png_charpp profile, png_uint_32 *proflen)
@@ -487,7 +505,7 @@ png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
#endif #endif
#if defined(PNG_READ_sPLT_SUPPORTED) #if defined(PNG_READ_sPLT_SUPPORTED)
png_uint_32 png_uint_32 PNGAPI
png_get_sPLT(png_structp png_ptr, png_infop info_ptr, png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
png_sPLT_tpp spalettes) png_sPLT_tpp spalettes)
{ {
@@ -498,7 +516,7 @@ png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
#endif #endif
#if defined(PNG_READ_hIST_SUPPORTED) #if defined(PNG_READ_hIST_SUPPORTED)
png_uint_32 png_uint_32 PNGAPI
png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist) png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
{ {
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
@@ -512,7 +530,7 @@ png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
} }
#endif #endif
png_uint_32 png_uint_32 PNGAPI
png_get_IHDR(png_structp png_ptr, png_infop info_ptr, png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
png_uint_32 *width, png_uint_32 *height, int *bit_depth, png_uint_32 *width, png_uint_32 *height, int *bit_depth,
int *color_type, int *interlace_type, int *compression_type, int *color_type, int *interlace_type, int *compression_type,
@@ -559,7 +577,7 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
} }
#if defined(PNG_READ_oFFs_SUPPORTED) #if defined(PNG_READ_oFFs_SUPPORTED)
png_uint_32 png_uint_32 PNGAPI
png_get_oFFs(png_structp png_ptr, png_infop info_ptr, png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
{ {
@@ -577,7 +595,7 @@ png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
#endif #endif
#if defined(PNG_READ_pCAL_SUPPORTED) #if defined(PNG_READ_pCAL_SUPPORTED)
png_uint_32 png_uint_32 PNGAPI
png_get_pCAL(png_structp png_ptr, png_infop info_ptr, png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
png_charp *units, png_charpp *params) png_charp *units, png_charpp *params)
@@ -602,7 +620,7 @@ png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED) #if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED)
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 png_uint_32 PNGAPI
png_get_sCAL(png_structp png_ptr, png_infop info_ptr, png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
int *unit, double *width, double *height) int *unit, double *width, double *height)
{ {
@@ -618,7 +636,7 @@ png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
} }
#else #else
#ifdef PNG_FIXED_POINT_SUPPORTED #ifdef PNG_FIXED_POINT_SUPPORTED
png_uint_32 png_uint_32 PNGAPI
png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr, png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
int *unit, png_charpp width, png_charpp height) int *unit, png_charpp width, png_charpp height)
{ {
@@ -637,7 +655,7 @@ png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
#endif #endif
#if defined(PNG_READ_pHYs_SUPPORTED) #if defined(PNG_READ_pHYs_SUPPORTED)
png_uint_32 png_uint_32 PNGAPI
png_get_pHYs(png_structp png_ptr, png_infop info_ptr, png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
{ {
@@ -667,7 +685,7 @@ png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
} }
#endif #endif
png_uint_32 png_uint_32 PNGAPI
png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
int *num_palette) int *num_palette)
{ {
@@ -684,7 +702,7 @@ png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
} }
#if defined(PNG_READ_sBIT_SUPPORTED) #if defined(PNG_READ_sBIT_SUPPORTED)
png_uint_32 png_uint_32 PNGAPI
png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
{ {
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
@@ -699,7 +717,7 @@ png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
#endif #endif
#if defined(PNG_READ_TEXT_SUPPORTED) #if defined(PNG_READ_TEXT_SUPPORTED)
png_uint_32 png_uint_32 PNGAPI
png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
int *num_text) int *num_text)
{ {
@@ -721,7 +739,7 @@ png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
#endif #endif
#if defined(PNG_READ_tIME_SUPPORTED) #if defined(PNG_READ_tIME_SUPPORTED)
png_uint_32 png_uint_32 PNGAPI
png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
{ {
if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
@@ -736,7 +754,7 @@ png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
#endif #endif
#if defined(PNG_READ_tRNS_SUPPORTED) #if defined(PNG_READ_tRNS_SUPPORTED)
png_uint_32 png_uint_32 PNGAPI
png_get_tRNS(png_structp png_ptr, png_infop info_ptr, png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
png_bytep *trans, int *num_trans, png_color_16p *trans_values) png_bytep *trans, int *num_trans, png_color_16p *trans_values)
{ {
@@ -775,7 +793,7 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
#endif #endif
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
png_uint_32 png_uint_32 PNGAPI
png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr, png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
png_unknown_chunkpp unknowns) png_unknown_chunkpp unknowns)
{ {
@@ -786,7 +804,7 @@ png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
#endif #endif
#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
png_byte png_byte PNGAPI
png_get_rgb_to_gray_status (png_structp png_ptr) png_get_rgb_to_gray_status (png_structp png_ptr)
{ {
return png_ptr->rgb_to_gray_status; return png_ptr->rgb_to_gray_status;
@@ -794,10 +812,16 @@ png_get_rgb_to_gray_status (png_structp png_ptr)
#endif #endif
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) #if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
png_voidp png_voidp PNGAPI
png_get_user_chunk_ptr(png_structp png_ptr) png_get_user_chunk_ptr(png_structp png_ptr)
{ {
return (png_ptr->user_chunk_ptr); return (png_ptr->user_chunk_ptr);
} }
#endif #endif
png_uint_32 PNGAPI
png_get_compression_buffer_size(png_structp png_ptr)
{
return(png_ptr->zbuf_size);
}

View File

@@ -1,11 +1,11 @@
/* pngmem.c - stub functions for memory allocation /* pngmem.c - stub functions for memory allocation
* *
* libpng 1.0.6f - April 14, 2000 * libpng 1.0.9beta5 - December 15, 2000
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
* This file provides a location for all memory allocation. Users who * This file provides a location for all memory allocation. Users who
* need special memory handling are expected to supply replacement * need special memory handling are expected to supply replacement
@@ -23,7 +23,7 @@
/* Allocate memory for a png_struct. The malloc and memset can be replaced /* Allocate memory for a png_struct. The malloc and memset can be replaced
by a single call to calloc() if this is thought to improve performance. */ by a single call to calloc() if this is thought to improve performance. */
png_voidp png_voidp /* PRIVATE */
png_create_struct(int type) png_create_struct(int type)
{ {
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
@@ -31,7 +31,7 @@ png_create_struct(int type)
} }
/* Alternate version of png_create_struct, for use with user-defined malloc. */ /* Alternate version of png_create_struct, for use with user-defined malloc. */
png_voidp png_voidp /* PRIVATE */
png_create_struct_2(int type, png_malloc_ptr malloc_fn) png_create_struct_2(int type, png_malloc_ptr malloc_fn)
{ {
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
@@ -62,7 +62,7 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn)
/* Free memory allocated by a png_create_struct() call */ /* Free memory allocated by a png_create_struct() call */
void void /* PRIVATE */
png_destroy_struct(png_voidp struct_ptr) png_destroy_struct(png_voidp struct_ptr)
{ {
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
@@ -70,7 +70,7 @@ png_destroy_struct(png_voidp struct_ptr)
} }
/* Free memory allocated by a png_create_struct() call */ /* Free memory allocated by a png_create_struct() call */
void void /* PRIVATE */
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn) png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
{ {
#endif #endif
@@ -108,7 +108,7 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
* result, we would be truncating potentially larger memory requests * result, we would be truncating potentially larger memory requests
* (which should cause a fatal error) and introducing major problems. * (which should cause a fatal error) and introducing major problems.
*/ */
png_voidp png_voidp PNGAPI
png_malloc(png_structp png_ptr, png_uint_32 size) png_malloc(png_structp png_ptr, png_uint_32 size)
{ {
#ifndef PNG_USER_MEM_SUPPORTED #ifndef PNG_USER_MEM_SUPPORTED
@@ -124,7 +124,7 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
return png_malloc_default(png_ptr, size); return png_malloc_default(png_ptr, size);
} }
png_voidp png_voidp PNGAPI
png_malloc_default(png_structp png_ptr, png_uint_32 size) png_malloc_default(png_structp png_ptr, png_uint_32 size)
{ {
png_voidp ret; png_voidp ret;
@@ -224,7 +224,7 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
/* free a pointer allocated by png_malloc(). In the default /* free a pointer allocated by png_malloc(). In the default
configuration, png_ptr is not used, but is passed in case it configuration, png_ptr is not used, but is passed in case it
is needed. If ptr is NULL, return without taking any action. */ is needed. If ptr is NULL, return without taking any action. */
void void PNGAPI
png_free(png_structp png_ptr, png_voidp ptr) png_free(png_structp png_ptr, png_voidp ptr)
{ {
if (png_ptr == NULL || ptr == NULL) if (png_ptr == NULL || ptr == NULL)
@@ -239,7 +239,7 @@ png_free(png_structp png_ptr, png_voidp ptr)
else png_free_default(png_ptr, ptr); else png_free_default(png_ptr, ptr);
} }
void void PNGAPI
png_free_default(png_structp png_ptr, png_voidp ptr) png_free_default(png_structp png_ptr, png_voidp ptr)
{ {
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
@@ -277,7 +277,7 @@ png_free_default(png_structp png_ptr, png_voidp ptr)
/* Allocate memory for a png_struct or a png_info. The malloc and /* Allocate memory for a png_struct or a png_info. The malloc and
memset can be replaced by a single call to calloc() if this is thought memset can be replaced by a single call to calloc() if this is thought
to improve performance noticably.*/ to improve performance noticably.*/
png_voidp png_voidp /* PRIVATE */
png_create_struct(int type) png_create_struct(int type)
{ {
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
@@ -287,7 +287,7 @@ png_create_struct(int type)
/* Allocate memory for a png_struct or a png_info. The malloc and /* Allocate memory for a png_struct or a png_info. The malloc and
memset can be replaced by a single call to calloc() if this is thought memset can be replaced by a single call to calloc() if this is thought
to improve performance noticably.*/ to improve performance noticably.*/
png_voidp png_voidp /* PRIVATE */
png_create_struct_2(int type, png_malloc_ptr malloc_fn) png_create_struct_2(int type, png_malloc_ptr malloc_fn)
{ {
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
@@ -328,7 +328,7 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn)
/* Free memory allocated by a png_create_struct() call */ /* Free memory allocated by a png_create_struct() call */
void void /* PRIVATE */
png_destroy_struct(png_voidp struct_ptr) png_destroy_struct(png_voidp struct_ptr)
{ {
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
@@ -336,7 +336,7 @@ png_destroy_struct(png_voidp struct_ptr)
} }
/* Free memory allocated by a png_create_struct() call */ /* Free memory allocated by a png_create_struct() call */
void void /* PRIVATE */
png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn) png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
{ {
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
@@ -370,7 +370,7 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
need to allocate exactly 64K, so whatever you call here must need to allocate exactly 64K, so whatever you call here must
have the ability to do that. */ have the ability to do that. */
png_voidp png_voidp PNGAPI
png_malloc(png_structp png_ptr, png_uint_32 size) png_malloc(png_structp png_ptr, png_uint_32 size)
{ {
#ifndef PNG_USER_MEM_SUPPORTED #ifndef PNG_USER_MEM_SUPPORTED
@@ -385,7 +385,7 @@ png_malloc(png_structp png_ptr, png_uint_32 size)
else else
return (png_malloc_default(png_ptr, size)); return (png_malloc_default(png_ptr, size));
} }
png_voidp png_voidp /* PRIVATE */
png_malloc_default(png_structp png_ptr, png_uint_32 size) png_malloc_default(png_structp png_ptr, png_uint_32 size)
{ {
png_voidp ret; png_voidp ret;
@@ -416,7 +416,7 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
/* Free a pointer allocated by png_malloc(). If ptr is NULL, return /* Free a pointer allocated by png_malloc(). If ptr is NULL, return
without taking any action. */ without taking any action. */
void void PNGAPI
png_free(png_structp png_ptr, png_voidp ptr) png_free(png_structp png_ptr, png_voidp ptr)
{ {
if (png_ptr == NULL || ptr == NULL) if (png_ptr == NULL || ptr == NULL)
@@ -430,7 +430,7 @@ png_free(png_structp png_ptr, png_voidp ptr)
} }
else png_free_default(png_ptr, ptr); else png_free_default(png_ptr, ptr);
} }
void void /* PRIVATE */
png_free_default(png_structp png_ptr, png_voidp ptr) png_free_default(png_structp png_ptr, png_voidp ptr)
{ {
if (png_ptr == NULL || ptr == NULL) if (png_ptr == NULL || ptr == NULL)
@@ -451,7 +451,7 @@ png_free_default(png_structp png_ptr, png_voidp ptr)
#endif /* Not Borland DOS special memory handler */ #endif /* Not Borland DOS special memory handler */
png_voidp png_voidp /* PRIVATE */
png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2, png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2,
png_uint_32 length) png_uint_32 length)
{ {
@@ -464,7 +464,7 @@ png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2,
return(png_memcpy (s1, s2, size)); return(png_memcpy (s1, s2, size));
} }
png_voidp png_voidp /* PRIVATE */
png_memset_check (png_structp png_ptr, png_voidp s1, int value, png_memset_check (png_structp png_ptr, png_voidp s1, int value,
png_uint_32 length) png_uint_32 length)
{ {
@@ -482,7 +482,7 @@ png_memset_check (png_structp png_ptr, png_voidp s1, int value,
/* This function is called when the application wants to use another method /* This function is called when the application wants to use another method
* of allocating and freeing memory. * of allocating and freeing memory.
*/ */
void void PNGAPI
png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
malloc_fn, png_free_ptr free_fn) malloc_fn, png_free_ptr free_fn)
{ {
@@ -495,7 +495,7 @@ png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
* functions. The application should free any memory associated with this * functions. The application should free any memory associated with this
* pointer before png_write_destroy and png_read_destroy are called. * pointer before png_write_destroy and png_read_destroy are called.
*/ */
png_voidp png_voidp PNGAPI
png_get_mem_ptr(png_structp png_ptr) png_get_mem_ptr(png_structp png_ptr)
{ {
return ((png_voidp)png_ptr->mem_ptr); return ((png_voidp)png_ptr->mem_ptr);

View File

@@ -1,11 +1,11 @@
/* pngpread.c - read a png file in push mode /* pngpread.c - read a png file in push mode
* *
* libpng 1.0.6f - April 14, 2000 * libpng 1.0.9beta5 - December 15, 2000
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
@@ -24,7 +24,7 @@
#define PNG_READ_iTXt_MODE 7 #define PNG_READ_iTXt_MODE 7
#define PNG_ERROR_MODE 8 #define PNG_ERROR_MODE 8
void void PNGAPI
png_process_data(png_structp png_ptr, png_infop info_ptr, png_process_data(png_structp png_ptr, png_infop info_ptr,
png_bytep buffer, png_size_t buffer_size) png_bytep buffer, png_size_t buffer_size)
{ {
@@ -39,7 +39,7 @@ png_process_data(png_structp png_ptr, png_infop info_ptr,
/* What we do with the incoming data depends on what we were previously /* What we do with the incoming data depends on what we were previously
* doing before we ran out of data... * doing before we ran out of data...
*/ */
void void /* PRIVATE */
png_process_some_data(png_structp png_ptr, png_infop info_ptr) png_process_some_data(png_structp png_ptr, png_infop info_ptr)
{ {
switch (png_ptr->process_mode) switch (png_ptr->process_mode)
@@ -99,7 +99,7 @@ png_process_some_data(png_structp png_ptr, png_infop info_ptr)
* checked by the calling application, or because of multiple calls to this * checked by the calling application, or because of multiple calls to this
* routine. * routine.
*/ */
void void /* PRIVATE */
png_push_read_sig(png_structp png_ptr, png_infop info_ptr) png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
{ {
png_size_t num_checked = png_ptr->sig_bytes, png_size_t num_checked = png_ptr->sig_bytes,
@@ -131,7 +131,7 @@ png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
} }
} }
void void /* PRIVATE */
png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -463,14 +463,14 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
} }
void void /* PRIVATE */
png_push_crc_skip(png_structp png_ptr, png_uint_32 skip) png_push_crc_skip(png_structp png_ptr, png_uint_32 skip)
{ {
png_ptr->process_mode = PNG_SKIP_MODE; png_ptr->process_mode = PNG_SKIP_MODE;
png_ptr->skip_length = skip; png_ptr->skip_length = skip;
} }
void void /* PRIVATE */
png_push_crc_finish(png_structp png_ptr) png_push_crc_finish(png_structp png_ptr)
{ {
if (png_ptr->skip_length && png_ptr->save_buffer_size) if (png_ptr->skip_length && png_ptr->save_buffer_size)
@@ -518,7 +518,7 @@ png_push_crc_finish(png_structp png_ptr)
} }
} }
void void /* PRIVATE */
png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
{ {
png_bytep ptr; png_bytep ptr;
@@ -556,7 +556,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
} }
} }
void void /* PRIVATE */
png_push_save_buffer(png_structp png_ptr) png_push_save_buffer(png_structp png_ptr)
{ {
if (png_ptr->save_buffer_size) if (png_ptr->save_buffer_size)
@@ -600,7 +600,7 @@ png_push_save_buffer(png_structp png_ptr)
png_ptr->buffer_size = 0; png_ptr->buffer_size = 0;
} }
void void /* PRIVATE */
png_push_restore_buffer(png_structp png_ptr, png_bytep buffer, png_push_restore_buffer(png_structp png_ptr, png_bytep buffer,
png_size_t buffer_length) png_size_t buffer_length)
{ {
@@ -610,7 +610,7 @@ png_push_restore_buffer(png_structp png_ptr, png_bytep buffer,
png_ptr->current_buffer_ptr = png_ptr->current_buffer; png_ptr->current_buffer_ptr = png_ptr->current_buffer;
} }
void void /* PRIVATE */
png_push_read_IDAT(png_structp png_ptr) png_push_read_IDAT(png_structp png_ptr)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -700,7 +700,7 @@ png_push_read_IDAT(png_structp png_ptr)
} }
} }
void void /* PRIVATE */
png_process_IDAT_data(png_structp png_ptr, png_bytep buffer, png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
png_size_t buffer_length) png_size_t buffer_length)
{ {
@@ -714,23 +714,26 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
for(;;) for(;;)
{ {
ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
if (ret == Z_STREAM_END) if (ret != Z_OK)
{ {
if (png_ptr->zstream.avail_in) if (ret == Z_STREAM_END)
png_error(png_ptr, "Extra compressed data");
if (!(png_ptr->zstream.avail_out))
{ {
png_push_process_row(png_ptr); if (png_ptr->zstream.avail_in)
} png_error(png_ptr, "Extra compressed data");
if (!(png_ptr->zstream.avail_out))
{
png_push_process_row(png_ptr);
}
png_ptr->mode |= PNG_AFTER_IDAT; png_ptr->mode |= PNG_AFTER_IDAT;
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
break; break;
}
else if (ret == Z_BUF_ERROR)
break;
else
png_error(png_ptr, "Decompression Error");
} }
else if (ret == Z_BUF_ERROR)
break;
else if (ret != Z_OK)
png_error(png_ptr, "Decompression Error");
if (!(png_ptr->zstream.avail_out)) if (!(png_ptr->zstream.avail_out))
{ {
png_push_process_row(png_ptr); png_push_process_row(png_ptr);
@@ -742,7 +745,7 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
} }
} }
void void /* PRIVATE */
png_push_process_row(png_structp png_ptr) png_push_process_row(png_structp png_ptr)
{ {
png_ptr->row_info.color_type = png_ptr->color_type; png_ptr->row_info.color_type = png_ptr->color_type;
@@ -884,32 +887,32 @@ png_push_process_row(png_structp png_ptr)
} }
} }
void void /* PRIVATE */
png_read_push_finish_row(png_structp png_ptr) png_read_push_finish_row(png_structp png_ptr)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* start of interlace block */ /* start of interlace block */
const int png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
/* offset to next interlace block */ /* offset to next interlace block */
const int png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
/* start of interlace block in the y direction */ /* start of interlace block in the y direction */
const int png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
/* offset to next interlace block in the y direction */ /* offset to next interlace block in the y direction */
const int png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
/* Width of interlace block. This is not currently used - if you need /* Width of interlace block. This is not currently used - if you need
* it, uncomment it here and in png.h * it, uncomment it here and in png.h
const int png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1};
*/ */
/* Height of interlace block. This is not currently used - if you need /* Height of interlace block. This is not currently used - if you need
* it, uncomment it here and in png.h * it, uncomment it here and in png.h
const int png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
*/ */
#endif #endif
@@ -949,7 +952,7 @@ png_read_push_finish_row(png_structp png_ptr)
} }
#if defined(PNG_READ_tEXt_SUPPORTED) #if defined(PNG_READ_tEXt_SUPPORTED)
void void /* PRIVATE */
png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
@@ -979,7 +982,7 @@ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length
png_ptr->process_mode = PNG_READ_tEXt_MODE; png_ptr->process_mode = PNG_READ_tEXt_MODE;
} }
void void /* PRIVATE */
png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr) png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr->buffer_size && png_ptr->current_text_left) if (png_ptr->buffer_size && png_ptr->current_text_left)
@@ -1024,20 +1027,23 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text)); text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
text_ptr->lang = (char *)NULL;
text_ptr->key = key; text_ptr->key = key;
#ifdef PNG_iTXt_SUPPORTED
text_ptr->lang = (char *)NULL;
text_ptr->lang_key = (char *)NULL; text_ptr->lang_key = (char *)NULL;
#endif
text_ptr->text = text; text_ptr->text = text;
png_set_text(png_ptr, info_ptr, text_ptr, 1); png_set_text(png_ptr, info_ptr, text_ptr, 1);
png_free(png_ptr, key);
png_free(png_ptr, text_ptr); png_free(png_ptr, text_ptr);
} }
} }
#endif #endif
#if defined(PNG_READ_zTXt_SUPPORTED) #if defined(PNG_READ_zTXt_SUPPORTED)
void void /* PRIVATE */
png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
@@ -1069,7 +1075,7 @@ png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length
png_ptr->process_mode = PNG_READ_zTXt_MODE; png_ptr->process_mode = PNG_READ_zTXt_MODE;
} }
void void /* PRIVATE */
png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr->buffer_size && png_ptr->current_text_left) if (png_ptr->buffer_size && png_ptr->current_text_left)
@@ -1206,19 +1212,22 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text)); text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt; text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt;
text_ptr->key = key; text_ptr->key = key;
#ifdef PNG_iTXt_SUPPORTED
text_ptr->lang = (char *)NULL; text_ptr->lang = (char *)NULL;
text_ptr->lang_key = (char *)NULL; text_ptr->lang_key = (char *)NULL;
#endif
text_ptr->text = text; text_ptr->text = text;
png_set_text(png_ptr, info_ptr, text_ptr, 1); png_set_text(png_ptr, info_ptr, text_ptr, 1);
png_free(png_ptr, key);
png_free(png_ptr, text_ptr); png_free(png_ptr, text_ptr);
} }
} }
#endif #endif
#if defined(PNG_READ_iTXt_SUPPORTED) #if defined(PNG_READ_iTXt_SUPPORTED)
void void /* PRIVATE */
png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
@@ -1248,7 +1257,7 @@ png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length
png_ptr->process_mode = PNG_READ_iTXt_MODE; png_ptr->process_mode = PNG_READ_iTXt_MODE;
} }
void void /* PRIVATE */
png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr) png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
{ {
@@ -1328,7 +1337,7 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
* chunk. If there isn't a problem with the chunk itself (ie a bad chunk * chunk. If there isn't a problem with the chunk itself (ie a bad chunk
* name or a critical chunk), the chunk is (currently) silently ignored. * name or a critical chunk), the chunk is (currently) silently ignored.
*/ */
void void /* PRIVATE */
png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_uint_32 skip=0; png_uint_32 skip=0;
@@ -1336,12 +1345,14 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 len
if (!(png_ptr->chunk_name[0] & 0x20)) if (!(png_ptr->chunk_name[0] & 0x20))
{ {
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
HANDLE_CHUNK_ALWAYS HANDLE_CHUNK_ALWAYS
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) #if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
&& png_ptr->read_user_chunk_fn == (png_user_chunk_ptr)NULL && png_ptr->read_user_chunk_fn == (png_user_chunk_ptr)NULL
#endif #endif
) )
#endif
png_chunk_error(png_ptr, "unknown critical chunk"); png_chunk_error(png_ptr, "unknown critical chunk");
/* to quiet compiler warnings about unused info_ptr */ /* to quiet compiler warnings about unused info_ptr */
@@ -1391,21 +1402,21 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 len
png_push_crc_skip(png_ptr, skip); png_push_crc_skip(png_ptr, skip);
} }
void void /* PRIVATE */
png_push_have_info(png_structp png_ptr, png_infop info_ptr) png_push_have_info(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr->info_fn != NULL) if (png_ptr->info_fn != NULL)
(*(png_ptr->info_fn))(png_ptr, info_ptr); (*(png_ptr->info_fn))(png_ptr, info_ptr);
} }
void void /* PRIVATE */
png_push_have_end(png_structp png_ptr, png_infop info_ptr) png_push_have_end(png_structp png_ptr, png_infop info_ptr)
{ {
if (png_ptr->end_fn != NULL) if (png_ptr->end_fn != NULL)
(*(png_ptr->end_fn))(png_ptr, info_ptr); (*(png_ptr->end_fn))(png_ptr, info_ptr);
} }
void void /* PRIVATE */
png_push_have_row(png_structp png_ptr, png_bytep row) png_push_have_row(png_structp png_ptr, png_bytep row)
{ {
if (png_ptr->row_fn != NULL) if (png_ptr->row_fn != NULL)
@@ -1413,18 +1424,19 @@ png_push_have_row(png_structp png_ptr, png_bytep row)
(int)png_ptr->pass); (int)png_ptr->pass);
} }
void void PNGAPI
png_progressive_combine_row (png_structp png_ptr, png_progressive_combine_row (png_structp png_ptr,
png_bytep old_row, png_bytep new_row) png_bytep old_row, png_bytep new_row)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
const int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; const int FARDATA png_pass_dsp_mask[7] =
{0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
#endif #endif
if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */ if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */
png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]); png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]);
} }
void void PNGAPI
png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr, png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr,
png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
png_progressive_end_ptr end_fn) png_progressive_end_ptr end_fn)
@@ -1436,7 +1448,7 @@ png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr,
png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer); png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer);
} }
png_voidp png_voidp PNGAPI
png_get_progressive_ptr(png_structp png_ptr) png_get_progressive_ptr(png_structp png_ptr)
{ {
return png_ptr->io_ptr; return png_ptr->io_ptr;

161
pngread.c
View File

@@ -1,11 +1,11 @@
/* pngread.c - read a PNG file /* pngread.c - read a PNG file
* *
* libpng 1.0.6f - April 14, 2000 * libpng 1.0.9beta5 - December 15, 2000
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
* This file contains routines that an application calls directly to * This file contains routines that an application calls directly to
* read a PNG file or stream. * read a PNG file or stream.
@@ -15,7 +15,7 @@
#include "png.h" #include "png.h"
/* Create a PNG structure for reading, and allocate any memory needed. */ /* Create a PNG structure for reading, and allocate any memory needed. */
png_structp png_structp PNGAPI
png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr,
png_error_ptr error_fn, png_error_ptr warn_fn) png_error_ptr error_fn, png_error_ptr warn_fn)
{ {
@@ -26,7 +26,7 @@ png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr,
} }
/* Alternate create PNG structure for reading, and allocate any memory needed. */ /* Alternate create PNG structure for reading, and allocate any memory needed. */
png_structp png_structp PNGAPI
png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
png_malloc_ptr malloc_fn, png_free_ptr free_fn) png_malloc_ptr malloc_fn, png_free_ptr free_fn)
@@ -41,6 +41,8 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
#endif #endif
#endif #endif
int i;
png_debug(1, "in png_create_read_struct\n"); png_debug(1, "in png_create_read_struct\n");
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
if ((png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, if ((png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
@@ -60,6 +62,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
#endif #endif
{ {
png_free(png_ptr, png_ptr->zbuf); png_free(png_ptr, png_ptr->zbuf);
png_ptr->zbuf=NULL;
png_destroy_struct(png_ptr); png_destroy_struct(png_ptr);
return (png_structp)NULL; return (png_structp)NULL;
} }
@@ -74,16 +77,38 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
/* Libpng 0.90 and later are binary incompatible with libpng 0.89, so i=0;
* we must recompile any applications that use any older library version. do
* For versions after libpng 1.0, we will be compatible, so we need
* only check the first digit.
*/
if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
(user_png_ver[0] == '0' && user_png_ver[2] < '9'))
{ {
png_error(png_ptr, if(user_png_ver[i] != png_libpng_ver[i])
"Incompatible libpng version in application and library"); png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
} while (png_libpng_ver[i++]);
if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
{
/* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
* we must recompile any applications that use any older library version.
* For versions after libpng 1.0, we will be compatible, so we need
* only check the first digit.
*/
if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
(user_png_ver[0] == '0' && user_png_ver[2] < '9'))
{
png_error(png_ptr,
"Incompatible libpng version in application and library");
}
/* Libpng 1.0.6 was not binary compatible, due to insertion of the
info_ptr->free_me member. Note to maintainer: this test can be
removed from version 2.0.0 and beyond because the previous test
would have already rejected it. */
if (user_png_ver[4] == '6' && user_png_ver[2] == '0' &&
user_png_ver[0] == '1' && user_png_ver[5] == '\0')
{
png_error(png_ptr,
"Application must be recompiled; version 1.0.6 was incompatible");
}
} }
/* initialize zbuf - compression buffer */ /* initialize zbuf - compression buffer */
@@ -114,14 +139,46 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
/* Initialize PNG structure for reading, and allocate any memory needed. /* Initialize PNG structure for reading, and allocate any memory needed.
This interface is deprecated in favour of the png_create_read_struct(), This interface is deprecated in favour of the png_create_read_struct(),
and it will eventually disappear. */ and it will eventually disappear. */
void #undef png_read_init
void PNGAPI
png_read_init(png_structp png_ptr) png_read_init(png_structp png_ptr)
{
/* We only come here via pre-1.0.7-compiled applications */
png_read_init_2(png_ptr, "1.0.0", 10000, 10000);
}
void PNGAPI
png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver,
png_size_t png_struct_size, png_size_t png_info_size)
{ {
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
jmp_buf tmp_jmp; /* to save current jump buffer */ jmp_buf tmp_jmp; /* to save current jump buffer */
#endif #endif
png_debug(1, "in png_read_init\n"); int i=0;
do
{
if(user_png_ver[i] != png_libpng_ver[i])
{
#ifdef PNG_LEGACY_SUPPORTED
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
#else
png_ptr->error_fn=(png_error_ptr)NULL;
png_error(png_ptr,
"Application uses deprecated png_read_init() and must be recompiled.");
#endif
}
} while (png_libpng_ver[i++]);
if(sizeof(png_struct) > png_struct_size ||
sizeof(png_info) > png_info_size)
{
png_ptr->error_fn=(png_error_ptr)NULL;
png_error(png_ptr,
"Application and library have different sized structs. Please recompile.");
}
png_debug(1, "in png_read_init_2\n");
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
/* save jump buffer and error functions */ /* save jump buffer and error functions */
@@ -167,7 +224,7 @@ png_read_init(png_structp png_ptr)
* here. The application can then have access to the signature bytes we * here. The application can then have access to the signature bytes we
* read if it is determined that this isn't a valid PNG file. * read if it is determined that this isn't a valid PNG file.
*/ */
void void PNGAPI
png_read_info(png_structp png_ptr, png_infop info_ptr) png_read_info(png_structp png_ptr, png_infop info_ptr)
{ {
png_debug(1, "in png_read_info\n"); png_debug(1, "in png_read_info\n");
@@ -259,7 +316,7 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
png_reset_crc(png_ptr); png_reset_crc(png_ptr);
png_crc_read(png_ptr, png_ptr->chunk_name, 4); png_crc_read(png_ptr, png_ptr->chunk_name, 4);
png_debug2(0, "Reading %s chunk, length=%d.\n", png_ptr->chunk_name, png_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name,
length); length);
/* This should be a binary subdivision search or a hash for /* This should be a binary subdivision search or a hash for
@@ -376,13 +433,16 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
} }
/* optional call to update the users info_ptr structure */ /* optional call to update the users info_ptr structure */
void void PNGAPI
png_read_update_info(png_structp png_ptr, png_infop info_ptr) png_read_update_info(png_structp png_ptr, png_infop info_ptr)
{ {
png_debug(1, "in png_read_update_info\n"); png_debug(1, "in png_read_update_info\n");
/* save jump buffer and error functions */ /* save jump buffer and error functions */
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
png_read_start_row(png_ptr); png_read_start_row(png_ptr);
else
png_warning(png_ptr,
"Ignoring extra png_read_update_info() call; row buffer not reallocated");
png_read_transform_info(png_ptr, info_ptr); png_read_transform_info(png_ptr, info_ptr);
} }
@@ -391,7 +451,7 @@ png_read_update_info(png_structp png_ptr, png_infop info_ptr)
* the user to obtain a gamma-corrected palette, for example. * the user to obtain a gamma-corrected palette, for example.
* If the user doesn't call this, we will do it ourselves. * If the user doesn't call this, we will do it ourselves.
*/ */
void void PNGAPI
png_start_read_image(png_structp png_ptr) png_start_read_image(png_structp png_ptr)
{ {
png_debug(1, "in png_start_read_image\n"); png_debug(1, "in png_start_read_image\n");
@@ -400,7 +460,7 @@ png_start_read_image(png_structp png_ptr)
png_read_start_row(png_ptr); png_read_start_row(png_ptr);
} }
void void PNGAPI
png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -409,7 +469,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
const int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; const int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
#endif #endif
int ret; int ret;
png_debug2(1, "in png_read_row (row %d, pass %d)\n", png_debug2(1, "in png_read_row (row %lu, pass %d)\n",
png_ptr->row_number, png_ptr->pass); png_ptr->row_number, png_ptr->pass);
/* save jump buffer and error functions */ /* save jump buffer and error functions */
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
@@ -586,6 +646,15 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf,
png_ptr->rowbytes + 1); png_ptr->rowbytes + 1);
#if defined(PNG_MNG_FEATURES_SUPPORTED)
if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
(png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
{
/* Intrapixel differencing */
png_do_read_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1);
}
#endif
if (png_ptr->transformations) if (png_ptr->transformations)
png_do_read_transformations(png_ptr); png_do_read_transformations(png_ptr);
@@ -641,10 +710,10 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
* not called png_set_interlace_handling(), the display_row buffer will * not called png_set_interlace_handling(), the display_row buffer will
* be ignored, so pass NULL to it. * be ignored, so pass NULL to it.
* *
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6f. * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.9beta5
*/ */
void void PNGAPI
png_read_rows(png_structp png_ptr, png_bytepp row, png_read_rows(png_structp png_ptr, png_bytepp row,
png_bytepp display_row, png_uint_32 num_rows) png_bytepp display_row, png_uint_32 num_rows)
{ {
@@ -690,9 +759,9 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
* only call this function once. If you desire to have an image for * only call this function once. If you desire to have an image for
* each pass of a interlaced image, use png_read_rows() instead. * each pass of a interlaced image, use png_read_rows() instead.
* *
* [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.6f. * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.9beta5
*/ */
void void PNGAPI
png_read_image(png_structp png_ptr, png_bytepp image) png_read_image(png_structp png_ptr, png_bytepp image)
{ {
png_uint_32 i,image_height; png_uint_32 i,image_height;
@@ -730,7 +799,7 @@ png_read_image(png_structp png_ptr, png_bytepp image)
* file, will verify the end is accurate, and will read any comments * file, will verify the end is accurate, and will read any comments
* or time information at the end of the file, if info is not NULL. * or time information at the end of the file, if info is not NULL.
*/ */
void void PNGAPI
png_read_end(png_structp png_ptr, png_infop info_ptr) png_read_end(png_structp png_ptr, png_infop info_ptr)
{ {
png_byte chunk_length[4]; png_byte chunk_length[4];
@@ -912,7 +981,7 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
} }
/* free all memory used by the read */ /* free all memory used by the read */
void void PNGAPI
png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
png_infopp end_info_ptr_ptr) png_infopp end_info_ptr_ptr)
{ {
@@ -978,7 +1047,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
} }
/* free all memory used by the read (old method) */ /* free all memory used by the read (old method) */
void void PNGAPI
png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr) png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr)
{ {
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
@@ -1013,19 +1082,37 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
png_free(png_ptr, png_ptr->gamma_from_1); png_free(png_ptr, png_ptr->gamma_from_1);
png_free(png_ptr, png_ptr->gamma_to_1); png_free(png_ptr, png_ptr->gamma_to_1);
#endif #endif
#ifdef PNG_FREE_ME_SUPPORTED
if (png_ptr->free_me & PNG_FREE_PLTE) if (png_ptr->free_me & PNG_FREE_PLTE)
png_zfree(png_ptr, png_ptr->palette); png_zfree(png_ptr, png_ptr->palette);
png_ptr->free_me &= ~PNG_FREE_PLTE; png_ptr->free_me &= ~PNG_FREE_PLTE;
#else
if (png_ptr->flags & PNG_FLAG_FREE_PLTE)
png_zfree(png_ptr, png_ptr->palette);
png_ptr->flags &= ~PNG_FLAG_FREE_PLTE;
#endif
#if defined(PNG_tRNS_SUPPORTED) || \ #if defined(PNG_tRNS_SUPPORTED) || \
defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
#ifdef PNG_FREE_ME_SUPPORTED
if (png_ptr->free_me & PNG_FREE_TRNS) if (png_ptr->free_me & PNG_FREE_TRNS)
png_free(png_ptr, png_ptr->trans); png_free(png_ptr, png_ptr->trans);
png_ptr->free_me &= ~PNG_FREE_TRNS; png_ptr->free_me &= ~PNG_FREE_TRNS;
#else
if (png_ptr->flags & PNG_FLAG_FREE_TRNS)
png_free(png_ptr, png_ptr->trans);
png_ptr->flags &= ~PNG_FLAG_FREE_TRNS;
#endif
#endif #endif
#if defined(PNG_READ_hIST_SUPPORTED) #if defined(PNG_READ_hIST_SUPPORTED)
#ifdef PNG_FREE_ME_SUPPORTED
if (png_ptr->free_me & PNG_FREE_HIST) if (png_ptr->free_me & PNG_FREE_HIST)
png_free(png_ptr, png_ptr->hist); png_free(png_ptr, png_ptr->hist);
png_ptr->free_me &= ~PNG_FREE_HIST; png_ptr->free_me &= ~PNG_FREE_HIST;
#else
if (png_ptr->flags & PNG_FLAG_FREE_HIST)
png_free(png_ptr, png_ptr->hist);
png_ptr->flags &= ~PNG_FLAG_FREE_HIST;
#endif
#endif #endif
#if defined(PNG_READ_GAMMA_SUPPORTED) #if defined(PNG_READ_GAMMA_SUPPORTED)
if (png_ptr->gamma_16_table != NULL) if (png_ptr->gamma_16_table != NULL)
@@ -1099,14 +1186,15 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
} }
void void PNGAPI
png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn) png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn)
{ {
png_ptr->read_row_fn = read_row_fn; png_ptr->read_row_fn = read_row_fn;
} }
#if defined(PNG_INFO_IMAGE_SUPPORTED) #if defined(PNG_INFO_IMAGE_SUPPORTED)
void png_read_png(png_structp png_ptr, png_infop info_ptr, void PNGAPI
png_read_png(png_structp png_ptr, png_infop info_ptr,
int transforms, int transforms,
voidp params) voidp params)
{ {
@@ -1218,15 +1306,20 @@ void png_read_png(png_structp png_ptr, png_infop info_ptr,
/* -------------- image transformations end here ------------------- */ /* -------------- image transformations end here ------------------- */
#ifdef PNG_FREE_ME_SUPPORTED
png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
#endif
if(info_ptr->row_pointers == NULL) if(info_ptr->row_pointers == NULL)
{ {
info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr, info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
info_ptr->height * sizeof(png_bytep)); info_ptr->height * sizeof(png_bytep));
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_ROWS; info_ptr->free_me |= PNG_FREE_ROWS;
#endif
for (row = 0; row < (int)info_ptr->height; row++)
info_ptr->row_pointers[row] = png_malloc(png_ptr,
png_get_rowbytes(png_ptr, info_ptr));
} }
for (row = 0; row < (int)info_ptr->height; row++)
info_ptr->row_pointers[row] = png_malloc(png_ptr,
png_get_rowbytes(png_ptr, info_ptr));
png_read_image(png_ptr, info_ptr->row_pointers); png_read_image(png_ptr, info_ptr->row_pointers);
info_ptr->valid |= PNG_INFO_IDAT; info_ptr->valid |= PNG_INFO_IDAT;

View File

@@ -1,11 +1,11 @@
/* pngrio.c - functions for data input /* pngrio.c - functions for data input
* *
* libpng 1.0.6f - April 14, 2000 * libpng 1.0.9beta5 - December 15, 2000
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
* This file provides a location for all input. Users who need * This file provides a location for all input. Users who need
* special handling are expected to write a function that has the same * special handling are expected to write a function that has the same
@@ -23,7 +23,7 @@
with very small lengths, so you should implement some kind of simple with very small lengths, so you should implement some kind of simple
buffering if you are using unbuffered reads. This should never be asked buffering if you are using unbuffered reads. This should never be asked
to read more then 64K on a 16 bit machine. */ to read more then 64K on a 16 bit machine. */
void void /* PRIVATE */
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
png_debug1(4,"reading %d bytes\n", length); png_debug1(4,"reading %d bytes\n", length);
@@ -39,7 +39,7 @@ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
read_data function and use it at run time with png_set_read_fn(), rather read_data function and use it at run time with png_set_read_fn(), rather
than changing the library. */ than changing the library. */
#ifndef USE_FAR_KEYWORD #ifndef USE_FAR_KEYWORD
static void static void /* PRIVATE */
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
png_size_t check; png_size_t check;
@@ -47,13 +47,16 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
/* fread() returns 0 on error, so it is OK to store this in a png_size_t /* fread() returns 0 on error, so it is OK to store this in a png_size_t
* instead of an int, which is what fread() actually returns. * instead of an int, which is what fread() actually returns.
*/ */
#if defined(_WIN32_WCE)
if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
check = 0;
#else
check = (png_size_t)fread(data, (png_size_t)1, length, check = (png_size_t)fread(data, (png_size_t)1, length,
(FILE *)png_ptr->io_ptr); (png_FILE_p)png_ptr->io_ptr);
#endif
if (check != length) if (check != length)
{
png_error(png_ptr, "Read Error"); png_error(png_ptr, "Read Error");
}
} }
#else #else
/* this is the model-independent version. Since the standard I/O library /* this is the model-independent version. Since the standard I/O library
@@ -64,19 +67,24 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
#define NEAR_BUF_SIZE 1024 #define NEAR_BUF_SIZE 1024
#define MIN(a,b) (a <= b ? a : b) #define MIN(a,b) (a <= b ? a : b)
static void static void /* PRIVATE */
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
int check; int check;
png_byte *n_data; png_byte *n_data;
FILE *io_ptr; png_FILE_p io_ptr;
/* Check if data really is near. If so, use usual code. */ /* Check if data really is near. If so, use usual code. */
n_data = (png_byte *)CVT_PTR_NOCHECK(data); n_data = (png_byte *)CVT_PTR_NOCHECK(data);
io_ptr = (FILE *)CVT_PTR(png_ptr->io_ptr); io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
if ((png_bytep)n_data == data) if ((png_bytep)n_data == data)
{ {
#if defined(_WIN32_WCE)
if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
check = 0;
#else
check = fread(n_data, 1, length, io_ptr); check = fread(n_data, 1, length, io_ptr);
#endif
} }
else else
{ {
@@ -87,7 +95,12 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
do do
{ {
read = MIN(NEAR_BUF_SIZE, remaining); read = MIN(NEAR_BUF_SIZE, remaining);
#if defined(_WIN32_WCE)
if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) )
err = 0;
#else
err = fread(buf, (png_size_t)1, read, io_ptr); err = fread(buf, (png_size_t)1, read, io_ptr);
#endif
png_memcpy(data, buf, read); /* copy far buffer to near buffer */ png_memcpy(data, buf, read); /* copy far buffer to near buffer */
if(err != read) if(err != read)
break; break;
@@ -99,9 +112,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
while (remaining != 0); while (remaining != 0);
} }
if ((png_uint_32)check != (png_uint_32)length) if ((png_uint_32)check != (png_uint_32)length)
{
png_error(png_ptr, "read Error"); png_error(png_ptr, "read Error");
}
} }
#endif #endif
#endif #endif
@@ -119,7 +130,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
unsigned int that is the number of bytes to be read. unsigned int that is the number of bytes to be read.
To exit and output any fatal error messages the new write To exit and output any fatal error messages the new write
function should call png_error(png_ptr, "Error msg"). */ function should call png_error(png_ptr, "Error msg"). */
void void PNGAPI
png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
png_rw_ptr read_data_fn) png_rw_ptr read_data_fn)
{ {

View File

@@ -1,11 +1,11 @@
/* pngrtran.c - transforms the data in a row for PNG readers /* pngrtran.c - transforms the data in a row for PNG readers
* *
* libpng 1.0.6f - April 14, 2000 * libpng 1.0.9beta5 - December 15, 2000
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
* This file contains functions optionally called by an application * This file contains functions optionally called by an application
* in order to tell libpng how to handle data when reading a PNG. * in order to tell libpng how to handle data when reading a PNG.
@@ -17,7 +17,7 @@
#include "png.h" #include "png.h"
/* Set the action on getting a CRC error for an ancillary or critical chunk. */ /* Set the action on getting a CRC error for an ancillary or critical chunk. */
void void PNGAPI
png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action) png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
{ {
png_debug(1, "in png_set_crc_action\n"); png_debug(1, "in png_set_crc_action\n");
@@ -72,7 +72,7 @@ png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ #if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
defined(PNG_FLOATING_POINT_SUPPORTED) defined(PNG_FLOATING_POINT_SUPPORTED)
/* handle alpha and tRNS via a background color */ /* handle alpha and tRNS via a background color */
void void PNGAPI
png_set_background(png_structp png_ptr, png_set_background(png_structp png_ptr,
png_color_16p background_color, int background_gamma_code, png_color_16p background_color, int background_gamma_code,
int need_expand, double background_gamma) int need_expand, double background_gamma)
@@ -105,7 +105,7 @@ png_set_background(png_structp png_ptr,
#if defined(PNG_READ_16_TO_8_SUPPORTED) #if defined(PNG_READ_16_TO_8_SUPPORTED)
/* strip 16 bit depth files to 8 bit depth */ /* strip 16 bit depth files to 8 bit depth */
void void PNGAPI
png_set_strip_16(png_structp png_ptr) png_set_strip_16(png_structp png_ptr)
{ {
png_debug(1, "in png_set_strip_16\n"); png_debug(1, "in png_set_strip_16\n");
@@ -114,7 +114,7 @@ png_set_strip_16(png_structp png_ptr)
#endif #endif
#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) #if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
void void PNGAPI
png_set_strip_alpha(png_structp png_ptr) png_set_strip_alpha(png_structp png_ptr)
{ {
png_debug(1, "in png_set_strip_alpha\n"); png_debug(1, "in png_set_strip_alpha\n");
@@ -141,7 +141,7 @@ typedef struct png_dsort_struct
typedef png_dsort FAR * png_dsortp; typedef png_dsort FAR * png_dsortp;
typedef png_dsort FAR * FAR * png_dsortpp; typedef png_dsort FAR * FAR * png_dsortpp;
void void PNGAPI
png_set_dither(png_structp png_ptr, png_colorp palette, png_set_dither(png_structp png_ptr, png_colorp palette,
int num_palette, int maximum_colors, png_uint_16p histogram, int num_palette, int maximum_colors, png_uint_16p histogram,
int full_dither) int full_dither)
@@ -511,7 +511,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
* are not close reciprocals, otherwise it slows things down slightly, and * are not close reciprocals, otherwise it slows things down slightly, and
* also needlessly introduces small errors. * also needlessly introduces small errors.
*/ */
void void PNGAPI
png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma) png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
{ {
png_debug(1, "in png_set_gamma\n"); png_debug(1, "in png_set_gamma\n");
@@ -527,7 +527,7 @@ png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
* less than 8-bit depth to 8-bit depth, and expand tRNS chunks * less than 8-bit depth to 8-bit depth, and expand tRNS chunks
* to alpha channels. * to alpha channels.
*/ */
void void PNGAPI
png_set_expand(png_structp png_ptr) png_set_expand(png_structp png_ptr)
{ {
png_debug(1, "in png_set_expand\n"); png_debug(1, "in png_set_expand\n");
@@ -549,7 +549,7 @@ png_set_expand(png_structp png_ptr)
*/ */
/* Expand paletted images to RGB. */ /* Expand paletted images to RGB. */
void void PNGAPI
png_set_palette_to_rgb(png_structp png_ptr) png_set_palette_to_rgb(png_structp png_ptr)
{ {
png_debug(1, "in png_set_expand\n"); png_debug(1, "in png_set_expand\n");
@@ -557,7 +557,7 @@ png_set_palette_to_rgb(png_structp png_ptr)
} }
/* Expand grayscale images of less than 8-bit depth to 8 bits. */ /* Expand grayscale images of less than 8-bit depth to 8 bits. */
void void PNGAPI
png_set_gray_1_2_4_to_8(png_structp png_ptr) png_set_gray_1_2_4_to_8(png_structp png_ptr)
{ {
png_debug(1, "in png_set_expand\n"); png_debug(1, "in png_set_expand\n");
@@ -565,7 +565,7 @@ png_set_gray_1_2_4_to_8(png_structp png_ptr)
} }
/* Expand tRNS chunks to alpha channels. */ /* Expand tRNS chunks to alpha channels. */
void void PNGAPI
png_set_tRNS_to_alpha(png_structp png_ptr) png_set_tRNS_to_alpha(png_structp png_ptr)
{ {
png_debug(1, "in png_set_expand\n"); png_debug(1, "in png_set_expand\n");
@@ -574,7 +574,7 @@ png_set_tRNS_to_alpha(png_structp png_ptr)
#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */ #endif /* defined(PNG_READ_EXPAND_SUPPORTED) */
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
void void PNGAPI
png_set_gray_to_rgb(png_structp png_ptr) png_set_gray_to_rgb(png_structp png_ptr)
{ {
png_debug(1, "in png_set_gray_to_rgb\n"); png_debug(1, "in png_set_gray_to_rgb\n");
@@ -588,7 +588,7 @@ png_set_gray_to_rgb(png_structp png_ptr)
* for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image. * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image.
*/ */
void void PNGAPI
png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red, png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red,
double green) double green)
{ {
@@ -598,7 +598,7 @@ png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red,
} }
#endif #endif
void void PNGAPI
png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action, png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
png_fixed_point red, png_fixed_point green) png_fixed_point red, png_fixed_point green)
{ {
@@ -645,21 +645,30 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
} }
#endif #endif
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
void defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_LEGACY_SUPPORTED)
void PNGAPI
png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
read_user_transform_fn) read_user_transform_fn)
{ {
png_debug(1, "in png_set_read_user_transform_fn\n"); png_debug(1, "in png_set_read_user_transform_fn\n");
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
png_ptr->transformations |= PNG_USER_TRANSFORM; png_ptr->transformations |= PNG_USER_TRANSFORM;
png_ptr->read_user_transform_fn = read_user_transform_fn; png_ptr->read_user_transform_fn = read_user_transform_fn;
#endif
#ifdef PNG_LEGACY_SUPPORTED
if(read_user_transform_fn)
png_warning(png_ptr,
"This version of libpng does not support user transforms");
#endif
} }
#endif #endif
/* Initialize everything needed for the read. This includes modifying /* Initialize everything needed for the read. This includes modifying
* the palette. * the palette.
*/ */
void void /* PRIVATE */
png_init_read_transformations(png_structp png_ptr) png_init_read_transformations(png_structp png_ptr)
{ {
png_debug(1, "in png_init_read_transformations\n"); png_debug(1, "in png_init_read_transformations\n");
@@ -970,13 +979,18 @@ png_init_read_transformations(png_structp png_ptr)
} }
#endif #endif
} }
#if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \
&& !defined(PNG_READ_BACKGROUND_SUPPORTED)
if(png_ptr)
return;
#endif
} }
/* Modify the info structure to reflect the transformations. The /* Modify the info structure to reflect the transformations. The
* info should be updated so a PNG file could be written with it, * info should be updated so a PNG file could be written with it,
* assuming the transformations result in valid PNG data. * assuming the transformations result in valid PNG data.
*/ */
void void /* PRIVATE */
png_read_transform_info(png_structp png_ptr, png_infop info_ptr) png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
{ {
png_debug(1, "in png_read_transform_info\n"); png_debug(1, "in png_read_transform_info\n");
@@ -1076,10 +1090,16 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
if ((png_ptr->transformations & PNG_FILLER) && if ((png_ptr->transformations & PNG_FILLER) &&
((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || ((info_ptr->color_type == PNG_COLOR_TYPE_RGB) ||
(info_ptr->color_type == PNG_COLOR_TYPE_GRAY))) (info_ptr->color_type == PNG_COLOR_TYPE_GRAY)))
{
info_ptr->channels++; info_ptr->channels++;
#if 0 /* if adding a true alpha channel not just filler */
info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
#endif
}
#endif #endif
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \
defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
if(png_ptr->transformations & PNG_USER_TRANSFORM) if(png_ptr->transformations & PNG_USER_TRANSFORM)
{ {
if(info_ptr->bit_depth < png_ptr->user_transform_depth) if(info_ptr->bit_depth < png_ptr->user_transform_depth)
@@ -1093,20 +1113,24 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
info_ptr->bit_depth); info_ptr->bit_depth);
info_ptr->rowbytes = ((info_ptr->width * info_ptr->pixel_depth + 7) >> 3); info_ptr->rowbytes = ((info_ptr->width * info_ptr->pixel_depth + 7) >> 3);
#if !defined(PNG_READ_EXPAND_SUPPORTED)
if(png_ptr)
return;
#endif
} }
/* Transform the row. The order of transformations is significant, /* Transform the row. The order of transformations is significant,
* and is very touchy. If you add a transformation, take care to * and is very touchy. If you add a transformation, take care to
* decide how it fits in with the other transformations here. * decide how it fits in with the other transformations here.
*/ */
void void /* PRIVATE */
png_do_read_transformations(png_structp png_ptr) png_do_read_transformations(png_structp png_ptr)
{ {
png_debug(1, "in png_do_read_transformations\n"); png_debug(1, "in png_do_read_transformations\n");
#if !defined(PNG_USELESS_TESTS_SUPPORTED) #if !defined(PNG_USELESS_TESTS_SUPPORTED)
if (png_ptr->row_buf == NULL) if (png_ptr->row_buf == NULL)
{ {
#if !defined(PNG_NO_STDIO) #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
char msg[50]; char msg[50];
sprintf(msg, "NULL row buffer for row %ld, pass %d", png_ptr->row_number, sprintf(msg, "NULL row buffer for row %ld, pass %d", png_ptr->row_number,
@@ -1307,10 +1331,12 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
/* png_byte channels; number of channels (1-4) */ /* png_byte channels; number of channels (1-4) */
/* png_byte pixel_depth; bits per pixel (depth*channels) */ /* png_byte pixel_depth; bits per pixel (depth*channels) */
png_ptr->row_buf + 1); /* start of pixel data for row */ png_ptr->row_buf + 1); /* start of pixel data for row */
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
if(png_ptr->user_transform_depth) if(png_ptr->user_transform_depth)
png_ptr->row_info.bit_depth = png_ptr->user_transform_depth; png_ptr->row_info.bit_depth = png_ptr->user_transform_depth;
if(png_ptr->user_transform_channels) if(png_ptr->user_transform_channels)
png_ptr->row_info.channels = png_ptr->user_transform_channels; png_ptr->row_info.channels = png_ptr->user_transform_channels;
#endif
png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth * png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth *
png_ptr->row_info.channels); png_ptr->row_info.channels);
png_ptr->row_info.rowbytes = (png_ptr->row_info.width * png_ptr->row_info.rowbytes = (png_ptr->row_info.width *
@@ -1327,7 +1353,7 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
* the numbers 0 or 1. If you would rather they contain 0 and 255, use * the numbers 0 or 1. If you would rather they contain 0 and 255, use
* png_do_shift() after this. * png_do_shift() after this.
*/ */
void void /* PRIVATE */
png_do_unpack(png_row_infop row_info, png_bytep row) png_do_unpack(png_row_infop row_info, png_bytep row)
{ {
png_debug(1, "in png_do_unpack\n"); png_debug(1, "in png_do_unpack\n");
@@ -1417,7 +1443,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
* a row of bit depth 8, but only 5 are significant, this will shift * a row of bit depth 8, but only 5 are significant, this will shift
* the values back to 0 through 31. * the values back to 0 through 31.
*/ */
void void /* PRIVATE */
png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits) png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
{ {
png_debug(1, "in png_do_unshift\n"); png_debug(1, "in png_do_unshift\n");
@@ -1523,7 +1549,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
#if defined(PNG_READ_16_TO_8_SUPPORTED) #if defined(PNG_READ_16_TO_8_SUPPORTED)
/* chop rows of bit depth 16 down to 8 */ /* chop rows of bit depth 16 down to 8 */
void void /* PRIVATE */
png_do_chop(png_row_infop row_info, png_bytep row) png_do_chop(png_row_infop row_info, png_bytep row)
{ {
png_debug(1, "in png_do_chop\n"); png_debug(1, "in png_do_chop\n");
@@ -1577,7 +1603,7 @@ png_do_chop(png_row_infop row_info, png_bytep row)
#endif #endif
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
void void /* PRIVATE */
png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
{ {
png_debug(1, "in png_do_read_swap_alpha\n"); png_debug(1, "in png_do_read_swap_alpha\n");
@@ -1669,7 +1695,7 @@ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
#endif #endif
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
void void /* PRIVATE */
png_do_read_invert_alpha(png_row_infop row_info, png_bytep row) png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
{ {
png_debug(1, "in png_do_read_invert_alpha\n"); png_debug(1, "in png_do_read_invert_alpha\n");
@@ -1768,7 +1794,7 @@ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
#if defined(PNG_READ_FILLER_SUPPORTED) #if defined(PNG_READ_FILLER_SUPPORTED)
/* Add filler channel if we have RGB color */ /* Add filler channel if we have RGB color */
void void /* PRIVATE */
png_do_read_filler(png_row_infop row_info, png_bytep row, png_do_read_filler(png_row_infop row_info, png_bytep row,
png_uint_32 filler, png_uint_32 flags) png_uint_32 filler, png_uint_32 flags)
{ {
@@ -1944,7 +1970,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
/* expand grayscale files to RGB, with or without alpha */ /* expand grayscale files to RGB, with or without alpha */
void void /* PRIVATE */
png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
{ {
png_uint_32 i; png_uint_32 i;
@@ -2046,7 +2072,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
* *
* Other integer coefficents can be used via png_set_rgb_to_gray(). * Other integer coefficents can be used via png_set_rgb_to_gray().
*/ */
int int /* PRIVATE */
png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
{ {
@@ -2286,7 +2312,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
* paletted. Most useful for gamma correction and simplification * paletted. Most useful for gamma correction and simplification
* of code. * of code.
*/ */
void void /* PRIVATE */
png_build_grayscale_palette(int bit_depth, png_colorp palette) png_build_grayscale_palette(int bit_depth, png_colorp palette)
{ {
int num_palette; int num_palette;
@@ -2332,7 +2358,7 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette)
/* This function is currently unused. Do we really need it? */ /* This function is currently unused. Do we really need it? */
#if defined(PNG_READ_DITHER_SUPPORTED) && defined(PNG_CORRECT_PALETTE_SUPPORTED) #if defined(PNG_READ_DITHER_SUPPORTED) && defined(PNG_CORRECT_PALETTE_SUPPORTED)
void void /* PRIVATE */
png_correct_palette(png_structp png_ptr, png_colorp palette, png_correct_palette(png_structp png_ptr, png_colorp palette,
int num_palette) int num_palette)
{ {
@@ -2517,7 +2543,7 @@ png_correct_palette(png_structp png_ptr, png_colorp palette,
* "background" is already in the screen gamma, while "background_1" is * "background" is already in the screen gamma, while "background_1" is
* at a gamma of 1.0. Paletted files have already been taken care of. * at a gamma of 1.0. Paletted files have already been taken care of.
*/ */
void void /* PRIVATE */
png_do_background(png_row_infop row_info, png_bytep row, png_do_background(png_row_infop row_info, png_bytep row,
png_color_16p trans_values, png_color_16p background, png_color_16p trans_values, png_color_16p background,
png_color_16p background_1, png_color_16p background_1,
@@ -3188,7 +3214,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
* is 16, use gamma_16_table and gamma_shift. Build these with * is 16, use gamma_16_table and gamma_shift. Build these with
* build_gamma_table(). * build_gamma_table().
*/ */
void void /* PRIVATE */
png_do_gamma(png_row_infop row_info, png_bytep row, png_do_gamma(png_row_infop row_info, png_bytep row,
png_bytep gamma_table, png_uint_16pp gamma_16_table, png_bytep gamma_table, png_uint_16pp gamma_16_table,
int gamma_shift) int gamma_shift)
@@ -3370,7 +3396,7 @@ png_do_gamma(png_row_infop row_info, png_bytep row,
/* Expands a palette row to an RGB or RGBA row depending /* Expands a palette row to an RGB or RGBA row depending
* upon whether you supply trans and num_trans. * upon whether you supply trans and num_trans.
*/ */
void void /* PRIVATE */
png_do_expand_palette(png_row_infop row_info, png_bytep row, png_do_expand_palette(png_row_infop row_info, png_bytep row,
png_colorp palette, png_bytep trans, int num_trans) png_colorp palette, png_bytep trans, int num_trans)
{ {
@@ -3513,7 +3539,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
/* If the bit depth < 8, it is expanded to 8. Also, if the /* If the bit depth < 8, it is expanded to 8. Also, if the
* transparency value is supplied, an alpha channel is built. * transparency value is supplied, an alpha channel is built.
*/ */
void void /* PRIVATE */
png_do_expand(png_row_infop row_info, png_bytep row, png_do_expand(png_row_infop row_info, png_bytep row,
png_color_16p trans_value) png_color_16p trans_value)
{ {
@@ -3712,7 +3738,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
#endif #endif
#if defined(PNG_READ_DITHER_SUPPORTED) #if defined(PNG_READ_DITHER_SUPPORTED)
void void /* PRIVATE */
png_do_dither(png_row_infop row_info, png_bytep row, png_do_dither(png_row_infop row_info, png_bytep row,
png_bytep palette_lookup, png_bytep dither_lookup) png_bytep palette_lookup, png_bytep dither_lookup)
{ {
@@ -3814,7 +3840,7 @@ static int png_gamma_shift[] =
* the future. Note also how the gamma_16 tables are segmented so that * the future. Note also how the gamma_16 tables are segmented so that
* we don't need to allocate > 64K chunks for a full 16-bit table. * we don't need to allocate > 64K chunks for a full 16-bit table.
*/ */
void void /* PRIVATE */
png_build_gamma_table(png_structp png_ptr) png_build_gamma_table(png_structp png_ptr)
{ {
png_debug(1, "in png_build_gamma_table\n"); png_debug(1, "in png_build_gamma_table\n");
@@ -4027,3 +4053,63 @@ png_build_gamma_table(png_structp png_ptr)
/* To do: install integer version of png_build_gamma_table here */ /* To do: install integer version of png_build_gamma_table here */
#endif #endif
#if defined(PNG_MNG_FEATURES_SUPPORTED)
/* undoes intrapixel differencing */
void /* PRIVATE */
png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_read_intrapixel\n");
if (
#if defined(PNG_USELESS_TESTS_SUPPORTED)
row != NULL && row_info != NULL &&
#endif
(row_info->color_type & PNG_COLOR_MASK_COLOR))
{
int bytes_per_pixel;
png_uint_32 row_width = row_info->width;
if (row_info->bit_depth == 8)
{
png_bytep rp;
png_uint_32 i;
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
bytes_per_pixel = 3;
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
bytes_per_pixel = 4;
else
return;
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
{
*(rp) = (png_byte)((256 + *rp + *(rp+1))&0xff);
*(rp+2) = (png_byte)((256 + *(rp+2) + *(rp+1))&0xff);
}
}
else if (row_info->bit_depth == 16)
{
png_bytep rp;
png_uint_32 i;
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
bytes_per_pixel = 6;
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
bytes_per_pixel = 8;
else
return;
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
{
png_uint_32 s0=*(rp )<<8 | *(rp+1);
png_uint_32 s1=*(rp+2)<<8 | *(rp+3);
png_uint_32 s2=*(rp+4)<<8 | *(rp+5);
png_uint_32 red=(65536+s0+s1)&0xffff;
png_uint_32 blue=(65536+s2+s1)&0xffff;
*(rp ) = (png_byte)((red>>8)&0xff);
*(rp+1) = (png_byte)(red&0xff);
*(rp+4) = (png_byte)((blue>>8)&0xff);
*(rp+5) = (png_byte)(blue&0xff);
}
}
}
}
#endif /* PNG_MNG_FEATURES_SUPPORTED */

View File

@@ -1,11 +1,11 @@
/* pngrutil.c - utilities to read a PNG file /* pngrutil.c - utilities to read a PNG file
* *
* libpng 1.0.6f - April 14, 2000 * libpng 1.0.9beta5 - December 15, 2000
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
* This file contains routines that are only called from within * This file contains routines that are only called from within
* libpng itself during the course of reading an image. * libpng itself during the course of reading an image.
@@ -14,9 +14,33 @@
#define PNG_INTERNAL #define PNG_INTERNAL
#include "png.h" #include "png.h"
#if defined(_WIN32_WCE)
/* strtod() function is not supported on WindowsCE */
# ifdef PNG_FLOATING_POINT_SUPPORTED
__inline double strtod(const char *nptr, char **endptr)
{
double result = 0;
int len;
wchar_t *str, *end;
len = MultiByteToWideChar(CP_ACP, 0, nptr, -1, NULL, 0);
str = (wchar_t *)malloc(len * sizeof(wchar_t));
if ( NULL != str )
{
MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len);
result = wcstod(str, &end);
len = WideCharToMultiByte(CP_ACP, 0, end, -1, NULL, 0, NULL, NULL);
*endptr = (char *)nptr + (strlen(nptr) - len + 1);
free(str);
}
return result;
}
# endif
#endif
#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED #ifndef PNG_READ_BIG_ENDIAN_SUPPORTED
/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */ /* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
png_uint_32 png_uint_32 /* PRIVATE */
png_get_uint_32(png_bytep buf) png_get_uint_32(png_bytep buf)
{ {
png_uint_32 i = ((png_uint_32)(*buf) << 24) + png_uint_32 i = ((png_uint_32)(*buf) << 24) +
@@ -31,7 +55,7 @@ png_get_uint_32(png_bytep buf)
/* Grab a signed 32-bit integer from a buffer in big-endian format. The /* Grab a signed 32-bit integer from a buffer in big-endian format. The
* data is stored in the PNG file in two's complement format, and it is * data is stored in the PNG file in two's complement format, and it is
* assumed that the machine format for signed integers is the same. */ * assumed that the machine format for signed integers is the same. */
png_int_32 png_int_32 /* PRIVATE */
png_get_int_32(png_bytep buf) png_get_int_32(png_bytep buf)
{ {
png_int_32 i = ((png_int_32)(*buf) << 24) + png_int_32 i = ((png_int_32)(*buf) << 24) +
@@ -44,7 +68,7 @@ png_get_int_32(png_bytep buf)
#endif /* PNG_READ_pCAL_SUPPORTED */ #endif /* PNG_READ_pCAL_SUPPORTED */
/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */ /* Grab an unsigned 16-bit integer from a buffer in big-endian format. */
png_uint_16 png_uint_16 /* PRIVATE */
png_get_uint_16(png_bytep buf) png_get_uint_16(png_bytep buf)
{ {
png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) + png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) +
@@ -55,7 +79,7 @@ png_get_uint_16(png_bytep buf)
#endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */ #endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */
/* Read data, and (optionally) run it through the CRC. */ /* Read data, and (optionally) run it through the CRC. */
void void /* PRIVATE */
png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length) png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length)
{ {
png_read_data(png_ptr, buf, length); png_read_data(png_ptr, buf, length);
@@ -66,7 +90,7 @@ png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length)
are reading a ancillary or critical chunk, and how the program has set are reading a ancillary or critical chunk, and how the program has set
things up, we may calculate the CRC on the data and print a message. things up, we may calculate the CRC on the data and print a message.
Returns '1' if there was a CRC error, '0' otherwise. */ Returns '1' if there was a CRC error, '0' otherwise. */
int int /* PRIVATE */
png_crc_finish(png_structp png_ptr, png_uint_32 skip) png_crc_finish(png_structp png_ptr, png_uint_32 skip)
{ {
png_size_t i; png_size_t i;
@@ -102,7 +126,7 @@ png_crc_finish(png_structp png_ptr, png_uint_32 skip)
/* Compare the CRC stored in the PNG file with that calculated by libpng from /* Compare the CRC stored in the PNG file with that calculated by libpng from
the data it has read thus far. */ the data it has read thus far. */
int int /* PRIVATE */
png_crc_error(png_structp png_ptr) png_crc_error(png_structp png_ptr)
{ {
png_byte crc_bytes[4]; png_byte crc_bytes[4];
@@ -141,7 +165,8 @@ png_crc_error(png_structp png_ptr)
* holding the original prefix part and an uncompressed version of the * holding the original prefix part and an uncompressed version of the
* trailing part (the malloc area passed in is freed). * trailing part (the malloc area passed in is freed).
*/ */
png_charp png_decompress_chunk(png_structp png_ptr, int comp_type, png_charp /* PRIVATE */
png_decompress_chunk(png_structp png_ptr, int comp_type,
png_charp chunkdata, png_size_t chunklength, png_charp chunkdata, png_size_t chunklength,
png_size_t prefix_size, png_size_t *newlength) png_size_t prefix_size, png_size_t *newlength)
{ {
@@ -151,6 +176,7 @@ png_charp png_decompress_chunk(png_structp png_ptr, int comp_type,
if (comp_type == PNG_TEXT_COMPRESSION_zTXt) if (comp_type == PNG_TEXT_COMPRESSION_zTXt)
{ {
int ret = Z_OK;
png_ptr->zstream.next_in = (png_bytep)(chunkdata + prefix_size); png_ptr->zstream.next_in = (png_bytep)(chunkdata + prefix_size);
png_ptr->zstream.avail_in = (uInt)(chunklength - prefix_size); png_ptr->zstream.avail_in = (uInt)(chunklength - prefix_size);
png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.next_out = png_ptr->zbuf;
@@ -161,7 +187,7 @@ png_charp png_decompress_chunk(png_structp png_ptr, int comp_type,
while (png_ptr->zstream.avail_in) while (png_ptr->zstream.avail_in)
{ {
int ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
if (ret != Z_OK && ret != Z_STREAM_END) if (ret != Z_OK && ret != Z_STREAM_END)
{ {
if (png_ptr->zstream.msg != NULL) if (png_ptr->zstream.msg != NULL)
@@ -221,6 +247,26 @@ png_charp png_decompress_chunk(png_structp png_ptr, int comp_type,
} }
} }
} }
if (ret != Z_STREAM_END)
{
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
char umsg[50];
if (ret == Z_BUF_ERROR)
sprintf(umsg,"Buffer error in compressed datastream in %s chunk",
png_ptr->chunk_name);
else if (ret == Z_DATA_ERROR)
sprintf(umsg,"Data error in compressed datastream in %s chunk",
png_ptr->chunk_name);
else
sprintf(umsg,"Incomplete compressed datastream in %s chunk",
png_ptr->chunk_name);
png_warning(png_ptr, umsg);
#else
png_warning(png_ptr,
"Incomplete compressed datastream in chunk other than IDAT");
#endif
}
inflateReset(&png_ptr->zstream); inflateReset(&png_ptr->zstream);
png_ptr->zstream.avail_in = 0; png_ptr->zstream.avail_in = 0;
@@ -229,9 +275,9 @@ png_charp png_decompress_chunk(png_structp png_ptr, int comp_type,
chunkdata = text; chunkdata = text;
*newlength=text_size; *newlength=text_size;
} }
else /* if (comp_type >= PNG_TEXT_COMPRESSION_LAST) */ else /* if (comp_type != PNG_TEXT_COMPRESSION_zTXt) */
{ {
#if !defined(PNG_NO_STDIO) #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
char umsg[50]; char umsg[50];
sprintf(umsg, "Unknown zTXt compression type %d", comp_type); sprintf(umsg, "Unknown zTXt compression type %d", comp_type);
@@ -251,7 +297,7 @@ png_charp png_decompress_chunk(png_structp png_ptr, int comp_type,
#endif #endif
/* read and check the IDHR chunk */ /* read and check the IDHR chunk */
void void /* PRIVATE */
png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_byte buf[13]; png_byte buf[13];
@@ -307,7 +353,14 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (compression_type != PNG_COMPRESSION_TYPE_BASE) if (compression_type != PNG_COMPRESSION_TYPE_BASE)
png_error(png_ptr, "Unknown compression method in IHDR"); png_error(png_ptr, "Unknown compression method in IHDR");
if (filter_type != PNG_FILTER_TYPE_BASE) if(
#if defined(PNG_MNG_FEATURES_SUPPORTED)
!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
(filter_type == PNG_INTRAPIXEL_DIFFERENCING) &&
(color_type == PNG_COLOR_TYPE_RGB ||
color_type == PNG_COLOR_TYPE_RGB_ALPHA)) &&
#endif
filter_type != PNG_FILTER_TYPE_BASE)
png_error(png_ptr, "Unknown filter method in IHDR"); png_error(png_ptr, "Unknown filter method in IHDR");
/* set internal variables */ /* set internal variables */
@@ -316,6 +369,7 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_ptr->bit_depth = (png_byte)bit_depth; png_ptr->bit_depth = (png_byte)bit_depth;
png_ptr->interlaced = (png_byte)interlace_type; png_ptr->interlaced = (png_byte)interlace_type;
png_ptr->color_type = (png_byte)color_type; png_ptr->color_type = (png_byte)color_type;
png_ptr->filter_type = (png_byte)filter_type;
/* find number of channels */ /* find number of channels */
switch (png_ptr->color_type) switch (png_ptr->color_type)
@@ -342,17 +396,20 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
(png_uint_32)png_ptr->pixel_depth + 7) >> 3); (png_uint_32)png_ptr->pixel_depth + 7) >> 3);
png_debug1(3,"bit_depth = %d\n", png_ptr->bit_depth); png_debug1(3,"bit_depth = %d\n", png_ptr->bit_depth);
png_debug1(3,"channels = %d\n", png_ptr->channels); png_debug1(3,"channels = %d\n", png_ptr->channels);
png_debug1(3,"rowbytes = %d\n", png_ptr->rowbytes); png_debug1(3,"rowbytes = %lu\n", png_ptr->rowbytes);
png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth,
color_type, interlace_type, compression_type, filter_type); color_type, interlace_type, compression_type, filter_type);
} }
/* read and check the palette */ /* read and check the palette */
void void /* PRIVATE */
png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_colorp palette; png_colorp palette;
int num, i; int num, i;
#ifndef PNG_NO_POINTER_INDEXING
png_colorp pal_ptr;
#endif
png_debug(1, "in png_handle_PLTE\n"); png_debug(1, "in png_handle_PLTE\n");
@@ -377,7 +434,7 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
} }
#endif #endif
if (length % 3) if (length > 768 || length % 3)
{ {
if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
{ {
@@ -395,6 +452,17 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
palette = (png_colorp)png_zalloc(png_ptr, (uInt)num, sizeof (png_color)); palette = (png_colorp)png_zalloc(png_ptr, (uInt)num, sizeof (png_color));
#ifndef PNG_NO_POINTER_INDEXING
for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++)
{
png_byte buf[3];
png_crc_read(png_ptr, buf, 3);
pal_ptr->red = buf[0];
pal_ptr->green = buf[1];
pal_ptr->blue = buf[2];
}
#else
for (i = 0; i < num; i++) for (i = 0; i < num; i++)
{ {
png_byte buf[3]; png_byte buf[3];
@@ -405,6 +473,7 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
palette[i].green = buf[1]; palette[i].green = buf[1];
palette[i].blue = buf[2]; palette[i].blue = buf[2];
} }
#endif
/* If we actually NEED the PLTE chunk (ie for a paletted image), we do /* If we actually NEED the PLTE chunk (ie for a paletted image), we do
whatever the normal CRC configuration tells us. However, if we whatever the normal CRC configuration tells us. However, if we
@@ -446,11 +515,15 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_ptr->palette = palette; png_ptr->palette = palette;
png_ptr->num_palette = (png_uint_16)num; png_ptr->num_palette = (png_uint_16)num;
#ifdef PNG_FREE_ME_SUPPORTED
png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0); png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);
png_ptr->free_me |= PNG_FREE_PLTE; png_ptr->free_me |= PNG_FREE_PLTE;
#else
png_ptr->flags |= PNG_FLAG_FREE_PLTE;
#endif
png_set_PLTE(png_ptr, info_ptr, palette, num); png_set_PLTE(png_ptr, info_ptr, palette, num);
#if defined (PNG_READ_tRNS_SUPPORTED) #if defined(PNG_READ_tRNS_SUPPORTED)
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{ {
if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
@@ -471,7 +544,7 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
} }
void void /* PRIVATE */
png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_debug(1, "in png_handle_IEND\n"); png_debug(1, "in png_handle_IEND\n");
@@ -495,7 +568,7 @@ png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
} }
#if defined(PNG_READ_gAMA_SUPPORTED) #if defined(PNG_READ_gAMA_SUPPORTED)
void void /* PRIVATE */
png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_fixed_point igamma; png_fixed_point igamma;
@@ -551,7 +624,7 @@ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_warning(png_ptr, png_warning(png_ptr,
"Ignoring incorrect gAMA value when sRGB is also present"); "Ignoring incorrect gAMA value when sRGB is also present");
#ifndef PNG_NO_STDIO #ifndef PNG_NO_CONSOLE_IO
fprintf(stderr, "gamma = (%d/100000)\n", (int)igamma); fprintf(stderr, "gamma = (%d/100000)\n", (int)igamma);
#endif #endif
return; return;
@@ -572,7 +645,7 @@ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#endif #endif
#if defined(PNG_READ_sBIT_SUPPORTED) #if defined(PNG_READ_sBIT_SUPPORTED)
void void /* PRIVATE */
png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_size_t truelen; png_size_t truelen;
@@ -638,7 +711,7 @@ png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#endif #endif
#if defined(PNG_READ_cHRM_SUPPORTED) #if defined(PNG_READ_cHRM_SUPPORTED)
void void /* PRIVATE */
png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_byte buf[4]; png_byte buf[4];
@@ -761,7 +834,7 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_warning(png_ptr, png_warning(png_ptr,
"Ignoring incorrect cHRM value when sRGB is also present"); "Ignoring incorrect cHRM value when sRGB is also present");
#ifndef PNG_NO_STDIO #ifndef PNG_NO_CONSOLE_IO
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
fprintf(stderr,"wx=%f, wy=%f, rx=%f, ry=%f\n", fprintf(stderr,"wx=%f, wy=%f, rx=%f, ry=%f\n",
white_x, white_y, red_x, red_y); white_x, white_y, red_x, red_y);
@@ -773,7 +846,7 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
fprintf(stderr,"gx=%ld, gy=%ld, bx=%ld, by=%ld\n", fprintf(stderr,"gx=%ld, gy=%ld, bx=%ld, by=%ld\n",
int_x_green, int_y_green, int_x_blue, int_y_blue); int_x_green, int_y_green, int_x_blue, int_y_blue);
#endif #endif
#endif /* PNG_NO_STDIO */ #endif /* PNG_NO_CONSOLE_IO */
} }
png_crc_finish(png_ptr, 0); png_crc_finish(png_ptr, 0);
return; return;
@@ -795,7 +868,7 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#endif #endif
#if defined(PNG_READ_sRGB_SUPPORTED) #if defined(PNG_READ_sRGB_SUPPORTED)
void void /* PRIVATE */
png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
int intent; int intent;
@@ -849,14 +922,25 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
igamma=(int)info_ptr->int_gamma; igamma=(int)info_ptr->int_gamma;
#else #else
# ifdef PNG_FLOATING_POINT_SUPPORTED # ifdef PNG_FLOATING_POINT_SUPPORTED
igamma=info_ptr->gamma * 100000.; igamma=(int)(info_ptr->gamma * 100000.);
# endif # endif
#endif
#if 0 && defined(PNG_cHRM_SUPPORTED) && !defined(PNG_FIXED_POINT_SUPPORTED)
/* We need to define these here because they aren't in png.h */
png_fixed_point int_x_white;
png_fixed_point int_y_white;
png_fixed_point int_x_red;
png_fixed_point int_y_red;
png_fixed_point int_x_green;
png_fixed_point int_y_green;
png_fixed_point int_x_blue;
png_fixed_point int_y_blue;
#endif #endif
if(igamma < 45000L || igamma > 46000L) if(igamma < 45000L || igamma > 46000L)
{ {
png_warning(png_ptr, png_warning(png_ptr,
"Ignoring incorrect gAMA value when sRGB is also present"); "Ignoring incorrect gAMA value when sRGB is also present");
#ifndef PNG_NO_STDIO #ifndef PNG_NO_CONSOLE_IO
# ifdef PNG_FIXED_POINT_SUPPORTED # ifdef PNG_FIXED_POINT_SUPPORTED
fprintf(stderr,"incorrect gamma=(%d/100000)\n",(int)png_ptr->int_gamma); fprintf(stderr,"incorrect gamma=(%d/100000)\n",(int)png_ptr->int_gamma);
# else # else
@@ -870,6 +954,7 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#endif /* PNG_READ_gAMA_SUPPORTED */ #endif /* PNG_READ_gAMA_SUPPORTED */
#ifdef PNG_READ_cHRM_SUPPORTED #ifdef PNG_READ_cHRM_SUPPORTED
#ifdef PNG_FIXED_POINT_SUPPORTED
if (info_ptr->valid & PNG_INFO_cHRM) if (info_ptr->valid & PNG_INFO_cHRM)
if (abs(info_ptr->int_x_white - 31270L) > 1000 || if (abs(info_ptr->int_x_white - 31270L) > 1000 ||
abs(info_ptr->int_y_white - 32900L) > 1000 || abs(info_ptr->int_y_white - 32900L) > 1000 ||
@@ -883,6 +968,7 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_warning(png_ptr, png_warning(png_ptr,
"Ignoring incorrect cHRM value when sRGB is also present"); "Ignoring incorrect cHRM value when sRGB is also present");
} }
#endif /* PNG_FIXED_POINT_SUPPORTED */
#endif /* PNG_READ_cHRM_SUPPORTED */ #endif /* PNG_READ_cHRM_SUPPORTED */
png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent); png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent);
@@ -890,7 +976,7 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#endif /* PNG_READ_sRGB_SUPPORTED */ #endif /* PNG_READ_sRGB_SUPPORTED */
#if defined(PNG_READ_iCCP_SUPPORTED) #if defined(PNG_READ_iCCP_SUPPORTED)
void void /* PRIVATE */
png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
/* Note: this does not properly handle chunks that are > 64K under DOS */ /* Note: this does not properly handle chunks that are > 64K under DOS */
{ {
@@ -898,6 +984,8 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_byte compression_type; png_byte compression_type;
png_charp profile; png_charp profile;
png_uint_32 skip = 0; png_uint_32 skip = 0;
png_uint_32 profile_size = 0;
png_uint_32 profile_length = 0;
png_size_t slength, prefix_length, data_length; png_size_t slength, prefix_length, data_length;
png_debug(1, "in png_handle_iCCP\n"); png_debug(1, "in png_handle_iCCP\n");
@@ -944,38 +1032,63 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
for (profile = chunkdata; *profile; profile++) for (profile = chunkdata; *profile; profile++)
/* empty loop to find end of name */ ; /* empty loop to find end of name */ ;
++profile; ++profile;
/* there should be at least one NUL (the compression type byte) /* there should be at least one zero (the compression type byte)
following the separator, and we should be on it */ following the separator, and we should be on it */
if (profile >= chunkdata + slength) if ( profile >= chunkdata + slength)
{ {
png_free(png_ptr, chunkdata); png_free(png_ptr, chunkdata);
png_warning(png_ptr, "malformed iCCP chunk"); png_warning(png_ptr, "Malformed iCCP chunk");
return; return;
} }
/* compression should always be zero */ /* compression_type should always be zero */
compression_type = *profile++; compression_type = *profile++;
if (compression_type)
{
png_warning(png_ptr, "Ignoring nonzero compression type in iCCP chunk");
compression_type=0x00; /* Reset it to zero (libpng-1.0.6 through 1.0.8
wrote nonzero) */
}
prefix_length = profile - chunkdata; prefix_length = profile - chunkdata;
chunkdata = png_decompress_chunk(png_ptr, compression_type, chunkdata, chunkdata = png_decompress_chunk(png_ptr, compression_type, chunkdata,
slength, prefix_length, &data_length); slength, prefix_length, &data_length);
profile_length = data_length - prefix_length;
profile_size = ((*(chunkdata+prefix_length))<<24) |
((*(chunkdata+prefix_length+1))<<16) |
((*(chunkdata+prefix_length+2))<< 8) |
((*(chunkdata+prefix_length+3)) );
if(profile_size < profile_length)
profile_length = profile_size;
if(profile_size > profile_length)
{
png_warning(png_ptr, "Ignoring truncated iCCP profile.\n");
return;
}
png_set_iCCP(png_ptr, info_ptr, chunkdata, compression_type, png_set_iCCP(png_ptr, info_ptr, chunkdata, compression_type,
chunkdata + prefix_length, data_length); chunkdata + prefix_length, data_length-prefix_length);
png_free(png_ptr, chunkdata); png_free(png_ptr, chunkdata);
} }
#endif /* PNG_READ_iCCP_SUPPORTED */ #endif /* PNG_READ_iCCP_SUPPORTED */
#if defined(PNG_READ_sPLT_SUPPORTED) #if defined(PNG_READ_sPLT_SUPPORTED)
void void /* PRIVATE */
png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
/* Note: this does not properly handle chunks that are > 64K under DOS */ /* Note: this does not properly handle chunks that are > 64K under DOS */
{ {
png_bytep chunkdata; png_bytep chunkdata;
png_bytep entry_start; png_bytep entry_start;
png_sPLT_t new_palette; png_sPLT_t new_palette;
#ifdef PNG_NO_POINTER_INDEXING
png_sPLT_entryp pp;
#endif
int data_length, entry_size, i; int data_length, entry_size, i;
png_uint_32 skip = 0; png_uint_32 skip = 0;
png_size_t slength; png_size_t slength;
@@ -1039,6 +1152,7 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
new_palette.entries = (png_sPLT_entryp)png_malloc( new_palette.entries = (png_sPLT_entryp)png_malloc(
png_ptr, new_palette.nentries * sizeof(png_sPLT_entry)); png_ptr, new_palette.nentries * sizeof(png_sPLT_entry));
#ifndef PNG_NO_POINTER_INDEXING
for (i = 0; i < new_palette.nentries; i++) for (i = 0; i < new_palette.nentries; i++)
{ {
png_sPLT_entryp pp = new_palette.entries + i; png_sPLT_entryp pp = new_palette.entries + i;
@@ -1059,6 +1173,28 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
} }
pp->frequency = png_get_uint_16(entry_start); entry_start += 2; pp->frequency = png_get_uint_16(entry_start); entry_start += 2;
} }
#else
pp = new_palette.entries;
for (i = 0; i < new_palette.nentries; i++)
{
if (new_palette.depth == 8)
{
pp[i].red = *entry_start++;
pp[i].green = *entry_start++;
pp[i].blue = *entry_start++;
pp[i].alpha = *entry_start++;
}
else
{
pp[i].red = png_get_uint_16(entry_start); entry_start += 2;
pp[i].green = png_get_uint_16(entry_start); entry_start += 2;
pp[i].blue = png_get_uint_16(entry_start); entry_start += 2;
pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2;
}
pp->frequency = png_get_uint_16(entry_start); entry_start += 2;
}
#endif
/* discard all chunk data except the name and stash that */ /* discard all chunk data except the name and stash that */
new_palette.name = (png_charp)chunkdata; new_palette.name = (png_charp)chunkdata;
@@ -1071,7 +1207,7 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#endif /* PNG_READ_sPLT_SUPPORTED */ #endif /* PNG_READ_sPLT_SUPPORTED */
#if defined(PNG_READ_tRNS_SUPPORTED) #if defined(PNG_READ_tRNS_SUPPORTED)
void void /* PRIVATE */
png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_debug(1, "in png_handle_tRNS\n"); png_debug(1, "in png_handle_tRNS\n");
@@ -1157,15 +1293,21 @@ png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (png_crc_finish(png_ptr, 0)) if (png_crc_finish(png_ptr, 0))
return; return;
#ifdef PNG_FREE_ME_SUPPORTED
png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
png_ptr->free_me |= PNG_FREE_TRNS; if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
png_ptr->free_me |= PNG_FREE_TRNS;
#else
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
png_ptr->flags |= PNG_FLAG_FREE_TRNS;
#endif
png_set_tRNS(png_ptr, info_ptr, png_ptr->trans, png_ptr->num_trans, png_set_tRNS(png_ptr, info_ptr, png_ptr->trans, png_ptr->num_trans,
&(png_ptr->trans_values)); &(png_ptr->trans_values));
} }
#endif #endif
#if defined(PNG_READ_bKGD_SUPPORTED) #if defined(PNG_READ_bKGD_SUPPORTED)
void void /* PRIVATE */
png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_size_t truelen; png_size_t truelen;
@@ -1225,7 +1367,6 @@ png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if(buf[0] > info_ptr->num_palette) if(buf[0] > info_ptr->num_palette)
{ {
png_warning(png_ptr, "Incorrect bKGD chunk index value"); png_warning(png_ptr, "Incorrect bKGD chunk index value");
png_crc_finish(png_ptr, length);
return; return;
} }
png_ptr->background.red = png_ptr->background.red =
@@ -1255,7 +1396,7 @@ png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#endif #endif
#if defined(PNG_READ_hIST_SUPPORTED) #if defined(PNG_READ_hIST_SUPPORTED)
void void /* PRIVATE */
png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
int num, i; int num, i;
@@ -1304,14 +1445,18 @@ png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (png_crc_finish(png_ptr, 0)) if (png_crc_finish(png_ptr, 0))
return; return;
#ifdef PNG_FREE_ME_SUPPORTED
png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);
png_ptr->free_me |= PNG_FREE_HIST; png_ptr->free_me |= PNG_FREE_HIST;
#else
png_ptr->flags |= PNG_FLAG_FREE_HIST;
#endif
png_set_hIST(png_ptr, info_ptr, png_ptr->hist); png_set_hIST(png_ptr, info_ptr, png_ptr->hist);
} }
#endif #endif
#if defined(PNG_READ_pHYs_SUPPORTED) #if defined(PNG_READ_pHYs_SUPPORTED)
void void /* PRIVATE */
png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_byte buf[9]; png_byte buf[9];
@@ -1321,16 +1466,16 @@ png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_debug(1, "in png_handle_pHYs\n"); png_debug(1, "in png_handle_pHYs\n");
if (!(png_ptr->mode & PNG_HAVE_IHDR)) if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before pHYS"); png_error(png_ptr, "Missing IHDR before pHYs");
else if (png_ptr->mode & PNG_HAVE_IDAT) else if (png_ptr->mode & PNG_HAVE_IDAT)
{ {
png_warning(png_ptr, "Invalid pHYS after IDAT"); png_warning(png_ptr, "Invalid pHYs after IDAT");
png_crc_finish(png_ptr, length); png_crc_finish(png_ptr, length);
return; return;
} }
else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
{ {
png_warning(png_ptr, "Duplicate pHYS chunk"); png_warning(png_ptr, "Duplicate pHYs chunk");
png_crc_finish(png_ptr, length); png_crc_finish(png_ptr, length);
return; return;
} }
@@ -1354,7 +1499,7 @@ png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#endif #endif
#if defined(PNG_READ_oFFs_SUPPORTED) #if defined(PNG_READ_oFFs_SUPPORTED)
void void /* PRIVATE */
png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_byte buf[9]; png_byte buf[9];
@@ -1397,8 +1542,8 @@ png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#endif #endif
#if defined(PNG_READ_pCAL_SUPPORTED) #if defined(PNG_READ_pCAL_SUPPORTED)
/* read the pCAL chunk (png-scivis-19970203) */ /* read the pCAL chunk (described in the PNG Extensions document) */
void void /* PRIVATE */
png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_charp purpose; png_charp purpose;
@@ -1426,7 +1571,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
return; return;
} }
png_debug1(2, "Allocating and reading pCAL chunk data (%d bytes)\n", png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)\n",
length + 1); length + 1);
purpose = (png_charp)png_malloc(png_ptr, length + 1); purpose = (png_charp)png_malloc(png_ptr, length + 1);
slength = (png_size_t)length; slength = (png_size_t)length;
@@ -1515,7 +1660,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#if defined(PNG_READ_sCAL_SUPPORTED) #if defined(PNG_READ_sCAL_SUPPORTED)
/* read the sCAL chunk */ /* read the sCAL chunk */
void void /* PRIVATE */
png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_charp buffer, ep; png_charp buffer, ep;
@@ -1546,7 +1691,7 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
return; return;
} }
png_debug1(2, "Allocating and reading sCAL chunk data (%d bytes)\n", png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)\n",
length + 1); length + 1);
buffer = (png_charp)png_malloc(png_ptr, length + 1); buffer = (png_charp)png_malloc(png_ptr, length + 1);
slength = (png_size_t)length; slength = (png_size_t)length;
@@ -1627,7 +1772,7 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#endif #endif
#if defined(PNG_READ_tIME_SUPPORTED) #if defined(PNG_READ_tIME_SUPPORTED)
void void /* PRIVATE */
png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_byte buf[7]; png_byte buf[7];
@@ -1671,7 +1816,7 @@ png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#if defined(PNG_READ_tEXt_SUPPORTED) #if defined(PNG_READ_tEXt_SUPPORTED)
/* Note: this does not properly handle chunks that are > 64K under DOS */ /* Note: this does not properly handle chunks that are > 64K under DOS */
void void /* PRIVATE */
png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_textp text_ptr; png_textp text_ptr;
@@ -1718,11 +1863,13 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text)); text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
text_ptr->key = key; text_ptr->key = key;
#ifdef PNG_iTXt_SUPPORTED
text_ptr->lang = NULL; text_ptr->lang = NULL;
text_ptr->lang_key = NULL; text_ptr->lang_key = NULL;
text_ptr->itxt_length = 0;
#endif
text_ptr->text = text; text_ptr->text = text;
text_ptr->text_length = png_strlen(text); text_ptr->text_length = png_strlen(text);
text_ptr->itxt_length = 0;
png_set_text(png_ptr, info_ptr, text_ptr, 1); png_set_text(png_ptr, info_ptr, text_ptr, 1);
@@ -1733,7 +1880,7 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#if defined(PNG_READ_zTXt_SUPPORTED) #if defined(PNG_READ_zTXt_SUPPORTED)
/* note: this does not correctly handle chunks that are > 64K under DOS */ /* note: this does not correctly handle chunks that are > 64K under DOS */
void void /* PRIVATE */
png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_textp text_ptr; png_textp text_ptr;
@@ -1792,12 +1939,14 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text)); text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
text_ptr->compression = comp_type; text_ptr->compression = comp_type;
text_ptr->lang = NULL;
text_ptr->key = chunkdata; text_ptr->key = chunkdata;
#ifdef PNG_iTXt_SUPPORTED
text_ptr->lang = NULL;
text_ptr->lang_key = NULL; text_ptr->lang_key = NULL;
text_ptr->itxt_length = 0;
#endif
text_ptr->text = chunkdata + prefix_len; text_ptr->text = chunkdata + prefix_len;
text_ptr->text_length = data_len; text_ptr->text_length = data_len;
text_ptr->itxt_length = 0;
png_set_text(png_ptr, info_ptr, text_ptr, 1); png_set_text(png_ptr, info_ptr, text_ptr, 1);
@@ -1808,7 +1957,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#if defined(PNG_READ_iTXt_SUPPORTED) #if defined(PNG_READ_iTXt_SUPPORTED)
/* note: this does not correctly handle chunks that are > 64K under DOS */ /* note: this does not correctly handle chunks that are > 64K under DOS */
void void /* PRIVATE */
png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_textp text_ptr; png_textp text_ptr;
@@ -1887,10 +2036,10 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
text_ptr->compression = (int)comp_flag + 1; text_ptr->compression = (int)comp_flag + 1;
text_ptr->lang_key = chunkdata+(lang_key-key); text_ptr->lang_key = chunkdata+(lang_key-key);
text_ptr->lang = chunkdata+(lang-key); text_ptr->lang = chunkdata+(lang-key);
text_ptr->itxt_length = data_len;
text_ptr->text_length = 0;
text_ptr->key = chunkdata; text_ptr->key = chunkdata;
text_ptr->text = chunkdata + prefix_len; text_ptr->text = chunkdata + prefix_len;
text_ptr->text_length = 0;
text_ptr->itxt_length = data_len;
png_set_text(png_ptr, info_ptr, text_ptr, 1); png_set_text(png_ptr, info_ptr, text_ptr, 1);
@@ -1904,7 +2053,7 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
chunk name, CRC, or a critical chunk), the chunk is silently ignored chunk name, CRC, or a critical chunk), the chunk is silently ignored
-- unless the PNG_FLAG_UNKNOWN_CHUNKS_SUPPORTED flag is on in which -- unless the PNG_FLAG_UNKNOWN_CHUNKS_SUPPORTED flag is on in which
case it will be saved away to be written out later. */ case it will be saved away to be written out later. */
void void /* PRIVATE */
png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_uint_32 skip = 0; png_uint_32 skip = 0;
@@ -1924,12 +2073,14 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (!(png_ptr->chunk_name[0] & 0x20)) if (!(png_ptr->chunk_name[0] & 0x20))
{ {
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
HANDLE_CHUNK_ALWAYS HANDLE_CHUNK_ALWAYS
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) #if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
&& png_ptr->read_user_chunk_fn == (png_user_chunk_ptr)NULL && png_ptr->read_user_chunk_fn == (png_user_chunk_ptr)NULL
#endif #endif
) )
#endif
png_chunk_error(png_ptr, "unknown critical chunk"); png_chunk_error(png_ptr, "unknown critical chunk");
} }
@@ -1988,7 +2139,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
#define isnonalpha(c) ((c) < 41 || (c) > 122 || ((c) > 90 && (c) < 97)) #define isnonalpha(c) ((c) < 41 || (c) > 122 || ((c) > 90 && (c) < 97))
void void /* PRIVATE */
png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name) png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name)
{ {
png_debug(1, "in png_check_chunk_name\n"); png_debug(1, "in png_check_chunk_name\n");
@@ -2009,7 +2160,7 @@ png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name)
a zero indicates the pixel is to be skipped. This is in addition a zero indicates the pixel is to be skipped. This is in addition
to any alpha or transparency value associated with the pixel. If to any alpha or transparency value associated with the pixel. If
you want all pixels to be combined, pass 0xff (255) in mask. */ you want all pixels to be combined, pass 0xff (255) in mask. */
void void /* PRIVATE */
#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW #ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
png_combine_row_c png_combine_row_c
#else #else
@@ -2217,7 +2368,7 @@ png_combine_row
} }
#if defined(PNG_READ_INTERLACING_SUPPORTED) #if defined(PNG_READ_INTERLACING_SUPPORTED)
void void /* PRIVATE */
#ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE #ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE
png_do_read_interlace_c png_do_read_interlace_c
#else #else
@@ -2437,10 +2588,15 @@ png_do_read_interlace
row_info->rowbytes = ((final_width * row_info->rowbytes = ((final_width *
(png_uint_32)row_info->pixel_depth + 7) >> 3); (png_uint_32)row_info->pixel_depth + 7) >> 3);
} }
#if !defined(PNG_READ_PACKSWAP_SUPPORTED)
/* silence compiler warning */
if (transformations)
return;
#endif
} }
#endif #endif
void void /* PRIVATE */
#ifdef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW #ifdef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
png_read_filter_row_c png_read_filter_row_c
#else #else
@@ -2450,7 +2606,7 @@ png_read_filter_row
png_bytep prev_row, int filter) png_bytep prev_row, int filter)
{ {
png_debug(1, "in png_read_filter_row\n"); png_debug(1, "in png_read_filter_row\n");
png_debug2(2,"row = %d, filter = %d\n", png_ptr->row_number, filter); png_debug2(2,"row = %lu, filter = %d\n", png_ptr->row_number, filter);
switch (filter) switch (filter)
{ {
case PNG_FILTER_VALUE_NONE: case PNG_FILTER_VALUE_NONE:
@@ -2568,7 +2724,7 @@ png_read_filter_row
} }
} }
void void /* PRIVATE */
png_read_finish_row(png_structp png_ptr) png_read_finish_row(png_structp png_ptr)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -2690,7 +2846,7 @@ png_read_finish_row(png_structp png_ptr)
png_ptr->mode |= PNG_AFTER_IDAT; png_ptr->mode |= PNG_AFTER_IDAT;
} }
void void /* PRIVATE */
png_read_start_row(png_structp png_ptr) png_read_start_row(png_structp png_ptr)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -2831,7 +2987,8 @@ png_read_start_row(png_structp png_ptr)
} }
#endif #endif
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \
defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
if(png_ptr->transformations & PNG_USER_TRANSFORM) if(png_ptr->transformations & PNG_USER_TRANSFORM)
{ {
int user_pixel_depth=png_ptr->user_transform_depth* int user_pixel_depth=png_ptr->user_transform_depth*
@@ -2863,12 +3020,12 @@ png_read_start_row(png_structp png_ptr)
png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
png_debug1(3, "width = %d,\n", png_ptr->width); png_debug1(3, "width = %lu,\n", png_ptr->width);
png_debug1(3, "height = %d,\n", png_ptr->height); png_debug1(3, "height = %lu,\n", png_ptr->height);
png_debug1(3, "iwidth = %d,\n", png_ptr->iwidth); png_debug1(3, "iwidth = %lu,\n", png_ptr->iwidth);
png_debug1(3, "num_rows = %d\n", png_ptr->num_rows); png_debug1(3, "num_rows = %lu\n", png_ptr->num_rows);
png_debug1(3, "rowbytes = %d,\n", png_ptr->rowbytes); png_debug1(3, "rowbytes = %lu,\n", png_ptr->rowbytes);
png_debug1(3, "irowbytes = %d,\n", png_ptr->irowbytes); png_debug1(3, "irowbytes = %lu,\n", png_ptr->irowbytes);
png_ptr->flags |= PNG_FLAG_ROW_INIT; png_ptr->flags |= PNG_FLAG_ROW_INIT;
} }

180
pngset.c
View File

@@ -1,11 +1,11 @@
/* pngset.c - storage of image information into info struct /* pngset.c - storage of image information into info struct
* *
* libpng 1.0.6f - April 14, 2000 * libpng 1.0.9beta5 - December 15, 2000
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
* The functions here are used during reads to store data from the file * The functions here are used during reads to store data from the file
* into the info struct, and during writes to store application data * into the info struct, and during writes to store application data
@@ -17,7 +17,7 @@
#include "png.h" #include "png.h"
#if defined(PNG_bKGD_SUPPORTED) #if defined(PNG_bKGD_SUPPORTED)
void void PNGAPI
png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
{ {
png_debug1(1, "in %s storage function\n", "bKGD"); png_debug1(1, "in %s storage function\n", "bKGD");
@@ -31,7 +31,7 @@ png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
#if defined(PNG_cHRM_SUPPORTED) #if defined(PNG_cHRM_SUPPORTED)
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
void void PNGAPI
png_set_cHRM(png_structp png_ptr, png_infop info_ptr, png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
double white_x, double white_y, double red_x, double red_y, double white_x, double white_y, double red_x, double red_y,
double green_x, double green_y, double blue_x, double blue_y) double green_x, double green_y, double blue_x, double blue_y)
@@ -62,7 +62,7 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
} }
#endif #endif
#ifdef PNG_FIXED_POINT_SUPPORTED #ifdef PNG_FIXED_POINT_SUPPORTED
void void PNGAPI
png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x,
png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y,
@@ -97,7 +97,7 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
#if defined(PNG_gAMA_SUPPORTED) #if defined(PNG_gAMA_SUPPORTED)
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
void void PNGAPI
png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
{ {
png_debug1(1, "in %s storage function\n", "gAMA"); png_debug1(1, "in %s storage function\n", "gAMA");
@@ -112,7 +112,7 @@ png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
} }
#endif #endif
#endif #endif
void void PNGAPI
png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
int_gamma) int_gamma)
{ {
@@ -123,12 +123,14 @@ png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
info_ptr->gamma = (float)(int_gamma/100000.); info_ptr->gamma = (float)(int_gamma/100000.);
#endif #endif
#ifdef PNG_FIXED_POINT_SUPPORTED
info_ptr->int_gamma = int_gamma; info_ptr->int_gamma = int_gamma;
#endif
info_ptr->valid |= PNG_INFO_gAMA; info_ptr->valid |= PNG_INFO_gAMA;
} }
#if defined(PNG_hIST_SUPPORTED) #if defined(PNG_hIST_SUPPORTED)
void void PNGAPI
png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist) png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
{ {
png_debug1(1, "in %s storage function\n", "hIST"); png_debug1(1, "in %s storage function\n", "hIST");
@@ -140,7 +142,7 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
} }
#endif #endif
void void PNGAPI
png_set_IHDR(png_structp png_ptr, png_infop info_ptr, png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
png_uint_32 width, png_uint_32 height, int bit_depth, png_uint_32 width, png_uint_32 height, int bit_depth,
int color_type, int interlace_type, int compression_type, int color_type, int interlace_type, int compression_type,
@@ -181,7 +183,7 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
} }
#if defined(PNG_oFFs_SUPPORTED) #if defined(PNG_oFFs_SUPPORTED)
void void PNGAPI
png_set_oFFs(png_structp png_ptr, png_infop info_ptr, png_set_oFFs(png_structp png_ptr, png_infop info_ptr,
png_int_32 offset_x, png_int_32 offset_y, int unit_type) png_int_32 offset_x, png_int_32 offset_y, int unit_type)
{ {
@@ -197,7 +199,7 @@ png_set_oFFs(png_structp png_ptr, png_infop info_ptr,
#endif #endif
#if defined(PNG_pCAL_SUPPORTED) #if defined(PNG_pCAL_SUPPORTED)
void void PNGAPI
png_set_pCAL(png_structp png_ptr, png_infop info_ptr, png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams,
png_charp units, png_charpp params) png_charp units, png_charpp params)
@@ -210,7 +212,7 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
return; return;
length = png_strlen(purpose) + 1; length = png_strlen(purpose) + 1;
png_debug1(3, "allocating purpose for info (%d bytes)\n", length); png_debug1(3, "allocating purpose for info (%lu bytes)\n", length);
info_ptr->pcal_purpose = (png_charp)png_malloc(png_ptr, length); info_ptr->pcal_purpose = (png_charp)png_malloc(png_ptr, length);
png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length); png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length);
@@ -221,7 +223,7 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
info_ptr->pcal_nparams = (png_byte)nparams; info_ptr->pcal_nparams = (png_byte)nparams;
length = png_strlen(units) + 1; length = png_strlen(units) + 1;
png_debug1(3, "allocating units for info (%d bytes)\n", length); png_debug1(3, "allocating units for info (%lu bytes)\n", length);
info_ptr->pcal_units = (png_charp)png_malloc(png_ptr, length); info_ptr->pcal_units = (png_charp)png_malloc(png_ptr, length);
png_memcpy(info_ptr->pcal_units, units, (png_size_t)length); png_memcpy(info_ptr->pcal_units, units, (png_size_t)length);
@@ -232,18 +234,21 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
for (i = 0; i < nparams; i++) for (i = 0; i < nparams; i++)
{ {
length = png_strlen(params[i]) + 1; length = png_strlen(params[i]) + 1;
png_debug2(3, "allocating parameter %d for info (%d bytes)\n", i, length); png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, length);
info_ptr->pcal_params[i] = (png_charp)png_malloc(png_ptr, length); info_ptr->pcal_params[i] = (png_charp)png_malloc(png_ptr, length);
png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length); png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length);
} }
info_ptr->valid |= PNG_INFO_pCAL; info_ptr->valid |= PNG_INFO_pCAL;
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_PCAL;
#endif
} }
#endif #endif
#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED) #if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED)
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
void void PNGAPI
png_set_sCAL(png_structp png_ptr, png_infop info_ptr, png_set_sCAL(png_structp png_ptr, png_infop info_ptr,
int unit, double width, double height) int unit, double width, double height)
{ {
@@ -259,7 +264,7 @@ png_set_sCAL(png_structp png_ptr, png_infop info_ptr,
} }
#else #else
#ifdef PNG_FIXED_POINT_SUPPORTED #ifdef PNG_FIXED_POINT_SUPPORTED
void void PNGAPI
png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr, png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
int unit, png_charp swidth, png_charp sheight) int unit, png_charp swidth, png_charp sheight)
{ {
@@ -282,13 +287,16 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length); png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length);
info_ptr->valid |= PNG_INFO_sCAL; info_ptr->valid |= PNG_INFO_sCAL;
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_SCAL;
#endif
} }
#endif #endif
#endif #endif
#endif #endif
#if defined(PNG_pHYs_SUPPORTED) #if defined(PNG_pHYs_SUPPORTED)
void void PNGAPI
png_set_pHYs(png_structp png_ptr, png_infop info_ptr, png_set_pHYs(png_structp png_ptr, png_infop info_ptr,
png_uint_32 res_x, png_uint_32 res_y, int unit_type) png_uint_32 res_x, png_uint_32 res_y, int unit_type)
{ {
@@ -303,7 +311,7 @@ png_set_pHYs(png_structp png_ptr, png_infop info_ptr,
} }
#endif #endif
void void PNGAPI
png_set_PLTE(png_structp png_ptr, png_infop info_ptr, png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
png_colorp palette, int num_palette) png_colorp palette, int num_palette)
{ {
@@ -319,7 +327,7 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
} }
#if defined(PNG_sBIT_SUPPORTED) #if defined(PNG_sBIT_SUPPORTED)
void void PNGAPI
png_set_sBIT(png_structp png_ptr, png_infop info_ptr, png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
png_color_8p sig_bit) png_color_8p sig_bit)
{ {
@@ -333,7 +341,7 @@ png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
#endif #endif
#if defined(PNG_sRGB_SUPPORTED) #if defined(PNG_sRGB_SUPPORTED)
void void PNGAPI
png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent) png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent)
{ {
png_debug1(1, "in %s storage function\n", "sRGB"); png_debug1(1, "in %s storage function\n", "sRGB");
@@ -344,7 +352,7 @@ png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent)
info_ptr->valid |= PNG_INFO_sRGB; info_ptr->valid |= PNG_INFO_sRGB;
} }
void void PNGAPI
png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
int intent) int intent)
{ {
@@ -416,7 +424,7 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
#if defined(PNG_iCCP_SUPPORTED) #if defined(PNG_iCCP_SUPPORTED)
void void PNGAPI
png_set_iCCP(png_structp png_ptr, png_infop info_ptr, png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
png_charp name, int compression_type, png_charp name, int compression_type,
png_charp profile, png_uint_32 proflen) png_charp profile, png_uint_32 proflen)
@@ -441,13 +449,15 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
/* Compression is always zero but is here so the API and info structure /* Compression is always zero but is here so the API and info structure
* does not have to change if we introduce multiple compression types */ * does not have to change if we introduce multiple compression types */
info_ptr->iccp_compression = (png_byte)compression_type; info_ptr->iccp_compression = (png_byte)compression_type;
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_ICCP; info_ptr->free_me |= PNG_FREE_ICCP;
#endif
info_ptr->valid |= PNG_INFO_iCCP; info_ptr->valid |= PNG_INFO_iCCP;
} }
#endif #endif
#if defined(PNG_TEXT_SUPPORTED) #if defined(PNG_TEXT_SUPPORTED)
void void PNGAPI
png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
int num_text) int num_text)
{ {
@@ -484,14 +494,17 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
info_ptr->num_text = 0; info_ptr->num_text = 0;
info_ptr->text = (png_textp)png_malloc(png_ptr, info_ptr->text = (png_textp)png_malloc(png_ptr,
(png_uint_32)(info_ptr->max_text * sizeof (png_text))); (png_uint_32)(info_ptr->max_text * sizeof (png_text)));
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_TEXT;
#endif
} }
png_debug1(3, "allocated %d entries for info_ptr->text\n", png_debug1(3, "allocated %d entries for info_ptr->text\n",
info_ptr->max_text); info_ptr->max_text);
} }
for (i = 0; i < num_text; i++) for (i = 0; i < num_text; i++)
{ {
png_size_t text_length,key_len,lang_len,lang_key_len; png_size_t text_length,key_len;
png_size_t lang_len,lang_key_len;
png_textp textp = &(info_ptr->text[info_ptr->num_text]); png_textp textp = &(info_ptr->text[info_ptr->num_text]);
if (text_ptr[i].key == (png_charp)NULL) if (text_ptr[i].key == (png_charp)NULL)
@@ -499,7 +512,13 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
key_len = png_strlen(text_ptr[i].key); key_len = png_strlen(text_ptr[i].key);
if(text_ptr[i].compression > 0) if(text_ptr[i].compression <= 0)
{
lang_len = 0;
lang_key_len = 0;
}
else
#ifdef PNG_iTXt_SUPPORTED
{ {
/* set iTXt data */ /* set iTXt data */
if (text_ptr[i].key != (png_charp)NULL) if (text_ptr[i].key != (png_charp)NULL)
@@ -511,18 +530,21 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
else else
lang_key_len = 0; lang_key_len = 0;
} }
else #else
{ {
lang_len = 0; png_warning(png_ptr, "iTXt chunk not supported.");
lang_key_len = 0; continue;
} }
#endif
if (text_ptr[i].text == (png_charp)NULL || text_ptr[i].text[0] == '\0') if (text_ptr[i].text == (png_charp)NULL || text_ptr[i].text[0] == '\0')
{ {
text_length = 0; text_length = 0;
#ifdef PNG_iTXt_SUPPORTED
if(text_ptr[i].compression > 0) if(text_ptr[i].compression > 0)
textp->compression = PNG_ITXT_COMPRESSION_NONE; textp->compression = PNG_ITXT_COMPRESSION_NONE;
else else
#endif
textp->compression = PNG_TEXT_COMPRESSION_NONE; textp->compression = PNG_TEXT_COMPRESSION_NONE;
} }
else else
@@ -532,13 +554,14 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
} }
textp->key = (png_charp)png_malloc(png_ptr, textp->key = (png_charp)png_malloc(png_ptr,
(png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4)); (png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4));
png_debug2(2, "Allocated %d bytes at %x in png_set_text\n", png_debug2(2, "Allocated %d bytes at %x in png_set_text\n",
key_len + lang_len + lang_key_len + text_length + 4, textp->key); key_len + lang_len + lang_key_len + text_length + 4, (int)textp->key);
png_memcpy(textp->key, text_ptr[i].key, png_memcpy(textp->key, text_ptr[i].key,
(png_size_t)(key_len)); (png_size_t)(key_len));
*(textp->key+key_len) = '\0'; *(textp->key+key_len) = '\0';
#ifdef PNG_iTXt_SUPPORTED
if (text_ptr[i].compression > 0) if (text_ptr[i].compression > 0)
{ {
textp->lang=textp->key + key_len + 1; textp->lang=textp->key + key_len + 1;
@@ -550,38 +573,42 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
textp->text=textp->lang_key + lang_key_len + 1; textp->text=textp->lang_key + lang_key_len + 1;
} }
else else
#endif
{ {
#ifdef PNG_iTXt_SUPPORTED
textp->lang=(png_charp)NULL; textp->lang=(png_charp)NULL;
textp->lang_key=(png_charp)NULL; textp->lang_key=(png_charp)NULL;
#endif
textp->text=textp->key + key_len + 1; textp->text=textp->key + key_len + 1;
} }
if(text_length) if(text_length)
png_memcpy(textp->text, text_ptr[i].text, png_memcpy(textp->text, text_ptr[i].text,
(png_size_t)(text_length)); (png_size_t)(text_length));
*(textp->text+text_length) = '\0'; *(textp->text+text_length) = '\0';
#ifdef PNG_iTXt_SUPPORTED
if(textp->compression > 0) if(textp->compression > 0)
{ {
textp->text_length = 0; textp->text_length = 0;
textp->itxt_length = text_length; textp->itxt_length = text_length;
} }
else else
#endif
{ {
textp->text_length = text_length; textp->text_length = text_length;
#ifdef PNG_iTXt_SUPPORTED
textp->itxt_length = 0; textp->itxt_length = 0;
#endif
} }
info_ptr->text[info_ptr->num_text]= *textp; info_ptr->text[info_ptr->num_text]= *textp;
info_ptr->num_text++; info_ptr->num_text++;
info_ptr->free_me |= PNG_FREE_TEXT;
png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text); png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text);
} }
} }
#endif #endif
#if defined(PNG_tIME_SUPPORTED) #if defined(PNG_tIME_SUPPORTED)
void void PNGAPI
png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time) png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
{ {
png_debug1(1, "in %s storage function\n", "tIME"); png_debug1(1, "in %s storage function\n", "tIME");
@@ -595,7 +622,7 @@ png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
#endif #endif
#if defined(PNG_tRNS_SUPPORTED) #if defined(PNG_tRNS_SUPPORTED)
void void PNGAPI
png_set_tRNS(png_structp png_ptr, png_infop info_ptr, png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
png_bytep trans, int num_trans, png_color_16p trans_values) png_bytep trans, int num_trans, png_color_16p trans_values)
{ {
@@ -619,7 +646,7 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
#endif #endif
#if defined(PNG_sPLT_SUPPORTED) #if defined(PNG_sPLT_SUPPORTED)
void void PNGAPI
png_set_sPLT(png_structp png_ptr, png_set_sPLT(png_structp png_ptr,
png_infop info_ptr, png_sPLT_tp entries, int nentries) png_infop info_ptr, png_sPLT_tp entries, int nentries)
{ {
@@ -632,6 +659,7 @@ png_set_sPLT(png_structp png_ptr,
png_memcpy(np, info_ptr->splt_palettes, png_memcpy(np, info_ptr->splt_palettes,
info_ptr->splt_palettes_num * sizeof(png_sPLT_t)); info_ptr->splt_palettes_num * sizeof(png_sPLT_t));
png_free(png_ptr, info_ptr->splt_palettes); png_free(png_ptr, info_ptr->splt_palettes);
info_ptr->splt_palettes=NULL;
for (i = 0; i < nentries; i++) for (i = 0; i < nentries; i++)
{ {
@@ -652,12 +680,14 @@ png_set_sPLT(png_structp png_ptr,
info_ptr->splt_palettes = np; info_ptr->splt_palettes = np;
info_ptr->splt_palettes_num += nentries; info_ptr->splt_palettes_num += nentries;
info_ptr->valid |= PNG_INFO_sPLT; info_ptr->valid |= PNG_INFO_sPLT;
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_SPLT; info_ptr->free_me |= PNG_FREE_SPLT;
#endif
} }
#endif /* PNG_sPLT_SUPPORTED */ #endif /* PNG_sPLT_SUPPORTED */
#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) #if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED)
void void PNGAPI
png_set_unknown_chunks(png_structp png_ptr, png_set_unknown_chunks(png_structp png_ptr,
png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns) png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)
{ {
@@ -674,6 +704,7 @@ png_set_unknown_chunks(png_structp png_ptr,
png_memcpy(np, info_ptr->unknown_chunks, png_memcpy(np, info_ptr->unknown_chunks,
info_ptr->unknown_chunks_num * sizeof(png_unknown_chunk)); info_ptr->unknown_chunks_num * sizeof(png_unknown_chunk));
png_free(png_ptr, info_ptr->unknown_chunks); png_free(png_ptr, info_ptr->unknown_chunks);
info_ptr->unknown_chunks=NULL;
for (i = 0; i < num_unknowns; i++) for (i = 0; i < num_unknowns; i++)
{ {
@@ -691,24 +722,51 @@ png_set_unknown_chunks(png_structp png_ptr,
info_ptr->unknown_chunks = np; info_ptr->unknown_chunks = np;
info_ptr->unknown_chunks_num += num_unknowns; info_ptr->unknown_chunks_num += num_unknowns;
#ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_UNKN; info_ptr->free_me |= PNG_FREE_UNKN;
#endif
}
void PNGAPI
png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr,
int chunk, int location)
{
if(png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk <
(int)info_ptr->unknown_chunks_num)
info_ptr->unknown_chunks[chunk].location = (png_byte)location;
} }
#endif #endif
#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ #if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
void void PNGAPI
png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted) png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
{ {
png_debug1(1, "in png_permit_empty_plte\n", ""); /* This function is deprecated in favor of png_permit_mng_features()
and will be removed from libpng-2.0.0 */
png_debug(1, "in png_permit_empty_plte, DEPRECATED.\n");
if (png_ptr == NULL) if (png_ptr == NULL)
return; return;
png_ptr->empty_plte_permitted=(png_byte)empty_plte_permitted; png_ptr->mng_features_permitted = (png_byte)
((png_ptr->mng_features_permitted & (~(PNG_FLAG_MNG_EMPTY_PLTE))) |
((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE)));
}
#endif
#if defined(PNG_MNG_FEATURES_SUPPORTED)
png_uint_32 PNGAPI
png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features)
{
png_debug(1, "in png_permit_mng_features\n");
if (png_ptr == NULL)
return (png_uint_32)0;
png_ptr->mng_features_permitted =
(png_byte)(mng_features & PNG_ALL_MNG_FEATURES);
return (png_uint_32)png_ptr->mng_features_permitted;
} }
#endif #endif
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
void void PNGAPI
png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep
chunk_list, int num_chunks) chunk_list, int num_chunks)
{ {
@@ -735,18 +793,21 @@ png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep
{ {
png_memcpy(new_list, png_ptr->chunk_list, 5*old_num_chunks); png_memcpy(new_list, png_ptr->chunk_list, 5*old_num_chunks);
png_free(png_ptr, png_ptr->chunk_list); png_free(png_ptr, png_ptr->chunk_list);
png_ptr->chunk_list=NULL;
} }
png_memcpy(new_list+5*old_num_chunks, chunk_list, 5*num_chunks); png_memcpy(new_list+5*old_num_chunks, chunk_list, 5*num_chunks);
for (p=new_list+5*old_num_chunks+4, i=0; i<num_chunks; i++, p+=5) for (p=new_list+5*old_num_chunks+4, i=0; i<num_chunks; i++, p+=5)
*p=(png_byte)keep; *p=(png_byte)keep;
png_ptr->num_chunk_list=old_num_chunks+num_chunks; png_ptr->num_chunk_list=old_num_chunks+num_chunks;
png_ptr->chunk_list=new_list; png_ptr->chunk_list=new_list;
#ifdef PNG_FREE_ME_SUPPORTED
png_ptr->free_me |= PNG_FREE_LIST; png_ptr->free_me |= PNG_FREE_LIST;
#endif
} }
#endif #endif
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) #if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
void void PNGAPI
png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr, png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr,
png_user_chunk_ptr read_user_chunk_fn) png_user_chunk_ptr read_user_chunk_fn)
{ {
@@ -757,18 +818,39 @@ png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr,
#endif #endif
#if defined(PNG_INFO_IMAGE_SUPPORTED) #if defined(PNG_INFO_IMAGE_SUPPORTED)
void void PNGAPI
png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers)
{ {
png_debug1(1, "in %s storage function\n", "rows"); png_debug1(1, "in %s storage function\n", "rows");
if (png_ptr == NULL || info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
if(info_ptr->row_pointers != row_pointers) if(info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers))
{
png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
info_ptr->row_pointers = row_pointers; info_ptr->row_pointers = row_pointers;
} if(row_pointers)
info_ptr->valid |= PNG_INFO_IDAT;
} }
#endif #endif
void PNGAPI
png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size)
{
if(png_ptr->zbuf)
png_free(png_ptr, png_ptr->zbuf);
png_ptr->zbuf_size = (png_size_t)size;
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size);
if(!png_ptr->zbuf)
png_error(png_ptr,"Unable to malloc zbuf");
png_ptr->zstream.next_out = png_ptr->zbuf;
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
}
void PNGAPI
png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask)
{
if (png_ptr && info_ptr)
info_ptr->valid &= ~(mask);
}

253
pngtest.c
View File

@@ -1,11 +1,11 @@
/* pngtest.c - a simple test program to test libpng /* pngtest.c - a simple test program to test libpng
* *
* libpng 1.0.6f - April 14, 2000 * libpng 1.0.9beta5 - December 15, 2000
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
* This program reads in a PNG image, writes it out again, and then * This program reads in a PNG image, writes it out again, and then
* compares the two files. If the files are identical, this shows that * compares the two files. If the files are identical, this shows that
@@ -16,7 +16,8 @@
* The program will report "FAIL" in certain legitimate cases: * The program will report "FAIL" in certain legitimate cases:
* 1) when the compression level or filter selection method is changed. * 1) when the compression level or filter selection method is changed.
* 2) when the maximum IDAT size (PNG_ZBUF_SIZE in pngconf.h) is not 8192. * 2) when the maximum IDAT size (PNG_ZBUF_SIZE in pngconf.h) is not 8192.
* 3) unknown ancillary chunks exist in the input file. * 3) unknown unsafe-to-copy ancillary chunks or unknown critical chunks
* exist in the input file.
* 4) others not listed here... * 4) others not listed here...
* In these cases, it is best to check with another tool such as "pngcheck" * In these cases, it is best to check with another tool such as "pngcheck"
* to see what the differences between the two files are. * to see what the differences between the two files are.
@@ -27,9 +28,27 @@
* of files at once by typing "pngtest -m file1.png file2.png ..." * of files at once by typing "pngtest -m file1.png file2.png ..."
*/ */
#include <stdio.h> #if defined(_WIN32_WCE)
#include <stdlib.h> # if _WIN32_WCE < 211
#include <assert.h> __error__ (f|w)printf functions are not supported on old WindowsCE.;
# endif
# include <windows.h>
# include <stdlib.h>
# define READFILE(file, data, length, check) \
if (ReadFile(file, data, length, &check,NULL)) check = 0
# define WRITEFILE(file, data, length, check)) \
if (WriteFile(file, data, length, &check, NULL)) check = 0
# define FCLOSE(file) CloseHandle(file)
#else
# include <stdio.h>
# include <stdlib.h>
# include <assert.h>
# define READFILE(file, data, length, check) \
check=(png_size_t)fread(data,(png_size_t)1,length,file)
# define WRITEFILE(file, data, length, check) \
check=(png_size_t)fwrite(data,(png_size_t)1, length, file)
# define FCLOSE(file) fclose(file)
#endif
/* Makes pngtest verbose so we can find problems (needs to be before png.h) */ /* Makes pngtest verbose so we can find problems (needs to be before png.h) */
#ifndef PNG_DEBUG #ifndef PNG_DEBUG
@@ -85,6 +104,8 @@ static int status_pass=1;
static int status_dots_requested=0; static int status_dots_requested=0;
static int status_dots=1; static int status_dots=1;
void
read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass);
void void
read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
{ {
@@ -104,6 +125,8 @@ read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
fprintf(stdout, "r"); fprintf(stdout, "r");
} }
void
write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass);
void void
write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
{ {
@@ -118,6 +141,8 @@ write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
5 in case illegal filter values are present.) */ 5 in case illegal filter values are present.) */
static png_uint_32 filters_used[256]; static png_uint_32 filters_used[256];
void void
count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data);
void
count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data) count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data)
{ {
if(png_ptr != NULL && row_info != NULL) if(png_ptr != NULL && row_info != NULL)
@@ -131,6 +156,8 @@ count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data)
static png_uint_32 zero_samples; static png_uint_32 zero_samples;
void
count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data);
void void
count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data) count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
{ {
@@ -232,15 +259,14 @@ static int wrote_question = 0;
than changing the library. */ than changing the library. */
#ifndef USE_FAR_KEYWORD #ifndef USE_FAR_KEYWORD
static void static void
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
png_size_t check; png_size_t check;
/* fread() returns 0 on error, so it is OK to store this in a png_size_t /* fread() returns 0 on error, so it is OK to store this in a png_size_t
* instead of an int, which is what fread() actually returns. * instead of an int, which is what fread() actually returns.
*/ */
check = (png_size_t)fread(data, (png_size_t)1, length, READFILE((png_FILE_p)png_ptr->io_ptr, data, length, check);
(FILE *)png_ptr->io_ptr);
if (check != length) if (check != length)
{ {
@@ -257,18 +283,18 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
#define MIN(a,b) (a <= b ? a : b) #define MIN(a,b) (a <= b ? a : b)
static void static void
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
int check; int check;
png_byte *n_data; png_byte *n_data;
FILE *io_ptr; png_FILE_p io_ptr;
/* Check if data really is near. If so, use usual code. */ /* Check if data really is near. If so, use usual code. */
n_data = (png_byte *)CVT_PTR_NOCHECK(data); n_data = (png_byte *)CVT_PTR_NOCHECK(data);
io_ptr = (FILE *)CVT_PTR(png_ptr->io_ptr); io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
if ((png_bytep)n_data == data) if ((png_bytep)n_data == data)
{ {
check = fread(n_data, 1, length, io_ptr); READFILE(io_ptr, n_data, length, check);
} }
else else
{ {
@@ -279,7 +305,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
do do
{ {
read = MIN(NEAR_BUF_SIZE, remaining); read = MIN(NEAR_BUF_SIZE, remaining);
err = fread(buf, (png_size_t)1, read, io_ptr); READFILE(io_ptr, buf, 1, err);
png_memcpy(data, buf, read); /* copy far buffer to near buffer */ png_memcpy(data, buf, read); /* copy far buffer to near buffer */
if(err != read) if(err != read)
break; break;
@@ -299,12 +325,14 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
#if defined(PNG_WRITE_FLUSH_SUPPORTED) #if defined(PNG_WRITE_FLUSH_SUPPORTED)
static void static void
png_default_flush(png_structp png_ptr) pngtest_flush(png_structp png_ptr)
{ {
FILE *io_ptr; #if !defined(_WIN32_WCE)
io_ptr = (FILE *)CVT_PTR((png_ptr->io_ptr)); png_FILE_p io_ptr;
io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
if (io_ptr != NULL) if (io_ptr != NULL)
fflush(io_ptr); fflush(io_ptr);
#endif
} }
#endif #endif
@@ -314,11 +342,11 @@ png_default_flush(png_structp png_ptr)
than changing the library. */ than changing the library. */
#ifndef USE_FAR_KEYWORD #ifndef USE_FAR_KEYWORD
static void static void
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
png_uint_32 check; png_uint_32 check;
check = fwrite(data, 1, length, (FILE *)(png_ptr->io_ptr)); WRITEFILE((png_FILE_p)png_ptr->io_ptr, data, length, check);
if (check != length) if (check != length)
{ {
png_error(png_ptr, "Write Error"); png_error(png_ptr, "Write Error");
@@ -334,18 +362,18 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
#define MIN(a,b) (a <= b ? a : b) #define MIN(a,b) (a <= b ? a : b)
static void static void
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
png_uint_32 check; png_uint_32 check;
png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */
FILE *io_ptr; png_FILE_p io_ptr;
/* Check if data really is near. If so, use usual code. */ /* Check if data really is near. If so, use usual code. */
near_data = (png_byte *)CVT_PTR_NOCHECK(data); near_data = (png_byte *)CVT_PTR_NOCHECK(data);
io_ptr = (FILE *)CVT_PTR(png_ptr->io_ptr); io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
if ((png_bytep)near_data == data) if ((png_bytep)near_data == data)
{ {
check = fwrite(near_data, 1, length, io_ptr); WRITEFILE(io_ptr, near_data, length, check);
} }
else else
{ {
@@ -357,7 +385,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
written = MIN(NEAR_BUF_SIZE, remaining); written = MIN(NEAR_BUF_SIZE, remaining);
png_memcpy(buf, data, written); /* copy far buffer to near buffer */ png_memcpy(buf, data, written); /* copy far buffer to near buffer */
err = fwrite(buf, 1, written, io_ptr); WRITEFILE(io_ptr, buf, written, err);
if (err != written) if (err != written)
break; break;
else else
@@ -381,7 +409,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
* not used, but it is passed in case it may be useful. * not used, but it is passed in case it may be useful.
*/ */
static void static void
png_default_warning(png_structp png_ptr, png_const_charp message) pngtest_warning(png_structp png_ptr, png_const_charp message)
{ {
PNG_CONST char *name = "UNKNOWN (ERROR!)"; PNG_CONST char *name = "UNKNOWN (ERROR!)";
if (png_ptr != NULL && png_ptr->error_ptr != NULL) if (png_ptr != NULL && png_ptr->error_ptr != NULL)
@@ -395,9 +423,9 @@ png_default_warning(png_structp png_ptr, png_const_charp message)
* error function pointer in png_set_error_fn(). * error function pointer in png_set_error_fn().
*/ */
static void static void
png_default_error(png_structp png_ptr, png_const_charp message) pngtest_error(png_structp png_ptr, png_const_charp message)
{ {
png_default_warning(png_ptr, message); pngtest_warning(png_ptr, message);
/* We can return because png_error calls the default handler, which is /* We can return because png_error calls the default handler, which is
* actually OK in this case. */ * actually OK in this case. */
} }
@@ -417,7 +445,7 @@ png_default_error(png_structp png_ptr, png_const_charp message)
by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K. */ by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K. */
typedef struct memory_information typedef struct memory_information
{ {
png_uint_32 size; png_uint_32 size;
png_voidp pointer; png_voidp pointer;
struct memory_information FAR *next; struct memory_information FAR *next;
} memory_information; } memory_information;
@@ -426,6 +454,8 @@ typedef memory_information FAR *memory_infop;
static memory_infop pinformation = NULL; static memory_infop pinformation = NULL;
static int current_allocation = 0; static int current_allocation = 0;
static int maximum_allocation = 0; static int maximum_allocation = 0;
static int total_allocation = 0;
static int num_allocations = 0;
extern PNG_EXPORT(png_voidp,png_debug_malloc) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_voidp,png_debug_malloc) PNGARG((png_structp png_ptr,
png_uint_32 size)); png_uint_32 size));
@@ -448,6 +478,8 @@ png_debug_malloc(png_structp png_ptr, png_uint_32 size)
memory_infop pinfo = png_malloc_default(png_ptr, sizeof *pinfo); memory_infop pinfo = png_malloc_default(png_ptr, sizeof *pinfo);
pinfo->size = size; pinfo->size = size;
current_allocation += size; current_allocation += size;
total_allocation += size;
num_allocations ++;
if (current_allocation > maximum_allocation) if (current_allocation > maximum_allocation)
maximum_allocation = current_allocation; maximum_allocation = current_allocation;
pinfo->pointer = png_malloc_default(png_ptr, size); pinfo->pointer = png_malloc_default(png_ptr, size);
@@ -459,7 +491,7 @@ png_debug_malloc(png_structp png_ptr, png_uint_32 size)
if(verbose) if(verbose)
printf("png_malloc %d bytes at %x\n",size,pinfo->pointer); printf("png_malloc %d bytes at %x\n",size,pinfo->pointer);
#endif #endif
assert(pinfo->size != 12345); assert(pinfo->size != 12345678);
return (png_voidp)(pinfo->pointer); return (png_voidp)(pinfo->pointer);
} }
} }
@@ -494,6 +526,7 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
the memory that is to be freed. */ the memory that is to be freed. */
memset(ptr, 0x55, pinfo->size); memset(ptr, 0x55, pinfo->size);
png_free_default(png_ptr, pinfo); png_free_default(png_ptr, pinfo);
pinfo=NULL;
break; break;
} }
if (pinfo->next == NULL) if (pinfo->next == NULL)
@@ -511,6 +544,7 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
printf("Freeing %x\n",ptr); printf("Freeing %x\n",ptr);
#endif #endif
png_free_default(png_ptr, ptr); png_free_default(png_ptr, ptr);
ptr=NULL;
} }
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
/* END of code to test memory allocation/deallocation */ /* END of code to test memory allocation/deallocation */
@@ -519,7 +553,8 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
int int
test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
{ {
static FILE *fpin, *fpout; /* "static" prevents setjmp corruption */ static png_FILE_p fpin;
static png_FILE_p fpout; /* "static" prevents setjmp corruption */
png_structp read_ptr, write_ptr; png_structp read_ptr, write_ptr;
png_infop read_info_ptr, write_info_ptr, end_info_ptr, write_end_info_ptr; png_infop read_info_ptr, write_info_ptr, end_info_ptr, write_end_info_ptr;
png_bytep row_buf; png_bytep row_buf;
@@ -533,20 +568,33 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#endif #endif
#endif #endif
#if defined(_WIN32_WCE)
TCHAR path[MAX_PATH];
#endif
char inbuf[256], outbuf[256]; char inbuf[256], outbuf[256];
row_buf = (png_bytep)NULL; row_buf = (png_bytep)NULL;
#if defined(_WIN32_WCE)
MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH);
if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE)
#else
if ((fpin = fopen(inname, "rb")) == NULL) if ((fpin = fopen(inname, "rb")) == NULL)
#endif
{ {
fprintf(STDERR, "Could not find input file %s\n", inname); fprintf(STDERR, "Could not find input file %s\n", inname);
return (1); return (1);
} }
#if defined(_WIN32_WCE)
MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH);
if ((fpout = CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL)) == INVALID_HANDLE_VALUE)
#else
if ((fpout = fopen(outname, "wb")) == NULL) if ((fpout = fopen(outname, "wb")) == NULL)
#endif
{ {
fprintf(STDERR, "Could not open output file %s\n", outname); fprintf(STDERR, "Could not open output file %s\n", outname);
fclose(fpin); FCLOSE(fpin);
return (1); return (1);
} }
@@ -560,8 +608,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
(png_error_ptr)NULL, (png_error_ptr)NULL); (png_error_ptr)NULL, (png_error_ptr)NULL);
#endif #endif
#if defined(PNG_NO_STDIO) #if defined(PNG_NO_STDIO)
png_set_error_fn(read_ptr, (png_voidp)inname, png_default_error, png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error,
png_default_warning); pngtest_warning);
#endif #endif
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, (png_voidp)NULL,
@@ -572,8 +620,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
(png_error_ptr)NULL, (png_error_ptr)NULL); (png_error_ptr)NULL, (png_error_ptr)NULL);
#endif #endif
#if defined(PNG_NO_STDIO) #if defined(PNG_NO_STDIO)
png_set_error_fn(write_ptr, (png_voidp)inname, png_default_error, png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error,
png_default_warning); pngtest_warning);
#endif #endif
png_debug(0, "Allocating read_info, write_info and end_info structures\n"); png_debug(0, "Allocating read_info, write_info and end_info structures\n");
read_info_ptr = png_create_info_struct(read_ptr); read_info_ptr = png_create_info_struct(read_ptr);
@@ -595,8 +643,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
png_destroy_info_struct(write_ptr, &write_end_info_ptr); png_destroy_info_struct(write_ptr, &write_end_info_ptr);
png_destroy_write_struct(&write_ptr, &write_info_ptr); png_destroy_write_struct(&write_ptr, &write_info_ptr);
fclose(fpin); FCLOSE(fpin);
fclose(fpout); FCLOSE(fpout);
return (1); return (1);
} }
#ifdef USE_FAR_KEYWORD #ifdef USE_FAR_KEYWORD
@@ -614,8 +662,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
png_destroy_info_struct(write_ptr, &write_end_info_ptr); png_destroy_info_struct(write_ptr, &write_end_info_ptr);
png_destroy_write_struct(&write_ptr, &write_info_ptr); png_destroy_write_struct(&write_ptr, &write_info_ptr);
fclose(fpin); FCLOSE(fpin);
fclose(fpout); FCLOSE(fpout);
return (1); return (1);
} }
#ifdef USE_FAR_KEYWORD #ifdef USE_FAR_KEYWORD
@@ -628,10 +676,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_init_io(read_ptr, fpin); png_init_io(read_ptr, fpin);
png_init_io(write_ptr, fpout); png_init_io(write_ptr, fpout);
#else #else
png_set_read_fn(read_ptr, (png_voidp)fpin, png_default_read_data); png_set_read_fn(read_ptr, (png_voidp)fpin, pngtest_read_data);
png_set_write_fn(write_ptr, (png_voidp)fpout, png_default_write_data, png_set_write_fn(write_ptr, (png_voidp)fpout, pngtest_write_data,
#if defined(PNG_WRITE_FLUSH_SUPPORTED) #if defined(PNG_WRITE_FLUSH_SUPPORTED)
png_default_flush); pngtest_flush);
#else #else
NULL); NULL);
#endif #endif
@@ -687,11 +735,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#endif #endif
} }
} }
#if defined(PNG_FIXED_POINT_SUPPORTED)
#if defined(PNG_cHRM_SUPPORTED) #if defined(PNG_cHRM_SUPPORTED)
{ {
png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x, png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x,
blue_y; blue_y;
if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y, &red_x, if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y, &red_x,
&red_y, &green_x, &green_y, &blue_x, &blue_y)) &red_y, &green_x, &green_y, &blue_x, &blue_y))
{ {
@@ -710,6 +758,32 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
} }
} }
#endif #endif
#else /* Use floating point versions */
#if defined(PNG_FLOATING_POINT_SUPPORTED)
#if defined(PNG_cHRM_SUPPORTED)
{
double white_x, white_y, red_x, red_y, green_x, green_y, blue_x,
blue_y;
if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x,
&red_y, &green_x, &green_y, &blue_x, &blue_y))
{
png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x,
red_y, green_x, green_y, blue_x, blue_y);
}
}
#endif
#if defined(PNG_gAMA_SUPPORTED)
{
double gamma;
if (png_get_gAMA(read_ptr, read_info_ptr, &gamma))
{
png_set_gAMA(write_ptr, write_info_ptr, gamma);
}
}
#endif
#endif /* floating point */
#endif /* fixed point */
#if defined(PNG_iCCP_SUPPORTED) #if defined(PNG_iCCP_SUPPORTED)
{ {
png_charp name; png_charp name;
@@ -815,22 +889,24 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
{ {
int unit; int unit;
double width, height; double scal_width, scal_height;
if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &width, &height)) if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &scal_width,
&scal_height))
{ {
png_set_sCAL(write_ptr, write_info_ptr, unit, width, height); png_set_sCAL(write_ptr, write_info_ptr, unit, scal_width, scal_height);
} }
} }
#else #else
#ifdef PNG_FIXED_POINT_SUPPORTED #ifdef PNG_FIXED_POINT_SUPPORTED
{ {
int unit; int unit;
png_charp width, height; png_charp scal_width, scal_height;
if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &width, &height)) if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width,
&scal_height))
{ {
png_set_sCAL_s(write_ptr, write_info_ptr, unit, width, height); png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width, scal_height);
} }
} }
#endif #endif
@@ -893,7 +969,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
generated locations in write_info_ptr are wrong because we generated locations in write_info_ptr are wrong because we
haven't written anything yet */ haven't written anything yet */
for (i = 0; i < (png_size_t)num_unknowns; i++) for (i = 0; i < (png_size_t)num_unknowns; i++)
write_info_ptr->unknown_chunks[i].location = unknowns[i].location; png_set_unknown_chunk_location(write_ptr, write_info_ptr, i,
unknowns[i].location);
} }
} }
#endif #endif
@@ -914,8 +991,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_destroy_read_struct(&read_ptr, &read_info_ptr, (png_infopp)NULL); png_destroy_read_struct(&read_ptr, &read_info_ptr, (png_infopp)NULL);
png_destroy_info_struct(write_ptr, &write_end_info_ptr); png_destroy_info_struct(write_ptr, &write_end_info_ptr);
png_destroy_write_struct(&write_ptr, &write_info_ptr); png_destroy_write_struct(&write_ptr, &write_info_ptr);
fclose(fpin); FCLOSE(fpin);
fclose(fpout); FCLOSE(fpout);
return (1); return (1);
} }
png_debug(0, "Writing row data\n"); png_debug(0, "Writing row data\n");
@@ -1007,8 +1084,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
generated locations in write_end_info_ptr are wrong because we generated locations in write_end_info_ptr are wrong because we
haven't written the end_info yet */ haven't written the end_info yet */
for (i = 0; i < (png_size_t)num_unknowns; i++) for (i = 0; i < (png_size_t)num_unknowns; i++)
write_end_info_ptr->unknown_chunks[i].location = png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i,
unknowns[i].location; unknowns[i].location);
} }
} }
#endif #endif
@@ -1027,24 +1104,35 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_debug(0, "Destroying data structs\n"); png_debug(0, "Destroying data structs\n");
png_free(read_ptr, row_buf); png_free(read_ptr, row_buf);
row_buf=NULL;
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
png_destroy_info_struct(write_ptr, &write_end_info_ptr); png_destroy_info_struct(write_ptr, &write_end_info_ptr);
png_destroy_write_struct(&write_ptr, &write_info_ptr); png_destroy_write_struct(&write_ptr, &write_info_ptr);
fclose(fpin); FCLOSE(fpin);
fclose(fpout); FCLOSE(fpout);
png_debug(0, "Opening files for comparison\n"); png_debug(0, "Opening files for comparison\n");
#if defined(_WIN32_WCE)
MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH);
if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE)
#else
if ((fpin = fopen(inname, "rb")) == NULL) if ((fpin = fopen(inname, "rb")) == NULL)
#endif
{ {
fprintf(STDERR, "Could not find file %s\n", inname); fprintf(STDERR, "Could not find file %s\n", inname);
return (1); return (1);
} }
#if defined(_WIN32_WCE)
MultiByteToWideChar(CP_ACP, 0, outname, -1, path, MAX_PATH);
if ((fpout = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE)
#else
if ((fpout = fopen(outname, "rb")) == NULL) if ((fpout = fopen(outname, "rb")) == NULL)
#endif
{ {
fprintf(STDERR, "Could not find file %s\n", outname); fprintf(STDERR, "Could not find file %s\n", outname);
fclose(fpin); FCLOSE(fpin);
return (1); return (1);
} }
@@ -1052,8 +1140,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
{ {
png_size_t num_in, num_out; png_size_t num_in, num_out;
num_in = fread(inbuf, 1, 1, fpin); READFILE(fpin, inbuf, 1, num_in);
num_out = fread(outbuf, 1, 1, fpout); READFILE(fpout, outbuf, 1, num_out);
if (num_in != num_out) if (num_in != num_out)
{ {
@@ -1071,8 +1159,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
ZLIB_VERSION); ZLIB_VERSION);
wrote_question=1; wrote_question=1;
} }
fclose(fpin); FCLOSE(fpin);
fclose(fpout); FCLOSE(fpout);
return (0); return (0);
} }
@@ -1094,14 +1182,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
ZLIB_VERSION); ZLIB_VERSION);
wrote_question=1; wrote_question=1;
} }
fclose(fpin); FCLOSE(fpin);
fclose(fpout); FCLOSE(fpout);
return (0); return (0);
} }
} }
fclose(fpin); FCLOSE(fpin);
fclose(fpout); FCLOSE(fpout);
return (0); return (0);
} }
@@ -1125,9 +1213,13 @@ main(int argc, char *argv[])
fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION); fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION);
fprintf(STDERR,"%s",png_get_copyright(NULL)); fprintf(STDERR,"%s",png_get_copyright(NULL));
/* Show the version of libpng used in building the library */ /* Show the version of libpng used in building the library */
fprintf(STDERR," library:%s",png_get_header_version(NULL)); fprintf(STDERR," library (%lu):%s", png_access_version_number(),
png_get_header_version(NULL));
/* Show the version of libpng used in building the application */ /* Show the version of libpng used in building the application */
fprintf(STDERR," pngtest:%s",PNG_HEADER_VERSION_STRING); fprintf(STDERR," pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER,
PNG_HEADER_VERSION_STRING);
fprintf(STDERR," sizeof(png_struct)=%d, sizeof(png_info)=%d\n",
sizeof(png_struct), sizeof(png_info));
/* Do some consistency checking on the memory allocation settings, I'm /* Do some consistency checking on the memory allocation settings, I'm
not sure this matters, but it is nice to know, the first of these not sure this matters, but it is nice to know, the first of these
@@ -1200,7 +1292,10 @@ main(int argc, char *argv[])
#endif #endif
for (i=2; i<argc; ++i) for (i=2; i<argc; ++i)
{ {
int k, kerror; #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
int k;
#endif
int kerror;
fprintf(STDERR, "Testing %s:",argv[i]); fprintf(STDERR, "Testing %s:",argv[i]);
kerror = test_one_file(argv[i], outname); kerror = test_one_file(argv[i], outname);
if (kerror == 0) if (kerror == 0)
@@ -1246,10 +1341,14 @@ main(int argc, char *argv[])
#endif #endif
} }
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
fprintf(STDERR, " Current memory allocation: %d bytes\n", fprintf(STDERR, " Current memory allocation: %10d bytes\n",
current_allocation); current_allocation);
fprintf(STDERR, " Maximum memory allocation: %d bytes\n", fprintf(STDERR, " Maximum memory allocation: %10d bytes\n",
maximum_allocation); maximum_allocation);
fprintf(STDERR, " Total memory allocation: %10d bytes\n",
total_allocation);
fprintf(STDERR, " Number of allocations: %10d\n",
num_allocations);
#endif #endif
} }
else else
@@ -1270,7 +1369,9 @@ main(int argc, char *argv[])
{ {
if(verbose == 1 || i == 2) if(verbose == 1 || i == 2)
{ {
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
int k; int k;
#endif
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
fprintf(STDERR, "\n PASS (%lu zero samples)\n",zero_samples); fprintf(STDERR, "\n PASS (%lu zero samples)\n",zero_samples);
#else #else
@@ -1315,10 +1416,14 @@ main(int argc, char *argv[])
#endif #endif
} }
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
fprintf(STDERR, " Current memory allocation: %d bytes\n", fprintf(STDERR, " Current memory allocation: %10d bytes\n",
current_allocation); current_allocation);
fprintf(STDERR, " Maximum memory allocation: %d bytes\n", fprintf(STDERR, " Maximum memory allocation: %10d bytes\n",
maximum_allocation); maximum_allocation);
fprintf(STDERR, " Total memory allocation: %10d bytes\n",
total_allocation);
fprintf(STDERR, " Number of allocations: %10d\n",
num_allocations);
#endif #endif
} }
@@ -1344,4 +1449,4 @@ main(int argc, char *argv[])
} }
/* Generate a compiler error if there is an old png.h in the search path. */ /* Generate a compiler error if there is an old png.h in the search path. */
typedef version_1_0_6f your_png_h_is_not_version_1_0_6f; typedef version_1_0_9beta5 your_png_h_is_not_version_1_0_9beta5;

View File

@@ -1,11 +1,11 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers) /* pngtrans.c - transforms the data in a row (used by both readers and writers)
* *
* libpng 1.0.6f - April 14, 2000 * libpng 1.0.9beta5 - December 15, 2000
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
@@ -13,7 +13,7 @@
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
/* turn on BGR-to-RGB mapping */ /* turn on BGR-to-RGB mapping */
void void PNGAPI
png_set_bgr(png_structp png_ptr) png_set_bgr(png_structp png_ptr)
{ {
png_debug(1, "in png_set_bgr\n"); png_debug(1, "in png_set_bgr\n");
@@ -23,7 +23,7 @@ png_set_bgr(png_structp png_ptr)
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
/* turn on 16 bit byte swapping */ /* turn on 16 bit byte swapping */
void void PNGAPI
png_set_swap(png_structp png_ptr) png_set_swap(png_structp png_ptr)
{ {
png_debug(1, "in png_set_swap\n"); png_debug(1, "in png_set_swap\n");
@@ -34,7 +34,7 @@ png_set_swap(png_structp png_ptr)
#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
/* turn on pixel packing */ /* turn on pixel packing */
void void PNGAPI
png_set_packing(png_structp png_ptr) png_set_packing(png_structp png_ptr)
{ {
png_debug(1, "in png_set_packing\n"); png_debug(1, "in png_set_packing\n");
@@ -48,7 +48,7 @@ png_set_packing(png_structp png_ptr)
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) #if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
/* turn on packed pixel swapping */ /* turn on packed pixel swapping */
void void PNGAPI
png_set_packswap(png_structp png_ptr) png_set_packswap(png_structp png_ptr)
{ {
png_debug(1, "in png_set_packswap\n"); png_debug(1, "in png_set_packswap\n");
@@ -58,7 +58,7 @@ png_set_packswap(png_structp png_ptr)
#endif #endif
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
void void PNGAPI
png_set_shift(png_structp png_ptr, png_color_8p true_bits) png_set_shift(png_structp png_ptr, png_color_8p true_bits)
{ {
png_debug(1, "in png_set_shift\n"); png_debug(1, "in png_set_shift\n");
@@ -69,7 +69,7 @@ png_set_shift(png_structp png_ptr, png_color_8p true_bits)
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ #if defined(PNG_READ_INTERLACING_SUPPORTED) || \
defined(PNG_WRITE_INTERLACING_SUPPORTED) defined(PNG_WRITE_INTERLACING_SUPPORTED)
int int PNGAPI
png_set_interlace_handling(png_structp png_ptr) png_set_interlace_handling(png_structp png_ptr)
{ {
png_debug(1, "in png_set_interlace handling\n"); png_debug(1, "in png_set_interlace handling\n");
@@ -89,7 +89,7 @@ png_set_interlace_handling(png_structp png_ptr)
* for 48-bit input data, as well as to avoid problems with some compilers * for 48-bit input data, as well as to avoid problems with some compilers
* that don't like bytes as parameters. * that don't like bytes as parameters.
*/ */
void void PNGAPI
png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
{ {
png_debug(1, "in png_set_filler\n"); png_debug(1, "in png_set_filler\n");
@@ -122,7 +122,7 @@ png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
void void PNGAPI
png_set_swap_alpha(png_structp png_ptr) png_set_swap_alpha(png_structp png_ptr)
{ {
png_debug(1, "in png_set_swap_alpha\n"); png_debug(1, "in png_set_swap_alpha\n");
@@ -132,7 +132,7 @@ png_set_swap_alpha(png_structp png_ptr)
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
void void PNGAPI
png_set_invert_alpha(png_structp png_ptr) png_set_invert_alpha(png_structp png_ptr)
{ {
png_debug(1, "in png_set_invert_alpha\n"); png_debug(1, "in png_set_invert_alpha\n");
@@ -141,7 +141,7 @@ png_set_invert_alpha(png_structp png_ptr)
#endif #endif
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
void void PNGAPI
png_set_invert_mono(png_structp png_ptr) png_set_invert_mono(png_structp png_ptr)
{ {
png_debug(1, "in png_set_invert_mono\n"); png_debug(1, "in png_set_invert_mono\n");
@@ -149,7 +149,7 @@ png_set_invert_mono(png_structp png_ptr)
} }
/* invert monochrome grayscale data */ /* invert monochrome grayscale data */
void void /* PRIVATE */
png_do_invert(png_row_infop row_info, png_bytep row) png_do_invert(png_row_infop row_info, png_bytep row)
{ {
png_debug(1, "in png_do_invert\n"); png_debug(1, "in png_do_invert\n");
@@ -174,7 +174,7 @@ png_do_invert(png_row_infop row_info, png_bytep row)
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
/* swaps byte order on 16 bit depth images */ /* swaps byte order on 16 bit depth images */
void void /* PRIVATE */
png_do_swap(png_row_infop row_info, png_bytep row) png_do_swap(png_row_infop row_info, png_bytep row)
{ {
png_debug(1, "in png_do_swap\n"); png_debug(1, "in png_do_swap\n");
@@ -305,7 +305,7 @@ static png_byte fourbppswaptable[256] = {
}; };
/* swaps pixel packing order within bytes */ /* swaps pixel packing order within bytes */
void void /* PRIVATE */
png_do_packswap(png_row_infop row_info, png_bytep row) png_do_packswap(png_row_infop row_info, png_bytep row)
{ {
png_debug(1, "in png_do_packswap\n"); png_debug(1, "in png_do_packswap\n");
@@ -337,7 +337,7 @@ png_do_packswap(png_row_infop row_info, png_bytep row)
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ #if defined(PNG_WRITE_FILLER_SUPPORTED) || \
defined(PNG_READ_STRIP_ALPHA_SUPPORTED) defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
/* remove filler or alpha byte(s) */ /* remove filler or alpha byte(s) */
void void /* PRIVATE */
png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
{ {
png_debug(1, "in png_do_strip_filler\n"); png_debug(1, "in png_do_strip_filler\n");
@@ -495,7 +495,7 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
/* swaps red and blue bytes within a pixel */ /* swaps red and blue bytes within a pixel */
void void /* PRIVATE */
png_do_bgr(png_row_infop row_info, png_bytep row) png_do_bgr(png_row_infop row_info, png_bytep row)
{ {
png_debug(1, "in png_do_bgr\n"); png_debug(1, "in png_do_bgr\n");
@@ -571,25 +571,39 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */ #endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
void defined(PNG_LEGACY_SUPPORTED)
void PNGAPI
png_set_user_transform_info(png_structp png_ptr, png_voidp png_set_user_transform_info(png_structp png_ptr, png_voidp
user_transform_ptr, int user_transform_depth, int user_transform_channels) user_transform_ptr, int user_transform_depth, int user_transform_channels)
{ {
png_debug(1, "in png_set_user_transform_info\n"); png_debug(1, "in png_set_user_transform_info\n");
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
png_ptr->user_transform_ptr = user_transform_ptr; png_ptr->user_transform_ptr = user_transform_ptr;
png_ptr->user_transform_depth = (png_byte)user_transform_depth; png_ptr->user_transform_depth = (png_byte)user_transform_depth;
png_ptr->user_transform_channels = (png_byte)user_transform_channels; png_ptr->user_transform_channels = (png_byte)user_transform_channels;
#else
if(user_transform_ptr || user_transform_depth || user_transform_channels)
png_warning(png_ptr,
"This version of libpng does not support user transform info");
#endif
} }
#endif
/* This function returns a pointer to the user_transform_ptr associated with /* This function returns a pointer to the user_transform_ptr associated with
* the user transform functions. The application should free any memory * the user transform functions. The application should free any memory
* associated with this pointer before png_write_destroy and png_read_destroy * associated with this pointer before png_write_destroy and png_read_destroy
* are called. * are called.
*/ */
png_voidp png_voidp PNGAPI
png_get_user_transform_ptr(png_structp png_ptr) png_get_user_transform_ptr(png_structp png_ptr)
{ {
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
return ((png_voidp)png_ptr->user_transform_ptr); return ((png_voidp)png_ptr->user_transform_ptr);
} #else
if(png_ptr)
return (NULL);
return (NULL);
#endif #endif
}

View File

@@ -2,14 +2,16 @@
* *
* For Intel x86 CPU and Microsoft Visual C++ compiler * For Intel x86 CPU and Microsoft Visual C++ compiler
* *
* libpng 1.0.6f - April 14, 2000 * libpng 1.0.9beta5 - December 15, 2000
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998, Intel Corporation
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
* Copyright (c) 1998, Intel Corporation
* *
* Contributed by Nirav Chhatrapati, Intel Corporation, 1998 * Contributed by Nirav Chhatrapati, Intel Corporation, 1998
* Interface to libpng contributed by Gilles Vollant, 1999 * Interface to libpng contributed by Gilles Vollant, 1999
* *
* [png_read_filter_row_mmx_avg() bpp == 2 bugfix, GRR 20000916]
*
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
@@ -25,7 +27,7 @@
static int mmx_supported=2; static int mmx_supported=2;
void void /* PRIVATE */
png_read_filter_row_c(png_structp png_ptr, png_row_infop row_info, png_read_filter_row_c(png_structp png_ptr, png_row_infop row_info,
png_bytep row, png_bytep prev_row, int filter); png_bytep row, png_bytep prev_row, int filter);
@@ -98,7 +100,7 @@ NOT_SUPPORTED:
/* Use this routine for x86 platform - uses faster MMX routine if machine /* Use this routine for x86 platform - uses faster MMX routine if machine
supports MMX */ supports MMX */
void void /* PRIVATE */
png_combine_row(png_structp png_ptr, png_bytep row, int mask) png_combine_row(png_structp png_ptr, png_bytep row, int mask)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -970,7 +972,7 @@ end48:
#if defined(PNG_READ_INTERLACING_SUPPORTED) #if defined(PNG_READ_INTERLACING_SUPPORTED)
void void /* PRIVATE */
png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
png_uint_32 transformations) png_uint_32 transformations)
{ {
@@ -1903,7 +1905,7 @@ union uAll {
// Optimized code for PNG Average filter decoder // Optimized code for PNG Average filter decoder
void void /* PRIVATE */
png_read_filter_row_mmx_avg(png_row_infop row_info, png_bytep row png_read_filter_row_mmx_avg(png_row_infop row_info, png_bytep row
, png_bytep prev_row) , png_bytep prev_row)
{ {
@@ -2117,8 +2119,8 @@ davg4lp:
case 2: case 2:
{ {
ActiveMask.use = 0x000000000000ffff; ActiveMask.use = 0x000000000000ffff;
ShiftBpp.use = 24; // == 3 * 8 ShiftBpp.use = 16; // == 2 * 8 [BUGFIX]
ShiftRem.use = 40; // == 64 - 24 ShiftRem.use = 48; // == 64 - 16 [BUGFIX]
_asm { _asm {
// Load ActiveMask // Load ActiveMask
movq mm7, ActiveMask movq mm7, ActiveMask
@@ -2133,7 +2135,7 @@ davg4lp:
// (we correct position in loop below) // (we correct position in loop below)
davg2lp: davg2lp:
movq mm0, [edi + ebx] movq mm0, [edi + ebx]
psllq mm2, ShiftRem // shift data to position correctly psrlq mm2, ShiftRem // shift data to position correctly [BUGFIX]
movq mm1, [esi + ebx] movq mm1, [esi + ebx]
// Add (Prev_row/2) to Average // Add (Prev_row/2) to Average
movq mm3, mm5 movq mm3, mm5
@@ -2336,7 +2338,7 @@ davgend:
} }
// Optimized code for PNG Paeth filter decoder // Optimized code for PNG Paeth filter decoder
void void /* PRIVATE */
png_read_filter_row_mmx_paeth(png_row_infop row_info, png_bytep row, png_read_filter_row_mmx_paeth(png_row_infop row_info, png_bytep row,
png_bytep prev_row) png_bytep prev_row)
{ {
@@ -3232,7 +3234,7 @@ dpthend:
} }
// Optimized code for PNG Sub filter decoder // Optimized code for PNG Sub filter decoder
void void /* PRIVATE */
png_read_filter_row_mmx_sub(png_row_infop row_info, png_bytep row) png_read_filter_row_mmx_sub(png_row_infop row_info, png_bytep row)
{ {
//int test; //int test;
@@ -3536,7 +3538,7 @@ dsubend:
} }
// Optimized code for PNG Up filter decoder // Optimized code for PNG Up filter decoder
void void /* PRIVATE */
png_read_filter_row_mmx_up(png_row_infop row_info, png_bytep row, png_read_filter_row_mmx_up(png_row_infop row_info, png_bytep row,
png_bytep prev_row) png_bytep prev_row)
{ {
@@ -3651,7 +3653,7 @@ dupend:
// Optimized png_read_filter_row routines // Optimized png_read_filter_row routines
void void /* PRIVATE */
png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep
row, png_bytep prev_row, int filter) row, png_bytep prev_row, int filter)
{ {
@@ -3671,11 +3673,11 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep
#ifdef PNG_DEBUG #ifdef PNG_DEBUG
png_debug(1, "in png_read_filter_row\n"); png_debug(1, "in png_read_filter_row\n");
#if (UseMMX == 1) # if (UseMMX == 1)
png_debug1(0,"%s, ", "MMX"); png_debug1(0,"%s, ", "MMX");
#else # else
png_debug1(0,"%s, ", "x86"); png_debug1(0,"%s, ", "x86");
#endif # endif
switch (filter) switch (filter)
{ {
case 0: sprintf(filnm, "None "); case 0: sprintf(filnm, "None ");
@@ -3846,7 +3848,8 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep
break; break;
} }
default: default:
png_error(png_ptr, "Bad adaptive filter type"); png_warning(png_ptr, "Ignoring bad adaptive filter type");
*row=0;
break; break;
} }
} }

View File

@@ -1,11 +1,11 @@
/* pngwio.c - functions for data output /* pngwio.c - functions for data output
* *
* libpng 1.0.6f - April 14, 2000 * libpng 1.0.9beta5 - December 15, 2000
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
* This file provides a location for all output. Users who need * This file provides a location for all output. Users who need
* special handling are expected to write functions that have the same * special handling are expected to write functions that have the same
@@ -24,7 +24,7 @@
buffering if you are using unbuffered writes. This should never be asked buffering if you are using unbuffered writes. This should never be asked
to write more than 64K on a 16 bit machine. */ to write more than 64K on a 16 bit machine. */
void void /* PRIVATE */
png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
if (png_ptr->write_data_fn != NULL ) if (png_ptr->write_data_fn != NULL )
@@ -39,16 +39,19 @@ png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
write_data function and use it at run time with png_set_write_fn(), rather write_data function and use it at run time with png_set_write_fn(), rather
than changing the library. */ than changing the library. */
#ifndef USE_FAR_KEYWORD #ifndef USE_FAR_KEYWORD
static void static void /* PRIVATE */
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
png_uint_32 check; png_uint_32 check;
check = fwrite(data, 1, length, (FILE *)(png_ptr->io_ptr)); #if defined(_WIN32_WCE)
if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
check = 0;
#else
check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr));
#endif
if (check != length) if (check != length)
{
png_error(png_ptr, "Write Error"); png_error(png_ptr, "Write Error");
}
} }
#else #else
/* this is the model-independent version. Since the standard I/O library /* this is the model-independent version. Since the standard I/O library
@@ -59,19 +62,24 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
#define NEAR_BUF_SIZE 1024 #define NEAR_BUF_SIZE 1024
#define MIN(a,b) (a <= b ? a : b) #define MIN(a,b) (a <= b ? a : b)
static void static void /* PRIVATE */
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
png_uint_32 check; png_uint_32 check;
png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */
FILE *io_ptr; png_FILE_p io_ptr;
/* Check if data really is near. If so, use usual code. */ /* Check if data really is near. If so, use usual code. */
near_data = (png_byte *)CVT_PTR_NOCHECK(data); near_data = (png_byte *)CVT_PTR_NOCHECK(data);
io_ptr = (FILE *)CVT_PTR(png_ptr->io_ptr); io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
if ((png_bytep)near_data == data) if ((png_bytep)near_data == data)
{ {
#if defined(_WIN32_WCE)
if ( !WriteFile(io_ptr, near_data, length, &check, NULL) )
check = 0;
#else
check = fwrite(near_data, 1, length, io_ptr); check = fwrite(near_data, 1, length, io_ptr);
#endif
} }
else else
{ {
@@ -83,7 +91,12 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
written = MIN(NEAR_BUF_SIZE, remaining); written = MIN(NEAR_BUF_SIZE, remaining);
png_memcpy(buf, data, written); /* copy far buffer to near buffer */ png_memcpy(buf, data, written); /* copy far buffer to near buffer */
#if defined(_WIN32_WCE)
if ( !WriteFile(io_ptr, buf, written, &err, NULL) )
err = 0;
#else
err = fwrite(buf, 1, written, io_ptr); err = fwrite(buf, 1, written, io_ptr);
#endif
if (err != written) if (err != written)
break; break;
else else
@@ -94,9 +107,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
while (remaining != 0); while (remaining != 0);
} }
if (check != length) if (check != length)
{
png_error(png_ptr, "Write Error"); png_error(png_ptr, "Write Error");
}
} }
#endif #endif
@@ -106,7 +117,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
to disk). After png_flush is called, there should be no data pending to disk). After png_flush is called, there should be no data pending
writing in any buffers. */ writing in any buffers. */
#if defined(PNG_WRITE_FLUSH_SUPPORTED) #if defined(PNG_WRITE_FLUSH_SUPPORTED)
void void /* PRIVATE */
png_flush(png_structp png_ptr) png_flush(png_structp png_ptr)
{ {
if (png_ptr->output_flush_fn != NULL) if (png_ptr->output_flush_fn != NULL)
@@ -114,13 +125,15 @@ png_flush(png_structp png_ptr)
} }
#if !defined(PNG_NO_STDIO) #if !defined(PNG_NO_STDIO)
static void static void /* PRIVATE */
png_default_flush(png_structp png_ptr) png_default_flush(png_structp png_ptr)
{ {
FILE *io_ptr; #if !defined(_WIN32_WCE)
io_ptr = (FILE *)CVT_PTR((png_ptr->io_ptr)); png_FILE_p io_ptr;
io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
if (io_ptr != NULL) if (io_ptr != NULL)
fflush(io_ptr); fflush(io_ptr);
#endif
} }
#endif #endif
#endif #endif
@@ -147,7 +160,7 @@ png_default_flush(png_structp png_ptr)
PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile
time, output_flush_fn will be ignored, although it must be time, output_flush_fn will be ignored, although it must be
supplied for compatibility. */ supplied for compatibility. */
void void PNGAPI
png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
{ {

View File

@@ -1,11 +1,11 @@
/* pngwrite.c - general routines to write a PNG file /* pngwrite.c - general routines to write a PNG file
* *
* libpng 1.0.6f - April 14, 2000 * libpng 1.0.9beta5 - December 15, 2000
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/ */
/* get internal access to png.h */ /* get internal access to png.h */
@@ -21,7 +21,7 @@
* write a plain PNG file. If you have long comments, I suggest writing * write a plain PNG file. If you have long comments, I suggest writing
* them in png_write_end(), and compressing them. * them in png_write_end(), and compressing them.
*/ */
void void PNGAPI
png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr) png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
{ {
png_debug(1, "in png_write_info_before_PLTE\n"); png_debug(1, "in png_write_info_before_PLTE\n");
@@ -57,7 +57,7 @@ png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
#endif #endif
#if defined(PNG_WRITE_iCCP_SUPPORTED) #if defined(PNG_WRITE_iCCP_SUPPORTED)
if (info_ptr->valid & PNG_INFO_iCCP) if (info_ptr->valid & PNG_INFO_iCCP)
png_write_iCCP(png_ptr, info_ptr->iccp_name, PNG_TEXT_COMPRESSION_NONE, png_write_iCCP(png_ptr, info_ptr->iccp_name, PNG_TEXT_COMPRESSION_zTXt,
info_ptr->iccp_profile, (int)info_ptr->iccp_proflen); info_ptr->iccp_profile, (int)info_ptr->iccp_proflen);
#endif #endif
#if defined(PNG_WRITE_sBIT_SUPPORTED) #if defined(PNG_WRITE_sBIT_SUPPORTED)
@@ -110,7 +110,7 @@ png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
} }
} }
void void PNGAPI
png_write_info(png_structp png_ptr, png_infop info_ptr) png_write_info(png_structp png_ptr, png_infop info_ptr)
{ {
#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) #if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
@@ -277,7 +277,7 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
* in png_write_info(), do not write them again here. If you have long * in png_write_info(), do not write them again here. If you have long
* comments, I suggest writing them here, and compressing them. * comments, I suggest writing them here, and compressing them.
*/ */
void void PNGAPI
png_write_end(png_structp png_ptr, png_infop info_ptr) png_write_end(png_structp png_ptr, png_infop info_ptr)
{ {
png_debug(1, "in png_write_end\n"); png_debug(1, "in png_write_end\n");
@@ -375,10 +375,17 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
/* write end of PNG file */ /* write end of PNG file */
png_write_IEND(png_ptr); png_write_IEND(png_ptr);
#if 0
/* This flush, added in libpng-1.0.8, causes some applications to crash
because they do not set png_ptr->output_flush_fn */
png_flush(png_ptr);
#endif
} }
#if defined(PNG_WRITE_tIME_SUPPORTED) #if defined(PNG_WRITE_tIME_SUPPORTED)
void #if !defined(_WIN32_WCE)
/* "time.h" functions are not supported on WindowsCE */
void PNGAPI
png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime) png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime)
{ {
png_debug(1, "in png_convert_from_struct_tm\n"); png_debug(1, "in png_convert_from_struct_tm\n");
@@ -390,7 +397,7 @@ png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime)
ptime->second = (png_byte)ttime->tm_sec; ptime->second = (png_byte)ttime->tm_sec;
} }
void void PNGAPI
png_convert_from_time_t(png_timep ptime, time_t ttime) png_convert_from_time_t(png_timep ptime, time_t ttime)
{ {
struct tm *tbuf; struct tm *tbuf;
@@ -400,9 +407,10 @@ png_convert_from_time_t(png_timep ptime, time_t ttime)
png_convert_from_struct_tm(ptime, tbuf); png_convert_from_struct_tm(ptime, tbuf);
} }
#endif #endif
#endif
/* Initialize png_ptr structure, and allocate any memory needed */ /* Initialize png_ptr structure, and allocate any memory needed */
png_structp png_structp PNGAPI
png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr, png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr,
png_error_ptr error_fn, png_error_ptr warn_fn) png_error_ptr error_fn, png_error_ptr warn_fn)
{ {
@@ -412,7 +420,7 @@ png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr,
} }
/* Alternate initialize png_ptr structure, and allocate any memory needed */ /* Alternate initialize png_ptr structure, and allocate any memory needed */
png_structp png_structp PNGAPI
png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
png_malloc_ptr malloc_fn, png_free_ptr free_fn) png_malloc_ptr malloc_fn, png_free_ptr free_fn)
@@ -424,6 +432,7 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
jmp_buf jmpbuf; jmp_buf jmpbuf;
#endif #endif
#endif #endif
int i;
png_debug(1, "in png_create_write_struct\n"); png_debug(1, "in png_create_write_struct\n");
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
if ((png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, if ((png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
@@ -443,6 +452,7 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
#endif #endif
{ {
png_free(png_ptr, png_ptr->zbuf); png_free(png_ptr, png_ptr->zbuf);
png_ptr->zbuf=NULL;
png_destroy_struct(png_ptr); png_destroy_struct(png_ptr);
return ((png_structp)NULL); return ((png_structp)NULL);
} }
@@ -456,16 +466,38 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
/* Libpng 0.90 and later are binary incompatible with libpng 0.89, so i=0;
* we must recompile any applications that use any older library version. do
* For versions after libpng 1.0, we will be compatible, so we need
* only check the first digit.
*/
if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
(png_libpng_ver[0] == '0' && user_png_ver[2] < '9'))
{ {
png_error(png_ptr, if(user_png_ver[i] != png_libpng_ver[i])
"Incompatible libpng version in application and library"); png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
} while (png_libpng_ver[i++]);
if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
{
/* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
* we must recompile any applications that use any older library version.
* For versions after libpng 1.0, we will be compatible, so we need
* only check the first digit.
*/
if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
(user_png_ver[0] == '0' && user_png_ver[2] < '9'))
{
png_error(png_ptr,
"Incompatible libpng version in application and library");
}
/* Libpng 1.0.6 was not binary compatible, due to insertion of the
info_ptr->free_me member. Note to maintainer: this test can be
removed from version 2.0.0 and beyond because the previous test
would have already rejected it. */
if (user_png_ver[4] == '6' && user_png_ver[2] == '0' &&
user_png_ver[0] == '1' && user_png_ver[5] == '\0')
{
png_error(png_ptr,
"Application must be recompiled; version 1.0.6 was incompatible");
}
} }
/* initialize zbuf - compression buffer */ /* initialize zbuf - compression buffer */
@@ -484,14 +516,46 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
} }
/* Initialize png_ptr structure, and allocate any memory needed */ /* Initialize png_ptr structure, and allocate any memory needed */
void #undef png_write_init
void PNGAPI
png_write_init(png_structp png_ptr) png_write_init(png_structp png_ptr)
{
/* We only come here via pre-1.0.7-compiled applications */
png_write_init_2(png_ptr, "1.0.0", 10000, 10000);
}
void PNGAPI
png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver,
png_size_t png_struct_size, png_size_t png_info_size)
{ {
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
jmp_buf tmp_jmp; /* to save current jump buffer */ jmp_buf tmp_jmp; /* to save current jump buffer */
#endif #endif
int i = 0;
do
{
if (user_png_ver[i] != png_libpng_ver[i])
{
#ifdef PNG_LEGACY_SUPPORTED
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
#else
png_ptr->error_fn=(png_error_ptr)NULL;
png_error(png_ptr,
"Application uses deprecated png_write_init() and must be recompiled.");
#endif
}
} while (png_libpng_ver[i++]);
if (sizeof(png_struct) > png_struct_size ||
sizeof(png_info) > png_info_size)
{
png_ptr->error_fn=(png_error_ptr)NULL;
png_error(png_ptr,
"Application and library have different sized structs. Please recompile.");
}
png_debug(1, "in png_write_init_2\n");
png_debug(1, "in png_write_init\n");
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
/* save jump buffer and error functions */ /* save jump buffer and error functions */
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf)); png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
@@ -522,7 +586,7 @@ png_write_init(png_structp png_ptr)
* have called png_set_interlace_handling(), you will have to * have called png_set_interlace_handling(), you will have to
* "write" the image seven times. * "write" the image seven times.
*/ */
void void PNGAPI
png_write_rows(png_structp png_ptr, png_bytepp row, png_write_rows(png_structp png_ptr, png_bytepp row,
png_uint_32 num_rows) png_uint_32 num_rows)
{ {
@@ -540,7 +604,7 @@ png_write_rows(png_structp png_ptr, png_bytepp row,
/* Write the image. You only need to call this function once, even /* Write the image. You only need to call this function once, even
* if you are writing an interlaced image. * if you are writing an interlaced image.
*/ */
void void PNGAPI
png_write_image(png_structp png_ptr, png_bytepp image) png_write_image(png_structp png_ptr, png_bytepp image)
{ {
png_uint_32 i; /* row index */ png_uint_32 i; /* row index */
@@ -567,7 +631,7 @@ png_write_image(png_structp png_ptr, png_bytepp image)
} }
/* called by user to write a row of image data */ /* called by user to write a row of image data */
void void PNGAPI
png_write_row(png_structp png_ptr, png_bytep row) png_write_row(png_structp png_ptr, png_bytep row)
{ {
png_debug2(1, "in png_write_row (row %ld, pass %d)\n", png_debug2(1, "in png_write_row (row %ld, pass %d)\n",
@@ -679,11 +743,11 @@ png_write_row(png_structp png_ptr, png_bytep row)
(png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3); (png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3);
png_debug1(3, "row_info->color_type = %d\n", png_ptr->row_info.color_type); png_debug1(3, "row_info->color_type = %d\n", png_ptr->row_info.color_type);
png_debug1(3, "row_info->width = %d\n", png_ptr->row_info.width); png_debug1(3, "row_info->width = %lu\n", png_ptr->row_info.width);
png_debug1(3, "row_info->channels = %d\n", png_ptr->row_info.channels); png_debug1(3, "row_info->channels = %d\n", png_ptr->row_info.channels);
png_debug1(3, "row_info->bit_depth = %d\n", png_ptr->row_info.bit_depth); png_debug1(3, "row_info->bit_depth = %d\n", png_ptr->row_info.bit_depth);
png_debug1(3, "row_info->pixel_depth = %d\n", png_ptr->row_info.pixel_depth); png_debug1(3, "row_info->pixel_depth = %d\n", png_ptr->row_info.pixel_depth);
png_debug1(3, "row_info->rowbytes = %d\n", png_ptr->row_info.rowbytes); png_debug1(3, "row_info->rowbytes = %lu\n", png_ptr->row_info.rowbytes);
/* Copy user's row into buffer, leaving room for filter byte. */ /* Copy user's row into buffer, leaving room for filter byte. */
png_memcpy_check(png_ptr, png_ptr->row_buf + 1, row, png_memcpy_check(png_ptr, png_ptr->row_buf + 1, row,
@@ -709,6 +773,15 @@ png_write_row(png_structp png_ptr, png_bytep row)
if (png_ptr->transformations) if (png_ptr->transformations)
png_do_write_transformations(png_ptr); png_do_write_transformations(png_ptr);
#if defined(PNG_MNG_FEATURES_SUPPORTED)
if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
(png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
{
/* Intrapixel differencing */
png_do_write_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1);
}
#endif
/* Find a filter if necessary, filter the row and write it out. */ /* Find a filter if necessary, filter the row and write it out. */
png_write_find_filter(png_ptr, &(png_ptr->row_info)); png_write_find_filter(png_ptr, &(png_ptr->row_info));
@@ -718,7 +791,7 @@ png_write_row(png_structp png_ptr, png_bytep row)
#if defined(PNG_WRITE_FLUSH_SUPPORTED) #if defined(PNG_WRITE_FLUSH_SUPPORTED)
/* Set the automatic flush interval or 0 to turn flushing off */ /* Set the automatic flush interval or 0 to turn flushing off */
void void PNGAPI
png_set_flush(png_structp png_ptr, int nrows) png_set_flush(png_structp png_ptr, int nrows)
{ {
png_debug(1, "in png_set_flush\n"); png_debug(1, "in png_set_flush\n");
@@ -726,7 +799,7 @@ png_set_flush(png_structp png_ptr, int nrows)
} }
/* flush the current output buffers now */ /* flush the current output buffers now */
void void PNGAPI
png_write_flush(png_structp png_ptr) png_write_flush(png_structp png_ptr)
{ {
int wrote_IDAT; int wrote_IDAT;
@@ -779,7 +852,7 @@ png_write_flush(png_structp png_ptr)
#endif /* PNG_WRITE_FLUSH_SUPPORTED */ #endif /* PNG_WRITE_FLUSH_SUPPORTED */
/* free all memory used by the write */ /* free all memory used by the write */
void void PNGAPI
png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
{ {
png_structp png_ptr = NULL; png_structp png_ptr = NULL;
@@ -804,11 +877,14 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
{ {
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
if (png_ptr->num_chunk_list) if (png_ptr->num_chunk_list)
{ {
png_free(png_ptr, png_ptr->chunk_list); png_free(png_ptr, png_ptr->chunk_list);
png_ptr->chunk_list=NULL;
png_ptr->num_chunk_list=0; png_ptr->num_chunk_list=0;
} }
#endif
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)info_ptr, free_fn); png_destroy_struct_2((png_voidp)info_ptr, free_fn);
@@ -832,7 +908,7 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
/* Free any memory used in png_ptr struct (old method) */ /* Free any memory used in png_ptr struct (old method) */
void void PNGAPI
png_write_destroy(png_structp png_ptr) png_write_destroy(png_structp png_ptr)
{ {
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
@@ -897,11 +973,10 @@ png_write_destroy(png_structp png_ptr)
} }
/* Allow the application to select one or more row filters to use. */ /* Allow the application to select one or more row filters to use. */
void void PNGAPI
png_set_filter(png_structp png_ptr, int method, int filters) png_set_filter(png_structp png_ptr, int method, int filters)
{ {
png_debug(1, "in png_set_filter\n"); png_debug(1, "in png_set_filter\n");
/* We allow 'method' only for future expansion of the base filter method. */
if (method == PNG_FILTER_TYPE_BASE) if (method == PNG_FILTER_TYPE_BASE)
{ {
switch (filters & (PNG_ALL_FILTERS | 0x07)) switch (filters & (PNG_ALL_FILTERS | 0x07))
@@ -997,7 +1072,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
* better compression. * better compression.
*/ */
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* GRR 970116 */ #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* GRR 970116 */
void void PNGAPI
png_set_filter_heuristics(png_structp png_ptr, int heuristic_method, png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
int num_weights, png_doublep filter_weights, int num_weights, png_doublep filter_weights,
png_doublep filter_costs) png_doublep filter_costs)
@@ -1114,7 +1189,7 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
} }
#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ #endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
void void PNGAPI
png_set_compression_level(png_structp png_ptr, int level) png_set_compression_level(png_structp png_ptr, int level)
{ {
png_debug(1, "in png_set_compression_level\n"); png_debug(1, "in png_set_compression_level\n");
@@ -1122,7 +1197,7 @@ png_set_compression_level(png_structp png_ptr, int level)
png_ptr->zlib_level = level; png_ptr->zlib_level = level;
} }
void void PNGAPI
png_set_compression_mem_level(png_structp png_ptr, int mem_level) png_set_compression_mem_level(png_structp png_ptr, int mem_level)
{ {
png_debug(1, "in png_set_compression_mem_level\n"); png_debug(1, "in png_set_compression_mem_level\n");
@@ -1130,7 +1205,7 @@ png_set_compression_mem_level(png_structp png_ptr, int mem_level)
png_ptr->zlib_mem_level = mem_level; png_ptr->zlib_mem_level = mem_level;
} }
void void PNGAPI
png_set_compression_strategy(png_structp png_ptr, int strategy) png_set_compression_strategy(png_structp png_ptr, int strategy)
{ {
png_debug(1, "in png_set_compression_strategy\n"); png_debug(1, "in png_set_compression_strategy\n");
@@ -1138,7 +1213,7 @@ png_set_compression_strategy(png_structp png_ptr, int strategy)
png_ptr->zlib_strategy = strategy; png_ptr->zlib_strategy = strategy;
} }
void void PNGAPI
png_set_compression_window_bits(png_structp png_ptr, int window_bits) png_set_compression_window_bits(png_structp png_ptr, int window_bits)
{ {
if (window_bits > 15) if (window_bits > 15)
@@ -1157,7 +1232,7 @@ png_set_compression_window_bits(png_structp png_ptr, int window_bits)
png_ptr->zlib_window_bits = window_bits; png_ptr->zlib_window_bits = window_bits;
} }
void void PNGAPI
png_set_compression_method(png_structp png_ptr, int method) png_set_compression_method(png_structp png_ptr, int method)
{ {
png_debug(1, "in png_set_compression_method\n"); png_debug(1, "in png_set_compression_method\n");
@@ -1167,14 +1242,14 @@ png_set_compression_method(png_structp png_ptr, int method)
png_ptr->zlib_method = method; png_ptr->zlib_method = method;
} }
void void PNGAPI
png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn) png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn)
{ {
png_ptr->write_row_fn = write_row_fn; png_ptr->write_row_fn = write_row_fn;
} }
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
void void PNGAPI
png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
write_user_transform_fn) write_user_transform_fn)
{ {
@@ -1186,9 +1261,9 @@ png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
#if defined(PNG_INFO_IMAGE_SUPPORTED) #if defined(PNG_INFO_IMAGE_SUPPORTED)
void png_write_png(png_structp png_ptr, png_infop info_ptr, void PNGAPI
int transforms, png_write_png(png_structp png_ptr, png_infop info_ptr,
voidp params) int transforms, voidp params)
{ {
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) #if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
/* invert the alpha channel from opacity to transparency */ /* invert the alpha channel from opacity to transparency */

View File

@@ -1,11 +1,11 @@
/* pngwtran.c - transforms the data in a row for PNG writers /* pngwtran.c - transforms the data in a row for PNG writers
* *
* libpng 1.0.6f - April 14, 2000 * libpng 1.0.9beta5 - December 15, 2000
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
@@ -14,7 +14,7 @@
/* Transform the data according to the user's wishes. The order of /* Transform the data according to the user's wishes. The order of
* transformations is significant. * transformations is significant.
*/ */
void void /* PRIVATE */
png_do_write_transformations(png_structp png_ptr) png_do_write_transformations(png_structp png_ptr)
{ {
png_debug(1, "in png_do_write_transformations\n"); png_debug(1, "in png_do_write_transformations\n");
@@ -82,7 +82,7 @@ png_do_write_transformations(png_structp png_ptr)
* row_info bit depth should be 8 (one pixel per byte). The channels * row_info bit depth should be 8 (one pixel per byte). The channels
* should be 1 (this only happens on grayscale and paletted images). * should be 1 (this only happens on grayscale and paletted images).
*/ */
void void /* PRIVATE */
png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
{ {
png_debug(1, "in png_do_pack\n"); png_debug(1, "in png_do_pack\n");
@@ -208,7 +208,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
* would pass 3 as bit_depth, and this routine would translate the * would pass 3 as bit_depth, and this routine would translate the
* data to 0 to 15. * data to 0 to 15.
*/ */
void void /* PRIVATE */
png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
{ {
png_debug(1, "in png_do_shift\n"); png_debug(1, "in png_do_shift\n");
@@ -332,7 +332,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth)
#endif #endif
#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) #if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
void void /* PRIVATE */
png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
{ {
png_debug(1, "in png_do_write_swap_alpha\n"); png_debug(1, "in png_do_write_swap_alpha\n");
@@ -420,7 +420,7 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row)
#endif #endif
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) #if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
void void /* PRIVATE */
png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
{ {
png_debug(1, "in png_do_write_invert_alpha\n"); png_debug(1, "in png_do_write_invert_alpha\n");
@@ -498,3 +498,64 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
} }
} }
#endif #endif
#if defined(PNG_MNG_FEATURES_SUPPORTED)
/* undoes intrapixel differencing */
void /* PRIVATE */
png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
{
png_debug(1, "in png_do_write_intrapixel\n");
if (
#if defined(PNG_USELESS_TESTS_SUPPORTED)
row != NULL && row_info != NULL &&
#endif
(row_info->color_type & PNG_COLOR_MASK_COLOR))
{
int bytes_per_pixel;
png_uint_32 row_width = row_info->width;
if (row_info->bit_depth == 8)
{
png_bytep rp;
png_uint_32 i;
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
bytes_per_pixel = 3;
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
bytes_per_pixel = 4;
else
return;
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
{
*(rp) = (png_byte)((*rp - *(rp+1))&0xff);
*(rp+2) = (png_byte)((*(rp+2) - *(rp+1))&0xff);
}
}
else if (row_info->bit_depth == 16)
{
png_bytep rp;
png_uint_32 i;
if (row_info->color_type == PNG_COLOR_TYPE_RGB)
bytes_per_pixel = 6;
else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
bytes_per_pixel = 8;
else
return;
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
{
png_uint_32 s0=*(rp )<<8 | *(rp+1);
png_uint_32 s1=*(rp+2)<<8 | *(rp+3);
png_uint_32 s2=*(rp+4)<<8 | *(rp+5);
png_uint_32 red=(s0-s1)&0xffff;
png_uint_32 blue=(s2-s1)&0xffff;
*(rp ) = (png_byte)((red>>8)&0xff);
*(rp+1) = (png_byte)(red&0xff);
*(rp+4) = (png_byte)((blue>>8)&0xff);
*(rp+5) = (png_byte)(blue&0xff);
}
}
}
}
#endif /* PNG_MNG_FEATURES_SUPPORTED */

View File

@@ -1,11 +1,11 @@
/* pngwutil.c - utilities to write a PNG file /* pngwutil.c - utilities to write a PNG file
* *
* libpng 1.0.6f - April 14, 2000 * libpng 1.0.9beta5 - December 15, 2000
* For conditions of distribution and use, see copyright notice in png.h * For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
* Copyright (c) 1996, 1997 Andreas Dilger
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
@@ -15,7 +15,7 @@
* with unsigned numbers for convenience, although one supported * with unsigned numbers for convenience, although one supported
* ancillary chunk uses signed (two's complement) numbers. * ancillary chunk uses signed (two's complement) numbers.
*/ */
void void /* PRIVATE */
png_save_uint_32(png_bytep buf, png_uint_32 i) png_save_uint_32(png_bytep buf, png_uint_32 i)
{ {
buf[0] = (png_byte)((i >> 24) & 0xff); buf[0] = (png_byte)((i >> 24) & 0xff);
@@ -29,7 +29,7 @@ png_save_uint_32(png_bytep buf, png_uint_32 i)
* complement format. If this isn't the case, then this routine needs to * complement format. If this isn't the case, then this routine needs to
* be modified to write data in two's complement format. * be modified to write data in two's complement format.
*/ */
void void /* PRIVATE */
png_save_int_32(png_bytep buf, png_int_32 i) png_save_int_32(png_bytep buf, png_int_32 i)
{ {
buf[0] = (png_byte)((i >> 24) & 0xff); buf[0] = (png_byte)((i >> 24) & 0xff);
@@ -43,7 +43,7 @@ png_save_int_32(png_bytep buf, png_int_32 i)
* The parameter is declared unsigned int, not png_uint_16, * The parameter is declared unsigned int, not png_uint_16,
* just to avoid potential problems on pre-ANSI C compilers. * just to avoid potential problems on pre-ANSI C compilers.
*/ */
void void /* PRIVATE */
png_save_uint_16(png_bytep buf, unsigned int i) png_save_uint_16(png_bytep buf, unsigned int i)
{ {
buf[0] = (png_byte)((i >> 8) & 0xff); buf[0] = (png_byte)((i >> 8) & 0xff);
@@ -59,7 +59,7 @@ png_save_uint_16(png_bytep buf, unsigned int i)
* png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end() * png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end()
* functions instead. * functions instead.
*/ */
void void PNGAPI
png_write_chunk(png_structp png_ptr, png_bytep chunk_name, png_write_chunk(png_structp png_ptr, png_bytep chunk_name,
png_bytep data, png_size_t length) png_bytep data, png_size_t length)
{ {
@@ -72,12 +72,12 @@ png_write_chunk(png_structp png_ptr, png_bytep chunk_name,
* The total_length is the sum of the lengths of all the data you will be * The total_length is the sum of the lengths of all the data you will be
* passing in png_write_chunk_data(). * passing in png_write_chunk_data().
*/ */
void void PNGAPI
png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name, png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name,
png_uint_32 length) png_uint_32 length)
{ {
png_byte buf[4]; png_byte buf[4];
png_debug2(0, "Writing %s chunk (%d bytes)\n", chunk_name, length); png_debug2(0, "Writing %s chunk (%lu bytes)\n", chunk_name, length);
/* write the length */ /* write the length */
png_save_uint_32(buf, length); png_save_uint_32(buf, length);
@@ -95,7 +95,7 @@ png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name,
* sum of the lengths from these calls *must* add up to the total_length * sum of the lengths from these calls *must* add up to the total_length
* given to png_write_chunk_start(). * given to png_write_chunk_start().
*/ */
void void PNGAPI
png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length) png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
/* write the data, and run the CRC over it */ /* write the data, and run the CRC over it */
@@ -107,7 +107,7 @@ png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length)
} }
/* Finish a chunk started with png_write_chunk_start(). */ /* Finish a chunk started with png_write_chunk_start(). */
void void PNGAPI
png_write_chunk_end(png_structp png_ptr) png_write_chunk_end(png_structp png_ptr)
{ {
png_byte buf[4]; png_byte buf[4];
@@ -124,7 +124,7 @@ png_write_chunk_end(png_structp png_ptr)
* we should call png_set_sig_bytes() to tell libpng how many of the * we should call png_set_sig_bytes() to tell libpng how many of the
* bytes have already been written. * bytes have already been written.
*/ */
void void /* PRIVATE */
png_write_sig(png_structp png_ptr) png_write_sig(png_structp png_ptr)
{ {
png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
@@ -151,7 +151,7 @@ typedef struct
} compression_state; } compression_state;
/* compress given text into storage in the png_ptr structure */ /* compress given text into storage in the png_ptr structure */
static int static int /* PRIVATE */
png_text_compress(png_structp png_ptr, png_text_compress(png_structp png_ptr,
png_charp text, png_size_t text_len, int compression, png_charp text, png_size_t text_len, int compression,
compression_state *comp) compression_state *comp)
@@ -167,12 +167,12 @@ png_text_compress(png_structp png_ptr,
{ {
comp->input = text; comp->input = text;
comp->input_len = text_len; comp->input_len = text_len;
return(text_len); return((int)text_len);
} }
if (compression >= PNG_TEXT_COMPRESSION_LAST) if (compression >= PNG_TEXT_COMPRESSION_LAST)
{ {
#if !defined(PNG_NO_STDIO) #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
char msg[50]; char msg[50];
sprintf(msg, "Unknown compression type %d", compression); sprintf(msg, "Unknown compression type %d", compression);
png_warning(png_ptr, msg); png_warning(png_ptr, msg);
@@ -260,7 +260,49 @@ png_text_compress(png_structp png_ptr,
{ {
/* tell zlib we are finished */ /* tell zlib we are finished */
ret = deflate(&png_ptr->zstream, Z_FINISH); ret = deflate(&png_ptr->zstream, Z_FINISH);
if (ret != Z_OK && ret != Z_STREAM_END)
if (ret == Z_OK)
{
/* check to see if we need more room */
if (!(png_ptr->zstream.avail_out))
{
/* check to make sure our output array has room */
if (comp->num_output_ptr >= comp->max_output_ptr)
{
int old_max;
old_max = comp->max_output_ptr;
comp->max_output_ptr = comp->num_output_ptr + 4;
if (comp->output_ptr != NULL)
{
png_charpp old_ptr;
old_ptr = comp->output_ptr;
/* This could be optimized to realloc() */
comp->output_ptr = (png_charpp)png_malloc(png_ptr,
(png_uint_32)(comp->max_output_ptr * sizeof (png_charpp)));
png_memcpy(comp->output_ptr, old_ptr,
old_max * sizeof (png_charp));
png_free(png_ptr, old_ptr);
}
else
comp->output_ptr = (png_charpp)png_malloc(png_ptr,
(png_uint_32)(comp->max_output_ptr * sizeof (png_charp)));
}
/* save off the data */
comp->output_ptr[comp->num_output_ptr] =
(png_charp)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size);
png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf,
png_ptr->zbuf_size);
comp->num_output_ptr++;
/* and reset the buffer pointers */
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
png_ptr->zstream.next_out = png_ptr->zbuf;
}
}
else if (ret != Z_STREAM_END)
{ {
/* we got an error */ /* we got an error */
if (png_ptr->zstream.msg != NULL) if (png_ptr->zstream.msg != NULL)
@@ -268,45 +310,6 @@ png_text_compress(png_structp png_ptr,
else else
png_error(png_ptr, "zlib error"); png_error(png_ptr, "zlib error");
} }
/* check to see if we need more room */
if (!(png_ptr->zstream.avail_out) && ret == Z_OK)
{
/* check to make sure our output array has room */
if (comp->num_output_ptr >= comp->max_output_ptr)
{
int old_max;
old_max = comp->max_output_ptr;
comp->max_output_ptr = comp->num_output_ptr + 4;
if (comp->output_ptr != NULL)
{
png_charpp old_ptr;
old_ptr = comp->output_ptr;
/* This could be optimized to realloc() */
comp->output_ptr = (png_charpp)png_malloc(png_ptr,
(png_uint_32)(comp->max_output_ptr * sizeof (png_charpp)));
png_memcpy(comp->output_ptr, old_ptr,
old_max * sizeof (png_charp));
png_free(png_ptr, old_ptr);
}
else
comp->output_ptr = (png_charpp)png_malloc(png_ptr,
(png_uint_32)(comp->max_output_ptr * sizeof (png_charp)));
}
/* save off the data */
comp->output_ptr[comp->num_output_ptr] = (png_charp)png_malloc(png_ptr,
(png_uint_32)png_ptr->zbuf_size);
png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf,
png_ptr->zbuf_size);
comp->num_output_ptr++;
/* and reset the buffer pointers */
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
png_ptr->zstream.next_out = png_ptr->zbuf;
}
} while (ret != Z_STREAM_END); } while (ret != Z_STREAM_END);
/* text length is number of buffers plus last buffer */ /* text length is number of buffers plus last buffer */
@@ -314,11 +317,11 @@ png_text_compress(png_structp png_ptr,
if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) if (png_ptr->zstream.avail_out < png_ptr->zbuf_size)
text_len += png_ptr->zbuf_size - (png_size_t)png_ptr->zstream.avail_out; text_len += png_ptr->zbuf_size - (png_size_t)png_ptr->zstream.avail_out;
return(text_len); return((int)text_len);
} }
/* ship the compressed text out via chunk writes */ /* ship the compressed text out via chunk writes */
static void static void /* PRIVATE */
png_write_compressed_data_out(png_structp png_ptr, compression_state *comp) png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
{ {
int i; int i;
@@ -336,9 +339,11 @@ png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
png_write_chunk_data(png_ptr,(png_bytep)comp->output_ptr[i], png_write_chunk_data(png_ptr,(png_bytep)comp->output_ptr[i],
png_ptr->zbuf_size); png_ptr->zbuf_size);
png_free(png_ptr, comp->output_ptr[i]); png_free(png_ptr, comp->output_ptr[i]);
comp->output_ptr[i]=NULL;
} }
if (comp->max_output_ptr != 0) if (comp->max_output_ptr != 0)
png_free(png_ptr, comp->output_ptr); png_free(png_ptr, comp->output_ptr);
comp->output_ptr=NULL;
/* write anything left in zbuf */ /* write anything left in zbuf */
if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size) if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size)
png_write_chunk_data(png_ptr, png_ptr->zbuf, png_write_chunk_data(png_ptr, png_ptr->zbuf,
@@ -354,7 +359,7 @@ png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
* information. Note that the rest of this code depends upon this * information. Note that the rest of this code depends upon this
* information being correct. * information being correct.
*/ */
void void /* PRIVATE */
png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
int bit_depth, int color_type, int compression_type, int filter_type, int bit_depth, int color_type, int compression_type, int filter_type,
int interlace_type) int interlace_type)
@@ -414,7 +419,12 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
compression_type = PNG_COMPRESSION_TYPE_BASE; compression_type = PNG_COMPRESSION_TYPE_BASE;
} }
if (filter_type != PNG_FILTER_TYPE_BASE) if (
#if defined(PNG_MNG_FEATURES_SUPPORTED)
!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
(filter_type == PNG_INTRAPIXEL_DIFFERENCING)) &&
#endif
filter_type != PNG_FILTER_TYPE_BASE)
{ {
png_warning(png_ptr, "Invalid filter type specified"); png_warning(png_ptr, "Invalid filter type specified");
filter_type = PNG_FILTER_TYPE_BASE; filter_type = PNG_FILTER_TYPE_BASE;
@@ -435,6 +445,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
png_ptr->bit_depth = (png_byte)bit_depth; png_ptr->bit_depth = (png_byte)bit_depth;
png_ptr->color_type = (png_byte)color_type; png_ptr->color_type = (png_byte)color_type;
png_ptr->interlaced = (png_byte)interlace_type; png_ptr->interlaced = (png_byte)interlace_type;
png_ptr->filter_type = (png_byte)filter_type;
png_ptr->width = width; png_ptr->width = width;
png_ptr->height = height; png_ptr->height = height;
@@ -497,7 +508,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
* correct order for PNG, so people can redefine it to any convenient * correct order for PNG, so people can redefine it to any convenient
* structure. * structure.
*/ */
void void /* PRIVATE */
png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal) png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -509,8 +520,8 @@ png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)
png_debug(1, "in png_write_PLTE\n"); png_debug(1, "in png_write_PLTE\n");
if (( if ((
#ifdef PNG_WRITE_EMPTY_PLTE_SUPPORTED #if defined(PNG_MNG_FEATURES_SUPPORTED)
!png_ptr->empty_plte_permitted && !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) &&
#endif #endif
num_pal == 0) || num_pal > 256) num_pal == 0) || num_pal > 256)
{ {
@@ -529,6 +540,7 @@ png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)
png_debug1(3, "num_palette = %d\n", png_ptr->num_palette); png_debug1(3, "num_palette = %d\n", png_ptr->num_palette);
png_write_chunk_start(png_ptr, (png_bytep)png_PLTE, num_pal * 3); png_write_chunk_start(png_ptr, (png_bytep)png_PLTE, num_pal * 3);
#ifndef PNG_NO_POINTER_INDEXING
for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++) for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++)
{ {
buf[0] = pal_ptr->red; buf[0] = pal_ptr->red;
@@ -536,12 +548,23 @@ png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)
buf[2] = pal_ptr->blue; buf[2] = pal_ptr->blue;
png_write_chunk_data(png_ptr, buf, (png_size_t)3); png_write_chunk_data(png_ptr, buf, (png_size_t)3);
} }
#else
/* This is a little slower but some buggy compilers need to do this instead */
pal_ptr=palette;
for (i = 0; i < num_pal; i++)
{
buf[0] = pal_ptr[i].red;
buf[1] = pal_ptr[i].green;
buf[2] = pal_ptr[i].blue;
png_write_chunk_data(png_ptr, buf, (png_size_t)3);
}
#endif
png_write_chunk_end(png_ptr); png_write_chunk_end(png_ptr);
png_ptr->mode |= PNG_HAVE_PLTE; png_ptr->mode |= PNG_HAVE_PLTE;
} }
/* write an IDAT chunk */ /* write an IDAT chunk */
void void /* PRIVATE */
png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length) png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -553,7 +576,7 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
} }
/* write an IEND chunk */ /* write an IEND chunk */
void void /* PRIVATE */
png_write_IEND(png_structp png_ptr) png_write_IEND(png_structp png_ptr)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -567,7 +590,7 @@ png_write_IEND(png_structp png_ptr)
#if defined(PNG_WRITE_gAMA_SUPPORTED) #if defined(PNG_WRITE_gAMA_SUPPORTED)
/* write a gAMA chunk */ /* write a gAMA chunk */
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
void void /* PRIVATE */
png_write_gAMA(png_structp png_ptr, double file_gamma) png_write_gAMA(png_structp png_ptr, double file_gamma)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -584,7 +607,7 @@ png_write_gAMA(png_structp png_ptr, double file_gamma)
} }
#endif #endif
#ifdef PNG_FIXED_POINT_SUPPORTED #ifdef PNG_FIXED_POINT_SUPPORTED
void void /* PRIVATE */
png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma) png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -602,7 +625,7 @@ png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma)
#if defined(PNG_WRITE_sRGB_SUPPORTED) #if defined(PNG_WRITE_sRGB_SUPPORTED)
/* write a sRGB chunk */ /* write a sRGB chunk */
void void /* PRIVATE */
png_write_sRGB(png_structp png_ptr, int srgb_intent) png_write_sRGB(png_structp png_ptr, int srgb_intent)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -621,7 +644,7 @@ png_write_sRGB(png_structp png_ptr, int srgb_intent)
#if defined(PNG_WRITE_iCCP_SUPPORTED) #if defined(PNG_WRITE_iCCP_SUPPORTED)
/* write an iCCP chunk */ /* write an iCCP chunk */
void void /* PRIVATE */
png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type, png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
png_charp profile, int profile_len) png_charp profile, int profile_len)
{ {
@@ -643,16 +666,17 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
if (compression_type) if (compression_type)
png_warning(png_ptr, "Unknown compression type in iCCP chunk"); png_warning(png_ptr, "Unknown compression type in iCCP chunk");
if (profile == NULL || *profile == '\0') if (profile == NULL)
profile_len = 0; profile_len = 0;
if (profile_len) if (profile_len)
profile_len = png_text_compress(png_ptr, profile, profile_len, profile_len = png_text_compress(png_ptr, profile, (png_size_t)profile_len,
PNG_TEXT_COMPRESSION_zTXt, &comp); PNG_TEXT_COMPRESSION_zTXt, &comp);
/* make sure we include the NULL after the name and the compression type */ /* make sure we include the NULL after the name and the compression type */
png_write_chunk_start(png_ptr, (png_bytep)png_iCCP, png_write_chunk_start(png_ptr, (png_bytep)png_iCCP,
(png_uint_32)name_len+profile_len+2); (png_uint_32)name_len+profile_len+2);
new_name[name_len+1]=0x00;
png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 2); png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 2);
if (profile_len) if (profile_len)
@@ -665,7 +689,7 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
#if defined(PNG_WRITE_sPLT_SUPPORTED) #if defined(PNG_WRITE_sPLT_SUPPORTED)
/* write a sPLT chunk */ /* write a sPLT chunk */
void void /* PRIVATE */
png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette) png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -677,6 +701,9 @@ png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
int entry_size = (spalette->depth == 8 ? 6 : 10); int entry_size = (spalette->depth == 8 ? 6 : 10);
int palette_size = entry_size * spalette->nentries; int palette_size = entry_size * spalette->nentries;
png_sPLT_entryp ep; png_sPLT_entryp ep;
#ifdef PNG_NO_POINTER_INDEXING
int i;
#endif
png_debug(1, "in png_write_sPLT\n"); png_debug(1, "in png_write_sPLT\n");
if (spalette->name == NULL || (name_len = png_check_keyword(png_ptr, if (spalette->name == NULL || (name_len = png_check_keyword(png_ptr,
@@ -693,6 +720,7 @@ png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1); png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1);
/* loop through each palette entry, writing appropriately */ /* loop through each palette entry, writing appropriately */
#ifndef PNG_NO_POINTER_INDEXING
for (ep = spalette->entries; ep<spalette->entries+spalette->nentries; ep++) for (ep = spalette->entries; ep<spalette->entries+spalette->nentries; ep++)
{ {
if (spalette->depth == 8) if (spalette->depth == 8)
@@ -713,6 +741,29 @@ png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
} }
png_write_chunk_data(png_ptr, entrybuf, entry_size); png_write_chunk_data(png_ptr, entrybuf, entry_size);
} }
#else
ep=spalette->entries;
for (i=0; i>spalette->nentries; i++)
{
if (spalette->depth == 8)
{
entrybuf[0] = (png_byte)ep[i].red;
entrybuf[1] = (png_byte)ep[i].green;
entrybuf[2] = (png_byte)ep[i].blue;
entrybuf[3] = (png_byte)ep[i].alpha;
png_save_uint_16(entrybuf + 4, ep[i].frequency);
}
else
{
png_save_uint_16(entrybuf + 0, ep[i].red);
png_save_uint_16(entrybuf + 2, ep[i].green);
png_save_uint_16(entrybuf + 4, ep[i].blue);
png_save_uint_16(entrybuf + 6, ep[i].alpha);
png_save_uint_16(entrybuf + 8, ep[i].frequency);
}
png_write_chunk_data(png_ptr, entrybuf, entry_size);
}
#endif
png_write_chunk_end(png_ptr); png_write_chunk_end(png_ptr);
png_free(png_ptr, new_name); png_free(png_ptr, new_name);
@@ -721,7 +772,7 @@ png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
#if defined(PNG_WRITE_sBIT_SUPPORTED) #if defined(PNG_WRITE_sBIT_SUPPORTED)
/* write the sBIT chunk */ /* write the sBIT chunk */
void void /* PRIVATE */
png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type) png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -778,7 +829,7 @@ png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type)
#if defined(PNG_WRITE_cHRM_SUPPORTED) #if defined(PNG_WRITE_cHRM_SUPPORTED)
/* write the cHRM chunk */ /* write the cHRM chunk */
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
void void /* PRIVATE */
png_write_cHRM(png_structp png_ptr, double white_x, double white_y, png_write_cHRM(png_structp png_ptr, double white_x, double white_y,
double red_x, double red_y, double green_x, double green_y, double red_x, double red_y, double green_x, double green_y,
double blue_x, double blue_y) double blue_x, double blue_y)
@@ -795,8 +846,8 @@ png_write_cHRM(png_structp png_ptr, double white_x, double white_y,
white_x + white_y > 1.0) white_x + white_y > 1.0)
{ {
png_warning(png_ptr, "Invalid cHRM white point specified"); png_warning(png_ptr, "Invalid cHRM white point specified");
#if !defined(PNG_NO_STDIO) #if !defined(PNG_NO_CONSOLE_IO)
printf("white_x=%f, white_y=%f\n",white_x, white_y); fprintf(stderr,"white_x=%f, white_y=%f\n",white_x, white_y);
#endif #endif
return; return;
} }
@@ -842,7 +893,7 @@ png_write_cHRM(png_structp png_ptr, double white_x, double white_y,
} }
#endif #endif
#ifdef PNG_FIXED_POINT_SUPPORTED #ifdef PNG_FIXED_POINT_SUPPORTED
void void /* PRIVATE */
png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x, png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y, png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y,
png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x, png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x,
@@ -858,8 +909,8 @@ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
if (white_x > 80000L || white_y > 80000L || white_x + white_y > 100000L) if (white_x > 80000L || white_y > 80000L || white_x + white_y > 100000L)
{ {
png_warning(png_ptr, "Invalid fixed cHRM white point specified"); png_warning(png_ptr, "Invalid fixed cHRM white point specified");
#if !defined(PNG_NO_STDIO) #if !defined(PNG_NO_CONSOLE_IO)
printf("white_x=%ld, white_y=%ld\n",white_x, white_y); fprintf(stderr,"white_x=%ld, white_y=%ld\n",white_x, white_y);
#endif #endif
return; return;
} }
@@ -897,7 +948,7 @@ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
#if defined(PNG_WRITE_tRNS_SUPPORTED) #if defined(PNG_WRITE_tRNS_SUPPORTED)
/* write the tRNS chunk */ /* write the tRNS chunk */
void void /* PRIVATE */
png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran, png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
int num_trans, int color_type) int num_trans, int color_type)
{ {
@@ -940,7 +991,7 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
#if defined(PNG_WRITE_bKGD_SUPPORTED) #if defined(PNG_WRITE_bKGD_SUPPORTED)
/* write the background chunk */ /* write the background chunk */
void void /* PRIVATE */
png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type) png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -952,9 +1003,9 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
if (color_type == PNG_COLOR_TYPE_PALETTE) if (color_type == PNG_COLOR_TYPE_PALETTE)
{ {
if ( if (
#ifdef PNG_WRITE_EMPTY_PLTE_SUPPORTED #if defined(PNG_MNG_FEATURES_SUPPORTED)
(!png_ptr->empty_plte_permitted || (png_ptr->num_palette ||
(png_ptr->empty_plte_permitted && png_ptr->num_palette)) && (!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) &&
#endif #endif
back->index > png_ptr->num_palette) back->index > png_ptr->num_palette)
{ {
@@ -981,7 +1032,7 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
#if defined(PNG_WRITE_hIST_SUPPORTED) #if defined(PNG_WRITE_hIST_SUPPORTED)
/* write the histogram */ /* write the histogram */
void void /* PRIVATE */
png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist) png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -1021,38 +1072,39 @@ png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)
* by the calling routine. This avoids problems with trying to write to * by the calling routine. This avoids problems with trying to write to
* static keywords without having to have duplicate copies of the strings. * static keywords without having to have duplicate copies of the strings.
*/ */
png_size_t png_size_t /* PRIVATE */
png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key) png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
{ {
png_size_t key_len; png_size_t key_len;
png_charp kp, dp; png_charp kp, dp;
int kflag; int kflag;
int kwarn=0;
png_debug(1, "in png_check_keyword\n"); png_debug(1, "in png_check_keyword\n");
*new_key = NULL; *new_key = NULL;
if (key == NULL || (key_len = png_strlen(key)) == 0) if (key == NULL || (key_len = png_strlen(key)) == 0)
{ {
png_chunk_warning(png_ptr, "zero length keyword"); png_warning(png_ptr, "zero length keyword");
return ((png_size_t)0); return ((png_size_t)0);
} }
png_debug1(2, "Keyword to be checked is '%s'\n", key); png_debug1(2, "Keyword to be checked is '%s'\n", key);
*new_key = (png_charp)png_malloc(png_ptr, (png_uint_32)(key_len + 1)); *new_key = (png_charp)png_malloc(png_ptr, (png_uint_32)(key_len + 2));
/* Replace non-printing characters with a blank and print a warning */ /* Replace non-printing characters with a blank and print a warning */
for (kp = key, dp = *new_key; *kp != '\0'; kp++, dp++) for (kp = key, dp = *new_key; *kp != '\0'; kp++, dp++)
{ {
if (*kp < 0x20 || (*kp > 0x7E && (png_byte)*kp < 0xA1)) if (*kp < 0x20 || (*kp > 0x7E && (png_byte)*kp < 0xA1))
{ {
#if !defined(PNG_NO_STDIO) #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
char msg[40]; char msg[40];
sprintf(msg, "invalid keyword character 0x%02X", *kp); sprintf(msg, "invalid keyword character 0x%02X", *kp);
png_chunk_warning(png_ptr, msg); png_warning(png_ptr, msg);
#else #else
png_chunk_warning(png_ptr, "invalid character in keyword"); png_warning(png_ptr, "invalid character in keyword");
#endif #endif
*dp = ' '; *dp = ' ';
} }
@@ -1067,7 +1119,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
kp = *new_key + key_len - 1; kp = *new_key + key_len - 1;
if (*kp == ' ') if (*kp == ' ')
{ {
png_chunk_warning(png_ptr, "trailing spaces removed from keyword"); png_warning(png_ptr, "trailing spaces removed from keyword");
while (*kp == ' ') while (*kp == ' ')
{ {
@@ -1080,7 +1132,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
kp = *new_key; kp = *new_key;
if (*kp == ' ') if (*kp == ' ')
{ {
png_chunk_warning(png_ptr, "leading spaces removed from keyword"); png_warning(png_ptr, "leading spaces removed from keyword");
while (*kp == ' ') while (*kp == ' ')
{ {
@@ -1102,6 +1154,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
else if (*kp == ' ') else if (*kp == ' ')
{ {
key_len--; key_len--;
kwarn=1;
} }
else else
{ {
@@ -1110,17 +1163,19 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
} }
} }
*dp = '\0'; *dp = '\0';
if(kwarn)
png_warning(png_ptr, "extra interior spaces removed from keyword");
if (key_len == 0) if (key_len == 0)
{ {
png_free(png_ptr, *new_key); png_free(png_ptr, *new_key);
*new_key=NULL; *new_key=NULL;
png_chunk_warning(png_ptr, "Zero length keyword"); png_warning(png_ptr, "Zero length keyword");
} }
if (key_len > 79) if (key_len > 79)
{ {
png_chunk_warning(png_ptr, "keyword length must be 1 - 79 characters"); png_warning(png_ptr, "keyword length must be 1 - 79 characters");
new_key[79] = '\0'; new_key[79] = '\0';
key_len = 79; key_len = 79;
} }
@@ -1131,7 +1186,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
#if defined(PNG_WRITE_tEXt_SUPPORTED) #if defined(PNG_WRITE_tEXt_SUPPORTED)
/* write a tEXt chunk */ /* write a tEXt chunk */
void void /* PRIVATE */
png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text, png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,
png_size_t text_len) png_size_t text_len)
{ {
@@ -1172,7 +1227,7 @@ png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,
#if defined(PNG_WRITE_zTXt_SUPPORTED) #if defined(PNG_WRITE_zTXt_SUPPORTED)
/* write a compressed text chunk */ /* write a compressed text chunk */
void void /* PRIVATE */
png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text, png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
png_size_t text_len, int compression) png_size_t text_len, int compression)
{ {
@@ -1204,7 +1259,8 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
png_free(png_ptr, new_key); png_free(png_ptr, new_key);
/* compute the compressed data; do it now for the length */ /* compute the compressed data; do it now for the length */
text_len = png_text_compress(png_ptr, text, text_len, compression, &comp); text_len = png_text_compress(png_ptr, text, text_len, compression,
&comp);
/* write start of chunk */ /* write start of chunk */
png_write_chunk_start(png_ptr, (png_bytep)png_zTXt, (png_uint_32) png_write_chunk_start(png_ptr, (png_bytep)png_zTXt, (png_uint_32)
@@ -1224,7 +1280,7 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
#if defined(PNG_WRITE_iTXt_SUPPORTED) #if defined(PNG_WRITE_iTXt_SUPPORTED)
/* write an iTXt chunk */ /* write an iTXt chunk */
void void /* PRIVATE */
png_write_iTXt(png_structp png_ptr, int compression, png_charp key, png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
png_charp lang, png_charp lang_key, png_charp text) png_charp lang, png_charp lang_key, png_charp text)
{ {
@@ -1256,7 +1312,8 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
text_len = 0; text_len = 0;
/* compute the compressed data; do it now for the length */ /* compute the compressed data; do it now for the length */
text_len = png_text_compress(png_ptr, text, text_len, compression-2, &comp); text_len = png_text_compress(png_ptr, text, text_len, compression-2,
&comp);
/* make sure we include the compression flag, the compression byte, /* make sure we include the compression flag, the compression byte,
* and the NULs after the key, lang, and lang_key parts */ * and the NULs after the key, lang, and lang_key parts */
@@ -1301,7 +1358,7 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
#if defined(PNG_WRITE_oFFs_SUPPORTED) #if defined(PNG_WRITE_oFFs_SUPPORTED)
/* write the oFFs chunk */ /* write the oFFs chunk */
void void /* PRIVATE */
png_write_oFFs(png_structp png_ptr, png_uint_32 x_offset, png_write_oFFs(png_structp png_ptr, png_uint_32 x_offset,
png_uint_32 y_offset, png_uint_32 y_offset,
int unit_type) int unit_type)
@@ -1324,8 +1381,8 @@ png_write_oFFs(png_structp png_ptr, png_uint_32 x_offset,
#endif #endif
#if defined(PNG_WRITE_pCAL_SUPPORTED) #if defined(PNG_WRITE_pCAL_SUPPORTED)
/* write the pCAL chunk (png-scivis-19970203) */ /* write the pCAL chunk (described in the PNG extensions document) */
void void /* PRIVATE */
png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0, png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
png_int_32 X1, int type, int nparams, png_charp units, png_charpp params) png_int_32 X1, int type, int nparams, png_charp units, png_charpp params)
{ {
@@ -1356,7 +1413,7 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
for (i = 0; i < nparams; i++) for (i = 0; i < nparams; i++)
{ {
params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1); params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1);
png_debug2(3, "pCAL parameter %d length = %d\n", i, params_len[i]); png_debug2(3, "pCAL parameter %d length = %lu\n", i, params_len[i]);
total_len += (png_size_t)params_len[i]; total_len += (png_size_t)params_len[i];
} }
@@ -1386,7 +1443,7 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
#if defined(PNG_WRITE_sCAL_SUPPORTED) #if defined(PNG_WRITE_sCAL_SUPPORTED)
/* write the sCAL chunk */ /* write the sCAL chunk */
#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) #if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO)
void void /* PRIVATE */
png_write_sCAL(png_structp png_ptr, int unit, double width,double height) png_write_sCAL(png_structp png_ptr, int unit, double width,double height)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -1397,8 +1454,19 @@ png_write_sCAL(png_structp png_ptr, int unit, double width,double height)
png_debug(1, "in png_write_sCAL\n"); png_debug(1, "in png_write_sCAL\n");
#if defined(_WIN32_WCE)
/* sprintf() function is not supported on WindowsCE */
{
wchar_t wc_buf[32];
swprintf(wc_buf, TEXT("%12.12e"), width);
WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, wbuf, 32, NULL, NULL);
swprintf(wc_buf, TEXT("%12.12e"), height);
WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, hbuf, 32, NULL, NULL);
}
#else
sprintf(wbuf, "%12.12e", width); sprintf(wbuf, "%12.12e", width);
sprintf(hbuf, "%12.12e", height); sprintf(hbuf, "%12.12e", height);
#endif
total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf); total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf);
png_debug1(3, "sCAL total length = %d\n", total_len); png_debug1(3, "sCAL total length = %d\n", total_len);
@@ -1411,7 +1479,7 @@ png_write_sCAL(png_structp png_ptr, int unit, double width,double height)
} }
#else #else
#ifdef PNG_FIXED_POINT_SUPPORTED #ifdef PNG_FIXED_POINT_SUPPORTED
void void /* PRIVATE */
png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width, png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width,
png_charp height) png_charp height)
{ {
@@ -1441,7 +1509,7 @@ png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width,
#if defined(PNG_WRITE_pHYs_SUPPORTED) #if defined(PNG_WRITE_pHYs_SUPPORTED)
/* write the pHYs chunk */ /* write the pHYs chunk */
void void /* PRIVATE */
png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit, png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit,
png_uint_32 y_pixels_per_unit, png_uint_32 y_pixels_per_unit,
int unit_type) int unit_type)
@@ -1467,7 +1535,7 @@ png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit,
/* Write the tIME chunk. Use either png_convert_from_struct_tm() /* Write the tIME chunk. Use either png_convert_from_struct_tm()
* or png_convert_from_time_t(), or fill in the structure yourself. * or png_convert_from_time_t(), or fill in the structure yourself.
*/ */
void void /* PRIVATE */
png_write_tIME(png_structp png_ptr, png_timep mod_time) png_write_tIME(png_structp png_ptr, png_timep mod_time)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -1496,7 +1564,7 @@ png_write_tIME(png_structp png_ptr, png_timep mod_time)
#endif #endif
/* initializes the row writing capability of libpng */ /* initializes the row writing capability of libpng */
void void /* PRIVATE */
png_write_start_row(png_structp png_ptr) png_write_start_row(png_structp png_ptr)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -1590,7 +1658,7 @@ png_write_start_row(png_structp png_ptr)
} }
/* Internal use only. Called when finished processing a row of data. */ /* Internal use only. Called when finished processing a row of data. */
void void /* PRIVATE */
png_write_finish_row(png_structp png_ptr) png_write_finish_row(png_structp png_ptr)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -1670,20 +1738,23 @@ png_write_finish_row(png_structp png_ptr)
/* tell the compressor we are done */ /* tell the compressor we are done */
ret = deflate(&png_ptr->zstream, Z_FINISH); ret = deflate(&png_ptr->zstream, Z_FINISH);
/* check for an error */ /* check for an error */
if (ret != Z_OK && ret != Z_STREAM_END) if (ret == Z_OK)
{
/* check to see if we need more room */
if (!(png_ptr->zstream.avail_out))
{
png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);
png_ptr->zstream.next_out = png_ptr->zbuf;
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
}
}
else if (ret != Z_STREAM_END)
{ {
if (png_ptr->zstream.msg != NULL) if (png_ptr->zstream.msg != NULL)
png_error(png_ptr, png_ptr->zstream.msg); png_error(png_ptr, png_ptr->zstream.msg);
else else
png_error(png_ptr, "zlib error"); png_error(png_ptr, "zlib error");
} }
/* check to see if we need more room */
if (!(png_ptr->zstream.avail_out) && ret == Z_OK)
{
png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);
png_ptr->zstream.next_out = png_ptr->zbuf;
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
}
} while (ret != Z_STREAM_END); } while (ret != Z_STREAM_END);
/* write any extra space */ /* write any extra space */
@@ -1704,7 +1775,7 @@ png_write_finish_row(png_structp png_ptr)
* sp will always be >= dp, so we should never overwrite anything. * sp will always be >= dp, so we should never overwrite anything.
* See the default: case for the easiest code to understand. * See the default: case for the easiest code to understand.
*/ */
void void /* PRIVATE */
png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -1875,7 +1946,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
#define PNG_HISHIFT 10 #define PNG_HISHIFT 10
#define PNG_LOMASK ((png_uint_32)0xffffL) #define PNG_LOMASK ((png_uint_32)0xffffL)
#define PNG_HIMASK ((png_uint_32)(~PNG_LOMASK >> PNG_HISHIFT)) #define PNG_HIMASK ((png_uint_32)(~PNG_LOMASK >> PNG_HISHIFT))
void void /* PRIVATE */
png_write_find_filter(png_structp png_ptr, png_row_infop row_info) png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
{ {
png_bytep prev_row, best_row, row_buf; png_bytep prev_row, best_row, row_buf;
@@ -2487,12 +2558,13 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
/* Do the actual writing of a previously filtered row. */ /* Do the actual writing of a previously filtered row. */
void void /* PRIVATE */
png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row) png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row)
{ {
png_debug(1, "in png_write_filtered_row\n"); png_debug(1, "in png_write_filtered_row\n");
png_debug1(2, "filter = %d\n", filtered_row[0]); png_debug1(2, "filter = %d\n", filtered_row[0]);
/* set up the zlib input buffer */ /* set up the zlib input buffer */
png_ptr->zstream.next_in = filtered_row; png_ptr->zstream.next_in = filtered_row;
png_ptr->zstream.avail_in = (uInt)png_ptr->row_info.rowbytes + 1; png_ptr->zstream.avail_in = (uInt)png_ptr->row_info.rowbytes + 1;
/* repeat until we have compressed all the data */ /* repeat until we have compressed all the data */

View File

@@ -0,0 +1,22 @@
USEUNIT("libpng.cpp");
USEUNIT("..\..\pngwutil.c");
USEUNIT("..\..\pngerror.c");
USEUNIT("..\..\pngget.c");
USEUNIT("..\..\pngmem.c");
USEUNIT("..\..\pngpread.c");
USEUNIT("..\..\pngread.c");
USEUNIT("..\..\pngrio.c");
USEUNIT("..\..\pngrtran.c");
USEUNIT("..\..\pngrutil.c");
USEUNIT("..\..\pngset.c");
USEUNIT("..\..\pngtrans.c");
USEUNIT("..\..\pngwio.c");
USEUNIT("..\..\pngwrite.c");
USEUNIT("..\..\pngwtran.c");
USEUNIT("..\..\png.c");
USELIB("zlib.lib");
//---------------------------------------------------------------------------
This file is used by the project manager only and should be treated like the project file
DllEntryPoint

View File

@@ -0,0 +1,25 @@
#------------------------------------------------------------------------------
VERSION = BWS.01
#------------------------------------------------------------------------------
!ifndef ROOT
ROOT = $(MAKEDIR)\..
!endif
#------------------------------------------------------------------------------
MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$**
DCC = $(ROOT)\bin\dcc32.exe $**
BRCC = $(ROOT)\bin\brcc32.exe $**
#------------------------------------------------------------------------------
PROJECTS = libpngstat.lib libpng.dll
#------------------------------------------------------------------------------
default: $(PROJECTS)
#------------------------------------------------------------------------------
libpngstat.lib: libpngstat.bpr
$(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $**
$(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak
libpng.dll: libpng.bpr
$(ROOT)\bin\bpr2mak $**
$(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak

157
projects/borland/libpng.bpr Normal file
View File

@@ -0,0 +1,157 @@
<?xml version='1.0' encoding='utf-8' ?>
<!-- C++Builder XML Project -->
<PROJECT>
<MACROS>
<VERSION value="BCB.05.03"/>
<PROJECT value="libpng.dll"/>
<OBJFILES value="libpng.obj ..\..\pngwutil.obj ..\..\pngerror.obj ..\..\pngget.obj
..\..\pngmem.obj ..\..\pngpread.obj ..\..\pngread.obj ..\..\pngrio.obj
..\..\pngrtran.obj ..\..\pngrutil.obj ..\..\pngset.obj ..\..\pngtrans.obj
..\..\pngwio.obj ..\..\pngwrite.obj ..\..\pngwtran.obj ..\..\png.obj"/>
<RESFILES value=""/>
<DEFFILE value=""/>
<RESDEPEN value="$(RESFILES)"/>
<LIBFILES value="zlib.lib"/>
<LIBRARIES value="bcbsmp50.lib dclocx50.lib NMFast50.lib Tee50.lib Vclx50.lib Vcl50.lib"/>
<SPARELIBS value="Vcl50.lib Vclx50.lib Tee50.lib NMFast50.lib dclocx50.lib bcbsmp50.lib"/>
<PACKAGES value="Vcl50.bpi Vclx50.bpi bcbsmp50.bpi Qrpt50.bpi Vcldb50.bpi Vclbde50.bpi
ibsmp50.bpi vcldbx50.bpi TeeUI50.bpi TeeDB50.bpi Tee50.bpi TeeQR50.bpi
VCLIB50.bpi bcbie50.bpi vclie50.bpi Inetdb50.bpi Inet50.bpi NMFast50.bpi
dclocx50.bpi bcb97axserver50.bpi SIMULUSCOMPONENTS.bpi Simulus2.bpi"/>
<PATHCPP value=".;..\.."/>
<PATHPAS value=".;"/>
<PATHRC value=".;"/>
<PATHASM value=".;"/>
<DEBUGLIBPATH value="$(BCB)\lib\debug"/>
<RELEASELIBPATH value="$(BCB)\lib\release"/>
<LINKER value="tlink32"/>
<USERDEFINES value="ZLIB_DLL;Z_PREFIX;PNG_BUILD_DLL;PNG_NO_MODULEDEF"/>
<SYSDEFINES value="NO_STRICT;_NO_VCL;_RTLDLL"/>
<MAINSOURCE value="libpng.bpf"/>
<INCLUDEPATH value="..\..;..\..\..\zlib;$(BCB)\include"/>
<LIBPATH value="..\..;$(BCB)\lib\obj;$(BCB)\lib"/>
<WARNINGS value="-w8092 -w8091 -w8090 -w8089 -w8087 -wprc -wucp -wstv -wstu -wsig -wpin
-wnod -wnak -wdef -wcln -wbbf -wasm -wamp -wamb"/>
</MACROS>
<OPTIONS>
<CFLAG1 value="-WD -O2 -w -Vx -Ve -x- -RT- -X- -a8 -5 -b- -d -k- -vi -tWD -tWM -c"/>
<PFLAGS value="-$Y- -$L- -$D- -$C- -v -JPHNE -M"/>
<RFLAGS value=""/>
<AFLAGS value="/mx /w2 /zn"/>
<LFLAGS value="-D&quot;&quot; -aa -Tpd -x -Gn -Gi -w"/>
</OPTIONS>
<LINKER>
<ALLOBJ value="c0d32.obj $(OBJFILES)"/>
<ALLRES value="$(RESFILES)"/>
<ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32mti.lib"/>
</LINKER>
<IDEOPTIONS>
[Version Info]
IncludeVerInfo=0
AutoIncBuild=0
MajorVer=1
MinorVer=0
Release=0
Build=0
Debug=0
PreRelease=0
Special=0
Private=0
DLL=1
Locale=2057
CodePage=1252
[Version Info Keys]
CompanyName=
FileDescription=
FileVersion=1.0.0.0
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=
Comments=
[HistoryLists\hlIncludePath]
Count=18
Item0=..\..;..\..\..\zlib;$(BCB)\include
Item1=..\..;P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\include
Item2=..\..;..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression\external;$(BCB)\include
Item3=..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression\external;$(BCB)\include
Item4=..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression;$(BCB)\include
Item5=..\Source\ThirdParty\PortableNetworkGraphics;..\Source\ThirdParty\ZLibCompression;$(BCB)\include
Item6=..\Source\ThirdParty\PortableNetworkGraphics;P:\Development\Source\ThirdParty\ZLibCompression;$(BCB)\include
Item7=..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\include
Item8=$(BCB)\include
Item9=..\Source;..\Source\General\Templates;..\Source\SIMUtilities;$(BCB)\include;$(BCB)\include\vcl
Item10=P:\Development\Source\;P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl
Item11=P:\Development\Source;P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl
Item12=P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl
Item13=P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities;$(BCB)\include;$(BCB)\include\vcl
Item14=P:\Development\Source\General\Templates\;$(BCB)\include;$(BCB)\include\vcl
Item15=P:\Development\Source\General\Templates;$(BCB)\include;$(BCB)\include\vcl
Item16=P:\Development\Source;$(BCB)\include;$(BCB)\include\vcl
Item17=$(BCB)\include;$(BCB)\include\vcl
[HistoryLists\hlLibraryPath]
Count=10
Item0=..\..;$(BCB)\lib\obj;$(BCB)\lib
Item1=..\..;..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\lib\obj;$(BCB)\lib
Item2=..\Source\ThirdParty\PortableNetworkGraphics\external;..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\lib\obj;$(BCB)\lib
Item3=..\Source\ThirdParty\PortableNetworkGraphics;$(BCB)\lib\obj;$(BCB)\lib
Item4=$(BCB)\lib\obj;$(BCB)\lib
Item5=..\Source\SIMUtilities;..\Source;$(BCB)\lib\obj;$(BCB)\lib
Item6=P:\Development\Source\SIMUtilities\;P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib
Item7=P:\Development\Source\SIMUtilities;P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib
Item8=P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib
Item9=P:\Development\Source;$(BCB)\lib\obj;$(BCB)\lib
[HistoryLists\hlDebugSourcePath]
Count=1
Item0=$(BCB)\source\vcl
[HistoryLists\hlConditionals]
Count=20
Item0=ZLIB_DLL;Z_PREFIX;PNG_BUILD_DLL;PNG_NO_MODULEDEF
Item1=_DEBUG;ZLIB_DLL;Z_PREFIX;PNG_BUILD_DLL;PNG_NO_MODULEDEF
Item2=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_NO_MODULEDEF
Item3=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF;PNG_NO_GLOBAL_ARRAYS
Item4=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF;PNG_SETJMP_NOT_SUPPORTED;PNG_DEBUG_FILE=stderr
Item5=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG;PNG_NO_MODULEDEF;PNG_SETJMP_NOT_SUPPORTED
Item6=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF;PNG_SETJMP_NOT_SUPPORTED
Item7=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5;PNG_NO_MODULEDEF
Item8=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG;PNG_DEBUG=5
Item9=PNG_BUILD_DLL;ZLIB_DLL;_DEBUG
Item10=PNG_BUILD_DLL;ZLIB_DLL
Item11=PNG_BUILD_DLL
Item12=PNG_DLL;PNG_BUILD_DLL;ZLIB_DLL
Item13=PNG_DLL;PNG_BUILD_DLL;PNG_NO_GLOBAL_ARRAYS;ZLIB_DLL
Item14=PNG_DLL;PNG_BUILD_DLL;PNG_NO_GLOBAL_ARRAYS
Item15=PNG_DLL;PNG_BUILD_DLL
Item16=PNG_DLL;PNG_BUILD_DLL;PNG_MODULEDEF
Item17=_HTML_FORM
Item18=_DEBUG;_HTML_FORM
Item19=_DEBUG
[HistoryLists\hlIntOutputDir]
Count=2
Item0=..\Obj
Item1=P:\Development\Obj
[Debugging]
DebugSourceDirs=
[Parameters]
RunParams=
HostApplication=P:\Development\Executables\LibPNGTestApp.exe
RemoteHost=
RemotePath=
RemoteDebug=0
[Compiler]
ShowInfoMsgs=0
LinkDebugVcl=0
LinkCGLIB=0
</IDEOPTIONS>
</PROJECT>

View File

@@ -0,0 +1,29 @@
//---------------------------------------------------------------------------
#include <windows.h>
//---------------------------------------------------------------------------
// Important note about DLL memory management when your DLL uses the
// static version of the RunTime Library:
//
// If your DLL exports any functions that pass String objects (or structs/
// classes containing nested Strings) as parameter or function results,
// you will need to add the library MEMMGR.LIB to both the DLL project and
// any other projects that use the DLL. You will also need to use MEMMGR.LIB
// if any other projects which use the DLL will be performing new or delete
// operations on any non-TObject-derived classes which are exported from the
// DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
// EXE's to use the BORLNDMM.DLL as their memory manager. In these cases,
// the file BORLNDMM.DLL should be deployed along with your DLL.
//
// To avoid using BORLNDMM.DLL, pass string information using "char *" or
// ShortString parameters.
//
// If your DLL uses the dynamic version of the RTL, you do not need to
// explicitly add MEMMGR.LIB as this will be done implicitly for you
//---------------------------------------------------------------------------
int WINAPI DllEntryPoint(HINSTANCE, unsigned long, void*)
{
return 1;
}
//---------------------------------------------------------------------------

View File

@@ -0,0 +1,19 @@
Project files to build libpng using Borland C++ Builder v5.0
To use this dll, you will need to:
1) add the following conditional defines to your project
PNG_USE_DLL
Z_PREFIX
2) add the paths to png.h and zlib.h to your include path
3) add libpng.lib or libpngstat.lib to the project.
If you are using libpng.dll, libpng.dll and zlib.dll will be required for the code to run.
Alternatively, the libpng.dll can be built using zlibstat.lib to produce one dll containing both the zlib and png code.
See the libpng documentation for instructions on how to use the code.

View File

@@ -0,0 +1,22 @@
USELIB("zlibstat.lib");
USEUNIT("..\..\pngerror.c");
USEUNIT("..\..\png.c");
USEUNIT("..\..\pngwutil.c");
USEUNIT("..\..\pngmem.c");
USEUNIT("..\..\pngpread.c");
USEUNIT("..\..\pngread.c");
USEUNIT("..\..\pngrio.c");
USEUNIT("..\..\pngrtran.c");
USEUNIT("..\..\pngrutil.c");
USEUNIT("..\..\pngset.c");
USEUNIT("..\..\pngtrans.c");
USEUNIT("..\..\pngwio.c");
USEUNIT("..\..\pngwrite.c");
USEUNIT("..\..\pngwtran.c");
USEUNIT("..\..\pngget.c");
//---------------------------------------------------------------------------
#define Library
// To add a file to the library use the Project menu 'Add to Project'.

View File

@@ -0,0 +1,109 @@
<?xml version='1.0' encoding='utf-8' ?>
<!-- C++Builder XML Project -->
<PROJECT>
<MACROS>
<VERSION value="BCB.05.03"/>
<PROJECT value="libpngstat.lib"/>
<OBJFILES value="..\..\pngerror.obj ..\..\png.obj ..\..\pngwutil.obj ..\..\pngmem.obj
..\..\pngpread.obj ..\..\pngread.obj ..\..\pngrio.obj ..\..\pngrtran.obj
..\..\pngrutil.obj ..\..\pngset.obj ..\..\pngtrans.obj ..\..\pngwio.obj
..\..\pngwrite.obj ..\..\pngwtran.obj ..\..\pngget.obj"/>
<RESFILES value=""/>
<DEFFILE value=""/>
<RESDEPEN value="$(RESFILES)"/>
<LIBFILES value="zlibstat.lib"/>
<LIBRARIES value=""/>
<PACKAGES value=""/>
<PATHCPP value=".;..\.."/>
<PATHPAS value=".;"/>
<PATHRC value=".;"/>
<PATHASM value=".;"/>
<LINKER value="TLib"/>
<USERDEFINES value=""/>
<SYSDEFINES value="_RTLDLL;NO_STRICT"/>
<MAINSOURCE value="libpngstat.bpf"/>
<INCLUDEPATH value="..\..;..\..\..\zlib;$(BCB)\include"/>
<LIBPATH value="..\..;$(BCB)\lib\obj;$(BCB)\lib"/>
<WARNINGS value="-w-par"/>
<LISTFILE value=""/>
</MACROS>
<OPTIONS>
<CFLAG1 value="-O2 -w -Vx -Ve -X- -a8 -5 -b- -d -k- -vi -c -tW -tWM"/>
<PFLAGS value="-$Y- -$L- -$D- -$C- -v -JPHNE -M"/>
<AFLAGS value="/mx /w2 /zn"/>
<LFLAGS value=""/>
</OPTIONS>
<LINKER>
<ALLOBJ value="$(OBJFILES)"/>
<ALLLIB value=""/>
</LINKER>
<IDEOPTIONS>
[Version Info]
IncludeVerInfo=0
AutoIncBuild=0
MajorVer=1
MinorVer=0
Release=0
Build=0
Debug=0
PreRelease=0
Special=0
Private=0
DLL=0
Locale=2057
CodePage=1252
[Version Info Keys]
CompanyName=
FileDescription=
FileVersion=1.0.0.0
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=1.0.0.0
Comments=
[HistoryLists\hlIncludePath]
Count=2
Item0=..\..;P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\include
Item1=..\..;$(BCB)\include;$(BCB)\include\vcl
[HistoryLists\hlLibraryPath]
Count=1
Item0=..\..;$(BCB)\lib\obj;$(BCB)\lib
[HistoryLists\hlDebugSourcePath]
Count=1
Item0=$(BCB)\source\vcl
[HistoryLists\hlConditionals]
Count=1
Item0=_DEBUG
[HistoryLists\hlTlibPageSize]
Count=1
Item0=0x0010
[Debugging]
DebugSourceDirs=$(BCB)\source\vcl
[Parameters]
RunParams=
HostApplication=
RemoteHost=
RemotePath=
RemoteDebug=0
[Compiler]
ShowInfoMsgs=0
LinkDebugVcl=0
LinkCGLIB=0
[Language]
ActiveLang=
ProjectLang=
RootDir=
</IDEOPTIONS>
</PROJECT>

View File

@@ -0,0 +1,33 @@
#------------------------------------------------------------------------------
VERSION = BWS.01
#------------------------------------------------------------------------------
!ifndef ROOT
ROOT = $(MAKEDIR)\..
!endif
#------------------------------------------------------------------------------
MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$**
DCC = $(ROOT)\bin\dcc32.exe $**
BRCC = $(ROOT)\bin\brcc32.exe $**
#------------------------------------------------------------------------------
PROJECTS = zlibstat.lib libpngstat.lib zlib.dll libpng.dll
#------------------------------------------------------------------------------
default: $(PROJECTS)
#------------------------------------------------------------------------------
libpng.dll: libpng.bpr
$(ROOT)\bin\bpr2mak $**
$(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak
zlibstat.lib: zlibstat.bpr
$(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $**
$(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak
zlib.dll: zlib.bpr
$(ROOT)\bin\bpr2mak $**
$(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak
libpngstat.lib: libpngstat.bpr
$(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $**
$(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak

20
projects/borland/zlib.bpf Normal file
View File

@@ -0,0 +1,20 @@
USEUNIT("zlib.cpp");
USEUNIT("..\..\..\zlib\zutil.c");
USEUNIT("..\..\..\zlib\compress.c");
USEUNIT("..\..\..\zlib\crc32.c");
USEUNIT("..\..\..\zlib\deflate.c");
USEUNIT("..\..\..\zlib\gzio.c");
USEUNIT("..\..\..\zlib\infblock.c");
USEUNIT("..\..\..\zlib\infcodes.c");
USEUNIT("..\..\..\zlib\inffast.c");
USEUNIT("..\..\..\zlib\inflate.c");
USEUNIT("..\..\..\zlib\inftrees.c");
USEUNIT("..\..\..\zlib\infutil.c");
USEUNIT("..\..\..\zlib\trees.c");
USEUNIT("..\..\..\zlib\uncompr.c");
USEUNIT("..\..\..\zlib\adler32.c");
//---------------------------------------------------------------------------
This file is used by the project manager only and should be treated like the project file
DllEntryPoint

25
projects/borland/zlib.bpg Normal file
View File

@@ -0,0 +1,25 @@
#------------------------------------------------------------------------------
VERSION = BWS.01
#------------------------------------------------------------------------------
!ifndef ROOT
ROOT = $(MAKEDIR)\..
!endif
#------------------------------------------------------------------------------
MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$**
DCC = $(ROOT)\bin\dcc32.exe $**
BRCC = $(ROOT)\bin\brcc32.exe $**
#------------------------------------------------------------------------------
PROJECTS = zlibstat.lib zlib.dll
#------------------------------------------------------------------------------
default: $(PROJECTS)
#------------------------------------------------------------------------------
zlibstat.lib: zlibstat.bpr
$(ROOT)\bin\bpr2mak -t$(ROOT)\bin\deflib.bmk $**
$(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak
zlib.dll: zlib.bpr
$(ROOT)\bin\bpr2mak $**
$(ROOT)\bin\make -$(MAKEFLAGS) -f$*.mak

147
projects/borland/zlib.bpr Normal file
View File

@@ -0,0 +1,147 @@
<?xml version='1.0' encoding='utf-8' ?>
<!-- C++Builder XML Project -->
<PROJECT>
<MACROS>
<VERSION value="BCB.05.03"/>
<PROJECT value="zlib.dll"/>
<OBJFILES value="zlib.obj ..\..\..\zlib\zutil.obj ..\..\..\zlib\compress.obj
..\..\..\zlib\crc32.obj ..\..\..\zlib\deflate.obj ..\..\..\zlib\gzio.obj
..\..\..\zlib\infblock.obj ..\..\..\zlib\infcodes.obj
..\..\..\zlib\inffast.obj ..\..\..\zlib\inflate.obj
..\..\..\zlib\inftrees.obj ..\..\..\zlib\infutil.obj
..\..\..\zlib\trees.obj ..\..\..\zlib\uncompr.obj ..\..\..\zlib\adler32.obj"/>
<RESFILES value=""/>
<DEFFILE value=""/>
<RESDEPEN value="$(RESFILES)"/>
<LIBFILES value=""/>
<LIBRARIES value="bcbsmp50.lib dclocx50.lib NMFast50.lib Tee50.lib Vclx50.lib Vcl50.lib"/>
<SPARELIBS value="Vcl50.lib Vclx50.lib Tee50.lib NMFast50.lib dclocx50.lib bcbsmp50.lib"/>
<PACKAGES value="Vcl50.bpi Vclx50.bpi bcbsmp50.bpi Qrpt50.bpi Vcldb50.bpi Vclbde50.bpi
ibsmp50.bpi vcldbx50.bpi TeeUI50.bpi TeeDB50.bpi Tee50.bpi TeeQR50.bpi
VCLIB50.bpi bcbie50.bpi vclie50.bpi Inetdb50.bpi Inet50.bpi NMFast50.bpi
dclocx50.bpi bcb97axserver50.bpi SIMULUSCOMPONENTS.bpi Simulus2.bpi"/>
<PATHCPP value=".;..\..\..\zlib"/>
<PATHPAS value=".;"/>
<PATHRC value=".;"/>
<PATHASM value=".;"/>
<DEBUGLIBPATH value="$(BCB)\lib\debug"/>
<RELEASELIBPATH value="$(BCB)\lib\release"/>
<LINKER value="tlink32"/>
<USERDEFINES value="ZLIB_DLL;Z_PREFIX"/>
<SYSDEFINES value="NO_STRICT;_NO_VCL;_RTLDLL"/>
<MAINSOURCE value="zlib.bpf"/>
<INCLUDEPATH value="..\..\..\zlib;$(BCB)\include"/>
<LIBPATH value="..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib"/>
<WARNINGS value="-w8092 -w8091 -w8090 -w8089 -w8087 -wprc -wuse -wucp -wstv -wstu -wpin
-w-par -wnod -wnak -wdef -wcln -wbbf -w-aus -wasm -wamp -wamb"/>
</MACROS>
<OPTIONS>
<CFLAG1 value="-WD -O2 -w -Vx -Ve -x- -RT- -ff -X- -a8 -5 -b- -d -k- -vi -tWD -tWM -c"/>
<PFLAGS value="-$Y- -$L- -$D- -$C- -v -JPHNE -M"/>
<RFLAGS value=""/>
<AFLAGS value="/mx /w2 /zn"/>
<LFLAGS value="-D&quot;&quot; -aa -Tpd -x -Gn -Gi -w"/>
</OPTIONS>
<LINKER>
<ALLOBJ value="c0d32.obj $(OBJFILES)"/>
<ALLRES value="$(RESFILES)"/>
<ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cw32mti.lib"/>
</LINKER>
<IDEOPTIONS>
[Version Info]
IncludeVerInfo=0
AutoIncBuild=0
MajorVer=1
MinorVer=0
Release=0
Build=0
Debug=0
PreRelease=0
Special=0
Private=0
DLL=1
Locale=2057
CodePage=1252
[Version Info Keys]
CompanyName=
FileDescription=
FileVersion=1.0.0.0
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=1.0.0.0
Comments=
[HistoryLists\hlIncludePath]
Count=16
Item0=..\..\..\zlib;$(BCB)\include
Item1=..\..\..;..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;..\..\..\zlib;$(BCB)\include
Item2=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;..\..\..\zlib;$(BCB)\include
Item3=P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\include
Item4=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;$(BCB)\include
Item5=..\Source\ThirdParty\ZLibCompression;$(BCB)\include
Item6=$(BCB)\include
Item7=..\Source;..\Source\General\Templates;..\Source\SIMUtilities;$(BCB)\include;$(BCB)\include\vcl
Item8=P:\Development\Source\;P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl
Item9=P:\Development\Source;P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl
Item10=P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities\;$(BCB)\include;$(BCB)\include\vcl
Item11=P:\Development\Source\General\Templates\;P:\Development\Source\SIMUtilities;$(BCB)\include;$(BCB)\include\vcl
Item12=P:\Development\Source\General\Templates\;$(BCB)\include;$(BCB)\include\vcl
Item13=P:\Development\Source\General\Templates;$(BCB)\include;$(BCB)\include\vcl
Item14=P:\Development\Source;$(BCB)\include;$(BCB)\include\vcl
Item15=$(BCB)\include;$(BCB)\include\vcl
[HistoryLists\hlLibraryPath]
Count=12
Item0=..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib
Item1=..\..\..;..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib
Item2=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib
Item3=P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\lib\obj;$(BCB)\lib
Item4=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression;$(BCB)\lib\obj;$(BCB)\lib
Item5=$(BCB)\lib\obj;$(BCB)\lib
Item6=..\Source\ThirdParty\ZLibCompression;$(BCB)\lib\obj;$(BCB)\lib
Item7=..\Source\SIMUtilities;..\Source;$(BCB)\lib\obj;$(BCB)\lib
Item8=P:\Development\Source\SIMUtilities\;P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib
Item9=P:\Development\Source\SIMUtilities;P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib
Item10=P:\Development\Source\;$(BCB)\lib\obj;$(BCB)\lib
Item11=P:\Development\Source;$(BCB)\lib\obj;$(BCB)\lib
[HistoryLists\hlDebugSourcePath]
Count=1
Item0=$(BCB)\source\vcl
[HistoryLists\hlConditionals]
Count=8
Item0=ZLIB_DLL;Z_PREFIX
Item1=ZLIB_DLL;_DEBUG;Z_PREFIX
Item2=ZLIB_DLL;_DEBUG
Item3=ZLIB_DLL
Item4=_WINDOWS;ZLIB_DLL
Item5=_HTML_FORM
Item6=_DEBUG;_HTML_FORM
Item7=_DEBUG
[HistoryLists\hlIntOutputDir]
Count=2
Item0=..\Obj
Item1=P:\Development\Obj
[Debugging]
DebugSourceDirs=
[Parameters]
RunParams=
HostApplication=
RemoteHost=
RemotePath=
RemoteDebug=0
[Compiler]
ShowInfoMsgs=0
LinkDebugVcl=0
LinkCGLIB=0
</IDEOPTIONS>
</PROJECT>

30
projects/borland/zlib.cpp Normal file
View File

@@ -0,0 +1,30 @@
//---------------------------------------------------------------------------
#include <windows.h>
//---------------------------------------------------------------------------
// Important note about DLL memory management when your DLL uses the
// static version of the RunTime Library:
//
// If your DLL exports any functions that pass String objects (or structs/
// classes containing nested Strings) as parameter or function results,
// you will need to add the library MEMMGR.LIB to both the DLL project and
// any other projects that use the DLL. You will also need to use MEMMGR.LIB
// if any other projects which use the DLL will be performing new or delete
// operations on any non-TObject-derived classes which are exported from the
// DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
// EXE's to use the BORLNDMM.DLL as their memory manager. In these cases,
// the file BORLNDMM.DLL should be deployed along with your DLL.
//
// To avoid using BORLNDMM.DLL, pass string information using "char *" or
// ShortString parameters.
//
// If your DLL uses the dynamic version of the RTL, you do not need to
// explicitly add MEMMGR.LIB as this will be done implicitly for you
//---------------------------------------------------------------------------
int WINAPI DllEntryPoint(HINSTANCE, unsigned long, void*)
{
return 1;
}
//---------------------------------------------------------------------------

View File

@@ -0,0 +1,20 @@
USEUNIT("..\..\..\zlib\zutil.c");
USEUNIT("..\..\..\zlib\compress.c");
USEUNIT("..\..\..\zlib\crc32.c");
USEUNIT("..\..\..\zlib\deflate.c");
USEUNIT("..\..\..\zlib\gzio.c");
USEUNIT("..\..\..\zlib\infblock.c");
USEUNIT("..\..\..\zlib\infcodes.c");
USEUNIT("..\..\..\zlib\inffast.c");
USEUNIT("..\..\..\zlib\inflate.c");
USEUNIT("..\..\..\zlib\inftrees.c");
USEUNIT("..\..\..\zlib\infutil.c");
USEUNIT("..\..\..\zlib\trees.c");
USEUNIT("..\..\..\zlib\uncompr.c");
USEUNIT("..\..\..\zlib\adler32.c");
//---------------------------------------------------------------------------
#define Library
// To add a file to the library use the Project menu 'Add to Project'.

View File

@@ -0,0 +1,131 @@
<?xml version='1.0' encoding='utf-8' ?>
<!-- C++Builder XML Project -->
<PROJECT>
<MACROS>
<VERSION value="BCB.05.03"/>
<PROJECT value="zlibstat.lib"/>
<OBJFILES value="..\..\..\zlib\zutil.obj ..\..\..\zlib\compress.obj ..\..\..\zlib\crc32.obj
..\..\..\zlib\deflate.obj ..\..\..\zlib\gzio.obj
..\..\..\zlib\infblock.obj ..\..\..\zlib\infcodes.obj
..\..\..\zlib\inffast.obj ..\..\..\zlib\inflate.obj
..\..\..\zlib\inftrees.obj ..\..\..\zlib\infutil.obj
..\..\..\zlib\trees.obj ..\..\..\zlib\uncompr.obj ..\..\..\zlib\adler32.obj"/>
<RESFILES value=""/>
<DEFFILE value=""/>
<RESDEPEN value="$(RESFILES)"/>
<LIBFILES value=""/>
<LIBRARIES value=""/>
<PACKAGES value=""/>
<PATHCPP value=".;..\..\..\zlib"/>
<PATHPAS value=".;"/>
<PATHRC value=".;"/>
<PATHASM value=".;"/>
<LINKER value="TLib"/>
<USERDEFINES value="Z_PREFIX"/>
<SYSDEFINES value="_RTLDLL;NO_STRICT"/>
<MAINSOURCE value="zlibstat.bpf"/>
<INCLUDEPATH value="..\..\..\zlib;$(BCB)\include"/>
<LIBPATH value="..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib"/>
<WARNINGS value="-w8092 -w8091 -w8090 -w8089 -w8087 -wprc -wuse -wucp -wstv -wstu -wpin
-wnod -wnak -wdef -wcln -wbbf -w-aus -wasm -wamp -wamb"/>
<LISTFILE value=""/>
</MACROS>
<OPTIONS>
<CFLAG1 value="-O2 -w -Vx -Ve -x- -RT- -X- -a8 -5 -b- -d -k- -vi -c -tW -tWM"/>
<PFLAGS value="-$Y- -$L- -$D- -$C- -v -JPHNE -M"/>
<AFLAGS value="/mx /w2 /zn"/>
<LFLAGS value=""/>
</OPTIONS>
<LINKER>
<ALLOBJ value="$(OBJFILES)"/>
<ALLLIB value=""/>
</LINKER>
<IDEOPTIONS>
[Version Info]
IncludeVerInfo=0
AutoIncBuild=0
MajorVer=1
MinorVer=0
Release=0
Build=0
Debug=0
PreRelease=0
Special=0
Private=0
DLL=0
Locale=2057
CodePage=1252
[Version Info Keys]
CompanyName=
FileDescription=
FileVersion=1.0.0.0
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=1.0.0.0
Comments=
[HistoryLists\hlIncludePath]
Count=8
Item0=..\..\..\zlib;$(BCB)\include
Item1=..\Source\ThirdParty\ZLibCompression\external;..\..\..\zlib;$(BCB)\include
Item2=P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\include
Item3=..\Source\ThirdParty\ZLibCompression\external;$(BCB)\include
Item4=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression\ext;..\Source\ThirdParty\ZLibCompression;$(BCB)\include
Item5=..\Source\ThirdParty\ZLibCompression;$(BCB)\include
Item6=$(BCB)\include
Item7=$(BCB)\include;$(BCB)\include\vcl
[HistoryLists\hlLibraryPath]
Count=7
Item0=..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib
Item1=$(BCB)\lib\obj;$(BCB)\lib
Item2=..\Source\ThirdParty\ZLibCompression\external;..\..\..\zlib;$(BCB)\lib\obj;$(BCB)\lib
Item3=P:\My Documents\Source\PNG+ZLib\zlib;$(BCB)\lib\obj;$(BCB)\lib
Item4=..\Source\ThirdParty\ZLibCompression\external;$(BCB)\lib\obj;$(BCB)\lib
Item5=..\Source\ThirdParty\ZLibCompression\external;..\Source\ThirdParty\ZLibCompression\ext;..\Source\ThirdParty\ZLibCompression;$(BCB)\lib\obj;$(BCB)\lib
Item6=..\Source\ThirdParty\ZLibCompression;$(BCB)\lib\obj;$(BCB)\lib
[HistoryLists\hlDebugSourcePath]
Count=1
Item0=$(BCB)\source\vcl
[HistoryLists\hlConditionals]
Count=3
Item0=Z_PREFIX
Item1=ZLIB_DLL
Item2=_WINDOWS;ZLIB_DLL
[HistoryLists\hlIntOutputDir]
Count=2
Item0=..\Obj
Item1=P:\Development\Obj
[HistoryLists\hlTlibPageSize]
Count=1
Item0=0x0010
[Debugging]
DebugSourceDirs=
[Parameters]
RunParams=
HostApplication=
RemoteHost=
RemotePath=
RemoteDebug=0
[Compiler]
ShowInfoMsgs=0
LinkDebugVcl=0
LinkCGLIB=0
[Language]
ActiveLang=
ProjectLang=
RootDir=
</IDEOPTIONS>
</PROJECT>

47
projects/msvc/README.txt Normal file
View File

@@ -0,0 +1,47 @@
Microsoft Developer Studio Build File, Format Version 6.00 for
libpng 1.0.9beta5 (December 15, 2000) and zlib
Copyright (C) 2000 Simon-Pierre Cadieux
For conditions of distribution and use, see copyright notice in png.h
Assumes that libpng sources are in ..\..
Assumes that zlib sources have been copied to ..\..\..\zlib
To build:
1) On the main menu Select "Build|Set Active configuration".
Among the configurations beginning with "libpng" select the
one you wish to build (the corresponding "zlib" configuration
will be built automatically).
2) Select "Build|Clean"
3) Select "Build|Rebuild All"
4) Look in the appropriate "win32" subdirectories for both "zlib"
and "libpng" binaries.
This project will build the PNG Development Group's "official" versions of
libpng and zlib libraries:
libpng1.dll (default version, currently C code only)
libpng1a.dll (C + Assembler version)
libpng1b.dll (C + Assembler debug version)
libpng1d.dll (C code debug version)
libpng1[c,e-m].dll (reserved for official versions)
libpng1[n-z].dll (available for private versions)
zlib.dll (default version, currently C code only)
zlibd.dll (debug version)
If you change anything in libpng, or select different compiler settings,
please change the library name to an unreserved name, and define
DLLFNAME_POSTFIX and (PRIVATEBUILD or SPECIALBUILD) accordingly. DLLFNAME_POSTFIX
should correspond to a string in the range of "N" to "Z" depending on the letter
you choose for your private version.
All DLLs built by this project use the Microsoft dynamic C runtime library
MSVCRT.DLL (MSVCRTD.DLL for debug versions). If you distribute any of the
above mentioned libraries you should also include this DLL in your package.
For a list of files that are redistributable in Visual C++ 6.0, see
Common\Redist\Redist.txt on Disc 1 of the Visual C++ 6.0 product CDs.

367
projects/msvc/libpng.dsp Normal file
View File

@@ -0,0 +1,367 @@
# Microsoft Developer Studio Project File - Name="libpng" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=libpng - Win32 DLL
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "libpng.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "libpng.mak" CFG="libpng - Win32 DLL"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "libpng - Win32 DLL" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "libpng - Win32 DLL Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "libpng - Win32 DLL ASM" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "libpng - Win32 DLL Debug ASM" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "libpng - Win32 LIB" (based on "Win32 (x86) Static Library")
!MESSAGE "libpng - Win32 LIB Debug" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
!IF "$(CFG)" == "libpng - Win32 DLL"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir ".\win32\libpng\dll"
# PROP Intermediate_Dir ".\win32\libpng\dll"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /c
# ADD CPP /nologo /MD /W3 /O1 /I "..\.." /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /Yu"png.h" /FD /c
MTL=midl.exe
RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /dll /machine:I386
# ADD LINK32 /nologo /dll /machine:I386 /out:".\win32\libpng\dll\libpng1.dll"
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir ".\win32\libpng\dll_dbg"
# PROP Intermediate_Dir ".\win32\libpng\dll_dbg"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
CPP=cl.exe
# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Zi /Od /I "..\.." /I "..\..\..\zlib" /D "DEBUG" /D "_DEBUG" /D PNG_DEBUG=1 /D "WIN32" /D "_WINDOWS" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /Yu"png.h" /FD /GZ /c
MTL=midl.exe
RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /i "..\.." /d "_DEBUG" /d PNG_DEBUG=1
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 /nologo /dll /debug /machine:I386 /out:".\win32\libpng\dll_dbg\libpng1d.dll"
!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir ".\win32\libpng\dll_asm"
# PROP Intermediate_Dir ".\win32\libpng\dll_asm"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /c
# ADD CPP /nologo /MD /W3 /O1 /I "..\.." /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /Yu"png.h" /FD /c
MTL=midl.exe
RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG" /d "PNG_USE_PNGVCRD"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /dll /machine:I386
# ADD LINK32 /nologo /dll /machine:I386 /out:".\win32\libpng\dll_asm\libpng1a.dll"
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug ASM"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir ".\win32\libpng\dll_dbga"
# PROP Intermediate_Dir ".\win32\libpng\dll_dbga"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
CPP=cl.exe
# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Zi /Od /I "..\.." /I "..\..\..\zlib" /D "DEBUG" /D "_DEBUG" /D PNG_DEBUG=1 /D "WIN32" /D "_WINDOWS" /D "PNG_USE_PNGVCRD" /D "PNG_BUILD_DLL" /D "ZLIB_DLL" /Yu"png.h" /FD /GZ /c
MTL=midl.exe
RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /i "..\.." /d "_DEBUG" /d PNG_DEBUG=1 /d "PNG_USE_PNGVCRD"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 /nologo /dll /debug /machine:I386 /out:".\win32\libpng\dll_dbga\libpng1b.dll"
!ELSEIF "$(CFG)" == "libpng - Win32 LIB"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir ".\win32\libpng\lib"
# PROP Intermediate_Dir ".\win32\libpng\lib"
# PROP Target_Dir ""
MTL=midl.exe
CPP=cl.exe
# ADD BASE CPP /nologo /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_LIB" /FD /c
# ADD CPP /nologo /W3 /O1 /I "..\.." /I "..\..\..\zlib" /D "WIN32" /D "NDEBUG" /Yu"png.h" /FD /c
RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir ".\win32\libpng\lib_dbg"
# PROP Intermediate_Dir ".\win32\libpng\lib_dbg"
# PROP Target_Dir ""
MTL=midl.exe
CPP=cl.exe
# ADD BASE CPP /nologo /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_LIB" /FD /GZ /c
# ADD CPP /nologo /W3 /Zi /Od /I "..\.." /I "..\..\..\zlib" /D "DEBUG" /D "_DEBUG" /D PNG_DEBUG=1 /D "WIN32" /Yu"png.h" /FD /GZ /c
RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ENDIF
# Begin Target
# Name "libpng - Win32 DLL"
# Name "libpng - Win32 DLL Debug"
# Name "libpng - Win32 DLL ASM"
# Name "libpng - Win32 DLL Debug ASM"
# Name "libpng - Win32 LIB"
# Name "libpng - Win32 LIB Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\png.c
# SUBTRACT CPP /YX /Yc /Yu
# End Source File
# Begin Source File
SOURCE=.\png.rc
!IF "$(CFG)" == "libpng - Win32 DLL"
!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug"
!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM"
!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug ASM"
!ELSEIF "$(CFG)" == "libpng - Win32 LIB"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug"
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\png32ms.def
!IF "$(CFG)" == "libpng - Win32 DLL"
!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug"
!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM"
!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug ASM"
!ELSEIF "$(CFG)" == "libpng - Win32 LIB"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug"
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\..\pngerror.c
# ADD CPP /Yc"png.h"
# End Source File
# Begin Source File
SOURCE=..\..\pngget.c
# End Source File
# Begin Source File
SOURCE=..\..\pngmem.c
# End Source File
# Begin Source File
SOURCE=..\..\pngpread.c
# End Source File
# Begin Source File
SOURCE=..\..\pngread.c
# End Source File
# Begin Source File
SOURCE=..\..\pngrio.c
# End Source File
# Begin Source File
SOURCE=..\..\pngrtran.c
# End Source File
# Begin Source File
SOURCE=..\..\pngrutil.c
# End Source File
# Begin Source File
SOURCE=..\..\pngset.c
# End Source File
# Begin Source File
SOURCE=..\..\pngtrans.c
# End Source File
# Begin Source File
SOURCE=..\..\pngvcrd.c
!IF "$(CFG)" == "libpng - Win32 DLL"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM"
!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug ASM"
!ELSEIF "$(CFG)" == "libpng - Win32 LIB"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "libpng - Win32 LIB Debug"
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\..\pngwio.c
# End Source File
# Begin Source File
SOURCE=..\..\pngwrite.c
# End Source File
# Begin Source File
SOURCE=..\..\pngwtran.c
# End Source File
# Begin Source File
SOURCE=..\..\pngwutil.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\..\png.h
# End Source File
# Begin Source File
SOURCE=..\..\pngconf.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# Begin Source File
SOURCE=.\readme.txt
# PROP Exclude_From_Build 1
# End Source File
# End Target
# End Project

44
projects/msvc/libpng.dsw Normal file
View File

@@ -0,0 +1,44 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "libpng"=.\libpng.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name zlib
End Project Dependency
}}}
###############################################################################
Project: "zlib"=.\zlib.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

100
projects/msvc/png.rc Normal file
View File

@@ -0,0 +1,100 @@
#define PNG_VERSION_INFO_ONLY
#include <windows.h>
#include "png.h"
#define _QUOTE(x) # x
#define QUOTE(x) _QUOTE(x)
#define PNG_LIBPNG_DLLFNAME "LIBPNG"
#if defined(DLLFNAME_POSTFIX) && !defined(PRIVATEBUILD) && !defined(SPECIALBUILD)
# error PRIVATEBUILD or SPECIALBUILD must be defined as a string describing the type of change brought to the standard library
#endif /* defined(DLLFNAME_POSTFIX)... */
#if !defined(DLLFNAME_POSTFIX) && defined(PNG_USE_PNGVCRD)
# if defined(PNG_DEBUG) && (PNG_DEBUG > 0)
# define DLLFNAME_POSTFIX "B"
# else
# define DLLFNAME_POSTFIX "A"
# endif /* !defined(DLLFNAME_POSTFIX)... */
# if !defined(SPECIALBUILD)
# define SPECIALBUILD "Use MMX instructions"
# endif /* SPECIALBUILD */
#endif
#if defined(PNG_DEBUG) && (PNG_DEBUG > 0)
# define VS_DEBUG VS_FF_DEBUG
# ifndef DLLFNAME_POSTFIX
# define DLLFNAME_POSTFIX "D"
# endif /* DLLFNAME_POSTFIX */
# ifndef COMMENTS
# define COMMENTS "PNG_DEBUG=" QUOTE(PNG_DEBUG)
# endif /* COMMENTS */
#else
# define VS_DEBUG 0
# ifndef DLLFNAME_POSTFIX
# define DLLFNAME_POSTFIX
# endif /* DLLFNAME_POSTFIX */
#endif /* defined(DEBUG)... */
#ifdef PRIVATEBUILD
# define VS_PRIVATEBUILD VS_FF_PRIVATEBUILD
#else
# define VS_PRIVATEBUILD 0
#endif /* PRIVATEBUILD */
#ifdef SPECIALBUILD
# define VS_SPECIALBUILD VS_FF_SPECIALBUILD
#else
# define VS_SPECIALBUILD 0
#endif /* SPECIALBUILD */
#if ((PNG_LIBPNG_BUILD_TYPE & PNG_LIBPNG_BUILD_TYPEMASK) != \
PNG_LIBPNG_BUILD_STABLE)
# define VS_PRERELEASE VS_FF_PRERELEASE
# define VS_PATCHED 0
#else
# define VS_PRERELEASE 0
# if (PNG_LIBPNG_BUILD_TYPE & PNG_LIBPNG_BUILD_PATCHED)
# define VS_PATCHED VS_FF_PATCHED
# else
# define VS_PATCHED 0
# endif
#endif
VS_VERSION_INFO VERSIONINFO
FILEVERSION PNG_LIBPNG_VER_MAJOR, PNG_LIBPNG_VER_MINOR, PNG_LIBPNG_VER_RELEASE, PNG_LIBPNG_VER_BUILD
PRODUCTVERSION PNG_LIBPNG_VER_MAJOR, PNG_LIBPNG_VER_MINOR, PNG_LIBPNG_VER_RELEASE, PNG_LIBPNG_VER_BUILD
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS VS_DEBUG | VS_PRIVATEBUILD | VS_SPECIALBUILD | VS_PRERELEASE | VS_PATCHED
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN BLOCK "040904E4" /* Language type = U.S English(0x0409) and Character Set = Windows, Multilingual(0x04E4) */
BEGIN
#ifdef COMMENTS
VALUE "Comments", COMMENTS "\000"
#endif /* COMMENTS */
VALUE "FileDescription", "PNG image compression library\000"
VALUE "FileVersion", PNG_LIBPNG_VER_STRING "\000"
VALUE "InternalName", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_MAJOR) DLLFNAME_POSTFIX " (Windows 32 bit)\000"
VALUE "LegalCopyright", "\251 1998-2000 Glenn Randers-Pehrson\000"
VALUE "OriginalFilename", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_MAJOR) DLLFNAME_POSTFIX ".DLL\000"
#ifdef PRIVATEBUILD
VALUE "PrivateBuild", PRIVATEBUILD
#endif /* PRIVATEBUILD */
VALUE "ProductName", "LibPNG\000"
VALUE "ProductVersion", "1\000"
#ifdef SPECIALBUILD
VALUE "SpecialBuild", SPECIALBUILD
#endif /* SPECIALBUILD */
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 0x04E4
END
END

178
projects/msvc/png32ms.def Normal file
View File

@@ -0,0 +1,178 @@
;------------------------------------------
; LIBPNG module definition file for Windows
;------------------------------------------
LIBRARY
DESCRIPTION "PNG image compression library for Windows"
EXPORTS
;Version 1.0.9beta5
png_build_grayscale_palette @1
png_check_sig @2
png_chunk_error @3
png_chunk_warning @4
png_convert_from_struct_tm @5
png_convert_from_time_t @6
png_create_info_struct @7
png_create_read_struct @8
png_create_write_struct @9
png_data_freer @10
png_destroy_info_struct @11
png_destroy_read_struct @12
png_destroy_write_struct @13
png_error @14
png_free @15
png_free_data @16
png_get_IHDR @17
png_get_PLTE @18
png_get_bKGD @19
png_get_bit_depth @20
png_get_cHRM @21
png_get_cHRM_fixed @22
png_get_channels @23
png_get_color_type @24
png_get_compression_buffer_size @25
png_get_compression_type @26
png_get_copyright @27
png_get_error_ptr @28
png_get_filter_type @29
png_get_gAMA @30
png_get_gAMA_fixed @31
png_get_hIST @32
png_get_header_ver @33
png_get_header_version @34
png_get_iCCP @35
png_get_image_height @36
png_get_image_width @37
png_get_interlace_type @38
png_get_io_ptr @39
png_get_libpng_ver @40
png_get_oFFs @41
png_get_pCAL @42
png_get_pHYs @43
png_get_pixel_aspect_ratio @44
png_get_pixels_per_meter @45
png_get_progressive_ptr @46
png_get_rgb_to_gray_status @47
png_get_rowbytes @48
png_get_rows @49
png_get_sBIT @50
png_get_sCAL @51
png_get_sPLT @52
png_get_sRGB @53
png_get_signature @54
png_get_tIME @55
png_get_tRNS @56
png_get_text @57
png_get_unknown_chunks @58
png_get_user_chunk_ptr @59
png_get_user_transform_ptr @60
png_get_valid @61
png_get_x_offset_microns @62
png_get_x_offset_pixels @63
png_get_x_pixels_per_meter @64
png_get_y_offset_microns @65
png_get_y_offset_pixels @66
png_get_y_pixels_per_meter @67
png_malloc @68
png_memcpy_check @69
png_memset_check @70
png_permit_empty_plte @71
png_process_data @72
png_progressive_combine_row @73
png_read_end @74
png_read_image @75
png_read_info @76
png_read_init @77
png_read_png @78
png_read_row @79
png_read_rows @80
png_read_update_info @81
png_reset_zstream @82
png_set_IHDR @83
png_set_PLTE @84
png_set_bKGD @85
png_set_background @86
png_set_bgr @87
png_set_cHRM @88
png_set_cHRM_fixed @89
png_set_compression_buffer_size @90
png_set_compression_level @91
png_set_compression_mem_level @92
png_set_compression_method @93
png_set_compression_strategy @94
png_set_compression_window_bits @95
png_set_crc_action @96
png_set_dither @97
png_set_error_fn @98
png_set_expand @99
png_set_filler @100
png_set_filter @101
png_set_filter_heuristics @102
png_set_flush @103
png_set_gAMA @104
png_set_gAMA_fixed @105
png_set_gamma @106
png_set_gray_1_2_4_to_8 @107
png_set_gray_to_rgb @108
png_set_hIST @109
png_set_iCCP @110
png_set_interlace_handling @111
png_set_invert_alpha @112
png_set_invert_mono @113
png_set_keep_unknown_chunks @114
png_set_oFFs @115
png_set_pCAL @116
png_set_pHYs @117
png_set_packing @118
png_set_packswap @119
png_set_palette_to_rgb @120
png_set_progressive_read_fn @121
png_set_read_fn @122
png_set_read_status_fn @123
png_set_read_user_chunk_fn @124
png_set_read_user_transform_fn @125
png_set_rgb_to_gray @126
png_set_rgb_to_gray_fixed @127
png_set_rows @128
png_set_sBIT @129
png_set_sCAL @130
png_set_sPLT @131
png_set_sRGB @132
png_set_sRGB_gAMA_and_cHRM @133
png_set_shift @134
png_set_sig_bytes @135
png_set_strip_16 @136
png_set_strip_alpha @137
png_set_swap @138
png_set_swap_alpha @139
png_set_tIME @140
png_set_tRNS @141
png_set_tRNS_to_alpha @142
png_set_text @143
png_set_unknown_chunk_location @144
png_set_unknown_chunks @145
png_set_user_transform_info @146
png_set_write_fn @147
png_set_write_status_fn @148
png_set_write_user_transform_fn @149
png_sig_cmp @150
png_start_read_image @151
png_warning @152
png_write_chunk @153
png_write_chunk_data @154
png_write_chunk_end @155
png_write_chunk_start @156
png_write_end @157
png_write_flush @158
png_write_image @159
png_write_info @160
png_write_info_before_PLTE @161
png_write_init @162
png_write_png @163
png_write_row @164
png_write_rows @165
png_read_init_2 @166
png_write_init_2 @167
png_access_version_number @168
; png_sig_bytes @169

45
projects/msvc/zlib.def Normal file
View File

@@ -0,0 +1,45 @@
LIBRARY
DESCRIPTION "zlib compression library for Windows"
EXPORTS
adler32 @1
compress @2
crc32 @3
deflate @4
deflateCopy @5
deflateEnd @6
deflateInit2_ @7
deflateInit_ @8
deflateParams @9
deflateReset @10
deflateSetDictionary @11
gzclose @12
gzdopen @13
gzerror @14
gzflush @15
gzopen @16
gzread @17
gzwrite @18
inflate @19
inflateEnd @20
inflateInit2_ @21
inflateInit_ @22
inflateReset @23
inflateSetDictionary @24
inflateSync @25
uncompress @26
zlibVersion @27
gzprintf @28
gzputc @29
gzgetc @30
gzseek @31
gzrewind @32
gztell @33
gzeof @34
gzsetparams @35
zError @36
inflateSyncPoint @37
get_crc_table @38
compress2 @39
gzputs @40
gzgets @41

400
projects/msvc/zlib.dsp Normal file
View File

@@ -0,0 +1,400 @@
# Microsoft Developer Studio Project File - Name="zlib" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=zlib - Win32 DLL
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "zlib.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "zlib.mak" CFG="zlib - Win32 DLL"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "zlib - Win32 DLL" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "zlib - Win32 DLL Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "zlib - Win32 DLL ASM" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "zlib - Win32 DLL Debug ASM" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "zlib - Win32 LIB" (based on "Win32 (x86) Static Library")
!MESSAGE "zlib - Win32 LIB Debug" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
!IF "$(CFG)" == "zlib - Win32 DLL"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir ".\win32\zlib\dll"
# PROP Intermediate_Dir ".\win32\zlib\dll"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /FD /c
# ADD CPP /nologo /MD /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ZLIB_DLL" /FD /c
MTL=midl.exe
RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /dll /machine:I386
# ADD LINK32 /nologo /dll /machine:I386
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir ".\win32\zlib\dll_dbg"
# PROP Intermediate_Dir ".\win32\zlib\dll_dbg"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
CPP=cl.exe
# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Zi /Od /D "DEBUG" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "ZLIB_DLL" /FD /GZ /c
MTL=midl.exe
RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 /nologo /dll /debug /machine:I386 /out:".\win32\zlib\dll_dbg\zlibd.dll"
!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir ".\win32\zlib\dll_asm"
# PROP Intermediate_Dir ".\win32\zlib\dll_asm"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
CPP=cl.exe
# ADD BASE CPP /nologo /MD /W3 /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /c
# ADD CPP /nologo /MD /W3 /O1 /I "..\..\..\zlib" /D "NDEBUG" /D "WIN32" /D "_WIN32" /D "_WINDOWS" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FD /c
MTL=midl.exe
RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /i "..\.." /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /dll /machine:I386
# ADD LINK32 gvmat32.obj /nologo /dll /machine:I386 /out:".\win32\zlib\dll_asm\zliba.dll"
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug ASM"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir ".\win32\zlib\dll_dbga"
# PROP Intermediate_Dir ".\win32\zlib\dll_dbga"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
CPP=cl.exe
# ADD BASE CPP /nologo /MDd /W3 /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Zi /Od /I "..\..\..\zlib" /D "_DEBUG" /D "WIN32" /D "_WIN32" /D "_WINDOWS" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FD /GZ /c
MTL=midl.exe
RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /i "..\.." /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 gvmat32d.obj /nologo /dll /debug /machine:I386 /out:".\win32\zlib\dll_dbga\zlibb.dll"
!ELSEIF "$(CFG)" == "zlib - Win32 LIB"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir ".\win32\zlib\lib"
# PROP Intermediate_Dir ".\win32\zlib\lib"
# PROP Target_Dir ""
MTL=midl.exe
CPP=cl.exe
# ADD BASE CPP /nologo /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_LIB" /FD /c
# ADD CPP /nologo /W3 /O1 /D "WIN32" /D "NDEBUG" /FD /c
RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir ".\win32\zlib\lib_dbg"
# PROP Intermediate_Dir ".\win32\zlib\lib_dbg"
# PROP Target_Dir ""
MTL=midl.exe
CPP=cl.exe
# ADD BASE CPP /nologo /W3 /Zi /Od /D "WIN32" /D "_DEBUG" /D "_LIB" /FD /GZ /c
# ADD CPP /nologo /W3 /Zi /Od /D "WIN32" /D "_DEBUG" /FD /GZ /c
RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ENDIF
# Begin Target
# Name "zlib - Win32 DLL"
# Name "zlib - Win32 DLL Debug"
# Name "zlib - Win32 DLL ASM"
# Name "zlib - Win32 DLL Debug ASM"
# Name "zlib - Win32 LIB"
# Name "zlib - Win32 LIB Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\..\zlib\adler32.c
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\compress.c
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\crc32.c
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\deflate.c
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\contrib\asm386\gvmat32c.c
!IF "$(CFG)" == "zlib - Win32 DLL"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM"
!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug ASM"
!ELSEIF "$(CFG)" == "zlib - Win32 LIB"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug"
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\gzio.c
# ADD CPP /Yc"zutil.h"
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\infblock.c
# ADD CPP /Yu"zutil.h"
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\infcodes.c
# ADD CPP /Yu"zutil.h"
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\inffast.c
# ADD CPP /Yu"zutil.h"
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\inflate.c
# ADD CPP /Yu"zutil.h"
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\inftrees.c
# ADD CPP /Yu"zutil.h"
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\infutil.c
# ADD CPP /Yu"zutil.h"
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\trees.c
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\uncompr.c
# End Source File
# Begin Source File
SOURCE=.\zlib.def
!IF "$(CFG)" == "zlib - Win32 DLL"
!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug"
!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM"
!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug ASM"
!ELSEIF "$(CFG)" == "zlib - Win32 LIB"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug"
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\msdos\zlib.rc
!IF "$(CFG)" == "zlib - Win32 DLL"
!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug"
!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM"
!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug ASM"
!ELSEIF "$(CFG)" == "zlib - Win32 LIB"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug"
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\zutil.c
# ADD CPP /Yu"zutil.h"
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\..\..\zlib\deflate.h
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\infblock.h
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\infcodes.h
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\inffast.h
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\inffixed.h
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\inftrees.h
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\infutil.h
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\trees.h
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\zconf.h
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\zlib.h
# End Source File
# Begin Source File
SOURCE=..\..\..\zlib\zutil.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,43 @@
libpng for WindowsCE Rel.1.0
============================
Copyright (c) 2000 Glenn Randers-Pehrson
Copyright (c) 2000 Tenik Co.,Ltd.
Porting for WindowsCE by Tenik Co.,Ltd.(Kazuo Adachi)
Introduction
============
This is libpng 1.0.9beta5 ported to WindowsCE 2.0 and 2.11.
libpng 1.0.9beta5 is a PNG reference library.
See README, a document of original libpng 1.0.9beta5.
zlib for WindowsCE
==================
This library requires zlib for WindowsCE. You can use the supplied
zlib.diff and zlibce.def files to add WindowsCE support to libpng-1.1.3.
Copyright notice
================
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
See README and LICENSE, documents of original libpng 1.0.9beta5, for conditions
of use and distribution.
Files
=====
READMEE.WCE - this file(in English)
READMEJ.WCE - this file(in Japanese)
png32ce.def - module definition file to make DLLs
Sample programs(../../pngtest.c and ../../contrib/*) can build on WindowsCE
2.11. WindowsCE 2.0 and below do not support 'console' functions.
Author
======
Tenik Co.,Ltd.
Kazuo Adachi
adachi@tenik.co.jp

View File

@@ -0,0 +1,44 @@
libpng for WindowsCE Rel.1.0
============================
Copyright (c) 2000 Glenn Randers-Pehrson
Copyright (c) 2000 Tenik Co.,Ltd.
Porting for WindowsCE by Tenik Co.,Ltd.(Kazuo Adachi)
<EFBFBD>͂<EFBFBD><EFBFBD>߂<EFBFBD>
========
libpng for WindowsCE<43><45> PNG<4E>`<60><><EFBFBD>̉摜<CC89>f<EFBFBD>[<5B>^<5E><><EFBFBD>C<EFBFBD>u<EFBFBD><75><EFBFBD><EFBFBD> libpng<6E><67>WindowsCE
<EFBFBD>łł<EFBFBD><EFBFBD>Blibpng<EFBFBD>ɂ‚<EFBFBD><EFBFBD>Ă̏ڂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>́A<EFBFBD>t<EFBFBD><EFBFBD><EFBFBD><EFBFBD> README <20><><EFBFBD><EFBFBD><EFBFBD>ǂ݂<C782><DD82><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
zlib for WindowsCE
==================
libpng<EFBFBD>ł́A<EFBFBD>f<EFBFBD>[<5B>^<5E><><EFBFBD>k<EFBFBD><6B><EFBFBD>C<EFBFBD>u<EFBFBD><75><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><C682><EFBFBD> zlib<69><62><EFBFBD>g<EFBFBD>p<EFBFBD><70><EFBFBD>Ă<EFBFBD><C482>܂<EFBFBD><DC82>Blibpng<6E><67>
<EFBFBD><EFBFBD><EFBFBD>p<EFBFBD><EFBFBD><EFBFBD><EFBFBD>߂ɂ́A<EFBFBD>ʓr zlib<69><62><EFBFBD>p<EFBFBD>ӂ<EFBFBD><D382><EFBFBD><EFBFBD>K<EFBFBD>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂<EFBFBD><DC82>B
<EFBFBD>Ȃ<EFBFBD><EFBFBD>A<EFBFBD><EFBFBD><EFBFBD>̃p<EFBFBD>b<EFBFBD>P<EFBFBD>[<5B>W<EFBFBD>ŗ<EFBFBD><C597>p<EFBFBD>ł<EFBFBD><C582><EFBFBD> zlib<69>͎<EFBFBD><CD8E>̍쐬<CC8D><EC90AC><EFBFBD><EFBFBD> zlibce.dll<6C>ł<EFBFBD><C582>B
<EFBFBD>g<EFBFBD>p<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
========
<EFBFBD><EFBFBD><EFBFBD>̃\<5C>t<EFBFBD>g<EFBFBD>E<EFBFBD>F<EFBFBD>A<EFBFBD>͖<EFBFBD><CD96>ۏ؂ł<D882><C582>B<EFBFBD><42><EFBFBD>̃\<5C>t<EFBFBD>g<EFBFBD>E<EFBFBD>F<EFBFBD>A<EFBFBD><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŗ<EFBFBD><C597>p<EFBFBD>҂<EFBFBD><D282><EFBFBD><EFBFBD><EFBFBD><E982B1>
<EFBFBD>ɂȂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȃ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Q<EFBFBD>ɂ‚<EFBFBD><EFBFBD>Ă<EFBFBD><EFBFBD>A<EFBFBD><EFBFBD><EFBFBD>ҁA<EFBFBD>z<EFBFBD>z<EFBFBD>ҁA<EFBFBD><EFBFBD><EFBFBD>̑<EFBFBD><EFBFBD><EFBFBD><EFBFBD>p<EFBFBD>҈ȊO<EFBFBD>̐l<EFBFBD><EFBFBD><EFBFBD>A
<EFBFBD>c<EFBFBD>̂ɐӔC<EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><EFBFBD>`<60><><EFBFBD>͂Ȃ<CD82><C882><EFBFBD><EFBFBD>̂Ƃ<CC82><C682>܂<EFBFBD><DC82>B
<EFBFBD><EFBFBD><EFBFBD>̑<EFBFBD><EFBFBD>A<EFBFBD><EFBFBD><EFBFBD>̃\<5C>t<EFBFBD>g<EFBFBD>E<EFBFBD>F<EFBFBD>A<EFBFBD>̗<EFBFBD><CC97>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD>ɂ‚<C982><C282>ẮA<CD81><41><EFBFBD>łł<C582><C582><EFBFBD> libpng 1.0.9beta5<EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̂Ƃ<EFBFBD><EFBFBD>܂<EFBFBD><EFBFBD>B<EFBFBD>ڂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>́A<EFBFBD>t<EFBFBD><EFBFBD><EFBFBD><EFBFBD> README,LICENSE <20><><EFBFBD><EFBFBD><EFBFBD>ǂ݂<C782><DD82><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
<EFBFBD><EFBFBD><EFBFBD>^<5E><><EFBFBD>e
========
READMEJ.WCE - <20><><EFBFBD>̃t<CC83>@<40>C<EFBFBD><43>
READMEE.WCE - <20><><EFBFBD>̃t<CC83>@<40>C<EFBFBD><43>(<28>p<EFBFBD><70>)
png32ce.def - DLL<4C><EFBFBD>p <20><><EFBFBD>`<60>t<EFBFBD>@<40>C<EFBFBD><43>
<EFBFBD>t<EFBFBD><EFBFBD><EFBFBD>T<EFBFBD><EFBFBD><EFBFBD>v<EFBFBD><EFBFBD><EFBFBD>E<EFBFBD>v<EFBFBD><EFBFBD><EFBFBD>O<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>́A<EFBFBD><EFBFBD><EFBFBD>b<EFBFBD>Z<EFBFBD>[<5B>W<EFBFBD>o<EFBFBD>͂̓s<CC93><73><EFBFBD><EFBFBD><EFBFBD>AWindowsCE 2.11<EFBFBD>ȍ~
<EFBFBD>ł̂ݎg<EFBFBD>p<EFBFBD>”\<5C>ł<EFBFBD><C582>B
<EFBFBD>z<EFBFBD>z<EFBFBD><EFBFBD>
======
<EFBFBD>e<EFBFBD>j<EFBFBD>b<EFBFBD>N<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>J<EFBFBD><4A><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>a<EFBFBD>Y
adachi@tenik.co.jp

View File

@@ -0,0 +1,39 @@
zlib for WindowsCE Rel.1.0
==========================
(C) 1995-1998 Jean-loup Gailly and Mark Adler
(C) 2000 Tenik Co.,Ltd.
Porting for WindowsCE by Tenik Co.,Ltd.(Kazuo Adachi)
Introduction
============
This is zlib 1.1.3 ported to WindowsCE 2.0 and 2.11.
zlib 1.1.3 is a general purpose data compression library.
See README, a document of original zlib 1.1.3.
Copyright notice
================
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
See README, a document of original zlib 1.1.3, for conditions of use and
distribution.
Files
=====
READMEE.WCE - this file(in English)
READMEJ.WCE - this file(in Japanese)
zlibce.def - module definition file to make DLLs
zlibce.diff - patch file for source code
Sample programs(minigzip.c and example.c) can build on WindowsCE 2.11.
WindowsCE 2.0 and below is not support 'console' functions.
Author
======
Tenik Co.,Ltd.
Kazuo Adachi
adachi@tenik.co.jp

View File

@@ -0,0 +1,41 @@
zlib for WindowsCE Rel.1.0
==========================
(C) 1995-1998 Jean-loup Gailly and Mark Adler
(C) 2000 Tenik Co.,Ltd.
Porting for WindowsCE by Tenik Co.,Ltd.(Kazuo Adachi)
<EFBFBD>͂<EFBFBD><EFBFBD>߂<EFBFBD>
========
zlib for WindowsCE<43>͔ėp<C497>̃f<CC83>[<5B>^<5E><><EFBFBD>k<EFBFBD><6B><EFBFBD>C<EFBFBD>u<EFBFBD><75><EFBFBD><EFBFBD> zlib<69><62> WindowsCE<43>łł<C582><C582>B
zlib<EFBFBD>ɂ‚<EFBFBD><EFBFBD>Ă̏ڂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>́A<EFBFBD>t<EFBFBD><EFBFBD><EFBFBD><EFBFBD> README <20><><EFBFBD><EFBFBD><EFBFBD>ǂ݂<C782><DD82><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
<EFBFBD>g<EFBFBD>p<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
========
<EFBFBD><EFBFBD><EFBFBD>̃\<5C>t<EFBFBD>g<EFBFBD>E<EFBFBD>F<EFBFBD>A<EFBFBD>͖<EFBFBD><CD96>ۏ؂ł<D882><C582>B<EFBFBD><42><EFBFBD>̃\<5C>t<EFBFBD>g<EFBFBD>E<EFBFBD>F<EFBFBD>A<EFBFBD><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŗ<EFBFBD><C597>p<EFBFBD>҂<EFBFBD><D282><EFBFBD><EFBFBD><EFBFBD><E982B1>
<EFBFBD>ɂȂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȃ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Q<EFBFBD>ɂ‚<EFBFBD><EFBFBD>Ă<EFBFBD><EFBFBD>A<EFBFBD><EFBFBD><EFBFBD>ҁA<EFBFBD>z<EFBFBD>z<EFBFBD>ҁA<EFBFBD><EFBFBD><EFBFBD>̑<EFBFBD><EFBFBD><EFBFBD><EFBFBD>p<EFBFBD>҈ȊO<EFBFBD>̐l<EFBFBD><EFBFBD><EFBFBD>A
<EFBFBD>c<EFBFBD>̂ɐӔC<EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><EFBFBD>`<60><><EFBFBD>͂Ȃ<CD82><C882><EFBFBD><EFBFBD>̂Ƃ<CC82><C682>܂<EFBFBD><DC82>B
<EFBFBD><EFBFBD><EFBFBD>̑<EFBFBD><EFBFBD>A<EFBFBD><EFBFBD><EFBFBD>̃\<5C>t<EFBFBD>g<EFBFBD>E<EFBFBD>F<EFBFBD>A<EFBFBD>̗<EFBFBD><CC97>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD>ɂ‚<C982><C282>ẮA<CD81><41><EFBFBD>łł<C582><C582><EFBFBD> zlib 1.1.3<EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̂Ƃ<EFBFBD><EFBFBD>܂<EFBFBD><EFBFBD>B<EFBFBD>ڂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>́A<EFBFBD>t<EFBFBD><EFBFBD><EFBFBD><EFBFBD> README <20><><EFBFBD><EFBFBD><EFBFBD>ǂ݂<C782><DD82><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B
<EFBFBD><EFBFBD><EFBFBD>^<5E><><EFBFBD>e
========
READMEJ.WCE - <20><><EFBFBD>̃t<CC83>@<40>C<EFBFBD><43>
READMEE.WCE - <20><><EFBFBD>̃t<CC83>@<40>C<EFBFBD><43>(<28>p<EFBFBD><70>)
zlibce.diff - <20>\<5C>[<5B>X<EFBFBD>R<EFBFBD>[<5B>h<EFBFBD><68><EFBFBD><EFBFBD><EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43>
zlibce.def - DLL<4C><EFBFBD>p <20><><EFBFBD>`<60>t<EFBFBD>@<40>C<EFBFBD><43>
<EFBFBD><EFBFBD><EFBFBD>ł<EFBFBD> zlib 1.1.3<EFBFBD>Ƃ̍ő<EFBFBD><EFBFBD>̈Ⴂ<EFBFBD>́Agzio.c<>̃R<CC83>[<5B>h<EFBFBD>ł<EFBFBD><C582>BWindowsCE<43>ɂ<EFBFBD>
stdio.h(open<65><6E><EFBFBD>̊֐<CC8A>)<29><><EFBFBD><EFBFBD><EFBFBD>݂<EFBFBD><DD82>Ȃ<EFBFBD><C882><EFBFBD><EFBFBD>߁A<DF81>Ǝ<EFBFBD><C68E><EFBFBD> gziowce.c<><63><EFBFBD><EFBFBD><EC90AC><EFBFBD>܂<EFBFBD><DC82><EFBFBD><EFBFBD>B
minigzip.c<><63> example.c<>̕t<CC95><74><EFBFBD>T<EFBFBD><54><EFBFBD>v<EFBFBD><76><EFBFBD>E<EFBFBD>v<EFBFBD><76><EFBFBD>O<EFBFBD><4F><EFBFBD><EFBFBD><EFBFBD>́A<CD81><41><EFBFBD>b<EFBFBD>Z<EFBFBD>[<5B>W<EFBFBD>o<EFBFBD>͂<EFBFBD>
<EFBFBD>s<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>AWindowsCE 2.11<EFBFBD>ȍ~<7E>ł̂ݎg<DD8E>p<EFBFBD>”\<5C>ł<EFBFBD><C582>B
<EFBFBD>z<EFBFBD>z<EFBFBD><EFBFBD>
======
<EFBFBD>e<EFBFBD>j<EFBFBD>b<EFBFBD>N<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>J<EFBFBD><4A><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>a<EFBFBD>Y
adachi@tenik.co.jp

4007
projects/wince/lpngce.dsp Normal file

File diff suppressed because it is too large Load Diff

44
projects/wince/lpngce.dsw Normal file
View File

@@ -0,0 +1,44 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "lpngce"=.\lpngce.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name zlibce
End Project Dependency
}}}
###############################################################################
Project: "zlibce"=.\zlibce.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

180
projects/wince/png32ce.def Normal file
View File

@@ -0,0 +1,180 @@
;------------------------------------------
; LIBPNG module definition file for Windows
;------------------------------------------
LIBRARY lpngce
EXPORTS
;Version 1.0.9beta5
png_build_grayscale_palette @1
png_check_sig @2
png_chunk_error @3
png_chunk_warning @4
; png_convert_from_struct_tm @5
; png_convert_from_time_t @6
png_create_info_struct @7
png_create_read_struct @8
png_create_write_struct @9
png_data_freer @10
png_destroy_info_struct @11
png_destroy_read_struct @12
png_destroy_write_struct @13
png_error @14
png_free @15
png_free_data @16
png_get_IHDR @17
png_get_PLTE @18
png_get_bKGD @19
png_get_bit_depth @20
png_get_cHRM @21
png_get_cHRM_fixed @22
png_get_channels @23
png_get_color_type @24
png_get_compression_buffer_size @25
png_get_compression_type @26
png_get_copyright @27
png_get_error_ptr @28
png_get_filter_type @29
png_get_gAMA @30
png_get_gAMA_fixed @31
png_get_hIST @32
png_get_header_ver @33
png_get_header_version @34
png_get_iCCP @35
png_get_image_height @36
png_get_image_width @37
png_get_interlace_type @38
png_get_io_ptr @39
png_get_libpng_ver @40
png_get_oFFs @41
png_get_pCAL @42
png_get_pHYs @43
png_get_pixel_aspect_ratio @44
png_get_pixels_per_meter @45
png_get_progressive_ptr @46
png_get_rgb_to_gray_status @47
png_get_rowbytes @48
png_get_rows @49
png_get_sBIT @50
png_get_sCAL @51
png_get_sPLT @52
png_get_sRGB @53
png_get_signature @54
png_get_tIME @55
png_get_tRNS @56
png_get_text @57
png_get_unknown_chunks @58
png_get_user_chunk_ptr @59
png_get_user_transform_ptr @60
png_get_valid @61
png_get_x_offset_microns @62
png_get_x_offset_pixels @63
png_get_x_pixels_per_meter @64
png_get_y_offset_microns @65
png_get_y_offset_pixels @66
png_get_y_pixels_per_meter @67
png_malloc @68
png_memcpy_check @69
png_memset_check @70
png_permit_empty_plte @71
png_process_data @72
png_progressive_combine_row @73
png_read_end @74
png_read_image @75
png_read_info @76
png_read_init @77
png_read_png @78
png_read_row @79
png_read_rows @80
png_read_update_info @81
png_reset_zstream @82
png_set_IHDR @83
png_set_PLTE @84
png_set_bKGD @85
png_set_background @86
png_set_bgr @87
png_set_cHRM @88
png_set_cHRM_fixed @89
png_set_compression_buffer_size @90
png_set_compression_level @91
png_set_compression_mem_level @92
png_set_compression_method @93
png_set_compression_strategy @94
png_set_compression_window_bits @95
png_set_crc_action @96
png_set_dither @97
png_set_error_fn @98
png_set_expand @99
png_set_filler @100
png_set_filter @101
png_set_filter_heuristics @102
png_set_flush @103
png_set_gAMA @104
png_set_gAMA_fixed @105
png_set_gamma @106
png_set_gray_1_2_4_to_8 @107
png_set_gray_to_rgb @108
png_set_hIST @109
png_set_iCCP @110
png_set_interlace_handling @111
png_set_invert_alpha @112
png_set_invert_mono @113
png_set_keep_unknown_chunks @114
png_set_oFFs @115
png_set_pCAL @116
png_set_pHYs @117
png_set_packing @118
png_set_packswap @119
png_set_palette_to_rgb @120
png_set_progressive_read_fn @121
png_set_read_fn @122
png_set_read_status_fn @123
png_set_read_user_chunk_fn @124
png_set_read_user_transform_fn @125
png_set_rgb_to_gray @126
png_set_rgb_to_gray_fixed @127
png_set_rows @128
png_set_sBIT @129
png_set_sCAL @130
png_set_sPLT @131
png_set_sRGB @132
png_set_sRGB_gAMA_and_cHRM @133
png_set_shift @134
png_set_sig_bytes @135
png_set_strip_16 @136
png_set_strip_alpha @137
png_set_swap @138
png_set_swap_alpha @139
png_set_tIME @140
png_set_tRNS @141
png_set_tRNS_to_alpha @142
png_set_text @143
png_set_unknown_chunk_location @144
png_set_unknown_chunks @145
png_set_user_transform_info @146
png_set_write_fn @147
png_set_write_status_fn @148
png_set_write_user_transform_fn @149
png_sig_cmp @150
png_start_read_image @151
png_warning @152
png_write_chunk @153
png_write_chunk_data @154
png_write_chunk_end @155
png_write_chunk_start @156
png_write_end @157
png_write_flush @158
png_write_image @159
png_write_info @160
png_write_info_before_PLTE @161
png_write_init @162
png_write_png @163
png_write_row @164
png_write_rows @165
png_read_init_2 @166
png_write_init_2 @167
png_access_version_number @168
; png_sig_bytes @169
png_libpng_ver @170
png_init_io @171
png_convert_to_rfc1123 @172

828
projects/wince/pngtest.dsp Normal file
View File

@@ -0,0 +1,828 @@
# Microsoft Developer Studio Project File - Name="pngtest" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (WCE x86) Application" 0x8301
# TARGTYPE "Win32 (WCE ARM) Application" 0x8501
# TARGTYPE "Win32 (WCE PPC) Application" 0x8401
# TARGTYPE "Win32 (WCE x86em) Application" 0x7f01
# TARGTYPE "Win32 (WCE SH3) Application" 0x8101
# TARGTYPE "Win32 (WCE SH4) Application" 0x8601
# TARGTYPE "Win32 (WCE MIPS) Application" 0x8201
# TARGTYPE "Win32 (WCE MIPSFP) Application" 0x8701
CFG=pngtest - Win32 (WCE MIPS) Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "pngtest.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "pngtest.mak" CFG="pngtest - Win32 (WCE MIPS) Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "pngtest - Win32 (WCE MIPS) Release" (based on "Win32 (WCE MIPS) Application")
!MESSAGE "pngtest - Win32 (WCE MIPS) Debug" (based on "Win32 (WCE MIPS) Application")
!MESSAGE "pngtest - Win32 (WCE SH4) Release" (based on "Win32 (WCE SH4) Application")
!MESSAGE "pngtest - Win32 (WCE SH4) Debug" (based on "Win32 (WCE SH4) Application")
!MESSAGE "pngtest - Win32 (WCE SH3) Release" (based on "Win32 (WCE SH3) Application")
!MESSAGE "pngtest - Win32 (WCE SH3) Debug" (based on "Win32 (WCE SH3) Application")
!MESSAGE "pngtest - Win32 (WCE ARM) Release" (based on "Win32 (WCE ARM) Application")
!MESSAGE "pngtest - Win32 (WCE ARM) Debug" (based on "Win32 (WCE ARM) Application")
!MESSAGE "pngtest - Win32 (WCE MIPSFP) Release" (based on "Win32 (WCE MIPSFP) Application")
!MESSAGE "pngtest - Win32 (WCE MIPSFP) Debug" (based on "Win32 (WCE MIPSFP) Application")
!MESSAGE "pngtest - Win32 (WCE x86) Release" (based on "Win32 (WCE x86) Application")
!MESSAGE "pngtest - Win32 (WCE x86) Debug" (based on "Win32 (WCE x86) Application")
!MESSAGE "pngtest - Win32 (WCE x86em) Release" (based on "Win32 (WCE x86em) Application")
!MESSAGE "pngtest - Win32 (WCE x86em) Debug" (based on "Win32 (WCE x86em) Application")
!MESSAGE "pngtest - Win32 (WCE PPC) Release" (based on "Win32 (WCE PPC) Application")
!MESSAGE "pngtest - Win32 (WCE PPC) Debug" (based on "Win32 (WCE PPC) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath "H/PC Pro 2.11"
# PROP WCE_FormatVersion "6.0"
!IF "$(CFG)" == "pngtest - Win32 (WCE MIPS) Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "WMIPSRel"
# PROP BASE Intermediate_Dir "WMIPSRel"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "WMIPSRel"
# PROP Intermediate_Dir "WMIPSRel"
# PROP Target_Dir ""
CPP=clmips.exe
# ADD BASE CPP /nologo /M$(CECrt) /W3 /O2 /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D "NDEBUG" /D "MIPS" /D "_MIPS_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /YX /QMRWCE /c
# ADD CPP /nologo /M$(CECrt) /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "NDEBUG" /D "MIPS" /D "_MIPS_" /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /D "PNG_USE_DLL" /QMRWCE /c
# SUBTRACT CPP /YX
RSC=rc.exe
# ADD BASE RSC /l 0x411 /r /d "MIPS" /d "_MIPS_" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "UNICODE" /d "NDEBUG"
# ADD RSC /l 0x411 /r /d "MIPS" /d "_MIPS_" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "UNICODE" /d "NDEBUG"
MTL=midl.exe
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 commctrl.lib coredll.lib /nologo /machine:MIPS /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT BASE LINK32 /pdb:none /nodefaultlib
# ADD LINK32 commctrl.lib coredll.lib /nologo /machine:MIPS /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT LINK32 /pdb:none /nodefaultlib
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE MIPS) Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "WMIPSDbg"
# PROP BASE Intermediate_Dir "WMIPSDbg"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "WMIPSDbg"
# PROP Intermediate_Dir "WMIPSDbg"
# PROP Target_Dir ""
CPP=clmips.exe
# ADD BASE CPP /nologo /M$(CECrtDebug) /W3 /Zi /Od /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D "DEBUG" /D "MIPS" /D "_MIPS_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /YX /QMRWCE /c
# ADD CPP /nologo /M$(CECrtDebug) /W3 /Zi /Od /I "..\.." /I "..\..\..\zlib" /D "DEBUG" /D "MIPS" /D "_MIPS_" /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /D "PNG_USE_DLL" /QMRWCE /c
# SUBTRACT CPP /YX
RSC=rc.exe
# ADD BASE RSC /l 0x411 /r /d "MIPS" /d "_MIPS_" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "UNICODE" /d "DEBUG"
# ADD RSC /l 0x411 /r /d "MIPS" /d "_MIPS_" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "UNICODE" /d "DEBUG"
MTL=midl.exe
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 commctrl.lib coredll.lib /nologo /debug /machine:MIPS /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT BASE LINK32 /pdb:none /nodefaultlib
# ADD LINK32 commctrl.lib coredll.lib /nologo /debug /machine:MIPS /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT LINK32 /pdb:none /nodefaultlib
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE SH4) Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "WCESH4Rel"
# PROP BASE Intermediate_Dir "WCESH4Rel"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "WCESH4Rel"
# PROP Intermediate_Dir "WCESH4Rel"
# PROP Target_Dir ""
CPP=shcl.exe
# ADD BASE CPP /nologo /Qsh4 /MC /W3 /O2 /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D "NDEBUG" /D "SHx" /D "SH4" /D "_SH4_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /YX /c
# ADD CPP /nologo /Qsh4 /MC /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "NDEBUG" /D "SHx" /D "SH4" /D "_SH4_" /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /D "PNG_USE_DLL" /c
# SUBTRACT CPP /YX
RSC=rc.exe
# ADD BASE RSC /l 0x411 /r /d "SHx" /d "SH4" /d "_SH4_" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "UNICODE" /d "NDEBUG"
# ADD RSC /l 0x411 /r /d "SHx" /d "SH4" /d "_SH4_" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "UNICODE" /d "NDEBUG"
MTL=midl.exe
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 commctrl.lib coredll.lib /nologo /machine:SH4 /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT BASE LINK32 /pdb:none /nodefaultlib
# ADD LINK32 commctrl.lib coredll.lib /nologo /machine:SH4 /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT LINK32 /pdb:none /nodefaultlib
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE SH4) Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "WCESH4Dbg"
# PROP BASE Intermediate_Dir "WCESH4Dbg"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "WCESH4Dbg"
# PROP Intermediate_Dir "WCESH4Dbg"
# PROP Target_Dir ""
CPP=shcl.exe
# ADD BASE CPP /nologo /Qsh4 /MC /W3 /Zi /Od /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D "DEBUG" /D "SHx" /D "SH4" /D "_SH4_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /YX /c
# ADD CPP /nologo /Qsh4 /MC /W3 /Zi /Od /I "..\.." /I "..\..\..\zlib" /D "DEBUG" /D "SHx" /D "SH4" /D "_SH4_" /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /D "PNG_USE_DLL" /c
# SUBTRACT CPP /YX
RSC=rc.exe
# ADD BASE RSC /l 0x411 /r /d "SHx" /d "SH4" /d "_SH4_" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "UNICODE" /d "DEBUG"
# ADD RSC /l 0x411 /r /d "SHx" /d "SH4" /d "_SH4_" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "UNICODE" /d "DEBUG"
MTL=midl.exe
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 commctrl.lib coredll.lib /nologo /debug /machine:SH4 /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT BASE LINK32 /pdb:none /nodefaultlib
# ADD LINK32 commctrl.lib coredll.lib /nologo /debug /machine:SH4 /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT LINK32 /pdb:none /nodefaultlib
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE SH3) Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "WCESH3Rel"
# PROP BASE Intermediate_Dir "WCESH3Rel"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "WCESH3Rel"
# PROP Intermediate_Dir "WCESH3Rel"
# PROP Target_Dir ""
CPP=shcl.exe
# ADD BASE CPP /nologo /M$(CECrt) /W3 /O2 /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D "NDEBUG" /D "SHx" /D "SH3" /D "_SH3_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /YX /c
# ADD CPP /nologo /M$(CECrt) /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "NDEBUG" /D "SHx" /D "SH3" /D "_SH3_" /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /D "PNG_USE_DLL" /c
# SUBTRACT CPP /YX
RSC=rc.exe
# ADD BASE RSC /l 0x411 /r /d "SHx" /d "SH3" /d "_SH3_" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "UNICODE" /d "NDEBUG"
# ADD RSC /l 0x411 /r /d "SHx" /d "SH3" /d "_SH3_" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "UNICODE" /d "NDEBUG"
MTL=midl.exe
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 commctrl.lib coredll.lib /nologo /machine:SH3 /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT BASE LINK32 /pdb:none /nodefaultlib
# ADD LINK32 commctrl.lib coredll.lib /nologo /machine:SH3 /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT LINK32 /pdb:none /nodefaultlib
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE SH3) Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "WCESH3Dbg"
# PROP BASE Intermediate_Dir "WCESH3Dbg"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "WCESH3Dbg"
# PROP Intermediate_Dir "WCESH3Dbg"
# PROP Target_Dir ""
CPP=shcl.exe
# ADD BASE CPP /nologo /M$(CECrtDebug) /W3 /Zi /Od /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D "DEBUG" /D "SHx" /D "SH3" /D "_SH3_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /YX /c
# ADD CPP /nologo /M$(CECrtDebug) /W3 /Zi /Od /I "..\.." /I "..\..\..\zlib" /D "DEBUG" /D "SHx" /D "SH3" /D "_SH3_" /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /D "PNG_USE_DLL" /c
# SUBTRACT CPP /YX
RSC=rc.exe
# ADD BASE RSC /l 0x411 /r /d "SHx" /d "SH3" /d "_SH3_" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "UNICODE" /d "DEBUG"
# ADD RSC /l 0x411 /r /d "SHx" /d "SH3" /d "_SH3_" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "UNICODE" /d "DEBUG"
MTL=midl.exe
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 commctrl.lib coredll.lib /nologo /debug /machine:SH3 /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT BASE LINK32 /pdb:none /nodefaultlib
# ADD LINK32 commctrl.lib coredll.lib /nologo /debug /machine:SH3 /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT LINK32 /pdb:none /nodefaultlib
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE ARM) Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "WCEARMRel"
# PROP BASE Intermediate_Dir "WCEARMRel"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "WCEARMRel"
# PROP Intermediate_Dir "WCEARMRel"
# PROP Target_Dir ""
CPP=clarm.exe
# ADD BASE CPP /nologo /MC /W3 /O2 /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D "NDEBUG" /D "ARM" /D "_ARM_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /YX /c
# ADD CPP /nologo /MC /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "NDEBUG" /D "ARM" /D "_ARM_" /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /D "PNG_USE_DLL" /c
# SUBTRACT CPP /YX
RSC=rc.exe
# ADD BASE RSC /l 0x411 /r /d "ARM" /d "_ARM_" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "UNICODE" /d "NDEBUG"
# ADD RSC /l 0x411 /r /d "ARM" /d "_ARM_" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "UNICODE" /d "NDEBUG"
MTL=midl.exe
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 coredll.lib commctrl.lib /nologo /machine:ARM /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT BASE LINK32 /pdb:none /nodefaultlib
# ADD LINK32 coredll.lib commctrl.lib /nologo /machine:ARM /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT LINK32 /pdb:none /nodefaultlib
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE ARM) Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "WCEARMDbg"
# PROP BASE Intermediate_Dir "WCEARMDbg"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "WCEARMDbg"
# PROP Intermediate_Dir "WCEARMDbg"
# PROP Target_Dir ""
CPP=clarm.exe
# ADD BASE CPP /nologo /MC /W3 /Zi /Od /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D "DEBUG" /D "ARM" /D "_ARM_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /YX /c
# ADD CPP /nologo /MC /W3 /Zi /Od /I "..\.." /I "..\..\..\zlib" /D "DEBUG" /D "ARM" /D "_ARM_" /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /D "PNG_USE_DLL" /c
# SUBTRACT CPP /YX
RSC=rc.exe
# ADD BASE RSC /l 0x411 /r /d "ARM" /d "_ARM_" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "UNICODE" /d "DEBUG"
# ADD RSC /l 0x411 /r /d "ARM" /d "_ARM_" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "UNICODE" /d "DEBUG"
MTL=midl.exe
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 coredll.lib commctrl.lib /nologo /debug /machine:ARM /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT BASE LINK32 /pdb:none /nodefaultlib
# ADD LINK32 coredll.lib commctrl.lib /nologo /debug /machine:ARM /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT LINK32 /pdb:none /nodefaultlib
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE MIPSFP) Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "WMIPSFPRel"
# PROP BASE Intermediate_Dir "WMIPSFPRel"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "WMIPSFPRel"
# PROP Intermediate_Dir "WMIPSFPRel"
# PROP Target_Dir ""
CPP=clmips.exe
# ADD BASE CPP /nologo /QMFWCE /MC /W3 /O2 /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D "NDEBUG" /D "MIPS" /D "_MIPS_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /YX /c
# ADD CPP /nologo /QMFWCE /MC /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "NDEBUG" /D "MIPS" /D "_MIPS_" /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /D "PNG_USE_DLL" /c
# SUBTRACT CPP /YX
RSC=rc.exe
# ADD BASE RSC /l 0x411 /r /d "MIPS" /d "_MIPS_" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "UNICODE" /d "NDEBUG"
# ADD RSC /l 0x411 /r /d "MIPS" /d "_MIPS_" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "UNICODE" /d "NDEBUG"
MTL=midl.exe
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 commctrl.lib coredll.lib /nologo /machine:MIPS /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT BASE LINK32 /pdb:none /nodefaultlib
# ADD LINK32 commctrl.lib coredll.lib /nologo /machine:MIPS /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT LINK32 /pdb:none /nodefaultlib
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE MIPSFP) Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "WMIPSFPDbg"
# PROP BASE Intermediate_Dir "WMIPSFPDbg"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "WMIPSFPDbg"
# PROP Intermediate_Dir "WMIPSFPDbg"
# PROP Target_Dir ""
CPP=clmips.exe
# ADD BASE CPP /nologo /QMFWCE /MC /W3 /Zi /Od /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D "DEBUG" /D "MIPS" /D "_MIPS_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /YX /c
# ADD CPP /nologo /QMFWCE /MC /W3 /Zi /Od /I "..\.." /I "..\..\..\zlib" /D "DEBUG" /D "MIPS" /D "_MIPS_" /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /D "PNG_USE_DLL" /c
# SUBTRACT CPP /YX
RSC=rc.exe
# ADD BASE RSC /l 0x411 /r /d "MIPS" /d "_MIPS_" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "UNICODE" /d "DEBUG"
# ADD RSC /l 0x411 /r /d "MIPS" /d "_MIPS_" /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "UNICODE" /d "DEBUG"
MTL=midl.exe
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 commctrl.lib coredll.lib /nologo /debug /machine:MIPS /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT BASE LINK32 /pdb:none /nodefaultlib
# ADD LINK32 commctrl.lib coredll.lib /nologo /debug /machine:MIPS /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT LINK32 /pdb:none /nodefaultlib
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE x86) Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "WCEX86Rel"
# PROP BASE Intermediate_Dir "WCEX86Rel"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "WCEX86Rel"
# PROP Intermediate_Dir "WCEX86Rel"
# PROP Target_Dir ""
CPP=cl.exe
# ADD BASE CPP /nologo /ML /W3 /O2 /D "x86" /D "_i386_" /D "_x86_" /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "NDEBUG" /D "i_386_" /D "_MBCS" /Gs8192 /GF /c
# ADD CPP /nologo /ML /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "x86" /D "_i386_" /D "_x86_" /D "NDEBUG" /D "i_386_" /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /D "PNG_USE_DLL" /Gs8192 /GF /c
RSC=rc.exe
# ADD BASE RSC /l 0x411 /r /d "x86" /d "_i386_" /d "_x86_" /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d UNDER_CE=$(CEVersion) /d "UNICODE" /d "NDEBUG"
# ADD RSC /l 0x411 /r /d "x86" /d "_i386_" /d "_x86_" /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d UNDER_CE=$(CEVersion) /d "UNICODE" /d "NDEBUG"
MTL=midl.exe
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 $(CEx86Corelibc) commctrl.lib coredll.lib /nologo /machine:IX86 /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT BASE LINK32 /pdb:none /nodefaultlib
# ADD LINK32 $(CEx86Corelibc) commctrl.lib coredll.lib /nologo /machine:IX86 /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT LINK32 /pdb:none /nodefaultlib
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE x86) Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "WCEX86Dbg"
# PROP BASE Intermediate_Dir "WCEX86Dbg"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "WCEX86Dbg"
# PROP Intermediate_Dir "WCEX86Dbg"
# PROP Target_Dir ""
CPP=cl.exe
# ADD BASE CPP /nologo /MLd /W3 /Zi /Od /D "x86" /D "_i386_" /D "_x86_" /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "DEBUG" /D "i_386_" /D "_MBCS" /Gs8192 /GF /c
# ADD CPP /nologo /MLd /W3 /Zi /Od /I "..\.." /I "..\..\..\zlib" /D "x86" /D "_i386_" /D "_x86_" /D "DEBUG" /D "i_386_" /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /D "PNG_USE_DLL" /Gs8192 /GF /c
RSC=rc.exe
# ADD BASE RSC /l 0x411 /r /d "x86" /d "_i386_" /d "_x86_" /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d UNDER_CE=$(CEVersion) /d "UNICODE" /d "DEBUG"
# ADD RSC /l 0x411 /r /d "x86" /d "_i386_" /d "_x86_" /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d UNDER_CE=$(CEVersion) /d "UNICODE" /d "DEBUG"
MTL=midl.exe
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 $(CEx86Corelibc) commctrl.lib coredll.lib /nologo /debug /machine:IX86 /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT BASE LINK32 /pdb:none /nodefaultlib
# ADD LINK32 $(CEx86Corelibc) commctrl.lib coredll.lib /nologo /debug /machine:IX86 /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT LINK32 /pdb:none /nodefaultlib
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE x86em) Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "x86emRel"
# PROP BASE Intermediate_Dir "x86emRel"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "x86emRel"
# PROP Intermediate_Dir "x86emRel"
# PROP Target_Dir ""
CPP=cl.exe
# ADD BASE CPP /nologo /ML /W3 /O2 /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "STRICT" /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D "_WIN32_WCE_EMULATION" /D "INTERNATIONAL" /D "USA" /D "INTLMSG_CODEPAGE" /D "NDEBUG" /D "x86" /D "i486" /D "_x86_" /D "_MBCS" /YX /c
# ADD CPP /nologo /ML /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "_UNICODE" /D "WIN32" /D "STRICT" /D "_WIN32_WCE_EMULATION" /D "INTERNATIONAL" /D "USA" /D "INTLMSG_CODEPAGE" /D "NDEBUG" /D "x86" /D "i486" /D "_x86_" /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /D "PNG_USE_DLL" /c
# SUBTRACT CPP /YX
RSC=rc.exe
# ADD BASE RSC /l 0x411 /d UNDER_CE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "WIN32" /d "STRICT" /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "_WIN32_WCE_EMULATION" /d "INTERNATIONAL" /d "USA" /d "INTLMSG_CODEPAGE" /d "NDEBUG"
# ADD RSC /l 0x411 /d UNDER_CE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "WIN32" /d "STRICT" /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "_WIN32_WCE_EMULATION" /d "INTERNATIONAL" /d "USA" /d "INTLMSG_CODEPAGE" /d "NDEBUG"
MTL=midl.exe
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 $(CEx86Corelibc) commctrl.lib coredll.lib /nologo /stack:0x10000,0x1000 /subsystem:windows /machine:I386 /nodefaultlib:"$(CENoDefaultLib)" /windowsce:emulation
# ADD LINK32 $(CEx86Corelibc) commctrl.lib coredll.lib /nologo /stack:0x10000,0x1000 /subsystem:windows /machine:I386 /nodefaultlib:"$(CENoDefaultLib)" /windowsce:emulation
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE x86em) Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "x86emDbg"
# PROP BASE Intermediate_Dir "x86emDbg"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "x86emDbg"
# PROP Intermediate_Dir "x86emDbg"
# PROP Target_Dir ""
CPP=cl.exe
# ADD BASE CPP /nologo /MLd /W3 /Gm /Zi /Od /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "STRICT" /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D "_WIN32_WCE_EMULATION" /D "INTERNATIONAL" /D "USA" /D "INTLMSG_CODEPAGE" /D "_DEBUG" /D "x86" /D "i486" /D "_x86_" /D "_MBCS" /YX /c
# ADD CPP /nologo /MLd /W3 /Gm /Zi /Od /I "..\.." /I "..\..\..\zlib" /D "_UNICODE" /D "WIN32" /D "STRICT" /D "_WIN32_WCE_EMULATION" /D "INTERNATIONAL" /D "USA" /D "INTLMSG_CODEPAGE" /D "_DEBUG" /D "x86" /D "i486" /D "_x86_" /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /D "PNG_USE_DLL" /c
# SUBTRACT CPP /YX
RSC=rc.exe
# ADD BASE RSC /l 0x411 /d UNDER_CE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "WIN32" /d "STRICT" /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "_WIN32_WCE_EMULATION" /d "INTERNATIONAL" /d "USA" /d "INTLMSG_CODEPAGE" /d "_DEBUG" /d "x86" /d "i486" /d "_x86_"
# ADD RSC /l 0x411 /d UNDER_CE=$(CEVersion) /d "UNICODE" /d "_UNICODE" /d "WIN32" /d "STRICT" /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d "_WIN32_WCE_EMULATION" /d "INTERNATIONAL" /d "USA" /d "INTLMSG_CODEPAGE" /d "_DEBUG" /d "x86" /d "i486" /d "_x86_"
MTL=midl.exe
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 $(CEx86Corelibc) commctrl.lib coredll.lib /nologo /stack:0x10000,0x1000 /subsystem:windows /debug /machine:I386 /nodefaultlib:"$(CENoDefaultLib)" /windowsce:emulation
# ADD LINK32 $(CEx86Corelibc) commctrl.lib coredll.lib /nologo /stack:0x10000,0x1000 /subsystem:windows /debug /machine:I386 /nodefaultlib:"$(CENoDefaultLib)" /windowsce:emulation
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE PPC) Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "WCEPPCRel"
# PROP BASE Intermediate_Dir "WCEPPCRel"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "WCEPPCRel"
# PROP Intermediate_Dir "WCEPPCRel"
# PROP Target_Dir ""
CPP=clppc.exe
# ADD BASE CPP /nologo /M$(CECrt) /W3 /O2 /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D "NDEBUG" /D "PPC" /D "_PPC_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /YX /c
# ADD CPP /nologo /M$(CECrt) /W3 /O2 /I "..\.." /I "..\..\..\zlib" /D "NDEBUG" /D "PPC" /D "_PPC_" /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /D "PNG_USE_DLL" /c
# SUBTRACT CPP /YX
RSC=rc.exe
# ADD BASE RSC /l 0x411 /r /d "ppc" /d "_ppc_" /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d UNDER_CE=$(CEVersion) /d "UNICODE" /d "NDEBUG"
# ADD RSC /l 0x411 /r /d "ppc" /d "_ppc_" /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d UNDER_CE=$(CEVersion) /d "UNICODE" /d "NDEBUG"
MTL=midl.exe
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 commctrl.lib coredll.lib /nologo /machine:PPC /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT BASE LINK32 /pdb:none /nodefaultlib
# ADD LINK32 commctrl.lib coredll.lib /nologo /machine:PPC /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT LINK32 /pdb:none /nodefaultlib
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE PPC) Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "WCEPPCDbg"
# PROP BASE Intermediate_Dir "WCEPPCDbg"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "WCEPPCDbg"
# PROP Intermediate_Dir "WCEPPCDbg"
# PROP Target_Dir ""
CPP=clppc.exe
# ADD BASE CPP /nologo /M$(CECrtDebug) /W3 /Zi /Od /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D "DEBUG" /D "PPC" /D "_PPC_" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /YX /c
# ADD CPP /nologo /M$(CECrtDebug) /W3 /Zi /Od /I "..\.." /I "..\..\..\zlib" /D "DEBUG" /D "PPC" /D "_PPC_" /D _WIN32_WCE=$(CEVersion) /D "$(CEConfigName)" /D UNDER_CE=$(CEVersion) /D "UNICODE" /D "_MBCS" /D "PNG_USE_DLL" /c
# SUBTRACT CPP /YX
RSC=rc.exe
# ADD BASE RSC /l 0x411 /r /d "ppc" /d "_ppc_" /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d UNDER_CE=$(CEVersion) /d "UNICODE" /d "DEBUG"
# ADD RSC /l 0x411 /r /d "ppc" /d "_ppc_" /d _WIN32_WCE=$(CEVersion) /d "$(CEConfigName)" /d UNDER_CE=$(CEVersion) /d "UNICODE" /d "DEBUG"
MTL=midl.exe
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 commctrl.lib coredll.lib /nologo /debug /machine:PPC /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT BASE LINK32 /pdb:none /nodefaultlib
# ADD LINK32 commctrl.lib coredll.lib /nologo /debug /machine:PPC /nodefaultlib:"$(CENoDefaultLib)" /subsystem:$(CESubsystem) /STACK:65536,4096
# SUBTRACT LINK32 /pdb:none /nodefaultlib
!ENDIF
# Begin Target
# Name "pngtest - Win32 (WCE MIPS) Release"
# Name "pngtest - Win32 (WCE MIPS) Debug"
# Name "pngtest - Win32 (WCE SH4) Release"
# Name "pngtest - Win32 (WCE SH4) Debug"
# Name "pngtest - Win32 (WCE SH3) Release"
# Name "pngtest - Win32 (WCE SH3) Debug"
# Name "pngtest - Win32 (WCE ARM) Release"
# Name "pngtest - Win32 (WCE ARM) Debug"
# Name "pngtest - Win32 (WCE MIPSFP) Release"
# Name "pngtest - Win32 (WCE MIPSFP) Debug"
# Name "pngtest - Win32 (WCE x86) Release"
# Name "pngtest - Win32 (WCE x86) Debug"
# Name "pngtest - Win32 (WCE x86em) Release"
# Name "pngtest - Win32 (WCE x86em) Debug"
# Name "pngtest - Win32 (WCE PPC) Release"
# Name "pngtest - Win32 (WCE PPC) Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\pngtest.c
!IF "$(CFG)" == "pngtest - Win32 (WCE MIPS) Release"
DEP_CPP_PNGTE=\
"..\..\..\zlib\zconf.h"\
"..\..\..\zlib\zlib.h"\
"..\..\png.h"\
"..\..\pngasmrd.h"\
"..\..\pngconf.h"\
NODEP_CPP_PNGTE=\
"..\..\alloc.h"\
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE MIPS) Debug"
DEP_CPP_PNGTE=\
"..\..\..\zlib\zconf.h"\
"..\..\..\zlib\zlib.h"\
"..\..\png.h"\
"..\..\pngasmrd.h"\
"..\..\pngconf.h"\
NODEP_CPP_PNGTE=\
"..\..\alloc.h"\
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE SH4) Release"
DEP_CPP_PNGTE=\
"..\..\..\zlib\zconf.h"\
"..\..\..\zlib\zlib.h"\
"..\..\png.h"\
"..\..\pngasmrd.h"\
"..\..\pngconf.h"\
NODEP_CPP_PNGTE=\
"..\..\alloc.h"\
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE SH4) Debug"
DEP_CPP_PNGTE=\
"..\..\..\zlib\zconf.h"\
"..\..\..\zlib\zlib.h"\
"..\..\png.h"\
"..\..\pngasmrd.h"\
"..\..\pngconf.h"\
NODEP_CPP_PNGTE=\
"..\..\alloc.h"\
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE SH3) Release"
DEP_CPP_PNGTE=\
"..\..\..\zlib\zconf.h"\
"..\..\..\zlib\zlib.h"\
"..\..\png.h"\
"..\..\pngasmrd.h"\
"..\..\pngconf.h"\
NODEP_CPP_PNGTE=\
"..\..\alloc.h"\
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE SH3) Debug"
DEP_CPP_PNGTE=\
"..\..\..\zlib\zconf.h"\
"..\..\..\zlib\zlib.h"\
"..\..\png.h"\
"..\..\pngasmrd.h"\
"..\..\pngconf.h"\
NODEP_CPP_PNGTE=\
"..\..\alloc.h"\
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE ARM) Release"
DEP_CPP_PNGTE=\
"..\..\..\zlib\zconf.h"\
"..\..\..\zlib\zlib.h"\
"..\..\png.h"\
"..\..\pngasmrd.h"\
"..\..\pngconf.h"\
NODEP_CPP_PNGTE=\
"..\..\alloc.h"\
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE ARM) Debug"
DEP_CPP_PNGTE=\
"..\..\..\zlib\zconf.h"\
"..\..\..\zlib\zlib.h"\
"..\..\png.h"\
"..\..\pngasmrd.h"\
"..\..\pngconf.h"\
NODEP_CPP_PNGTE=\
"..\..\alloc.h"\
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE MIPSFP) Release"
DEP_CPP_PNGTE=\
"..\..\..\zlib\zconf.h"\
"..\..\..\zlib\zlib.h"\
"..\..\png.h"\
"..\..\pngasmrd.h"\
"..\..\pngconf.h"\
NODEP_CPP_PNGTE=\
"..\..\alloc.h"\
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE MIPSFP) Debug"
DEP_CPP_PNGTE=\
"..\..\..\zlib\zconf.h"\
"..\..\..\zlib\zlib.h"\
"..\..\png.h"\
"..\..\pngasmrd.h"\
"..\..\pngconf.h"\
NODEP_CPP_PNGTE=\
"..\..\alloc.h"\
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE x86) Release"
DEP_CPP_PNGTE=\
"..\..\..\zlib\zconf.h"\
"..\..\..\zlib\zlib.h"\
"..\..\png.h"\
"..\..\pngasmrd.h"\
"..\..\pngconf.h"\
NODEP_CPP_PNGTE=\
"..\..\alloc.h"\
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE x86) Debug"
DEP_CPP_PNGTE=\
"..\..\..\zlib\zconf.h"\
"..\..\..\zlib\zlib.h"\
"..\..\png.h"\
"..\..\pngasmrd.h"\
"..\..\pngconf.h"\
NODEP_CPP_PNGTE=\
"..\..\alloc.h"\
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE x86em) Release"
DEP_CPP_PNGTE=\
"..\..\..\zlib\zconf.h"\
"..\..\..\zlib\zlib.h"\
"..\..\png.h"\
"..\..\pngasmrd.h"\
"..\..\pngconf.h"\
NODEP_CPP_PNGTE=\
"..\..\alloc.h"\
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE x86em) Debug"
DEP_CPP_PNGTE=\
"..\..\..\zlib\zconf.h"\
"..\..\..\zlib\zlib.h"\
"..\..\png.h"\
"..\..\pngasmrd.h"\
"..\..\pngconf.h"\
NODEP_CPP_PNGTE=\
"..\..\alloc.h"\
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE PPC) Release"
DEP_CPP_PNGTE=\
"..\..\..\zlib\zconf.h"\
"..\..\..\zlib\zlib.h"\
"..\..\png.h"\
"..\..\pngasmrd.h"\
"..\..\pngconf.h"\
NODEP_CPP_PNGTE=\
"..\..\alloc.h"\
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE PPC) Debug"
DEP_CPP_PNGTE=\
"..\..\..\zlib\zconf.h"\
"..\..\..\zlib\zlib.h"\
"..\..\png.h"\
"..\..\pngasmrd.h"\
"..\..\pngconf.h"\
NODEP_CPP_PNGTE=\
"..\..\alloc.h"\
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\winmain.c
!IF "$(CFG)" == "pngtest - Win32 (WCE MIPS) Release"
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE MIPS) Debug"
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE SH4) Release"
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE SH4) Debug"
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE SH3) Release"
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE SH3) Debug"
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE ARM) Release"
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE ARM) Debug"
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE MIPSFP) Release"
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE MIPSFP) Debug"
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE x86) Release"
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE x86) Debug"
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE x86em) Release"
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE x86em) Debug"
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE PPC) Release"
!ELSEIF "$(CFG)" == "pngtest - Win32 (WCE PPC) Debug"
!ENDIF
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -0,0 +1,59 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "lpngce"=.\lpngce.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name zlibce
End Project Dependency
}}}
###############################################################################
Project: "pngtest"=.\pngtest.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name lpngce
End Project Dependency
}}}
###############################################################################
Project: "zlibce"=.\zlibce.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

86
projects/wince/winmain.c Normal file
View File

@@ -0,0 +1,86 @@
/* winmain.c - a simple entry point for WindowsCE
*
* Copyright (c) 2000 Tenik Co.,Ltd.
*/
#include <windows.h>
#include <tchar.h>
extern int main(int argc, char *argv[]);
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR lpszCmdLine, int nCmdShow)
{
#define SIZE_ARGV (32)
TCHAR path[MAX_PATH];
LPTSTR file;
char prog[MAX_PATH];
int argc;
char *argv[SIZE_ARGV];
int size;
char *buff;
char *argp;
char *args;
char quote;
// get program name
argc = 0;
GetModuleFileName(GetCurrentProcess(), path, MAX_PATH);
file = _tcsrchr(path, TEXT('\\'));
if (NULL == file) {
file = path;
}
else {
file++;
}
WideCharToMultiByte(CP_ACP, 0, file, -1, prog, MAX_PATH, NULL, NULL);
argv[argc++] = prog;
// analyze parameters
size = WideCharToMultiByte(CP_ACP, 0, lpszCmdLine, -1, NULL, 0, NULL, NULL);
buff = (char *)malloc(size);
size = WideCharToMultiByte(CP_ACP, 0, lpszCmdLine, -1, buff, size, NULL, NULL);
quote = 0x00;
args = argp = buff;
if (argp && *argp && size) {
argv[argc++] = args;
while (*argp) {
if (quote) {
if (*argp == quote) {
argp++;
if (*argp != quote) {
quote = 0x00;
}
else {
*args++ = *argp++;
}
}
else {
*args++ = *argp++;
}
}
else {
if (*argp == ' ') {
*args++ = *argp++ = '\0';
while (*argp && *argp == ' ') {
argp++;
}
if (*argp && argc < SIZE_ARGV) {
argv[argc++] = args;
}
}
else {
if (*argp == '\"') {
quote = *argp++;
}
else {
*args++ = *argp++;
}
}
}
}
}
*args = '\0';
return main(argc, argv);
}

2168
projects/wince/zlib.diff Normal file

File diff suppressed because it is too large Load Diff

44
projects/wince/zlibce.def Normal file
View File

@@ -0,0 +1,44 @@
LIBRARY zlibce.dll
EXPORTS
adler32 @1
compress @2
crc32 @3
deflate @4
deflateCopy @5
deflateEnd @6
deflateInit2_ @7
deflateInit_ @8
deflateParams @9
deflateReset @10
deflateSetDictionary @11
gzclose @12
gzdopen @13
gzerror @14
gzflush @15
gzopen @16
gzread @17
gzwrite @18
inflate @19
inflateEnd @20
inflateInit2_ @21
inflateInit_ @22
inflateReset @23
inflateSetDictionary @24
inflateSync @25
uncompress @26
zlibVersion @27
gzprintf @28
gzputc @29
gzgetc @30
gzseek @31
gzrewind @32
gztell @33
gzeof @34
gzsetparams @35
zError @36
inflateSyncPoint @37
get_crc_table @38
compress2 @39
gzputs @40
gzgets @41

2832
projects/wince/zlibce.dsp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,7 @@
// Project file for libpng (static) // Project file for libpng (static)
// IBM VisualAge/C++ version 4.0 or later // IBM VisualAge/C++ version 4.0 or later
// Copyright (C) 2000 Cosmin Truta // Copyright (C) 2000 Cosmin Truta
// For conditions of distribution and use, see copyright notice in png.h
// Notes: // Notes:
// All modules are compiled in C mode // All modules are compiled in C mode
// Tested with IBM VAC++ 4.0 under Win32 // Tested with IBM VAC++ 4.0 under Win32

View File

@@ -2,40 +2,40 @@
# Toolflags: # Toolflags:
CCflags = -c -depend !Depend -IC:,Zlib: -g -throwback -DRISCOS -fnah CCflags = -c -depend !Depend -IC:,Zlib: -g -throwback -DRISCOS -fnah
C++flags = -c -depend !Depend -IC: -throwback C++flags = -c -depend !Depend -IC: -throwback
Linkflags = -aif -c++ -o $@ Linkflags = -aif -c++ -o $@
ObjAsmflags = -throwback -NoCache -depend !Depend ObjAsmflags = -throwback -NoCache -depend !Depend
CMHGflags = CMHGflags =
LibFileflags = -c -l -o $@ LibFileflags = -c -l -o $@
Squeezeflags = -o $@ Squeezeflags = -o $@
# Final targets: # Final targets:
@.libpng-lib: @.o.png @.o.pngerror @.o.pngrio @.o.pngwio @.o.pngmem \ @.libpng-lib: @.o.png @.o.pngerror @.o.pngrio @.o.pngwio @.o.pngmem \
@.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngrtran \ @.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngrtran \
@.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil @.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil
LibFile $(LibFileflags) @.o.png @.o.pngerror @.o.pngrio @.o.pngrtran \ LibFile $(LibFileflags) @.o.png @.o.pngerror @.o.pngrio @.o.pngrtran \
@.o.pngmem @.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngwio \ @.o.pngmem @.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngwio \
@.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil @.o.pngrutil @.o.pngtrans @.o.pngwrite @.o.pngwtran @.o.pngwutil
@.mm-libpng-lib: @.mm.png @.mm.pngerror @.mm.pngrio @.mm.pngwio @.mm.pngmem \ @.mm-libpng-lib: @.mm.png @.mm.pngerror @.mm.pngrio @.mm.pngwio @.mm.pngmem \
@.mm.pngpread @.mm.pngset @.mm.pngget @.mm.pngread @.mm.pngrtran \ @.mm.pngpread @.mm.pngset @.mm.pngget @.mm.pngread @.mm.pngrtran \
@.mm.pngrutil @.mm.pngtrans @.mm.pngwrite @.mm.pngwtran @.mm.pngwutil @.mm.pngrutil @.mm.pngtrans @.mm.pngwrite @.mm.pngwtran @.mm.pngwutil
LibFile $(LibFileflags) @.mm.png @.mm.pngerror @.mm.pngrio \ LibFile $(LibFileflags) @.mm.png @.mm.pngerror @.mm.pngrio \
@.mm.pngwio @.mm.pngmem @.mm.pngpread @.mm.pngset @.mm.pngget \ @.mm.pngwio @.mm.pngmem @.mm.pngpread @.mm.pngset @.mm.pngget \
@.mm.pngread @.mm.pngrtran @.mm.pngrutil @.mm.pngtrans @.mm.pngwrite \ @.mm.pngread @.mm.pngrtran @.mm.pngrutil @.mm.pngtrans @.mm.pngwrite \
@.mm.pngwtran @.mm.pngwutil @.mm.pngwtran @.mm.pngwutil
# User-editable dependencies: # User-editable dependencies:
# (C) Copyright 1997 Tom Tanner # (C) Copyright 1997 Tom Tanner
Test: @.pngtest Test: @.pngtest
<Prefix$Dir>.pngtest <Prefix$Dir>.pngtest
@remove <Prefix$Dir>.pngtest @remove <Prefix$Dir>.pngtest
#It would be nice if you could stop "make" listing from here on! #It would be nice if you could stop "make" listing from here on!
@.pngtest: @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib @.pngtest: @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib
Link $(Linkflags) @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib Link $(Linkflags) @.o.pngtest @.libpng-lib C:o.Stubs Zlib:zlib_lib
.SUFFIXES: .o .mm .c .SUFFIXES: .o .mm .c

84
scripts/makefile.aix Normal file
View File

@@ -0,0 +1,84 @@
# makefile for libpng using gcc (generic, static library)
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# Copyright (C) 2000 Cosmin Truta
# Copyright (C) 2000 Marc O. Gloor (AIX support added, from makefile.gcc)
# For conditions of distribution and use, see copyright notice in png.h
# Location of the zlib library and include files
ZLIBINC = ../zlib
ZLIBLIB = ../zlib
# Compiler, linker, lib and other tools
CC = gcc
LD = $(CC)
AR = ar rcs
RANLIB = ranlib
RM = rm -f
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0.9beta5
PNGVER = $(PNGMAJ).$(PNGMIN)
prefix=/usr/local
INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib
CDEBUG = -g -DPNG_DEBUG=5
LDDEBUG =
CRELEASE = -O2
LDRELEASE = -s
CFLAGS = -I$(ZLIBINC) -Wall $(CRELEASE)
LDFLAGS = -L. -L$(ZLIBLIB) -lpng -lz -lm $(LDRELEASE)
# File extensions
O=.o
A=.a
E=
# Variables
OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \
pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \
pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O)
# Targets
all: libpng$(A) pngtest$(E)
libpng$(A): $(OBJS)
$(AR) $@ $(OBJS)
$(RANLIB) $@
test: pngtest$(E)
./pngtest$(E)
pngtest$(E): pngtest$(O) libpng$(A)
$(LD) -o $@ pngtest$(O) $(LDFLAGS)
install: libpng.a
-@if [ ! -d $(INCPATH) ]; then mkdir $(INCPATH); fi
-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
cp png.h pngconf.h $(INCPATH)
chmod 644 $(INCPATH)/png.h $(INCPATH)/pngconf.h
cp libpng.a $(LIBPATH)
clean:
/bin/rm -f *.o libpng.a libpng.so* pngtest pngout.png
png$(O): png.h pngconf.h
pngerror$(O): png.h pngconf.h
pngget$(O): png.h pngconf.h
pngmem$(O): png.h pngconf.h
pngpread$(O): png.h pngconf.h
pngread$(O): png.h pngconf.h
pngrio$(O): png.h pngconf.h
pngrtran$(O): png.h pngconf.h
pngrutil$(O): png.h pngconf.h
pngset$(O): png.h pngconf.h
pngtest$(O): png.h pngconf.h
pngtrans$(O): png.h pngconf.h
pngwio$(O): png.h pngconf.h
pngwrite$(O): png.h pngconf.h
pngwtran$(O): png.h pngconf.h
pngwutil$(O): png.h pngconf.h

View File

@@ -1,14 +1,20 @@
# Commodore Amiga Makefile # Commodore Amiga Makefile
# makefile for libpng and SAS C V6.55 compiler # makefile for libpng and SAS C V6.5x compiler
# Copyright (C) 1995 Wolf Faust # Copyright (C) 1995-2000 Wolf Faust
# For conditions of distribution and use, see copyright notice in png.h
#
# Note: Use #define PNG_READ_BIG_ENDIAN_SUPPORTED in pngconf.h
#
# Location/path of zlib include files
ZLIB=/zlib
#compiler #compiler
CC=sc CC=sc
#compiler flags #compiler flags
# WARNING: a bug in V6.51 causes bad code with OPTGO # WARNING: a bug in V6.51 causes bad code with OPTGO
# So use V6.55 or set NOOPTGO!!!!!!!!! # So use V6.55 or set NOOPTGO!!!!!!!!!
CFLAGS= NOSTKCHK PARMS=REG OPTIMIZE OPTGO OPTPEEP OPTINLOCAL OPTINL\ CFLAGS= NOSTKCHK PARMS=REG OPTIMIZE OPTGO OPTPEEP OPTINLOCAL OPTINL\
OPTLOOP OPTRDEP=4 OPTDEP=4 OPTCOMP=4 DEFINE=PNG_INTERNAL OPTLOOP OPTRDEP=4 OPTDEP=4 OPTCOMP=4 INCLUDEDIR=$(ZLIB) \
DEFINE=PNG_INTERNAL
#linker flags #linker flags
LDFLAGS= SD ND BATCH LDFLAGS= SD ND BATCH
#link libs #link libs
@@ -22,8 +28,9 @@ AR= oml
# make directory command # make directory command
MKDIR= makedir MKDIR= makedir
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o pngpread.o \ OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngerror.o pngwrite.o pngrtran.o pngwtran.o pngrio.o pngwio.o pngmem.o pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o
all: libpng.lib pngtest all: libpng.lib pngtest
@@ -39,4 +46,3 @@ FROM LIB:c.o pngtest.o
LIB $(LDLIBS) LIB $(LDLIBS)
< <

View File

@@ -3,7 +3,7 @@
# To build the library, do: # To build the library, do:
# "make -fmakefile.bc32" # "make -fmakefile.bc32"
# #
# ---------- 32-bit Borland C++ ---------- # -------------------- 32-bit Borland C++ --------------------
### Absolutely necessary for this makefile to work ### Absolutely necessary for this makefile to work
.AUTODEPEND .AUTODEPEND

View File

@@ -1,5 +1,5 @@
# Makefile for png32bd.dll # Makefile for png32bd.dll
# ------------- 32-bit Borland C++ ------------- # -------------------- 32-bit Borland C++ --------------------
# This makefile expects to find zlib.h and zlib32bd.lib in the # This makefile expects to find zlib.h and zlib32bd.lib in the
# $(ZLIBDIR) directory. # $(ZLIBDIR) directory.
@@ -21,7 +21,7 @@ PNGLIB=png32bd.lib
CC=bcc32 CC=bcc32
CFLAGS= -ps -O2 -N- -k- -d -r- -w-par -w-aus -I$(ZLIBDIR) \ CFLAGS= -ps -O2 -N- -k- -d -r- -w-par -w-aus -I$(ZLIBDIR) \
-DPNG_NO_GLOBAL_ARRAYS #-DPNG_DEBUG=5 -DPNG_NO_GLOBAL_ARRAYS #-DPNG_DEBUG=5
#LINK=tlink32 #LINK=tlink32
#LINK=ilink32 #LINK=ilink32
LINK=bcc32 LINK=bcc32

Some files were not shown because too many files have changed in this diff Show More