Compare commits

...

11 Commits

Author SHA1 Message Date
Glenn Randers-Pehrson
787081f75b [libpng10] Imported from libpng-1.0.14.tar 2011-09-03 12:23:05 -05:00
Glenn Randers-Pehrson
80b4f15ae3 [libpng10] Imported from libpng-1.0.13.tar 2011-09-03 12:23:02 -05:00
Glenn Randers-Pehrson
e68f5a361b Imported from libpng-1.0.12beta1.tar 2009-04-06 16:06:14 -05:00
Glenn Randers-Pehrson
328353990f Imported from libpng-1.0.11.tar 2009-04-06 16:06:12 -05:00
Glenn Randers-Pehrson
82ae383331 Imported from libpng-1.0.11rc1.tar 2009-04-06 16:06:10 -05:00
Glenn Randers-Pehrson
e1eff58f87 Imported from libpng-1.0.11beta3.tar 2009-04-06 16:06:08 -05:00
Glenn Randers-Pehrson
f64a06f5ec Imported from libpng-1.0.11beta2.tar 2009-04-06 16:06:06 -05:00
Glenn Randers-Pehrson
87c6bc984a Imported from libpng-1.0.11beta1.tar 2009-04-06 16:06:04 -05:00
Glenn Randers-Pehrson
13cfbac075 Imported from libpng-1.0.10.tar 2009-04-06 16:06:02 -05:00
Glenn Randers-Pehrson
e164447858 Imported from libpng-1.0.10rc1.tar 2009-04-06 16:06:00 -05:00
Glenn Randers-Pehrson
1909560348 Imported from libpng-1.0.10beta1.tar 2009-04-06 16:05:58 -05:00
111 changed files with 7589 additions and 12657 deletions

View File

@@ -1,58 +1,55 @@
Libpng 1.0.9 - January 31, 2001 Libpng 1.0.14 - July 8, 2002
This is a public release of libpng, intended for use in production codes. This is a public release of libpng, intended for use in production codes.
Changes since the last public release (1.0.8): Changes since the last public release (1.0.13):
Fixed typo in scripts/makefile.hpux Changed ${PNGMAJ}.${PNGVER} bug to ${PNGVER} in makefile.sgi and makefile.sggcc
Fixed seqence-point bug in contrib/pngminus/png2pnm (Martin Zinser) Fixed VER -> PNGVER typo in makefile.macosx and added install-static to install
Updated makevms.com in scripts and contrib/* and contrib/* (Martin Zinser) Added install: target to makefile.32sunu and makefile.64sunu
Changed "cdrom.com" in documentation to "libpng.org" Revised 15 makefiles to link libpng.a to libpngNN.a and the include libpng
Revised pnggccrd.c to get it all working, and updated makefile.gcmmx (Greg). subdirectory to libpngNN subdirectory without the full pathname.
Changed type of "params" from voidp to png_voidp in png_read|write_png(). Moved generation of libpng.pc from "install" to "all" in 15 makefiles.
Added MNG_EXTENSIONS_SUPPORTED macro and support for some proposed MNG Added install-man target to 15 makefiles (Dimitri Papadopolous-Orfanos).
features, for testing purposes. Added $(DESTDIR) feature to 24 makefiles (Tim Mooney)
Make sure PNGAPI and PNG_IMPEXP are defined in pngconf.h. Fixed bug with $prefix, should be $(prefix) in makefile.hpux.
Revised the 3 instances of WRITEFILE in pngtest.c. Updated cygwin-specific portion of pngconf.h and revised makefile.cygwin
Updated png.rc in dll/msvc project Added a link from libpngNN.pc to libpng.pc in 15 makefiles.
Revised makefile.dec to define and use LIBPATH and INCPATH Added links from include/libpngNN/*.h to include/*.h in 24 makefiles.
Increased size of global png_libpng_ver[] array from 12 to 18 chars. Revised makefile.darwin to make relative links without full pathname.
Made global png_libpng_ver[], png_sig[] and png_pass_*[] arrays const. Added setjmp() at the end of png_create_*_struct_2() in case user forgets
Removed duplicate png_crc_finish() from png_handle_bKGD() function. to put one in their application.
Added a warning when application calls png_read_update_info() multiple times. Fixed bug in reporting number of channels in pngget.c, introduced in
Revised makefile.cygwin version 1.2.2
Fixed bugs in iCCP support in pngrutil.c and pngwutil.c. Added "libpng.pc" dependency to the "install-shared" target in 15 makefiles.
Replaced png_set_empty_plte_permitted() with png_permit_mng_features(). Remove old libpng.pc and libpngNN.pc before installing new ones.
Relocated "msvc" and "wince" project subdirectories into "projects" Revised 15 makefiles to build libpng-config and libpngNN-config from
subdirectory and added projects/borland project subdirectory. libpng-config-*.in.
Set VS_FF_PRERELEASE and VS_FF_PATCHED flags in msvc/png.rc when appropriate. Added "Win32 DLL VB" configuration to projects/msvc/libpng.dsp
Add error message in png_set_compression_buffer_size() when malloc fails. Changed "error" and "message" in prototypes to "error_message" and
Revised PNG_LIBPNG_BUILD_TYPE macro in png.h, used in the msvc project. "warning_message" to avoid namespace conflict.
Removed the png_flush() in pngwrite.c that crashes some applications Restored png_zalloc and png_zfree to nonexported form as in libpng-1.2.1.
that don't set png_output_flush_fn. Removed description of png_set_mem_fn() from documentation.
Added makefile.macosx and makefile.aix to scripts directory. Revised projects/msvc/README.txt
Change png_chunk_warning to png_warning in png_check_keyword(). Added libpng.pc and libpng-config to "all:" target in 16 makefiles.
Increased the first part of msg buffer from 16 to 18 in png_chunk_error(). Fixed bug in 16 makefiles: $(DESTDIR)/$(LIBPATH) to $(DESTDIR)$(LIBPATH)
Added support for filter method 64 (for PNG datastreams embedded in MNG) Added missing "\" before closing double quote in makefile.gcmmx.
Revised png_set_filter() to accept filter method 64 when appropriate. Plugged various memory leaks; added png_malloc_warn() and png_set_text_2()
Added new PNG_HAVE_PNG_SIGNATURE bit to png_ptr->mode and use it to functions.
help prevent applications from using MNG features in PNG datastreams. Plugged memory leak of png_ptr->current_text (Matt Holgate).
Revised libpng.3/libpng.txt. Changed "filter type" to "filter method". Check for buffer overflow before reading CRC in pngpread.c (Warwick Allison)
Fixed error handling of unknown compression type in png_decompress_chunk(). Added -soname to the loader flags in makefile.dec, makefile.sgi, and
In pngconf.h, define __cdecl when _MSC_VER is defined. makefile.sggcc.
Changed PNG_TEXT_COMPRESSION_zTXt to PNG_COMPRESSION_TYPE_BASE several places. Added "test-installed" targets to makefile.linux, makefile.gcmmx,
Revised memory management in png_set_hIST and png_handle_hIST in a backward makefile.sgi, makefile.sggcc, makefile.32sunu, makefile.64sunu,
compatible manner. PLTE and tRNS were revised similarly. makefile.beos, makefile.darwin, makefile.dec, makefile.macosx,
Revised the iCCP chunk reader to ignore trailing garbage. makefile.solaris, makefile.sco, makefile.cygwin, makefile.hpux,
Moved pngasmrd.h into pngconf.h. makefile.hpgcc, and makefile.so9.
Improved handling of out-of-spec garbage iCCP chunks generated by PhotoShop. Plugged memory leak of row_buf in pngtest.c when there is a png_error().
Added png_set_invalid to wince and msvc project module definition files. Detect buffer overflow in pngpread.c when IDAT is corrupted with extra data.
Fixed bug with progressive reading of narrow interlaced images in pngpread.c Revised pnggccrd.c to be able to back out version 1.0.x via PNG_1_0_X macro.
Do not typedef png_FILE_io in pngconf.h when PNG_NO_STDIO is defined. Changed png_warning() to png_error() when width is too large to process.
Updated makefile.sgi to make shared library.
Added check of cygwin's ALL_STATIC in pngconf.h
Added "-nommx" parameter to contrib/gregbook/rpng2-win and rpng2-x demos.
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

264
CHANGES
View File

@@ -1,3 +1,4 @@
CHANGES - changes for libpng CHANGES - changes for libpng
version 0.2 version 0.2
@@ -732,10 +733,11 @@ version 1.0.6j [May 3, 2000]
version 1.0.7beta11 [May 7, 2000] version 1.0.7beta11 [May 7, 2000]
Removed the new PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT modes Removed the new PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT modes
which are no longer used. which are no longer used.
Eliminated the three new members of png_text when PNG_NO_iTXt_SUPPORTED Eliminated the three new members of png_text when PNG_LEGACY_SUPPORTED is
or PNG_LEGACY_SUPPORTED is defined. defined or when neither PNG_READ_iTXt_SUPPORTED nor PNG_WRITE_iTXT_SUPPORTED
Made PNG_NO_ITXT_SUPPORTED the default setting, to avoid memory overrun is defined.
when old applications fill the info_ptr->text structure directly. Made PNG_NO_READ|WRITE_iTXt 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. 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 Relocated version macro definitions ahead of the includes of zlib.h and
pngconf.h in png.h. pngconf.h in png.h.
@@ -893,6 +895,260 @@ version 1.0.9rc2 [January 22, 2001]
version 1.0.9 [January 31, 2001] version 1.0.9 [January 31, 2001]
Added check of cygwin's ALL_STATIC in pngconf.h Added check of cygwin's ALL_STATIC in pngconf.h
Added "-nommx" parameter to contrib/gregbook/rpng2-win and rpng2-x demos. Added "-nommx" parameter to contrib/gregbook/rpng2-win and rpng2-x demos.
version 1.0.10beta1 [March 14, 2001]
Revised makefile.dec, makefile.sgi, and makefile.sggcc; added makefile.hpgcc.
Reformatted libpng.3 to eliminate bad line breaks.
Added checks for _mmx_supported in the read_filter_row function of pnggccrd.c
Added prototype for png_mmx_support() near the top of pnggccrd.c
Moved some error checking from png_handle_IHDR to png_set_IHDR.
Added PNG_NO_READ_SUPPORTED and PNG_NO_WRITE_SUPPORTED macros.
Revised png_mmx_support() function in pnggccrd.c
Restored version 1.0.8 PNG_WRITE_EMPTY_PLTE_SUPPORTED behavior in pngwutil.c
Fixed memory leak in contrib/visupng/PngFile.c
Fixed bugs in png_combine_row() in pnggccrd.c and pngvcrd.c (C version)
Added warnings when retrieving or setting gamma=0.
Increased the first part of msg buffer from 16 to 18 in png_chunk_warning().
version 1.0.10rc1 [March 23, 2001]
Changed all instances of memcpy, strcpy, and strlen to png_memcpy, png_strcpy,
and png_strlen.
Revised png_mmx_supported() function in pnggccrd.c to return proper value.
Fixed bug in progressive reading (pngpread.c) with small images (height < 8).
version 1.0.10 [March 30, 2001]
Deleted extraneous space (introduced in 1.0.9) from line 42 of makefile.cygwin
Added beos project files (Chris Herborth)
version 1.0.11beta1 [April 3, 2001]
Added type casts on several png_malloc() calls (Dimitri Papadapoulos).
Removed a no-longer needed AIX work-around from pngconf.h
Changed several "//" single-line comments to C-style in pnggccrd.c
version 1.0.11beta2 [April 11, 2001]
Removed PNGAPI from several functions whose prototypes did not have PNGAPI.
Updated scripts/pngos2.def
version 1.0.11beta3 [April 14, 2001]
Added checking the results of many instances of png_malloc() for NULL
version 1.0.11beta4 [April 20, 2001]
Undid the changes from version 1.0.11beta3. Added a check for NULL return
from user's malloc_fn().
Removed some useless type casts of the NULL pointer.
Added makefile.netbsd
version 1.0.11 [April 27, 2001]
Revised makefile.netbsd
version 1.0.12beta1 [May 14, 2001]
Test for Windows platform in pngconf.h when including malloc.h (Emmanuel Blot)
Updated makefile.cygwin and handling of Cygwin's ALL_STATIC in pngconf.h
Added some never-to-be-executed code in pnggccrd.c to quiet compiler warnings.
Eliminated the png_error about apps using png_read|write_init(). Instead,
libpng will reallocate the png_struct and info_struct if they are too small.
This retains future binary compatibility for old applications written for
libpng-0.88 and earlier.
version 1.2.0beta1 [May 6, 2001]
Bumped DLLNUM to 2.
Re-enabled PNG_MNG_FEATURES_SUPPORTED and enabled PNG_ASSEMBLER_CODE_SUPPORTED
by default.
Added runtime selection of MMX features.
Added png_set_strip_error_numbers function and related macros.
version 1.2.0beta2 [May 7, 2001]
Finished merging 1.2.0beta1 with version 1.0.11
Added a check for attempts to read or write PLTE in grayscale PNG datastreams.
version 1.2.0beta3 [May 17, 2001]
Enabled user memory function by default.
Modified png_create_struct so it passes user mem_ptr to user memory allocator.
Increased png_mng_features flag from png_byte to png_uint_32.
Bumped shared-library (so-number) and dll-number to 3.
version 1.2.0beta4 [June 23, 2001]
Check for missing profile length field in iCCP chunk and free chunk_data
in case of truncated iCCP chunk.
Bumped shared-library number to 3 in makefile.sgi and makefile.sggcc
Bumped dll-number from 2 to 3 in makefile.cygwin
Revised contrib/gregbook/rpng*-x.c to avoid a memory leak and to exit cleanly
if user attempts to run it on an 8-bit display.
Updated contrib/gregbook
Use png_malloc instead of png_zalloc to allocate palette in pngset.c
Updated makefile.ibmc
Added some typecasts to eliminate gcc 3.0 warnings. Changed prototypes
of png_write_oFFS width and height from png_uint_32 to png_int_32.
Updated example.c
Revised prototypes for png_debug_malloc and png_debug_free in pngtest.c
version 1.2.0beta5 [August 8, 2001]
Revised contrib/gregbook
Revised makefile.gcmmx
Revised pnggccrd.c to conditionally compile some thread-unsafe code only
when PNG_THREAD_UNSAFE_OK is defined.
Added tests to prevent pngwutil.c from writing a bKGD or tRNS chunk with
value exceeding 2^bit_depth-1
Revised makefile.sgi and makefile.sggcc
Replaced calls to fprintf(stderr,...) with png_warning() in pnggccrd.c
Removed restriction that do_invert_mono only operate on 1-bit opaque files
version 1.2.0 [September 1, 2001]
Changed a png_warning() to png_debug() in pnggccrd.c
Fixed contrib/gregbook/rpng-x.c, rpng2-x.c to avoid crash with XFreeGC().
version 1.2.1beta1 [October 19, 2001]
Revised makefile.std in contrib/pngminus
Include background_1 in png_struct regardless of gamma support.
Revised makefile.netbsd and makefile.macosx, added makefile.darwin.
Revised example.c to provide more details about using row_callback().
version 1.2.1beta2 [October 25, 2001]
Added type cast to each NULL appearing in a function call, except for
WINCE functions.
Added makefile.so9.
version 1.2.1beta3 [October 27, 2001]
Removed type casts from all NULLs.
Simplified png_create_struct_2().
version 1.2.1beta4 [November 7, 2001]
Revised png_create_info_struct() and png_creat_struct_2().
Added error message if png_write_info() was omitted.
Type cast NULLs appearing in function calls when _NO_PROTO or
PNG_TYPECAST_NULL is defined.
version 1.2.1rc1 [November 24, 2001]
Type cast NULLs appearing in function calls except when PNG_NO_TYPECAST_NULL
is defined.
Changed typecast of "size" argument to png_size_t in pngmem.c calls to
the user malloc_fn, to agree with the prototype in png.h
Added a pop/push operation to pnggccrd.c, to preserve Eflag (Maxim Sobolev)
Updated makefile.sgi to recognize LIBPATH and INCPATH.
Updated various makefiles so "make clean" does not remove previous major
version of the shared library.
version 1.2.1rc2 [December 4, 2001]
Always allocate 256-entry internal palette, hist, and trans arrays, to
avoid out-of-bounds memory reference caused by invalid PNG datastreams.
Added a check for prefix_length > data_length in iCCP chunk handler.
version 1.2.1 [December 7, 2001]
None.
version 1.2.2beta1 [February 22, 2002]
Fixed a bug with reading the length of iCCP profiles (Larry Reeves).
Revised makefile.linux, makefile.gcmmx, and makefile.sgi to generate
libpng.a, libpng12.so (not libpng.so.3), and libpng12/png.h
Revised makefile.darwin to remove "-undefined suppress" option.
Added checks for gamma and chromaticity values over 21474.83, which exceed
the limit for PNG unsigned 32-bit integers when encoded.
Revised calls to png_create_read_struct() and png_create_write_struct()
for simpler debugging.
Revised png_zalloc() so zlib handles errors (uses PNG_FLAG_MALLOC_NULL_MEM_OK)
version 1.2.2beta2 [February 23, 2002]
Check chunk_length and idat_size for invalid (over PNG_MAX_UINT) lengths.
Check for invalid image dimensions in png_get_IHDR.
Added missing "fi;" in the install target of the SGI makefiles.
Added install-static to all makefiles that make shared libraries.
Always do gamma compensation when image is partially transparent.
version 1.2.2beta3 [March 7, 2002]
Compute background.gray and background_1.gray even when color_type is RGB
in case image gets reduced to gray later.
Modified shared-library makefiles to install pkgconfig/libpngNN.pc.
Export (with PNGAPI) png_zalloc, png_zfree, and png_handle_as_unknown
Removed unused png_write_destroy_info prototype from png.h
Eliminated incorrect use of width_mmx from pnggccrd.c in pixel_bytes == 8 case
Added install-shared target to all makefiles that make shared libraries.
Stopped a double free of palette, hist, and trans when not using free_me.
Added makefile.32sunu for Sun Ultra 32 and makefile.64sunu for Sun Ultra 64.
version 1.2.2beta4 [March 8, 2002]
Compute background.gray and background_1.gray even when color_type is RGB
in case image gets reduced to gray later (Jason Summers).
Relocated a misplaced /bin/rm in the "install-shared" makefile targets
Added PNG_1_0_X macro which can be used to build a 1.0.x-compatible library.
version 1.2.2beta5 [March 26, 2002]
Added missing PNGAPI to several function definitions.
Check for invalid bit_depth or color_type in png_get_IHDR(), and
check for missing PLTE or IHDR in png_push_read_chunk() (Matthias Clasen).
Revised iTXt support to accept NULL for lang and lang_key.
Compute gamma for color components of background even when color_type is gray.
Changed "()" to "{}" in scripts/libpng.pc.in.
Revised makefiles to put png.h and pngconf.h only in $prefix/include/libpngNN
Revised makefiles to make symlink to libpng.so.NN in addition to libpngNN.so
version 1.2.2beta6 [March 31, 2002]
version 1.0.13beta1 [March 31, 2002]
Prevent png_zalloc() from trying to memset memory that it failed to acquire.
Add typecasts of PNG_MAX_UINT in pngset_cHRM_fixed() (Matt Holgate).
Ensure that the right function (user or default) is used to free the
png_struct after an error in png_create_read_struct_2().
version 1.2.2rc1 [April 7, 2002]
version 1.0.13rc1 [April 7, 2002]
Save the ebx register in pnggccrd.c (Sami Farin)
Add "mem_ptr = png_ptr->mem_ptr" in png_destroy_write_struct() (Paul Gardner).
Updated makefiles to put headers in include/libpng and remove old include/*.h.
version 1.2.2 [April 15, 2002]
version 1.0.13 [April 15, 2002]
Revised description of png_set_filter() in libpng.3/libpng.txt.
Revised makefile.netbsd and added makefile.neNNbsd and makefile.freebsd
version 1.0.13patch01 [April 17, 2002]
version 1.2.2patch01 [April 17, 2002]
Changed ${PNGMAJ}.${PNGVER} bug to ${PNGVER} in makefile.sgi and makefile.sggcc
Fixed VER -> PNGVER typo in makefile.macosx and added install-static to install
Added install: target to makefile.32sunu and makefile.64sunu
version 1.0.13patch03 [April 18, 2002]
version 1.2.2patch03 [April 18, 2002]
Revised 15 makefiles to link libpng.a to libpngNN.a and the include libpng
subdirectory to libpngNN subdirectory without the full pathname.
Moved generation of libpng.pc from "install" to "all" in 15 makefiles.
version 1.2.3rc1 [April 28, 2002]
Added install-man target to 15 makefiles (Dimitri Papadopolous-Orfanos).
Added $(DESTDIR) feature to 24 makefiles (Tim Mooney)
Fixed bug with $prefix, should be $(prefix) in makefile.hpux.
Updated cygwin-specific portion of pngconf.h and revised makefile.cygwin
Added a link from libpngNN.pc to libpng.pc in 15 makefiles.
Added links from include/libpngNN/*.h to include/*.h in 24 makefiles.
Revised makefile.darwin to make relative links without full pathname.
Added setjmp() at the end of png_create_*_struct_2() in case user forgets
to put one in their application.
Restored png_zalloc() and png_zfree() prototypes to version 1.2.1 and
removed them from module definition files.
version 1.2.3rc2 [May 1, 2002]
Fixed bug in reporting number of channels in pngget.c and pngset.c,
that was introduced in version 1.2.2beta5.
Exported png_zalloc(), png_zfree(), png_default_read(), png_default_write(),
png_default_flush(), and png_push_fill_buffer() and included them in
module definition files.
Added "libpng.pc" dependency to the "install-shared" target in 15 makefiles.
version 1.2.3rc3 [May 1, 2002]
Revised prototype for png_default_flush()
Remove old libpng.pc and libpngNN.pc before installing new ones.
version 1.2.3rc4 [May 2, 2002]
Typos in *.def files (png_default_read|write -> png_default_read|write_data)
In makefiles, changed rm libpng.NN.pc to rm libpngNN.pc
Added libpng-config and libpngNN-config and modified makefiles to install them.
Changed $(MANPATH) to $(DESTDIR)$(MANPATH) in makefiles
Added "Win32 DLL VB" configuration to projects/msvc/libpng.dsp
version 1.2.3rc5 [May 11, 2002]
Changed "error" and "message" in prototypes to "error_message" and
"warning_message" to avoid namespace conflict.
Revised 15 makefiles to build libpng-config from libpng-config-*.in
Once more restored png_zalloc and png_zfree to regular nonexported form.
Restored png_default_read|write_data, png_default_flush, png_read_fill_buffer
to nonexported form, but with PNGAPI, and removed them from module def files.
version 1.2.3rc6 [May 14, 2002]
Removed "PNGAPI" from png_zalloc() and png_zfree() in png.c
Changed "Gz" to "Gd" in projects/msvc/libpng.dsp and zlib.dsp.
Removed leftover libpng-config "sed" script from four makefiles.
Revised libpng-config creating script in 16 makefiles.
version 1.2.3 [May 22, 2002]
Revised libpng-config target in makefile.cygwin.
Removed description of png_set_mem_fn() from documentation.
Revised makefile.freebsd.
Minor cosmetic changes to 15 makefiles, e.g., $(DI) = $(DESTDIR)/$(INCDIR).
Revised projects/msvc/README.txt
Changed -lpng to -lpngNN in LDFLAGS in several makefiles.
version 1.2.4beta1 [May 24, 2002]
Added libpng.pc and libpng-config to "all:" target in 16 makefiles.
Fixed bug in 16 makefiles: $(DESTDIR)/$(LIBPATH) to $(DESTDIR)$(LIBPATH)
Added missing "\" before closing double quote in makefile.gcmmx.
Plugged various memory leaks; added png_malloc_warn() and png_set_text_2()
functions.
version 1.2.4beta2 [June 25, 2002]
Plugged memory leak of png_ptr->current_text (Matt Holgate).
Check for buffer overflow before reading CRC in pngpread.c (Warwick Allison)
Added -soname to the loader flags in makefile.dec, makefile.sgi, and
makefile.sggcc.
Added "test-installed" target to makefile.linux, makefile.gcmmx,
makefile.sgi, and makefile.sggcc.
version 1.2.4beta3 [June 28, 2002]
Plugged memory leak of row_buf in pngtest.c when there is a png_error().
Detect buffer overflow in pngpread.c when IDAT is corrupted with extra data.
Added "test-installed" target to makefile.32sunu, makefile.64sunu,
makefile.beos, makefile.darwin, makefile.dec, makefile.macosx,
makefile.solaris, makefile.hpux, makefile.hpgcc, and makefile.so9.
version 1.2.4rc1 [July 2, 2002]
Added "test-installed" target to makefile.cygwin and makefile.sco.
Revised pnggccrd.c to be able to back out version 1.0.x via PNG_1_0_X macro.
version 1.0.14 [July 8, 2002]
Changed png_warning() to png_error() when width is too large to process.
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

34
INSTALL
View File

@@ -1,5 +1,5 @@
Installing libpng version 1.0.9 - January 31, 2001 Installing libpng version 1.0.14 - July 8, 2002
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.9" or "lpng109" and "zlib-1.1.3" might be called "libpng-1.0.14" 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:
@@ -28,9 +28,11 @@ Your directory structure should look like this:
pngsuite pngsuite
visupng visupng
projects projects
beos
borland borland
msvc msvc
wince netware.txt
wince.txt
scripts scripts
makefile.* makefile.*
pngtest.png pngtest.png
@@ -47,9 +49,12 @@ 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.
If you are building libpng with MSVC, you can enter the libpng\msvc directory If you are building libpng with MSVC, you can enter the libpng\msvc directory
and follow the instructions in msvc\README.txt. You can build libpng for and follow the instructions in msvc\README.txt.
WindowsCE by entering the libpng\wince directory and following the
instructions in the README* files. You can build libpng for WindowsCE by entering the downloading and installing
the libpng\wince directory as instructed in the projects\wince.txt file, and
then following the instructions in the README* files. Similarly, you can
build libpng for Netware as instructed in projects\netware.txt.
Else enter the zlib directory and follow the instructions in zlib/README, 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 then come back here and choose the appropriate makefile.sys in the scripts
@@ -59,8 +64,8 @@ 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.9) makefile.linux => Linux/ELF makefile (gcc, creates libpng10.so.0.1.0.14)
makefile.gcmmx => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.9, makefile.gcmmx => Linux/ELF makefile (gcc, creates libpng10.so.0.1.0.14,
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
@@ -68,16 +73,25 @@ include
ftp://ftp.cs.wisc.edu/ghost) ftp://ftp.cs.wisc.edu/ghost)
makefile.aix => AIX makefile makefile.aix => AIX makefile
makefile.cygwin => Cygwin/gcc makefile makefile.cygwin => Cygwin/gcc makefile
makefile.darwin => Darwin makefile
makefile.dec => DEC Alpha UNIX makefile makefile.dec => DEC Alpha UNIX makefile
makefile.hpgcc => FreeBSD makefile
makefile.hpgcc => HPUX makefile using gcc
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 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.macosx => MACOS X Makefile
makefile.netbsd => NetBSD/cc makefile, uses PNGGCCRD, makes libpng.so.
makefile.ne0bsd => NetBSD/cc makefile, uses PNGGCCRD, makes libpng0.so
makefile.openbsd => OpenBSD 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.9) makefile.sggcc => Silicon Graphics (gcc, creates libpng10.so.0.1.0.14)
makefile.sunos => Sun makefile makefile.sunos => Sun makefile
makefile.solaris => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.9) makefile.solaris => Solaris 2.X makefile (gcc, creates libpng10.so.0.1.0.14)
makefile.so9 => Solaris 9 makefile (gcc, creates libpng10.so.0.1.0.14)
makefile.32sunu => Sun Ultra 32-bit makefile
makefile.64sunu => Sun Ultra 64-bit makefile
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

View File

@@ -1,4 +1,11 @@
Known bugs in libpng-1.0.9 Known bugs in libpng version 1.0.14
1. April 22, 2001: pnggccrd.c has been reported to crash on NetBSD when
reading interlaced PNG files, when assembler code is enabled but running
on a non-MMX i386 platform.
STATUS: Under investigation. The change to pnggccrd.c in libpng-1.2.1
fixed a problem under FreeBSD but not the problem with NetBSD, which
still fails as of libpng-1.2.2rc1.
None.

View File

@@ -8,8 +8,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
If you modify libpng you may insert additional notices immediately following If you modify libpng you may insert additional notices immediately following
this sentence. this sentence.
libpng versions 1.0.7, July 1, 2000, through 1.0.9, January 31, 2001, are libpng versions 1.0.7, July 1, 2000, through 1.0.14, July 8, 2002, are
Copyright (c) 2000 Glenn Randers-Pehrson Copyright (c) 2000-2002 Glenn Randers-Pehrson
and are distributed according to the same disclaimer and license as libpng-1.0.6 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 with the following individuals added to the list of Contributing Authors
@@ -99,4 +99,4 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson Glenn Randers-Pehrson
randeg@alum.rpi.edu randeg@alum.rpi.edu
January 31, 2001 July 8, 2002

29
README
View File

@@ -1,4 +1,4 @@
README for libpng 1.0.9 - January 31, 2001 (shared library 2.1) README for libpng 1.0.14 - July 8, 2002 (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.
@@ -172,19 +172,24 @@ Files in this distribution:
pngsuite => Test images pngsuite => Test images
visupng => Contains a MSVC workspace for VisualPng visupng => Contains a MSVC workspace for VisualPng
projects => Contains project files and workspaces for building DLL projects => Contains project files and workspaces for building DLL
beos => Contains a Beos workspace for building libpng
borland => Contains a Borland workspace for building libpng borland => Contains a Borland workspace for building libpng
and zlib and zlib
msvc => Contains a Microsoft Visual C++ (MSVC) workspace msvc => Contains a Microsoft Visual C++ (MSVC) workspace
for building libpng and zlib for building libpng and zlib
wince => Contains a Microsoft Visual C++ (Windows CD Toolkit) netware.txt => Contains instructions for downloading a set of
workspace for building libpng and zlib on WindowsCE project files for building libpng and zlib on
Netware.
wince.txt => Contains instructions for downloading 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.9) (gcc, creates libpng10.so.0.1.0.14)
makefile.gcmmx => Linux/ELF makefile (gcc, creates makefile.gcmmx => Linux/ELF makefile (gcc, creates
libpng.so.2.1.0.9, uses assembler code libpng10.so.0.1.0.14, 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
@@ -192,17 +197,27 @@ Files in this distribution:
ftp://ftp.cs.wisc.edu/ghost) ftp://ftp.cs.wisc.edu/ghost)
makefile.aix => AIX makefile makefile.aix => AIX makefile
makefile.cygwin => Cygwin/gcc makefile makefile.cygwin => Cygwin/gcc makefile
makefile.darwin => Darwin makefile
makefile.dec => DEC Alpha UNIX makefile makefile.dec => DEC Alpha UNIX makefile
makefile.freebsd => FreeBSD makefile
makefile.hpgcc => HPUX makefile using gcc
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 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.macosx => MACOS X Makefile
makefile.netbsd => NetBSD/cc makefile, PNGGCCRD, makes libpng.so.
makefile.ne0bsd => NetBSD/cc makefile, PNGGCCRD, makes libpng0.so
makefile.openbsd => OpenBSD 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.9) makefile.sggcc => Silicon Graphics (gcc, creates libpng10.so.0.1.0.14)
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.9) (gcc, creates libpng10.so.0.1.0.14)
makefile.so9 => Solaris 9 makefile
(gcc, creates libpng10.so.0.1.0.14)
makefile.32sunu => Sun Ultra 32-bit makefile
makefile.64sunu => Sun Ultra 64-bit makefile
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

View File

@@ -1,13 +1,13 @@
Y2K compliance in libpng: Y2K compliance in libpng:
========================= =========================
January 31, 2001 July 8, 2002
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.9 are Y2K compliant. It is my belief that earlier upward through 1.0.14 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.9. Instead, please There is no \"configure\" script for Libpng-1.0.14. 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

@@ -1,6 +1,6 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. Copyright (c) 1998-2001 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors

View File

@@ -1,6 +1,6 @@
# Sample makefile for rpng-x / rpng2-x / wpng for SGI using cc and make. # Sample makefile for rpng-x / rpng2-x / wpng for SGI using cc and make.
# Greg Roelofs # Greg Roelofs
# Last modified: 16 January 1000 # Last modified: 7 March 2002
# #
# The programs built by this makefile are described in the book, # The programs built by this makefile are described in the book,
# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and # "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and
@@ -23,9 +23,9 @@
# macros -------------------------------------------------------------------- # macros --------------------------------------------------------------------
PNGINC = -I/usr/local/include PNGINC = -I/usr/local/include/libpng10
PNGLIB = -L/usr/local/lib -lpng # dynamically linked against libpng PNGLIB = -L/usr/local/lib -lpng10 # dynamically linked against libpng
#PNGLIB = /usr/local/lib/libpng.a # statically linked against libpng #PNGLIB = /usr/local/lib/libpng10.a # statically linked against libpng
# or: # or:
#PNGINC = -I../.. #PNGINC = -I../..
#PNGLIB = -L../.. -lpng #PNGLIB = -L../.. -lpng

View File

@@ -1,6 +1,6 @@
# Sample makefile for rpng-x / rpng2-x / wpng using gcc and make. # Sample makefile for rpng-x / rpng2-x / wpng using gcc and make.
# Greg Roelofs # Greg Roelofs
# Last modified: 28 February 2000 # Last modified: 7 March 2002
# #
# The programs built by this makefile are described in the book, # The programs built by this makefile are described in the book,
# "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and # "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and
@@ -23,24 +23,24 @@
# macros -------------------------------------------------------------------- # macros --------------------------------------------------------------------
PNGINC = -I/usr/local/include PNGINC = -I/usr/local/include/libpng10
#PNGLIB = -L/usr/local/lib -lpng # dynamically linked against libpng #PNGLIB = -L/usr/local/lib -lpng10 # dynamically linked against libpng
PNGLIB = /usr/local/lib/libpng.a # statically linked against libpng PNGLIB = /usr/local/lib/libpng10.a # statically linked against libpng
# or: # or:
#PNGINC = -I../.. #PNGINC = -I../libpng
#PNGLIB = -L../.. -lpng #PNGLIB = -L../libpng -lpng
#PNGLIB = ../../libpng.a #PNGLIB = ../libpng/libpng.a
ZINC = -I/usr/local/include ZINC = -I/usr/local/include
#ZLIB = -L/usr/local/lib -lz # dynamically linked against zlib #ZLIB = -L/usr/local/lib -lz # dynamically linked against zlib
ZLIB = /usr/local/lib/libz.a # statically linked against zlib ZLIB = /usr/local/lib/libz.a # statically linked against zlib
#ZINC = -I../zlib #ZINC = -I../zlib
#ZLIB = -L../zlib -lz #ZLIB = -L../zlib -lz
#ZLIB = ../../../zlib/libz.a #ZLIB = ../zlib/libz.a
#XINC = -I/usr/include/X11 # old-style, stock X distributions #XINC = -I/usr/include # old-style, stock X distributions
#XLIB = -L/usr/lib/X11 -lX11 #XLIB = -L/usr/lib/X11 -lX11
#XINC = -I/usr/openwin/include # 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

@@ -32,12 +32,12 @@
# macros -------------------------------------------------------------------- # macros --------------------------------------------------------------------
PNGPATH = ../.. PNGPATH = ../libpng
PNGINC = -I$(PNGPATH) PNGINC = -I$(PNGPATH)
#PNGLIB = $(PNGPATH)/pngdll.lib #PNGLIB = $(PNGPATH)/pngdll.lib
PNGLIB = $(PNGPATH)/libpng.lib PNGLIB = $(PNGPATH)/libpng.lib
ZPATH = ../../../zlib ZPATH = ../zlib
ZINC = -I$(ZPATH) ZINC = -I$(ZPATH)
#ZLIB = $(ZPATH)/zlibdll.lib #ZLIB = $(ZPATH)/zlibdll.lib
ZLIB = $(ZPATH)/zlibstat.lib ZLIB = $(ZPATH)/zlibstat.lib

View File

@@ -16,13 +16,12 @@ of PBMPLUS/NetPBM) and converts them to PNG.
The source code for all three demo programs currently compiles under The source code for all three demo programs currently compiles under
Unix, OpenVMS, and 32-bit Windows. (Special thanks to Martin Zinser, Unix, OpenVMS, and 32-bit Windows. (Special thanks to Martin Zinser,
zinser@decus.de, for making the necessary changes for OpenVMS and for zinser@decus.de, for making the necessary changes for OpenVMS and for
providing an appropriate build script.) Build instructions can be providing an appropriate build script.) Build instructions can be found
found below. below.
Files: Files:
README this file README this file
README.w32 additional Windows-specific information
LICENSE terms of distribution and reuse (BSD-like) LICENSE terms of distribution and reuse (BSD-like)
Makefile.unx Unix makefile Makefile.unx Unix makefile
@@ -45,26 +44,27 @@ Files:
toucan.png transparent PNG for testing (by Stefan Schneider) toucan.png transparent PNG for testing (by Stefan Schneider)
Note that the programs are designed to be functional, but their primary Note that, although the programs are designed to be functional, their
purpose is to demonstrate how to use libpng to add PNG support to other primary purpose is to illustrate how to use libpng to add PNG support to
programs. As such, their user interfaces are crude and definitely not other programs. As such, their user interfaces are crude and definitely
intended for everyday use. are not intended for everyday use.
Please see http://www.cdrom.com/pub/png/pngbook.html for further infor- Please see http://www.libpng.org/pub/png/pngbook.html for further infor-
mation and links to the latest version of the source code, and Chapters mation and links to the latest version of the source code, and Chapters
13-15 of the book for detailed discussion of the three programs. 13-15 of the book for detailed discussion of the three programs.
Greg Roelofs Greg Roelofs
19 March 2000 newt@pobox.com
30 June 2001
BUILD INSTRUCTIONS BUILD INSTRUCTIONS
- Prerequisites: - Prerequisites (in order of compilation):
- zlib ftp://ftp.cdrom.com/pub/infozip/zlib/zlib.html - zlib http://www.gzip.org/zlib/
- libpng http://www.cdrom.com/pub/png/pngcode.html - libpng http://www.libpng.org/pub/png/libpng.html
- pngbook http://www.cdrom.com/pub/png/book/sources.html - pngbook http://www.libpng.org/pub/png/book/sources.html
The pngbook demo programs are explicitly designed to demonstrate proper The pngbook demo programs are explicitly designed to demonstrate proper
coding techniques for using the libpng reference library. As a result, coding techniques for using the libpng reference library. As a result,
@@ -128,11 +128,13 @@ BUILD INSTRUCTIONS
The result should be three executables: rpng-win.exe, rpng2-win.exe, The result should be three executables: rpng-win.exe, rpng2-win.exe,
and wpng.exe. Copy them somewhere in your PATH or run them from the and wpng.exe. Copy them somewhere in your PATH or run them from the
current folder. Unlike the Unix versions, the two windowed programs current folder. Like the Unix versions, the two windowed programs
(rpng and rpng2) do not display a usage screen when invoked without (rpng and rpng2) now display a usage screen in a console window when
command-line arguments; see README.w32 for brief help or the book for invoked without command-line arguments; this is new behavior as of
details. Note that the programs use the Unix-style "-" character to the June 2001 release. Note that the programs use the Unix-style "-"
specify options, instead of the more common DOS/Windows "/" character. character to specify options, instead of the more common DOS/Windows
"/" character. (For example: "rpng2-win -bgpat 4 foo.png", not
"rpng2-win /bgpat 4 foo.png")
- OpenVMS: - OpenVMS:

View File

@@ -1,53 +0,0 @@
See the main README file for basic instructions on compiling and running
the programs. See http://www.cdrom.com/pub/png/pngbook.html for further
information and links to the source code, and Chapters 13-15 of the book
for detailed discussion of the three programs.
Since the two viewers, rpng and rpng2, are both designed to write infor-
mation to the console (i.e., a DOS-window command line) while displaying
the image in a graphical window--and since I haven't yet figured out how
to do that under Windows--here are the usage screens for the two programs:
rpng-win 1.02 of 19 March 2000: Simple PNG Viewer for Windows
Compiled with libpng 1.0.5; using libpng 1.0.5.
Compiled with zlib 1.1.3; using zlib 1.1.3.
Usage: rpng-win [-gamma exp] [-bgcolor bg] file.png
exp transfer-function exponent (``gamma'') of the display
system in floating-point format (e.g., ``2.2''); equal
to the product of the lookup-table exponent (varies)
and the CRT exponent (usually 2.2); must be positive
bg desired background color in 7-character hex RGB format
(e.g., ``#ff7f00'' for orange: same as HTML colors);
used with transparent images
Press Q, Esc or mouse button 1 after image is displayed to quit.
rpng2-win 1.04 of 19 March 2000: Progressive PNG Viewer for Windows
Compiled with libpng 1.0.5; using libpng 1.0.5.
Compiled with zlib 1.1.3; using zlib 1.1.3.
Usage: rpng2-win [-gamma exp] [-bgcolor bg | -bgpat pat] [-timing] file.png
exp transfer-function exponent (``gamma'') of the display
system in floating-point format (e.g., ``2.2''); equal
to the product of the lookup-table exponent (varies)
and the CRT exponent (usually 2.2); must be positive
bg desired background color in 7-character hex RGB format
(e.g., ``#ff7f00'' for orange: same as HTML colors);
used with transparent images; overrides -bgpat
pat desired background pattern number (1-16); used with
transparent images; overrides -bgcolor
-timing enables delay for every block read, to simulate modem
download of image (~36 Kbps)
Press Q, Esc or mouse button 1 after image is displayed to quit.
The usage screen for the third (non-windowed) program, wpng, can be seen
simply by invoking it without any parameters (``wpng'').
Greg Roelofs
19 March 2000

View File

@@ -9,21 +9,22 @@ $! Set locations where zlib and libpng sources live.
$! $!
$ zpath = "" $ zpath = ""
$ pngpath = "" $ pngpath = ""
$ if f$search("[-.zlib]zlib.h").nes."" then zpath = "[-.zlib]"
$ if f$search("[-.libpng]png.h").nes."" then pngpath = "[-.libpng]"
$! $!
$ if f$search("[---.zlib]zlib.h").nes."" then zpath = "[---.zlib]" $ if f$search("[---.zlib]zlib.h").nes."" then zpath = "[---.zlib]"
$ if f$search("[--]png.h").nes."" then pngpath = "[--]" $ if f$search("[--]png.h").nes."" then pngpath = "[--]"
$! $!
$ if f$search("[-.zlib]zlib.h").nes."" then zpath = "[-.zlib]"
$ if f$search("[-.libpng]png.h").nes."" then pngpath = "[-.libpng]"
$!
$ if zpath .eqs. "" $ if zpath .eqs. ""
$ then $ then
$ write sys$output "Zlib include not found. Exiting..." $ write sys$output "zlib include not found. Exiting..."
$ exit 2 $ exit 2
$ endif $ endif
$! $!
$ if pngpath .eqs. "" $ if pngpath .eqs. ""
$ then $ then
$ write sys$output "Libpng include not found. Exiting..." $ write sys$output "libpng include not found. Exiting..."
$ exit 2 $ exit 2
$ endif $ endif
$! $!

View File

@@ -239,7 +239,7 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
return NULL; return NULL;
} }
Trace((stderr, "readpng_get_image: rowbytes = %ld, height = %ld\n", rowbytes, height)); Trace((stderr, "readpng_get_image: channels = %d, rowbytes = %ld, height = %ld\n", *pChannels, rowbytes, height));
/* set the individual row_pointers to point at the correct offsets */ /* set the individual row_pointers to point at the correct offsets */

View File

@@ -49,8 +49,77 @@ static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg);
void readpng2_version_info(void) void readpng2_version_info(void)
{ {
fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n", #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && \
PNG_LIBPNG_VER_STRING, png_libpng_ver); (defined(__i386__) || defined(_M_IX86)) && \
defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
/*
* WARNING: This preprocessor approach means that the following code
* cannot be used with a libpng DLL older than 1.2.0--the
* compiled-in symbols for the new functions will not exist.
* (Could use dlopen() and dlsym() on Unix and corresponding
* calls for Windows, but not portable...)
*/
{
int mmxsupport = png_mmx_support();
if (mmxsupport < 0)
fprintf(stderr, " Compiled with libpng %s; using libpng %s "
"without MMX support.\n", PNG_LIBPNG_VER_STRING, png_libpng_ver);
else {
int compilerID;
png_uint_32 mmx_mask = png_get_mmx_flagmask(
PNG_SELECT_READ | PNG_SELECT_WRITE, &compilerID);
fprintf(stderr, " Compiled with libpng %s; using libpng %s "
"with MMX support\n (%s version).", PNG_LIBPNG_VER_STRING,
png_libpng_ver, compilerID == 1? "MSVC++" :
(compilerID == 2? "GNU C" : "unknown"));
fprintf(stderr, " Processor %s MMX instructions.\n",
mmxsupport? "supports" : "does not support");
if (mmxsupport > 0) {
int num_optims = 0;
fprintf(stderr,
" Potential MMX optimizations supported by libpng:\n");
if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)
++num_optims;
if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_UP)
++num_optims;
if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)
++num_optims;
if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)
++num_optims;
if (num_optims)
fprintf(stderr,
" decoding %s row filters (reading)\n",
(num_optims == 4)? "all non-trivial" : "some");
if (mmx_mask & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) {
fprintf(stderr, " combining rows (reading)\n");
++num_optims;
}
if (mmx_mask & PNG_ASM_FLAG_MMX_READ_INTERLACE) {
fprintf(stderr,
" expanding interlacing (reading)\n");
++num_optims;
}
mmx_mask &= ~( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \
| PNG_ASM_FLAG_MMX_READ_INTERLACE \
| PNG_ASM_FLAG_MMX_READ_FILTER_SUB \
| PNG_ASM_FLAG_MMX_READ_FILTER_UP \
| PNG_ASM_FLAG_MMX_READ_FILTER_AVG \
| PNG_ASM_FLAG_MMX_READ_FILTER_PAETH );
if (mmx_mask) {
fprintf(stderr, " other (unknown)\n");
++num_optims;
}
if (num_optims == 0)
fprintf(stderr, " (none)\n");
}
}
}
#else
fprintf(stderr, " Compiled with libpng %s; using libpng %s "
"without MMX support.\n", PNG_LIBPNG_VER_STRING, png_libpng_ver);
#endif
fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n", fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n",
ZLIB_VERSION, zlib_version); ZLIB_VERSION, zlib_version);
@@ -111,6 +180,97 @@ int readpng2_init(mainprog_info *mainprog_ptr)
png_set_progressive_read_fn(png_ptr, mainprog_ptr, png_set_progressive_read_fn(png_ptr, mainprog_ptr,
readpng2_info_callback, readpng2_row_callback, readpng2_end_callback); readpng2_info_callback, readpng2_row_callback, readpng2_end_callback);
/*
* may as well enable or disable MMX routines here, if supported;
*
* to enable all: mask = png_get_mmx_flagmask (
* PNG_SELECT_READ | PNG_SELECT_WRITE, &compilerID);
* flags = png_get_asm_flags (png_ptr);
* flags |= mask;
* png_set_asm_flags (png_ptr, flags);
*
* to disable all: mask = png_get_mmx_flagmask (
* PNG_SELECT_READ | PNG_SELECT_WRITE, &compilerID);
* flags = png_get_asm_flags (png_ptr);
* flags &= ~mask;
* png_set_asm_flags (png_ptr, flags);
*/
#if (defined(__i386__) || defined(_M_IX86)) && \
defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
/*
* WARNING: This preprocessor approach means that the following code
* cannot be used with a libpng DLL older than 1.2.0--the
* compiled-in symbols for the new functions will not exist.
* (Could use dlopen() and dlsym() on Unix and corresponding
* calls for Windows, but not portable...)
*/
{
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
png_uint_32 mmx_disable_mask = 0;
png_uint_32 asm_flags, mmx_mask;
int compilerID;
if (mainprog_ptr->nommxfilters)
mmx_disable_mask |= ( PNG_ASM_FLAG_MMX_READ_FILTER_SUB \
| PNG_ASM_FLAG_MMX_READ_FILTER_UP \
| PNG_ASM_FLAG_MMX_READ_FILTER_AVG \
| PNG_ASM_FLAG_MMX_READ_FILTER_PAETH );
if (mainprog_ptr->nommxcombine)
mmx_disable_mask |= PNG_ASM_FLAG_MMX_READ_COMBINE_ROW;
if (mainprog_ptr->nommxinterlace)
mmx_disable_mask |= PNG_ASM_FLAG_MMX_READ_INTERLACE;
asm_flags = png_get_asm_flags(png_ptr);
png_set_asm_flags(png_ptr, asm_flags & ~mmx_disable_mask);
/* Now query libpng's asm settings, just for yuks. Note that this
* differs from the querying of its *potential* MMX capabilities
* in readpng2_version_info(); this is true runtime verification. */
asm_flags = png_get_asm_flags(png_ptr);
mmx_mask = png_get_mmx_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE,
&compilerID);
if (asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_COMPILED)
fprintf(stderr,
" MMX support (%s version) is compiled into libpng\n",
compilerID == 1? "MSVC++" :
(compilerID == 2? "GNU C" : "unknown"));
else
fprintf(stderr, " MMX support is not compiled into libpng\n");
fprintf(stderr, " MMX instructions are %ssupported by CPU\n",
(asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU)? "" : "not ");
fprintf(stderr, " MMX read support for combining rows is %sabled\n",
(asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)? "en" : "dis");
fprintf(stderr,
" MMX read support for expanding interlacing is %sabled\n",
(asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE)? "en" : "dis");
fprintf(stderr, " MMX read support for \"sub\" filter is %sabled\n",
(asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "en" : "dis");
fprintf(stderr, " MMX read support for \"up\" filter is %sabled\n",
(asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "en" : "dis");
fprintf(stderr, " MMX read support for \"avg\" filter is %sabled\n",
(asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "en" : "dis");
fprintf(stderr, " MMX read support for \"Paeth\" filter is %sabled\n",
(asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "en" : "dis");
asm_flags &= (mmx_mask & ~( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \
| PNG_ASM_FLAG_MMX_READ_INTERLACE \
| PNG_ASM_FLAG_MMX_READ_FILTER_SUB \
| PNG_ASM_FLAG_MMX_READ_FILTER_UP \
| PNG_ASM_FLAG_MMX_READ_FILTER_AVG \
| PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ));
if (asm_flags)
fprintf(stderr,
" additional MMX support is also enabled (0x%02lx)\n",
asm_flags);
#else /* !PNG_ASSEMBLER_CODE_SUPPORTED */
fprintf(stderr, " MMX querying is disabled in libpng.\n");
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
}
#endif
/* make sure we save our pointers for use in readpng2_decode_data() */ /* make sure we save our pointers for use in readpng2_decode_data() */
mainprog_ptr->png_ptr = png_ptr; mainprog_ptr->png_ptr = png_ptr;

View File

@@ -9,7 +9,6 @@
with a little tweaking (or maybe not). with a little tweaking (or maybe not).
to do: to do:
- stdout/stderr don't work! need message window (maybe scrollable?)
- handle quoted command-line args (especially filenames with spaces) - handle quoted command-line args (especially filenames with spaces)
- have minimum window width: oh well - have minimum window width: oh well
- use %.1023s to simplify truncation of title-bar string? - use %.1023s to simplify truncation of title-bar string?
@@ -22,10 +21,11 @@
match; switched to png_jmpbuf() macro match; switched to png_jmpbuf() macro
- 1.02: added extra set of parentheses to png_jmpbuf() macro; fixed - 1.02: added extra set of parentheses to png_jmpbuf() macro; fixed
command-line parsing bug command-line parsing bug
- 1.10: enabled "message window"/console (thanks to David Geldreich)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. Copyright (c) 1998-2001 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors
@@ -52,13 +52,14 @@
#define PROGNAME "rpng-win" #define PROGNAME "rpng-win"
#define LONGNAME "Simple PNG Viewer for Windows" #define LONGNAME "Simple PNG Viewer for Windows"
#define VERSION "1.02 of 19 March 2000" #define VERSION "1.20 of 28 May 2001"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <windows.h> #include <windows.h>
#include <conio.h> /* only for _getch() */
/* #define DEBUG : this enables the Trace() macros */ /* #define DEBUG : this enables the Trace() macros */
@@ -128,7 +129,17 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
filename = (char *)NULL; filename = (char *)NULL;
/* First set the default value for our display-system exponent, i.e., /* First reenable console output, which normally goes to the bit bucket
* for windowed apps. Closing the console window will terminate the
* app. Thanks to David.Geldreich@realviz.com for supplying the magical
* incantation. */
AllocConsole();
freopen("CONOUT$", "a", stderr);
freopen("CONOUT$", "a", stdout);
/* Next set the default value for our display-system exponent, i.e.,
* the product of the CRT exponent and the exponent corresponding to * the product of the CRT exponent and the exponent corresponding to
* the frame-buffer's lookup table (LUT), if any. This is not an * the frame-buffer's lookup table (LUT), if any. This is not an
* exhaustive list of LUT values (e.g., OpenStep has a lot of weird * exhaustive list of LUT values (e.g., OpenStep has a lot of weird
@@ -272,20 +283,31 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
/* usage screen */ /* usage screen */
if (error) { if (error) {
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname); int ch;
fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname);
readpng_version_info(); readpng_version_info();
fprintf(stderr, "\n" fprintf(stderr, "\n"
"Usage: %s [-gamma exp] [-bgcolor bg] file.png\n" "Usage: %s [-gamma exp] [-bgcolor bg] file.png\n"
" exp \ttransfer-function exponent (``gamma'') of the display\n" " exp \ttransfer-function exponent (``gamma'') of the display\n"
"\t\t system in floating-point format (e.g., ``%.1f''); equal\n" "\t\t system in floating-point format (e.g., ``%.1f''); equal\n"
"\t\t to the product of the lookup-table exponent (varies)\n" "\t\t to the product of the lookup-table exponent (varies)\n"
"\t\t and the CRT exponent (usually 2.2); must be positive\n" "\t\t and the CRT exponent (usually 2.2); must be positive\n"
" bg \tdesired background color in 7-character hex RGB format\n" " bg \tdesired background color in 7-character hex RGB format\n"
"\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
"\t\t used with transparent images\n" "\t\t used with transparent images\n"
"\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n" "\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n"
"\n", PROGNAME, default_display_exponent); "Press Q or Esc to quit this usage screen.\n"
"\n", PROGNAME, default_display_exponent);
do
ch = _getch();
while (ch != 'q' && ch != 'Q' && ch != 0x1B);
exit(1); exit(1);
} else {
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
fprintf(stderr,
"\n [console window: closing this window will terminate %s]\n\n",
PROGNAME);
} }

View File

@@ -21,10 +21,12 @@
- 1.10: added support for non-default visuals; fixed X pixel-conversion - 1.10: added support for non-default visuals; fixed X pixel-conversion
- 1.11: added extra set of parentheses to png_jmpbuf() macro; fixed - 1.11: added extra set of parentheses to png_jmpbuf() macro; fixed
command-line parsing bug command-line parsing bug
- 1.12: fixed small X memory leak (thanks to Francois Petitjean)
- 1.13: fixed XFreeGC() crash bug
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. Copyright (c) 1998-2001 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind, This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors express or implied. In no event shall the author or contributors
@@ -51,7 +53,7 @@
#define PROGNAME "rpng-x" #define PROGNAME "rpng-x"
#define LONGNAME "Simple PNG Viewer for X" #define LONGNAME "Simple PNG Viewer for X"
#define VERSION "1.11 of 19 March 2000" #define VERSION "1.13 of 16 August 2001"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -117,6 +119,7 @@ static Colormap colormap;
static int have_nondefault_visual = FALSE; static int have_nondefault_visual = FALSE;
static int have_colormap = FALSE; static int have_colormap = FALSE;
static int have_window = FALSE; static int have_window = FALSE;
static int have_gc = FALSE;
/* /*
ulg numcolors=0, pixels[256]; ulg numcolors=0, pixels[256];
ush reds[256], greens[256], blues[256]; ush reds[256], greens[256], blues[256];
@@ -542,9 +545,20 @@ static int rpng_x_create_window(void)
XSetWMProperties(display, window, pWindowName, pIconName, NULL, 0, XSetWMProperties(display, window, pWindowName, pIconName, NULL, 0,
size_hints, wm_hints, NULL); size_hints, wm_hints, NULL);
/* various properties and hints no longer needed; free memory */
if (pWindowName)
XFree(pWindowName->value);
if (pIconName)
XFree(pIconName->value);
if (size_hints)
XFree(size_hints);
if (wm_hints)
XFree(wm_hints);
XMapWindow(display, window); XMapWindow(display, window);
gc = XCreateGC(display, window, 0, &gcvalues); gc = XCreateGC(display, window, 0, &gcvalues);
have_gc = TRUE;
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
Fill window with the specified background color. Fill window with the specified background color.
@@ -814,7 +828,8 @@ static void rpng_x_cleanup(void)
ximage = NULL; ximage = NULL;
} }
XFreeGC(display, gc); if (have_gc)
XFreeGC(display, gc);
if (have_window) if (have_window)
XDestroyWindow(display, window); XDestroyWindow(display, window);

View File

@@ -24,8 +24,9 @@
- 1.03: modified to allow abbreviated options - 1.03: modified to allow abbreviated options
- 1.04: removed bogus extra argument from usage fprintf() [Glenn R-P?]; - 1.04: removed bogus extra argument from usage fprintf() [Glenn R-P?];
fixed command-line parsing bug fixed command-line parsing bug
- 1.10: enabled "message window" (console), thanks to David Geldreich - 1.10: enabled "message window"/console (thanks to David Geldreich)
- 1.20: added runtime MMX-enabling/disabling and new -mmx* options - 1.20: added runtime MMX-enabling/disabling and new -mmx* options
- 1.21: made minor tweak to usage screen to fit within 25-line console
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
@@ -56,7 +57,7 @@
#define PROGNAME "rpng2-win" #define PROGNAME "rpng2-win"
#define LONGNAME "Progressive PNG Viewer for Windows" #define LONGNAME "Progressive PNG Viewer for Windows"
#define VERSION "1.20 of 29 January 2001" #define VERSION "1.21 of 29 June 2001"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -451,12 +452,13 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
"\t\t combining rows, and expanding interlacing, respectively\n" "\t\t combining rows, and expanding interlacing, respectively\n"
#endif #endif
"\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n" "\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n"
"Press Q or Esc to quit this usage screen.\n" "Press Q or Esc to quit this usage screen. ",
"\n", PROGNAME, PROGNAME,
#if (defined(__i386__) || defined(_M_IX86)) #if (defined(__i386__) || defined(_M_IX86))
strlen(PROGNAME), " ", strlen(PROGNAME), " ",
#endif #endif
strlen(PROGNAME), " ", default_display_exponent, num_bgpat); strlen(PROGNAME), " ", default_display_exponent, num_bgpat);
fflush(stderr);
do do
ch = _getch(); ch = _getch();
while (ch != 'q' && ch != 'Q' && ch != 0x1B); while (ch != 'q' && ch != 'Q' && ch != 0x1B);
@@ -466,6 +468,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
fprintf(stderr, fprintf(stderr,
"\n [console window: closing this window will terminate %s]\n\n", "\n [console window: closing this window will terminate %s]\n\n",
PROGNAME); PROGNAME);
fflush(stderr);
} }

View File

@@ -26,6 +26,8 @@
- 1.11: added -usleep option for demos; fixed command-line parsing bug - 1.11: added -usleep option for demos; fixed command-line parsing bug
- 1.12: added -pause option for demos and testing - 1.12: added -pause option for demos and testing
- 1.20: added runtime MMX-enabling/disabling and new -mmx* options - 1.20: added runtime MMX-enabling/disabling and new -mmx* options
- 1.21: fixed small X memory leak (thanks to Francois Petitjean)
- 1.22: fixed XFreeGC() crash bug
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
@@ -56,7 +58,7 @@
#define PROGNAME "rpng2-x" #define PROGNAME "rpng2-x"
#define LONGNAME "Progressive PNG Viewer for X" #define LONGNAME "Progressive PNG Viewer for X"
#define VERSION "1.20 of 29 January 2001" #define VERSION "1.22 of 16 August 2001"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -227,6 +229,7 @@ static Colormap colormap;
static int have_nondefault_visual = FALSE; static int have_nondefault_visual = FALSE;
static int have_colormap = FALSE; static int have_colormap = FALSE;
static int have_window = FALSE; static int have_window = FALSE;
static int have_gc = FALSE;
@@ -585,8 +588,15 @@ static void rpng2_x_init(void)
* pattern */ * pattern */
if (rpng2_x_create_window()) { if (rpng2_x_create_window()) {
/* GRR TEMPORARY HACK: this is fundamentally no different from cases
* above; libpng should longjmp() back to us when png_ptr goes away.
* If we/it segfault instead, seems like a libpng bug... */
/* we're here via libpng callback, so if window fails, clean and bail */
readpng2_cleanup(&rpng2_info); readpng2_cleanup(&rpng2_info);
return; rpng2_x_cleanup();
exit(2);
} }
} }
@@ -738,9 +748,20 @@ static int rpng2_x_create_window(void)
XSetWMProperties(display, window, pWindowName, pIconName, NULL, 0, XSetWMProperties(display, window, pWindowName, pIconName, NULL, 0,
size_hints, wm_hints, NULL); size_hints, wm_hints, NULL);
/* various properties and hints no longer needed; free memory */
if (pWindowName)
XFree(pWindowName->value);
if (pIconName)
XFree(pIconName->value);
if (size_hints)
XFree(size_hints);
if (wm_hints)
XFree(wm_hints);
XMapWindow(display, window); XMapWindow(display, window);
gc = XCreateGC(display, window, 0, &gcvalues); gc = XCreateGC(display, window, 0, &gcvalues);
have_gc = TRUE;
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
Allocate memory for the X- and display-specific version of the image. Allocate memory for the X- and display-specific version of the image.
@@ -1356,7 +1377,8 @@ static void rpng2_x_cleanup(void)
ximage = NULL; ximage = NULL;
} }
XFreeGC(display, gc); if (have_gc)
XFreeGC(display, gc);
if (have_window) if (have_window)
XDestroyWindow(display, window); XDestroyWindow(display, window);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -54,7 +54,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:console /machine:I386 # ADD BASE LINK32 /nologo /subsystem:console /machine:I386
# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll\libpng1.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 ..\..\projects\msvc\win32\libpng\dll\libpng10.lib /nologo /subsystem:console /machine:I386
# Begin Special Build Tool # Begin Special Build Tool
OutDir=.\dll OutDir=.\dll
SOURCE="$(InputPath)" SOURCE="$(InputPath)"
@@ -84,7 +84,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # 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 # ADD LINK32 ..\..\projects\msvc\win32\libpng\dll_dbg\libpng10d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# Begin Special Build Tool # Begin Special Build Tool
OutDir=.\dll_dbg OutDir=.\dll_dbg
SOURCE="$(InputPath)" SOURCE="$(InputPath)"
@@ -114,7 +114,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:console /machine:I386 # ADD BASE LINK32 /nologo /subsystem:console /machine:I386
# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll_asm\libpng1a.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 ..\..\projects\msvc\win32\libpng\dll_asm\libpng10a.lib /nologo /subsystem:console /machine:I386
# Begin Special Build Tool # Begin Special Build Tool
OutDir=.\dll_asm OutDir=.\dll_asm
SOURCE="$(InputPath)" SOURCE="$(InputPath)"
@@ -144,7 +144,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # 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 # ADD LINK32 ..\..\projects\msvc\win32\libpng\dll_dbga\libpng10b.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# Begin Special Build Tool # Begin Special Build Tool
OutDir=.\dll_dbga OutDir=.\dll_dbga
SOURCE="$(InputPath)" SOURCE="$(InputPath)"

View File

@@ -1,26 +1,31 @@
# Makefile for PngMinus (png2pnm and pnm2png) # Makefile for PngMinus (png2pnm and pnm2png)
# Linux / Unix # Linux / Unix
CC=cc -O #CC=cc
LD=cc -O CC=gcc
#CC=gcc -O LD=$(CC)
#LD=gcc -O
LB=ar
RM=rm
CP=cp
PNGPATH = /usr/local RM=rm -f
PNGINC = $(PNGPATH)/include
#PNGLIB = $(PNGPATH)/lib -lpng
PNGLIB = $(PNGPATH)/lib/libpng.a
ZPATH = /usr/local #PNGPATH = /usr/local
ZINC = $(ZPATH)/include #PNGINC = -I$(PNGPATH)/include/libpng10
#ZLIB = $(ZPATH)/lib -lz #PNGLIB = -L$(PNGPATH)/lib -lpng10
ZLIB = $(ZPATH)/lib/libz.a #PNGLIBS = $(PNGPATH)/lib/libpng10.a
PNGINC = -I../..
PNGLIB = -L../.. -lpng
PNGLIBS = ../../libpng.a
CCFLAGS=-I$(PNGINC) -I$(ZINC) #ZPATH = /usr/local
LDFLAGS=-L$(PNGLIB) -L$(ZLIB) #ZINC = -I$(ZPATH)/include
#ZLIB = -L$(ZPATH)/lib -lz
#ZLIBS = $(ZPATH)/lib/libz.a
ZINC = -I../../../zlib
ZLIB = -L../../../zlib -lz
ZLIBS = ../../../zlib/libz.a
CFLAGS=-O3 $(PNGINC) $(ZINC)
LDFLAGS=$(PNGLIB) $(ZLIB)
LDFLAGSS=$(PNGLIBS) $(ZLIBS)
C=.c C=.c
O=.o O=.o
L=.a L=.a
@@ -28,25 +33,33 @@ E=
# dependencies # dependencies
all: png2pnm$(E) pnm2png$(E) #all: png2pnm$(E) pnm2png$(E)
all: png2pnm$(E) pnm2png$(E) png2pnm-static$(E) pnm2png-static$(E)
png2pnm$(O): png2pnm$(C) png2pnm$(O): png2pnm$(C)
$(CC) -c $(CCFLAGS) png2pnm$(C) $(CC) -c $(CFLAGS) png2pnm$(C)
png2pnm$(E): png2pnm$(O) png2pnm$(E): png2pnm$(O)
$(LD) -o png2pnm$(E) png2pnm$(O) $(LDFLAGS) -lpng -lz -lm $(LD) -o png2pnm$(E) png2pnm$(O) $(LDFLAGS) -lm
png2pnm-static$(E): png2pnm$(O)
$(LD) -o png2pnm-static$(E) png2pnm$(O) $(LDFLAGSS) -lm
pnm2png$(O): pnm2png$(C) pnm2png$(O): pnm2png$(C)
$(CC) -c $(CCFLAGS) pnm2png$(C) $(CC) -c $(CFLAGS) pnm2png$(C)
pnm2png$(E): pnm2png$(O) pnm2png$(E): pnm2png$(O)
$(LD) -o pnm2png$(E) pnm2png$(O) $(LDFLAGS) -lpng -lz -lm $(LD) -o pnm2png$(E) pnm2png$(O) $(LDFLAGS) -lm
pnm2png-static$(E): pnm2png$(O)
$(LD) -o pnm2png-static$(E) pnm2png$(O) $(LDFLAGSS) -lm
clean: clean:
$(RM) png2pnm$(O) $(RM) png2pnm$(O)
$(RM) pnm2png$(O) $(RM) pnm2png$(O)
$(RM) png2pnm$(E) $(RM) png2pnm$(E)
$(RM) pnm2png$(E) $(RM) pnm2png$(E)
$(RM) png2pnm-static$(E)
$(RM) pnm2png-static$(E)
# End of makefile for png2pnm / pnm2png # End of makefile for png2pnm / pnm2png

0
contrib/pngminus/png2pnm.sh Executable file → Normal file
View File

0
contrib/pngminus/pngminus.sh Executable file → Normal file
View File

0
contrib/pngminus/pnm2png.sh Executable file → Normal file
View File

View File

@@ -59,8 +59,8 @@ BSC32=bscmake.exe
# ADD BASE BSC32 /nologo # ADD BASE BSC32 /nologo
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe 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 BASE LINK32 libpng10.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" # ADD LINK32 libpng10.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 # Begin Special Build Tool
OutDir=.\dll OutDir=.\dll
SOURCE="$(InputPath)" SOURCE="$(InputPath)"
@@ -92,9 +92,9 @@ BSC32=bscmake.exe
# ADD BASE BSC32 /nologo # ADD BASE BSC32 /nologo
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe 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" # ADD BASE LINK32 libpng10.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 # 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" # ADD LINK32 libpng10d.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 # SUBTRACT LINK32 /nodefaultlib
# Begin Special Build Tool # Begin Special Build Tool
OutDir=.\dll_dbg OutDir=.\dll_dbg
@@ -128,7 +128,7 @@ BSC32=bscmake.exe
# ADD BASE BSC32 /nologo # ADD BASE BSC32 /nologo
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe 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 BASE LINK32 libpng10.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" # 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 # Begin Special Build Tool
OutDir=.\lib OutDir=.\lib
@@ -161,7 +161,7 @@ BSC32=bscmake.exe
# ADD BASE BSC32 /nologo # ADD BASE BSC32 /nologo
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe 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" # ADD BASE LINK32 libpng10d.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 # 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" # 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 # SUBTRACT LINK32 /nodefaultlib

102
example.c
View File

@@ -114,7 +114,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
if (info_ptr == NULL) if (info_ptr == NULL)
{ {
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 (ERROR); return (ERROR);
} }
@@ -126,7 +126,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
if (setjmp(png_jmpbuf(png_ptr))) if (setjmp(png_jmpbuf(png_ptr)))
{ {
/* Free all of the memory associated with the png_ptr and info_ptr */ /* Free all of the memory associated with the png_ptr and info_ptr */
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 (ERROR); return (ERROR);
@@ -157,7 +157,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
* adjustment), then you can read the entire image (including * adjustment), then you can read the entire image (including
* pixels) into the info structure with this call: * pixels) into the info structure with this call:
*/ */
png_read_png(png_ptr, info_ptr, png_transforms, NULL); png_read_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL);
#else #else
/* OK, you're doing it the hard way, with the lower-level functions */ /* OK, you're doing it the hard way, with the lower-level functions */
@@ -167,13 +167,13 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
png_read_info(png_ptr, info_ptr); png_read_info(png_ptr, info_ptr);
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
&interlace_type, NULL, NULL); &interlace_type, int_p_NULL, int_p_NULL);
/**** Set up the data transformations you want. Note that these are all /* Set up the data transformations you want. Note that these are all
**** optional. Only call them if you want/need them. Many of the * optional. Only call them if you want/need them. Many of the
**** transformations only work on specific types of images, and many * transformations only work on specific types of images, and many
**** are mutually exclusive. * are mutually exclusive.
****/ */
/* tell libpng to strip 16 bit/color files down to 8 bits/color */ /* tell libpng to strip 16 bit/color files down to 8 bits/color */
png_set_strip_16(png_ptr); png_set_strip_16(png_ptr);
@@ -194,17 +194,17 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
/* Expand paletted colors into true RGB triplets */ /* Expand paletted colors into true RGB triplets */
if (color_type == PNG_COLOR_TYPE_PALETTE) if (color_type == PNG_COLOR_TYPE_PALETTE)
png_set_expand(png_ptr); png_set_palette_rgb(png_ptr);
/* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */ /* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
png_set_expand(png_ptr); png_set_gray_1_2_4_to_8(png_ptr);
/* Expand paletted or RGB images with transparency to full alpha channels /* Expand paletted or RGB images with transparency to full alpha channels
* so the data will be available as RGBA quartets. * so the data will be available as RGBA quartets.
*/ */
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
png_set_expand(png_ptr); png_set_tRNS_to_alpha(png_ptr);
/* Set the background color to draw transparent and alpha images over. /* Set the background color to draw transparent and alpha images over.
* It is possible to set the red, green, and blue components directly * It is possible to set the red, green, and blue components directly
@@ -277,7 +277,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
png_color std_color_cube[MAX_SCREEN_COLORS]; png_color std_color_cube[MAX_SCREEN_COLORS];
png_set_dither(png_ptr, std_color_cube, MAX_SCREEN_COLORS, png_set_dither(png_ptr, std_color_cube, MAX_SCREEN_COLORS,
MAX_SCREEN_COLORS, NULL, 0); MAX_SCREEN_COLORS, png_uint_16p_NULL, 0);
} }
/* 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))
@@ -338,7 +338,8 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
for (row = 0; row < height; row++) for (row = 0; row < height; row++)
{ {
row_pointers[row] = malloc(png_get_rowbytes(png_ptr, info_ptr)); row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr,
info_ptr));
} }
/* Now it's time to read the image. One of these methods is REQUIRED */ /* Now it's time to read the image. One of these methods is REQUIRED */
@@ -353,18 +354,18 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
#ifdef single /* Read the image a single row at a time */ #ifdef single /* Read the image a single row at a time */
for (y = 0; y < height; y++) for (y = 0; y < height; y++)
{ {
png_read_rows(png_ptr, &row_pointers[y], NULL, 1); png_read_rows(png_ptr, &row_pointers[y], png_bytepp_NULL, 1);
} }
#else no_single /* Read the image several rows at a time */ #else no_single /* Read the image several rows at a time */
for (y = 0; y < height; y += number_of_rows) for (y = 0; y < height; y += number_of_rows)
{ {
#ifdef sparkle /* Read the image using the "sparkle" effect. */ #ifdef sparkle /* Read the image using the "sparkle" effect. */
png_read_rows(png_ptr, &row_pointers[y], NULL, number_of_rows); png_read_rows(png_ptr, &row_pointers[y], png_bytepp_NULL,
number_of_rows);
png_read_rows(png_ptr, NULL, row_pointers[y], number_of_rows);
#else no_sparkle /* Read the image using the "rectangle" effect */ #else no_sparkle /* Read the image using the "rectangle" effect */
png_read_rows(png_ptr, NULL, &row_pointers[y], number_of_rows); png_read_rows(png_ptr, png_bytepp_NULL, &row_pointers[y],
number_of_rows);
#endif no_sparkle /* use only one of these two methods */ #endif no_sparkle /* use only one of these two methods */
} }
@@ -381,7 +382,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */
/* At this point you have read the entire image */ /* At this point you have read the entire image */
/* clean up after the read, and free any memory allocated - REQUIRED */ /* clean up after the read, and free any memory allocated - REQUIRED */
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
/* close the file */ /* close the file */
fclose(fp); fclose(fp);
@@ -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);
} }
@@ -449,7 +450,7 @@ process_data(png_structp *png_ptr, png_infop *info_ptr,
if (setjmp(png_jmpbuf((*png_ptr)))) if (setjmp(png_jmpbuf((*png_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);
} }
@@ -481,21 +482,47 @@ info_callback(png_structp png_ptr, png_infop info)
row_callback(png_structp png_ptr, png_bytep new_row, row_callback(png_structp png_ptr, png_bytep new_row,
png_uint_32 row_num, int pass) png_uint_32 row_num, int pass)
{ {
/* this function is called for every row in the image. If the /*
* image is interlacing, and you turned on the interlace handler, * This function is called for every row in the image. If the
* image is interlaced, and you turned on the interlace handler,
* this function will be called for every row in every pass. * this function will be called for every row in every pass.
* Some of these rows will not be changed from the previous pass. *
* When the row is not changed, the new_row variable will be NULL. * In this function you will receive a pointer to new row data from
* libpng called new_row that is to replace a corresponding row (of
* the same data format) in a buffer allocated by your application.
*
* The new row data pointer new_row may be NULL, indicating there is
* no new data to be replaced (in cases of interlace loading).
*
* If new_row is not NULL then you need to call
* png_progressive_combine_row() to replace the corresponding row as
* shown below:
*/
/* Check if row_num is in bounds. */
if((row_num >= 0) && (row_num < height))
{
/* Get pointer to corresponding row in our
* PNG read buffer.
*/
png_bytep old_row = ((png_bytep *)our_data)[row_num];
/* If both rows are allocated then copy the new row
* data to the corresponding row data.
*/
if((old_row != NULL) && (new_row != NULL))
png_progressive_combine_row(png_ptr, old_row, new_row);
}
/*
* The rows and passes are called in order, so you don't really * The rows and passes are called in order, so you don't really
* need the row_num and pass, but I'm supplying them because it * need the row_num and pass, but I'm supplying them because it
* may make your life easier. * may make your life easier.
* *
* For the non-NULL rows of interlaced images, you must call * For the non-NULL rows of interlaced images, you must call
* png_progressive_combine_row() passing in the row and the * png_progressive_combine_row() passing in the new row and the
* old row. You can call this function for NULL rows (it will * old row, as demonstrated above. You can call this function for
* just return) and for non-interlaced images (it just does the * NULL rows (it will just return) and for non-interlaced images
* memcpy for you) if it will make the code easier. Thus, you * (it just does the png_memcpy for you) if it will make the code
* can just do this for all cases: * easier. Thus, you can just do this for all cases:
*/ */
png_progressive_combine_row(png_ptr, old_row, new_row); png_progressive_combine_row(png_ptr, old_row, new_row);
@@ -504,8 +531,8 @@ row_callback(png_structp png_ptr, png_bytep new_row,
* that the first pass (pass == 0 really) will completely cover * that the first pass (pass == 0 really) will completely cover
* the old row, so the rows do not have to be initialized. After * the old row, so the rows do not have to be initialized. After
* the first pass (and only for interlaced images), you will have * the first pass (and only for interlaced images), you will have
* to pass the current row, and the function will combine the * to pass the current row as new_row, and the function will combine
* old row and the new row. * the old row and the new row.
*/ */
} }
@@ -555,7 +582,7 @@ void write_png(char *file_name /* , ... other image information ... */)
if (info_ptr == NULL) if (info_ptr == NULL)
{ {
fclose(fp); fclose(fp);
png_destroy_write_struct(&png_ptr, (png_infopp)NULL); png_destroy_write_struct(&png_ptr, png_infopp_NULL);
return (ERROR); return (ERROR);
} }
@@ -587,7 +614,7 @@ void write_png(char *file_name /* , ... other image information ... */)
* image info living info in the structure. You could "|" many * image info living info in the structure. You could "|" many
* PNG_TRANSFORM flags into the png_transforms integer here. * PNG_TRANSFORM flags into the png_transforms integer here.
*/ */
png_write_png(png_ptr, info_ptr, png_transforms, NULL); png_write_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL);
#else #else
/* This is the hard way */ /* This is the hard way */
@@ -603,7 +630,8 @@ void write_png(char *file_name /* , ... other image information ... */)
PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
/* set the palette if there is one. REQUIRED for indexed-color images */ /* set the palette if there is one. REQUIRED for indexed-color images */
palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH * sizeof (png_color)); palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH
* sizeof (png_color));
/* ... set palette colors ... */ /* ... set palette colors ... */
png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH); png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);
/* You must not free palette here, because png_set_PLTE only makes a link to /* You must not free palette here, because png_set_PLTE only makes a link to

507
libpng.3
View File

@@ -1,6 +1,6 @@
.TH LIBPNG 3 "January 31, 2001" .TH LIBPNG 3 "July 8, 2002"
.SH NAME .SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.9 libpng \- Portable Network Graphics (PNG) Reference Library 1.0.14
.SH SYNOPSIS .SH SYNOPSIS
\fI\fB \fI\fB
@@ -302,7 +302,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.9
\fI\fB \fI\fB
\fBvoid png_info_init (png_infop \fIinfo_ptr\fP\fB);\fP \fBint png_handle_as_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP
\fI\fB \fI\fB
@@ -310,6 +310,14 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.9
\fI\fB \fI\fB
\fBDEPRECATED: void png_info_init (png_infop \fIinfo_ptr\fP\fB);\fP
\fI\fB
\fBDEPRECATED: void png_info_init_2 (png_infopp \fP\fIptr_ptr\fP\fB, png_size_t \fIpng_info_struct_size\fP\fB);\fP
\fI\fB
\fBpng_voidp png_malloc (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP \fBpng_voidp png_malloc (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP
\fI\fB \fI\fB
@@ -334,7 +342,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.9
\fI\fB \fI\fB
\fBvoid png_permit_empty_plte (png_structp \fP\fIpng_ptr\fP\fB, int \fIempty_plte_permitted\fP\fB);\fP \fBDEPRECATED: void png_permit_empty_plte (png_structp \fP\fIpng_ptr\fP\fB, int \fIempty_plte_permitted\fP\fB);\fP
\fI\fB \fI\fB
@@ -362,7 +370,9 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.9
\fI\fB \fI\fB
\fBDEPRECATED: void png_read_init_2 (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fP\fIuser_png_ver\fP\fB, png_size_t \fP\fIpng_struct_size\fP\fB, png_size_t \fIpng_info_size\fP\fB);\fP \fBDEPRECATED: void png_read_init_2 (png_structpp \fP\fIptr_ptr\fP\fB, png_const_charp \fP\fIuser_png_ver\fP\fB, png_size_t \fP\fIpng_struct_size\fP\fB, png_size_t \fIpng_info_size\fP\fB);\fP
\fI\fB
\fBvoid png_read_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP \fBvoid png_read_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
@@ -692,10 +702,6 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.9
\fI\fB \fI\fB
\fBvoid png_write_destroy_info (png_infop \fIinfo_ptr\fP\fB);\fP
\fI\fB
\fBvoid png_write_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP \fBvoid png_write_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP
\fI\fB \fI\fB
@@ -712,7 +718,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.9
\fI\fB \fI\fB
\fBDEPRECATED: void png_write_init_2 (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fP\fIuser_png_ver\fP\fB, png_size_t \fP\fIpng_struct_size\fP\fB, png_size_t \fIpng_info_size\fP\fB);\fP \fBDEPRECATED: void png_write_init_2 (png_structpp \fP\fIptr_ptr\fP\fB, png_const_charp \fP\fIuser_png_ver\fP\fB, png_size_t \fP\fIpng_struct_size\fP\fB, png_size_t \fIpng_info_size\fP\fB);\fP
\fI\fB \fI\fB
@@ -736,6 +742,14 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.9
\fI\fB \fI\fB
\fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP
\fI\fB
\fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP
\fI\fB
.SH DESCRIPTION .SH DESCRIPTION
The The
.I libpng .I libpng
@@ -747,10 +761,10 @@ Following is a copy of the libpng.txt file that accompanies libpng.
.SH LIBPNG.TXT .SH LIBPNG.TXT
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.9 - January 31, 2001 libpng version 1.0.14 - July 8, 2002
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-2002 Glenn Randers-Pehrson
For conditions of distribution and use, see copyright For conditions of distribution and use, see copyright
notice in png.h. notice in png.h.
@@ -825,7 +839,9 @@ Libpng is thread safe, provided the threads are using different
instances of the structures. Each thread should have its own instances of the structures. Each thread should have its own
png_struct and png_info instances, and thus its own image. png_struct and png_info instances, and thus its own image.
Libpng does not protect itself against two threads using the Libpng does not protect itself against two threads using the
same instance of a structure. same instance of a structure. Note: thread safety may be defeated
by use of some of the MMX assembler code in pnggccrd.c, which is only
compiled when the user defines PNG_THREAD_UNSAFE_OK.
.SH II. Structures .SH II. Structures
@@ -1004,10 +1020,11 @@ input stream. You must supply the function
png_byte name[5]; png_byte name[5];
png_byte *data; png_byte *data;
png_size_t size; png_size_t size;
/* Note that libpng has already taken care of the /* Note that libpng has already taken care of
CRC handling */ the CRC handling */
/* put your code here. Return one of the following: */ /* put your code here. Return one of the
following: */
return (-n); /* chunk had an error */ return (-n); /* chunk had an error */
return (0); /* did not recognize */ return (0); /* did not recognize */
@@ -1032,7 +1049,8 @@ called after each row has been read, which you can use to control
a progress meter or the like. It's demonstrated in pngtest.c. a progress meter or the like. It's demonstrated in pngtest.c.
You must supply a function You must supply a function
void read_row_callback(png_ptr ptr, png_uint_32 row, int pass); void read_row_callback(png_ptr ptr, png_uint_32 row,
int pass);
{ {
/* put your code here */ /* put your code here */
} }
@@ -1078,16 +1096,23 @@ the entire image into memory, and (b) the input transformations
you want to do are limited to the following set: you want to do are limited to the following set:
PNG_TRANSFORM_IDENTITY No transformation PNG_TRANSFORM_IDENTITY No transformation
PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to 8 bits PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to
8 bits
PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel
PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit samples to bytes PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit
PNG_TRANSFORM_PACKSWAP Change order of packed pixels to LSB first samples to bytes
PNG_TRANSFORM_PACKSWAP Change order of packed
pixels to LSB first
PNG_TRANSFORM_EXPAND Perform set_expand() PNG_TRANSFORM_EXPAND Perform set_expand()
PNG_TRANSFORM_INVERT_MONO Invert monochrome images PNG_TRANSFORM_INVERT_MONO Invert monochrome images
PNG_TRANSFORM_SHIFT Normalize pixels to the sBIT depth PNG_TRANSFORM_SHIFT Normalize pixels to the
PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA to BGRA sBIT depth
PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA to AG PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA
PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity to transparency to BGRA
PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA
to AG
PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity
to transparency
PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples
(This excludes setting a background color, doing gamma transformation, (This excludes setting a background color, doing gamma transformation,
@@ -1115,9 +1140,11 @@ where row_pointers is an array of pointers to the pixel data for each row:
If you know your image size and pixel size ahead of time, you can allocate 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 prior to calling png_read_png() with
row_pointers = png_malloc(png_ptr, height*sizeof(png_bytep)); row_pointers = png_malloc(png_ptr,
height*sizeof(png_bytep));
for (int i=0; i<height, i++) for (int i=0; i<height, i++)
row_pointers[i]=png_malloc(png_ptr, width*pixel_size); row_pointers[i]=png_malloc(png_ptr,
width*pixel_size);
png_set_rows(png_ptr, info_ptr, &row_pointers); png_set_rows(png_ptr, info_ptr, &row_pointers);
Alternatively you could allocate your image in one big block and define Alternatively you could allocate your image in one big block and define
@@ -1185,8 +1212,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_method can be NULL if you are filter_method can be NULL if you are
not interested in their values. not 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
@@ -1249,14 +1276,15 @@ into the info_ptr is returned for any complex types.
implies specific values of gAMA and implies specific values of gAMA and
cHRM. cHRM.
png_get_iCCP(png_ptr, info_ptr, &name, &compression_type, png_get_iCCP(png_ptr, info_ptr, &name,
&profile, &proflen); &compression_type, &profile, &proflen);
name - The profile name. name - The profile name.
compression - The compression type; always PNG_COMPRESSION_TYPE_BASE compression - The compression type; always
for PNG 1.0. You may give NULL to this argument PNG_COMPRESSION_TYPE_BASE for PNG 1.0.
to ignore it. You may give NULL to this argument to
profile - International Color Consortium color profile ignore it.
data. May contain NULs. profile - International Color Consortium color
profile data. May contain NULs.
proflen - length of profile data in bytes. proflen - length of profile data in bytes.
png_get_sBIT(png_ptr, info_ptr, &sig_bit); png_get_sBIT(png_ptr, info_ptr, &sig_bit);
@@ -1310,23 +1338,26 @@ into the info_ptr is returned for any complex types.
after decompression, 0 for tEXt/zTXt after decompression, 0 for tEXt/zTXt
text_ptr[i].lang - language of comment (empty text_ptr[i].lang - language of comment (empty
string for unknown). string for unknown).
text_ptr[i].translated_keyword - keyword in UTF-8 text_ptr[i].lang_key - keyword in UTF-8
(empty string for unknown). (empty string for unknown).
num_text - number of comments (same as num_comments; num_text - number of comments (same as
you can put NULL here to avoid the duplication) num_comments; you can put NULL here
Note while png_set_text() will accept text, language, and to avoid the duplication)
translated keywords that can be NULL pointers, the structure Note while png_set_text() will accept text, language,
returned by png_get_text will always contain regular and translated keywords that can be NULL pointers, the
zero-terminated C strings. They might be empty strings but structure returned by png_get_text will always contain
they will never be NULL pointers. regular zero-terminated C strings. They might be
empty strings but they will never be NULL pointers.
num_spalettes = png_get_sPLT(png_ptr, info_ptr, &palette_ptr); num_spalettes = png_get_sPLT(png_ptr, info_ptr,
&palette_ptr);
palette_ptr - array of palette structures holding palette_ptr - array of palette structures holding
contents of one or more sPLT chunks read. contents of one or more sPLT chunks
read.
num_spalettes - number of sPLT chunks read. num_spalettes - number of sPLT chunks read.
png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y,
&unit_type); &unit_type);
offset_x - positive offset from the left edge offset_x - positive offset from the left edge
of the screen of the screen
offset_y - positive offset from the top edge offset_y - positive offset from the top edge
@@ -1334,7 +1365,7 @@ into the info_ptr is returned for any complex types.
unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER
png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y,
&unit_type); &unit_type);
res_x - pixels/unit physical resolution in res_x - pixels/unit physical resolution in
x direction x direction
res_y - pixels/unit physical resolution in res_y - pixels/unit physical resolution in
@@ -1342,47 +1373,50 @@ into the info_ptr is returned for any complex types.
unit_type - PNG_RESOLUTION_UNKNOWN, unit_type - PNG_RESOLUTION_UNKNOWN,
PNG_RESOLUTION_METER PNG_RESOLUTION_METER
png_get_sCAL(png_ptr, info_ptr, &unit, &width, &height) png_get_sCAL(png_ptr, info_ptr, &unit, &width,
&height)
unit - physical scale units (an integer) unit - physical scale units (an integer)
width - width of a pixel in physical scale units width - width of a pixel in physical scale units
height - height of a pixel in physical scale units height - height of a pixel in physical scale units
(width and height are doubles) (width and height are doubles)
png_get_sCAL_s(png_ptr, info_ptr, &unit, &width, &height) png_get_sCAL_s(png_ptr, info_ptr, &unit, &width,
&height)
unit - physical scale units (an integer) unit - physical scale units (an integer)
width - width of a pixel in physical scale units width - width of a pixel in physical scale units
height - height of a pixel in physical scale units height - height of a pixel in physical scale units
(width and height are strings like "2.54") (width and height are strings like "2.54")
num_unknown_chunks = png_get_unknown_chunks(png_ptr, info_ptr, num_unknown_chunks = png_get_unknown_chunks(png_ptr,
&unknowns) info_ptr, &unknowns)
unknowns - array of png_unknown_chunk structures holding unknowns - array of png_unknown_chunk
unknown chunks structures holding unknown chunks
unknowns[i].name - name of unknown chunk unknowns[i].name - name of unknown chunk
unknowns[i].data - data of unknown chunk unknowns[i].data - data of unknown chunk
unknowns[i].size - size of unknown chunk's data unknowns[i].size - size of unknown chunk's data
unknowns[i].location - position of chunk in file unknowns[i].location - position of chunk in file
The value of "i" corresponds to the order in which the chunks were read The value of "i" corresponds to the order in which the
from the PNG file or inserted with the png_set_unknown_chunks() function. chunks were read from the PNG file or inserted with the
png_set_unknown_chunks() function.
The data from the pHYs chunk can be retrieved in several convenient The data from the pHYs chunk can be retrieved in several convenient
forms: forms:
res_x = png_get_x_pixels_per_meter(png_ptr, res_x = png_get_x_pixels_per_meter(png_ptr,
info_ptr) info_ptr)
res_y = png_get_y_pixels_per_meter(png_ptr, res_y = png_get_y_pixels_per_meter(png_ptr,
info_ptr) info_ptr)
res_x_and_y = png_get_pixels_per_meter(png_ptr, res_x_and_y = png_get_pixels_per_meter(png_ptr,
info_ptr) info_ptr)
res_x = png_get_x_pixels_per_inch(png_ptr, res_x = png_get_x_pixels_per_inch(png_ptr,
info_ptr) info_ptr)
res_y = png_get_y_pixels_per_inch(png_ptr, res_y = png_get_y_pixels_per_inch(png_ptr,
info_ptr) info_ptr)
res_x_and_y = png_get_pixels_per_inch(png_ptr, res_x_and_y = png_get_pixels_per_inch(png_ptr,
info_ptr) info_ptr)
aspect_ratio = png_get_pixel_aspect_ratio(png_ptr, aspect_ratio = png_get_pixel_aspect_ratio(png_ptr,
info_ptr) info_ptr)
(Each of these returns 0 [signifying "unknown"] if (Each of these returns 0 [signifying "unknown"] if
the data is not present or if res_x is 0; the data is not present or if res_x is 0;
@@ -1397,8 +1431,8 @@ forms:
y_offset = png_get_y_offset_inches(png_ptr, info_ptr); y_offset = png_get_y_offset_inches(png_ptr, info_ptr);
(Each of these returns 0 [signifying "unknown" if both (Each of these returns 0 [signifying "unknown" if both
x and y are 0] if the data is not present or if the chunk x and y are 0] if the data is not present or if the
is present but the unit is the pixel) chunk is present but the unit is the pixel)
For more information, see the png_info definition in png.h and the For more information, see the png_info definition in png.h and the
PNG specification for chunk contents. Be careful with trusting PNG specification for chunk contents. Be careful with trusting
@@ -1519,7 +1553,7 @@ higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to
convert the PNG pixel data back to the original bit depth of the image. convert the PNG pixel data back to the original bit depth of the image.
This call reduces the pixels back down to the original bit depth: This call reduces the pixels back down to the original bit depth:
png_color_16p sig_bit; png_color_8p sig_bit;
if (png_get_sBIT(png_ptr, info_ptr, &sig_bit)) if (png_get_sBIT(png_ptr, info_ptr, &sig_bit))
png_set_shift(png_ptr, sig_bit); png_set_shift(png_ptr, sig_bit);
@@ -1531,17 +1565,18 @@ changes the storage of the pixels to blue, green, red:
color_type == PNG_COLOR_TYPE_RGB_ALPHA) color_type == PNG_COLOR_TYPE_RGB_ALPHA)
png_set_bgr(png_ptr); png_set_bgr(png_ptr);
PNG files store RGB pixels packed into 3 bytes. This code expands them PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them
into 4 bytes for windowing systems that need them in this format: into 4 or 8 bytes for windowing systems that need them in this format:
if (bit_depth == 8 && color_type == if (color_type == PNG_COLOR_TYPE_RGB)
PNG_COLOR_TYPE_RGB) png_set_filler(png_ptr, png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE);
filler, PNG_FILLER_BEFORE);
where "filler" is the 8 or 16-bit number to fill with, and the location is where "filler" is the 8 or 16-bit number to fill with, and the location is
either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether
you want the filler before the RGB or after. This transformation you want the filler before the RGB or after. This transformation
does not affect images that already have full alpha channels. does not affect images that already have full alpha channels. To add an
opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which
will generate RGBA pixels.
If you are reading an image with an alpha channel, and you need the If you are reading an image with an alpha channel, and you need the
data as ARGB instead of the normal PNG format RGBA: data as ARGB instead of the normal PNG format RGBA:
@@ -1611,8 +1646,8 @@ which can be expressed with integers as
The calculation is done in a linear colorspace, if the image gamma The calculation is done in a linear colorspace, if the image gamma
is known. is known.
If you have a grayscale and you are using png_set_expand_depth() or If you have a grayscale and you are using png_set_expand_depth(),
png_set_expand() to change to png_set_expand(), or png_set_gray_to_rgb to change to truecolor or to
a higher bit-depth, you must either supply the background color as a gray a higher bit-depth, you must either supply the background color as a gray
value at the original file bit-depth (need_expand = 1) or else supply the value at the original file bit-depth (need_expand = 1) or else supply the
background color as an RGB triplet at the final, expanded bit depth background color as an RGB triplet at the final, expanded bit depth
@@ -1731,7 +1766,13 @@ PNG files describe monochrome as black being zero and white being one.
The following code will reverse this (make black be one and white be The following code will reverse this (make black be one and white be
zero): zero):
if (bit_depth == 1 && color_type == PNG_COLOR_GRAY) if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY)
png_set_invert_mono(png_ptr);
This function can also be used to invert grayscale and gray-alpha images:
if (color_type == PNG_COLOR_TYPE_GRAY ||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_invert_mono(png_ptr); png_set_invert_mono(png_ptr);
PNG files store 16 bit pixels in network byte order (big-endian, PNG files store 16 bit pixels in network byte order (big-endian,
@@ -1932,7 +1973,7 @@ When you are done, you can free all memory allocated by libpng like this:
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 function: 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, seq)
mask - identifies data to be freed, a mask mask - identifies data to be freed, a mask
containing the logical OR of one or containing the logical OR of one or
more of more of
@@ -1942,16 +1983,17 @@ point to libpng-allocated storage with the following function:
PNG_FREE_SCAL, PNG_FREE_SPLT, PNG_FREE_SCAL, PNG_FREE_SPLT,
PNG_FREE_TEXT, PNG_FREE_UNKN, PNG_FREE_TEXT, PNG_FREE_UNKN,
or simply PNG_FREE_ALL or simply PNG_FREE_ALL
n - sequence number of item to be freed seq - sequence number of item to be freed
(-1 for all items) (-1 for all items)
This function 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 "seq" 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 "seq" 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 in the structure
is freed, where n is "seq".
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,
@@ -1975,8 +2017,7 @@ or png_destroy_*() is supposed to free the data. When the user assumes
responsibility for libpng-allocated data, the application must use responsibility for libpng-allocated data, the application must use
png_free() to free it, and when the user transfers responsibility to libpng 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() 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 or png_zalloc() to allocate it.
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 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 the description of the high level read interface, you must not transfer
@@ -2270,7 +2311,8 @@ called after each row has been written, which you can use to control
a progress meter or the like. It's demonstrated in pngtest.c. a progress meter or the like. It's demonstrated in pngtest.c.
You must supply a function You must supply a function
void write_row_callback(png_ptr, png_uint_32 row, int pass); void write_row_callback(png_ptr, png_uint_32 row,
int pass);
{ {
/* put your code here */ /* put your code here */
} }
@@ -2298,8 +2340,9 @@ types.
/* turn on or off filtering, and/or choose /* turn on or off filtering, and/or choose
specific filters. You can use either a single PNG_FILTER_VALUE_NAME specific filters. You can use either a single
or the logical OR of one or more PNG_FILTER_NAME masks. */ 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_VALUE_NONE | PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE |
PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB |
@@ -2435,11 +2478,12 @@ Some of the more important parts of the png_info are:
png_set_iCCP(png_ptr, info_ptr, name, compression_type, png_set_iCCP(png_ptr, info_ptr, name, compression_type,
profile, proflen); profile, proflen);
name - The profile name. name - The profile name.
compression - The compression type; always PNG_COMPRESSION_TYPE_BASE compression - The compression type; always
for PNG 1.0. You may give NULL to this argument PNG_COMPRESSION_TYPE_BASE for PNG 1.0.
to ignore it. You may give NULL to this argument to
profile - International Color Consortium color profile ignore it.
data. May contain NULs. profile - International Color Consortium color
profile data. May contain NULs.
proflen - length of profile data in bytes. proflen - length of profile data in bytes.
png_set_sBIT(png_ptr, info_ptr, sig_bit); png_set_sBIT(png_ptr, info_ptr, sig_bit);
@@ -2493,11 +2537,13 @@ Some of the more important parts of the png_info are:
or empty for unknown). or empty for unknown).
num_text - number of comments num_text - number of comments
png_set_sPLT(png_ptr, info_ptr, &palette_ptr, num_spalettes); png_set_sPLT(png_ptr, info_ptr, &palette_ptr,
palette_ptr - array of png_sPLT_struct structures to be num_spalettes);
added to the list of palettes in the info palette_ptr - array of png_sPLT_struct structures
structure. to be added to the list of palettes
num_spalettes - number of palette structures to be added. in the info structure.
num_spalettes - number of palette structures to be
added.
png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y,
unit_type); unit_type);
@@ -2528,9 +2574,10 @@ Some of the more important parts of the png_info are:
height - height of a pixel in physical scale units height - height of a pixel in physical scale units
(width and height are strings like "2.54") (width and height are strings like "2.54")
png_set_unknown_chunks(png_ptr, info_ptr, &unknowns, num_unknowns) png_set_unknown_chunks(png_ptr, info_ptr, &unknowns,
unknowns - array of png_unknown_chunk structures holding num_unknowns)
unknown chunks unknowns - array of png_unknown_chunk
structures holding unknown chunks
unknowns[i].name - name of unknown chunk unknowns[i].name - name of unknown chunk
unknowns[i].data - data of unknown chunk unknowns[i].data - data of unknown chunk
unknowns[i].size - size of unknown chunk's data unknowns[i].size - size of unknown chunk's data
@@ -2539,14 +2586,15 @@ Some of the more important parts of the png_info are:
PNG_HAVE_IHDR: before PLTE PNG_HAVE_IHDR: before PLTE
PNG_HAVE_PLTE: before IDAT PNG_HAVE_PLTE: before IDAT
PNG_AFTER_IDAT: after IDAT PNG_AFTER_IDAT: after IDAT
The "location" member is set automatically according to
what part of the output file has already been written. The "location" member is set automatically according to
You can change its value after calling png_set_unknown_chunks() what part of the output file has already been written.
as demonstrated in pngtest.c. Within each of the "locations", You can change its value after calling png_set_unknown_chunks()
the chunks are sequenced according to their position in the as demonstrated in pngtest.c. Within each of the "locations",
structure (that is, the value of "i", which is the order in which the chunks are sequenced according to their position in the
the chunk was either read from the input file or defined with structure (that is, the value of "i", which is the order in which
png_set_unknown_chunks). the chunk was either read from the input file or defined with
png_set_unknown_chunks).
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.
@@ -2647,12 +2695,17 @@ transformations are permitted, enabled by the following masks.
PNG_TRANSFORM_IDENTITY No transformation PNG_TRANSFORM_IDENTITY No transformation
PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples
PNG_TRANSFORM_PACKSWAP Change order of packed pixels to LSB first PNG_TRANSFORM_PACKSWAP Change order of packed
pixels to LSB first
PNG_TRANSFORM_INVERT_MONO Invert monochrome images PNG_TRANSFORM_INVERT_MONO Invert monochrome images
PNG_TRANSFORM_SHIFT Normalize pixels to the sBIT depth PNG_TRANSFORM_SHIFT Normalize pixels to the
PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA to BGRA sBIT depth
PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA to AG PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA
PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity to transparency to BGRA
PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA
to AG
PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity
to transparency
PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples 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.
@@ -2916,7 +2969,7 @@ When you are done, you can free all memory used by libpng like this:
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 function: 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, seq)
mask - identifies data to be freed, a mask mask - identifies data to be freed, a mask
containing the logical OR of one or containing the logical OR of one or
more of more of
@@ -2926,16 +2979,17 @@ point to libpng-allocated storage with the following function:
PNG_FREE_SCAL, PNG_FREE_SPLT, PNG_FREE_SCAL, PNG_FREE_SPLT,
PNG_FREE_TEXT, PNG_FREE_UNKN, PNG_FREE_TEXT, PNG_FREE_UNKN,
or simply PNG_FREE_ALL or simply PNG_FREE_ALL
n - sequence number of item to be freed seq - sequence number of item to be freed
(-1 for all items) (-1 for all items)
This function 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 "seq" 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 "seq" 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 in the structure
is freed, where n is "seq".
If you allocated data such as a palette that you passed If you allocated data such as a palette that you passed
in to libpng with 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
@@ -3008,26 +3062,29 @@ 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_malloc(), png_zalloc(), Memory allocation is done through the functions png_malloc()
and png_free(). These currently just call the standard C functions. If and png_free(). These currently just call the standard C functions. 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. If you prefer 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 to use a different method of allocating and freeing data, you can use
png_create_read_struct_2() or png_create_write_struct_2() to register
png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr your own functions as described above.
malloc_fn, png_free_ptr free_fn) These functions also provide a void pointer that can be retrieved via
This function also provides a void pointer that can be retrieved via
mem_ptr=png_get_mem_ptr(png_ptr); mem_ptr=png_get_mem_ptr(png_ptr);
Your replacement memory functions must have prototypes as follows: Your replacement memory functions must have prototypes as follows:
png_voidp malloc_fn(png_structp png_ptr, png_uint_32 size); png_voidp malloc_fn(png_structp png_ptr,
png_size_t size);
void free_fn(png_structp png_ptr, png_voidp ptr); void free_fn(png_structp png_ptr, png_voidp ptr);
Your malloc_fn() should return NULL in case of failure. The png_malloc()
function will call png_error() if it receives a NULL from the system
memory allocator or from your replacement malloc_fn().
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
@@ -3050,9 +3107,9 @@ png_get_io_ptr(). For example:
The replacement I/O functions must 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_size_t length);
void user_write_data(png_structp png_ptr, void user_write_data(png_structp png_ptr,
png_bytep data, png_uint_32 length); png_bytep data, png_size_t length);
void user_flush_data(png_structp png_ptr); void user_flush_data(png_structp png_ptr);
Supplying NULL for the read, write, or flush functions sets them back Supplying NULL for the read, write, or flush functions sets them back
@@ -3187,6 +3244,10 @@ compression level by calling:
Another useful one is to reduce the memory level used by the library. Another useful one is to reduce the memory level used by the library.
The memory level defaults to 8, but it can be lowered if you are The memory level defaults to 8, but it can be lowered if you are
short on memory (running DOS, for example, where you only have 640K). short on memory (running DOS, for example, where you only have 640K).
Note that the memory level does have an effect on compression; among
other things, lower levels will result in sections of incompressible
data being emitted in smaller stored blocks, with a correspondingly
larger relative overhead of up to 15% in the worst case.
png_set_compression_mem_level(png_ptr, level); png_set_compression_mem_level(png_ptr, level);
@@ -3221,38 +3282,39 @@ 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 with '|' to specify one or more filters to use. ORed together with '|' to specify one or more filters to use.
These filters are described in more detail in the PNG specification. If These filters are described in more detail in the PNG specification.
you intend to change the filter type during the course of writing If 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. (Note that this
means the first row must always be adaptively filtered, because libpng
currently does not allocate the filter buffers until png_write_row()
is called for the first time.)
filters = PNG_FILTER_NONE | PNG_FILTER_SUB filters = PNG_FILTER_NONE | PNG_FILTER_SUB
PNG_FILTER_UP | PNG_FILTER_AVE | PNG_FILTER_UP | PNG_FILTER_AVE |
PNG_FILTER_PAETH | PNG_ALL_FILTERS; 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);
The second parameter can also be PNG_INTRAPIXEL_DIFFERENCING The second parameter can also be
if you are writing a PNG to be embedded in a MNG PNG_INTRAPIXEL_DIFFERENCING if you are
datastream. This parameter must be the same as the writing a PNG to be embedded in a MNG
value of filter_method used in png_set_IHDR(). datastream. This parameter must be the
same as the value of filter_method used
in png_set_IHDR().
It is also possible to influence how libpng chooses from among the It is also possible to influence how libpng chooses from among the
available filters. This is done in two ways - by telling it how available filters. This is done in one or both of two ways - by
important it is to keep the same filter for successive rows, and telling it how important it is to keep the same filter for successive
by telling it the relative computational costs of the filters. rows, and by telling it the relative computational costs of the filters.
double weights[3] = {1.5, 1.3, 1.1}, double weights[3] = {1.5, 1.3, 1.1},
costs[PNG_FILTER_VALUE_LAST] = costs[PNG_FILTER_VALUE_LAST] =
{1.0, 1.3, 1.3, 1.5, 1.7}; {1.0, 1.3, 1.3, 1.5, 1.7};
png_set_filter_selection(png_ptr, png_set_filter_heuristics(png_ptr,
PNG_FILTER_SELECTION_WEIGHTED, 3, PNG_FILTER_HEURISTIC_WEIGHTED, 3,
weights, costs); weights, costs);
The weights are multiplying factors that indicate to libpng that the The weights are multiplying factors that indicate to libpng that the
@@ -3352,7 +3414,6 @@ 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.
.SH VI. MNG support .SH VI. MNG support
The MNG specification (available at http://www.libpng.org/pub/mng) allows The MNG specification (available at http://www.libpng.org/pub/mng) allows
@@ -3366,7 +3427,7 @@ png_permit_mng_features() function:
PNG_FLAG_MNG_EMPTY_PLTE PNG_FLAG_MNG_EMPTY_PLTE
PNG_FLAG_MNG_FILTER_64 PNG_FLAG_MNG_FILTER_64
PNG_ALL_MNG_FEATURES PNG_ALL_MNG_FEATURES
feature_set is a png_32_uint that is the logical AND of feature_set is a png_byte that is the logical AND of
your mask with the set of MNG features that is your mask with the set of MNG features that is
supported by the version of libpng that you are using. supported by the version of libpng that you are using.
@@ -3388,7 +3449,7 @@ of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are
still alive and well, but they have moved on to other things. 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_destroy() have been
moved to PNG_INTERNAL in version 0.95 to discourage their use. These moved to PNG_INTERNAL in version 0.95 to discourage their use. These
functions will be removed from libpng version 2.0.0. functions will be removed from libpng version 2.0.0.
@@ -3427,15 +3488,15 @@ application:
png_uint_32 application_vn = PNG_LIBPNG_VER; png_uint_32 application_vn = PNG_LIBPNG_VER;
.SH VIII. Y2K Compliance in libpng .SH VII. Y2K Compliance in libpng
January 31, 2001 July 8, 2002
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.9 are Y2K compliant. It is my belief that earlier upward through 1.0.14 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
@@ -3453,7 +3514,8 @@ There are seven time-related functions:
png_convert_to_rfc_1123() in png.c png_convert_to_rfc_1123() in png.c
(formerly png_convert_to_rfc_1152() in error) (formerly png_convert_to_rfc_1152() in error)
png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c png_convert_from_struct_tm() in pngwrite.c, called
in pngwrite.c
png_convert_from_time_t() in pngwrite.c png_convert_from_time_t() in pngwrite.c
png_get_tIME() in pngget.c png_get_tIME() in pngget.c
png_handle_tIME() in pngrutil.c, called in pngread.c png_handle_tIME() in pngrutil.c, called in pngread.c
@@ -3492,43 +3554,93 @@ on the library has not always been consistent and straightforward.
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 ("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 ("beta 4") 0.90 90 0.90
0.95 ("1.0 beta 5") 0.95 95 0.95 [should have been 2.0.95] 0.95 ("beta 5") 0.95 95 0.95
0.96 ("1.0 beta 6") 0.96 96 0.96 [should have been 2.0.96] 0.96 ("beta 6") 0.96 96 0.96
0.97b ("1.00.97 beta 7") 1.00.97 97 1.0.1 [should have been 2.0.97] 0.97b ("beta 7") 1.00.97 97 1.0.1
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
1.0.0 1.0.0 100 2.1.0 [100 should be 10000] 1.0.0 1.0.0 100 2.1.0
1.0.1 1.0.1 10001 2.1.0 1.0.0 (from here on, the 100 2.1.0
1.0.1a-e 1.0.1a-e 10002 2.1.0.1a-e 1.0.1 png.h string is 10001 2.1.0
1.0.2 1.0.2 10002 2.1.0.2 1.0.1a-e identical to the 10002 from here on, the
1.0.2a-b 1.0.2a-b 10003 2.1.0.2a-b 1.0.2 source version) 10002 shared library is 2.V
1.0.3 1.0.3 10003 2.1.0.3 1.0.2a-b 10003 where V is the source
1.0.3a-d 1.0.3a-d 10004 2.1.0.3a-d 1.0.1 10001 code version except as
1.0.4 1.0.4 10004 2.1.0.4 1.0.1a-e 10002 2.1.0.1a-e noted.
1.0.4a-f 1.0.4a-f 10005 2.1.0.4a-f 1.0.2 10002 2.1.0.2
1.0.5 (+ 2 patches) 1.0.5 10005 2.1.0.5 1.0.2a-b 10003 2.1.0.2a-b
1.0.5a-d 1.0.5a-d 10006 2.1.0.5a-d 1.0.3 10003 2.1.0.3
1.0.5e-r 1.0.5e-r 10100 2.1.0.5e-r (not compatible) 1.0.3a-d 10004 2.1.0.3a-d
1.0.5s-v 1.0.5s-v 10006 2.1.0.5s-v (compatible) 1.0.4 10004 2.1.0.4
1.0.6 (+ 3 patches) 1.0.6 10006 2.1.0.6 1.0.4a-f 10005 2.1.0.4a-f
1.0.6d 1.0.6d 10007 2.1.0.6d 1.0.5 (+ 2 patches) 10005 2.1.0.5
1.0.7 1.0.7 10007 2.1.0.7 (still compatible) 1.0.5a-d 10006 2.1.0.5a-d
1.0.5e-r 10100 2.1.0.5e-r
1.0.5s-v 10006 2.1.0.5s-v
1.0.6 (+ 3 patches) 10006 2.1.0.6
1.0.6d-g 10007 2.1.0.6d-g
1.0.6h 10007 10.6h
1.0.6i 10007 10.6i
1.0.6j 10007 2.1.0.6j
1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14
1.0.7beta15-18 1 10007 2.1.0.7beta15-18
1.0.7rc1-2 1 10007 2.1.0.7rc1-2
1.0.7 1 10007 2.1.0.7
1.0.8beta1-4 1 10008 2.1.0.8beta1-4
1.0.8rc1 1 10008 2.1.0.8rc1
1.0.8 1 10008 2.1.0.8
1.0.9beta1-6 1 10009 2.1.0.9beta1-6
1.0.9rc1 1 10009 2.1.0.9rc1
1.0.9beta7-10 1 10009 2.1.0.9beta7-10
1.0.9rc2 1 10009 2.1.0.9rc2
1.0.9 1 10009 2.1.0.9
1.0.10beta1 1 10010 2.1.0.10beta1
1.0.10rc1 1 10010 2.1.0.10rc1
1.0.10 1 10010 2.1.0.10
1.0.11beta1-3 1 10011 2.1.0.11beta1-3
1.0.11rc1 1 10011 2.1.0.11rc1
1.0.11 1 10011 2.1.0.11
1.0.12beta1-2 2 10012 2.1.0.12beta1-2
1.0.12rc1 2 10012 2.1.0.12rc1
1.0.12 2 10012 2.1.0.12
1.1.0a-f - 10100 2.1.1.0a-f abandoned
1.2.0beta1-2 2 10200 2.1.2.0beta1-2
1.2.0beta3-5 3 10200 3.1.2.0beta3-5
1.2.0rc1 3 10200 3.1.2.0rc1
1.2.0 3 10200 3.1.2.0
1.2.1beta-4 3 10201 3.1.2.1beta1-4
1.2.1rc1-2 3 10201 3.1.2.1rc1-2
1.2.1 3 10201 3.1.2.1
1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6
1.0.13beta1 10 10013 10.so.0.1.0.13beta1
1.0.13rc1 10 10013 10.so.0.1.0.13rc1
1.2.2rc1 12 10202 12.so.0.1.2.2rc1
1.0.13 10 10013 10.so.0.1.0.13
1.2.2 12 10202 12.so.0.1.2.2
1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6
1.2.3 12 10203 12.so.0.1.2.3
1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3
1.2.4rc1 13 10204 12.so.0.1.2.4rc1
1.0.14 10 10014 10.so.0.1.0.14
1.2.4 13 10204 12.so.0.1.2.4
Henceforth the source version will match the shared-library minor Henceforth the source version will match the shared-library minor
and patch numbers; the shared-library major version number will be and patch 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".
.SH "SEE ALSO" .SH "SEE ALSO"
libpngpf(3), png(5) libpngpf(3), png(5)
@@ -3576,7 +3688,7 @@ possible without all of you.
Thanks to Frank J. T. Wojcik for helping with the documentation. Thanks to Frank J. T. Wojcik for helping with the documentation.
Libpng version 1.0.9 - January 31, 2001: Libpng version 1.0.14 - July 8, 2002:
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (randeg@alum.rpi.edu). Currently maintained by Glenn Randers-Pehrson (randeg@alum.rpi.edu).
@@ -3593,8 +3705,8 @@ included in the libpng distribution, the latter shall prevail.)
If you modify libpng you may insert additional notices immediately following If you modify libpng you may insert additional notices immediately following
this sentence. this sentence.
libpng versions 1.0.7, July 1, 2000, through 1.0.9, January 31, 2001, are libpng versions 1.0.7, July 1, 2000, through 1.0.14, July 8, 2002, are
Copyright (c) 2000 Glenn Randers-Pehrson, and are Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.0.6 distributed according to the same disclaimer and license as libpng-1.0.6
with the following individuals added to the list of Contributing Authors with the following individuals added to the list of Contributing Authors
@@ -3604,12 +3716,13 @@ with the following individuals added to the list of Contributing Authors
and with the following additions to the disclaimer: and with the following additions to the disclaimer:
There is no warranty against interference with your enjoyment of the There is no warranty against interference with your
library or against infringement. There is no warranty that our enjoyment of the library or against infringement.
efforts or the library will fulfill any of your particular purposes There is no warranty that our efforts or the library
or needs. This library is provided with all faults, and the entire will fulfill any of your particular purposes or needs.
risk of satisfactory quality, performance, accuracy, and effort is with This library is provided with all faults, and the entire
the user. 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 libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
Copyright (c) 1998, 1999 Glenn Randers-Pehrson Copyright (c) 1998, 1999 Glenn Randers-Pehrson
@@ -3658,11 +3771,11 @@ to the following restrictions:
1. The origin of this source code must not be misrepresented. 1. The origin of this source code must not be misrepresented.
2. Altered versions must be plainly marked as such and must not 2. Altered versions must be plainly marked as such and
be misrepresented as being the original source. must not be misrepresented as being the original source.
3. This Copyright notice may not be removed or altered from any 3. This Copyright notice may not be removed or altered from
source or altered source distribution. any source or altered source 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
@@ -3684,7 +3797,7 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson Glenn Randers-Pehrson
randeg@alum.rpi.edu randeg@alum.rpi.edu
January 31, 2001 July 8, 2002
.\" end of man page .\" end of man page

View File

@@ -1,9 +1,9 @@
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.9 - January 31, 2001 libpng version 1.0.14 - July 8, 2002
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-2002 Glenn Randers-Pehrson
For conditions of distribution and use, see copyright For conditions of distribution and use, see copyright
notice in png.h. notice in png.h.
@@ -78,7 +78,9 @@ Libpng is thread safe, provided the threads are using different
instances of the structures. Each thread should have its own instances of the structures. Each thread should have its own
png_struct and png_info instances, and thus its own image. png_struct and png_info instances, and thus its own image.
Libpng does not protect itself against two threads using the Libpng does not protect itself against two threads using the
same instance of a structure. same instance of a structure. Note: thread safety may be defeated
by use of some of the MMX assembler code in pnggccrd.c, which is only
compiled when the user defines PNG_THREAD_UNSAFE_OK.
II. Structures II. Structures
@@ -257,10 +259,11 @@ input stream. You must supply the function
png_byte name[5]; png_byte name[5];
png_byte *data; png_byte *data;
png_size_t size; png_size_t size;
/* Note that libpng has already taken care of the /* Note that libpng has already taken care of
CRC handling */ the CRC handling */
/* put your code here. Return one of the following: */ /* put your code here. Return one of the
following: */
return (-n); /* chunk had an error */ return (-n); /* chunk had an error */
return (0); /* did not recognize */ return (0); /* did not recognize */
@@ -285,7 +288,8 @@ called after each row has been read, which you can use to control
a progress meter or the like. It's demonstrated in pngtest.c. a progress meter or the like. It's demonstrated in pngtest.c.
You must supply a function You must supply a function
void read_row_callback(png_ptr ptr, png_uint_32 row, int pass); void read_row_callback(png_ptr ptr, png_uint_32 row,
int pass);
{ {
/* put your code here */ /* put your code here */
} }
@@ -331,16 +335,23 @@ the entire image into memory, and (b) the input transformations
you want to do are limited to the following set: you want to do are limited to the following set:
PNG_TRANSFORM_IDENTITY No transformation PNG_TRANSFORM_IDENTITY No transformation
PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to 8 bits PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to
8 bits
PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel
PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit samples to bytes PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit
PNG_TRANSFORM_PACKSWAP Change order of packed pixels to LSB first samples to bytes
PNG_TRANSFORM_PACKSWAP Change order of packed
pixels to LSB first
PNG_TRANSFORM_EXPAND Perform set_expand() PNG_TRANSFORM_EXPAND Perform set_expand()
PNG_TRANSFORM_INVERT_MONO Invert monochrome images PNG_TRANSFORM_INVERT_MONO Invert monochrome images
PNG_TRANSFORM_SHIFT Normalize pixels to the sBIT depth PNG_TRANSFORM_SHIFT Normalize pixels to the
PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA to BGRA sBIT depth
PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA to AG PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA
PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity to transparency to BGRA
PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA
to AG
PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity
to transparency
PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples
(This excludes setting a background color, doing gamma transformation, (This excludes setting a background color, doing gamma transformation,
@@ -368,9 +379,11 @@ where row_pointers is an array of pointers to the pixel data for each row:
If you know your image size and pixel size ahead of time, you can allocate 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 prior to calling png_read_png() with
row_pointers = png_malloc(png_ptr, height*sizeof(png_bytep)); row_pointers = png_malloc(png_ptr,
height*sizeof(png_bytep));
for (int i=0; i<height, i++) for (int i=0; i<height, i++)
row_pointers[i]=png_malloc(png_ptr, width*pixel_size); row_pointers[i]=png_malloc(png_ptr,
width*pixel_size);
png_set_rows(png_ptr, info_ptr, &row_pointers); png_set_rows(png_ptr, info_ptr, &row_pointers);
Alternatively you could allocate your image in one big block and define Alternatively you could allocate your image in one big block and define
@@ -438,8 +451,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_method can be NULL if you are filter_method can be NULL if you are
not interested in their values. not 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
@@ -502,14 +515,15 @@ into the info_ptr is returned for any complex types.
implies specific values of gAMA and implies specific values of gAMA and
cHRM. cHRM.
png_get_iCCP(png_ptr, info_ptr, &name, &compression_type, png_get_iCCP(png_ptr, info_ptr, &name,
&profile, &proflen); &compression_type, &profile, &proflen);
name - The profile name. name - The profile name.
compression - The compression type; always PNG_COMPRESSION_TYPE_BASE compression - The compression type; always
for PNG 1.0. You may give NULL to this argument PNG_COMPRESSION_TYPE_BASE for PNG 1.0.
to ignore it. You may give NULL to this argument to
profile - International Color Consortium color profile ignore it.
data. May contain NULs. profile - International Color Consortium color
profile data. May contain NULs.
proflen - length of profile data in bytes. proflen - length of profile data in bytes.
png_get_sBIT(png_ptr, info_ptr, &sig_bit); png_get_sBIT(png_ptr, info_ptr, &sig_bit);
@@ -563,23 +577,26 @@ into the info_ptr is returned for any complex types.
after decompression, 0 for tEXt/zTXt after decompression, 0 for tEXt/zTXt
text_ptr[i].lang - language of comment (empty text_ptr[i].lang - language of comment (empty
string for unknown). string for unknown).
text_ptr[i].translated_keyword - keyword in UTF-8 text_ptr[i].lang_key - keyword in UTF-8
(empty string for unknown). (empty string for unknown).
num_text - number of comments (same as num_comments; num_text - number of comments (same as
you can put NULL here to avoid the duplication) num_comments; you can put NULL here
Note while png_set_text() will accept text, language, and to avoid the duplication)
translated keywords that can be NULL pointers, the structure Note while png_set_text() will accept text, language,
returned by png_get_text will always contain regular and translated keywords that can be NULL pointers, the
zero-terminated C strings. They might be empty strings but structure returned by png_get_text will always contain
they will never be NULL pointers. regular zero-terminated C strings. They might be
empty strings but they will never be NULL pointers.
num_spalettes = png_get_sPLT(png_ptr, info_ptr, &palette_ptr); num_spalettes = png_get_sPLT(png_ptr, info_ptr,
&palette_ptr);
palette_ptr - array of palette structures holding palette_ptr - array of palette structures holding
contents of one or more sPLT chunks read. contents of one or more sPLT chunks
read.
num_spalettes - number of sPLT chunks read. num_spalettes - number of sPLT chunks read.
png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y,
&unit_type); &unit_type);
offset_x - positive offset from the left edge offset_x - positive offset from the left edge
of the screen of the screen
offset_y - positive offset from the top edge offset_y - positive offset from the top edge
@@ -587,7 +604,7 @@ into the info_ptr is returned for any complex types.
unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER
png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y,
&unit_type); &unit_type);
res_x - pixels/unit physical resolution in res_x - pixels/unit physical resolution in
x direction x direction
res_y - pixels/unit physical resolution in res_y - pixels/unit physical resolution in
@@ -595,47 +612,50 @@ into the info_ptr is returned for any complex types.
unit_type - PNG_RESOLUTION_UNKNOWN, unit_type - PNG_RESOLUTION_UNKNOWN,
PNG_RESOLUTION_METER PNG_RESOLUTION_METER
png_get_sCAL(png_ptr, info_ptr, &unit, &width, &height) png_get_sCAL(png_ptr, info_ptr, &unit, &width,
&height)
unit - physical scale units (an integer) unit - physical scale units (an integer)
width - width of a pixel in physical scale units width - width of a pixel in physical scale units
height - height of a pixel in physical scale units height - height of a pixel in physical scale units
(width and height are doubles) (width and height are doubles)
png_get_sCAL_s(png_ptr, info_ptr, &unit, &width, &height) png_get_sCAL_s(png_ptr, info_ptr, &unit, &width,
&height)
unit - physical scale units (an integer) unit - physical scale units (an integer)
width - width of a pixel in physical scale units width - width of a pixel in physical scale units
height - height of a pixel in physical scale units height - height of a pixel in physical scale units
(width and height are strings like "2.54") (width and height are strings like "2.54")
num_unknown_chunks = png_get_unknown_chunks(png_ptr, info_ptr, num_unknown_chunks = png_get_unknown_chunks(png_ptr,
&unknowns) info_ptr, &unknowns)
unknowns - array of png_unknown_chunk structures holding unknowns - array of png_unknown_chunk
unknown chunks structures holding unknown chunks
unknowns[i].name - name of unknown chunk unknowns[i].name - name of unknown chunk
unknowns[i].data - data of unknown chunk unknowns[i].data - data of unknown chunk
unknowns[i].size - size of unknown chunk's data unknowns[i].size - size of unknown chunk's data
unknowns[i].location - position of chunk in file unknowns[i].location - position of chunk in file
The value of "i" corresponds to the order in which the chunks were read The value of "i" corresponds to the order in which the
from the PNG file or inserted with the png_set_unknown_chunks() function. chunks were read from the PNG file or inserted with the
png_set_unknown_chunks() function.
The data from the pHYs chunk can be retrieved in several convenient The data from the pHYs chunk can be retrieved in several convenient
forms: forms:
res_x = png_get_x_pixels_per_meter(png_ptr, res_x = png_get_x_pixels_per_meter(png_ptr,
info_ptr) info_ptr)
res_y = png_get_y_pixels_per_meter(png_ptr, res_y = png_get_y_pixels_per_meter(png_ptr,
info_ptr) info_ptr)
res_x_and_y = png_get_pixels_per_meter(png_ptr, res_x_and_y = png_get_pixels_per_meter(png_ptr,
info_ptr) info_ptr)
res_x = png_get_x_pixels_per_inch(png_ptr, res_x = png_get_x_pixels_per_inch(png_ptr,
info_ptr) info_ptr)
res_y = png_get_y_pixels_per_inch(png_ptr, res_y = png_get_y_pixels_per_inch(png_ptr,
info_ptr) info_ptr)
res_x_and_y = png_get_pixels_per_inch(png_ptr, res_x_and_y = png_get_pixels_per_inch(png_ptr,
info_ptr) info_ptr)
aspect_ratio = png_get_pixel_aspect_ratio(png_ptr, aspect_ratio = png_get_pixel_aspect_ratio(png_ptr,
info_ptr) info_ptr)
(Each of these returns 0 [signifying "unknown"] if (Each of these returns 0 [signifying "unknown"] if
the data is not present or if res_x is 0; the data is not present or if res_x is 0;
@@ -650,8 +670,8 @@ forms:
y_offset = png_get_y_offset_inches(png_ptr, info_ptr); y_offset = png_get_y_offset_inches(png_ptr, info_ptr);
(Each of these returns 0 [signifying "unknown" if both (Each of these returns 0 [signifying "unknown" if both
x and y are 0] if the data is not present or if the chunk x and y are 0] if the data is not present or if the
is present but the unit is the pixel) chunk is present but the unit is the pixel)
For more information, see the png_info definition in png.h and the For more information, see the png_info definition in png.h and the
PNG specification for chunk contents. Be careful with trusting PNG specification for chunk contents. Be careful with trusting
@@ -772,7 +792,7 @@ higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to
convert the PNG pixel data back to the original bit depth of the image. convert the PNG pixel data back to the original bit depth of the image.
This call reduces the pixels back down to the original bit depth: This call reduces the pixels back down to the original bit depth:
png_color_16p sig_bit; png_color_8p sig_bit;
if (png_get_sBIT(png_ptr, info_ptr, &sig_bit)) if (png_get_sBIT(png_ptr, info_ptr, &sig_bit))
png_set_shift(png_ptr, sig_bit); png_set_shift(png_ptr, sig_bit);
@@ -784,17 +804,18 @@ changes the storage of the pixels to blue, green, red:
color_type == PNG_COLOR_TYPE_RGB_ALPHA) color_type == PNG_COLOR_TYPE_RGB_ALPHA)
png_set_bgr(png_ptr); png_set_bgr(png_ptr);
PNG files store RGB pixels packed into 3 bytes. This code expands them PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them
into 4 bytes for windowing systems that need them in this format: into 4 or 8 bytes for windowing systems that need them in this format:
if (bit_depth == 8 && color_type == if (color_type == PNG_COLOR_TYPE_RGB)
PNG_COLOR_TYPE_RGB) png_set_filler(png_ptr, png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE);
filler, PNG_FILLER_BEFORE);
where "filler" is the 8 or 16-bit number to fill with, and the location is where "filler" is the 8 or 16-bit number to fill with, and the location is
either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether
you want the filler before the RGB or after. This transformation you want the filler before the RGB or after. This transformation
does not affect images that already have full alpha channels. does not affect images that already have full alpha channels. To add an
opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which
will generate RGBA pixels.
If you are reading an image with an alpha channel, and you need the If you are reading an image with an alpha channel, and you need the
data as ARGB instead of the normal PNG format RGBA: data as ARGB instead of the normal PNG format RGBA:
@@ -864,8 +885,8 @@ which can be expressed with integers as
The calculation is done in a linear colorspace, if the image gamma The calculation is done in a linear colorspace, if the image gamma
is known. is known.
If you have a grayscale and you are using png_set_expand_depth() or If you have a grayscale and you are using png_set_expand_depth(),
png_set_expand() to change to png_set_expand(), or png_set_gray_to_rgb to change to truecolor or to
a higher bit-depth, you must either supply the background color as a gray a higher bit-depth, you must either supply the background color as a gray
value at the original file bit-depth (need_expand = 1) or else supply the value at the original file bit-depth (need_expand = 1) or else supply the
background color as an RGB triplet at the final, expanded bit depth background color as an RGB triplet at the final, expanded bit depth
@@ -984,7 +1005,13 @@ PNG files describe monochrome as black being zero and white being one.
The following code will reverse this (make black be one and white be The following code will reverse this (make black be one and white be
zero): zero):
if (bit_depth == 1 && color_type == PNG_COLOR_GRAY) if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY)
png_set_invert_mono(png_ptr);
This function can also be used to invert grayscale and gray-alpha images:
if (color_type == PNG_COLOR_TYPE_GRAY ||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_invert_mono(png_ptr); png_set_invert_mono(png_ptr);
PNG files store 16 bit pixels in network byte order (big-endian, PNG files store 16 bit pixels in network byte order (big-endian,
@@ -1185,7 +1212,7 @@ When you are done, you can free all memory allocated by libpng like this:
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 function: 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, seq)
mask - identifies data to be freed, a mask mask - identifies data to be freed, a mask
containing the logical OR of one or containing the logical OR of one or
more of more of
@@ -1195,16 +1222,17 @@ point to libpng-allocated storage with the following function:
PNG_FREE_SCAL, PNG_FREE_SPLT, PNG_FREE_SCAL, PNG_FREE_SPLT,
PNG_FREE_TEXT, PNG_FREE_UNKN, PNG_FREE_TEXT, PNG_FREE_UNKN,
or simply PNG_FREE_ALL or simply PNG_FREE_ALL
n - sequence number of item to be freed seq - sequence number of item to be freed
(-1 for all items) (-1 for all items)
This function 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 "seq" 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 "seq" 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 in the structure
is freed, where n is "seq".
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,
@@ -1228,8 +1256,7 @@ or png_destroy_*() is supposed to free the data. When the user assumes
responsibility for libpng-allocated data, the application must use responsibility for libpng-allocated data, the application must use
png_free() to free it, and when the user transfers responsibility to libpng 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() 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 or png_zalloc() to allocate it.
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 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 the description of the high level read interface, you must not transfer
@@ -1523,7 +1550,8 @@ called after each row has been written, which you can use to control
a progress meter or the like. It's demonstrated in pngtest.c. a progress meter or the like. It's demonstrated in pngtest.c.
You must supply a function You must supply a function
void write_row_callback(png_ptr, png_uint_32 row, int pass); void write_row_callback(png_ptr, png_uint_32 row,
int pass);
{ {
/* put your code here */ /* put your code here */
} }
@@ -1551,8 +1579,9 @@ types.
/* turn on or off filtering, and/or choose /* turn on or off filtering, and/or choose
specific filters. You can use either a single PNG_FILTER_VALUE_NAME specific filters. You can use either a single
or the logical OR of one or more PNG_FILTER_NAME masks. */ 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_VALUE_NONE | PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE |
PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB |
@@ -1688,11 +1717,12 @@ Some of the more important parts of the png_info are:
png_set_iCCP(png_ptr, info_ptr, name, compression_type, png_set_iCCP(png_ptr, info_ptr, name, compression_type,
profile, proflen); profile, proflen);
name - The profile name. name - The profile name.
compression - The compression type; always PNG_COMPRESSION_TYPE_BASE compression - The compression type; always
for PNG 1.0. You may give NULL to this argument PNG_COMPRESSION_TYPE_BASE for PNG 1.0.
to ignore it. You may give NULL to this argument to
profile - International Color Consortium color profile ignore it.
data. May contain NULs. profile - International Color Consortium color
profile data. May contain NULs.
proflen - length of profile data in bytes. proflen - length of profile data in bytes.
png_set_sBIT(png_ptr, info_ptr, sig_bit); png_set_sBIT(png_ptr, info_ptr, sig_bit);
@@ -1746,11 +1776,13 @@ Some of the more important parts of the png_info are:
or empty for unknown). or empty for unknown).
num_text - number of comments num_text - number of comments
png_set_sPLT(png_ptr, info_ptr, &palette_ptr, num_spalettes); png_set_sPLT(png_ptr, info_ptr, &palette_ptr,
palette_ptr - array of png_sPLT_struct structures to be num_spalettes);
added to the list of palettes in the info palette_ptr - array of png_sPLT_struct structures
structure. to be added to the list of palettes
num_spalettes - number of palette structures to be added. in the info structure.
num_spalettes - number of palette structures to be
added.
png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y,
unit_type); unit_type);
@@ -1781,9 +1813,10 @@ Some of the more important parts of the png_info are:
height - height of a pixel in physical scale units height - height of a pixel in physical scale units
(width and height are strings like "2.54") (width and height are strings like "2.54")
png_set_unknown_chunks(png_ptr, info_ptr, &unknowns, num_unknowns) png_set_unknown_chunks(png_ptr, info_ptr, &unknowns,
unknowns - array of png_unknown_chunk structures holding num_unknowns)
unknown chunks unknowns - array of png_unknown_chunk
structures holding unknown chunks
unknowns[i].name - name of unknown chunk unknowns[i].name - name of unknown chunk
unknowns[i].data - data of unknown chunk unknowns[i].data - data of unknown chunk
unknowns[i].size - size of unknown chunk's data unknowns[i].size - size of unknown chunk's data
@@ -1792,14 +1825,15 @@ Some of the more important parts of the png_info are:
PNG_HAVE_IHDR: before PLTE PNG_HAVE_IHDR: before PLTE
PNG_HAVE_PLTE: before IDAT PNG_HAVE_PLTE: before IDAT
PNG_AFTER_IDAT: after IDAT PNG_AFTER_IDAT: after IDAT
The "location" member is set automatically according to
what part of the output file has already been written. The "location" member is set automatically according to
You can change its value after calling png_set_unknown_chunks() what part of the output file has already been written.
as demonstrated in pngtest.c. Within each of the "locations", You can change its value after calling png_set_unknown_chunks()
the chunks are sequenced according to their position in the as demonstrated in pngtest.c. Within each of the "locations",
structure (that is, the value of "i", which is the order in which the chunks are sequenced according to their position in the
the chunk was either read from the input file or defined with structure (that is, the value of "i", which is the order in which
png_set_unknown_chunks). the chunk was either read from the input file or defined with
png_set_unknown_chunks).
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.
@@ -1900,12 +1934,17 @@ transformations are permitted, enabled by the following masks.
PNG_TRANSFORM_IDENTITY No transformation PNG_TRANSFORM_IDENTITY No transformation
PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples
PNG_TRANSFORM_PACKSWAP Change order of packed pixels to LSB first PNG_TRANSFORM_PACKSWAP Change order of packed
pixels to LSB first
PNG_TRANSFORM_INVERT_MONO Invert monochrome images PNG_TRANSFORM_INVERT_MONO Invert monochrome images
PNG_TRANSFORM_SHIFT Normalize pixels to the sBIT depth PNG_TRANSFORM_SHIFT Normalize pixels to the
PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA to BGRA sBIT depth
PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA to AG PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA
PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity to transparency to BGRA
PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA
to AG
PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity
to transparency
PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples 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.
@@ -2169,7 +2208,7 @@ When you are done, you can free all memory used by libpng like this:
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 function: 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, seq)
mask - identifies data to be freed, a mask mask - identifies data to be freed, a mask
containing the logical OR of one or containing the logical OR of one or
more of more of
@@ -2179,16 +2218,17 @@ point to libpng-allocated storage with the following function:
PNG_FREE_SCAL, PNG_FREE_SPLT, PNG_FREE_SCAL, PNG_FREE_SPLT,
PNG_FREE_TEXT, PNG_FREE_UNKN, PNG_FREE_TEXT, PNG_FREE_UNKN,
or simply PNG_FREE_ALL or simply PNG_FREE_ALL
n - sequence number of item to be freed seq - sequence number of item to be freed
(-1 for all items) (-1 for all items)
This function 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 "seq" 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 "seq" 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 in the structure
is freed, where n is "seq".
If you allocated data such as a palette that you passed If you allocated data such as a palette that you passed
in to libpng with 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
@@ -2261,26 +2301,29 @@ 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_malloc(), png_zalloc(), Memory allocation is done through the functions png_malloc()
and png_free(). These currently just call the standard C functions. If and png_free(). These currently just call the standard C functions. 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. If you prefer 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 to use a different method of allocating and freeing data, you can use
png_create_read_struct_2() or png_create_write_struct_2() to register
png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr your own functions as described above.
malloc_fn, png_free_ptr free_fn) These functions also provide a void pointer that can be retrieved via
This function also provides a void pointer that can be retrieved via
mem_ptr=png_get_mem_ptr(png_ptr); mem_ptr=png_get_mem_ptr(png_ptr);
Your replacement memory functions must have prototypes as follows: Your replacement memory functions must have prototypes as follows:
png_voidp malloc_fn(png_structp png_ptr, png_uint_32 size); png_voidp malloc_fn(png_structp png_ptr,
png_size_t size);
void free_fn(png_structp png_ptr, png_voidp ptr); void free_fn(png_structp png_ptr, png_voidp ptr);
Your malloc_fn() should return NULL in case of failure. The png_malloc()
function will call png_error() if it receives a NULL from the system
memory allocator or from your replacement malloc_fn().
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
@@ -2303,9 +2346,9 @@ png_get_io_ptr(). For example:
The replacement I/O functions must 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_size_t length);
void user_write_data(png_structp png_ptr, void user_write_data(png_structp png_ptr,
png_bytep data, png_uint_32 length); png_bytep data, png_size_t length);
void user_flush_data(png_structp png_ptr); void user_flush_data(png_structp png_ptr);
Supplying NULL for the read, write, or flush functions sets them back Supplying NULL for the read, write, or flush functions sets them back
@@ -2440,6 +2483,10 @@ compression level by calling:
Another useful one is to reduce the memory level used by the library. Another useful one is to reduce the memory level used by the library.
The memory level defaults to 8, but it can be lowered if you are The memory level defaults to 8, but it can be lowered if you are
short on memory (running DOS, for example, where you only have 640K). short on memory (running DOS, for example, where you only have 640K).
Note that the memory level does have an effect on compression; among
other things, lower levels will result in sections of incompressible
data being emitted in smaller stored blocks, with a correspondingly
larger relative overhead of up to 15% in the worst case.
png_set_compression_mem_level(png_ptr, level); png_set_compression_mem_level(png_ptr, level);
@@ -2474,38 +2521,39 @@ 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 with '|' to specify one or more filters to use. ORed together with '|' to specify one or more filters to use.
These filters are described in more detail in the PNG specification. If These filters are described in more detail in the PNG specification.
you intend to change the filter type during the course of writing If 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. (Note that this
means the first row must always be adaptively filtered, because libpng
currently does not allocate the filter buffers until png_write_row()
is called for the first time.)
filters = PNG_FILTER_NONE | PNG_FILTER_SUB filters = PNG_FILTER_NONE | PNG_FILTER_SUB
PNG_FILTER_UP | PNG_FILTER_AVE | PNG_FILTER_UP | PNG_FILTER_AVE |
PNG_FILTER_PAETH | PNG_ALL_FILTERS; 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);
The second parameter can also be PNG_INTRAPIXEL_DIFFERENCING The second parameter can also be
if you are writing a PNG to be embedded in a MNG PNG_INTRAPIXEL_DIFFERENCING if you are
datastream. This parameter must be the same as the writing a PNG to be embedded in a MNG
value of filter_method used in png_set_IHDR(). datastream. This parameter must be the
same as the value of filter_method used
in png_set_IHDR().
It is also possible to influence how libpng chooses from among the It is also possible to influence how libpng chooses from among the
available filters. This is done in two ways - by telling it how available filters. This is done in one or both of two ways - by
important it is to keep the same filter for successive rows, and telling it how important it is to keep the same filter for successive
by telling it the relative computational costs of the filters. rows, and by telling it the relative computational costs of the filters.
double weights[3] = {1.5, 1.3, 1.1}, double weights[3] = {1.5, 1.3, 1.1},
costs[PNG_FILTER_VALUE_LAST] = costs[PNG_FILTER_VALUE_LAST] =
{1.0, 1.3, 1.3, 1.5, 1.7}; {1.0, 1.3, 1.3, 1.5, 1.7};
png_set_filter_selection(png_ptr, png_set_filter_heuristics(png_ptr,
PNG_FILTER_SELECTION_WEIGHTED, 3, PNG_FILTER_HEURISTIC_WEIGHTED, 3,
weights, costs); weights, costs);
The weights are multiplying factors that indicate to libpng that the The weights are multiplying factors that indicate to libpng that the
@@ -2605,7 +2653,6 @@ 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. MNG support VI. MNG support
The MNG specification (available at http://www.libpng.org/pub/mng) allows The MNG specification (available at http://www.libpng.org/pub/mng) allows
@@ -2619,7 +2666,7 @@ png_permit_mng_features() function:
PNG_FLAG_MNG_EMPTY_PLTE PNG_FLAG_MNG_EMPTY_PLTE
PNG_FLAG_MNG_FILTER_64 PNG_FLAG_MNG_FILTER_64
PNG_ALL_MNG_FEATURES PNG_ALL_MNG_FEATURES
feature_set is a png_32_uint that is the logical AND of feature_set is a png_byte that is the logical AND of
your mask with the set of MNG features that is your mask with the set of MNG features that is
supported by the version of libpng that you are using. supported by the version of libpng that you are using.
@@ -2641,7 +2688,7 @@ of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are
still alive and well, but they have moved on to other things. 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_destroy() have been
moved to PNG_INTERNAL in version 0.95 to discourage their use. These moved to PNG_INTERNAL in version 0.95 to discourage their use. These
functions will be removed from libpng version 2.0.0. functions will be removed from libpng version 2.0.0.
@@ -2680,15 +2727,15 @@ application:
png_uint_32 application_vn = PNG_LIBPNG_VER; png_uint_32 application_vn = PNG_LIBPNG_VER;
VIII. Y2K Compliance in libpng VII. Y2K Compliance in libpng
January 31, 2001 July 8, 2002
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.9 are Y2K compliant. It is my belief that earlier upward through 1.0.14 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
@@ -2706,7 +2753,8 @@ There are seven time-related functions:
png_convert_to_rfc_1123() in png.c png_convert_to_rfc_1123() in png.c
(formerly png_convert_to_rfc_1152() in error) (formerly png_convert_to_rfc_1152() in error)
png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c png_convert_from_struct_tm() in pngwrite.c, called
in pngwrite.c
png_convert_from_time_t() in pngwrite.c png_convert_from_time_t() in pngwrite.c
png_get_tIME() in pngget.c png_get_tIME() in pngget.c
png_handle_tIME() in pngrutil.c, called in pngread.c png_handle_tIME() in pngrutil.c, called in pngread.c

View File

@@ -1,6 +1,6 @@
.TH LIBPNGPF 3 "January 31, 2001" .TH LIBPNGPF 3 "July 8, 2002"
.SH NAME .SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.0.9 libpng \- Portable Network Graphics (PNG) Reference Library 1.0.14
(private functions) (private functions)
.SH SYNOPSIS .SH SYNOPSIS
\fB#include <png.h>\fP \fB#include <png.h>\fP
@@ -47,11 +47,11 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.9
\fI\fB \fI\fB
\fBpng_voidp png_create_struct (int \fP\fItype\fP\fB, png_malloc_ptr \fImalloc_fn\fP\fB);\fP \fBpng_voidp png_create_struct (int \fItype\fP\fB);\fP
\fI\fB \fI\fB
\fBpng_voidp png_create_struct_2 (int \fItype\fP\fB);\fP \fBpng_voidp png_create_struct_2 (int \fP\fItype\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_voidp \fImem_ptr\fP\fB);\fP
\fI\fB \fI\fB
@@ -63,7 +63,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.9
\fI\fB \fI\fB
\fBvoid png_destroy_struct_2 (png_voidp \fP\fIstruct_ptr\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP \fBvoid png_destroy_struct_2 (png_voidp \fP\fIstruct_ptr\fP\fB, png_free_ptr \fP\fIfree_fn\fP\fB, png_voidp \fImem_ptr\fP\fB);\fP
\fI\fB \fI\fB
@@ -191,10 +191,6 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.9
\fI\fB \fI\fB
\fBint png_handle_as_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP
\fI\fB
\fBvoid png_handle_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP \fBvoid png_handle_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP
\fI\fB \fI\fB
@@ -425,6 +421,8 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.9
\fBvoid png_write_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP \fBvoid png_write_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP
\fI\fB
\fBvoid png_write_filtered_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIfiltered_row\fP\fB);\fP \fBvoid png_write_filtered_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIfiltered_row\fP\fB);\fP
\fI\fB \fI\fB
@@ -529,17 +527,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.9
\fI\fB \fI\fB
\fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP
\fI\fB
\fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP
\fI\fB
.SH DESCRIPTION .SH DESCRIPTION
The functions listed above are used privately by libpng The functions listed above are used privately by libpng
and are not recommended for use by applications. They and are not recommended for use by applications. They are
not "exported" to applications using shared libraries. They
are listed alphabetically here as an aid to libpng maintainers. are listed alphabetically here as an aid to libpng maintainers.
See png.h for more information on these functions. See png.h for more information on these functions.

2
png.5
View File

@@ -1,4 +1,4 @@
.TH PNG 5 "January 31, 2001" .TH PNG 5 "July 8, 2002"
.SH NAME .SH NAME
png \- Portable Network Graphics (PNG) format png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION .SH DESCRIPTION

180
png.c
View File

@@ -1,8 +1,8 @@
/* png.c - location for general purpose libpng functions /* png.c - location for general purpose libpng functions
* *
* libpng version 1.0.9 - January 31, 2001 * libpng version 1.0.14 - July 8, 2002
* Copyright (c) 1998-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2002 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
@@ -13,14 +13,14 @@
#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_9 Your_png_h_is_not_version_1_0_9; typedef version_1_0_14 Your_png_h_is_not_version_1_0_14;
/* 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 */
const char png_libpng_ver[18] = "1.0.9"; const char png_libpng_ver[18] = "1.0.14";
/* 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. */
@@ -135,13 +135,26 @@ png_check_sig(png_bytep sig, int num)
} }
/* Function to allocate memory for zlib and clear it to 0. */ /* Function to allocate memory for zlib and clear it to 0. */
#ifdef PNG_1_0_X
voidpf PNGAPI voidpf PNGAPI
#else
voidpf /* private */
#endif
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_structp p=png_ptr;
png_uint_32 save_flags=p->flags;
p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes);
p->flags=save_flags;
#ifndef PNG_NO_ZALLOC_ZERO #ifndef PNG_NO_ZALLOC_ZERO
if (ptr == NULL)
return ((voidpf)ptr);
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);
@@ -157,7 +170,11 @@ png_zalloc(voidpf png_ptr, uInt items, uInt size)
} }
/* function to free memory for zlib */ /* function to free memory for zlib */
#ifdef PNG_1_0_X
void PNGAPI void PNGAPI
#else
void /* private */
#endif
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);
@@ -212,14 +229,13 @@ png_create_info_struct(png_structp png_ptr)
png_debug(1, "in png_create_info_struct\n"); png_debug(1, "in png_create_info_struct\n");
if(png_ptr == NULL) return (NULL); if(png_ptr == NULL) return (NULL);
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
if ((info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO,
png_ptr->malloc_fn)) != NULL) png_ptr->malloc_fn, png_ptr->mem_ptr);
#else #else
if ((info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO)) != NULL) info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO);
#endif #endif
{ if (info_ptr != NULL)
png_info_init(info_ptr); png_info_init_3(&info_ptr, sizeof(png_info));
}
return (info_ptr); return (info_ptr);
} }
@@ -243,11 +259,12 @@ png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
png_info_destroy(png_ptr, info_ptr); png_info_destroy(png_ptr, info_ptr);
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn); png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn,
png_ptr->mem_ptr);
#else #else
png_destroy_struct((png_voidp)info_ptr); png_destroy_struct((png_voidp)info_ptr);
#endif #endif
*info_ptr_ptr = (png_infop)NULL; *info_ptr_ptr = NULL;
} }
} }
@@ -255,10 +272,28 @@ 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.
*/ */
#undef png_info_init
void PNGAPI void PNGAPI
png_info_init(png_infop info_ptr) png_info_init(png_infop info_ptr)
{ {
png_debug(1, "in png_info_init\n"); /* We only come here via pre-1.0.12-compiled applications */
png_info_init_3(&info_ptr, 0);
}
void PNGAPI
png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size)
{
png_infop info_ptr = *ptr_ptr;
png_debug(1, "in png_info_init_3\n");
if(sizeof(png_info) > png_info_struct_size)
{
png_destroy_struct(info_ptr);
info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO);
*ptr_ptr = info_ptr;
}
/* set everything to 0 */ /* set everything to 0 */
png_memset(info_ptr, 0, sizeof (png_info)); png_memset(info_ptr, 0, sizeof (png_info));
} }
@@ -282,7 +317,8 @@ png_data_freer(png_structp png_ptr, png_infop info_ptr,
#endif #endif
void PNGAPI 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");
if (png_ptr == NULL || info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
@@ -326,6 +362,9 @@ if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS))
{ {
png_free(png_ptr, info_ptr->trans); png_free(png_ptr, info_ptr->trans);
info_ptr->valid &= ~PNG_INFO_tRNS; info_ptr->valid &= ~PNG_INFO_tRNS;
#ifndef PNG_FREE_ME_SUPPORTED
png_ptr->flags &= ~PNG_FLAG_FREE_TRNS;
#endif
info_ptr->trans = NULL; info_ptr->trans = NULL;
} }
#endif #endif
@@ -469,6 +508,9 @@ if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST))
png_free(png_ptr, info_ptr->hist); png_free(png_ptr, info_ptr->hist);
info_ptr->hist = NULL; info_ptr->hist = NULL;
info_ptr->valid &= ~PNG_INFO_hIST; info_ptr->valid &= ~PNG_INFO_hIST;
#ifndef PNG_FREE_ME_SUPPORTED
png_ptr->flags &= ~PNG_FLAG_FREE_HIST;
#endif
} }
#endif #endif
@@ -482,6 +524,9 @@ if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE))
png_zfree(png_ptr, info_ptr->palette); png_zfree(png_ptr, info_ptr->palette);
info_ptr->palette = NULL; info_ptr->palette = NULL;
info_ptr->valid &= ~PNG_INFO_PLTE; info_ptr->valid &= ~PNG_INFO_PLTE;
#ifndef PNG_FREE_ME_SUPPORTED
png_ptr->flags &= ~PNG_FLAG_FREE_PLTE;
#endif
info_ptr->num_palette = 0; info_ptr->num_palette = 0;
} }
@@ -536,7 +581,7 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
} }
#endif #endif
png_info_init(info_ptr); png_info_init_3(&info_ptr, sizeof(png_info));
} }
/* This function returns a pointer to the io_ptr associated with the user /* This function returns a pointer to the io_ptr associated with the user
@@ -582,31 +627,31 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
} }
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
{ {
wchar_t time_buf[29]; wchar_t time_buf[29];
wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"), wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"),
ptime->day % 32, short_months[(ptime->month - 1) % 12], ptime->day % 32, short_months[(ptime->month - 1) % 12],
ptime->year, ptime->hour % 24, ptime->minute % 60, ptime->year, ptime->hour % 24, ptime->minute % 60,
ptime->second % 61); ptime->second % 61);
WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 29, WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 29,
NULL, NULL); NULL, NULL);
} }
#else #else
#ifdef USE_FAR_KEYWORD #ifdef USE_FAR_KEYWORD
{ {
char near_time_buf[29]; char near_time_buf[29];
sprintf(near_time_buf, "%d %s %d %02d:%02d:%02d +0000", sprintf(near_time_buf, "%d %s %d %02d:%02d:%02d +0000",
ptime->day % 32, short_months[(ptime->month - 1) % 12], ptime->day % 32, short_months[(ptime->month - 1) % 12],
ptime->year, ptime->hour % 24, ptime->minute % 60, ptime->year, ptime->hour % 24, ptime->minute % 60,
ptime->second % 61); ptime->second % 61);
png_memcpy(png_ptr->time_buffer, near_time_buf, png_memcpy(png_ptr->time_buffer, near_time_buf,
29*sizeof(char)); 29*sizeof(char));
} }
#else #else
sprintf(png_ptr->time_buffer, "%d %s %d %02d:%02d:%02d +0000", sprintf(png_ptr->time_buffer, "%d %s %d %02d:%02d:%02d +0000",
ptime->day % 32, short_months[(ptime->month - 1) % 12], ptime->day % 32, short_months[(ptime->month - 1) % 12],
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 */ #endif /* _WIN32_WCE */
return ((png_charp)png_ptr->time_buffer); return ((png_charp)png_ptr->time_buffer);
@@ -626,10 +671,10 @@ 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 ((png_charp) "\n libpng version 1.0.9 - January 31, 2001\n\ return ((png_charp) "\n libpng version 1.0.14 - July 8, 2002\n\
Copyright (c) 1998-2001 Glenn Randers-Pehrson\n\ Copyright (c) 1998-2002 Glenn Randers-Pehrson\n\
Copyright (c) 1996, 1997 Andreas Dilger\n\ Copyright (c) 1996-1997 Andreas Dilger\n\
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n"); Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n");
return ((png_charp) ""); return ((png_charp) "");
} }
@@ -644,8 +689,8 @@ 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((png_charp) "1.0.9"); return((png_charp) "1.0.14");
return((png_charp) "1.0.9"); return((png_charp) "1.0.14");
} }
png_charp PNGAPI png_charp PNGAPI
@@ -695,17 +740,66 @@ png_uint_32 PNGAPI
png_access_version_number(void) png_access_version_number(void)
{ {
/* Version of *.c files used when building libpng */ /* Version of *.c files used when building libpng */
return((png_uint_32) 10009L); return((png_uint_32) 10014L);
} }
#if 0 /* delay this until version 1.2.0 */ #if !defined(PNG_1_0_X)
/* this function was added to libpng 1.0.9 (porting aid to libpng-1.2.0) */ #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
#ifndef PNG_ASSEMBLER_CODE_SUPPORTED /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
/* this INTERNAL function was added to libpng 1.2.0 */
void /* PRIVATE */
png_init_mmx_flags (png_structp png_ptr)
{
png_ptr->mmx_rowbytes_threshold = 0;
png_ptr->mmx_bitdepth_threshold = 0;
# if (defined(PNG_USE_PNGVCRD) || defined(PNG_USE_PNGGCCRD))
png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_COMPILED;
if (png_mmx_support()) {
png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU
# ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
| PNG_ASM_FLAG_MMX_READ_COMBINE_ROW
# endif
# ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE
| PNG_ASM_FLAG_MMX_READ_INTERLACE
# endif
# ifndef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
;
# else
| PNG_ASM_FLAG_MMX_READ_FILTER_SUB
| PNG_ASM_FLAG_MMX_READ_FILTER_UP
| PNG_ASM_FLAG_MMX_READ_FILTER_AVG
| PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
png_ptr->mmx_rowbytes_threshold = PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT;
png_ptr->mmx_bitdepth_threshold = PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT;
# endif
} else {
png_ptr->asm_flags &= ~( PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU
| PNG_MMX_READ_FLAGS
| PNG_MMX_WRITE_FLAGS );
}
# else /* !((PNGVCRD || PNGGCCRD) && PNG_ASSEMBLER_CODE_SUPPORTED)) */
/* clear all MMX flags; no support is compiled in */
png_ptr->asm_flags &= ~( PNG_MMX_FLAGS );
# endif /* ?(PNGVCRD || PNGGCCRD) */
}
#endif /* !(PNG_ASSEMBLER_CODE_SUPPORTED) */
/* this function was added to libpng 1.2.0 */
#if !defined(PNG_USE_PNGGCCRD) && \
!(defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD))
int PNGAPI int PNGAPI
png_mmx_support(void) png_mmx_support(void)
{ {
return -1; return -1;
} }
#endif #endif
#endif /* 0 */ #endif /* PNG_1_0_X */

424
png.h
View File

@@ -1,15 +1,14 @@
/* png.h - header file for PNG reference library /* png.h - header file for PNG reference library
* *
* libpng version 1.0.9 - January 31, 2001 * libpng version 1.0.14 - July 8, 2002
* Copyright (c) 1998-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2002 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (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.9 - January 31, 2001: Glenn * libpng versions 0.97, January 1998, through 1.0.14 - July 8, 2002: Glenn
* See also "Contributing Authors", below. * See also "Contributing Authors", below.
* *
* Note about libpng version numbers: * Note about libpng version numbers:
@@ -64,6 +63,36 @@
* 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10
* 1.0.9rc2 1 10009 2.1.0.9rc2 * 1.0.9rc2 1 10009 2.1.0.9rc2
* 1.0.9 1 10009 2.1.0.9 * 1.0.9 1 10009 2.1.0.9
* 1.0.10beta1 1 10010 2.1.0.10beta1
* 1.0.10rc1 1 10010 2.1.0.10rc1
* 1.0.10 1 10010 2.1.0.10
* 1.0.11beta1-3 1 10011 2.1.0.11beta1-3
* 1.0.11rc1 1 10011 2.1.0.11rc1
* 1.0.11 1 10011 2.1.0.11
* 1.0.12beta1-2 2 10012 2.1.0.12beta1-2
* 1.0.12rc1 2 10012 2.1.0.12rc1
* 1.0.12 2 10012 2.1.0.12
* 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned)
* 1.2.0beta1-2 2 10200 2.1.2.0beta1-2
* 1.2.0beta3-5 3 10200 3.1.2.0beta3-5
* 1.2.0rc1 3 10200 3.1.2.0rc1
* 1.2.0 3 10200 3.1.2.0
* 1.2.1beta1-4 3 10201 3.1.2.1beta1-4
* 1.2.1rc1-2 3 10201 3.1.2.1rc1-2
* 1.2.1 3 10201 3.1.2.1
* 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6
* 1.0.13beta1 10 10013 10.so.0.1.0.13beta1
* 1.0.13rc1 10 10013 10.so.0.1.0.13rc1
* 1.2.2rc1 12 10202 12.so.0.1.2.2rc1
* 1.0.13 10 10013 10.so.0.1.0.13
* 1.2.2 12 10202 12.so.0.1.2.2
* 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6
* 1.2.3 12 10203 12.so.0.1.2.3
* 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3
* 1.0.14rc1 13 10014 10.so.0.1.0.14rc1
* 1.2.4rc1 13 10204 12.so.0.1.2.4rc1
* 1.0.14 10 10014 10.so.0.1.0.14
* 1.2.4 13 10204 12.so.0.1.2.4
* *
* Henceforth the source version will match the shared-library major * Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be * and minor numbers; the shared-library major version number will be
@@ -93,8 +122,8 @@
* If you modify libpng you may insert additional notices immediately following * If you modify libpng you may insert additional notices immediately following
* this sentence. * this sentence.
* *
* libpng versions 1.0.7, July 1, 2000, through 1.0.9, January 31, 2001, are * libpng versions 1.0.7, July 1, 2000, through 1.0.14, July 8, 2002, are
* Copyright (c) 2000, 2001 Glenn Randers-Pehrson, and are * Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
* distributed according to the same disclaimer and license as libpng-1.0.6 * distributed according to the same disclaimer and license as libpng-1.0.6
* with the following individuals added to the list of Contributing Authors * with the following individuals added to the list of Contributing Authors
* *
@@ -158,11 +187,11 @@
* *
* 1. The origin of this source code must not be misrepresented. * 1. The origin of this source code must not be misrepresented.
* *
* 2. Altered versions must be plainly marked as such and must not * 2. Altered versions must be plainly marked as such and
* be misrepresented as being the original source. * must not be misrepresented as being the original source.
* *
* 3. This Copyright notice may not be removed or altered from any * 3. This Copyright notice may not be removed or altered from
* source or altered source distribution. * any source or altered source 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
@@ -198,13 +227,13 @@
* Y2K compliance in libpng: * Y2K compliance in libpng:
* ========================= * =========================
* *
* January 31, 2001 * July 8, 2002
* *
* 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.9 are Y2K compliant. It is my belief that earlier * upward through 1.0.14 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
@@ -260,15 +289,15 @@
*/ */
/* Version information for png.h - this should match the version in png.c */ /* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.0.9" #define PNG_LIBPNG_VER_STRING "1.0.14"
#define PNG_LIBPNG_VER_SONUM 2 #define PNG_LIBPNG_VER_SONUM 0
#define PNG_LIBPNG_VER_DLLNUM %DLLNUM% #define PNG_LIBPNG_VER_DLLNUM %DLLNUM%
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 0 #define PNG_LIBPNG_VER_MINOR 0
#define PNG_LIBPNG_VER_RELEASE 9 #define PNG_LIBPNG_VER_RELEASE 14
/* This should match the numeric part of the final component of /* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero: */ * PNG_LIBPNG_VER_STRING, omitting any leading zero: */
@@ -287,7 +316,7 @@
* Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only * 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.0 was mis-numbered 100 instead of 10000). From
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */
#define PNG_LIBPNG_VER 10009 /* 1.0.9 */ #define PNG_LIBPNG_VER 10014 /* 1.0.14 */
#ifndef PNG_VERSION_INFO_ONLY #ifndef PNG_VERSION_INFO_ONLY
@@ -308,6 +337,40 @@ extern "C" {
* which applications aren't expected to use directly. * which applications aren't expected to use directly.
*/ */
#ifndef PNG_NO_TYPECAST_NULL
#define int_p_NULL (int *)NULL
#define png_bytep_NULL (png_bytep)NULL
#define png_bytepp_NULL (png_bytepp)NULL
#define png_doublep_NULL (png_doublep)NULL
#define png_error_ptr_NULL (png_error_ptr)NULL
#define png_flush_ptr_NULL (png_flush_ptr)NULL
#define png_free_ptr_NULL (png_free_ptr)NULL
#define png_infopp_NULL (png_infopp)NULL
#define png_malloc_ptr_NULL (png_malloc_ptr)NULL
#define png_read_status_ptr_NULL (png_read_status_ptr)NULL
#define png_rw_ptr_NULL (png_rw_ptr)NULL
#define png_structp_NULL (png_structp)NULL
#define png_uint_16p_NULL (png_uint_16p)NULL
#define png_voidp_NULL (png_voidp)NULL
#define png_write_status_ptr_NULL (png_write_status_ptr)NULL
#else
#define int_p_NULL NULL
#define png_bytep_NULL NULL
#define png_bytepp_NULL NULL
#define png_doublep_NULL NULL
#define png_error_ptr_NULL NULL
#define png_flush_ptr_NULL NULL
#define png_free_ptr_NULL NULL
#define png_infopp_NULL NULL
#define png_malloc_ptr_NULL NULL
#define png_read_status_ptr_NULL NULL
#define png_rw_ptr_NULL NULL
#define png_structp_NULL NULL
#define png_uint_16p_NULL NULL
#define png_voidp_NULL NULL
#define png_write_status_ptr_NULL NULL
#endif
/* 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
@@ -315,7 +378,7 @@ extern "C" {
*/ */
#ifdef PNG_USE_GLOBAL_ARRAYS #ifdef PNG_USE_GLOBAL_ARRAYS
PNG_EXPORT_VAR (const char) png_libpng_ver[18]; PNG_EXPORT_VAR (const char) png_libpng_ver[18];
/* need room for 99.99.99beta99z*/ /* 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
@@ -541,7 +604,7 @@ typedef struct png_info_struct
png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
/* The following is informational only on read, and not used on writes. */ /* The following is informational only on read, and not used on writes. */
png_byte channels; /* number of data channels per pixel (1, 2, 3, 4)*/ png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */
png_byte pixel_depth; /* number of bits per pixel */ png_byte pixel_depth; /* number of bits per pixel */
png_byte spare_byte; /* to align the data, and for future use */ png_byte spare_byte; /* to align the data, and for future use */
png_byte signature[8]; /* magic bytes read by libpng from start of file */ png_byte signature[8]; /* magic bytes read by libpng from start of file */
@@ -693,6 +756,7 @@ 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
/* New members added in libpng-1.0.6 */
#ifdef PNG_FREE_ME_SUPPORTED #ifdef PNG_FREE_ME_SUPPORTED
png_uint_32 free_me; /* flags items libpng is responsible for freeing */ png_uint_32 free_me; /* flags items libpng is responsible for freeing */
#endif #endif
@@ -830,7 +894,7 @@ typedef png_info FAR * FAR * png_infopp;
#define PNG_KEYWORD_MAX_LENGTH 79 #define PNG_KEYWORD_MAX_LENGTH 79
/* Maximum number of entries in PLTE/sPLT/tRNS arrays */ /* Maximum number of entries in PLTE/sPLT/tRNS arrays */
#define PNG_MAX_PALETTE_LENGTH 256 #define PNG_MAX_PALETTE_LENGTH 256
/* These determine if an ancillary chunk's data has been successfully read /* These determine if an ancillary chunk's data has been successfully read
* from the PNG header, or if the application has filled in the corresponding * from the PNG header, or if the application has filled in the corresponding
@@ -902,10 +966,10 @@ 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_USER_CHUNKS_SUPPORTED)
typedef int (PNGAPI *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_UNKNOWN_CHUNKS_SUPPORTED)
typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp));
#endif #endif
@@ -949,7 +1013,7 @@ struct png_struct_def
png_voidp error_ptr; /* user supplied struct for error functions */ png_voidp error_ptr; /* user supplied struct for error functions */
png_rw_ptr write_data_fn; /* function for writing output data */ png_rw_ptr write_data_fn; /* function for writing output data */
png_rw_ptr read_data_fn; /* function for reading input data */ png_rw_ptr read_data_fn; /* function for reading input data */
png_voidp io_ptr; /* ptr to application struct for I/O functions*/ png_voidp io_ptr; /* ptr to application struct for I/O functions */
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
png_user_transform_ptr read_user_transform_fn; /* user read transform */ png_user_transform_ptr read_user_transform_fn; /* user read transform */
@@ -1025,16 +1089,16 @@ struct png_struct_def
#endif #endif
#endif #endif
#if defined(PNG_READ_bKGD_SUPPORTED) #if defined(PNG_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 */
# endif /* PNG_READ_GAMMA && PNG_READ_bKGD_SUPPORTED */ #endif
#endif /* PNG_READ_bKGD_SUPPORTED */ #endif /* PNG_bKGD_SUPPORTED */
#if defined(PNG_WRITE_FLUSH_SUPPORTED) #if defined(PNG_WRITE_FLUSH_SUPPORTED)
png_flush_ptr output_flush_fn;/* Function for flushing output */ png_flush_ptr output_flush_fn;/* Function for flushing output */
@@ -1059,7 +1123,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_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
@@ -1067,7 +1131,7 @@ struct png_struct_def
png_color_8 shift; /* shift for significant bit tranformation */ png_color_8 shift; /* shift for significant bit tranformation */
#endif #endif
#if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ #if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
|| defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
png_bytep trans; /* transparency values for paletted files */ png_bytep trans; /* transparency values for paletted files */
png_color_16 trans_values; /* transparency values for non-paletted files */ png_color_16 trans_values; /* transparency values for non-paletted files */
@@ -1092,12 +1156,12 @@ struct png_struct_def
int process_mode; /* what push library is currently doing */ int process_mode; /* what push library is currently doing */
int cur_palette; /* current push library palette index */ int cur_palette; /* current push library palette index */
# if defined(PNG_READ_TEXT_SUPPORTED) # if defined(PNG_TEXT_SUPPORTED)
png_size_t current_text_size; /* current size of text input data */ png_size_t current_text_size; /* current size of text input data */
png_size_t current_text_left; /* how much text left to read in input */ png_size_t current_text_left; /* how much text left to read in input */
png_charp current_text; /* current text chunk buffer */ png_charp current_text; /* current text chunk buffer */
png_charp current_text_ptr; /* current location in current_text */ png_charp current_text_ptr; /* current location in current_text */
# endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_READ_TEXT_SUPPORTED */ # endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
@@ -1115,7 +1179,7 @@ struct png_struct_def
png_bytep dither_index; /* index translation for palette files */ png_bytep dither_index; /* index translation for palette files */
#endif #endif
#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_READ_hIST_SUPPORTED) #if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED)
png_uint_16p hist; /* histogram */ png_uint_16p hist; /* histogram */
#endif #endif
@@ -1133,19 +1197,13 @@ struct png_struct_def
png_charp time_buffer; /* String to hold RFC 1123 time text */ png_charp time_buffer; /* String to hold RFC 1123 time text */
#endif #endif
#ifdef PNG_USER_MEM_SUPPORTED
png_voidp mem_ptr; /* user supplied struct for mem functions */
png_malloc_ptr malloc_fn; /* function for allocating memory */
png_free_ptr free_fn; /* function for freeing memory */
#endif
/* New members added in libpng-1.0.6 */ /* New members added in libpng-1.0.6 */
#ifdef PNG_FREE_ME_SUPPORTED #ifdef PNG_FREE_ME_SUPPORTED
png_uint_32 free_me; /* flags items libpng is responsible for freeing */ png_uint_32 free_me; /* flags items libpng is responsible for freeing */
#endif #endif
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) #if defined(PNG_USER_CHUNKS_SUPPORTED)
png_voidp user_chunk_ptr; png_voidp user_chunk_ptr;
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
#endif #endif
@@ -1155,33 +1213,75 @@ struct png_struct_def
png_bytep chunk_list; png_bytep chunk_list;
#endif #endif
/* New members added in libpng-1.0.3 */
#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;
/* These were changed from png_byte in libpng-1.0.6 */
png_uint_16 rgb_to_gray_red_coeff; png_uint_16 rgb_to_gray_red_coeff;
png_uint_16 rgb_to_gray_green_coeff; png_uint_16 rgb_to_gray_green_coeff;
png_uint_16 rgb_to_gray_blue_coeff; png_uint_16 rgb_to_gray_blue_coeff;
#endif #endif
/* New member added in libpng-1.0.4 (renamed in 1.0.9) */
#if defined(PNG_MNG_FEATURES_SUPPORTED) || \ #if defined(PNG_MNG_FEATURES_SUPPORTED) || \
defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
/* Note to maintainer: change this to png_uint_32 at next opportunity */ /* changed from png_byte to png_uint_32 at version 1.2.0 */
#ifdef PNG_1_0_X
png_byte mng_features_permitted; png_byte mng_features_permitted;
#else
png_uint_32 mng_features_permitted;
#endif /* PNG_1_0_X */
#endif #endif
/* New member added in libpng-1.0.7 */
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
png_fixed_point int_gamma; png_fixed_point int_gamma;
#endif #endif
/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */
#if defined(PNG_MNG_FEATURES_SUPPORTED)
png_byte filter_type; png_byte filter_type;
#endif
#if defined(PNG_1_0_X) || (defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD))
/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */
png_uint_32 row_buf_size;
#endif
/* New members added in libpng-1.2.0 */
#if !defined(PNG_1_0_X) && defined(PNG_ASSEMBLER_CODE_SUPPORTED)
png_byte mmx_bitdepth_threshold;
png_uint_32 mmx_rowbytes_threshold;
png_uint_32 asm_flags;
#endif
/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
#ifdef PNG_USER_MEM_SUPPORTED
png_voidp mem_ptr; /* user supplied struct for mem functions */
png_malloc_ptr malloc_fn; /* function for allocating memory */
png_free_ptr free_fn; /* function for freeing memory */
#endif
/* New member added in libpng-1.0.13 and 1.2.0 */
png_bytep big_row_buf; /* buffer to save current (unfiltered) row */
#if defined(PNG_READ_DITHER_SUPPORTED)
/* The following three members were added at version 1.0.14 and 1.2.4 */
png_bytep dither_sort; /* working sort array */
png_bytep index_to_palette; /* where the original index currently is */
/* in the palette */
png_bytep palette_to_index; /* which original index points to this */
/* palette color */
#endif
}; };
/* This prevents a compiler error in png_get_copyright() in png.c if png.c /* This prevents a compiler error in png.c if png.c and png.h are both at
and png.h are both at * version 1.0.9 version 1.0.14
*/ */
typedef png_structp version_1_0_9; typedef png_structp version_1_0_14;
typedef png_struct FAR * FAR * png_structpp; typedef png_struct FAR * FAR * png_structpp;
@@ -1232,6 +1332,7 @@ extern PNG_EXPORT(void,png_set_compression_buffer_size)
/* Reset the compression stream */ /* Reset the compression stream */
extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr));
/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */
#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,
@@ -1262,8 +1363,12 @@ extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(png_infop,png_create_info_struct) extern PNG_EXPORT(png_infop,png_create_info_struct)
PNGARG((png_structp png_ptr)); PNGARG((png_structp png_ptr));
/* Initialize the info structure (old interface - NOT DLL EXPORTED) */ /* Initialize the info structure (old interface - DEPRECATED) */
extern void png_info_init PNGARG((png_infop info_ptr)); extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr));
#undef png_info_init
#define png_info_init(info_ptr) png_info_init_3(&info_ptr, sizeof(png_info));
extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr,
png_size_t png_info_struct_size));
/* Writes all the PNG information before the image. */ /* Writes all the PNG information before the image. */
extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr,
@@ -1436,11 +1541,11 @@ extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr));
extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr,
png_infop info_ptr)); png_infop info_ptr));
/* read a one or more rows of image data.*/ /* read one or more rows of image data. */
extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr,
png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); png_bytepp row, png_bytepp display_row, png_uint_32 num_rows));
/* read a row of data.*/ /* read a row of data. */
extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr,
png_bytep row, png_bytep row,
png_bytep display_row)); png_bytep display_row));
@@ -1485,9 +1590,6 @@ extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
extern PNG_EXPORT(void,png_destroy_write_struct) extern PNG_EXPORT(void,png_destroy_write_struct)
PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr));
/* free any memory used in info_ptr struct (old method - NOT DLL EXPORTED) */
extern void png_write_destroy_info PNGARG((png_infop info_ptr));
/* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */ /* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
extern void png_write_destroy PNGARG((png_structp png_ptr)); extern void png_write_destroy PNGARG((png_structp png_ptr));
@@ -1695,7 +1797,7 @@ extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr)
PNGARG((png_structp png_ptr)); PNGARG((png_structp png_ptr));
#endif #endif
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED #ifdef PNG_USER_CHUNKS_SUPPORTED
extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr,
png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));
extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp
@@ -1729,9 +1831,26 @@ extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr,
extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr,
png_uint_32 size)); png_uint_32 size));
#if defined(PNG_1_0_X)
# define png_malloc_warn png_malloc
#else
/* Added at libpng version 1.2.4 */
extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr,
png_uint_32 size));
#endif
/* frees a pointer allocated by png_malloc() */ /* frees a pointer allocated by png_malloc() */
extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr));
#if defined(PNG_1_0_X)
/* Function to allocate memory for zlib. */
extern PNG_EXPORT(voidpf,png_zalloc) PNGARG((voidpf png_ptr, uInt items,
uInt size));
/* Function to free memory for zlib */
extern PNG_EXPORT(void,png_zfree) PNGARG((voidpf png_ptr, voidpf ptr));
#endif
/* 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));
@@ -1780,19 +1899,19 @@ extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
/* Fatal error in PNG image of libpng - can't continue */ /* Fatal error in PNG image of libpng - can't continue */
extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr,
png_const_charp error)); png_const_charp error_message));
/* The same, but the chunk name is prepended to the error string. */ /* The same, but the chunk name is prepended to the error string. */
extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr,
png_const_charp error)); png_const_charp error_message));
/* Non-fatal error in libpng. Can continue, but may have a problem. */ /* Non-fatal error in libpng. Can continue, but may have a problem. */
extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr,
png_const_charp message)); png_const_charp warning_message));
/* Non-fatal error in libpng, chunk name is prepended to message. */ /* Non-fatal error in libpng, chunk name is prepended to message. */
extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr,
png_const_charp message)); png_const_charp warning_message));
/* The png_set_<chunk> functions are for storing values in the png_info_struct. /* The png_set_<chunk> functions are for storing values in the png_info_struct.
* Similarly, the png_get_<chunk> calls are used to read values from the * Similarly, the png_get_<chunk> calls are used to read values from the
@@ -1888,7 +2007,7 @@ png_ptr, png_infop info_ptr));
extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr,
png_infop info_ptr)); png_infop info_ptr));
#if defined(PNG_READ_bKGD_SUPPORTED) #if defined(PNG_bKGD_SUPPORTED)
extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_color_16p *background)); png_infop info_ptr, png_color_16p *background));
#endif #endif
@@ -1898,7 +2017,7 @@ extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_color_16p background)); png_infop info_ptr, png_color_16p background));
#endif #endif
#if defined(PNG_READ_cHRM_SUPPORTED) #if defined(PNG_cHRM_SUPPORTED)
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr,
png_infop info_ptr, double *white_x, double *white_y, double *red_x, png_infop info_ptr, double *white_x, double *white_y, double *red_x,
@@ -1929,7 +2048,7 @@ extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr,
#endif #endif
#endif #endif
#if defined(PNG_READ_gAMA_SUPPORTED) #if defined(PNG_gAMA_SUPPORTED)
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr,
png_infop info_ptr, double *file_gamma)); png_infop info_ptr, double *file_gamma));
@@ -1947,7 +2066,7 @@ extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_fixed_point int_file_gamma)); png_infop info_ptr, png_fixed_point int_file_gamma));
#endif #endif
#if defined(PNG_READ_hIST_SUPPORTED) #if defined(PNG_hIST_SUPPORTED)
extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_16p *hist)); png_infop info_ptr, png_uint_16p *hist));
#endif #endif
@@ -1967,7 +2086,7 @@ extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr,
int color_type, int interlace_method, int compression_method, int color_type, int interlace_method, int compression_method,
int filter_method)); int filter_method));
#if defined(PNG_READ_oFFs_SUPPORTED) #if defined(PNG_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,
png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y,
int *unit_type)); int *unit_type));
@@ -1979,7 +2098,7 @@ extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr,
int unit_type)); int unit_type));
#endif #endif
#if defined(PNG_READ_pCAL_SUPPORTED) #if defined(PNG_pCAL_SUPPORTED)
extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1,
int *type, int *nparams, png_charp *units, png_charpp *params)); int *type, int *nparams, png_charp *units, png_charpp *params));
@@ -1991,7 +2110,7 @@ extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr,
int type, int nparams, png_charp units, png_charpp params)); int type, int nparams, png_charp units, png_charpp params));
#endif #endif
#if defined(PNG_READ_pHYs_SUPPORTED) #if defined(PNG_pHYs_SUPPORTED)
extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
#endif #endif
@@ -2007,7 +2126,7 @@ extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr,
extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_colorp palette, int num_palette)); png_infop info_ptr, png_colorp palette, int num_palette));
#if defined(PNG_READ_sBIT_SUPPORTED) #if defined(PNG_sBIT_SUPPORTED)
extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_color_8p *sig_bit)); png_infop info_ptr, png_color_8p *sig_bit));
#endif #endif
@@ -2017,7 +2136,7 @@ extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_color_8p sig_bit)); png_infop info_ptr, png_color_8p sig_bit));
#endif #endif
#if defined(PNG_READ_sRGB_SUPPORTED) #if defined(PNG_sRGB_SUPPORTED)
extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr,
png_infop info_ptr, int *intent)); png_infop info_ptr, int *intent));
#endif #endif
@@ -2029,7 +2148,7 @@ extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr,
png_infop info_ptr, int intent)); png_infop info_ptr, int intent));
#endif #endif
#if defined(PNG_READ_iCCP_SUPPORTED) #if defined(PNG_iCCP_SUPPORTED)
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));
@@ -2043,7 +2162,7 @@ extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr,
/* Note to maintainer: profile should be png_bytep */ /* Note to maintainer: profile should be png_bytep */
#endif #endif
#if defined(PNG_READ_sPLT_SUPPORTED) #if defined(PNG_sPLT_SUPPORTED)
extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_sPLT_tpp entries)); png_infop info_ptr, png_sPLT_tpp entries));
#endif #endif
@@ -2053,7 +2172,7 @@ extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_sPLT_tp entries, int nentries)); png_infop info_ptr, png_sPLT_tp entries, int nentries));
#endif #endif
#if defined(PNG_READ_TEXT_SUPPORTED) #if defined(PNG_TEXT_SUPPORTED)
/* png_get_text also returns the number of text chunks in *num_text */ /* png_get_text also returns the number of text chunks in *num_text */
extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_textp *text_ptr, int *num_text)); png_infop info_ptr, png_textp *text_ptr, int *num_text));
@@ -2072,7 +2191,7 @@ extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_textp text_ptr, int num_text)); png_infop info_ptr, png_textp text_ptr, int num_text));
#endif #endif
#if defined(PNG_READ_tIME_SUPPORTED) #if defined(PNG_tIME_SUPPORTED)
extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_timep *mod_time)); png_infop info_ptr, png_timep *mod_time));
#endif #endif
@@ -2082,7 +2201,7 @@ extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_timep mod_time)); png_infop info_ptr, png_timep mod_time));
#endif #endif
#if defined(PNG_READ_tRNS_SUPPORTED) #if defined(PNG_tRNS_SUPPORTED)
extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_bytep *trans, int *num_trans, png_infop info_ptr, png_bytep *trans, int *num_trans,
png_color_16p *trans_values)); png_color_16p *trans_values));
@@ -2097,7 +2216,7 @@ extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
#if defined(PNG_tRNS_SUPPORTED) #if defined(PNG_tRNS_SUPPORTED)
#endif #endif
#if defined(PNG_READ_sCAL_SUPPORTED) #if defined(PNG_sCAL_SUPPORTED)
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr, extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr,
png_infop info_ptr, int *unit, double *width, double *height)); png_infop info_ptr, int *unit, double *width, double *height));
@@ -2107,7 +2226,7 @@ extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr,
png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight));
#endif #endif
#endif #endif
#endif /* PNG_READ_sCAL_SUPPORTED */ #endif /* PNG_sCAL_SUPPORTED */
#if defined(PNG_sCAL_SUPPORTED) #if defined(PNG_sCAL_SUPPORTED)
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
@@ -2118,7 +2237,7 @@ extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr,
extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr, extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr,
png_infop info_ptr, int unit, png_charp swidth, png_charp sheight)); png_infop info_ptr, int unit, png_charp swidth, png_charp sheight));
#endif #endif
#endif /* PNG_READ_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */ #endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
/* provide a list of chunks and how they are to be handled, if the built-in /* provide a list of chunks and how they are to be handled, if the built-in
@@ -2139,6 +2258,10 @@ extern PNG_EXPORT(void, png_set_unknown_chunk_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
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep
chunk_name));
#endif
/* Png_free_data() will turn off the "valid" flag for anything it frees. /* 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, If you need to turn it off for a chunk that your application has freed,
@@ -2221,15 +2344,84 @@ extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp
png_ptr, png_uint_32 mng_features_permitted)); png_ptr, png_uint_32 mng_features_permitted));
#endif #endif
#if 0 /* delay these until version 1.2.0 */ /* Added to version 1.2.0 */
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
#define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED 0x01 /* not user-settable */
#define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU 0x02 /* not user-settable */
#define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW 0x04
#define PNG_ASM_FLAG_MMX_READ_INTERLACE 0x08
#define PNG_ASM_FLAG_MMX_READ_FILTER_SUB 0x10
#define PNG_ASM_FLAG_MMX_READ_FILTER_UP 0x20
#define PNG_ASM_FLAG_MMX_READ_FILTER_AVG 0x40
#define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80
#define PNG_ASM_FLAGS_INITIALIZED 0x80000000 /* not user-settable */
#define PNG_MMX_READ_FLAGS ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \
| PNG_ASM_FLAG_MMX_READ_INTERLACE \
| PNG_ASM_FLAG_MMX_READ_FILTER_SUB \
| PNG_ASM_FLAG_MMX_READ_FILTER_UP \
| PNG_ASM_FLAG_MMX_READ_FILTER_AVG \
| PNG_ASM_FLAG_MMX_READ_FILTER_PAETH )
#define PNG_MMX_WRITE_FLAGS ( 0 )
#define PNG_MMX_FLAGS ( PNG_ASM_FLAG_MMX_SUPPORT_COMPILED \
| PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU \
| PNG_MMX_READ_FLAGS \
| PNG_MMX_WRITE_FLAGS )
#define PNG_SELECT_READ 1
#define PNG_SELECT_WRITE 2
#if !defined(PNG_1_0_X)
/* pngget.c */
extern PNG_EXPORT(png_uint_32,png_get_mmx_flagmask)
PNGARG((int flag_select, int *compilerID));
/* pngget.c */
extern PNG_EXPORT(png_uint_32,png_get_asm_flagmask)
PNGARG((int flag_select));
/* pngget.c */
extern PNG_EXPORT(png_uint_32,png_get_asm_flags)
PNGARG((png_structp png_ptr));
/* pngget.c */
extern PNG_EXPORT(png_byte,png_get_mmx_bitdepth_threshold)
PNGARG((png_structp png_ptr));
/* pngget.c */
extern PNG_EXPORT(png_uint_32,png_get_mmx_rowbytes_threshold)
PNGARG((png_structp png_ptr));
/* pngset.c */
extern PNG_EXPORT(void,png_set_asm_flags)
PNGARG((png_structp png_ptr, png_uint_32 asm_flags));
/* pngset.c */
extern PNG_EXPORT(void,png_set_mmx_thresholds)
PNGARG((png_structp png_ptr, png_byte mmx_bitdepth_threshold,
png_uint_32 mmx_rowbytes_threshold));
#endif /* PNG_1_0_X */
#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
#if !defined(PNG_1_0_X)
/* png.c, pnggccrd.c, or pngvcrd.c */ /* png.c, pnggccrd.c, or pngvcrd.c */
extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); extern PNG_EXPORT(int,png_mmx_support) PNGARG((void));
/* Strip the prepended error numbers ("#nnn ") from error and warning
* messages before passing them to the error or warning handler. */
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp
png_ptr, png_uint_32 strip_mode));
#endif #endif
#endif /* PNG_1_0_X */
/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ /* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */
#define PNG_HEADER_VERSION_STRING \ #define PNG_HEADER_VERSION_STRING \
" libpng version 1.0.9 - January 31, 2001 (header)\n" " libpng version 1.0.14 - July 8, 2002 (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
@@ -2352,6 +2544,9 @@ extern PNG_EXPORT(int,png_mmx_support) PNGARG((void));
#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L
#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L
#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L #define PNG_FLAG_LIBRARY_MISMATCH 0x20000L
#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L
#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L
#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L
/* 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
@@ -2443,13 +2638,13 @@ PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5];
* values, which is almost certainly true. * values, which is almost certainly true.
*/ */
#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED) #if defined(PNG_READ_BIG_ENDIAN_SUPPORTED)
# if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_READ_oFFs_SUPPORTED) # if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED)
# define png_get_int_32(buf) ( *((png_int_32p) (buf))) # define png_get_int_32(buf) ( *((png_int_32p) (buf)))
# endif # endif
# define png_get_uint_32(buf) ( *((png_uint_32p) (buf))) # define png_get_uint_32(buf) ( *((png_uint_32p) (buf)))
# define png_get_uint_16(buf) ( *((png_uint_16p) (buf))) # define png_get_uint_16(buf) ( *((png_uint_16p) (buf)))
#else #else
# if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_READ_oFFs_SUPPORTED) # if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED)
PNG_EXTERN png_int_32 png_get_int_32 PNGARG((png_bytep buf)); PNG_EXTERN png_int_32 png_get_int_32 PNGARG((png_bytep buf));
# endif # endif
PNG_EXTERN png_uint_32 png_get_uint_32 PNGARG((png_bytep buf)); PNG_EXTERN png_uint_32 png_get_uint_32 PNGARG((png_bytep buf));
@@ -2460,8 +2655,11 @@ PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf));
* (old interface - DEPRECATED - use png_create_read_struct instead). * (old interface - DEPRECATED - use png_create_read_struct instead).
*/ */
extern PNG_EXPORT(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, \ #undef png_read_init
PNG_LIBPNG_VER_STRING, sizeof(png_struct), sizeof(png_info)); #define png_read_init(png_ptr) png_read_init_3(&png_ptr, \
PNG_LIBPNG_VER_STRING, sizeof(png_struct));
extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr,
png_const_charp user_png_ver, png_size_t png_struct_size));
extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr, 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_const_charp user_png_ver, png_size_t png_struct_size, png_size_t
png_info_size)); png_info_size));
@@ -2470,8 +2668,11 @@ extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr,
* (old interface - DEPRECATED - use png_create_write_struct instead). * (old interface - DEPRECATED - use png_create_write_struct instead).
*/ */
extern PNG_EXPORT(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, \ #undef png_write_init
PNG_LIBPNG_VER_STRING, sizeof(png_struct), sizeof(png_info)); #define png_write_init(png_ptr) png_write_init_3(&png_ptr, \
PNG_LIBPNG_VER_STRING, sizeof(png_struct));
extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr,
png_const_charp user_png_ver, png_size_t png_struct_size));
extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr, 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_const_charp user_png_ver, png_size_t png_struct_size, png_size_t
png_info_size)); png_info_size));
@@ -2483,20 +2684,47 @@ PNG_EXTERN png_voidp png_create_struct PNGARG((int type));
PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)); PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr));
PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr
malloc_fn)); malloc_fn, png_voidp mem_ptr));
PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr, PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr,
png_free_ptr free_fn)); png_free_ptr free_fn, png_voidp mem_ptr));
/* Free any memory that info_ptr points to and reset struct. */ /* Free any memory that info_ptr points to and reset struct. */
PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr, PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr,
png_infop info_ptr)); png_infop info_ptr));
#ifndef PNG_1_0_X
/* Function to allocate memory for zlib. */ /* Function to allocate memory for zlib. */
PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size)); PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size));
/* Function to free memory for zlib */ /* Function to free memory for zlib */
PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)); PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr));
/* Next four functions are used internally as callbacks. PNGAPI is required
* but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3. */
PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr,
png_bytep data, png_size_t length));
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr,
png_bytep buffer, png_size_t length));
#endif
PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr,
png_bytep data, png_size_t length));
#if defined(PNG_WRITE_FLUSH_SUPPORTED)
#if !defined(PNG_NO_STDIO)
PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr));
#endif
#endif
#else /* PNG_1_0_X */
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr,
png_bytep buffer, png_size_t length));
#endif
#endif /* PNG_1_0_X */
/* Reset the CRC variable */ /* Reset the CRC variable */
PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr)); PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
@@ -2513,8 +2741,8 @@ PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf,
png_size_t length)); png_size_t length));
/* Decompress data in a chunk that uses compression */ /* Decompress data in a chunk that uses compression */
#if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) || \ #if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \
defined(PNG_READ_iCCP_SUPPORTED) || defined(PNG_READ_sPLT_SUPPORTED) defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED)
PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr, PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr,
int comp_type, png_charp chunkdata, png_size_t chunklength, int comp_type, png_charp chunkdata, png_size_t chunklength,
png_size_t prefix_length, png_size_t *data_length)); png_size_t prefix_length, png_size_t *data_length));
@@ -2537,13 +2765,14 @@ PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr,
PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)); PNG_EXTERN void png_flush PNGARG((png_structp png_ptr));
#endif #endif
/* Place a 32-bit number into a buffer in PNG byte order (big-endian). /* Place a 32-bit number into a buffer in PNG byte order (big-endian).
* The only currently known PNG chunks that use signed numbers are * The only currently known PNG chunks that use signed numbers are
* the ancillary extension chunks, oFFs and pCAL. * the ancillary extension chunks, oFFs and pCAL.
*/ */
PNG_EXTERN void png_save_uint_32 PNGARG((png_bytep buf, png_uint_32 i)); PNG_EXTERN void png_save_uint_32 PNGARG((png_bytep buf, png_uint_32 i));
#if defined(PNG_WRITE_pCAL_SUPPORTED) #if defined(PNG_WRITE_pCAL_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
PNG_EXTERN void png_save_int_32 PNGARG((png_bytep buf, png_int_32 i)); PNG_EXTERN void png_save_int_32 PNGARG((png_bytep buf, png_int_32 i));
#endif #endif
@@ -2659,9 +2888,14 @@ PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr,
png_charp text)); png_charp text));
#endif #endif
#if defined(PNG_TEXT_SUPPORTED) /* Added at version 1.0.14 and 1.2.4 */
PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr,
png_infop info_ptr, png_textp text_ptr, int num_text));
#endif
#if defined(PNG_WRITE_oFFs_SUPPORTED) #if defined(PNG_WRITE_oFFs_SUPPORTED)
PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr, PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr,
png_uint_32 x_offset, png_uint_32 y_offset, int unit_type)); png_int_32 x_offset, png_int_32 y_offset, int unit_type));
#endif #endif
#if defined(PNG_WRITE_pCAL_SUPPORTED) #if defined(PNG_WRITE_pCAL_SUPPORTED)
@@ -2709,7 +2943,7 @@ PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row,
#if defined(PNG_READ_INTERLACING_SUPPORTED) #if defined(PNG_READ_INTERLACING_SUPPORTED)
/* expand an interlaced row */ /* expand an interlaced row */
/* OLD interface: /* OLD pre-1.0.9 interface:
PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info,
png_bytep row, int pass, png_uint_32 transformations)); png_bytep row, int pass, png_uint_32 transformations));
*/ */
@@ -2836,12 +3070,17 @@ PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row,
#endif #endif
#if defined(PNG_READ_BACKGROUND_SUPPORTED) #if defined(PNG_READ_BACKGROUND_SUPPORTED)
#if defined(PNG_READ_GAMMA_SUPPORTED)
PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, PNG_EXTERN void png_do_background PNGARG((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,
png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1,
png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1,
png_uint_16pp gamma_16_to_1, int gamma_shift)); png_uint_16pp gamma_16_to_1, int gamma_shift));
#else
PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
png_color_16p trans_values, png_color_16p background));
#endif
#endif #endif
#if defined(PNG_READ_GAMMA_SUPPORTED) #if defined(PNG_READ_GAMMA_SUPPORTED)
@@ -2954,11 +3193,6 @@ PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length)); png_uint_32 length));
#endif #endif
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
PNG_EXTERN int png_handle_as_unknown PNGARG((png_structp png_ptr, png_bytep
chunk_name));
#endif
PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr, PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_32 length)); png_infop info_ptr, png_uint_32 length));
@@ -2980,8 +3214,6 @@ PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr));
PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr, PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr,
png_uint_32 length)); png_uint_32 length));
PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr)); PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr));
PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr,
png_bytep buffer, png_size_t length));
PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr)); PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr));
PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr, PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr,
png_bytep buffer, png_size_t buffer_length)); png_bytep buffer, png_size_t buffer_length));
@@ -3029,6 +3261,10 @@ PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info,
png_bytep row)); png_bytep row));
#endif #endif
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
/* png.c */ /* PRIVATE */
PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr));
#endif
/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
#endif /* PNG_INTERNAL */ #endif /* PNG_INTERNAL */

View File

@@ -1,8 +1,8 @@
/* 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.9 - January 31, 2001 * libpng 1.0.14 - July 8, 2002
* 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) 2001 Glenn Randers-Pehrson * Copyright (c) 2002 Glenn Randers-Pehrson
* *
*/ */

262
pngconf.h
View File

@@ -1,8 +1,8 @@
/* pngconf.h - machine configurable file for libpng /* pngconf.h - machine configurable file for libpng
* *
* libpng 1.0.9 - January 31, 2001 * libpng 1.0.14 - July 8, 2002
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2002 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/ */
@@ -16,6 +16,8 @@
#ifndef PNGCONF_H #ifndef PNGCONF_H
#define PNGCONF_H #define PNGCONF_H
#define PNG_1_0_X
/* This is the size of the compression buffer, and thus the size of /* This is the size of the compression buffer, and thus the size of
* an IDAT chunk. Make this whatever size you feel is best for your * an IDAT chunk. Make this whatever size you feel is best for your
* machine. One of these will be allocated per png_struct. When this * machine. One of these will be allocated per png_struct. When this
@@ -33,8 +35,30 @@
# define PNG_ZBUF_SIZE 8192 # define PNG_ZBUF_SIZE 8192
#endif #endif
/* Enable if you want a write-only libpng */
#ifndef PNG_NO_READ_SUPPORTED
# define PNG_READ_SUPPORTED
#endif
/* Enable if you want a read-only libpng */
#ifndef PNG_NO_WRITE_SUPPORTED
# define PNG_WRITE_SUPPORTED
#endif
/* Enabled by default in 1.2.0. You can disable this if you don't need to
support PNGs that are embedded in MNG datastreams */
#if !defined(PNG_1_0_X) && !defined(PNG_NO_MNG_FEATURES)
# ifndef PNG_MNG_FEATURES_SUPPORTED
# define PNG_MNG_FEATURES_SUPPORTED
# endif
#endif
#ifndef PNG_NO_FLOATING_POINT_SUPPORTED #ifndef PNG_NO_FLOATING_POINT_SUPPORTED
# define PNG_FLOATING_POINT_SUPPORTED # ifndef PNG_FLOATING_POINT_SUPPORTED
# define PNG_FLOATING_POINT_SUPPORTED
# endif
#endif #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
@@ -56,58 +80,77 @@
* (no define) -- building static library, or building an * (no define) -- building static library, or building an
* application and linking to the static lib * application and linking to the static lib
* 'Cygwin' defines/defaults: * 'Cygwin' defines/defaults:
* PNG_BUILD_DLL -- building the dll * PNG_BUILD_DLL -- (ignored) building the dll
* (no define) -- building an application, linking to the dll * (no define) -- (ignored) building an application, linking to the dll
* PNG_STATIC -- building the static lib, or building an application * PNG_STATIC -- (ignored) building the static lib, or building an
* that links to the static lib. * application that links to the static lib.
* ALL_STATIC -- building various static libs, or building an application * ALL_STATIC -- (ignored) building various static libs, or building an
* that links to the static libs. * application that links to the static libs.
* Thus, * Thus,
* a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and * 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 * 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 * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but
* unnecessary. * unnecessary.
*
* Also, the precedence order is:
* ALL_STATIC (since we can't #undef something outside our namespace)
* PNG_BUILD_DLL
* PNG_STATIC
* (nothing) == PNG_USE_DLL
*
* CYGWIN (2002-01-20): The preceding is now obsolete. With the advent
* of auto-import in binutils, we no longer need to worry about
* __declspec(dllexport) / __declspec(dllimport) and friends. Therefore,
* we don't need to worry about PNG_STATIC or ALL_STATIC when it comes
* to __declspec() stuff. However, we DO need to worry about
* PNG_BUILD_DLL and PNG_STATIC because those change some defaults
* such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed.
*/ */
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
# if defined(PNG_BUILD_DLL) # if defined(ALL_STATIC)
# if defined(PNG_BUILD_DLL)
# undef PNG_BUILD_DLL
# endif
# if defined(PNG_USE_DLL) # if defined(PNG_USE_DLL)
# undef PNG_USE_DLL # undef PNG_USE_DLL
# endif # endif
# if !defined(PNG_DLL) # if defined(PNG_DLL)
# define PNG_DLL # undef PNG_DLL
# endif # endif
# if defined(PNG_STATIC) # if !defined(PNG_STATIC)
# undef PNG_STATIC
# endif
# else
# if defined(ALL_STATIC)
# define PNG_STATIC # define PNG_STATIC
# endif # endif
# if defined(PNG_STATIC) # else
# if defined (PNG_BUILD_DLL)
# if defined(PNG_STATIC)
# undef PNG_STATIC
# endif
# if defined(PNG_USE_DLL) # if defined(PNG_USE_DLL)
# undef PNG_USE_DLL # undef PNG_USE_DLL
# endif # endif
# if defined(PNG_DLL) # if !defined(PNG_DLL)
# undef PNG_DLL # define PNG_DLL
# endif # endif
# else # else
# if defined(PNG_USE_DLL) # 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)
# define PNG_USE_DLL
# endif
# if !defined(PNG_DLL) # if !defined(PNG_DLL)
# define PNG_DLL # define PNG_DLL
# endif # endif
# else # endif
# if defined(PNG_DLL) # endif
# define PNG_USE_DLL
# else
# define PNG_USE_DLL
# define PNG_DLL
# endif
# endif
# 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
@@ -169,6 +212,9 @@
#ifdef _NO_PROTO #ifdef _NO_PROTO
# define PNGARG(arglist) () # define PNGARG(arglist) ()
# ifndef PNG_TYPECAST_NULL
# define PNG_TYPECAST_NULL
# endif
#else #else
# define PNGARG(arglist) arglist # define PNGARG(arglist) arglist
#endif /* _NO_PROTO */ #endif /* _NO_PROTO */
@@ -193,7 +239,7 @@
# include <sys/types.h> # include <sys/types.h>
#endif #endif
#ifndef PNG_SETJMP_NOT_SUPPORTED #if !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED)
# define PNG_SETJMP_SUPPORTED # define PNG_SETJMP_SUPPORTED
#endif #endif
@@ -224,12 +270,6 @@
# 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
@@ -288,7 +328,8 @@
# include "alloc.h" # include "alloc.h"
#endif #endif
#ifdef _MSC_VER #if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \
defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__))
# include <malloc.h> # include <malloc.h>
#endif #endif
@@ -367,14 +408,14 @@
* iTXt is supported. It is turned off by default, to support old apps * 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() * 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 * and letting libpng malloc it. It will be turned on by default in
* libpng-2.0.0. * libpng-1.3.0.
*/ */
#ifndef PNG_iTXt_SUPPORTED #ifndef PNG_iTXt_SUPPORTED
# ifndef PNG_READ_iTXt_SUPPORTED # if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt)
# define PNG_NO_READ_iTXt # define PNG_NO_READ_iTXt
# endif # endif
# ifndef PNG_WRITE_iTXt_SUPPORTED # if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt)
# define PNG_NO_WRITE_iTXt # define PNG_NO_WRITE_iTXt
# endif # endif
#endif #endif
@@ -418,14 +459,12 @@
# define PNG_FREE_ME_SUPPORTED # define PNG_FREE_ME_SUPPORTED
#endif #endif
#if defined(PNG_READ_SUPPORTED)
#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
#endif #endif
#if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \
!defined(PNG_NO_WRITE_TRANSFORMS)
# define PNG_WRITE_TRANSFORMS_SUPPORTED
#endif
#ifdef PNG_READ_TRANSFORMS_SUPPORTED #ifdef PNG_READ_TRANSFORMS_SUPPORTED
# ifndef PNG_NO_READ_EXPAND # ifndef PNG_NO_READ_EXPAND
@@ -498,19 +537,21 @@
# endif # endif
#endif #endif
/* Enable if you need to support PNGs that are embedded in MNG /* Deprecated, will be removed from version 2.0.0.
datastreams */ Use PNG_MNG_FEATURES_SUPPORTED instead. */
/*
#ifndef PNG_NO_MNG_FEATURES
# define PNG_MNG_FEATURES_SUPPORTED
#endif
*/
/* Deprecated, will be removed from version 2.0.0 */
#ifndef PNG_NO_READ_EMPTY_PLTE #ifndef PNG_NO_READ_EMPTY_PLTE
# define PNG_READ_EMPTY_PLTE_SUPPORTED # define PNG_READ_EMPTY_PLTE_SUPPORTED
#endif #endif
#endif /* PNG_READ_SUPPORTED */
#if defined(PNG_WRITE_SUPPORTED)
# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \
!defined(PNG_NO_WRITE_TRANSFORMS)
# define PNG_WRITE_TRANSFORMS_SUPPORTED
#endif
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED #ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
# ifndef PNG_NO_WRITE_SHIFT # ifndef PNG_NO_WRITE_SHIFT
# define PNG_WRITE_SHIFT_SUPPORTED # define PNG_WRITE_SHIFT_SUPPORTED
@@ -560,6 +601,12 @@
# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED # define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
#endif #endif
#ifndef PNG_1_0_X
#ifndef PNG_NO_ERROR_NUMBERS
#define PNG_ERROR_NUMBERS_SUPPORTED
#endif
#endif /* PNG_1_0_X */
#ifndef PNG_NO_WRITE_FLUSH #ifndef PNG_NO_WRITE_FLUSH
# define PNG_WRITE_FLUSH_SUPPORTED # define PNG_WRITE_FLUSH_SUPPORTED
#endif #endif
@@ -569,6 +616,8 @@
# define PNG_WRITE_EMPTY_PLTE_SUPPORTED # define PNG_WRITE_EMPTY_PLTE_SUPPORTED
#endif #endif
#endif /* PNG_WRITE_SUPPORTED */
#ifndef PNG_NO_STDIO #ifndef PNG_NO_STDIO
# define PNG_TIME_RFC1123_SUPPORTED # define PNG_TIME_RFC1123_SUPPORTED
#endif #endif
@@ -589,36 +638,52 @@
* png_get_x_offset_microns() * png_get_x_offset_microns()
* png_get_y_offset_microns() * png_get_y_offset_microns()
*/ */
#ifndef PNG_NO_EASY_ACCESS #if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED)
# define PNG_EASY_ACCESS_SUPPORTED # define PNG_EASY_ACCESS_SUPPORTED
#endif #endif
/* PNG_ASSEMBLER_CODE will be enabled by default in version 1.2.0 /* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0
even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined */ even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined */
#ifndef PNG_NO_ASSEMBLER_CODE #if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE)
# if defined(PNG_USE_PNGVCRD) || defined(PNG_USE_PNGGCCRD) # ifndef PNG_ASSEMBLER_CODE_SUPPORTED
# define PNG_ASSEMBLER_CODE_SUPPORTED # define PNG_ASSEMBLER_CODE_SUPPORTED
# endif
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
# define PNG_MMX_CODE_SUPPORTED # define PNG_MMX_CODE_SUPPORTED
# endif # endif
#endif #endif
/* If you are sure that you don't need thread safety and you are compiling
with PNG_USE_PNGCCRD for an MMX application, you can define this for
faster execution. See pnggccrd.c.
#define PNG_THREAD_UNSAFE_OK
*/
#if !defined(PNG_1_0_X)
#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED)
# define PNG_USER_MEM_SUPPORTED
#endif
#endif /* PNG_1_0_X */
/* 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 #ifdef PNG_READ_SUPPORTED
#ifndef PNG_NO_USER_MEM # ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
# define PNG_USER_MEM_SUPPORTED # define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
#endif # endif
#ifndef PNG_NO_ZALLOC_ZERO
# define PNG_ZALLOC_ZERO
#endif #endif
*/ */
/* This is only for PowerPC big-endian and 680x0 systems */ /* This is only for PowerPC big-endian and 680x0 systems */
/* some testing */ /* some testing */
/* /*
#define PNG_READ_BIG_ENDIAN_SUPPORTED #ifdef PNG_READ_SUPPORTED
# ifndef PNG_PNG_READ_BIG_ENDIAN_SUPPORTED
# define PNG_READ_BIG_ENDIAN_SUPPORTED
# endif
#endif
*/ */
/* Buggy compilers (e.g., gcc 2.7.2.2) need this */ /* Buggy compilers (e.g., gcc 2.7.2.2) need this */
@@ -638,11 +703,14 @@
* a bit smaller. * a bit smaller.
*/ */
#if !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ #if defined(PNG_READ_SUPPORTED) && \
!defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
!defined(PNG_NO_READ_ANCILLARY_CHUNKS) !defined(PNG_NO_READ_ANCILLARY_CHUNKS)
# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED # define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
#endif #endif
#if !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
#if defined(PNG_WRITE_SUPPORTED) && \
!defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
!defined(PNG_NO_WRITE_ANCILLARY_CHUNKS) !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS)
# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED # define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
#endif #endif
@@ -675,8 +743,12 @@
# define PNG_iCCP_SUPPORTED # define PNG_iCCP_SUPPORTED
#endif #endif
#ifndef PNG_NO_READ_iTXt #ifndef PNG_NO_READ_iTXt
# define PNG_READ_iTXt_SUPPORTED # ifndef PNG_READ_iTXt_SUPPORTED
# define PNG_iTXt_SUPPORTED # define PNG_READ_iTXt_SUPPORTED
# endif
# ifndef PNG_iTXt_SUPPORTED
# define PNG_iTXt_SUPPORTED
# endif
#endif #endif
#ifndef PNG_NO_READ_oFFs #ifndef PNG_NO_READ_oFFs
# define PNG_READ_oFFs_SUPPORTED # define PNG_READ_oFFs_SUPPORTED
@@ -791,7 +863,9 @@
# endif # endif
#endif #endif
#ifndef PNG_NO_WRITE_iTXt #ifndef PNG_NO_WRITE_iTXt
# define PNG_WRITE_iTXt_SUPPORTED # ifndef PNG_WRITE_iTXt_SUPPORTED
# define PNG_WRITE_iTXt_SUPPORTED
# endif
# ifndef PNG_iTXt_SUPPORTED # ifndef PNG_iTXt_SUPPORTED
# define PNG_iTXt_SUPPORTED # define PNG_iTXt_SUPPORTED
# endif # endif
@@ -1085,10 +1159,23 @@ typedef z_stream FAR * png_zstreamp;
# endif # endif
#endif #endif
#if defined(__CYGWIN__)
# undef PNGAPI
# define PNGAPI __cdecl
# undef PNG_IMPEXP
# define PNG_IMPEXP
#endif
/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
* you may get warnings regarding the linkage of png_zalloc and png_zfree.
* Don't ignore those warnings; you must also reset the default calling
* convention in your compiler to match your PNGAPI, and you must build
* zlib and your applications the same way you build libpng.
*/
#ifndef PNGAPI #ifndef PNGAPI
#if defined(__MINGW32__) || defined(__CYGWIN__) && !defined(PNG_MODULEDEF) #if defined(__MINGW32__) && !defined(PNG_MODULEDEF)
# ifndef PNG_NO_MODULEDEF # ifndef PNG_NO_MODULEDEF
# define PNG_NO_MODULEDEF # define PNG_NO_MODULEDEF
# endif # endif
@@ -1100,8 +1187,7 @@ typedef z_stream FAR * png_zstreamp;
#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \ #if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \
(( defined(_Windows) || defined(_WINDOWS) || \ (( defined(_Windows) || defined(_WINDOWS) || \
defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \ defined(WIN32) || defined(_WIN32) || defined(__WIN32__) ))
) && !defined(__CYGWIN__))
# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) # if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
# define PNGAPI __cdecl # define PNGAPI __cdecl
@@ -1128,8 +1214,8 @@ typedef z_stream FAR * png_zstreamp;
# if defined(PNG_BUILD_DLL) # if defined(PNG_BUILD_DLL)
# define PNG_IMPEXP __export # define PNG_IMPEXP __export
# else # else
# define PNG_IMPEXP /*__import*/ /* doesn't exist AFAIK in # define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in
VC++*/ VC++ */
# endif /* Exists in Borland C++ for # endif /* Exists in Borland C++ for
C++ classes (== huge) */ C++ classes (== huge) */
# endif # endif
@@ -1144,18 +1230,16 @@ typedef z_stream FAR * png_zstreamp;
# endif # endif
# endif /* PNG_IMPEXP */ # endif /* PNG_IMPEXP */
#else /* !(DLL || non-cygwin WINDOWS) */ #else /* !(DLL || non-cygwin WINDOWS) */
# if defined(__CYGWIN__) && !defined(PNG_DLL) # if (defined(__IBMC__) || defined(IBMCPP__)) && defined(__OS2__)
# if !defined(PNG_IMPEXP) # define PNGAPI _System
# define PNG_IMPEXP # define PNG_IMPEXP
# endif
# define PNGAPI __cdecl
# else
# if 0 /* ... other platforms, with other meanings */
# else # else
# define PNGAPI # if 0 /* ... other platforms, with other meanings */
# define PNG_IMPEXP # else
# define PNGAPI
# define PNG_IMPEXP
# endif
# endif # endif
# endif
#endif #endif
#endif #endif
@@ -1221,8 +1305,9 @@ typedef z_stream FAR * png_zstreamp;
# define PNG_ZBUF_SIZE 65536 # define PNG_ZBUF_SIZE 65536
#endif #endif
#ifdef PNG_READ_SUPPORTED
/* Prior to libpng-1.0.9, this block was in pngasmrd.h */ /* Prior to libpng-1.0.9, this block was in pngasmrd.h */
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_INTERNAL) #if defined(PNG_INTERNAL)
/* These are the default thresholds before the MMX code kicks in; if either /* These are the default thresholds before the MMX code kicks in; if either
* rowbytes or bitdepth is below the threshold, plain C code is used. These * rowbytes or bitdepth is below the threshold, plain C code is used. These
@@ -1258,7 +1343,8 @@ typedef z_stream FAR * png_zstreamp;
#endif #endif
/* - see pnggccrd.c for info about what is currently enabled */ /* - see pnggccrd.c for info about what is currently enabled */
#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ #endif /* PNG_INTERNAL */
#endif /* PNG_READ_SUPPORTED */
#endif /* PNGCONF_H */ #endif /* PNGCONF_H */

View File

@@ -1,9 +1,9 @@
/* pngerror.c - stub functions for i/o and memory allocation /* pngerror.c - stub functions for i/o and memory allocation
* *
* libpng 1.0.9 - January 31, 2001 * libpng 1.0.14 - July 8, 2002
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2002 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
@@ -18,10 +18,10 @@
static void /* PRIVATE */ static void /* PRIVATE */
png_default_error PNGARG((png_structp png_ptr, png_default_error PNGARG((png_structp png_ptr,
png_const_charp message)); png_const_charp error_message));
static void /* PRIVATE */ static void /* PRIVATE */
png_default_warning PNGARG((png_structp png_ptr, png_default_warning PNGARG((png_structp png_ptr,
png_const_charp message)); png_const_charp warning_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
* should not be changed. If there is a need to handle errors differently, * should not be changed. If there is a need to handle errors differently,
@@ -29,14 +29,46 @@ png_default_warning PNGARG((png_structp png_ptr,
* to replace the error function at run-time. * to replace the error function at run-time.
*/ */
void PNGAPI void PNGAPI
png_error(png_structp png_ptr, png_const_charp message) png_error(png_structp png_ptr, png_const_charp error_message)
{ {
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
char msg[16];
if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
{
int offset = 0;
if (*error_message == '#')
{
for (offset=1; offset<15; offset++)
if (*(error_message+offset) == ' ')
break;
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
{
int i;
for (i=0; i<offset-1; i++)
msg[i]=error_message[i+1];
msg[i]='\0';
error_message=msg;
}
else
error_message+=offset;
}
else
{
if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
{
msg[0]='0';
msg[1]='\0';
error_message=msg;
}
}
}
#endif
if (png_ptr->error_fn != NULL) if (png_ptr->error_fn != NULL)
(*(png_ptr->error_fn))(png_ptr, message); (*(png_ptr->error_fn))(png_ptr, error_message);
/* if the following returns or doesn't exist, use the default function, /* if the following returns or doesn't exist, use the default function,
which will not return */ which will not return */
png_default_error(png_ptr, message); png_default_error(png_ptr, error_message);
} }
/* This function is called whenever there is a non-fatal error. This function /* This function is called whenever there is a non-fatal error. This function
@@ -45,12 +77,25 @@ png_error(png_structp png_ptr, png_const_charp message)
* 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 PNGAPI void PNGAPI
png_warning(png_structp png_ptr, png_const_charp message) png_warning(png_structp png_ptr, png_const_charp warning_message)
{ {
int offset = 0;
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
#endif
{
if (*warning_message == '#')
{
for (offset=1; offset<15; offset++)
if (*(warning_message+offset) == ' ')
break;
}
}
if (png_ptr->warning_fn != NULL) if (png_ptr->warning_fn != NULL)
(*(png_ptr->warning_fn))(png_ptr, message); (*(png_ptr->warning_fn))(png_ptr,
(png_const_charp)(warning_message+offset));
else else
png_default_warning(png_ptr, message); png_default_warning(png_ptr, (png_const_charp)(warning_message+offset));
} }
/* These utilities are used internally to build an error message that relates /* These utilities are used internally to build an error message that relates
@@ -61,11 +106,12 @@ png_warning(png_structp png_ptr, png_const_charp message)
*/ */
#define isnonalpha(c) ((c) < 41 || (c) > 122 || ((c) > 90 && (c) < 97)) #define isnonalpha(c) ((c) < 41 || (c) > 122 || ((c) > 90 && (c) < 97))
static PNG_CONST char png_digit[16] = { 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 /* PRIVATE */ 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
error_message)
{ {
int iout = 0, iin = 0; int iout = 0, iin = 0;
@@ -85,30 +131,30 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp message
} }
} }
if (message == NULL) if (error_message == NULL)
buffer[iout] = 0; buffer[iout] = 0;
else else
{ {
buffer[iout++] = ':'; buffer[iout++] = ':';
buffer[iout++] = ' '; buffer[iout++] = ' ';
png_memcpy(buffer+iout, message, 64); png_memcpy(buffer+iout, error_message, 64);
buffer[iout+63] = 0; buffer[iout+63] = 0;
} }
} }
void PNGAPI void PNGAPI
png_chunk_error(png_structp png_ptr, png_const_charp message) png_chunk_error(png_structp png_ptr, png_const_charp error_message)
{ {
char msg[18+64]; char msg[18+64];
png_format_buffer(png_ptr, msg, message); png_format_buffer(png_ptr, msg, error_message);
png_error(png_ptr, msg); png_error(png_ptr, msg);
} }
void PNGAPI void PNGAPI
png_chunk_warning(png_structp png_ptr, png_const_charp message) png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
{ {
char msg[16+64]; char msg[18+64];
png_format_buffer(png_ptr, msg, message); png_format_buffer(png_ptr, msg, warning_message);
png_warning(png_ptr, msg); png_warning(png_ptr, msg);
} }
@@ -118,12 +164,34 @@ png_chunk_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 /* PRIVATE */ static void /* PRIVATE */
png_default_error(png_structp png_ptr, png_const_charp message) png_default_error(png_structp png_ptr, png_const_charp error_message)
{ {
#ifndef PNG_NO_CONSOLE_IO #ifndef PNG_NO_CONSOLE_IO
fprintf(stderr, "libpng error: %s\n", message); #ifdef PNG_ERROR_NUMBERS_SUPPORTED
if (*error_message == '#')
{
int offset;
char error_number[16];
for (offset=0; offset<15; offset++)
{
error_number[offset] = *(error_message+offset+1);
if (*(error_message+offset) == ' ')
break;
}
if((offset > 1) && (offset < 15))
{
error_number[offset-1]='\0';
fprintf(stderr, "libpng error no. %s: %s\n", error_number,
error_message+offset);
}
else
fprintf(stderr, "libpng error: %s, offset=%d\n", error_message,offset);
}
else
#endif
fprintf(stderr, "libpng error: %s\n", error_message);
#else #else
if (message) if (error_message)
/* make compiler happy */ ; /* make compiler happy */ ;
#endif #endif
@@ -150,12 +218,34 @@ png_default_error(png_structp png_ptr, png_const_charp message)
* 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 /* PRIVATE */ static void /* PRIVATE */
png_default_warning(png_structp png_ptr, png_const_charp message) png_default_warning(png_structp png_ptr, png_const_charp warning_message)
{ {
#ifndef PNG_NO_CONSOLE_IO #ifndef PNG_NO_CONSOLE_IO
fprintf(stderr, "libpng warning: %s\n", message); # ifdef PNG_ERROR_NUMBERS_SUPPORTED
if (*warning_message == '#')
{
int offset;
char warning_number[16];
for (offset=0; offset<15; offset++)
{
warning_number[offset]=*(warning_message+offset+1);
if (*(warning_message+offset) == ' ')
break;
}
if((offset > 1) && (offset < 15))
{
warning_number[offset-1]='\0';
fprintf(stderr, "libpng warning no. %s: %s\n", warning_number,
warning_message+offset);
}
else
fprintf(stderr, "libpng warning: %s\n", warning_message);
}
else
# endif
fprintf(stderr, "libpng warning: %s\n", warning_message);
#else #else
if (message) if (warning_message)
/* appease compiler */ ; /* appease compiler */ ;
#endif #endif
if (png_ptr) if (png_ptr)
@@ -188,4 +278,14 @@ png_get_error_ptr(png_structp png_ptr)
} }
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
void PNGAPI
png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
{
if(png_ptr != NULL)
{
png_ptr->flags &=
((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode);
}
}
#endif

File diff suppressed because it is too large Load Diff

147
pngget.c
View File

@@ -1,9 +1,9 @@
/* pngget.c - retrieval of values from info struct /* pngget.c - retrieval of values from info struct
* *
* libpng 1.0.9 - January 31, 2001 * libpng 1.0.14 - July 8, 2002
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2002 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/ */
@@ -137,7 +137,7 @@ png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
#if defined(PNG_pHYs_SUPPORTED) #if defined(PNG_pHYs_SUPPORTED)
if (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);
@@ -297,7 +297,7 @@ png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
*.00003937); *.00003937);
} }
#if defined(PNG_READ_pHYs_SUPPORTED) #if defined(PNG_pHYs_SUPPORTED)
png_uint_32 PNGAPI 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)
@@ -330,7 +330,7 @@ png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
} }
return (retval); return (retval);
} }
#endif /* PNG_READ_pHYs_SUPPORTED */ #endif /* PNG_pHYs_SUPPORTED */
#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ #endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
/* png_get_channels really belongs in here, too, but it's been around longer */ /* png_get_channels really belongs in here, too, but it's been around longer */
@@ -355,7 +355,7 @@ png_get_signature(png_structp png_ptr, png_infop info_ptr)
return (NULL); return (NULL);
} }
#if defined(PNG_READ_bKGD_SUPPORTED) #if defined(PNG_bKGD_SUPPORTED)
png_uint_32 PNGAPI 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)
@@ -371,7 +371,7 @@ png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
} }
#endif #endif
#if defined(PNG_READ_cHRM_SUPPORTED) #if defined(PNG_cHRM_SUPPORTED)
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 PNGAPI 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,
@@ -435,7 +435,7 @@ png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
#endif #endif
#endif #endif
#if defined(PNG_READ_gAMA_SUPPORTED) #if defined(PNG_gAMA_SUPPORTED)
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 PNGAPI 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)
@@ -467,7 +467,7 @@ png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
#endif #endif
#endif #endif
#if defined(PNG_READ_sRGB_SUPPORTED) #if defined(PNG_sRGB_SUPPORTED)
png_uint_32 PNGAPI 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)
{ {
@@ -482,7 +482,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_iCCP_SUPPORTED)
png_uint_32 PNGAPI 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,
@@ -504,7 +504,7 @@ png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
} }
#endif #endif
#if defined(PNG_READ_sPLT_SUPPORTED) #if defined(PNG_sPLT_SUPPORTED)
png_uint_32 PNGAPI 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)
@@ -515,7 +515,7 @@ png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
} }
#endif #endif
#if defined(PNG_READ_hIST_SUPPORTED) #if defined(PNG_hIST_SUPPORTED)
png_uint_32 PNGAPI 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)
{ {
@@ -547,7 +547,11 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
*width = info_ptr->width; *width = info_ptr->width;
*height = info_ptr->height; *height = info_ptr->height;
*bit_depth = info_ptr->bit_depth; *bit_depth = info_ptr->bit_depth;
if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16)
png_error(png_ptr, "Invalid bit depth");
*color_type = info_ptr->color_type; *color_type = info_ptr->color_type;
if (info_ptr->color_type > 6)
png_error(png_ptr, "Invalid color type");
if (compression_type != NULL) if (compression_type != NULL)
*compression_type = info_ptr->compression_type; *compression_type = info_ptr->compression_type;
if (filter_type != NULL) if (filter_type != NULL)
@@ -566,9 +570,13 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
channels++; channels++;
pixel_depth = *bit_depth * channels; pixel_depth = *bit_depth * channels;
rowbytes_per_pixel = (pixel_depth + 7) >> 3; rowbytes_per_pixel = (pixel_depth + 7) >> 3;
if ((*width > PNG_MAX_UINT/rowbytes_per_pixel)) if (width == 0 || *width > PNG_MAX_UINT)
png_error(png_ptr, "Invalid image width");
if (height == 0 || *height > PNG_MAX_UINT)
png_error(png_ptr, "Invalid image height");
if (*width > PNG_MAX_UINT/rowbytes_per_pixel - 64)
{ {
png_warning(png_ptr, png_error(png_ptr,
"Width too large for libpng to process image data."); "Width too large for libpng to process image data.");
} }
return (1); return (1);
@@ -576,7 +584,7 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
return (0); return (0);
} }
#if defined(PNG_READ_oFFs_SUPPORTED) #if defined(PNG_oFFs_SUPPORTED)
png_uint_32 PNGAPI 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)
@@ -594,7 +602,7 @@ png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
} }
#endif #endif
#if defined(PNG_READ_pCAL_SUPPORTED) #if defined(PNG_pCAL_SUPPORTED)
png_uint_32 PNGAPI 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,
@@ -618,7 +626,7 @@ png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
} }
#endif #endif
#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED) #if defined(PNG_sCAL_SUPPORTED)
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 PNGAPI 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,
@@ -654,7 +662,7 @@ png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
#endif #endif
#endif #endif
#if defined(PNG_READ_pHYs_SUPPORTED) #if defined(PNG_pHYs_SUPPORTED)
png_uint_32 PNGAPI 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)
@@ -701,7 +709,7 @@ png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
return (0); return (0);
} }
#if defined(PNG_READ_sBIT_SUPPORTED) #if defined(PNG_sBIT_SUPPORTED)
png_uint_32 PNGAPI 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)
{ {
@@ -716,7 +724,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_TEXT_SUPPORTED)
png_uint_32 PNGAPI 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)
@@ -738,7 +746,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_tIME_SUPPORTED)
png_uint_32 PNGAPI 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)
{ {
@@ -753,7 +761,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_tRNS_SUPPORTED)
png_uint_32 PNGAPI 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)
@@ -792,7 +800,7 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
} }
#endif #endif
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
png_uint_32 PNGAPI 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)
@@ -811,7 +819,7 @@ png_get_rgb_to_gray_status (png_structp png_ptr)
} }
#endif #endif
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) #if defined(PNG_USER_CHUNKS_SUPPORTED)
png_voidp PNGAPI png_voidp PNGAPI
png_get_user_chunk_ptr(png_structp png_ptr) png_get_user_chunk_ptr(png_structp png_ptr)
{ {
@@ -826,3 +834,94 @@ png_get_compression_buffer_size(png_structp png_ptr)
return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L); return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L);
} }
#ifndef PNG_1_0_X
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
/* this function was added to libpng 1.2.0 and should exist by default */
png_uint_32 PNGAPI
png_get_asm_flags (png_structp png_ptr)
{
return (png_uint_32)(png_ptr? png_ptr->asm_flags : 0L);
}
/* this function was added to libpng 1.2.0 and should exist by default */
png_uint_32 PNGAPI
png_get_asm_flagmask (int flag_select)
{
png_uint_32 settable_asm_flags = 0;
if (flag_select & PNG_SELECT_READ)
settable_asm_flags |=
PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
PNG_ASM_FLAG_MMX_READ_INTERLACE |
PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
PNG_ASM_FLAG_MMX_READ_FILTER_UP |
PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
/* no non-MMX flags yet */
#if 0
/* GRR: no write-flags yet, either, but someday... */
if (flag_select & PNG_SELECT_WRITE)
settable_asm_flags |=
PNG_ASM_FLAG_MMX_WRITE_ [whatever] ;
#endif /* 0 */
return settable_asm_flags; /* _theoretically_ settable capabilities only */
}
#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
/* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
/* this function was added to libpng 1.2.0 */
png_uint_32 PNGAPI
png_get_mmx_flagmask (int flag_select, int *compilerID)
{
png_uint_32 settable_mmx_flags = 0;
if (flag_select & PNG_SELECT_READ)
settable_mmx_flags |=
PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
PNG_ASM_FLAG_MMX_READ_INTERLACE |
PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
PNG_ASM_FLAG_MMX_READ_FILTER_UP |
PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
#if 0
/* GRR: no MMX write support yet, but someday... */
if (flag_select & PNG_SELECT_WRITE)
settable_mmx_flags |=
PNG_ASM_FLAG_MMX_WRITE_ [whatever] ;
#endif /* 0 */
if (compilerID != NULL) {
#ifdef PNG_USE_PNGVCRD
*compilerID = 1; /* MSVC */
#else
#ifdef PNG_USE_PNGGCCRD
*compilerID = 2; /* gcc/gas */
#else
*compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */
#endif
#endif
}
return settable_mmx_flags; /* _theoretically_ settable capabilities only */
}
/* this function was added to libpng 1.2.0 */
png_byte PNGAPI
png_get_mmx_bitdepth_threshold (png_structp png_ptr)
{
return (png_byte)(png_ptr? png_ptr->mmx_bitdepth_threshold : 0);
}
/* this function was added to libpng 1.2.0 */
png_uint_32 PNGAPI
png_get_mmx_rowbytes_threshold (png_structp png_ptr)
{
return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L);
}
#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
#endif /* PNG_1_0_X */

151
pngmem.c
View File

@@ -1,9 +1,9 @@
/* pngmem.c - stub functions for memory allocation /* pngmem.c - stub functions for memory allocation
* *
* libpng 1.0.9 - January 31, 2001 * libpng 1.0.14 - July 8, 2002
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2002 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
@@ -27,12 +27,12 @@ png_voidp /* PRIVATE */
png_create_struct(int type) png_create_struct(int type)
{ {
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
return (png_create_struct_2(type, NULL)); return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL));
} }
/* 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 /* PRIVATE */ 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, png_voidp mem_ptr)
{ {
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
png_size_t size; png_size_t size;
@@ -43,35 +43,36 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn)
else if (type == PNG_STRUCT_PNG) else if (type == PNG_STRUCT_PNG)
size = sizeof(png_struct); size = sizeof(png_struct);
else else
return ((png_voidp)NULL); return (png_get_copyright());
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
if(malloc_fn != NULL) if(malloc_fn != NULL)
{ {
if ((struct_ptr = (*(malloc_fn))(NULL, size)) != NULL) png_struct dummy_struct;
png_memset(struct_ptr, 0, size); png_structp png_ptr = &dummy_struct;
return (struct_ptr); png_ptr->mem_ptr=mem_ptr;
struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size);
} }
else
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL) struct_ptr = (png_voidp)farmalloc(size));
{ if (struct_ptr != NULL)
png_memset(struct_ptr, 0, size); png_memset(struct_ptr, 0, size);
}
return (struct_ptr); return (struct_ptr);
} }
/* Free memory allocated by a png_create_struct() call */ /* Free memory allocated by a png_create_struct() call */
void /* PRIVATE */ 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
png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL); png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL);
} }
/* Free memory allocated by a png_create_struct() call */ /* Free memory allocated by a png_create_struct() call */
void /* PRIVATE */ 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,
png_voidp mem_ptr)
{ {
#endif #endif
if (struct_ptr != NULL) if (struct_ptr != NULL)
@@ -81,6 +82,7 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
{ {
png_struct dummy_struct; png_struct dummy_struct;
png_structp png_ptr = &dummy_struct; png_structp png_ptr = &dummy_struct;
png_ptr->mem_ptr=mem_ptr;
(*(free_fn))(png_ptr, struct_ptr); (*(free_fn))(png_ptr, struct_ptr);
return; return;
} }
@@ -108,18 +110,23 @@ 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 PNGAPI 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
png_voidp ret; png_voidp ret;
#endif
if (png_ptr == NULL || size == 0) if (png_ptr == NULL || size == 0)
return ((png_voidp)NULL); return (NULL);
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
if(png_ptr->malloc_fn != NULL) if(png_ptr->malloc_fn != NULL)
return ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size)); {
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
png_error(png_ptr, "Out of memory!");
return (ret);
}
else else
return png_malloc_default(png_ptr, size); return png_malloc_default(png_ptr, size);
} }
@@ -170,12 +177,22 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
if (table == NULL) if (table == NULL)
{ {
png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */ if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */
else
png_warning(png_ptr, "Out Of Memory.");
return (NULL);
} }
if ((png_size_t)table & 0xfff0) if ((png_size_t)table & 0xfff0)
{ {
png_error(png_ptr, "Farmalloc didn't return normalized pointer"); if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
png_error(png_ptr,
"Farmalloc didn't return normalized pointer");
else
png_warning(png_ptr,
"Farmalloc didn't return normalized pointer");
return (NULL);
} }
png_ptr->offset_table = table; png_ptr->offset_table = table;
@@ -184,7 +201,11 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
if (png_ptr->offset_table_ptr == NULL) if (png_ptr->offset_table_ptr == NULL)
{ {
png_error(png_ptr, "Out Of memory."); if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
png_error(png_ptr, "Out Of memory."); /* Note "O" and "M" */
else
png_warning(png_ptr, "Out Of memory.");
return (NULL);
} }
hptr = (png_byte huge *)table; hptr = (png_byte huge *)table;
@@ -206,7 +227,13 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
} }
if (png_ptr->offset_table_count >= png_ptr->offset_table_number) if (png_ptr->offset_table_count >= png_ptr->offset_table_number)
png_error(png_ptr, "Out of Memory."); {
if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
png_error(png_ptr, "Out of Memory."); /* Note "o" and "M" */
else
png_warning(png_ptr, "Out of Memory.");
return (NULL);
}
ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++]; ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++];
} }
@@ -215,7 +242,10 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
if (ret == NULL) if (ret == NULL)
{ {
png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */ if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */
else
png_warning(png_ptr, "Out of memory."); /* Note "o" and "m" */
} }
return (ret); return (ret);
@@ -276,19 +306,19 @@ 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 /* PRIVATE */ png_voidp /* PRIVATE */
png_create_struct(int type) png_create_struct(int type)
{ {
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
return (png_create_struct_2(type, NULL)); return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL));
} }
/* 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 /* PRIVATE */ 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, png_voidp mem_ptr)
{ {
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
png_size_t size; png_size_t size;
@@ -299,12 +329,16 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn)
else if (type == PNG_STRUCT_PNG) else if (type == PNG_STRUCT_PNG)
size = sizeof(png_struct); size = sizeof(png_struct);
else else
return ((png_voidp)NULL); return (NULL);
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
if(malloc_fn != NULL) if(malloc_fn != NULL)
{ {
if ((struct_ptr = (*(malloc_fn))(NULL, size)) != NULL) png_struct dummy_struct;
png_structp png_ptr = &dummy_struct;
png_ptr->mem_ptr=mem_ptr;
struct_ptr = (*(malloc_fn))(png_ptr, size);
if (struct_ptr != NULL)
png_memset(struct_ptr, 0, size); png_memset(struct_ptr, 0, size);
return (struct_ptr); return (struct_ptr);
} }
@@ -332,12 +366,13 @@ 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
png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL); png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL);
} }
/* Free memory allocated by a png_create_struct() call */ /* Free memory allocated by a png_create_struct() call */
void /* PRIVATE */ 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,
png_voidp mem_ptr)
{ {
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
if (struct_ptr != NULL) if (struct_ptr != NULL)
@@ -347,6 +382,7 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
{ {
png_struct dummy_struct; png_struct dummy_struct;
png_structp png_ptr = &dummy_struct; png_structp png_ptr = &dummy_struct;
png_ptr->mem_ptr=mem_ptr;
(*(free_fn))(png_ptr, struct_ptr); (*(free_fn))(png_ptr, struct_ptr);
return; return;
} }
@@ -363,7 +399,6 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
} }
} }
/* Allocate memory. For reasonable files, size should never exceed /* Allocate memory. For reasonable files, size should never exceed
64K. However, zlib may allocate more then 64K if you don't tell 64K. However, zlib may allocate more then 64K if you don't tell
it not to. See zconf.h and png.h for more information. zlib does it not to. See zconf.h and png.h for more information. zlib does
@@ -373,19 +408,24 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn)
png_voidp PNGAPI 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
png_voidp ret; png_voidp ret;
#endif
if (png_ptr == NULL || size == 0) if (png_ptr == NULL || size == 0)
return ((png_voidp)NULL); return (NULL);
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
if(png_ptr->malloc_fn != NULL) if(png_ptr->malloc_fn != NULL)
return ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size)); {
ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
png_error(png_ptr, "Out of Memory!");
return (ret);
}
else else
return (png_malloc_default(png_ptr, size)); return (png_malloc_default(png_ptr, size));
} }
png_voidp /* PRIVATE */
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;
@@ -393,7 +433,12 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
#ifdef PNG_MAX_MALLOC_64K #ifdef PNG_MAX_MALLOC_64K
if (size > (png_uint_32)65536L) if (size > (png_uint_32)65536L)
png_error(png_ptr, "Cannot Allocate > 64K"); {
if(png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
png_error(png_ptr, "Cannot Allocate > 64K");
else
return NULL;
}
#endif #endif
#if defined(__TURBOC__) && !defined(__FLAT__) #if defined(__TURBOC__) && !defined(__FLAT__)
@@ -406,10 +451,8 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
# endif # endif
#endif #endif
if (ret == NULL) if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
{
png_error(png_ptr, "Out of Memory"); png_error(png_ptr, "Out of Memory");
}
return (ret); return (ret);
} }
@@ -430,7 +473,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 /* PRIVATE */ void PNGAPI
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 +494,27 @@ 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 /* PRIVATE */ #if defined(PNG_1_0_X)
# define png_malloc_warn png_malloc
#else
/* This function was added at libpng version 1.2.3. The png_malloc_warn()
* function will issue a png_warning and return NULL instead of issuing a
* png_error, if it fails to allocate the requested memory.
*/
png_voidp PNGAPI
png_malloc_warn(png_structp png_ptr, png_uint_32 size)
{
png_voidp ptr;
png_uint_32 save_flags=png_ptr->flags;
png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
ptr = (png_voidp)png_malloc((png_structp)png_ptr, size);
png_ptr->flags=save_flags;
return(ptr);
}
#endif
png_voidp PNGAPI
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 +527,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 /* PRIVATE */ png_voidp PNGAPI
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)
{ {

View File

@@ -1,9 +1,9 @@
/* pngpread.c - read a png file in push mode /* pngpread.c - read a png file in push mode
* *
* libpng 1.0.9 - January 31, 2001 * libpng 1.0.14 - July 8, 2002
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2002 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/ */
@@ -221,7 +221,6 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_push_save_buffer(png_ptr); png_push_save_buffer(png_ptr);
return; return;
} }
png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length); png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length);
} }
else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
@@ -231,7 +230,6 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_push_save_buffer(png_ptr); png_push_save_buffer(png_ptr);
return; return;
} }
png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length); png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length);
} }
else if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) else if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4))
@@ -240,6 +238,12 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
* header chunks, and we can start reading the image (or if this * header chunks, and we can start reading the image (or if this
* is called after the image has been read - we have an error). * is called after the image has been read - we have an error).
*/ */
if (!(png_ptr->mode & PNG_HAVE_IHDR))
png_error(png_ptr, "Missing IHDR before IDAT");
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
!(png_ptr->mode & PNG_HAVE_PLTE))
png_error(png_ptr, "Missing PLTE before IDAT");
if (png_ptr->mode & PNG_HAVE_IDAT) if (png_ptr->mode & PNG_HAVE_IDAT)
{ {
if (png_ptr->push_length == 0) if (png_ptr->push_length == 0)
@@ -264,8 +268,8 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_push_save_buffer(png_ptr); png_push_save_buffer(png_ptr);
return; return;
} }
png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length); png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length);
png_ptr->process_mode = PNG_READ_DONE_MODE; png_ptr->process_mode = PNG_READ_DONE_MODE;
png_push_have_end(png_ptr, info_ptr); png_push_have_end(png_ptr, info_ptr);
} }
@@ -277,7 +281,6 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_push_save_buffer(png_ptr); png_push_save_buffer(png_ptr);
return; return;
} }
png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length); png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length);
} }
#endif #endif
@@ -289,7 +292,6 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_push_save_buffer(png_ptr); png_push_save_buffer(png_ptr);
return; return;
} }
png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length); png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length);
} }
#endif #endif
@@ -301,7 +303,6 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_push_save_buffer(png_ptr); png_push_save_buffer(png_ptr);
return; return;
} }
png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length); png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length);
} }
#endif #endif
@@ -313,7 +314,6 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_push_save_buffer(png_ptr); png_push_save_buffer(png_ptr);
return; return;
} }
png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length); png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length);
} }
#endif #endif
@@ -325,7 +325,6 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_push_save_buffer(png_ptr); png_push_save_buffer(png_ptr);
return; return;
} }
png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length); png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length);
} }
#endif #endif
@@ -337,7 +336,6 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_push_save_buffer(png_ptr); png_push_save_buffer(png_ptr);
return; return;
} }
png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length); png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length);
} }
#endif #endif
@@ -349,7 +347,6 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_push_save_buffer(png_ptr); png_push_save_buffer(png_ptr);
return; return;
} }
png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length); png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length);
} }
#endif #endif
@@ -361,7 +358,6 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_push_save_buffer(png_ptr); png_push_save_buffer(png_ptr);
return; return;
} }
png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length); png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length);
} }
#endif #endif
@@ -373,7 +369,6 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_push_save_buffer(png_ptr); png_push_save_buffer(png_ptr);
return; return;
} }
png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length); png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length);
} }
#endif #endif
@@ -385,7 +380,6 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_push_save_buffer(png_ptr); png_push_save_buffer(png_ptr);
return; return;
} }
png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length); png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length);
} }
#endif #endif
@@ -397,7 +391,6 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_push_save_buffer(png_ptr); png_push_save_buffer(png_ptr);
return; return;
} }
png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length); png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length);
} }
#endif #endif
@@ -409,7 +402,6 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_push_save_buffer(png_ptr); png_push_save_buffer(png_ptr);
return; return;
} }
png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length); png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length);
} }
#endif #endif
@@ -421,7 +413,6 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_push_save_buffer(png_ptr); png_push_save_buffer(png_ptr);
return; return;
} }
png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length); png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length);
} }
#endif #endif
@@ -433,30 +424,49 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_push_save_buffer(png_ptr); png_push_save_buffer(png_ptr);
return; return;
} }
png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length); png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length);
} }
#endif #endif
#if defined(PNG_READ_tEXt_SUPPORTED) #if defined(PNG_READ_tEXt_SUPPORTED)
else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
png_push_save_buffer(png_ptr);
return;
}
png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length); png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length);
} }
#endif #endif
#if defined(PNG_READ_zTXt_SUPPORTED) #if defined(PNG_READ_zTXt_SUPPORTED)
else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
png_push_save_buffer(png_ptr);
return;
}
png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length); png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);
} }
#endif #endif
#if defined(PNG_READ_iTXt_SUPPORTED) #if defined(PNG_READ_iTXt_SUPPORTED)
else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
png_push_save_buffer(png_ptr);
return;
}
png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length); png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
} }
#endif #endif
else else
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
{
png_push_save_buffer(png_ptr);
return;
}
png_push_handle_unknown(png_ptr, info_ptr, png_ptr->push_length); png_push_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);
} }
@@ -518,7 +528,7 @@ png_push_crc_finish(png_structp png_ptr)
} }
} }
void /* PRIVATE */ void PNGAPI
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;
@@ -736,6 +746,13 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
} }
if (!(png_ptr->zstream.avail_out)) if (!(png_ptr->zstream.avail_out))
{ {
if ((
#if defined(PNG_READ_INTERLACING_SUPPORTED)
png_ptr->interlaced && png_ptr->pass > 6) ||
(!png_ptr->interlaced &&
#endif
png_ptr->row_number == png_ptr->num_rows-1))
png_error(png_ptr, "Too much data in IDAT chunks");
png_push_process_row(png_ptr); png_push_process_row(png_ptr);
png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes;
png_ptr->zstream.next_out = png_ptr->row_buf; png_ptr->zstream.next_out = png_ptr->row_buf;
@@ -792,10 +809,23 @@ png_push_process_row(png_structp png_ptr)
{ {
for (i = 0; i < 4 && png_ptr->pass == 2; i++) for (i = 0; i < 4 && png_ptr->pass == 2; i++)
{ {
png_push_have_row(png_ptr, NULL); png_push_have_row(png_ptr, png_bytep_NULL);
png_read_push_finish_row(png_ptr); png_read_push_finish_row(png_ptr);
} }
} }
if (png_ptr->pass == 4 && png_ptr->height <= 4)
{
for (i = 0; i < 2 && png_ptr->pass == 4; i++)
{
png_push_have_row(png_ptr, png_bytep_NULL);
png_read_push_finish_row(png_ptr);
}
}
if (png_ptr->pass == 6 && png_ptr->height <= 4)
{
png_push_have_row(png_ptr, png_bytep_NULL);
png_read_push_finish_row(png_ptr);
}
break; break;
} }
case 1: case 1:
@@ -810,7 +840,7 @@ png_push_process_row(png_structp png_ptr)
{ {
for (i = 0; i < 4 && png_ptr->pass == 2; i++) for (i = 0; i < 4 && png_ptr->pass == 2; i++)
{ {
png_push_have_row(png_ptr, NULL); png_push_have_row(png_ptr, png_bytep_NULL);
png_read_push_finish_row(png_ptr); png_read_push_finish_row(png_ptr);
} }
} }
@@ -826,14 +856,14 @@ png_push_process_row(png_structp png_ptr)
} }
for (i = 0; i < 4 && png_ptr->pass == 2; i++) for (i = 0; i < 4 && png_ptr->pass == 2; i++)
{ {
png_push_have_row(png_ptr, NULL); png_push_have_row(png_ptr, png_bytep_NULL);
png_read_push_finish_row(png_ptr); png_read_push_finish_row(png_ptr);
} }
if (png_ptr->pass == 4) /* pass 3 might be empty */ if (png_ptr->pass == 4) /* pass 3 might be empty */
{ {
for (i = 0; i < 2 && png_ptr->pass == 4; i++) for (i = 0; i < 2 && png_ptr->pass == 4; i++)
{ {
png_push_have_row(png_ptr, NULL); png_push_have_row(png_ptr, png_bytep_NULL);
png_read_push_finish_row(png_ptr); png_read_push_finish_row(png_ptr);
} }
} }
@@ -851,7 +881,7 @@ png_push_process_row(png_structp png_ptr)
{ {
for (i = 0; i < 2 && png_ptr->pass == 4; i++) for (i = 0; i < 2 && png_ptr->pass == 4; i++)
{ {
png_push_have_row(png_ptr, NULL); png_push_have_row(png_ptr, png_bytep_NULL);
png_read_push_finish_row(png_ptr); png_read_push_finish_row(png_ptr);
} }
} }
@@ -867,12 +897,12 @@ png_push_process_row(png_structp png_ptr)
} }
for (i = 0; i < 2 && png_ptr->pass == 4; i++) for (i = 0; i < 2 && png_ptr->pass == 4; i++)
{ {
png_push_have_row(png_ptr, NULL); png_push_have_row(png_ptr, png_bytep_NULL);
png_read_push_finish_row(png_ptr); png_read_push_finish_row(png_ptr);
} }
if (png_ptr->pass == 6) /* pass 5 might be empty */ if (png_ptr->pass == 6) /* pass 5 might be empty */
{ {
png_push_have_row(png_ptr, NULL); png_push_have_row(png_ptr, png_bytep_NULL);
png_read_push_finish_row(png_ptr); png_read_push_finish_row(png_ptr);
} }
break; break;
@@ -887,7 +917,7 @@ png_push_process_row(png_structp png_ptr)
} }
if (png_ptr->pass == 6) /* skip top generated row */ if (png_ptr->pass == 6) /* skip top generated row */
{ {
png_push_have_row(png_ptr, NULL); png_push_have_row(png_ptr, png_bytep_NULL);
png_read_push_finish_row(png_ptr); png_read_push_finish_row(png_ptr);
} }
break; break;
@@ -898,7 +928,7 @@ png_push_process_row(png_structp png_ptr)
png_read_push_finish_row(png_ptr); png_read_push_finish_row(png_ptr);
if (png_ptr->pass != 6) if (png_ptr->pass != 6)
break; break;
png_push_have_row(png_ptr, NULL); png_push_have_row(png_ptr, png_bytep_NULL);
png_read_push_finish_row(png_ptr); png_read_push_finish_row(png_ptr);
} }
} }
@@ -982,7 +1012,8 @@ png_read_push_finish_row(png_structp png_ptr)
#if defined(PNG_READ_tEXt_SUPPORTED) #if defined(PNG_READ_tEXt_SUPPORTED)
void /* PRIVATE */ 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))
{ {
@@ -994,7 +1025,7 @@ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length
#ifdef PNG_MAX_MALLOC_64K #ifdef PNG_MAX_MALLOC_64K
png_ptr->skip_length = 0; /* This may not be necessary */ png_ptr->skip_length = 0; /* This may not be necessary */
if (length > (png_uint_32)65535L) /* Can't hold the entire string in memory */ if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */
{ {
png_warning(png_ptr, "tEXt chunk too large to fit in memory"); png_warning(png_ptr, "tEXt chunk too large to fit in memory");
png_ptr->skip_length = length - (png_uint_32)65535L; png_ptr->skip_length = length - (png_uint_32)65535L;
@@ -1031,6 +1062,7 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
png_textp text_ptr; png_textp text_ptr;
png_charp text; png_charp text;
png_charp key; png_charp key;
int ret;
if (png_ptr->buffer_size < 4) if (png_ptr->buffer_size < 4)
{ {
@@ -1046,7 +1078,6 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
#endif #endif
key = png_ptr->current_text; key = png_ptr->current_text;
png_ptr->current_text = 0;
for (text = key; *text; text++) for (text = key; *text; text++)
/* empty loop */ ; /* empty loop */ ;
@@ -1058,22 +1089,27 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
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 #ifdef PNG_iTXt_SUPPORTED
text_ptr->lang = (char *)NULL; text_ptr->lang = NULL;
text_ptr->lang_key = (char *)NULL; text_ptr->lang_key = NULL;
#endif #endif
text_ptr->text = text; text_ptr->text = text;
png_set_text(png_ptr, info_ptr, text_ptr, 1); ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
png_free(png_ptr, key); png_free(png_ptr, key);
png_free(png_ptr, text_ptr); png_free(png_ptr, text_ptr);
png_ptr->current_text = NULL;
if (ret)
png_warning(png_ptr, "Insufficient memory to store text chunk.");
} }
} }
#endif #endif
#if defined(PNG_READ_zTXt_SUPPORTED) #if defined(PNG_READ_zTXt_SUPPORTED)
void /* PRIVATE */ 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))
{ {
@@ -1136,7 +1172,6 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
png_push_crc_finish(png_ptr); png_push_crc_finish(png_ptr);
key = png_ptr->current_text; key = png_ptr->current_text;
png_ptr->current_text = 0;
for (text = key; *text; text++) for (text = key; *text; text++)
/* empty loop */ ; /* empty loop */ ;
@@ -1144,6 +1179,7 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
/* zTXt can't have zero text */ /* zTXt can't have zero text */
if (text == key + png_ptr->current_text_size) if (text == key + png_ptr->current_text_size)
{ {
png_ptr->current_text = NULL;
png_free(png_ptr, key); png_free(png_ptr, key);
return; return;
} }
@@ -1152,6 +1188,7 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
if (*text != PNG_TEXT_COMPRESSION_zTXt) /* check compression byte */ if (*text != PNG_TEXT_COMPRESSION_zTXt) /* check compression byte */
{ {
png_ptr->current_text = NULL;
png_free(png_ptr, key); png_free(png_ptr, key);
return; return;
} }
@@ -1176,6 +1213,7 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
{ {
inflateReset(&png_ptr->zstream); inflateReset(&png_ptr->zstream);
png_ptr->zstream.avail_in = 0; png_ptr->zstream.avail_in = 0;
png_ptr->current_text = NULL;
png_free(png_ptr, key); png_free(png_ptr, key);
png_free(png_ptr, text); png_free(png_ptr, text);
return; return;
@@ -1185,8 +1223,8 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
if (text == NULL) if (text == NULL)
{ {
text = (png_charp)png_malloc(png_ptr, text = (png_charp)png_malloc(png_ptr,
(png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out + (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out
key_size + 1)); + key_size + 1));
png_memcpy(text + key_size, png_ptr->zbuf, png_memcpy(text + key_size, png_ptr->zbuf,
png_ptr->zbuf_size - png_ptr->zstream.avail_out); png_ptr->zbuf_size - png_ptr->zstream.avail_out);
png_memcpy(text, key, key_size); png_memcpy(text, key, key_size);
@@ -1229,11 +1267,13 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
if (ret != Z_STREAM_END) if (ret != Z_STREAM_END)
{ {
png_ptr->current_text = NULL;
png_free(png_ptr, key); png_free(png_ptr, key);
png_free(png_ptr, text); png_free(png_ptr, text);
return; return;
} }
png_ptr->current_text = NULL;
png_free(png_ptr, key); png_free(png_ptr, key);
key = text; key = text;
text += key_size; text += key_size;
@@ -1242,22 +1282,26 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
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 #ifdef PNG_iTXt_SUPPORTED
text_ptr->lang = (char *)NULL; text_ptr->lang = NULL;
text_ptr->lang_key = (char *)NULL; text_ptr->lang_key = NULL;
#endif #endif
text_ptr->text = text; text_ptr->text = text;
png_set_text(png_ptr, info_ptr, text_ptr, 1); ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
png_free(png_ptr, key); png_free(png_ptr, key);
png_free(png_ptr, text_ptr); png_free(png_ptr, text_ptr);
if (ret)
png_warning(png_ptr, "Insufficient memory to store text chunk.");
} }
} }
#endif #endif
#if defined(PNG_READ_iTXt_SUPPORTED) #if defined(PNG_READ_iTXt_SUPPORTED)
void /* PRIVATE */ 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))
{ {
@@ -1269,7 +1313,7 @@ png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length
#ifdef PNG_MAX_MALLOC_64K #ifdef PNG_MAX_MALLOC_64K
png_ptr->skip_length = 0; /* This may not be necessary */ png_ptr->skip_length = 0; /* This may not be necessary */
if (length > (png_uint_32)65535L) /* Can't hold the entire string in memory */ if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */
{ {
png_warning(png_ptr, "iTXt chunk too large to fit in memory"); png_warning(png_ptr, "iTXt chunk too large to fit in memory");
png_ptr->skip_length = length - (png_uint_32)65535L; png_ptr->skip_length = length - (png_uint_32)65535L;
@@ -1310,6 +1354,7 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
png_charp lang; png_charp lang;
png_charp lang_key; png_charp lang_key;
png_charp text; png_charp text;
int ret;
if (png_ptr->buffer_size < 4) if (png_ptr->buffer_size < 4)
{ {
@@ -1325,7 +1370,6 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
#endif #endif
key = png_ptr->current_text; key = png_ptr->current_text;
png_ptr->current_text = 0;
for (lang = key; *lang; lang++) for (lang = key; *lang; lang++)
/* empty loop */ ; /* empty loop */ ;
@@ -1355,9 +1399,13 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
text_ptr->text_length = 0; text_ptr->text_length = 0;
text_ptr->itxt_length = png_strlen(text); text_ptr->itxt_length = png_strlen(text);
png_set_text(png_ptr, info_ptr, text_ptr, 1); ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
png_ptr->current_text = NULL;
png_free(png_ptr, text_ptr); png_free(png_ptr, text_ptr);
if (ret)
png_warning(png_ptr, "Insufficient memory to store iTXt chunk.");
} }
} }
#endif #endif
@@ -1367,7 +1415,8 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
* name or a critical chunk), the chunk is (currently) silently ignored. * name or a critical chunk), the chunk is (currently) silently ignored.
*/ */
void /* PRIVATE */ 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;
png_check_chunk_name(png_ptr, png_ptr->chunk_name); png_check_chunk_name(png_ptr, png_ptr->chunk_name);
@@ -1378,7 +1427,7 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 len
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 == NULL
#endif #endif
) )
#endif #endif
@@ -1403,12 +1452,12 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 len
} }
#endif #endif
strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name); png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name);
chunk.data = (png_bytep)png_malloc(png_ptr, length); chunk.data = (png_bytep)png_malloc(png_ptr, length);
png_crc_read(png_ptr, chunk.data, length); png_crc_read(png_ptr, chunk.data, length);
chunk.size = length; chunk.size = length;
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) #if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
if(png_ptr->read_user_chunk_fn != (png_user_chunk_ptr)NULL) if(png_ptr->read_user_chunk_fn != NULL)
{ {
/* callback to user unknown chunk handler */ /* callback to user unknown chunk handler */
if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0) if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0)
@@ -1482,6 +1531,4 @@ png_get_progressive_ptr(png_structp png_ptr)
{ {
return png_ptr->io_ptr; return png_ptr->io_ptr;
} }
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */

213
pngread.c
View File

@@ -1,9 +1,9 @@
/* pngread.c - read a PNG file /* pngread.c - read a PNG file
* *
* libpng 1.0.9 - January 31, 2001 * libpng 1.0.14 - July 8, 2002
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2002 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
@@ -22,7 +22,7 @@ png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr,
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
return (png_create_read_struct_2(user_png_ver, error_ptr, error_fn, return (png_create_read_struct_2(user_png_ver, error_ptr, error_fn,
warn_fn, NULL, NULL, NULL)); warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL));
} }
/* Alternate create PNG structure for reading, and allocate any memory needed. */ /* Alternate create PNG structure for reading, and allocate any memory needed. */
@@ -45,14 +45,19 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
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, png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
(png_malloc_ptr)malloc_fn)) == NULL) (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr);
#else #else
if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL) png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
#endif #endif
{ if (png_ptr == NULL)
return (png_structp)NULL; return (NULL);
}
#if !defined(PNG_1_0_X)
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
png_init_mmx_flags(png_ptr); /* 1.2.0 addition */
#endif
#endif /* PNG_1_0_X */
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
#ifdef USE_FAR_KEYWORD #ifdef USE_FAR_KEYWORD
@@ -63,8 +68,13 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
{ {
png_free(png_ptr, png_ptr->zbuf); png_free(png_ptr, png_ptr->zbuf);
png_ptr->zbuf=NULL; png_ptr->zbuf=NULL;
png_destroy_struct(png_ptr); #ifdef PNG_USER_MEM_SUPPORTED
return (png_structp)NULL; png_destroy_struct_2((png_voidp)png_ptr,
(png_free_ptr)free_fn, (png_voidp)mem_ptr);
#else
png_destroy_struct((png_voidp)png_ptr);
#endif
return (NULL);
} }
#ifdef USE_FAR_KEYWORD #ifdef USE_FAR_KEYWORD
png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf)); png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
@@ -92,23 +102,27 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
* only check the first digit. * only check the first digit.
*/ */
if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
(user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) ||
(user_png_ver[0] == '0' && user_png_ver[2] < '9')) (user_png_ver[0] == '0' && user_png_ver[2] < '9'))
{ {
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
char msg[80];
if (user_png_ver)
{
sprintf(msg, "Application was compiled with png.h from libpng-%.20s",
user_png_ver);
png_warning(png_ptr, msg);
}
sprintf(msg, "Application is running with png.c from libpng-%.20s",
png_libpng_ver);
png_warning(png_ptr, msg);
#endif
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
png_ptr->flags=0;
#endif
png_error(png_ptr, png_error(png_ptr,
"Incompatible libpng version in application and library"); "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 */
@@ -131,8 +145,21 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.next_out = png_ptr->zbuf;
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
png_set_read_fn(png_ptr, NULL, NULL); png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL);
#ifdef PNG_SETJMP_SUPPORTED
/* Applications that neglect to set up their own setjmp() and then encounter
a png_error() will longjmp here. Since the jmpbuf is then meaningless we
abort instead of returning. */
#ifdef USE_FAR_KEYWORD
if (setjmp(jmpbuf))
PNG_ABORT();
png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
#else
if (setjmp(png_ptr->jmpbuf))
PNG_ABORT();
#endif
#endif
return (png_ptr); return (png_ptr);
} }
@@ -144,18 +171,63 @@ 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 */ /* We only come here via pre-1.0.7-compiled applications */
png_read_init_2(png_ptr, "1.0.0", 10000, 10000); png_read_init_2(png_ptr, "1.0.6 or earlier", 0, 0);
} }
void PNGAPI void PNGAPI
png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver, 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) png_size_t png_struct_size, png_size_t png_info_size)
{
/* We only come here via pre-1.0.12-compiled applications */
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
if(sizeof(png_struct) > png_struct_size || sizeof(png_info) > png_info_size)
{
char msg[80];
png_ptr->warning_fn=NULL;
if (user_png_ver)
{
sprintf(msg, "Application was compiled with png.h from libpng-%.20s",
user_png_ver);
png_warning(png_ptr, msg);
}
sprintf(msg, "Application is running with png.c from libpng-%.20s",
png_libpng_ver);
png_warning(png_ptr, msg);
}
#endif
if(sizeof(png_struct) > png_struct_size)
{
png_ptr->error_fn=NULL;
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
png_ptr->flags=0;
#endif
png_error(png_ptr,
"The png struct allocated by the application for reading is too small.");
}
if(sizeof(png_info) > png_info_size)
{
png_ptr->error_fn=NULL;
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
png_ptr->flags=0;
#endif
png_error(png_ptr,
"The info struct allocated by application for reading is too small.");
}
png_read_init_3(&png_ptr, user_png_ver, png_struct_size);
}
void PNGAPI
png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
png_size_t png_struct_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; int i=0;
png_structp png_ptr=*ptr_ptr;
do do
{ {
if(user_png_ver[i] != png_libpng_ver[i]) if(user_png_ver[i] != png_libpng_ver[i])
@@ -163,28 +235,28 @@ png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver,
#ifdef PNG_LEGACY_SUPPORTED #ifdef PNG_LEGACY_SUPPORTED
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
#else #else
png_ptr->error_fn=(png_error_ptr)NULL; png_ptr->warning_fn=NULL;
png_error(png_ptr, png_warning(png_ptr,
"Application uses deprecated png_read_init() and must be recompiled."); "Application uses deprecated png_read_init() and should be recompiled.");
break;
#endif #endif
} }
} while (png_libpng_ver[i++]); } while (png_libpng_ver[i++]);
if(sizeof(png_struct) > png_struct_size || png_debug(1, "in png_read_init_3\n");
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 */
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf)); png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
#endif #endif
if(sizeof(png_struct) > png_struct_size)
{
png_destroy_struct(png_ptr);
*ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
png_ptr = *ptr_ptr;
}
/* reset all variables to 0 */ /* reset all variables to 0 */
png_memset(png_ptr, 0, sizeof (png_struct)); png_memset(png_ptr, 0, sizeof (png_struct));
@@ -213,7 +285,7 @@ png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver,
png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.next_out = png_ptr->zbuf;
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
png_set_read_fn(png_ptr, NULL, NULL); png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL);
} }
/* Read the information before the actual image data. This has been /* Read the information before the actual image data. This has been
@@ -228,7 +300,6 @@ 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");
/* save jump buffer and error functions */
/* If we haven't checked all of the PNG signature bytes, do so now. */ /* If we haven't checked all of the PNG signature bytes, do so now. */
if (png_ptr->sig_bytes < 8) if (png_ptr->sig_bytes < 8)
{ {
@@ -321,6 +392,9 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
png_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name, png_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name,
length); length);
if (length > PNG_MAX_UINT)
png_error(png_ptr, "Invalid chunk length.");
/* This should be a binary subdivision search or a hash for /* This should be a binary subdivision search or a hash for
* matching the chunk name rather than a linear search. * matching the chunk name rather than a linear search.
*/ */
@@ -439,7 +513,6 @@ 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 */
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 else
@@ -457,7 +530,6 @@ 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");
/* 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);
} }
@@ -473,7 +545,6 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
int ret; int ret;
png_debug2(1, "in png_read_row (row %lu, 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 */
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);
if (png_ptr->row_number == 0 && png_ptr->pass == 0) if (png_ptr->row_number == 0 && png_ptr->pass == 0)
@@ -604,6 +675,9 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
png_read_data(png_ptr, chunk_length, 4); png_read_data(png_ptr, chunk_length, 4);
png_ptr->idat_size = png_get_uint_32(chunk_length); png_ptr->idat_size = png_get_uint_32(chunk_length);
if (png_ptr->idat_size > PNG_MAX_UINT)
png_error(png_ptr, "Invalid chunk length.");
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);
if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
@@ -715,7 +789,7 @@ 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.9 * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.14
*/ */
void PNGAPI void PNGAPI
@@ -727,7 +801,6 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
png_bytepp dp; png_bytepp dp;
png_debug(1, "in png_read_rows\n"); png_debug(1, "in png_read_rows\n");
/* save jump buffer and error functions */
rp = row; rp = row;
dp = display_row; dp = display_row;
if (rp != NULL && dp != NULL) if (rp != NULL && dp != NULL)
@@ -742,14 +815,14 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
for (i = 0; i < num_rows; i++) for (i = 0; i < num_rows; i++)
{ {
png_bytep rptr = *rp; png_bytep rptr = *rp;
png_read_row(png_ptr, rptr, NULL); png_read_row(png_ptr, rptr, png_bytep_NULL);
rp++; rp++;
} }
else if(dp != NULL) else if(dp != NULL)
for (i = 0; i < num_rows; i++) for (i = 0; i < num_rows; i++)
{ {
png_bytep dptr = *dp; png_bytep dptr = *dp;
png_read_row(png_ptr, NULL, dptr); png_read_row(png_ptr, png_bytep_NULL, dptr);
dp++; dp++;
} }
} }
@@ -764,7 +837,7 @@ 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.9 * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.14
*/ */
void PNGAPI void PNGAPI
png_read_image(png_structp png_ptr, png_bytepp image) png_read_image(png_structp png_ptr, png_bytepp image)
@@ -774,7 +847,6 @@ png_read_image(png_structp png_ptr, png_bytepp image)
png_bytepp rp; png_bytepp rp;
png_debug(1, "in png_read_image\n"); png_debug(1, "in png_read_image\n");
/* save jump buffer and error functions */
#ifdef PNG_READ_INTERLACING_SUPPORTED #ifdef PNG_READ_INTERLACING_SUPPORTED
pass = png_set_interlace_handling(png_ptr); pass = png_set_interlace_handling(png_ptr);
@@ -794,7 +866,7 @@ png_read_image(png_structp png_ptr, png_bytepp image)
rp = image; rp = image;
for (i = 0; i < image_height; i++) for (i = 0; i < image_height; i++)
{ {
png_read_row(png_ptr, *rp, NULL); png_read_row(png_ptr, *rp, png_bytep_NULL);
rp++; rp++;
} }
} }
@@ -811,7 +883,6 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
png_uint_32 length; png_uint_32 length;
png_debug(1, "in png_read_end\n"); png_debug(1, "in png_read_end\n");
/* save jump buffer and error functions */
png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */ png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */
do do
@@ -882,6 +953,9 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
png_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name); png_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name);
if (length > PNG_MAX_UINT)
png_error(png_ptr, "Invalid chunk length.");
if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
png_handle_IHDR(png_ptr, info_ptr, length); png_handle_IHDR(png_ptr, info_ptr, length);
else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
@@ -994,10 +1068,10 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
png_infop info_ptr = NULL, end_info_ptr = NULL; png_infop info_ptr = NULL, end_info_ptr = NULL;
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
png_free_ptr free_fn = NULL; png_free_ptr free_fn = NULL;
png_voidp mem_ptr = NULL;
#endif #endif
png_debug(1, "in png_destroy_read_struct\n"); png_debug(1, "in png_destroy_read_struct\n");
/* save jump buffer and error functions */
if (png_ptr_ptr != NULL) if (png_ptr_ptr != NULL)
png_ptr = *png_ptr_ptr; png_ptr = *png_ptr_ptr;
@@ -1009,6 +1083,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
free_fn = png_ptr->free_fn; free_fn = png_ptr->free_fn;
mem_ptr = png_ptr->mem_ptr;
#endif #endif
png_read_destroy(png_ptr, info_ptr, end_info_ptr); png_read_destroy(png_ptr, info_ptr, end_info_ptr);
@@ -1020,11 +1095,12 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
#endif #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, (png_free_ptr)free_fn,
(png_voidp)mem_ptr);
#else #else
png_destroy_struct((png_voidp)info_ptr); png_destroy_struct((png_voidp)info_ptr);
#endif #endif
*info_ptr_ptr = (png_infop)NULL; *info_ptr_ptr = NULL;
} }
if (end_info_ptr != NULL) if (end_info_ptr != NULL)
@@ -1033,26 +1109,28 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1); png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1);
#endif #endif
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)end_info_ptr, free_fn); png_destroy_struct_2((png_voidp)end_info_ptr, (png_free_ptr)free_fn,
(png_voidp)mem_ptr);
#else #else
png_destroy_struct((png_voidp)end_info_ptr); png_destroy_struct((png_voidp)end_info_ptr);
#endif #endif
*end_info_ptr_ptr = (png_infop)NULL; *end_info_ptr_ptr = NULL;
} }
if (png_ptr != NULL) if (png_ptr != NULL)
{ {
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)png_ptr, free_fn); png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,
(png_voidp)mem_ptr);
#else #else
png_destroy_struct((png_voidp)png_ptr); png_destroy_struct((png_voidp)png_ptr);
#endif #endif
*png_ptr_ptr = (png_structp)NULL; *png_ptr_ptr = NULL;
} }
} }
/* free all memory used by the read (old method) */ /* free all memory used by the read (old method) */
void PNGAPI void /* PRIVATE */
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
@@ -1066,7 +1144,6 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
#endif #endif
png_debug(1, "in png_read_destroy\n"); png_debug(1, "in png_read_destroy\n");
/* save jump buffer and error functions */
if (info_ptr != NULL) if (info_ptr != NULL)
png_info_destroy(png_ptr, info_ptr); png_info_destroy(png_ptr, info_ptr);
@@ -1074,7 +1151,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
png_info_destroy(png_ptr, end_info_ptr); png_info_destroy(png_ptr, end_info_ptr);
png_free(png_ptr, png_ptr->zbuf); png_free(png_ptr, png_ptr->zbuf);
png_free(png_ptr, png_ptr->row_buf); png_free(png_ptr, png_ptr->big_row_buf);
png_free(png_ptr, png_ptr->prev_row); png_free(png_ptr, png_ptr->prev_row);
#if defined(PNG_READ_DITHER_SUPPORTED) #if defined(PNG_READ_DITHER_SUPPORTED)
png_free(png_ptr, png_ptr->palette_lookup); png_free(png_ptr, png_ptr->palette_lookup);
@@ -1162,6 +1239,12 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
png_free(png_ptr, png_ptr->save_buffer); png_free(png_ptr, png_ptr->save_buffer);
#endif #endif
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
#ifdef PNG_TEXT_SUPPORTED
png_free(png_ptr, png_ptr->current_text);
#endif /* PNG_TEXT_SUPPORTED */
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
/* Save the important info out of the png_struct, in case it is /* Save the important info out of the png_struct, in case it is
* being used again. * being used again.
*/ */
@@ -1305,7 +1388,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
/* Optional call to gamma correct and add the background to the palette /* Optional call to gamma correct and add the background to the palette
* and update info structure. REQUIRED if you are expecting libpng to * and update info structure. REQUIRED if you are expecting libpng to
* update the palette for you (ie you selected such a transform above). * update the palette for you (i.e., you selected such a transform above).
*/ */
png_read_update_info(png_ptr, info_ptr); png_read_update_info(png_ptr, info_ptr);
@@ -1317,13 +1400,15 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
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 #ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_ROWS; info_ptr->free_me |= PNG_FREE_ROWS;
#endif #endif
for (row = 0; row < (int)info_ptr->height; row++) for (row = 0; row < (int)info_ptr->height; row++)
info_ptr->row_pointers[row] = png_malloc(png_ptr, {
info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr,
png_get_rowbytes(png_ptr, info_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);
@@ -1332,7 +1417,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
/* read rest of file, and get additional chunks in info_ptr - REQUIRED */ /* read rest of file, and get additional chunks in info_ptr - REQUIRED */
png_read_end(png_ptr, info_ptr); png_read_end(png_ptr, info_ptr);
if(transforms == 0 || params == (voidp)NULL) if(transforms == 0 || params == NULL)
/* quiet compiler warnings */ return; /* quiet compiler warnings */ return;
} }

View File

@@ -1,9 +1,9 @@
/* pngrio.c - functions for data input /* pngrio.c - functions for data input
* *
* libpng 1.0.9 - January 31, 2001 * libpng 1.0.14 - July 8, 2002
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2002 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
@@ -26,7 +26,7 @@
void /* PRIVATE */ 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", (int)length);
if (png_ptr->read_data_fn != NULL) if (png_ptr->read_data_fn != NULL)
(*(png_ptr->read_data_fn))(png_ptr, data, length); (*(png_ptr->read_data_fn))(png_ptr, data, length);
else else
@@ -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 /* PRIVATE */ void PNGAPI
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;
@@ -159,4 +159,3 @@ png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
png_ptr->output_flush_fn = NULL; png_ptr->output_flush_fn = NULL;
#endif #endif
} }

View File

@@ -1,9 +1,9 @@
/* 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.9 - January 31, 2001 * libpng 1.0.14 - July 8, 2002
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2002 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
@@ -167,15 +167,14 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
Perhaps not the best solution, but good enough. */ Perhaps not the best solution, but good enough. */
int i; int i;
png_bytep sort;
/* initialize an array to sort colors */ /* initialize an array to sort colors */
sort = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_palette png_ptr->dither_sort = (png_bytep)png_malloc(png_ptr,
* sizeof (png_byte))); (png_uint_32)(num_palette * sizeof (png_byte)));
/* initialize the sort array */ /* initialize the dither_sort array */
for (i = 0; i < num_palette; i++) for (i = 0; i < num_palette; i++)
sort[i] = (png_byte)i; png_ptr->dither_sort[i] = (png_byte)i;
/* Find the least used palette entries by starting a /* Find the least used palette entries by starting a
bubble sort, and running it until we have sorted bubble sort, and running it until we have sorted
@@ -191,13 +190,14 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
done = 1; done = 1;
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
{ {
if (histogram[sort[j]] < histogram[sort[j + 1]]) if (histogram[png_ptr->dither_sort[j]]
< histogram[png_ptr->dither_sort[j + 1]])
{ {
png_byte t; png_byte t;
t = sort[j]; t = png_ptr->dither_sort[j];
sort[j] = sort[j + 1]; png_ptr->dither_sort[j] = png_ptr->dither_sort[j + 1];
sort[j + 1] = t; png_ptr->dither_sort[j + 1] = t;
done = 0; done = 0;
} }
} }
@@ -214,11 +214,11 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
move the others */ move the others */
for (i = 0; i < maximum_colors; i++) for (i = 0; i < maximum_colors; i++)
{ {
if ((int)sort[i] >= maximum_colors) if ((int)png_ptr->dither_sort[i] >= maximum_colors)
{ {
do do
j--; j--;
while ((int)sort[j] >= maximum_colors); while ((int)png_ptr->dither_sort[j] >= maximum_colors);
palette[i] = palette[j]; palette[i] = palette[j];
} }
} }
@@ -232,13 +232,13 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
for (i = 0; i < maximum_colors; i++) for (i = 0; i < maximum_colors; i++)
{ {
/* only move the colors we need to */ /* only move the colors we need to */
if ((int)sort[i] >= maximum_colors) if ((int)png_ptr->dither_sort[i] >= maximum_colors)
{ {
png_color tmp_color; png_color tmp_color;
do do
j--; j--;
while ((int)sort[j] >= maximum_colors); while ((int)png_ptr->dither_sort[j] >= maximum_colors);
tmp_color = palette[j]; tmp_color = palette[j];
palette[j] = palette[i]; palette[j] = palette[i];
@@ -276,7 +276,8 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
} }
} }
} }
png_free(png_ptr, sort); png_free(png_ptr, png_ptr->dither_sort);
png_ptr->dither_sort=NULL;
} }
else else
{ {
@@ -291,23 +292,22 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
int i; int i;
int max_d; int max_d;
int num_new_palette; int num_new_palette;
png_dsortp t;
png_dsortpp hash; png_dsortpp hash;
png_bytep index_to_palette;
/* where the original index currently is in the palette */ t=NULL;
png_bytep palette_to_index;
/* which original index points to this palette color */
/* initialize palette index arrays */ /* initialize palette index arrays */
index_to_palette = (png_bytep)png_malloc(png_ptr, png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
(png_uint_32)(num_palette * sizeof (png_byte))); (png_uint_32)(num_palette * sizeof (png_byte)));
palette_to_index = (png_bytep)png_malloc(png_ptr, png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
(png_uint_32)(num_palette * sizeof (png_byte))); (png_uint_32)(num_palette * sizeof (png_byte)));
/* initialize the sort array */ /* initialize the sort array */
for (i = 0; i < num_palette; i++) for (i = 0; i < num_palette; i++)
{ {
index_to_palette[i] = (png_byte)i; png_ptr->index_to_palette[i] = (png_byte)i;
palette_to_index[i] = (png_byte)i; png_ptr->palette_to_index[i] = (png_byte)i;
} }
hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 * hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 *
@@ -342,18 +342,22 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
if (d <= max_d) if (d <= max_d)
{ {
png_dsortp t;
t = (png_dsortp)png_malloc(png_ptr, (png_uint_32)(sizeof t = (png_dsortp)png_malloc_warn(png_ptr,
(png_dsort))); (png_uint_32)(sizeof(png_dsort)));
if (t == NULL)
break;
t->next = hash[d]; t->next = hash[d];
t->left = (png_byte)i; t->left = (png_byte)i;
t->right = (png_byte)j; t->right = (png_byte)j;
hash[d] = t; hash[d] = t;
} }
} }
if (t == NULL)
break;
} }
if (t != NULL)
for (i = 0; i <= max_d; i++) for (i = 0; i <= max_d; i++)
{ {
if (hash[i] != NULL) if (hash[i] != NULL)
@@ -362,8 +366,10 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
for (p = hash[i]; p; p = p->next) for (p = hash[i]; p; p = p->next)
{ {
if ((int)index_to_palette[p->left] < num_new_palette && if ((int)png_ptr->index_to_palette[p->left]
(int)index_to_palette[p->right] < num_new_palette) < num_new_palette &&
(int)png_ptr->index_to_palette[p->right]
< num_new_palette)
{ {
int j, next_j; int j, next_j;
@@ -379,7 +385,8 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
} }
num_new_palette--; num_new_palette--;
palette[index_to_palette[j]] = palette[num_new_palette]; palette[png_ptr->index_to_palette[j]]
= palette[num_new_palette];
if (!full_dither) if (!full_dither)
{ {
int k; int k;
@@ -387,23 +394,23 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
for (k = 0; k < num_palette; k++) for (k = 0; k < num_palette; k++)
{ {
if (png_ptr->dither_index[k] == if (png_ptr->dither_index[k] ==
index_to_palette[j]) png_ptr->index_to_palette[j])
png_ptr->dither_index[k] = png_ptr->dither_index[k] =
index_to_palette[next_j]; png_ptr->index_to_palette[next_j];
if ((int)png_ptr->dither_index[k] == if ((int)png_ptr->dither_index[k] ==
num_new_palette) num_new_palette)
png_ptr->dither_index[k] = png_ptr->dither_index[k] =
index_to_palette[j]; png_ptr->index_to_palette[j];
} }
} }
index_to_palette[palette_to_index[num_new_palette]] = png_ptr->index_to_palette[png_ptr->palette_to_index
index_to_palette[j]; [num_new_palette]] = png_ptr->index_to_palette[j];
palette_to_index[index_to_palette[j]] = png_ptr->palette_to_index[png_ptr->index_to_palette[j]]
palette_to_index[num_new_palette]; = png_ptr->palette_to_index[num_new_palette];
index_to_palette[j] = (png_byte)num_new_palette; png_ptr->index_to_palette[j] = (png_byte)num_new_palette;
palette_to_index[num_new_palette] = (png_byte)j; png_ptr->palette_to_index[num_new_palette] = (png_byte)j;
} }
if (num_new_palette <= maximum_colors) if (num_new_palette <= maximum_colors)
break; break;
@@ -420,8 +427,6 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
png_dsortp p = hash[i]; png_dsortp p = hash[i];
while (p) while (p)
{ {
png_dsortp t;
t = p->next; t = p->next;
png_free(png_ptr, p); png_free(png_ptr, p);
p = t; p = t;
@@ -432,8 +437,10 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
max_d += 96; max_d += 96;
} }
png_free(png_ptr, hash); png_free(png_ptr, hash);
png_free(png_ptr, palette_to_index); png_free(png_ptr, png_ptr->palette_to_index);
png_free(png_ptr, index_to_palette); png_free(png_ptr, png_ptr->index_to_palette);
png_ptr->palette_to_index=NULL;
png_ptr->index_to_palette=NULL;
} }
num_palette = maximum_colors; num_palette = maximum_colors;
} }
@@ -510,13 +517,19 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
* only do transformations on images where the file_gamma and screen_gamma * only do transformations on images where the file_gamma and screen_gamma
* 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.
*
* We will turn off gamma transformation later if no semitransparent entries
* are present in the tRNS array for palette images. We can't do it here
* because we don't necessarily have the tRNS chunk yet.
*/ */
void PNGAPI 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");
if (fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) ||
png_ptr->transformations |= PNG_GAMMA; (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) ||
(png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))
png_ptr->transformations |= PNG_GAMMA;
png_ptr->gamma = (float)file_gamma; png_ptr->gamma = (float)file_gamma;
png_ptr->screen_gamma = (float)scrn_gamma; png_ptr->screen_gamma = (float)scrn_gamma;
} }
@@ -692,23 +705,23 @@ png_init_read_transformations(png_structp png_ptr)
{ {
case 1: case 1:
png_ptr->background.gray *= (png_uint_16)0xff; png_ptr->background.gray *= (png_uint_16)0xff;
png_ptr->background.red = png_ptr->background.green = png_ptr->background.red = png_ptr->background.green
png_ptr->background.blue = png_ptr->background.gray; = png_ptr->background.blue = png_ptr->background.gray;
break; break;
case 2: case 2:
png_ptr->background.gray *= (png_uint_16)0x55; png_ptr->background.gray *= (png_uint_16)0x55;
png_ptr->background.red = png_ptr->background.green = png_ptr->background.red = png_ptr->background.green
png_ptr->background.blue = png_ptr->background.gray; = png_ptr->background.blue = png_ptr->background.gray;
break; break;
case 4: case 4:
png_ptr->background.gray *= (png_uint_16)0x11; png_ptr->background.gray *= (png_uint_16)0x11;
png_ptr->background.red = png_ptr->background.green = png_ptr->background.red = png_ptr->background.green
png_ptr->background.blue = png_ptr->background.gray; = png_ptr->background.blue = png_ptr->background.gray;
break; break;
case 8: case 8:
case 16: case 16:
png_ptr->background.red = png_ptr->background.green = png_ptr->background.red = png_ptr->background.green
png_ptr->background.blue = png_ptr->background.gray; = png_ptr->background.blue = png_ptr->background.gray;
break; break;
} }
} }
@@ -742,10 +755,26 @@ png_init_read_transformations(png_structp png_ptr)
} }
#endif #endif
#if defined(PNG_READ_BACKGROUND_SUPPORTED) #if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED)
png_ptr->background_1 = png_ptr->background; png_ptr->background_1 = png_ptr->background;
#endif #endif
#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) #if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
if ((color_type == PNG_COLOR_TYPE_PALETTE && png_ptr->num_trans != 0)
&& (fabs(png_ptr->screen_gamma * png_ptr->gamma - 1.0)
< PNG_GAMMA_THRESHOLD))
{
int i,k;
k=0;
for (i=0; i<png_ptr->num_trans; i++)
{
if (png_ptr->trans[i] != 0 && png_ptr->trans[i] != 0xff)
k=1; /* partial transparency is present */
}
if (k == 0)
png_ptr->transformations &= (~PNG_GAMMA);
}
if (png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) if (png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY))
{ {
png_build_gamma_table(png_ptr); png_build_gamma_table(png_ptr);
@@ -754,6 +783,8 @@ png_init_read_transformations(png_structp png_ptr)
{ {
if (color_type == PNG_COLOR_TYPE_PALETTE) if (color_type == PNG_COLOR_TYPE_PALETTE)
{ {
/* could skip if no transparency and
*/
png_color back, back_1; png_color back, back_1;
png_colorp palette = png_ptr->palette; png_colorp palette = png_ptr->palette;
int num_palette = png_ptr->num_palette; int num_palette = png_ptr->num_palette;
@@ -848,7 +879,7 @@ png_init_read_transformations(png_structp png_ptr)
} }
} }
} }
/* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN)*/ /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */
else else
/* color_type != PNG_COLOR_TYPE_PALETTE */ /* color_type != PNG_COLOR_TYPE_PALETTE */
{ {
@@ -873,9 +904,16 @@ png_init_read_transformations(png_structp png_ptr)
break; break;
} }
if (color_type & PNG_COLOR_MASK_COLOR) png_ptr->background_1.gray = (png_uint_16)(pow(
(double)png_ptr->background.gray / m, g) * m + .5);
png_ptr->background.gray = (png_uint_16)(pow(
(double)png_ptr->background.gray / m, gs) * m + .5);
if ((png_ptr->background.red != png_ptr->background.green) ||
(png_ptr->background.red != png_ptr->background.blue) ||
(png_ptr->background.red != png_ptr->background.gray))
{ {
/* RGB or RGBA */ /* RGB or RGBA with color background */
png_ptr->background_1.red = (png_uint_16)(pow( png_ptr->background_1.red = (png_uint_16)(pow(
(double)png_ptr->background.red / m, g) * m + .5); (double)png_ptr->background.red / m, g) * m + .5);
png_ptr->background_1.green = (png_uint_16)(pow( png_ptr->background_1.green = (png_uint_16)(pow(
@@ -891,17 +929,17 @@ png_init_read_transformations(png_structp png_ptr)
} }
else else
{ {
/* GRAY or GRAY ALPHA */ /* GRAY, GRAY ALPHA, RGB, or RGBA with gray background */
png_ptr->background_1.gray = (png_uint_16)(pow( png_ptr->background_1.red = png_ptr->background_1.green
(double)png_ptr->background.gray / m, g) * m + .5); = png_ptr->background_1.blue = png_ptr->background_1.gray;
png_ptr->background.gray = (png_uint_16)(pow( png_ptr->background.red = png_ptr->background.green
(double)png_ptr->background.gray / m, gs) * m + .5); = png_ptr->background.blue = png_ptr->background.gray;
} }
} }
} }
else else
/* transformation does not include PNG_BACKGROUND */ /* transformation does not include PNG_BACKGROUND */
#endif #endif /* PNG_READ_BACKGROUND_SUPPORTED */
if (color_type == PNG_COLOR_TYPE_PALETTE) if (color_type == PNG_COLOR_TYPE_PALETTE)
{ {
png_colorp palette = png_ptr->palette; png_colorp palette = png_ptr->palette;
@@ -919,7 +957,7 @@ png_init_read_transformations(png_structp png_ptr)
#if defined(PNG_READ_BACKGROUND_SUPPORTED) #if defined(PNG_READ_BACKGROUND_SUPPORTED)
else else
#endif #endif
#endif #endif /* PNG_READ_GAMMA_SUPPORTED && PNG_FLOATING_POINT_SUPPORTED */
#if defined(PNG_READ_BACKGROUND_SUPPORTED) #if defined(PNG_READ_BACKGROUND_SUPPORTED)
/* No GAMMA transformation */ /* No GAMMA transformation */
if ((png_ptr->transformations & PNG_BACKGROUND) && if ((png_ptr->transformations & PNG_BACKGROUND) &&
@@ -952,7 +990,7 @@ png_init_read_transformations(png_structp png_ptr)
} }
} }
} }
#endif #endif /* PNG_READ_BACKGROUND_SUPPORTED */
#if defined(PNG_READ_SHIFT_SUPPORTED) #if defined(PNG_READ_SHIFT_SUPPORTED)
if ((png_ptr->transformations & PNG_SHIFT) && if ((png_ptr->transformations & PNG_SHIFT) &&
@@ -977,7 +1015,7 @@ png_init_read_transformations(png_structp png_ptr)
png_ptr->palette[i].blue >>= sb; png_ptr->palette[i].blue >>= sb;
} }
} }
#endif #endif /* PNG_READ_SHIFT_SUPPORTED */
} }
#if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \ #if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \
&& !defined(PNG_READ_BACKGROUND_SUPPORTED) && !defined(PNG_READ_BACKGROUND_SUPPORTED)
@@ -1227,12 +1265,15 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998:
((png_ptr->num_trans != 0 ) || ((png_ptr->num_trans != 0 ) ||
(png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) (png_ptr->color_type & PNG_COLOR_MASK_ALPHA)))
png_do_background(&(png_ptr->row_info), png_ptr->row_buf + 1, png_do_background(&(png_ptr->row_info), png_ptr->row_buf + 1,
&(png_ptr->trans_values), &(png_ptr->background), &(png_ptr->trans_values), &(png_ptr->background)
&(png_ptr->background_1), #if defined(PNG_READ_GAMMA_SUPPORTED)
, &(png_ptr->background_1),
png_ptr->gamma_table, png_ptr->gamma_from_1, png_ptr->gamma_table, png_ptr->gamma_from_1,
png_ptr->gamma_to_1, png_ptr->gamma_16_table, png_ptr->gamma_to_1, png_ptr->gamma_16_table,
png_ptr->gamma_16_from_1, png_ptr->gamma_16_to_1, png_ptr->gamma_16_from_1, png_ptr->gamma_16_to_1,
png_ptr->gamma_shift); png_ptr->gamma_shift
#endif
);
#endif #endif
#if defined(PNG_READ_GAMMA_SUPPORTED) #if defined(PNG_READ_GAMMA_SUPPORTED)
@@ -2312,7 +2353,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 /* PRIVATE */ void PNGAPI
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;
@@ -2545,11 +2586,14 @@ png_correct_palette(png_structp png_ptr, png_colorp palette,
*/ */
void /* PRIVATE */ 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, #if defined(PNG_READ_GAMMA_SUPPORTED)
, png_color_16p background_1,
png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1,
png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1,
png_uint_16pp gamma_16_to_1, int gamma_shift) png_uint_16pp gamma_16_to_1, int gamma_shift
#endif
)
{ {
png_bytep sp, dp; png_bytep sp, dp;
png_uint_32 i; png_uint_32 i;
@@ -2932,6 +2976,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
{ {
*dp = *sp; *dp = *sp;
} }
#if defined(PNG_READ_GAMMA_SUPPORTED)
else if (a == 0) else if (a == 0)
{ {
*dp = (png_byte)background->gray; *dp = (png_byte)background->gray;
@@ -2940,6 +2985,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
{ {
png_composite(*dp, *sp, a, background_1->gray); png_composite(*dp, *sp, a, background_1->gray);
} }
#else
*dp = (png_byte)background->gray;
#endif
} }
} }
} }
@@ -2963,12 +3011,17 @@ png_do_background(png_row_infop row_info, png_bytep row,
*dp = (png_byte)((v >> 8) & 0xff); *dp = (png_byte)((v >> 8) & 0xff);
*(dp + 1) = (png_byte)(v & 0xff); *(dp + 1) = (png_byte)(v & 0xff);
} }
#if defined(PNG_READ_GAMMA_SUPPORTED)
else if (a == 0) else if (a == 0)
#else
else
#endif
{ {
/* background is already in screen gamma */ /* background is already in screen gamma */
*dp = (png_byte)((background->gray >> 8) & 0xff); *dp = (png_byte)((background->gray >> 8) & 0xff);
*(dp + 1) = (png_byte)(background->gray & 0xff); *(dp + 1) = (png_byte)(background->gray & 0xff);
} }
#if defined(PNG_READ_GAMMA_SUPPORTED)
else else
{ {
png_uint_16 g, v, w; png_uint_16 g, v, w;
@@ -2979,6 +3032,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
*dp = (png_byte)((w >> 8) & 0xff); *dp = (png_byte)((w >> 8) & 0xff);
*(dp + 1) = (png_byte)(w & 0xff); *(dp + 1) = (png_byte)(w & 0xff);
} }
#endif
} }
} }
else else
@@ -2993,11 +3047,16 @@ png_do_background(png_row_infop row_info, png_bytep row,
{ {
png_memcpy(dp, sp, 2); png_memcpy(dp, sp, 2);
} }
#if defined(PNG_READ_GAMMA_SUPPORTED)
else if (a == 0) else if (a == 0)
#else
else
#endif
{ {
*dp = (png_byte)((background->gray >> 8) & 0xff); *dp = (png_byte)((background->gray >> 8) & 0xff);
*(dp + 1) = (png_byte)(background->gray & 0xff); *(dp + 1) = (png_byte)(background->gray & 0xff);
} }
#if defined(PNG_READ_GAMMA_SUPPORTED)
else else
{ {
png_uint_16 g, v; png_uint_16 g, v;
@@ -3007,6 +3066,7 @@ png_do_background(png_row_infop row_info, png_bytep row,
*dp = (png_byte)((v >> 8) & 0xff); *dp = (png_byte)((v >> 8) & 0xff);
*(dp + 1) = (png_byte)(v & 0xff); *(dp + 1) = (png_byte)(v & 0xff);
} }
#endif
} }
} }
} }
@@ -3128,17 +3188,17 @@ png_do_background(png_row_infop row_info, png_bytep row,
png_uint_16 v, w, x; png_uint_16 v, w, x;
v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
png_composite_16(w, v, a, background->red); png_composite_16(w, v, a, background_1->red);
x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];
*dp = (png_byte)((x >> 8) & 0xff); *dp = (png_byte)((x >> 8) & 0xff);
*(dp + 1) = (png_byte)(x & 0xff); *(dp + 1) = (png_byte)(x & 0xff);
v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)]; v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)];
png_composite_16(w, v, a, background->green); png_composite_16(w, v, a, background_1->green);
x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];
*(dp + 2) = (png_byte)((x >> 8) & 0xff); *(dp + 2) = (png_byte)((x >> 8) & 0xff);
*(dp + 3) = (png_byte)(x & 0xff); *(dp + 3) = (png_byte)(x & 0xff);
v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)]; v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)];
png_composite_16(w, v, a, background->blue); png_composite_16(w, v, a, background_1->blue);
x = gamma_16_from_1[(w & 0xff) >> gamma_shift][w >> 8]; x = gamma_16_from_1[(w & 0xff) >> gamma_shift][w >> 8];
*(dp + 4) = (png_byte)((x >> 8) & 0xff); *(dp + 4) = (png_byte)((x >> 8) & 0xff);
*(dp + 5) = (png_byte)(x & 0xff); *(dp + 5) = (png_byte)(x & 0xff);

View File

@@ -1,9 +1,9 @@
/* pngrutil.c - utilities to read a PNG file /* pngrutil.c - utilities to read a PNG file
* *
* libpng 1.0.9 - January 31, 2001 * libpng 1.0.14 - July 8, 2002
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2002 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
@@ -30,7 +30,7 @@ __inline double strtod(const char *nptr, char **endptr)
MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len); MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len);
result = wcstod(str, &end); result = wcstod(str, &end);
len = WideCharToMultiByte(CP_ACP, 0, end, -1, NULL, 0, NULL, NULL); len = WideCharToMultiByte(CP_ACP, 0, end, -1, NULL, 0, NULL, NULL);
*endptr = (char *)nptr + (strlen(nptr) - len + 1); *endptr = (char *)nptr + (png_strlen(nptr) - len + 1);
free(str); free(str);
} }
return result; return result;
@@ -200,7 +200,12 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
if (text == NULL) if (text == NULL)
{ {
text_size = prefix_size + sizeof(msg) + 1; text_size = prefix_size + sizeof(msg) + 1;
text = (png_charp)png_malloc(png_ptr, text_size); text = (png_charp)png_malloc_warn(png_ptr, text_size);
if (text == NULL)
{
png_free(png_ptr,chunkdata);
png_error(png_ptr,"Not enough memory to decompress chunk");
}
png_memcpy(text, chunkdata, prefix_size); png_memcpy(text, chunkdata, prefix_size);
} }
@@ -218,9 +223,14 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
{ {
text_size = prefix_size + text_size = prefix_size +
png_ptr->zbuf_size - png_ptr->zstream.avail_out; png_ptr->zbuf_size - png_ptr->zstream.avail_out;
text = (png_charp)png_malloc(png_ptr, text_size + 1); text = (png_charp)png_malloc_warn(png_ptr, text_size + 1);
if (text == NULL)
{
png_free(png_ptr,chunkdata);
png_error(png_ptr,"Not enough memory to decompress chunk.");
}
png_memcpy(text + prefix_size, png_ptr->zbuf, png_memcpy(text + prefix_size, png_ptr->zbuf,
text_size - prefix_size); text_size - prefix_size);
png_memcpy(text, chunkdata, prefix_size); png_memcpy(text, chunkdata, prefix_size);
*(text + text_size) = 0x00; *(text + text_size) = 0x00;
} }
@@ -229,8 +239,15 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
png_charp tmp; png_charp tmp;
tmp = text; tmp = text;
text = (png_charp)png_malloc(png_ptr, (png_uint_32)(text_size + text = (png_charp)png_malloc_warn(png_ptr,
(png_uint_32)(text_size +
png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1)); png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1));
if (text == NULL)
{
png_free(png_ptr, tmp);
png_free(png_ptr, chunkdata);
png_error(png_ptr,"Not enough memory to decompress chunk..");
}
png_memcpy(text, tmp, text_size); png_memcpy(text, tmp, text_size);
png_free(png_ptr, tmp); png_free(png_ptr, tmp);
png_memcpy(text + text_size, png_ptr->zbuf, png_memcpy(text + text_size, png_ptr->zbuf,
@@ -269,7 +286,12 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
text_size=prefix_size; text_size=prefix_size;
if (text == NULL) if (text == NULL)
{ {
text = (png_charp)png_malloc(png_ptr, text_size+1); text = (png_charp)png_malloc_warn(png_ptr, text_size+1);
if (text == NULL)
{
png_free(png_ptr, chunkdata);
png_error(png_ptr,"Not enough memory for text.");
}
png_memcpy(text, chunkdata, prefix_size); png_memcpy(text, chunkdata, prefix_size);
} }
*(text + text_size) = 0x00; *(text + text_size) = 0x00;
@@ -332,59 +354,6 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
filter_type = buf[11]; filter_type = buf[11];
interlace_type = buf[12]; interlace_type = buf[12];
/* check for width and height valid values */
if (width == 0 || width > PNG_MAX_UINT || height == 0 ||
height > PNG_MAX_UINT)
png_error(png_ptr, "Invalid image size in IHDR");
/* check other values */
if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 &&
bit_depth != 8 && bit_depth != 16)
png_error(png_ptr, "Invalid bit depth in IHDR");
if (color_type < 0 || color_type == 1 ||
color_type == 5 || color_type > 6)
png_error(png_ptr, "Invalid color type in IHDR");
if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) ||
((color_type == PNG_COLOR_TYPE_RGB ||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA ||
color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8))
png_error(png_ptr, "Invalid color type/bit depth combination in IHDR");
if (interlace_type >= PNG_INTERLACE_LAST)
png_error(png_ptr, "Unknown interlace method in IHDR");
if (compression_type != PNG_COMPRESSION_TYPE_BASE)
png_error(png_ptr, "Unknown compression method in IHDR");
#if defined(PNG_MNG_FEATURES_SUPPORTED)
/* Accept filter_method 64 (intrapixel differencing) only if
* 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and
* 2. Libpng did not read a PNG signature (this filter_method is only
* used in PNG datastreams that are embedded in MNG datastreams) and
* 3. The application called png_permit_mng_features with a mask that
* included PNG_FLAG_MNG_FILTER_64 and
* 4. The filter_method is 64 and
* 5. The color_type is RGB or RGBA
*/
if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted)
png_warning(png_ptr,"MNG features are not allowed in a PNG datastream\n");
if(filter_type != PNG_FILTER_TYPE_BASE)
{
if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
(filter_type == PNG_INTRAPIXEL_DIFFERENCING) &&
((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&
(color_type == PNG_COLOR_TYPE_RGB ||
color_type == PNG_COLOR_TYPE_RGB_ALPHA)))
png_error(png_ptr, "Unknown filter method in IHDR");
if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)
png_warning(png_ptr, "Invalid filter method in IHDR");
}
#else
if(filter_type != PNG_FILTER_TYPE_BASE)
png_error(png_ptr, "Unknown filter method in IHDR");
#endif
/* set internal variables */ /* set internal variables */
png_ptr->width = width; png_ptr->width = width;
@@ -392,7 +361,9 @@ 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;
#if defined(PNG_MNG_FEATURES_SUPPORTED)
png_ptr->filter_type = (png_byte)filter_type; png_ptr->filter_type = (png_byte)filter_type;
#endif
/* find number of channels */ /* find number of channels */
switch (png_ptr->color_type) switch (png_ptr->color_type)
@@ -449,6 +420,13 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_ptr->mode |= PNG_HAVE_PLTE; png_ptr->mode |= PNG_HAVE_PLTE;
if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR))
{
png_warning(png_ptr,
"Ignoring PLTE chunk in grayscale PNG");
png_crc_finish(png_ptr, length);
return;
}
#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) #if !defined(PNG_READ_OPT_PLTE_SUPPORTED)
if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
{ {
@@ -565,9 +543,7 @@ png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_error(png_ptr, "No image in file"); png_error(png_ptr, "No image in file");
/* to quiet compiler warnings about unused info_ptr */ info_ptr = info_ptr; /* quiet compiler warnings about unused info_ptr */
if (info_ptr == NULL)
return;
} }
png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND); png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND);
@@ -628,7 +604,11 @@ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
igamma = (png_fixed_point)png_get_uint_32(buf); igamma = (png_fixed_point)png_get_uint_32(buf);
/* check for zero gamma */ /* check for zero gamma */
if (igamma == 0) if (igamma == 0)
return; {
png_warning(png_ptr,
"Ignoring gAMA chunk with gamma=0");
return;
}
#if defined(PNG_READ_sRGB_SUPPORTED) #if defined(PNG_READ_sRGB_SUPPORTED)
if (info_ptr->valid & PNG_INFO_sRGB) if (info_ptr->valid & PNG_INFO_sRGB)
@@ -733,6 +713,8 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_fixed_point int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, png_fixed_point int_x_white, int_y_white, int_x_red, int_y_red, int_x_green,
int_y_green, int_x_blue, int_y_blue; int_y_green, int_x_blue, int_y_blue;
png_uint_32 uint_x, uint_y;
png_debug(1, "in png_handle_cHRM\n"); png_debug(1, "in png_handle_cHRM\n");
if (!(png_ptr->mode & PNG_HAVE_IHDR)) if (!(png_ptr->mode & PNG_HAVE_IHDR))
@@ -766,60 +748,69 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
} }
png_crc_read(png_ptr, buf, 4); png_crc_read(png_ptr, buf, 4);
int_x_white = (png_fixed_point)png_get_uint_32(buf); uint_x = png_get_uint_32(buf);
png_crc_read(png_ptr, buf, 4); png_crc_read(png_ptr, buf, 4);
int_y_white = (png_fixed_point)png_get_uint_32(buf); uint_y = png_get_uint_32(buf);
if (int_x_white > 80000L || int_y_white > 80000L || if (uint_x > 80000L || uint_y > 80000L ||
int_x_white + int_y_white > 100000L) uint_x + uint_y > 100000L)
{ {
png_warning(png_ptr, "Invalid cHRM white point"); png_warning(png_ptr, "Invalid cHRM white point");
png_crc_finish(png_ptr, 24); png_crc_finish(png_ptr, 24);
return; return;
} }
int_x_white = (png_fixed_point)uint_x;
int_y_white = (png_fixed_point)uint_y;
png_crc_read(png_ptr, buf, 4); png_crc_read(png_ptr, buf, 4);
int_x_red = (png_fixed_point)png_get_uint_32(buf); uint_x = png_get_uint_32(buf);
png_crc_read(png_ptr, buf, 4); png_crc_read(png_ptr, buf, 4);
int_y_red = (png_fixed_point)png_get_uint_32(buf); uint_y = png_get_uint_32(buf);
if (int_x_red > 80000L || int_y_red > 80000L || if (uint_x > 80000L || uint_y > 80000L ||
int_x_red + int_y_red > 100000L) uint_x + uint_y > 100000L)
{ {
png_warning(png_ptr, "Invalid cHRM red point"); png_warning(png_ptr, "Invalid cHRM red point");
png_crc_finish(png_ptr, 16); png_crc_finish(png_ptr, 16);
return; return;
} }
int_x_red = (png_fixed_point)uint_x;
int_y_red = (png_fixed_point)uint_y;
png_crc_read(png_ptr, buf, 4); png_crc_read(png_ptr, buf, 4);
int_x_green = (png_fixed_point)png_get_uint_32(buf); uint_x = png_get_uint_32(buf);
png_crc_read(png_ptr, buf, 4); png_crc_read(png_ptr, buf, 4);
int_y_green = (png_fixed_point)png_get_uint_32(buf); uint_y = png_get_uint_32(buf);
if (int_x_green > 80000L || int_y_green > 80000L || if (uint_x > 80000L || uint_y > 80000L ||
int_x_green + int_y_green > 100000L) uint_x + uint_y > 100000L)
{ {
png_warning(png_ptr, "Invalid cHRM green point"); png_warning(png_ptr, "Invalid cHRM green point");
png_crc_finish(png_ptr, 8); png_crc_finish(png_ptr, 8);
return; return;
} }
int_x_green = (png_fixed_point)uint_x;
int_y_green = (png_fixed_point)uint_y;
png_crc_read(png_ptr, buf, 4); png_crc_read(png_ptr, buf, 4);
int_x_blue = (png_fixed_point)png_get_uint_32(buf); uint_x = png_get_uint_32(buf);
png_crc_read(png_ptr, buf, 4); png_crc_read(png_ptr, buf, 4);
int_y_blue = (png_fixed_point)png_get_uint_32(buf); uint_y = png_get_uint_32(buf);
if (int_x_blue > 80000L || int_y_blue > 80000L || if (uint_x > 80000L || uint_y > 80000L ||
int_x_blue + int_y_blue > 100000L) uint_x + uint_y > 100000L)
{ {
png_warning(png_ptr, "Invalid cHRM blue point"); png_warning(png_ptr, "Invalid cHRM blue point");
png_crc_finish(png_ptr, 0); png_crc_finish(png_ptr, 0);
return; return;
} }
int_x_blue = (png_fixed_point)uint_x;
int_y_blue = (png_fixed_point)uint_y;
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
white_x = (float)int_x_white / (float)100000.0; white_x = (float)int_x_white / (float)100000.0;
white_y = (float)int_y_white / (float)100000.0; white_y = (float)int_y_white / (float)100000.0;
@@ -836,12 +827,12 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
if (abs(int_x_white - 31270L) > 1000 || if (abs(int_x_white - 31270L) > 1000 ||
abs(int_y_white - 32900L) > 1000 || abs(int_y_white - 32900L) > 1000 ||
abs( int_x_red - 64000L) > 1000 || abs(int_x_red - 64000L) > 1000 ||
abs( int_y_red - 33000L) > 1000 || abs(int_y_red - 33000L) > 1000 ||
abs(int_x_green - 30000L) > 1000 || abs(int_x_green - 30000L) > 1000 ||
abs(int_y_green - 60000L) > 1000 || abs(int_y_green - 60000L) > 1000 ||
abs( int_x_blue - 15000L) > 1000 || abs(int_x_blue - 15000L) > 1000 ||
abs( int_y_blue - 6000L) > 1000) abs(int_y_blue - 6000L) > 1000)
{ {
png_warning(png_ptr, png_warning(png_ptr,
@@ -936,17 +927,6 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
# ifdef PNG_FLOATING_POINT_SUPPORTED # ifdef PNG_FLOATING_POINT_SUPPORTED
igamma=(int)(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)
{ {
@@ -970,12 +950,12 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
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 ||
abs( info_ptr->int_x_red - 64000L) > 1000 || abs(info_ptr->int_x_red - 64000L) > 1000 ||
abs( info_ptr->int_y_red - 33000L) > 1000 || abs(info_ptr->int_y_red - 33000L) > 1000 ||
abs(info_ptr->int_x_green - 30000L) > 1000 || abs(info_ptr->int_x_green - 30000L) > 1000 ||
abs(info_ptr->int_y_green - 60000L) > 1000 || abs(info_ptr->int_y_green - 60000L) > 1000 ||
abs( info_ptr->int_x_blue - 15000L) > 1000 || abs(info_ptr->int_x_blue - 15000L) > 1000 ||
abs( info_ptr->int_y_blue - 6000L) > 1000) abs(info_ptr->int_y_blue - 6000L) > 1000)
{ {
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");
@@ -994,6 +974,7 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
{ {
png_charp chunkdata; png_charp chunkdata;
png_byte compression_type; png_byte compression_type;
png_bytep pC;
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_size = 0;
@@ -1071,17 +1052,26 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
profile_length = data_length - prefix_length; profile_length = data_length - prefix_length;
if ( prefix_length > data_length || profile_length < 4)
{
png_free(png_ptr, chunkdata);
png_warning(png_ptr, "Profile size field missing from iCCP chunk");
return;
}
/* Check the profile_size recorded in the first 32 bits of the ICC profile */ /* Check the profile_size recorded in the first 32 bits of the ICC profile */
profile_size = ((*(chunkdata+prefix_length))<<24) | pC = (png_bytep)(chunkdata+prefix_length);
((*(chunkdata+prefix_length+1))<<16) | profile_size = ((*(pC ))<<24) |
((*(chunkdata+prefix_length+2))<< 8) | ((*(pC+1))<<16) |
((*(chunkdata+prefix_length+3)) ); ((*(pC+2))<< 8) |
((*(pC+3)) );
if(profile_size < profile_length) if(profile_size < profile_length)
profile_length = profile_size; profile_length = profile_size;
if(profile_size > profile_length) if(profile_size > profile_length)
{ {
png_free(png_ptr, chunkdata);
png_warning(png_ptr, "Ignoring truncated iCCP profile.\n"); png_warning(png_ptr, "Ignoring truncated iCCP profile.\n");
return; return;
} }
@@ -1129,7 +1119,7 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
chunkdata = (png_bytep)png_malloc(png_ptr, length + 1); chunkdata = (png_bytep)png_malloc(png_ptr, length + 1);
slength = (png_size_t)length; slength = (png_size_t)length;
png_crc_read(png_ptr, chunkdata, slength); png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
if (png_crc_finish(png_ptr, skip)) if (png_crc_finish(png_ptr, skip))
{ {
@@ -1159,7 +1149,8 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (data_length % entry_size) if (data_length % entry_size)
{ {
png_free(png_ptr, chunkdata); png_free(png_ptr, chunkdata);
png_error(png_ptr, "sPLT chunk has bad length"); png_warning(png_ptr, "sPLT chunk has bad length");
return;
} }
new_palette.nentries = data_length / entry_size; new_palette.nentries = data_length / entry_size;
@@ -1224,7 +1215,7 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
void /* PRIVATE */ 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_byte readbuf[PNG_MAX_PALETTE_LENGTH]; png_byte readbuf[PNG_MAX_PALETTE_LENGTH];
png_debug(1, "in png_handle_tRNS\n"); png_debug(1, "in png_handle_tRNS\n");
@@ -1407,7 +1398,7 @@ 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;
png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH]; png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH];
png_debug(1, "in png_handle_hIST\n"); png_debug(1, "in png_handle_hIST\n");
@@ -1573,7 +1564,12 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_debug1(2, "Allocating and reading pCAL chunk data (%lu 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_warn(png_ptr, length + 1);
if (purpose == NULL)
{
png_warning(png_ptr, "No memory for pCAL purpose.");
return;
}
slength = (png_size_t)length; slength = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)purpose, slength); png_crc_read(png_ptr, (png_bytep)purpose, slength);
@@ -1628,8 +1624,14 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
/* Empty loop to move past the units string. */ ; /* Empty loop to move past the units string. */ ;
png_debug(3, "Allocating pCAL parameters array\n"); png_debug(3, "Allocating pCAL parameters array\n");
params = (png_charpp)png_malloc(png_ptr, (png_uint_32)(nparams params = (png_charpp)png_malloc_warn(png_ptr, (png_uint_32)(nparams
*sizeof(png_charp))) ; *sizeof(png_charp))) ;
if (params == NULL)
{
png_free(png_ptr, purpose);
png_warning(png_ptr, "No memory for pCAL params.");
return;
}
/* Get pointers to the start of each parameter string. */ /* Get pointers to the start of each parameter string. */
for (i = 0; i < (int)nparams; i++) for (i = 0; i < (int)nparams; i++)
@@ -1693,7 +1695,12 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_debug1(2, "Allocating and reading sCAL chunk data (%lu 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_warn(png_ptr, length + 1);
if (buffer == NULL)
{
png_warning(png_ptr, "Out of memory while processing sCAL chunk");
return;
}
slength = (png_size_t)length; slength = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)buffer, slength); png_crc_read(png_ptr, (png_bytep)buffer, slength);
@@ -1716,8 +1723,13 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
} }
#else #else
#ifdef PNG_FIXED_POINT_SUPPORTED #ifdef PNG_FIXED_POINT_SUPPORTED
swidth = (png_charp)png_malloc(png_ptr, strlen(ep) + 1); swidth = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1);
png_memcpy(swidth, ep, (png_size_t)strlen(ep)); if (swidth == NULL)
{
png_warning(png_ptr, "Out of memory while processing sCAL chunk width");
return;
}
png_memcpy(swidth, ep, (png_size_t)png_strlen(ep));
#endif #endif
#endif #endif
@@ -1734,8 +1746,13 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
} }
#else #else
#ifdef PNG_FIXED_POINT_SUPPORTED #ifdef PNG_FIXED_POINT_SUPPORTED
sheight = (png_charp)png_malloc(png_ptr, strlen(ep) + 1); sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1);
png_memcpy(sheight, ep, (png_size_t)strlen(ep)); if (swidth == NULL)
{
png_warning(png_ptr, "Out of memory while processing sCAL chunk height");
return;
}
png_memcpy(sheight, ep, (png_size_t)png_strlen(ep));
#endif #endif
#endif #endif
@@ -1824,6 +1841,7 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_charp text; png_charp text;
png_uint_32 skip = 0; png_uint_32 skip = 0;
png_size_t slength; png_size_t slength;
int ret;
png_debug(1, "in png_handle_tEXt\n"); png_debug(1, "in png_handle_tEXt\n");
@@ -1842,7 +1860,12 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
} }
#endif #endif
key = (png_charp)png_malloc(png_ptr, length + 1); key = (png_charp)png_malloc_warn(png_ptr, length + 1);
if (key == NULL)
{
png_warning(png_ptr, "No memory to process text chunk.");
return;
}
slength = (png_size_t)length; slength = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)key, slength); png_crc_read(png_ptr, (png_bytep)key, slength);
@@ -1860,7 +1883,13 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (text != key + slength) if (text != key + slength)
text++; text++;
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text)); text_ptr = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)sizeof(png_text));
if (text_ptr == NULL)
{
png_warning(png_ptr, "Not enough memory to process text chunk.");
png_free(png_ptr, key);
return;
}
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 #ifdef PNG_iTXt_SUPPORTED
@@ -1871,10 +1900,12 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
text_ptr->text = text; text_ptr->text = text;
text_ptr->text_length = png_strlen(text); text_ptr->text_length = png_strlen(text);
png_set_text(png_ptr, info_ptr, text_ptr, 1); ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
png_free(png_ptr, key); png_free(png_ptr, key);
png_free(png_ptr, text_ptr); png_free(png_ptr, text_ptr);
if (ret)
png_warning(png_ptr, "Insufficient memory to process text chunk.");
} }
#endif #endif
@@ -1887,6 +1918,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_charp chunkdata; png_charp chunkdata;
png_charp text; png_charp text;
int comp_type; int comp_type;
int ret;
png_size_t slength, prefix_len, data_len; png_size_t slength, prefix_len, data_len;
png_debug(1, "in png_handle_zTXt\n"); png_debug(1, "in png_handle_zTXt\n");
@@ -1907,7 +1939,12 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
} }
#endif #endif
chunkdata = (png_charp)png_malloc(png_ptr, length + 1); chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
if (chunkdata == NULL)
{
png_warning(png_ptr,"Out of memory processing zTXt chunk.");
return;
}
slength = (png_size_t)length; slength = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)chunkdata, slength); png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
if (png_crc_finish(png_ptr, 0)) if (png_crc_finish(png_ptr, 0))
@@ -1942,7 +1979,13 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
chunkdata = (png_charp)png_decompress_chunk(png_ptr, comp_type, chunkdata, chunkdata = (png_charp)png_decompress_chunk(png_ptr, comp_type, chunkdata,
(png_size_t)length, prefix_len, &data_len); (png_size_t)length, prefix_len, &data_len);
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text)); text_ptr = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)sizeof(png_text));
if (text_ptr == NULL)
{
png_warning(png_ptr,"Not enough memory to process zTXt chunk.");
png_free(png_ptr, chunkdata);
return;
}
text_ptr->compression = comp_type; text_ptr->compression = comp_type;
text_ptr->key = chunkdata; text_ptr->key = chunkdata;
#ifdef PNG_iTXt_SUPPORTED #ifdef PNG_iTXt_SUPPORTED
@@ -1953,10 +1996,12 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
text_ptr->text = chunkdata + prefix_len; text_ptr->text = chunkdata + prefix_len;
text_ptr->text_length = data_len; text_ptr->text_length = data_len;
png_set_text(png_ptr, info_ptr, text_ptr, 1); ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
png_free(png_ptr, text_ptr); png_free(png_ptr, text_ptr);
png_free(png_ptr, chunkdata); png_free(png_ptr, chunkdata);
if (ret)
png_error(png_ptr, "Insufficient memory to store zTXt chunk.");
} }
#endif #endif
@@ -1970,6 +2015,7 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_charp key, lang, text, lang_key; png_charp key, lang, text, lang_key;
int comp_flag; int comp_flag;
int comp_type = 0; int comp_type = 0;
int ret;
png_size_t slength, prefix_len, data_len; png_size_t slength, prefix_len, data_len;
png_debug(1, "in png_handle_iTXt\n"); png_debug(1, "in png_handle_iTXt\n");
@@ -1991,7 +2037,12 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
} }
#endif #endif
chunkdata = (png_charp)png_malloc(png_ptr, length + 1); chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
if (chunkdata == NULL)
{
png_warning(png_ptr, "No memory to process iTXt chunk.");
return;
}
slength = (png_size_t)length; slength = (png_size_t)length;
png_crc_read(png_ptr, (png_bytep)chunkdata, slength); png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
if (png_crc_finish(png_ptr, 0)) if (png_crc_finish(png_ptr, 0))
@@ -2037,7 +2088,13 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
(size_t)length, prefix_len, &data_len); (size_t)length, prefix_len, &data_len);
else else
data_len=png_strlen(chunkdata + prefix_len); data_len=png_strlen(chunkdata + prefix_len);
text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text)); text_ptr = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)sizeof(png_text));
if (text_ptr == NULL)
{
png_warning(png_ptr,"Not enough memory to process iTXt chunk.");
png_free(png_ptr, chunkdata);
return;
}
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);
@@ -2046,10 +2103,12 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
text_ptr->key = chunkdata; text_ptr->key = chunkdata;
text_ptr->text = chunkdata + prefix_len; text_ptr->text = chunkdata + prefix_len;
png_set_text(png_ptr, info_ptr, text_ptr, 1); ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
png_free(png_ptr, text_ptr); png_free(png_ptr, text_ptr);
png_free(png_ptr, chunkdata); png_free(png_ptr, chunkdata);
if (ret)
png_error(png_ptr, "Insufficient memory to store iTXt chunk.");
} }
#endif #endif
@@ -2082,7 +2141,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
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 == NULL
#endif #endif
) )
#endif #endif
@@ -2102,12 +2161,12 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
length = (png_uint_32)65535L; length = (png_uint_32)65535L;
} }
#endif #endif
strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name); png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name);
chunk.data = (png_bytep)png_malloc(png_ptr, length); chunk.data = (png_bytep)png_malloc(png_ptr, length);
png_crc_read(png_ptr, chunk.data, length); chunk.size = (png_size_t)length;
chunk.size = length; png_crc_read(png_ptr, (png_bytep)chunk.data, length);
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) #if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
if(png_ptr->read_user_chunk_fn != (png_user_chunk_ptr)NULL) if(png_ptr->read_user_chunk_fn != NULL)
{ {
/* callback to user unknown chunk handler */ /* callback to user unknown chunk handler */
if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0) if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0)
@@ -2115,7 +2174,10 @@ 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(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)
{
png_free(png_ptr, chunk.data);
png_chunk_error(png_ptr, "unknown critical chunk"); png_chunk_error(png_ptr, "unknown critical chunk");
}
png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
} }
} }
@@ -2131,8 +2193,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
png_crc_finish(png_ptr, skip); png_crc_finish(png_ptr, skip);
#if !defined(PNG_READ_USER_CHUNKS_SUPPORTED) #if !defined(PNG_READ_USER_CHUNKS_SUPPORTED)
if (info_ptr == NULL) info_ptr = info_ptr; /* quiet compiler warnings about unused info_ptr */
/* quiet compiler warnings about unused info_ptr */ ;
#endif #endif
} }
@@ -2371,6 +2432,10 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask)
#ifdef PNG_READ_INTERLACING_SUPPORTED #ifdef PNG_READ_INTERLACING_SUPPORTED
#ifndef PNG_HAVE_ASSEMBLER_READ_INTERLACE /* else in pngvcrd.c, pnggccrd.c */ #ifndef PNG_HAVE_ASSEMBLER_READ_INTERLACE /* else in pngvcrd.c, pnggccrd.c */
/* OLD pre-1.0.9 interface:
void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
png_uint_32 transformations)
*/
void /* PRIVATE */ void /* PRIVATE */
png_do_read_interlace(png_structp png_ptr) png_do_read_interlace(png_structp png_ptr)
{ {
@@ -2589,9 +2654,7 @@ png_do_read_interlace(png_structp png_ptr)
(png_uint_32)row_info->pixel_depth + 7) >> 3); (png_uint_32)row_info->pixel_depth + 7) >> 3);
} }
#if !defined(PNG_READ_PACKSWAP_SUPPORTED) #if !defined(PNG_READ_PACKSWAP_SUPPORTED)
/* silence compiler warning */ transformations = transformations; /* silence compiler warning */
if (transformations)
return;
#endif #endif
} }
#endif /* !PNG_HAVE_ASSEMBLER_READ_INTERLACE */ #endif /* !PNG_HAVE_ASSEMBLER_READ_INTERLACE */
@@ -3007,7 +3070,11 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
if (row_bytes > (png_uint_32)65536L) if (row_bytes > (png_uint_32)65536L)
png_error(png_ptr, "This image requires a row greater than 64KB"); png_error(png_ptr, "This image requires a row greater than 64KB");
#endif #endif
png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, row_bytes); png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64);
png_ptr->row_buf = png_ptr->big_row_buf+32;
#if defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD)
png_ptr->row_buf_size = row_bytes;
#endif
#ifdef PNG_MAX_MALLOC_64K #ifdef PNG_MAX_MALLOC_64K
if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L) if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L)

381
pngset.c
View File

@@ -1,9 +1,9 @@
/* pngset.c - storage of image information into info struct /* pngset.c - storage of image information into info struct
* *
* libpng 1.0.9 - January 31, 2001 * libpng 1.0.14 - July 8, 2002
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2002 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
@@ -40,6 +40,25 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
if (png_ptr == NULL || info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
if (white_x < 0.0 || white_y < 0.0 ||
red_x < 0.0 || red_y < 0.0 ||
green_x < 0.0 || green_y < 0.0 ||
blue_x < 0.0 || blue_y < 0.0)
{
png_warning(png_ptr,
"Ignoring attempt to set negative chromaticity value");
return;
}
if (white_x > 21474.83 || white_y > 21474.83 ||
red_x > 21474.83 || red_y > 21474.83 ||
green_x > 21474.83 || green_y > 21474.83 ||
blue_x > 21474.83 || blue_y > 21474.83)
{
png_warning(png_ptr,
"Ignoring attempt to set chromaticity value exceeding 21474.83");
return;
}
info_ptr->x_white = (float)white_x; info_ptr->x_white = (float)white_x;
info_ptr->y_white = (float)white_y; info_ptr->y_white = (float)white_y;
info_ptr->x_red = (float)red_x; info_ptr->x_red = (float)red_x;
@@ -51,12 +70,12 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_FIXED_POINT_SUPPORTED #ifdef PNG_FIXED_POINT_SUPPORTED
info_ptr->int_x_white = (png_fixed_point)(white_x*100000.+0.5); info_ptr->int_x_white = (png_fixed_point)(white_x*100000.+0.5);
info_ptr->int_y_white = (png_fixed_point)(white_y*100000.+0.5); info_ptr->int_y_white = (png_fixed_point)(white_y*100000.+0.5);
info_ptr->int_x_red = (png_fixed_point)(red_x*100000.+0.5); info_ptr->int_x_red = (png_fixed_point)( red_x*100000.+0.5);
info_ptr->int_y_red = (png_fixed_point)(red_y*100000.+0.5); info_ptr->int_y_red = (png_fixed_point)( red_y*100000.+0.5);
info_ptr->int_x_green = (png_fixed_point)(green_x*100000.+0.5); info_ptr->int_x_green = (png_fixed_point)(green_x*100000.+0.5);
info_ptr->int_y_green = (png_fixed_point)(green_y*100000.+0.5); info_ptr->int_y_green = (png_fixed_point)(green_y*100000.+0.5);
info_ptr->int_x_blue = (png_fixed_point)(blue_x*100000.+0.5); info_ptr->int_x_blue = (png_fixed_point)( blue_x*100000.+0.5);
info_ptr->int_y_blue = (png_fixed_point)(blue_y*100000.+0.5); info_ptr->int_y_blue = (png_fixed_point)( blue_y*100000.+0.5);
#endif #endif
info_ptr->valid |= PNG_INFO_cHRM; info_ptr->valid |= PNG_INFO_cHRM;
} }
@@ -72,6 +91,24 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
if (png_ptr == NULL || info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
if (white_x < 0 || white_y < 0 ||
red_x < 0 || red_y < 0 ||
green_x < 0 || green_y < 0 ||
blue_x < 0 || blue_y < 0)
{
png_warning(png_ptr,
"Ignoring attempt to set negative chromaticity value");
return;
}
if (white_x > (double) PNG_MAX_UINT || white_y > (double) PNG_MAX_UINT ||
red_x > (double) PNG_MAX_UINT || red_y > (double) PNG_MAX_UINT ||
green_x > (double) PNG_MAX_UINT || green_y > (double) PNG_MAX_UINT ||
blue_x > (double) PNG_MAX_UINT || blue_y > (double) PNG_MAX_UINT)
{
png_warning(png_ptr,
"Ignoring attempt to set chromaticity value exceeding 21474.83");
return;
}
info_ptr->int_x_white = white_x; info_ptr->int_x_white = white_x;
info_ptr->int_y_white = white_y; info_ptr->int_y_white = white_y;
info_ptr->int_x_red = red_x; info_ptr->int_x_red = red_x;
@@ -83,12 +120,12 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
info_ptr->x_white = (float)(white_x/100000.); info_ptr->x_white = (float)(white_x/100000.);
info_ptr->y_white = (float)(white_y/100000.); info_ptr->y_white = (float)(white_y/100000.);
info_ptr->x_red = (float)(red_x/100000.); info_ptr->x_red = (float)( red_x/100000.);
info_ptr->y_red = (float)(red_y/100000.); info_ptr->y_red = (float)( red_y/100000.);
info_ptr->x_green = (float)(green_x/100000.); info_ptr->x_green = (float)(green_x/100000.);
info_ptr->y_green = (float)(green_y/100000.); info_ptr->y_green = (float)(green_y/100000.);
info_ptr->x_blue = (float)(blue_x/100000.); info_ptr->x_blue = (float)( blue_x/100000.);
info_ptr->y_blue = (float)(blue_y/100000.); info_ptr->y_blue = (float)( blue_y/100000.);
#endif #endif
info_ptr->valid |= PNG_INFO_cHRM; info_ptr->valid |= PNG_INFO_cHRM;
} }
@@ -100,53 +137,92 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
void PNGAPI 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)
{ {
double gamma;
png_debug1(1, "in %s storage function\n", "gAMA"); png_debug1(1, "in %s storage function\n", "gAMA");
if (png_ptr == NULL || info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
info_ptr->gamma = (float)file_gamma; /* Check for overflow */
if (file_gamma > 21474.83)
{
png_warning(png_ptr, "Limiting gamma to 21474.83");
gamma=21474.83;
}
else
gamma=file_gamma;
info_ptr->gamma = (float)gamma;
#ifdef PNG_FIXED_POINT_SUPPORTED #ifdef PNG_FIXED_POINT_SUPPORTED
info_ptr->int_gamma = (int)(file_gamma*100000.+.5); info_ptr->int_gamma = (int)(gamma*100000.+.5);
#endif #endif
info_ptr->valid |= PNG_INFO_gAMA; info_ptr->valid |= PNG_INFO_gAMA;
if(gamma == 0.0)
png_warning(png_ptr, "Setting gamma=0");
} }
#endif #endif
#endif
void PNGAPI 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)
{ {
png_fixed_point gamma;
png_debug1(1, "in %s storage function\n", "gAMA"); png_debug1(1, "in %s storage function\n", "gAMA");
if (png_ptr == NULL || info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
if (int_gamma > (png_fixed_point) PNG_MAX_UINT)
{
png_warning(png_ptr, "Limiting gamma to 21474.83");
gamma=PNG_MAX_UINT;
}
else
{
if (int_gamma < 0)
{
png_warning(png_ptr, "Setting negative gamma to zero");
gamma=0;
}
else
gamma=int_gamma;
}
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
info_ptr->gamma = (float)(int_gamma/100000.); info_ptr->gamma = (float)(gamma/100000.);
#endif #endif
#ifdef PNG_FIXED_POINT_SUPPORTED #ifdef PNG_FIXED_POINT_SUPPORTED
info_ptr->int_gamma = int_gamma; info_ptr->int_gamma = gamma;
#endif #endif
info_ptr->valid |= PNG_INFO_gAMA; info_ptr->valid |= PNG_INFO_gAMA;
if(gamma == 0)
png_warning(png_ptr, "Setting gamma=0");
} }
#endif
#if defined(PNG_hIST_SUPPORTED) #if defined(PNG_hIST_SUPPORTED)
void PNGAPI 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)
{ {
int i; int i;
png_debug1(1, "in %s storage function\n", "hIST"); png_debug1(1, "in %s storage function\n", "hIST");
if (png_ptr == NULL || info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
if (info_ptr->num_palette == 0) if (info_ptr->num_palette == 0)
{
png_warning(png_ptr, png_warning(png_ptr,
"Palette size 0, hIST allocation skipped."); "Palette size 0, hIST allocation skipped.");
return;
}
#ifdef PNG_FREE_ME_SUPPORTED #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);
#endif #endif
png_ptr->hist = (png_uint_16p)png_malloc(png_ptr, /* Changed from info->num_palette to 256 in version 1.2.1 */
(png_uint_32)(info_ptr->num_palette * sizeof (png_uint_16))); png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr,
(png_uint_32)(256 * sizeof (png_uint_16)));
if (png_ptr->hist == NULL)
{
png_warning(png_ptr, "Insufficient memory for hIST chunk data.");
return;
}
for (i = 0; i < info_ptr->num_palette; i++) for (i = 0; i < info_ptr->num_palette; i++)
png_ptr->hist[i] = hist[i]; png_ptr->hist[i] = hist[i];
@@ -172,6 +248,61 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
if (png_ptr == NULL || info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; return;
/* check for width and height valid values */
if (width == 0 || height == 0)
png_error(png_ptr, "Image width or height is zero in IHDR");
if (width > PNG_MAX_UINT || height > PNG_MAX_UINT)
png_error(png_ptr, "Invalid image size in IHDR");
/* check other values */
if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 &&
bit_depth != 8 && bit_depth != 16)
png_error(png_ptr, "Invalid bit depth in IHDR");
if (color_type < 0 || color_type == 1 ||
color_type == 5 || color_type > 6)
png_error(png_ptr, "Invalid color type in IHDR");
if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) ||
((color_type == PNG_COLOR_TYPE_RGB ||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA ||
color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8))
png_error(png_ptr, "Invalid color type/bit depth combination in IHDR");
if (interlace_type >= PNG_INTERLACE_LAST)
png_error(png_ptr, "Unknown interlace method in IHDR");
if (compression_type != PNG_COMPRESSION_TYPE_BASE)
png_error(png_ptr, "Unknown compression method in IHDR");
#if defined(PNG_MNG_FEATURES_SUPPORTED)
/* Accept filter_method 64 (intrapixel differencing) only if
* 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and
* 2. Libpng did not read a PNG signature (this filter_method is only
* used in PNG datastreams that are embedded in MNG datastreams) and
* 3. The application called png_permit_mng_features with a mask that
* included PNG_FLAG_MNG_FILTER_64 and
* 4. The filter_method is 64 and
* 5. The color_type is RGB or RGBA
*/
if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted)
png_warning(png_ptr,"MNG features are not allowed in a PNG datastream\n");
if(filter_type != PNG_FILTER_TYPE_BASE)
{
if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
(filter_type == PNG_INTRAPIXEL_DIFFERENCING) &&
((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&
(color_type == PNG_COLOR_TYPE_RGB ||
color_type == PNG_COLOR_TYPE_RGB_ALPHA)))
png_error(png_ptr, "Unknown filter method in IHDR");
if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)
png_warning(png_ptr, "Invalid filter method in IHDR");
}
#else
if(filter_type != PNG_FILTER_TYPE_BASE)
png_error(png_ptr, "Unknown filter method in IHDR");
#endif
info_ptr->width = width; info_ptr->width = width;
info_ptr->height = height; info_ptr->height = height;
info_ptr->bit_depth = (png_byte)bit_depth; info_ptr->bit_depth = (png_byte)bit_depth;
@@ -191,7 +322,7 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
/* check for overflow */ /* check for overflow */
rowbytes_per_pixel = (info_ptr->pixel_depth + 7) >> 3; rowbytes_per_pixel = (info_ptr->pixel_depth + 7) >> 3;
if (( width > PNG_MAX_UINT/rowbytes_per_pixel)) if ( width > PNG_MAX_UINT/rowbytes_per_pixel - 64)
{ {
png_warning(png_ptr, png_warning(png_ptr,
"Width too large to process image data; rowbytes will overflow."); "Width too large to process image data; rowbytes will overflow.");
@@ -232,7 +363,12 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
length = png_strlen(purpose) + 1; length = png_strlen(purpose) + 1;
png_debug1(3, "allocating purpose for info (%lu 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_warn(png_ptr, length);
if (info_ptr->pcal_purpose == NULL)
{
png_warning(png_ptr, "Insufficient memory for pCAL purpose.");
return;
}
png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length); png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length);
png_debug(3, "storing X0, X1, type, and nparams in info\n"); png_debug(3, "storing X0, X1, type, and nparams in info\n");
@@ -243,18 +379,34 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
length = png_strlen(units) + 1; length = png_strlen(units) + 1;
png_debug1(3, "allocating units for info (%lu 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_warn(png_ptr, length);
if (info_ptr->pcal_units == NULL)
{
png_warning(png_ptr, "Insufficient memory for pCAL units.");
return;
}
png_memcpy(info_ptr->pcal_units, units, (png_size_t)length); png_memcpy(info_ptr->pcal_units, units, (png_size_t)length);
info_ptr->pcal_params = (png_charpp)png_malloc(png_ptr, info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr,
(png_uint_32)((nparams + 1) * sizeof(png_charp))); (png_uint_32)((nparams + 1) * sizeof(png_charp)));
if (info_ptr->pcal_params == NULL)
{
png_warning(png_ptr, "Insufficient memory for pCAL params.");
return;
}
info_ptr->pcal_params[nparams] = NULL; info_ptr->pcal_params[nparams] = NULL;
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 (%lu 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_warn(png_ptr, length);
if (info_ptr->pcal_params[i] == NULL)
{
png_warning(png_ptr, "Insufficient memory for pCAL parameter.");
return;
}
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);
} }
@@ -302,7 +454,7 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
length = png_strlen(sheight) + 1; length = png_strlen(sheight) + 1;
png_debug1(3, "allocating unit for info (%d bytes)\n", length); png_debug1(3, "allocating unit for info (%d bytes)\n", length);
info_ptr->scal_s_width = (png_charp)png_malloc(png_ptr, length); info_ptr->scal_s_height = (png_charp)png_malloc(png_ptr, length);
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;
@@ -347,9 +499,13 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
#ifdef PNG_FREE_ME_SUPPORTED #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);
#endif #endif
png_ptr->palette = (png_colorp)png_zalloc(png_ptr, (uInt)num_palette, /* Changed in libpng-1.2.1 to allocate 256 instead of num_palette entries,
in case of an invalid PNG file that has too-large sample values. */
png_ptr->palette = (png_colorp)png_zalloc(png_ptr, (uInt)256,
sizeof (png_color)); sizeof (png_color));
memcpy(png_ptr->palette, palette, num_palette * sizeof (png_color)); if (png_ptr->palette == NULL)
png_error(png_ptr, "Unable to malloc palette");
png_memcpy(png_ptr->palette, palette, num_palette * sizeof (png_color));
info_ptr->palette = png_ptr->palette; info_ptr->palette = png_ptr->palette;
info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
@@ -472,9 +628,9 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL) if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)
return; return;
new_iccp_name = png_malloc(png_ptr, png_strlen(name)+1); new_iccp_name = (png_charp)png_malloc(png_ptr, png_strlen(name)+1);
strcpy(new_iccp_name, name); png_strcpy(new_iccp_name, name);
new_iccp_profile = png_malloc(png_ptr, proflen); new_iccp_profile = (png_charp)png_malloc(png_ptr, proflen);
png_memcpy(new_iccp_profile, profile, (png_size_t)proflen); png_memcpy(new_iccp_profile, profile, (png_size_t)proflen);
png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0); png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0);
@@ -496,6 +652,16 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
void PNGAPI 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)
{
int ret;
ret=png_set_text_2(png_ptr, info_ptr, text_ptr, num_text);
if (ret)
png_error(png_ptr, "Insufficient memory to store text");
}
int /* PRIVATE */
png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
int num_text)
{ {
int i; int i;
@@ -503,7 +669,7 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
"text" : (png_const_charp)png_ptr->chunk_name)); "text" : (png_const_charp)png_ptr->chunk_name));
if (png_ptr == NULL || info_ptr == NULL || num_text == 0) if (png_ptr == NULL || info_ptr == NULL || num_text == 0)
return; return(0);
/* Make sure we have enough space in the "text" array in info_struct /* Make sure we have enough space in the "text" array in info_struct
* to hold all of the incoming text_ptr objects. * to hold all of the incoming text_ptr objects.
@@ -518,8 +684,13 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
old_max = info_ptr->max_text; old_max = info_ptr->max_text;
info_ptr->max_text = info_ptr->num_text + num_text + 8; info_ptr->max_text = info_ptr->num_text + num_text + 8;
old_text = info_ptr->text; old_text = info_ptr->text;
info_ptr->text = (png_textp)png_malloc(png_ptr, info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
(png_uint_32)(info_ptr->max_text * sizeof (png_text))); (png_uint_32)(info_ptr->max_text * sizeof (png_text)));
if (info_ptr->text == NULL)
{
png_free(png_ptr, old_text);
return(1);
}
png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max * png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max *
sizeof(png_text))); sizeof(png_text)));
png_free(png_ptr, old_text); png_free(png_ptr, old_text);
@@ -528,8 +699,10 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
{ {
info_ptr->max_text = num_text + 8; info_ptr->max_text = num_text + 8;
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_warn(png_ptr,
(png_uint_32)(info_ptr->max_text * sizeof (png_text))); (png_uint_32)(info_ptr->max_text * sizeof (png_text)));
if (info_ptr->text == NULL)
return(1);
#ifdef PNG_FREE_ME_SUPPORTED #ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_TEXT; info_ptr->free_me |= PNG_FREE_TEXT;
#endif #endif
@@ -543,7 +716,7 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
png_size_t lang_len,lang_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 == NULL)
continue; continue;
key_len = png_strlen(text_ptr[i].key); key_len = png_strlen(text_ptr[i].key);
@@ -557,11 +730,11 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
#ifdef PNG_iTXt_SUPPORTED #ifdef PNG_iTXt_SUPPORTED
{ {
/* set iTXt data */ /* set iTXt data */
if (text_ptr[i].key != (png_charp)NULL) if (text_ptr[i].lang != NULL)
lang_len = png_strlen(text_ptr[i].lang); lang_len = png_strlen(text_ptr[i].lang);
else else
lang_len = 0; lang_len = 0;
if (text_ptr[i].lang_key != (png_charp)NULL) if (text_ptr[i].lang_key != NULL)
lang_key_len = png_strlen(text_ptr[i].lang_key); lang_key_len = png_strlen(text_ptr[i].lang_key);
else else
lang_key_len = 0; lang_key_len = 0;
@@ -573,7 +746,7 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
} }
#endif #endif
if (text_ptr[i].text == (png_charp)NULL || text_ptr[i].text[0] == '\0') if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0')
{ {
text_length = 0; text_length = 0;
#ifdef PNG_iTXt_SUPPORTED #ifdef PNG_iTXt_SUPPORTED
@@ -589,10 +762,13 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
textp->compression = text_ptr[i].compression; textp->compression = text_ptr[i].compression;
} }
textp->key = (png_charp)png_malloc(png_ptr, textp->key = (png_charp)png_malloc_warn(png_ptr,
(png_uint_32)(key_len + text_length + lang_len + lang_key_len + 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", if (textp->key == NULL)
key_len + lang_len + lang_key_len + text_length + 4, (int)textp->key); return(1);
png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n",
(png_uint_32)(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));
@@ -612,8 +788,8 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
#endif #endif
{ {
#ifdef PNG_iTXt_SUPPORTED #ifdef PNG_iTXt_SUPPORTED
textp->lang=(png_charp)NULL; textp->lang=NULL;
textp->lang_key=(png_charp)NULL; textp->lang_key=NULL;
#endif #endif
textp->text=textp->key + key_len + 1; textp->text=textp->key + key_len + 1;
} }
@@ -640,6 +816,7 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
info_ptr->num_text++; info_ptr->num_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);
} }
return(0);
} }
#endif #endif
@@ -669,15 +846,17 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
if (trans != NULL) if (trans != NULL)
{ {
/* /*
* It may not actually be necessary to set png_ptr->trans here; * It may not actually be necessary to set png_ptr->trans here;
* we do it for backward compatibility with the way the png_handle_tRNS * we do it for backward compatibility with the way the png_handle_tRNS
* function used to do the allocation. * function used to do the allocation.
*/ */
#ifdef PNG_FREE_ME_SUPPORTED #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);
#endif #endif
png_ptr->trans = info_ptr->trans = png_malloc(png_ptr, num_trans); /* Changed from num_trans to 256 in version 1.2.1 */
memcpy(info_ptr->trans, trans, num_trans); png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr,
(png_uint_32)256);
png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans);
#ifdef PNG_FREE_ME_SUPPORTED #ifdef PNG_FREE_ME_SUPPORTED
info_ptr->free_me |= PNG_FREE_TRNS; info_ptr->free_me |= PNG_FREE_TRNS;
#else #else
@@ -705,8 +884,13 @@ png_set_sPLT(png_structp png_ptr,
png_sPLT_tp np; png_sPLT_tp np;
int i; int i;
np = (png_sPLT_tp)png_malloc(png_ptr, np = (png_sPLT_tp)png_malloc_warn(png_ptr,
(info_ptr->splt_palettes_num + nentries) * sizeof(png_sPLT_t)); (info_ptr->splt_palettes_num + nentries) * sizeof(png_sPLT_t));
if (np == NULL)
{
png_warning(png_ptr, "No memory for sPLT palettes.");
return;
}
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));
@@ -719,12 +903,12 @@ png_set_sPLT(png_structp png_ptr,
png_sPLT_tp from = entries + i; png_sPLT_tp from = entries + i;
to->name = (png_charp)png_malloc(png_ptr, to->name = (png_charp)png_malloc(png_ptr,
png_strlen(from->name) + 1); png_strlen(from->name) + 1);
png_strcpy(to->name, from->name); png_strcpy(to->name, from->name);
to->entries = (png_sPLT_entryp)png_malloc(png_ptr, to->entries = (png_sPLT_entryp)png_malloc(png_ptr,
from->nentries * sizeof(png_sPLT_t)); from->nentries * sizeof(png_sPLT_t));
png_memcpy(to->entries, from->entries, png_memcpy(to->entries, from->entries,
from->nentries * sizeof(png_sPLT_t)); from->nentries * sizeof(png_sPLT_t));
to->nentries = from->nentries; to->nentries = from->nentries;
to->depth = from->depth; to->depth = from->depth;
} }
@@ -738,7 +922,7 @@ png_set_sPLT(png_structp png_ptr,
} }
#endif /* PNG_sPLT_SUPPORTED */ #endif /* PNG_sPLT_SUPPORTED */
#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
void PNGAPI 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)
@@ -749,9 +933,14 @@ png_set_unknown_chunks(png_structp png_ptr,
if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0) if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0)
return; return;
np = (png_unknown_chunkp)png_malloc(png_ptr, np = (png_unknown_chunkp)png_malloc_warn(png_ptr,
(info_ptr->unknown_chunks_num + num_unknowns) * (info_ptr->unknown_chunks_num + num_unknowns) *
sizeof(png_unknown_chunk)); sizeof(png_unknown_chunk));
if (np == NULL)
{
png_warning(png_ptr, "Out of memory while processing unknown chunk.");
return;
}
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));
@@ -765,11 +954,16 @@ png_set_unknown_chunks(png_structp png_ptr,
png_strcpy((png_charp)to->name, (png_charp)from->name); png_strcpy((png_charp)to->name, (png_charp)from->name);
to->data = (png_bytep)png_malloc(png_ptr, from->size); to->data = (png_bytep)png_malloc(png_ptr, from->size);
png_memcpy(to->data, from->data, from->size); if (to->data == NULL)
to->size = from->size; png_warning(png_ptr, "Out of memory while processing unknown chunk.");
else
{
png_memcpy(to->data, from->data, from->size);
to->size = from->size;
/* note our location in the read or write sequence */ /* note our location in the read or write sequence */
to->location = (png_byte)(png_ptr->mode & 0xff); to->location = (png_byte)(png_ptr->mode & 0xff);
}
} }
info_ptr->unknown_chunks = np; info_ptr->unknown_chunks = np;
@@ -840,14 +1034,17 @@ png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep
if (chunk_list == NULL) if (chunk_list == NULL)
return; return;
old_num_chunks=png_ptr->num_chunk_list; old_num_chunks=png_ptr->num_chunk_list;
new_list=png_malloc(png_ptr,5*(num_chunks+old_num_chunks)); new_list=(png_bytep)png_malloc(png_ptr,
if(png_ptr->chunk_list != (png_bytep)NULL) (png_uint_32)(5*(num_chunks+old_num_chunks)));
if(png_ptr->chunk_list != NULL)
{ {
png_memcpy(new_list, png_ptr->chunk_list, 5*old_num_chunks); png_memcpy(new_list, png_ptr->chunk_list,
(png_size_t)(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_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,
(png_size_t)(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;
@@ -883,7 +1080,6 @@ png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers)
info_ptr->row_pointers = row_pointers; info_ptr->row_pointers = row_pointers;
if(row_pointers) if(row_pointers)
info_ptr->valid |= PNG_INFO_IDAT; info_ptr->valid |= PNG_INFO_IDAT;
} }
#endif #endif
@@ -894,8 +1090,6 @@ png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size)
png_free(png_ptr, png_ptr->zbuf); png_free(png_ptr, png_ptr->zbuf);
png_ptr->zbuf_size = (png_size_t)size; png_ptr->zbuf_size = (png_size_t)size;
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, 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.next_out = png_ptr->zbuf;
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
} }
@@ -907,3 +1101,60 @@ png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask)
info_ptr->valid &= ~(mask); info_ptr->valid &= ~(mask);
} }
#ifndef PNG_1_0_X
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
/* this function was added to libpng 1.2.0 and should always exist by default */
void PNGAPI
png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags)
{
png_uint_32 settable_asm_flags;
png_uint_32 settable_mmx_flags;
settable_mmx_flags =
#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
#endif
#ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE
PNG_ASM_FLAG_MMX_READ_INTERLACE |
#endif
#ifdef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
PNG_ASM_FLAG_MMX_READ_FILTER_UP |
PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
PNG_ASM_FLAG_MMX_READ_FILTER_PAETH |
#endif
0;
/* could be some non-MMX ones in the future, but not currently: */
settable_asm_flags = settable_mmx_flags;
if (!(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_COMPILED) ||
!(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU))
{
/* clear all MMX flags if MMX isn't supported */
settable_asm_flags &= ~settable_mmx_flags;
png_ptr->asm_flags &= ~settable_mmx_flags;
}
/* we're replacing the settable bits with those passed in by the user,
* so first zero them out of the master copy, then logical-OR in the
* allowed subset that was requested */
png_ptr->asm_flags &= ~settable_asm_flags; /* zero them */
png_ptr->asm_flags |= (asm_flags & settable_asm_flags); /* set them */
}
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
/* this function was added to libpng 1.2.0 */
void PNGAPI
png_set_mmx_thresholds (png_structp png_ptr,
png_byte mmx_bitdepth_threshold,
png_uint_32 mmx_rowbytes_threshold)
{
png_ptr->mmx_bitdepth_threshold = mmx_bitdepth_threshold;
png_ptr->mmx_rowbytes_threshold = mmx_rowbytes_threshold;
}
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
#endif /* ?PNG_1_0_X */

194
pngtest.c
View File

@@ -1,9 +1,9 @@
/* pngtest.c - a simple test program to test libpng /* pngtest.c - a simple test program to test libpng
* *
* libpng 1.0.9 - January 31, 2001 * libpng 1.0.14 - July 8, 2002
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2002 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
@@ -51,16 +51,20 @@
#endif #endif
#if defined(PNG_NO_STDIO) #if defined(PNG_NO_STDIO)
#if defined(_WIN32_WCE) # if defined(_WIN32_WCE)
typedef HANDLE png_FILE_p; typedef HANDLE png_FILE_p;
#else # else
typedef FILE * png_FILE_p; typedef FILE * png_FILE_p;
#endif # endif
#endif #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
#define PNG_DEBUG 0 # define PNG_DEBUG 0
#endif
#if !PNG_DEBUG
# define SINGLE_ROWBUF_ALLOC /* makes buffer overruns easier to nail */
#endif #endif
/* Turn on CPU timing /* Turn on CPU timing
@@ -113,7 +117,13 @@ static int status_dots_requested=0;
static int status_dots=1; static int status_dots=1;
void void
#ifdef PNG_1_0_X
PNGAPI
#endif
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);
#ifdef PNG_1_0_X
PNGAPI
#endif
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)
{ {
@@ -133,8 +143,14 @@ read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
fprintf(stdout, "r"); fprintf(stdout, "r");
} }
#ifdef PNG_1_0_X
PNGAPI
#endif
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);
#ifdef PNG_1_0_X
PNGAPI
#endif
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)
{ {
@@ -149,8 +165,14 @@ 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
#ifdef PNG_1_0_X
PNGAPI
#endif
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);
void void
#ifdef PNG_1_0_X
PNGAPI
#endif
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)
@@ -165,8 +187,14 @@ 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 void
#ifdef PNG_1_0_X
PNGAPI
#endif
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);
void void
#ifdef PNG_1_0_X
PNGAPI
#endif
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)
{ {
png_bytep dp = data; png_bytep dp = data;
@@ -279,7 +307,7 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
if (check != length) if (check != length)
{ {
png_error(png_ptr, "Read Error"); png_error(png_ptr, "Read Error!");
} }
} }
#else #else
@@ -466,10 +494,8 @@ static int maximum_allocation = 0;
static int total_allocation = 0; static int total_allocation = 0;
static int num_allocations = 0; static int num_allocations = 0;
extern PNG_EXPORT(png_voidp,png_debug_malloc) PNGARG((png_structp png_ptr, png_voidp png_debug_malloc PNGARG((png_structp png_ptr, png_uint_32 size));
png_uint_32 size)); void png_debug_free PNGARG((png_structp png_ptr, png_voidp ptr));
extern PNG_EXPORT(void,png_debug_free) PNGARG((png_structp png_ptr,
png_voidp ptr));
png_voidp png_voidp
png_debug_malloc(png_structp png_ptr, png_uint_32 size) png_debug_malloc(png_structp png_ptr, png_uint_32 size)
@@ -479,26 +505,27 @@ png_debug_malloc(png_structp png_ptr, png_uint_32 size)
png_debug_malloc directly, with png_ptr == NULL which is OK */ png_debug_malloc directly, with png_ptr == NULL which is OK */
if (size == 0) if (size == 0)
return (png_voidp)(NULL); return (NULL);
/* This calls the library allocator twice, once to get the requested /* This calls the library allocator twice, once to get the requested
buffer and once to get a new free list entry. */ buffer and once to get a new free list entry. */
{ {
memory_infop pinfo = png_malloc_default(png_ptr, sizeof *pinfo); memory_infop pinfo = (memory_infop)png_malloc_default(png_ptr,
(png_uint_32)sizeof *pinfo);
pinfo->size = size; pinfo->size = size;
current_allocation += size; current_allocation += size;
total_allocation += size; total_allocation += size;
num_allocations ++; 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_voidp)png_malloc_default(png_ptr, size);
pinfo->next = pinformation; pinfo->next = pinformation;
pinformation = pinfo; pinformation = pinfo;
/* Make sure the caller isn't assuming zeroed memory. */ /* Make sure the caller isn't assuming zeroed memory. */
png_memset(pinfo->pointer, 0xdd, pinfo->size); png_memset(pinfo->pointer, 0xdd, pinfo->size);
#if PNG_DEBUG #if PNG_DEBUG
if(verbose) if(verbose)
printf("png_malloc %d bytes at %x\n",size,pinfo->pointer); printf("png_malloc %lu bytes at %x\n",size,pinfo->pointer);
#endif #endif
assert(pinfo->size != 12345678); assert(pinfo->size != 12345678);
return (png_voidp)(pinfo->pointer); return (png_voidp)(pinfo->pointer);
@@ -533,14 +560,14 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
fprintf(STDERR, "Duplicate free of memory\n"); fprintf(STDERR, "Duplicate free of memory\n");
/* We must free the list element too, but first kill /* We must free the list element too, but first kill
the memory that is to be freed. */ the memory that is to be freed. */
memset(ptr, 0x55, pinfo->size); png_memset(ptr, 0x55, pinfo->size);
png_free_default(png_ptr, pinfo); png_free_default(png_ptr, pinfo);
pinfo=NULL; pinfo=NULL;
break; break;
} }
if (pinfo->next == NULL) if (pinfo->next == NULL)
{ {
fprintf(STDERR, "Pointer %x not found\n", ptr); fprintf(STDERR, "Pointer %x not found\n", (unsigned int)ptr);
break; break;
} }
ppinfo = &pinfo->next; ppinfo = &pinfo->next;
@@ -564,8 +591,17 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
{ {
static png_FILE_p fpin; static png_FILE_p fpin;
static png_FILE_p fpout; /* "static" prevents setjmp corruption */ static png_FILE_p fpout; /* "static" prevents setjmp corruption */
png_structp read_ptr, write_ptr; png_structp read_ptr;
png_infop read_info_ptr, write_info_ptr, end_info_ptr, write_end_info_ptr; png_infop read_info_ptr, end_info_ptr;
#ifdef PNG_WRITE_SUPPORTED
png_structp write_ptr;
png_infop write_info_ptr;
png_infop write_end_info_ptr;
#else
png_structp write_ptr = NULL;
png_infop write_info_ptr = NULL;
png_infop write_end_info_ptr = NULL;
#endif
png_bytep row_buf; png_bytep row_buf;
png_uint_32 y; png_uint_32 y;
png_uint_32 width, height; png_uint_32 width, height;
@@ -582,7 +618,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#endif #endif
char inbuf[256], outbuf[256]; char inbuf[256], outbuf[256];
row_buf = (png_bytep)NULL; row_buf = NULL;
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH);
@@ -609,35 +645,37 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_debug(0, "Allocating read and write structures\n"); png_debug(0, "Allocating read and write structures\n");
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
read_ptr = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, read_ptr = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
(png_error_ptr)NULL, (png_error_ptr)NULL, (png_voidp)NULL, png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL,
(png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free);
#else #else
read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
(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, pngtest_error, png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error,
pngtest_warning); pngtest_warning);
#endif #endif
#ifdef PNG_WRITE_SUPPORTED
#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,
(png_error_ptr)NULL, (png_error_ptr)NULL, (png_voidp)NULL, png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL,
(png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free);
#else #else
write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
(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, pngtest_error, png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error,
pngtest_warning); pngtest_warning);
#endif
#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);
write_info_ptr = png_create_info_struct(write_ptr);
end_info_ptr = png_create_info_struct(read_ptr); end_info_ptr = png_create_info_struct(read_ptr);
#ifdef PNG_WRITE_SUPPORTED
write_info_ptr = png_create_info_struct(write_ptr);
write_end_info_ptr = png_create_info_struct(write_ptr); write_end_info_ptr = png_create_info_struct(write_ptr);
#ifdef PNG_USER_MEM_SUPPORTED
#endif #endif
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
@@ -649,9 +687,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#endif #endif
{ {
fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname); fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname);
if (row_buf)
png_free(read_ptr, row_buf);
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
#ifdef PNG_WRITE_SUPPORTED
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);
#endif
FCLOSE(fpin); FCLOSE(fpin);
FCLOSE(fpout); FCLOSE(fpout);
return (1); return (1);
@@ -660,6 +702,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_memcpy(png_jmpbuf(read_ptr),jmpbuf,sizeof(jmp_buf)); png_memcpy(png_jmpbuf(read_ptr),jmpbuf,sizeof(jmp_buf));
#endif #endif
#ifdef PNG_WRITE_SUPPORTED
png_debug(0, "Setting jmpbuf for write struct\n"); png_debug(0, "Setting jmpbuf for write struct\n");
#ifdef USE_FAR_KEYWORD #ifdef USE_FAR_KEYWORD
if (setjmp(jmpbuf)) if (setjmp(jmpbuf))
@@ -670,7 +713,9 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname); fprintf(STDERR, "%s -> %s: libpng write error\n", inname, 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);
#ifdef PNG_WRITE_SUPPORTED
png_destroy_write_struct(&write_ptr, &write_info_ptr); png_destroy_write_struct(&write_ptr, &write_info_ptr);
#endif
FCLOSE(fpin); FCLOSE(fpin);
FCLOSE(fpout); FCLOSE(fpout);
return (1); return (1);
@@ -678,30 +723,39 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#ifdef USE_FAR_KEYWORD #ifdef USE_FAR_KEYWORD
png_memcpy(png_jmpbuf(write_ptr),jmpbuf,sizeof(jmp_buf)); png_memcpy(png_jmpbuf(write_ptr),jmpbuf,sizeof(jmp_buf));
#endif #endif
#endif
#endif #endif
png_debug(0, "Initializing input and output streams\n"); png_debug(0, "Initializing input and output streams\n");
#if !defined(PNG_NO_STDIO) #if !defined(PNG_NO_STDIO)
png_init_io(read_ptr, fpin); png_init_io(read_ptr, fpin);
# ifdef PNG_WRITE_SUPPORTED
png_init_io(write_ptr, fpout); png_init_io(write_ptr, fpout);
# endif
#else #else
png_set_read_fn(read_ptr, (png_voidp)fpin, pngtest_read_data); png_set_read_fn(read_ptr, (png_voidp)fpin, pngtest_read_data);
# ifdef PNG_WRITE_SUPPORTED
png_set_write_fn(write_ptr, (png_voidp)fpout, pngtest_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)
pngtest_flush); pngtest_flush);
#else # else
NULL); NULL);
#endif # endif
# endif
#endif #endif
if(status_dots_requested == 1) if(status_dots_requested == 1)
{ {
#ifdef PNG_WRITE_SUPPORTED
png_set_write_status_fn(write_ptr, write_row_callback); png_set_write_status_fn(write_ptr, write_row_callback);
#endif
png_set_read_status_fn(read_ptr, read_row_callback); png_set_read_status_fn(read_ptr, read_row_callback);
} }
else else
{ {
png_set_write_status_fn(write_ptr, NULL); #ifdef PNG_WRITE_SUPPORTED
png_set_read_status_fn(read_ptr, NULL); png_set_write_status_fn(write_ptr, png_write_status_ptr_NULL);
#endif
png_set_read_status_fn(read_ptr, png_read_status_ptr_NULL);
} }
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
@@ -720,10 +774,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#define HANDLE_CHUNK_IF_SAFE 2 #define HANDLE_CHUNK_IF_SAFE 2
#define HANDLE_CHUNK_ALWAYS 3 #define HANDLE_CHUNK_ALWAYS 3
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
png_set_keep_unknown_chunks(read_ptr, HANDLE_CHUNK_ALWAYS, NULL, 0); png_set_keep_unknown_chunks(read_ptr, HANDLE_CHUNK_ALWAYS,
png_bytep_NULL, 0);
#endif #endif
#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) #if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED)
png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_IF_SAFE, NULL, 0); png_set_keep_unknown_chunks(write_ptr, HANDLE_CHUNK_IF_SAFE,
png_bytep_NULL, 0);
#endif #endif
png_debug(0, "Reading info struct\n"); png_debug(0, "Reading info struct\n");
@@ -984,32 +1040,29 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
} }
#endif #endif
#ifdef PNG_WRITE_SUPPORTED
png_debug(0, "\nWriting info struct\n"); png_debug(0, "\nWriting info struct\n");
/* If we wanted, we could write info in two steps: /* If we wanted, we could write info in two steps:
png_write_info_before_PLTE(write_ptr, write_info_ptr); png_write_info_before_PLTE(write_ptr, write_info_ptr);
*/ */
png_write_info(write_ptr, write_info_ptr); png_write_info(write_ptr, write_info_ptr);
#endif
png_debug(0, "\nAllocating row buffer \n"); #ifdef SINGLE_ROWBUF_ALLOC
png_debug(0, "\nAllocating row buffer...");
row_buf = (png_bytep)png_malloc(read_ptr, row_buf = (png_bytep)png_malloc(read_ptr,
png_get_rowbytes(read_ptr, read_info_ptr)); png_get_rowbytes(read_ptr, read_info_ptr));
if (row_buf == NULL) png_debug1(0, "0x%08lx\n\n", (unsigned long)row_buf);
{ #endif /* SINGLE_ROWBUF_ALLOC */
fprintf(STDERR, "No memory to allocate row buffer\n");
png_destroy_read_struct(&read_ptr, &read_info_ptr, (png_infopp)NULL);
png_destroy_info_struct(write_ptr, &write_end_info_ptr);
png_destroy_write_struct(&write_ptr, &write_info_ptr);
FCLOSE(fpin);
FCLOSE(fpout);
return (1);
}
png_debug(0, "Writing row data\n"); png_debug(0, "Writing row data\n");
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ #if defined(PNG_READ_INTERLACING_SUPPORTED) || \
defined(PNG_WRITE_INTERLACING_SUPPORTED) defined(PNG_WRITE_INTERLACING_SUPPORTED)
num_pass = png_set_interlace_handling(read_ptr); num_pass = png_set_interlace_handling(read_ptr);
# ifdef PNG_WRITE_SUPPORTED
png_set_interlace_handling(write_ptr); png_set_interlace_handling(write_ptr);
# endif
#else #else
num_pass=1; num_pass=1;
#endif #endif
@@ -1024,7 +1077,16 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_debug1(0, "Writing row data for pass %d\n",pass); png_debug1(0, "Writing row data for pass %d\n",pass);
for (y = 0; y < height; y++) for (y = 0; y < height; y++)
{ {
png_read_rows(read_ptr, (png_bytepp)&row_buf, (png_bytepp)NULL, 1); #ifndef SINGLE_ROWBUF_ALLOC
png_debug2(0, "\nAllocating row buffer (pass %d, y = %ld)...", pass,y);
row_buf = (png_bytep)png_malloc(read_ptr,
png_get_rowbytes(read_ptr, read_info_ptr));
png_debug2(0, "0x%08lx (%ld bytes)\n", (unsigned long)row_buf,
png_get_rowbytes(read_ptr, read_info_ptr));
#endif /* !SINGLE_ROWBUF_ALLOC */
png_read_rows(read_ptr, (png_bytepp)&row_buf, png_bytepp_NULL, 1);
#ifdef PNG_WRITE_SUPPORTED
#ifdef PNGTEST_TIMING #ifdef PNGTEST_TIMING
t_stop = (float)clock(); t_stop = (float)clock();
t_decode += (t_stop - t_start); t_decode += (t_stop - t_start);
@@ -1036,6 +1098,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
t_encode += (t_stop - t_start); t_encode += (t_stop - t_start);
t_start = t_stop; t_start = t_stop;
#endif #endif
#endif /* PNG_WRITE_SUPPORTED */
#ifndef SINGLE_ROWBUF_ALLOC
png_debug2(0, "Freeing row buffer (pass %d, y = %ld)\n\n", pass, y);
png_free(read_ptr, row_buf);
#endif /* !SINGLE_ROWBUF_ALLOC */
} }
} }
@@ -1098,7 +1166,9 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
} }
} }
#endif #endif
#ifdef PNG_WRITE_SUPPORTED
png_write_end(write_ptr, write_end_info_ptr); png_write_end(write_ptr, write_end_info_ptr);
#endif
#ifdef PNG_EASY_ACCESS_SUPPORTED #ifdef PNG_EASY_ACCESS_SUPPORTED
if(verbose) if(verbose)
@@ -1112,11 +1182,20 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#endif #endif
png_debug(0, "Destroying data structs\n"); png_debug(0, "Destroying data structs\n");
#ifdef SINGLE_ROWBUF_ALLOC
png_debug(1, "destroying row_buf for read_ptr\n");
png_free(read_ptr, row_buf); png_free(read_ptr, row_buf);
row_buf=NULL; row_buf=NULL;
#endif /* SINGLE_ROWBUF_ALLOC */
png_debug(1, "destroying read_ptr, read_info_ptr, end_info_ptr\n");
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
#ifdef PNG_WRITE_SUPPORTED
png_debug(1, "destroying write_end_info_ptr\n");
png_destroy_info_struct(write_ptr, &write_end_info_ptr); png_destroy_info_struct(write_ptr, &write_end_info_ptr);
png_debug(1, "destroying write_ptr, write_info_ptr\n");
png_destroy_write_struct(&write_ptr, &write_info_ptr); png_destroy_write_struct(&write_ptr, &write_info_ptr);
#endif
png_debug(0, "Destruction complete.\n");
FCLOSE(fpin); FCLOSE(fpin);
FCLOSE(fpout); FCLOSE(fpout);
@@ -1227,8 +1306,8 @@ main(int argc, char *argv[])
/* Show the version of libpng used in building the application */ /* Show the version of libpng used in building the application */
fprintf(STDERR," pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER, fprintf(STDERR," pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER,
PNG_HEADER_VERSION_STRING); PNG_HEADER_VERSION_STRING);
fprintf(STDERR," sizeof(png_struct)=%d, sizeof(png_info)=%d\n", fprintf(STDERR," sizeof(png_struct)=%ld, sizeof(png_info)=%ld\n",
sizeof(png_struct), sizeof(png_info)); (long)sizeof(png_struct), (long)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
@@ -1343,7 +1422,8 @@ main(int argc, char *argv[])
current_allocation); current_allocation);
while (pinfo != NULL) while (pinfo != NULL)
{ {
fprintf(STDERR, " %d bytes at %x\n", pinfo->size, pinfo->pointer); fprintf(STDERR, " %lu bytes at %x\n", pinfo->size,
(unsigned int) pinfo->pointer);
pinfo = pinfo->next; pinfo = pinfo->next;
} }
} }
@@ -1417,8 +1497,8 @@ main(int argc, char *argv[])
current_allocation); current_allocation);
while (pinfo != NULL) while (pinfo != NULL)
{ {
fprintf(STDERR," %d bytes at %x\n", fprintf(STDERR," %lu bytes at %x\n",
pinfo->size, pinfo->pointer); pinfo->size, (unsigned int)pinfo->pointer);
pinfo = pinfo->next; pinfo = pinfo->next;
} }
} }
@@ -1458,4 +1538,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_9 your_png_h_is_not_version_1_0_9; typedef version_1_0_14 your_png_h_is_not_version_1_0_14;

View File

@@ -1,9 +1,9 @@
/* 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.9 - January 31, 2001 * libpng 1.0.14 - July 8, 2002
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2002 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/ */
@@ -153,11 +153,14 @@ 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");
if (row_info->bit_depth == 1 && /* This test removed from libpng version 1.0.13 and 1.2.0:
* if (row_info->bit_depth == 1 &&
*/
#if defined(PNG_USELESS_TESTS_SUPPORTED) #if defined(PNG_USELESS_TESTS_SUPPORTED)
row != NULL && row_info != NULL && if (row == NULL || row_info == NULL)
return;
#endif #endif
row_info->color_type == PNG_COLOR_TYPE_GRAY) if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
{ {
png_bytep rp = row; png_bytep rp = row;
png_uint_32 i; png_uint_32 i;
@@ -169,6 +172,33 @@ png_do_invert(png_row_infop row_info, png_bytep row)
rp++; rp++;
} }
} }
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
row_info->bit_depth == 8)
{
png_bytep rp = row;
png_uint_32 i;
png_uint_32 istop = row_info->rowbytes;
for (i = 0; i < istop; i+=2)
{
*rp = (png_byte)(~(*rp));
rp+=2;
}
}
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
row_info->bit_depth == 16)
{
png_bytep rp = row;
png_uint_32 i;
png_uint_32 istop = row_info->rowbytes;
for (i = 0; i < istop; i+=4)
{
*rp = (png_byte)(~(*rp));
*(rp+1) = (png_byte)(~(*(rp+1)));
rp+=4;
}
}
} }
#endif #endif
@@ -392,11 +422,12 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
sp += 8; dp += 6; sp += 8; dp += 6;
for (i = 1; i < row_width; i++) for (i = 1; i < row_width; i++)
{ {
/* This could be (although memcpy is probably slower): /* This could be (although png_memcpy is probably slower):
png_memcpy(dp, sp, 6); png_memcpy(dp, sp, 6);
sp += 8; sp += 8;
dp += 6; dp += 6;
*/ */
*dp++ = *sp++; *dp++ = *sp++;
*dp++ = *sp++; *dp++ = *sp++;
*dp++ = *sp++; *dp++ = *sp++;
@@ -411,11 +442,12 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
/* This converts from XXRRGGBB or AARRGGBB to RRGGBB */ /* This converts from XXRRGGBB or AARRGGBB to RRGGBB */
for (i = 0; i < row_width; i++) for (i = 0; i < row_width; i++)
{ {
/* This could be (although memcpy is probably slower): /* This could be (although png_memcpy is probably slower):
png_memcpy(dp, sp, 6); png_memcpy(dp, sp, 6);
sp += 8; sp += 8;
dp += 6; dp += 6;
*/ */
sp+=2; sp+=2;
*dp++ = *sp++; *dp++ = *sp++;
*dp++ = *sp++; *dp++ = *sp++;
@@ -606,4 +638,3 @@ png_get_user_transform_ptr(png_structp png_ptr)
return (NULL); return (NULL);
#endif #endif
} }

View File

@@ -2,14 +2,14 @@
* *
* For Intel x86 CPU and Microsoft Visual C++ compiler * For Intel x86 CPU and Microsoft Visual C++ compiler
* *
* libpng 1.0.9 - January 31, 2001 * libpng version 1.0.14 - July 8, 2002
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2002 Glenn Randers-Pehrson
* Copyright (c) 1998, Intel Corporation * 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
* Debugging and cleanup by Greg Roelofs, 2000, 2001 *
* *
* In png_do_read_interlace() in libpng versions 1.0.3a through 1.0.4d, * In png_do_read_interlace() in libpng versions 1.0.3a through 1.0.4d,
* a sign error in the post-MMX cleanup code for each pixel_depth resulted * a sign error in the post-MMX cleanup code for each pixel_depth resulted
@@ -19,6 +19,8 @@
* *
* [png_read_filter_row_mmx_avg() bpp == 2 bugfix, GRR 20000916] * [png_read_filter_row_mmx_avg() bpp == 2 bugfix, GRR 20000916]
* *
* [runtime MMX configuration, GRR 20010102]
*
*/ */
#define PNG_INTERNAL #define PNG_INTERNAL
@@ -37,6 +39,7 @@ png_mmx_support(void)
push ebx //CPUID will trash these push ebx //CPUID will trash these
push ecx push ecx
push edx push edx
pushfd //Save Eflag to stack pushfd //Save Eflag to stack
pop eax //Get Eflag from stack into eax pop eax //Get Eflag from stack into eax
mov ecx, eax //Make another copy of Eflag in ecx mov ecx, eax //Make another copy of Eflag in ecx
@@ -46,6 +49,8 @@ png_mmx_support(void)
popfd //Restored modified value back to Eflag reg popfd //Restored modified value back to Eflag reg
pushfd //Save Eflag to stack pushfd //Save Eflag to stack
pop eax //Get Eflag from stack pop eax //Get Eflag from stack
push ecx // save original Eflag to stack
popfd // restore original Eflag
xor eax, ecx //Compare the new Eflag with the original Eflag xor eax, ecx //Compare the new Eflag with the original Eflag
jz NOT_SUPPORTED //If the same, CPUID instruction is not supported, jz NOT_SUPPORTED //If the same, CPUID instruction is not supported,
//skip following instructions and jump to //skip following instructions and jump to
@@ -110,6 +115,8 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask)
png_debug(1,"in png_combine_row_asm\n"); png_debug(1,"in png_combine_row_asm\n");
if (mmx_supported == 2) { if (mmx_supported == 2) {
/* this should have happened in png_init_mmx_flags() already */
png_warning(png_ptr, "asm_flags may not have been initialized");
png_mmx_support(); png_mmx_support();
} }
@@ -300,7 +307,8 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask)
__int64 mask0=0x0102040810204080; __int64 mask0=0x0102040810204080;
if ( mmx_supported ) if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)
/* && mmx_supported */ )
{ {
srcptr = png_ptr->row_buf + 1; srcptr = png_ptr->row_buf + 1;
dstptr = row; dstptr = row;
@@ -400,7 +408,8 @@ end8:
__int64 mask1=0x0101020204040808, __int64 mask1=0x0101020204040808,
mask0=0x1010202040408080; mask0=0x1010202040408080;
if ( mmx_supported ) if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)
/* && mmx_supported */ )
{ {
srcptr = png_ptr->row_buf + 1; srcptr = png_ptr->row_buf + 1;
dstptr = row; dstptr = row;
@@ -520,7 +529,8 @@ end16:
len = (png_ptr->width)&~7; len = (png_ptr->width)&~7;
diff = (png_ptr->width)&7; diff = (png_ptr->width)&7;
if ( mmx_supported ) if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)
/* && mmx_supported */ )
{ {
_asm _asm
{ {
@@ -651,7 +661,8 @@ end24:
len = (png_ptr->width)&~7; len = (png_ptr->width)&~7;
diff = (png_ptr->width)&7; diff = (png_ptr->width)&7;
if ( mmx_supported ) if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)
/* && mmx_supported */ )
{ {
_asm _asm
{ {
@@ -785,7 +796,8 @@ end32:
mask1=0x2020202040404040, mask1=0x2020202040404040,
mask0=0x4040808080808080; mask0=0x4040808080808080;
if ( mmx_supported ) if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)
/* && mmx_supported */ )
{ {
srcptr = png_ptr->row_buf + 1; srcptr = png_ptr->row_buf + 1;
dstptr = row; dstptr = row;
@@ -975,6 +987,8 @@ png_do_read_interlace(png_structp png_ptr)
png_debug(1,"in png_do_read_interlace\n"); png_debug(1,"in png_do_read_interlace\n");
if (mmx_supported == 2) { if (mmx_supported == 2) {
/* this should have happened in png_init_mmx_flags() already */
png_warning(png_ptr, "asm_flags may not have been initialized");
png_mmx_support(); png_mmx_support();
} }
@@ -1175,7 +1189,8 @@ png_do_read_interlace(png_structp png_ptr)
// NOTE: there is NO MMX code for 48-bit and 64-bit images // NOTE: there is NO MMX code for 48-bit and 64-bit images
// use MMX routine if machine supports it // use MMX routine if machine supports it
if ( mmx_supported ) if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE)
/* && mmx_supported */ )
{ {
if (pixel_bytes == 3) if (pixel_bytes == 3)
{ {
@@ -3637,6 +3652,8 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep
#endif #endif
if (mmx_supported == 2) { if (mmx_supported == 2) {
/* this should have happened in png_init_mmx_flags() already */
png_warning(png_ptr, "asm_flags may not have been initialized");
png_mmx_support(); png_mmx_support();
} }
@@ -3646,13 +3663,17 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep
{ {
case 0: sprintf(filnm, "none"); case 0: sprintf(filnm, "none");
break; break;
case 1: sprintf(filnm, "sub-%s", "MMX"); case 1: sprintf(filnm, "sub-%s",
(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "MMX" : "x86");
break; break;
case 2: sprintf(filnm, "up-%s", "MMX"); case 2: sprintf(filnm, "up-%s",
(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "MMX" : "x86");
break; break;
case 3: sprintf(filnm, "avg-%s", "MMX"); case 3: sprintf(filnm, "avg-%s",
(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "MMX" : "x86");
break; break;
case 4: sprintf(filnm, "Paeth-%s", "MMX"); case 4: sprintf(filnm, "Paeth-%s",
(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "MMX":"x86");
break; break;
default: sprintf(filnm, "unknw"); default: sprintf(filnm, "unknw");
break; break;
@@ -3670,9 +3691,9 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep
case PNG_FILTER_VALUE_SUB: case PNG_FILTER_VALUE_SUB:
{ {
if ( if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) &&
(row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) && (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) &&
(row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT)) (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold))
{ {
png_read_filter_row_mmx_sub(row_info, row); png_read_filter_row_mmx_sub(row_info, row);
} }
@@ -3695,9 +3716,9 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep
case PNG_FILTER_VALUE_UP: case PNG_FILTER_VALUE_UP:
{ {
if ( if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP) &&
(row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) && (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) &&
(row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT)) (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold))
{ {
png_read_filter_row_mmx_up(row_info, row, prev_row); png_read_filter_row_mmx_up(row_info, row, prev_row);
} }
@@ -3719,9 +3740,9 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep
case PNG_FILTER_VALUE_AVG: case PNG_FILTER_VALUE_AVG:
{ {
if ( if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) &&
(row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) && (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) &&
(row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT)) (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold))
{ {
png_read_filter_row_mmx_avg(row_info, row, prev_row); png_read_filter_row_mmx_avg(row_info, row, prev_row);
} }
@@ -3753,9 +3774,9 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep
case PNG_FILTER_VALUE_PAETH: case PNG_FILTER_VALUE_PAETH:
{ {
if ( if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) &&
(row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) && (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) &&
(row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT)) (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold))
{ {
png_read_filter_row_mmx_paeth(row_info, row, prev_row); png_read_filter_row_mmx_paeth(row_info, row, prev_row);
} }

View File

@@ -1,9 +1,9 @@
/* pngwio.c - functions for data output /* pngwio.c - functions for data output
* *
* libpng 1.0.9 - January 31, 2001 * libpng 1.0.14 - July 8, 2002
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2002 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* *
@@ -17,6 +17,7 @@
#define PNG_INTERNAL #define PNG_INTERNAL
#include "png.h" #include "png.h"
#ifdef PNG_WRITE_SUPPORTED
/* Write the data to whatever output you are using. The default routine /* Write the data to whatever output you are using. The default routine
writes to a file pointer. Note that this routine sometimes gets called writes to a file pointer. Note that this routine sometimes gets called
@@ -39,7 +40,7 @@ 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 /* PRIVATE */ void PNGAPI
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;
@@ -62,7 +63,7 @@ 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 /* PRIVATE */ void PNGAPI
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;
@@ -125,7 +126,7 @@ png_flush(png_structp png_ptr)
} }
#if !defined(PNG_NO_STDIO) #if !defined(PNG_NO_STDIO)
static void /* PRIVATE */ void PNGAPI
png_default_flush(png_structp png_ptr) png_default_flush(png_structp png_ptr)
{ {
#if !defined(_WIN32_WCE) #if !defined(_WIN32_WCE)
@@ -224,3 +225,4 @@ void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check)
} }
# endif # endif
# endif # endif
#endif /* PNG_WRITE_SUPPORTED */

View File

@@ -1,9 +1,9 @@
/* pngwrite.c - general routines to write a PNG file /* pngwrite.c - general routines to write a PNG file
* *
* libpng 1.0.9 - January 31, 2001 * libpng 1.0.14 - July 8, 2002
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2002 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*/ */
@@ -11,6 +11,7 @@
/* get internal access to png.h */ /* get internal access to png.h */
#define PNG_INTERNAL #define PNG_INTERNAL
#include "png.h" #include "png.h"
#ifdef PNG_WRITE_SUPPORTED
/* Writes all the PNG information. This is the suggested way to use the /* Writes all the PNG information. This is the suggested way to use the
* library. If you have a new chunk to add, make a function to write it, * library. If you have a new chunk to add, make a function to write it,
@@ -423,7 +424,7 @@ png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr,
{ {
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
return (png_create_write_struct_2(user_png_ver, error_ptr, error_fn, return (png_create_write_struct_2(user_png_ver, error_ptr, error_fn,
warn_fn, NULL, NULL, NULL)); warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL));
} }
/* Alternate initialize png_ptr structure, and allocate any memory needed */ /* Alternate initialize png_ptr structure, and allocate any memory needed */
@@ -442,14 +443,19 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
int i; 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, png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
(png_malloc_ptr)malloc_fn)) == NULL) (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr);
#else #else
if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL) png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
#endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_USER_MEM_SUPPORTED */
{ if (png_ptr == NULL)
return ((png_structp)NULL); return (NULL);
}
#if !defined(PNG_1_0_X)
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
png_init_mmx_flags(png_ptr); /* 1.2.0 addition */
#endif
#endif /* PNG_1_0_X */
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
#ifdef USE_FAR_KEYWORD #ifdef USE_FAR_KEYWORD
@@ -461,7 +467,7 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
png_free(png_ptr, png_ptr->zbuf); png_free(png_ptr, png_ptr->zbuf);
png_ptr->zbuf=NULL; png_ptr->zbuf=NULL;
png_destroy_struct(png_ptr); png_destroy_struct(png_ptr);
return ((png_structp)NULL); return (NULL);
} }
#ifdef USE_FAR_KEYWORD #ifdef USE_FAR_KEYWORD
png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf)); png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
@@ -488,23 +494,27 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
* only check the first digit. * only check the first digit.
*/ */
if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
(user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) ||
(user_png_ver[0] == '0' && user_png_ver[2] < '9')) (user_png_ver[0] == '0' && user_png_ver[2] < '9'))
{ {
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
char msg[80];
if (user_png_ver)
{
sprintf(msg, "Application was compiled with png.h from libpng-%.20s",
user_png_ver);
png_warning(png_ptr, msg);
}
sprintf(msg, "Application is running with png.c from libpng-%.20s",
png_libpng_ver);
png_warning(png_ptr, msg);
#endif
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
png_ptr->flags=0;
#endif
png_error(png_ptr, png_error(png_ptr,
"Incompatible libpng version in application and library"); "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 */
@@ -512,14 +522,28 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
(png_uint_32)png_ptr->zbuf_size); (png_uint_32)png_ptr->zbuf_size);
png_set_write_fn(png_ptr, NULL, NULL, NULL); png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL,
png_flush_ptr_NULL);
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT,
1, NULL, NULL); 1, png_doublep_NULL, png_doublep_NULL);
#endif #endif
return ((png_structp)png_ptr); #ifdef PNG_SETJMP_SUPPORTED
/* Applications that neglect to set up their own setjmp() and then encounter
a png_error() will longjmp here. Since the jmpbuf is then meaningless we
abort instead of returning. */
#ifdef USE_FAR_KEYWORD
if (setjmp(jmpbuf))
PNG_ABORT();
png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
#else
if (setjmp(png_ptr->jmpbuf))
PNG_ABORT();
#endif
#endif
return (png_ptr);
} }
/* Initialize png_ptr structure, and allocate any memory needed */ /* Initialize png_ptr structure, and allocate any memory needed */
@@ -528,13 +552,57 @@ 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 */ /* We only come here via pre-1.0.7-compiled applications */
png_write_init_2(png_ptr, "1.0.0", 10000, 10000); png_write_init_2(png_ptr, "1.0.6 or earlier", 0, 0);
} }
void PNGAPI void PNGAPI
png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver, 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) png_size_t png_struct_size, png_size_t png_info_size)
{ {
/* We only come here via pre-1.0.12-compiled applications */
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
if(sizeof(png_struct) > png_struct_size || sizeof(png_info) > png_info_size)
{
char msg[80];
png_ptr->warning_fn=NULL;
if (user_png_ver)
{
sprintf(msg, "Application was compiled with png.h from libpng-%.20s",
user_png_ver);
png_warning(png_ptr, msg);
}
sprintf(msg, "Application is running with png.c from libpng-%.20s",
png_libpng_ver);
png_warning(png_ptr, msg);
}
#endif
if(sizeof(png_struct) > png_struct_size)
{
png_ptr->error_fn=NULL;
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
png_ptr->flags=0;
#endif
png_error(png_ptr,
"The png struct allocated by the application for writing is too small.");
}
if(sizeof(png_info) > png_info_size)
{
png_ptr->error_fn=NULL;
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
png_ptr->flags=0;
#endif
png_error(png_ptr,
"The info struct allocated by the application for writing is too small.");
}
png_write_init_3(&png_ptr, user_png_ver, png_struct_size);
}
void PNGAPI
png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
png_size_t png_struct_size)
{
png_structp png_ptr=*ptr_ptr;
#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
@@ -546,45 +614,53 @@ png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver,
#ifdef PNG_LEGACY_SUPPORTED #ifdef PNG_LEGACY_SUPPORTED
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
#else #else
png_ptr->error_fn=(png_error_ptr)NULL; png_ptr->warning_fn=NULL;
png_error(png_ptr, png_warning(png_ptr,
"Application uses deprecated png_write_init() and must be recompiled."); "Application uses deprecated png_write_init() and should be recompiled.");
break;
#endif #endif
} }
} while (png_libpng_ver[i++]); } while (png_libpng_ver[i++]);
if (sizeof(png_struct) > png_struct_size || png_debug(1, "in png_write_init_3\n");
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");
#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));
#endif #endif
if (sizeof(png_struct) > png_struct_size)
{
png_destroy_struct(png_ptr);
png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
*ptr_ptr = png_ptr;
}
/* reset all variables to 0 */ /* reset all variables to 0 */
png_memset(png_ptr, 0, sizeof (png_struct)); png_memset(png_ptr, 0, sizeof (png_struct));
#if !defined(PNG_1_0_X)
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
png_init_mmx_flags(png_ptr); /* 1.2.0 addition */
#endif
#endif /* PNG_1_0_X */
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
/* restore jump buffer */ /* restore jump buffer */
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf)); png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
#endif #endif
png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL,
png_flush_ptr_NULL);
/* initialize zbuf - compression buffer */ /* initialize zbuf - compression buffer */
png_ptr->zbuf_size = PNG_ZBUF_SIZE; png_ptr->zbuf_size = PNG_ZBUF_SIZE;
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
(png_uint_32)png_ptr->zbuf_size); (png_uint_32)png_ptr->zbuf_size);
png_set_write_fn(png_ptr, NULL, NULL, NULL);
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT,
1, NULL, NULL); 1, png_doublep_NULL, png_doublep_NULL);
#endif #endif
} }
@@ -646,6 +722,11 @@ png_write_row(png_structp png_ptr, png_bytep row)
/* initialize transformations and other stuff if first time */ /* initialize transformations and other stuff if first time */
if (png_ptr->row_number == 0 && png_ptr->pass == 0) if (png_ptr->row_number == 0 && png_ptr->pass == 0)
{ {
/* make sure we wrote the header info */
if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
png_error(png_ptr,
"png_write_info was never called before png_write_row.");
/* check for transforms that have been set but were defined out */ /* check for transforms that have been set but were defined out */
#if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED) #if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED)
if (png_ptr->transformations & PNG_INVERT_MONO) if (png_ptr->transformations & PNG_INVERT_MONO)
@@ -875,6 +956,7 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
png_infop info_ptr = NULL; png_infop info_ptr = NULL;
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
png_free_ptr free_fn = NULL; png_free_ptr free_fn = NULL;
png_voidp mem_ptr = NULL;
#endif #endif
png_debug(1, "in png_destroy_write_struct\n"); png_debug(1, "in png_destroy_write_struct\n");
@@ -883,6 +965,7 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
png_ptr = *png_ptr_ptr; png_ptr = *png_ptr_ptr;
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
free_fn = png_ptr->free_fn; free_fn = png_ptr->free_fn;
mem_ptr = png_ptr->mem_ptr;
#endif #endif
} }
@@ -903,28 +986,30 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
#endif #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, (png_free_ptr)free_fn,
(png_voidp)mem_ptr);
#else #else
png_destroy_struct((png_voidp)info_ptr); png_destroy_struct((png_voidp)info_ptr);
#endif #endif
*info_ptr_ptr = (png_infop)NULL; *info_ptr_ptr = NULL;
} }
if (png_ptr != NULL) if (png_ptr != NULL)
{ {
png_write_destroy(png_ptr); png_write_destroy(png_ptr);
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
png_destroy_struct_2((png_voidp)png_ptr, free_fn); png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,
(png_voidp)mem_ptr);
#else #else
png_destroy_struct((png_voidp)png_ptr); png_destroy_struct((png_voidp)png_ptr);
#endif #endif
*png_ptr_ptr = (png_structp)NULL; *png_ptr_ptr = NULL;
} }
} }
/* Free any memory used in png_ptr struct (old method) */ /* Free any memory used in png_ptr struct (old method) */
void PNGAPI void /* PRIVATE */
png_write_destroy(png_structp png_ptr) png_write_destroy(png_structp png_ptr)
{ {
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
@@ -1137,12 +1222,11 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
if (png_ptr->filter_weights == NULL) if (png_ptr->filter_weights == NULL)
{ {
png_ptr->filter_weights = (png_uint_16p) png_malloc(png_ptr, png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(sizeof(png_uint_16) * num_weights)); (png_uint_32)(sizeof(png_uint_16) * num_weights));
png_ptr->inv_filter_weights = (png_uint_16p) png_malloc(png_ptr, png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(sizeof(png_uint_16) * num_weights)); (png_uint_32)(sizeof(png_uint_16) * num_weights));
for (i = 0; i < num_weights; i++) for (i = 0; i < num_weights; i++)
{ {
png_ptr->inv_filter_weights[i] = png_ptr->inv_filter_weights[i] =
@@ -1172,10 +1256,10 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
*/ */
if (png_ptr->filter_costs == NULL) if (png_ptr->filter_costs == NULL)
{ {
png_ptr->filter_costs = (png_uint_16p) png_malloc(png_ptr, png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); (png_uint_32)(sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
png_ptr->inv_filter_costs = (png_uint_16p) png_malloc(png_ptr, png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); (png_uint_32)(sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)
@@ -1359,7 +1443,8 @@ png_write_png(png_structp png_ptr, png_infop info_ptr,
/* It is REQUIRED to call this to finish writing the rest of the file */ /* It is REQUIRED to call this to finish writing the rest of the file */
png_write_end(png_ptr, info_ptr); png_write_end(png_ptr, info_ptr);
if(transforms == 0 || params == (voidp)NULL) if(transforms == 0 || params == NULL)
/* quiet compiler warnings */ return; /* quiet compiler warnings */ return;
} }
#endif #endif
#endif /* PNG_WRITE_SUPPORTED */

View File

@@ -1,15 +1,16 @@
/* 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.9 - January 31, 2001 * libpng 1.0.14 - July 8, 2002
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2002 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (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"
#ifdef PNG_WRITE_SUPPORTED
/* 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.
@@ -559,3 +560,4 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
} }
} }
#endif /* PNG_MNG_FEATURES_SUPPORTED */ #endif /* PNG_MNG_FEATURES_SUPPORTED */
#endif /* PNG_WRITE_SUPPORTED */

View File

@@ -1,15 +1,16 @@
/* pngwutil.c - utilities to write a PNG file /* pngwutil.c - utilities to write a PNG file
* *
* libpng 1.0.9 - January 31, 2001 * libpng 1.0.14 - July 8, 2002
* 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-2001 Glenn Randers-Pehrson * Copyright (c) 1998-2002 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (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"
#ifdef PNG_WRITE_SUPPORTED
/* Place a 32-bit number into a buffer in PNG byte order. We work /* Place a 32-bit number into a buffer in PNG byte order. We work
* with unsigned numbers for convenience, although one supported * with unsigned numbers for convenience, although one supported
@@ -24,7 +25,7 @@ png_save_uint_32(png_bytep buf, png_uint_32 i)
buf[3] = (png_byte)(i & 0xff); buf[3] = (png_byte)(i & 0xff);
} }
#if defined(PNG_WRITE_pCAL_SUPPORTED) #if defined(PNG_WRITE_pCAL_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
/* The png_save_int_32 function assumes integers are stored in two's /* The png_save_int_32 function assumes integers are stored in two's
* 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.
@@ -234,8 +235,8 @@ png_text_compress(png_structp png_ptr,
old_ptr = comp->output_ptr; old_ptr = comp->output_ptr;
comp->output_ptr = (png_charpp)png_malloc(png_ptr, comp->output_ptr = (png_charpp)png_malloc(png_ptr,
(png_uint_32)(comp->max_output_ptr * sizeof (png_charpp))); (png_uint_32)(comp->max_output_ptr * sizeof (png_charpp)));
png_memcpy(comp->output_ptr, old_ptr, png_memcpy(comp->output_ptr, old_ptr, old_max
old_max * sizeof (png_charp)); * sizeof (png_charp));
png_free(png_ptr, old_ptr); png_free(png_ptr, old_ptr);
} }
else else
@@ -284,7 +285,7 @@ png_text_compress(png_structp png_ptr,
comp->output_ptr = (png_charpp)png_malloc(png_ptr, comp->output_ptr = (png_charpp)png_malloc(png_ptr,
(png_uint_32)(comp->max_output_ptr * sizeof (png_charpp))); (png_uint_32)(comp->max_output_ptr * sizeof (png_charpp)));
png_memcpy(comp->output_ptr, old_ptr, png_memcpy(comp->output_ptr, old_ptr,
old_max * sizeof (png_charp)); old_max * sizeof (png_charp));
png_free(png_ptr, old_ptr); png_free(png_ptr, old_ptr);
} }
else else
@@ -331,7 +332,8 @@ png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
/* handle the no-compression case */ /* handle the no-compression case */
if (comp->input) if (comp->input)
{ {
png_write_chunk_data(png_ptr, (png_bytep)comp->input, comp->input_len); png_write_chunk_data(png_ptr, (png_bytep)comp->input,
(png_size_t)comp->input_len);
return; return;
} }
@@ -434,7 +436,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
#if defined(PNG_MNG_FEATURES_SUPPORTED) #if defined(PNG_MNG_FEATURES_SUPPORTED)
!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&
(color_type == PNG_COLOR_TYPE_RGB || (color_type == PNG_COLOR_TYPE_RGB ||
color_type == PNG_COLOR_TYPE_RGB_ALPHA) && color_type == PNG_COLOR_TYPE_RGB_ALPHA) &&
(filter_type == PNG_INTRAPIXEL_DIFFERENCING)) && (filter_type == PNG_INTRAPIXEL_DIFFERENCING)) &&
#endif #endif
@@ -459,7 +461,9 @@ 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;
#if defined(PNG_MNG_FEATURES_SUPPORTED)
png_ptr->filter_type = (png_byte)filter_type; png_ptr->filter_type = (png_byte)filter_type;
#endif
png_ptr->width = width; png_ptr->width = width;
png_ptr->height = height; png_ptr->height = height;
@@ -538,16 +542,23 @@ png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)
!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) && !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) &&
#endif #endif
num_pal == 0) || num_pal > 256) num_pal == 0) || num_pal > 256)
{
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{ {
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) png_error(png_ptr, "Invalid number of colors in palette");
{ }
png_error(png_ptr, "Invalid number of colors in palette"); else
} {
else png_warning(png_ptr, "Invalid number of colors in palette");
{ return;
png_warning(png_ptr, "Invalid number of colors in palette"); }
return; }
}
if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR))
{
png_warning(png_ptr,
"Ignoring request to write a PLTE chunk in grayscale PNG");
return;
} }
png_ptr->num_palette = (png_uint_16)num_pal; png_ptr->num_palette = (png_uint_16)num_pal;
@@ -597,7 +608,8 @@ png_write_IEND(png_structp png_ptr)
PNG_IEND; PNG_IEND;
#endif #endif
png_debug(1, "in png_write_IEND\n"); png_debug(1, "in png_write_IEND\n");
png_write_chunk(png_ptr, (png_bytep)png_IEND, NULL, (png_size_t)0); png_write_chunk(png_ptr, (png_bytep)png_IEND, png_bytep_NULL,
(png_size_t)0);
png_ptr->mode |= PNG_HAVE_IEND; png_ptr->mode |= PNG_HAVE_IEND;
} }
@@ -631,7 +643,7 @@ png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma)
png_debug(1, "in png_write_gAMA\n"); png_debug(1, "in png_write_gAMA\n");
/* file_gamma is saved in 1/100,000ths */ /* file_gamma is saved in 1/100,000ths */
png_save_uint_32(buf, file_gamma); png_save_uint_32(buf, (png_uint_32)file_gamma);
png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);
} }
#endif #endif
@@ -728,7 +740,7 @@ png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
} }
/* make sure we include the NULL after the name */ /* make sure we include the NULL after the name */
png_write_chunk_start(png_ptr, (png_bytep) png_sPLT, png_write_chunk_start(png_ptr, (png_bytep)png_sPLT,
(png_uint_32)(name_len + 2 + palette_size)); (png_uint_32)(name_len + 2 + palette_size));
png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 1); png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 1);
png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1); png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1);
@@ -753,7 +765,7 @@ png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
png_save_uint_16(entrybuf + 6, ep->alpha); png_save_uint_16(entrybuf + 6, ep->alpha);
png_save_uint_16(entrybuf + 8, ep->frequency); png_save_uint_16(entrybuf + 8, ep->frequency);
} }
png_write_chunk_data(png_ptr, entrybuf, entry_size); png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size);
} }
#else #else
ep=spalette->entries; ep=spalette->entries;
@@ -928,32 +940,32 @@ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
#endif #endif
return; return;
} }
png_save_uint_32(buf, white_x); png_save_uint_32(buf, (png_uint_32)white_x);
png_save_uint_32(buf + 4, white_y); png_save_uint_32(buf + 4, (png_uint_32)white_y);
if (red_x > 80000L || red_y > 80000L || red_x + red_y > 100000L) if (red_x > 80000L || red_y > 80000L || red_x + red_y > 100000L)
{ {
png_warning(png_ptr, "Invalid cHRM fixed red point specified"); png_warning(png_ptr, "Invalid cHRM fixed red point specified");
return; return;
} }
png_save_uint_32(buf + 8, red_x); png_save_uint_32(buf + 8, (png_uint_32)red_x);
png_save_uint_32(buf + 12, red_y); png_save_uint_32(buf + 12, (png_uint_32)red_y);
if (green_x > 80000L || green_y > 80000L || green_x + green_y > 100000L) if (green_x > 80000L || green_y > 80000L || green_x + green_y > 100000L)
{ {
png_warning(png_ptr, "Invalid fixed cHRM green point specified"); png_warning(png_ptr, "Invalid fixed cHRM green point specified");
return; return;
} }
png_save_uint_32(buf + 16, green_x); png_save_uint_32(buf + 16, (png_uint_32)green_x);
png_save_uint_32(buf + 20, green_y); png_save_uint_32(buf + 20, (png_uint_32)green_y);
if (blue_x > 80000L || blue_y > 80000L || blue_x + blue_y > 100000L) if (blue_x > 80000L || blue_y > 80000L || blue_x + blue_y > 100000L)
{ {
png_warning(png_ptr, "Invalid fixed cHRM blue point specified"); png_warning(png_ptr, "Invalid fixed cHRM blue point specified");
return; return;
} }
png_save_uint_32(buf + 24, blue_x); png_save_uint_32(buf + 24, (png_uint_32)blue_x);
png_save_uint_32(buf + 28, blue_y); png_save_uint_32(buf + 28, (png_uint_32)blue_y);
png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32);
} }
@@ -985,6 +997,12 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
else if (color_type == PNG_COLOR_TYPE_GRAY) else if (color_type == PNG_COLOR_TYPE_GRAY)
{ {
/* one 16 bit value */ /* one 16 bit value */
if(tran->gray >= (1 << png_ptr->bit_depth))
{
png_warning(png_ptr,
"Ignoring attempt to write tRNS chunk out-of-range for bit_depth");
return;
}
png_save_uint_16(buf, tran->gray); png_save_uint_16(buf, tran->gray);
png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)2); png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)2);
} }
@@ -994,6 +1012,12 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
png_save_uint_16(buf, tran->red); png_save_uint_16(buf, tran->red);
png_save_uint_16(buf + 2, tran->green); png_save_uint_16(buf + 2, tran->green);
png_save_uint_16(buf + 4, tran->blue); png_save_uint_16(buf + 4, tran->blue);
if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))
{
png_warning(png_ptr,
"Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8");
return;
}
png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)6); png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)6);
} }
else else
@@ -1034,10 +1058,22 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
png_save_uint_16(buf, back->red); png_save_uint_16(buf, back->red);
png_save_uint_16(buf + 2, back->green); png_save_uint_16(buf + 2, back->green);
png_save_uint_16(buf + 4, back->blue); png_save_uint_16(buf + 4, back->blue);
if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))
{
png_warning(png_ptr,
"Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8");
return;
}
png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)6); png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)6);
} }
else else
{ {
if(back->gray >= (1 << png_ptr->bit_depth))
{
png_warning(png_ptr,
"Ignoring attempt to write bKGD chunk out-of-range for bit_depth");
return;
}
png_save_uint_16(buf, back->gray); png_save_uint_16(buf, back->gray);
png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)2); png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)2);
} }
@@ -1313,22 +1349,28 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
png_warning(png_ptr, "Empty keyword in iTXt chunk"); png_warning(png_ptr, "Empty keyword in iTXt chunk");
return; return;
} }
if (lang == NULL || (lang_len = png_check_keyword(png_ptr, lang, if (lang == NULL || (lang_len = png_check_keyword(png_ptr, lang, &new_lang))==0)
&new_lang))==0)
{ {
png_warning(png_ptr, "Empty language field in iTXt chunk"); png_warning(png_ptr, "Empty language field in iTXt chunk");
return; new_lang = NULL;
lang_len = 0;
} }
lang_key_len = png_strlen(lang_key);
text_len = png_strlen(text);
if (text == NULL || *text == '\0') if (lang_key == NULL)
lang_key_len = 0;
else
lang_key_len = png_strlen(lang_key);
if (text == NULL)
text_len = 0; text_len = 0;
else
text_len = png_strlen(text);
/* 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, text_len = png_text_compress(png_ptr, text, text_len, compression-2,
&comp); &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 */
@@ -1358,23 +1400,22 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
cbuf[1] = 0; cbuf[1] = 0;
png_write_chunk_data(png_ptr, cbuf, 2); png_write_chunk_data(png_ptr, cbuf, 2);
png_write_chunk_data(png_ptr, (png_bytep)new_lang, lang_len + 1); cbuf[0] = 0;
png_write_chunk_data(png_ptr, (png_bytep)lang_key, lang_key_len+1); png_write_chunk_data(png_ptr, (new_lang ? (png_bytep)new_lang : cbuf), lang_len + 1);
png_write_chunk_data(png_ptr, '\0', 1); png_write_chunk_data(png_ptr, (lang_key ? (png_bytep)lang_key : cbuf), lang_key_len + 1);
png_write_compressed_data_out(png_ptr, &comp); png_write_compressed_data_out(png_ptr, &comp);
png_write_chunk_end(png_ptr); png_write_chunk_end(png_ptr);
png_free(png_ptr, new_key); png_free(png_ptr, new_key);
png_free(png_ptr, new_lang); if (new_lang)
png_free(png_ptr, new_lang);
} }
#endif #endif
#if defined(PNG_WRITE_oFFs_SUPPORTED) #if defined(PNG_WRITE_oFFs_SUPPORTED)
/* write the oFFs chunk */ /* write the oFFs chunk */
void /* PRIVATE */ void /* PRIVATE */
png_write_oFFs(png_structp png_ptr, png_uint_32 x_offset, png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset,
png_uint_32 y_offset,
int unit_type) int unit_type)
{ {
#ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_USE_LOCAL_ARRAYS
@@ -1386,8 +1427,8 @@ png_write_oFFs(png_structp png_ptr, png_uint_32 x_offset,
if (unit_type >= PNG_OFFSET_LAST) if (unit_type >= PNG_OFFSET_LAST)
png_warning(png_ptr, "Unrecognized unit type for oFFs chunk"); png_warning(png_ptr, "Unrecognized unit type for oFFs chunk");
png_save_uint_32(buf, x_offset); png_save_int_32(buf, x_offset);
png_save_uint_32(buf + 4, y_offset); png_save_int_32(buf + 4, y_offset);
buf[8] = (png_byte)unit_type; buf[8] = (png_byte)unit_type;
png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9); png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9);
@@ -1414,9 +1455,9 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); png_warning(png_ptr, "Unrecognized equation type for pCAL chunk");
purpose_len = png_check_keyword(png_ptr, purpose, &new_purpose) + 1; purpose_len = png_check_keyword(png_ptr, purpose, &new_purpose) + 1;
png_debug1(3, "pCAL purpose length = %d\n", purpose_len); png_debug1(3, "pCAL purpose length = %d\n", (int)purpose_len);
units_len = png_strlen(units) + (nparams == 0 ? 0 : 1); units_len = png_strlen(units) + (nparams == 0 ? 0 : 1);
png_debug1(3, "pCAL units length = %d\n", units_len); png_debug1(3, "pCAL units length = %d\n", (int)units_len);
total_len = purpose_len + units_len + 10; total_len = purpose_len + units_len + 10;
params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams
@@ -1431,7 +1472,7 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
total_len += (png_size_t)params_len[i]; total_len += (png_size_t)params_len[i];
} }
png_debug1(3, "pCAL total length = %d\n", total_len); png_debug1(3, "pCAL total length = %d\n", (int)total_len);
png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len); png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len);
png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len); png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len);
png_save_int_32(buf, X0); png_save_int_32(buf, X0);
@@ -1483,11 +1524,11 @@ png_write_sCAL(png_structp png_ptr, int unit, double width,double height)
#endif #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", (int)total_len);
png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len); png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len);
png_write_chunk_data(png_ptr, (png_bytep)&unit, 1); png_write_chunk_data(png_ptr, (png_bytep)&unit, 1);
png_write_chunk_data(png_ptr, (png_bytep)wbuf, strlen(wbuf)+1); png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1);
png_write_chunk_data(png_ptr, (png_bytep)hbuf, strlen(hbuf)); png_write_chunk_data(png_ptr, (png_bytep)hbuf, png_strlen(hbuf));
png_write_chunk_end(png_ptr); png_write_chunk_end(png_ptr);
} }
@@ -1505,15 +1546,15 @@ png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width,
png_debug(1, "in png_write_sCAL_s\n"); png_debug(1, "in png_write_sCAL_s\n");
strcpy(wbuf,(const char *)width); png_strcpy(wbuf,(const char *)width);
strcpy(hbuf,(const char *)height); png_strcpy(hbuf,(const char *)height);
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);
png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len); png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len);
png_write_chunk_data(png_ptr, (png_bytep)&unit, 1); png_write_chunk_data(png_ptr, (png_bytep)&unit, 1);
png_write_chunk_data(png_ptr, (png_bytep)wbuf, strlen(wbuf)+1); png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1);
png_write_chunk_data(png_ptr, (png_bytep)hbuf, strlen(hbuf)); png_write_chunk_data(png_ptr, (png_bytep)hbuf, png_strlen(hbuf));
png_write_chunk_end(png_ptr); png_write_chunk_end(png_ptr);
} }
@@ -2631,3 +2672,4 @@ png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row)
} }
#endif #endif
} }
#endif /* PNG_WRITE_SUPPORTED */

Binary file not shown.

View File

@@ -0,0 +1,22 @@
This project builds a shared library version of libpng on x86 BeOS.
It defines PNG_USE_PNGGCCRD, which activates the assembly code in
pnggccrd.c; this hasn't been extensively tested on BeOS.
To install:
1) build
Note: As of version 1.0.10, you'll get a fair number of warnings when
you compile pnggccrd.c. As far as I know, these are harmless,
but it would be better if someone fixed them.
2) copy and png.h, pngconf.h somewhere; /boot/home/config/include (which
you'll have to make) is a good choice
3) copy libpng.so to /boot/home/config/lib
4) build your libpng.so applications (remember to include libz.a as
well when you link)
- Chris Herborth, March 27, 2001

Binary file not shown.

View File

@@ -0,0 +1,22 @@
This project builds a static library version of libpng on x86 BeOS.
It defines PNG_USE_PNGGCCRD, which activates the assembly code in
pnggccrd.c; this hasn't been extensively tested on BeOS.
To install:
1) build
Note: As of version 1.0.10, you'll get a fair number of warnings when
you compile pnggccrd.c. As far as I know, these are harmless,
but it would be better if someone fixed them.
2) copy and png.h, pngconf.h somewhere; /boot/home/config/include (which
you'll have to make) is a good choice
3) copy libpng.a to /boot/home/config/lib
4) build your libpng.a applications (remember to include libz.a as
well when you link)
- Chris Herborth, March 27, 2001

View File

@@ -1,5 +1,5 @@
Microsoft Developer Studio Build File, Format Version 6.00 for Microsoft Developer Studio Build File, Format Version 6.00 for
libpng 1.0.9 (January 31, 2001) and zlib libpng 1.0.14 (July 8, 2002) and zlib
Copyright (C) 2000 Simon-Pierre Cadieux Copyright (C) 2000 Simon-Pierre Cadieux
For conditions of distribution and use, see copyright notice in png.h For conditions of distribution and use, see copyright notice in png.h
@@ -24,12 +24,12 @@ To build:
This project will build the PNG Development Group's "official" versions of This project will build the PNG Development Group's "official" versions of
libpng and zlib libraries: libpng and zlib libraries:
libpng1.dll (default version, currently C code only) libpng10.dll (default version, currently C code only)
libpng1.dll (C + Assembler version) libpng10.dll (C + Assembler version)
libpng1.dll (C + Assembler debug version) libpng10.dll (C + Assembler debug version)
libpng1.dll (C code debug version) libpng10.dll (C code debug version)
libpng1[c,e-m].dll (reserved for official versions) libpng10[c,e-m].dll (reserved for official versions)
libpng1[n-z].dll (available for private versions) libpng10[n-z].dll (available for private versions)
zlib.dll (default version, currently C code only) zlib.dll (default version, currently C code only)
zlibd.dll (debug version) zlibd.dll (debug version)

View File

@@ -56,7 +56,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe LINK32=link.exe
# ADD BASE LINK32 /nologo /dll /machine:I386 # ADD BASE LINK32 /nologo /dll /machine:I386
# ADD LINK32 /nologo /dll /machine:I386 /out:".\win32\libpng\dll\libpng1.dll" # ADD LINK32 /nologo /dll /machine:I386 /out:".\win32\libpng\dll\libpng10.dll"
# SUBTRACT LINK32 /pdb:none # SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug" !ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug"
@@ -84,7 +84,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe LINK32=link.exe
# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 /nologo /dll /debug /machine:I386 /out:".\win32\libpng\dll_dbg\libpng1d.dll" # ADD LINK32 /nologo /dll /debug /machine:I386 /out:".\win32\libpng\dll_dbg\libpng10d.dll"
!ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM" !ELSEIF "$(CFG)" == "libpng - Win32 DLL ASM"
@@ -111,7 +111,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe LINK32=link.exe
# ADD BASE LINK32 /nologo /dll /machine:I386 # ADD BASE LINK32 /nologo /dll /machine:I386
# ADD LINK32 /nologo /dll /machine:I386 /out:".\win32\libpng\dll_asm\libpng1a.dll" # ADD LINK32 /nologo /dll /machine:I386 /out:".\win32\libpng\dll_asm\libpng10a.dll"
# SUBTRACT LINK32 /pdb:none # SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug ASM" !ELSEIF "$(CFG)" == "libpng - Win32 DLL Debug ASM"
@@ -139,7 +139,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe LINK32=link.exe
# ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 /nologo /dll /debug /machine:I386 /out:".\win32\libpng\dll_dbga\libpng1b.dll" # ADD LINK32 /nologo /dll /debug /machine:I386 /out:".\win32\libpng\dll_dbga\libpng10b.dll"
!ELSEIF "$(CFG)" == "libpng - Win32 LIB" !ELSEIF "$(CFG)" == "libpng - Win32 LIB"

View File

@@ -81,7 +81,7 @@ BEGIN
VALUE "FileDescription", "PNG image compression library\000" VALUE "FileDescription", "PNG image compression library\000"
VALUE "FileVersion", PNG_LIBPNG_VER_STRING "\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 "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 "LegalCopyright", "\251 1998-2002 Glenn Randers-Pehrson\000"
VALUE "OriginalFilename", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_MAJOR) DLLFNAME_POSTFIX ".DLL\000" VALUE "OriginalFilename", PNG_LIBPNG_DLLFNAME QUOTE(PNG_LIBPNG_VER_MAJOR) DLLFNAME_POSTFIX ".DLL\000"
#ifdef PRIVATEBUILD #ifdef PRIVATEBUILD
VALUE "PrivateBuild", PRIVATEBUILD VALUE "PrivateBuild", PRIVATEBUILD

View File

@@ -6,7 +6,7 @@ LIBRARY
DESCRIPTION "PNG image compression library for Windows" DESCRIPTION "PNG image compression library for Windows"
EXPORTS EXPORTS
;Version 1.0.9 ;Version 1.0.14
png_build_grayscale_palette @1 png_build_grayscale_palette @1
png_check_sig @2 png_check_sig @2
png_chunk_error @3 png_chunk_error @3
@@ -77,12 +77,14 @@ EXPORTS
png_malloc @68 png_malloc @68
png_memcpy_check @69 png_memcpy_check @69
png_memset_check @70 png_memset_check @70
; png_permit_empty_plte is deprecated
png_permit_empty_plte @71 png_permit_empty_plte @71
png_process_data @72 png_process_data @72
png_progressive_combine_row @73 png_progressive_combine_row @73
png_read_end @74 png_read_end @74
png_read_image @75 png_read_image @75
png_read_info @76 png_read_info @76
; png_read_init is deprecated
png_read_init @77 png_read_init @77
png_read_png @78 png_read_png @78
png_read_row @79 png_read_row @79
@@ -168,10 +170,12 @@ EXPORTS
png_write_image @159 png_write_image @159
png_write_info @160 png_write_info @160
png_write_info_before_PLTE @161 png_write_info_before_PLTE @161
; png_write_init is deprecated
png_write_init @162 png_write_init @162
png_write_png @163 png_write_png @163
png_write_row @164 png_write_row @164
png_write_rows @165 png_write_rows @165
; png_read_init_2 and png_write_init_2 are deprecated.
png_read_init_2 @166 png_read_init_2 @166
png_write_init_2 @167 png_write_init_2 @167
png_access_version_number @168 png_access_version_number @168
@@ -180,7 +184,37 @@ EXPORTS
png_init_io @171 png_init_io @171
png_convert_to_rfc1123 @172 png_convert_to_rfc1123 @172
png_set_invalid @173 png_set_invalid @173
;To be added at version 1.2.0 ; Added at version 1.0.12
; png_permit_mng_features @174 ; For compatiblity with 1.0.7-1.0.11
;To be added at version 1.2.0 png_info_init @174
; png_mmx_support @175 png_read_init_3 @175
png_write_init_3 @176
png_info_init_3 @177
png_destroy_struct @178
; Added at version 1.2.0
; For use with PNG_USER_MEM_SUPPORTED
; png_destroy_struct_2 @179
; png_create_read_struct_2 @180
; png_create_write_struct_2 @181
; png_malloc_default @182
; png_free_default @183
; MNG features
; png_permit_mng_features @184
; MMX support
; png_mmx_support @185
; png_get_mmx_flagmask @186
; png_get_asm_flagmask @187
; png_get_asm_flags @188
; png_get_mmx_bitdepth_threshold @189
; png_get_mmx_rowbytes_threshold @190
; png_set_asm_flags @191
; png_init_mmx_flags @192
; Strip error numbers
; png_set_strip_error_numbers @193
; Added at version 1.2.2
png_handle_as_unknown @179
png_zalloc @180
png_zfree @181
; png_handle_as_unknown @194
; png_zalloc @195
; png_zfree @196

6
projects/netware.txt Normal file
View File

@@ -0,0 +1,6 @@
A set of project files is available for Netware. Get
libpng-1.0.14-project-netware.zip from a libpng distribution
site such as http://libpng.sourceforge.net
Put the zip file in this directory (projects) and then run
"unzip -a libpng-1.0.14-project-netware.zip"

6
projects/wince.txt Normal file
View File

@@ -0,0 +1,6 @@
A set of project files is available for WinCE. Get
libpng-1.0.14-project-wince.zip from a libpng distribution
site such as http://libpng.sourceforge.net
Put the zip file in this directory (projects) and then run
"unzip -a libpng-1.0.14-project-wince.zip"

View File

@@ -1,43 +0,0 @@
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.9 ported to WindowsCE 2.0 and 2.11.
libpng 1.0.9 is a PNG reference library.
See README, a document of original libpng 1.0.9.
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.9, 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

@@ -1,44 +0,0 @@
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.9<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

@@ -1,39 +0,0 @@
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

@@ -1,41 +0,0 @@
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

File diff suppressed because it is too large Load Diff

View File

@@ -1,44 +0,0 @@
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>
{{{
}}}
###############################################################################

View File

@@ -1,185 +0,0 @@
;------------------------------------------
; LIBPNG module definition file for Windows
;------------------------------------------
LIBRARY lpngce
EXPORTS
;Version 1.0.9
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
png_set_invalid @173
;To be added at version 1.2.0
; png_permit_mng_features @174
;To be added at version 1.2.0
; png_mmx_support @175

View File

@@ -1,812 +0,0 @@
# 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"\
"..\..\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"\
"..\..\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"\
"..\..\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"\
"..\..\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"\
"..\..\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"\
"..\..\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"\
"..\..\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"\
"..\..\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"\
"..\..\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"\
"..\..\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"\
"..\..\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"\
"..\..\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"\
"..\..\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"\
"..\..\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"\
"..\..\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"\
"..\..\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

@@ -1,59 +0,0 @@
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>
{{{
}}}
###############################################################################

View File

@@ -1,86 +0,0 @@
/* 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);
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,44 +0,0 @@
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

File diff suppressed because it is too large Load Diff

70
scripts/libpng-config-body.in Executable file
View File

@@ -0,0 +1,70 @@
usage()
{
cat <<EOF
Usage: libpng-config [OPTION] ...
Known values for OPTION are:
--prefix print libpng prefix
--libs print library linking information
--cflags print compiler flags
--cppflags print pre-processor flags
--ldflags print loader flags
--rpath print path to shared library
--help display this help and exit
--version output version information
EOF
exit $1
}
if test $# -eq 0; then
usage 1
fi
while test $# -gt 0; do
case "$1" in
--prefix)
echo ${prefix}
;;
--version)
echo ${version}
exit 0
;;
--help)
usage 0
;;
--cflags)
echo ${cflags}
;;
--cppflags)
echo ${cppflags}
;;
--libs)
echo ${libs}
;;
--rpath)
echo ${rpath}
;;
--ldflags)
echo ${ldflags}
;;
*)
usage
exit 1
;;
esac
shift
done
exit 0

18
scripts/libpng-config-head.in Executable file
View File

@@ -0,0 +1,18 @@
#! /bin/sh
# libpng-config
# provides configuration info for libpng.
# Copyright (C) 2002 Glenn Randers-Pehrson
# For conditions of distribution and use, see copyright notice in png.h
# Modeled after libxml-config.
version=1.0.14
prefix=""
cppflags=""
cflags=""
ldflags=""
libs=""
rpath=""

11
scripts/libpng.pc.in Normal file
View File

@@ -0,0 +1,11 @@
prefix=@PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${exec_prefix}/include
Name: libpng10
Description: Loads and saves PNG files
Version: 1.0.14
Libs: -L${libdir} -lpng10 -lz -lm
Cflags: -I${includedir}/libpng10

213
scripts/makefile.32sunu Normal file
View File

@@ -0,0 +1,213 @@
# makefile for libpng on Solaris 2.x with cc
# Contributed by William L. Sebok, based on makefile.linux
# Copyright (C) 2002 Glenn Randers-Pehrson
# Copyright (C) 1998 Greg Roelofs
# Copyright (C) 1996, 1997 Andreas Dilger
# For conditions of distribution and use, see copyright notice in png.h
CC=cc
SUN_CC_FLAGS=-fast -xtarget=ultra
SUN_LD_FLAGS=-fast -xtarget=ultra
# where make install puts libpng.a, libpng10.so and libpng10/png.h
prefix=/a
# Where the zlib library and include files are located
# Changing these to ../zlib poses a security risk. If you want
# to have zlib in an adjacent directory, specify the full path instead of "..".
#ZLIBLIB=../zlib
#ZLIBINC=../zlib
ZLIBLIB=/usr/lib
ZLIBINC=/usr/include
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
CFLAGS=-I$(ZLIBINC) $(SUN_CC_FLAGS) \
# $(WARNMORE) -g -DPNG_DEBUG=5
LDFLAGS=-L. -R. $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng10 -lz -lm
#RANLIB=ranlib
RANLIB=echo
LIBNAME=libpng10
PNGMAJ = 0
PNGMIN = 1.0.14
PNGVER = $(PNGMAJ).$(PNGMIN)
INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib
MANPATH=$(prefix)/man
BINPATH=$(prefix)/bin
# override DESTDIR= on the make install command line to easily support
# installing into a temporary location. Example:
#
# make install DESTDIR=/tmp/build/libpng
#
# If you're going to install into a temporary location
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
# you execute make install.
DESTDIR=
DB=$(DESTDIR)$(BINPATH)
DI=$(DESTDIR)$(INCPATH)
DL=$(DESTDIR)$(LIBPATH)
DM=$(DESTDIR)$(MANPATH)
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o
OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o
.c.pic.o:
$(CC) -c $(CFLAGS) -KPIC -o $@ $*.c
all: libpng.a $(LIBNAME).so pngtest libpng.pc libpng-config
libpng.a: $(OBJS)
ar rc $@ $(OBJS)
$(RANLIB) $@
libpng.pc:
cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
libpng-config:
( cat scripts/libpng-config-head.in; \
echo prefix=\"$(prefix)\"; \
echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo cflags=\"-xtarget=ultra\"; \
echo ldflags=\"-xtarget=ultra -L$(LIBPATH) -R$(LIBPATH)\"; \
echo libs=\"-lpng10 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config
$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER)
ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
$(LIBNAME).so.$(PNGVER): $(OBJSDLL)
@case "`type ld`" in *ucb*) \
echo; \
echo '## WARNING:'; \
echo '## The commands "CC" and "LD" must NOT refer to /usr/ucb/cc'; \
echo '## and /usr/ucb/ld. If they do, you need to adjust your PATH'; \
echo '## environment variable to put /usr/ccs/bin ahead of /usr/ucb.'; \
echo '## The environment variable LD_LIBRARY_PATH should not be set'; \
echo '## at all. If it is, things are likely to break because of'; \
echo '## the libucb dependency that is created.'; \
echo; \
;; \
esac
$(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h $(LIBNAME).so.$(PNGMAJ) \
-o $(LIBNAME).so.$(PNGVER) $(OBJSDLL) -lz
pngtest: pngtest.o $(LIBNAME).so
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
test: pngtest
./pngtest
install-headers: png.h pngconf.h
-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
cp png.h pngconf.h $(DI)/$(LIBNAME)
chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
-@/bin/rm $(DI)/libpng
(cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .)
install-static: install-headers libpng.a
-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
cp libpng.a $(DL)/$(LIBNAME).a
chmod 644 $(DL)/$(LIBNAME).a
-@/bin/rm -f $(DL)/libpng.a
(cd $(DL); ln -f -s $(LIBNAME).a libpng.a)
install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
-@/bin/rm -f $(DL)/libpng.so
-@/bin/rm -f $(DL)/libpng.so.2
-@/bin/rm -f $(DL)/libpng.so.2.*
cp $(LIBNAME).so.$(PNGVER) $(DL)
chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
(cd $(DL); \
ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so; \
ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so.2; \
ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so.2.$(PNGMIN); \
ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig
-@/bin/rm -f $(DL)/pkgconfig/libpng10.pc
-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
cp libpng.pc $(DL)/pkgconfig/libpng10.pc
chmod 644 $(DL)/pkgconfig/libpng10.pc
(cd $(DL)/pkgconfig; ln -f -s libpng10.pc libpng.pc)
install-man: libpng.3 libpngpf.3 png.5
-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
-@/bin/rm -f $(DM)/man3/libpng.3
-@/bin/rm -f $(DM)/man3/libpngpf.3
cp libpng.3 $(DM)/man3
cp libpngpf.3 $(DM)/man3
-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
-@/bin/rm -f $(DM)/man5/png.5
cp png.5 $(DM)/man5
install-config: libpng-config
-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
-@/bin/rm -f $(DB)/libpng-config
-@/bin/rm -f $(DB)/libpng10-config
cp libpng-config $(DB)/libpng10-config
chmod 755 $(DB)/libpng10-config
(cd $(DB); ln -sf libpng10-config libpng-config)
install: install-static install-shared install-man install-config
# If you installed in $(DESTDIR), test-installed won't work until you
# move the library to its final location.
test-installed:
echo
echo Testing installed dynamic shared library.
$(CC) $(SUN_CC_FLAGS) -I$(ZLIBINC) \
`$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
-o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs` \
$(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB)
./pngtesti pngtest.png
clean:
/bin/rm -f *.o libpng.a pngtest pngtesti pngout.png libpng.pc \
libpng-config $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)*
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
writelock:
chmod a-w *.[ch35] $(DOCS) scripts/*
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o png.pic.o: png.h pngconf.h
pngerror.o pngerror.pic.o: png.h pngconf.h
pngrio.o pngrio.pic.o: png.h pngconf.h
pngwio.o pngwio.pic.o: png.h pngconf.h
pngmem.o pngmem.pic.o: png.h pngconf.h
pngset.o pngset.pic.o: png.h pngconf.h
pngget.o pngget.pic.o: png.h pngconf.h
pngread.o pngread.pic.o: png.h pngconf.h
pngrtran.o pngrtran.pic.o: png.h pngconf.h
pngrutil.o pngrutil.pic.o: png.h pngconf.h
pngtrans.o pngtrans.pic.o: png.h pngconf.h
pngwrite.o pngwrite.pic.o: png.h pngconf.h
pngwtran.o pngwtran.pic.o: png.h pngconf.h
pngwutil.o pngwutil.pic.o: png.h pngconf.h
pngpread.o pngpread.pic.o: png.h pngconf.h
pngtest.o: png.h pngconf.h

213
scripts/makefile.64sunu Normal file
View File

@@ -0,0 +1,213 @@
# makefile for libpng on Solaris 2.x with cc
# Contributed by William L. Sebok, based on makefile.linux
# Copyright (C) 2002 Glenn Randers-Pehrson
# Copyright (C) 1998 Greg Roelofs
# Copyright (C) 1996, 1997 Andreas Dilger
# For conditions of distribution and use, see copyright notice in png.h
CC=cc
SUN_CC_FLAGS=-fast -xtarget=ultra -xarch=v9
SUN_LD_FLAGS=-fast -xtarget=ultra -xarch=v9
# where make install puts libpng.a, libpng10.so and libpng10/png.h
prefix=/a
# Where the zlib library and include files are located
# Changing these to ../zlib poses a security risk. If you want
# to have zlib in an adjacent directory, specify the full path instead of "..".
#ZLIBLIB=../zlib
#ZLIBINC=../zlib
ZLIBLIB=/usr/lib
ZLIBINC=/usr/include
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
CFLAGS=-I$(ZLIBINC) $(SUN_CC_FLAGS) \
# $(WARNMORE) -g -DPNG_DEBUG=5
LDFLAGS=-L. -R. $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng10 -lz -lm
#RANLIB=ranlib
RANLIB=echo
LIBNAME=libpng10
PNGMAJ = 0
PNGMIN = 1.0.14
PNGVER = $(PNGMAJ).$(PNGMIN)
INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib
MANPATH=$(prefix)/man
BINPATH=$(prefix)/bin
# override DESTDIR= on the make install command line to easily support
# installing into a temporary location. Example:
#
# make install DESTDIR=/tmp/build/libpng
#
# If you're going to install into a temporary location
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
# you execute make install.
DESTDIR=
DB=$(DESTDIR)$(BINPATH)
DI=$(DESTDIR)$(INCPATH)
DL=$(DESTDIR)$(LIBPATH)
DM=$(DESTDIR)$(MANPATH)
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o
OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o
.c.pic.o:
$(CC) -c $(CFLAGS) -KPIC -o $@ $*.c
all: libpng.a $(LIBNAME).so pngtest libpng.pc libpng-config
libpng.a: $(OBJS)
ar rc $@ $(OBJS)
$(RANLIB) $@
libpng.pc:
cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
libpng-config:
( cat scripts/libpng-config-head.in; \
echo prefix=\"$(prefix)\"; \
echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo cflags=\"-xtarget=ultra -xarch=v9\"; \
echo ldflags=\"-xtarget=ultra -xarch=v9 -L$(LIBPATH) -R$(LIBPATH)\"; \
echo libs=\"-lpng10 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config
$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER)
ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
$(LIBNAME).so.$(PNGVER): $(OBJSDLL)
@case "`type ld`" in *ucb*) \
echo; \
echo '## WARNING:'; \
echo '## The commands "CC" and "LD" must NOT refer to /usr/ucb/cc'; \
echo '## and /usr/ucb/ld. If they do, you need to adjust your PATH'; \
echo '## environment variable to put /usr/ccs/bin ahead of /usr/ucb.'; \
echo '## The environment variable LD_LIBRARY_PATH should not be set'; \
echo '## at all. If it is, things are likely to break because of'; \
echo '## the libucb dependency that is created.'; \
echo; \
;; \
esac
$(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h $(LIBNAME).so.$(PNGMAJ) \
-o $(LIBNAME).so.$(PNGVER) $(OBJSDLL) -lz
pngtest: pngtest.o $(LIBNAME).so
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
test: pngtest
./pngtest
install-headers: png.h pngconf.h
-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
cp png.h pngconf.h $(DI)/$(LIBNAME)
chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
-@/bin/rm $(DI)/libpng
(cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .)
install-static: install-headers libpng.a
-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
cp libpng.a $(DL)/$(LIBNAME).a
chmod 644 $(DL)/$(LIBNAME).a
-@/bin/rm -f $(DL)/libpng.a
(cd $(DL); ln -f -s $(LIBNAME).a libpng.a)
install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
-@/bin/rm -f $(DL)/libpng.so
-@/bin/rm -f $(DL)/libpng.so.2
-@/bin/rm -f $(DL)/libpng.so.2.*
cp $(LIBNAME).so.$(PNGVER) $(DL)
chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
(cd $(DL); \
ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so; \
ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so.2; \
ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so.2.$(PNGMIN); \
ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
(cd $(DL)/pkgconfig; ln -f -s $(LIBNAME).pc libpng.pc)
install-man: libpng.3 libpngpf.3 png.5
-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
-@/bin/rm -f $(DM)/man3/libpng.3
-@/bin/rm -f $(DM)/man3/libpngpf.3
cp libpng.3 $(DM)/man3
cp libpngpf.3 $(DM)/man3
-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
-@/bin/rm -f $(DM)/man5/png.5
cp png.5 $(DM)/man5
install-config: libpng-config
-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
-@/bin/rm -f $(DB)/libpng-config
-@/bin/rm -f $(DB)/$(LIBNAME)-config
cp libpng-config $(DB)/$(LIBNAME)-config
chmod 755 $(DB)/$(LIBNAME)-config
(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
install: install-static install-shared install-man install-config
# If you installed in $(DESTDIR), test-installed won't work until you
# move the library to its final location.
test-installed:
echo
echo Testing installed dynamic shared library.
$(CC) $(SUN_CC_FLAGS) -I$(ZLIBINC) \
`$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
-o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs` \
$(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB)
./pngtesti pngtest.png
clean:
/bin/rm -f *.o libpng.a pngtest pngtesti pngout.png libpng.pc \
libpng-config $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)*
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
writelock:
chmod a-w *.[ch35] $(DOCS) scripts/*
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o png.pic.o: png.h pngconf.h
pngerror.o pngerror.pic.o: png.h pngconf.h
pngrio.o pngrio.pic.o: png.h pngconf.h
pngwio.o pngwio.pic.o: png.h pngconf.h
pngmem.o pngmem.pic.o: png.h pngconf.h
pngset.o pngset.pic.o: png.h pngconf.h
pngget.o pngget.pic.o: png.h pngconf.h
pngread.o pngread.pic.o: png.h pngconf.h
pngrtran.o pngrtran.pic.o: png.h pngconf.h
pngrutil.o pngrutil.pic.o: png.h pngconf.h
pngtrans.o pngtrans.pic.o: png.h pngconf.h
pngwrite.o pngwrite.pic.o: png.h pngconf.h
pngwtran.o pngwtran.pic.o: png.h pngconf.h
pngwutil.o pngwutil.pic.o: png.h pngconf.h
pngpread.o pngpread.pic.o: png.h pngconf.h
pngtest.o: png.h pngconf.h

View File

@@ -1,7 +1,8 @@
# makefile for libpng using gcc (generic, static library) # makefile for libpng using gcc (generic, static library)
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. # Copyright (C) 2002 Glenn Randers-Pehrson
# Copyright (C) 2000 Cosmin Truta # Copyright (C) 2000 Cosmin Truta
# Copyright (C) 2000 Marc O. Gloor (AIX support added, from makefile.gcc) # Copyright (C) 2000 Marc O. Gloor (AIX support added, from makefile.gcc)
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h # For conditions of distribution and use, see copyright notice in png.h
# Location of the zlib library and include files # Location of the zlib library and include files
@@ -15,16 +16,27 @@ AR = ar rcs
RANLIB = ranlib RANLIB = ranlib
RM = rm -f RM = rm -f
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not PNGMAJ = 0
# have to change it. PNGMIN = 1.0.14
PNGMAJ = 2
PNGMIN = 1.0.9
PNGVER = $(PNGMAJ).$(PNGMIN) PNGVER = $(PNGMAJ).$(PNGMIN)
prefix=/usr/local prefix=/usr/local
INCPATH=$(prefix)/include INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib LIBPATH=$(prefix)/lib
# override DESTDIR= on the make install command line to easily support
# installing into a temporary location. Example:
#
# make install DESTDIR=/tmp/build/libpng
#
# If you're going to install into a temporary location
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
# you execute make install.
DESTDIR=
DI=$(DESTDIR)/$(INCPATH)
DL=$(DESTDIR)/$(LIBPATH)
CDEBUG = -g -DPNG_DEBUG=5 CDEBUG = -g -DPNG_DEBUG=5
LDDEBUG = LDDEBUG =
CRELEASE = -O2 CRELEASE = -O2
@@ -56,14 +68,19 @@ pngtest$(E): pngtest$(O) libpng$(A)
$(LD) -o $@ pngtest$(O) $(LDFLAGS) $(LD) -o $@ pngtest$(O) $(LDFLAGS)
install: libpng.a install: libpng.a
-@if [ ! -d $(INCPATH) ]; then mkdir $(INCPATH); fi -@if [ ! -d $(DI) ]; then mkdir $(DI); fi
-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi -@if [ ! -d $(DI)/libpng ]; then mkdir $(DI)/libpng; fi
cp png.h pngconf.h $(INCPATH) -@if [ ! -d $(DL) ]; then mkdir $(DL); fi
chmod 644 $(INCPATH)/png.h $(INCPATH)/pngconf.h -@rm $(DI)/png.h
cp libpng.a $(LIBPATH) -@rm $(DI)/pngconf.h
cp png.h pngconf.h $(DI)/libpng
chmod 644 $(DI)/libpng/png.h \
$(DI)/libpng/pngconf.h
(cd $(DI); ln -f -s libpng/* .)
cp libpng.a $(DL)
clean: clean:
/bin/rm -f *.o libpng.a libpng.so* pngtest pngout.png /bin/rm -f *.o libpng.a pngtest pngout.png
png$(O): png.h pngconf.h png$(O): png.h pngconf.h
pngerror$(O): png.h pngconf.h pngerror$(O): png.h pngconf.h

View File

@@ -1,4 +1,5 @@
# makefile for libpng # makefile for libpng
# Copyright (C) 2002 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h # For conditions of distribution and use, see copyright notice in png.h
# modified for LC56/ATARI assumes libz.lib is in same dir and uses default # modified for LC56/ATARI assumes libz.lib is in same dir and uses default
@@ -10,6 +11,18 @@ LDFLAGS=-lpng -lz -lm
# where make install puts libpng.a and png.h # where make install puts libpng.a and png.h
prefix=/usr/local prefix=/usr/local
INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib
# override DESTDIR= on the make install command line to easily support
# installing into a temporary location. Example:
#
# make install DESTDIR=/tmp/build/libpng
#
# If you're going to install into a temporary location
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
# you execute make install.
DESTDIR=
OBJS = $(LBR)(png.o) $(LBR)(pngset.o) $(LBR)(pngget.o) $(LBR)(pngrutil.o)\ OBJS = $(LBR)(png.o) $(LBR)(pngset.o) $(LBR)(pngget.o) $(LBR)(pngrutil.o)\
$(LBR)(pngtrans.o) $(LBR)(pngwutil.o)\ $(LBR)(pngtrans.o) $(LBR)(pngwutil.o)\
@@ -25,9 +38,14 @@ pngtest.ttp: pngtest.o $(LBR)
$(CC) $(CFLAGS) $(LDFLAGS) -o$@ pngtest.o $(CC) $(CFLAGS) $(LDFLAGS) -o$@ pngtest.o
install: libpng.a install: libpng.a
-@mkdir $(prefix)/include -@mkdir $(DESTDIR)$(INCPATH)
-@mkdir $(prefix)/lib -@mkdir $(DESTDIR)$(INCPATH)/libpng
cp png.h $(prefix)/include -@mkdir $(DESTDIR)$(LIBPATH)
cp pngconf.h $(prefix)/include -@rm -f $(DESTDIR)$(INCPATH)/png.h
chmod 644 $(prefix)/include/png.h -@rm -f $(DESTDIR)$(INCPATH)/pngconf.h
chmod 644 $(prefix)/include/pngconf.h cp png.h $(DESTDIR)$(INCPATH)/libpng
cp pngconf.h $(DESTDIR)$(INCPATH)/libpng
chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h
chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h
(cd $(DESTDIR)$(INCPATH); ln -f -s $(LIBNAME) libpng; \
ln -f -s $(LIBNAME)/* .)

View File

@@ -1,5 +1,6 @@
# makefile for libpng on BeOS x86 ELF with gcc # makefile for libpng on BeOS x86 ELF with gcc
# modified from makefile.linux by Sander Stoks # modified from makefile.linux by Sander Stoks
# Copyright (C) 2002 Glenn Randers-Pehrson
# Copyright (C) 1999 Greg Roelofs # Copyright (C) 1999 Greg Roelofs
# Copyright (C) 1996, 1997 Andreas Dilger # Copyright (C) 1996, 1997 Andreas Dilger
# For conditions of distribution and use, see copyright notice in png.h # For conditions of distribution and use, see copyright notice in png.h
@@ -10,10 +11,8 @@ CC=gcc
ZLIBLIB=/usr/local/lib ZLIBLIB=/usr/local/lib
ZLIBINC=/usr/local/include ZLIBINC=/usr/local/include
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not PNGMAJ = 0
# have to change it. PNGMIN = 1.0.14
PNGMAJ = 2
PNGMIN = 1.0.9
PNGVER = $(PNGMAJ).$(PNGMIN) PNGVER = $(PNGMAJ).$(PNGMIN)
ALIGN= ALIGN=
@@ -29,15 +28,34 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
CFLAGS=-I$(ZLIBINC) -Wall -O1 -funroll-loops \ CFLAGS=-I$(ZLIBINC) -Wall -O1 -funroll-loops \
$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
# LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz -lm # LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz -lm
LDFLAGS=-L. -Wl,-soname=libpng.so.$(PNGMAJ) -L$(ZLIBLIB) -lz -lm LDFLAGS=-L. -Wl,-soname=$(LIBNAME).so.$(PNGMAJ) -L$(ZLIBLIB) -lz -lm
RANLIB=ranlib RANLIB=ranlib
#RANLIB=echo #RANLIB=echo
# where make install puts libpng.a, libpng.so*, and png.h # where make install puts libpng.a, libpng10.so*, and png.h
prefix=/usr/local prefix=/usr/local
INCPATH=$(prefix)/include INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib LIBPATH=$(prefix)/lib
MANPATH=$(prefix)/man
BINPATH=$(prefix)/bin
# override DESTDIR= on the make install command line to easily support
# installing into a temporary location. Example:
#
# make install DESTDIR=/tmp/build/libpng
#
# If you're going to install into a temporary location
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
# you execute make install.
DESTDIR=
DB=$(DESTDIR)$(BINPATH)
DI=$(DESTDIR)$(INCPATH)
DL=$(DESTDIR)$(LIBPATH)
DM=$(DESTDIR)$(MANPATH)
LIBNAME=libpng10
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -47,42 +65,114 @@ OBJSDLL = $(OBJS)
.SUFFIXES: .c .o .SUFFIXES: .c .o
all: libpng.a libpng.so pngtest all: libpng.a $(LIBNAME).so pngtest libpng.pc libpng-config
libpng.a: $(OBJS) libpng.a: $(OBJS)
ar rc $@ $(OBJS) ar rc $@ $(OBJS)
$(RANLIB) $@ $(RANLIB) $@
libpng.so: libpng.so.$(PNGMAJ) libpng.pc:
ln -sf libpng.so.$(PNGMAJ) libpng.so cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
cp libpng.so* /boot/home/config/lib
libpng.so.$(PNGMAJ): libpng.so.$(PNGVER) libpng-config:
ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ) ( cat scripts/libpng-config-head.in; \
echo prefix=\"$(prefix)\"; \
echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo cflags=\"\"; \
echo ldflags=\"-Wl,-soname=$(LIBNAME).so.$(PNGMAJ)\"; \
echo libs=\"-lpng10 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config
libpng.so.$(PNGVER): $(OBJSDLL) $(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
$(CC) -L$(ZLIBLIB) -lz -nostart -Wl,-soname,libpng.so.$(PNGMAJ) -o ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
libpng.so.$(PNGVER) \ cp $(LIBNAME).so* /boot/home/config/lib
$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER)
ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
$(LIBNAME).so.$(PNGVER): $(OBJSDLL)
$(CC) -L$(ZLIBLIB) -lz -nostart -Wl,-soname,$(LIBNAME).so.$(PNGMAJ) -o
$(LIBNAME).so.$(PNGVER) \
$(OBJSDLL) $(OBJSDLL)
pngtest: pngtest.o libpng.so pngtest: pngtest.o $(LIBNAME).so
$(CC) -L$(ZLIBLIB) -lz -lpng -o pngtest pngtest.o $(CC) -L$(ZLIBLIB) -lz -lpng10 -o pngtest pngtest.o
test: pngtest test: pngtest
./pngtest ./pngtest
install: libpng.a libpng.so.$(PNGVER) install-headers: png.h pngconf.h
-@mkdir $(INCPATH) $(LIBPATH) -@if [ ! -d $(DI) ]; then mkdir $(DI); fi
cp png.h pngconf.h $(INCPATH) -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
chmod 644 $(INCPATH)/png.h $(INCPATH)/pngconf.h cp png.h pngconf.h $(DI)/$(LIBNAME)
cp libpng.a libpng.so.$(PNGVER) $(LIBPATH) chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
chmod 755 $(LIBPATH)/libpng.so.$(PNGVER) -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
-@/bin/rm -f $(LIBPATH)/libpng.so.$(PNGMAJ) $(LIBPATH)/libpng.so -@/bin/rm -f $(DI)/libpng
(cd $(LIBPATH); ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \ (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
ln -sf libpng.so.$(PNGMAJ) libpng.so)
install-static: install-headers libpng.a
-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
cp libpng.a $(DL)/$(LIBNAME).a
chmod 644 $(DL)/$(LIBNAME).a
-@/bin/rm -f $(DL)/libpng.a
(cd $(DL); ln -sf $(LIBNAME).a libpng.a)
install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
-@/bin/rm -f $(DL)/libpng.so
-@/bin/rm -f $(DL)/libpng.so.2
-@/bin/rm -f $(DL)/libpng.so.2.*
cp $(LIBNAME).so.$(PNGVER) $(DL)
chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
(cd $(DL); \
ln -sf $(LIBNAME).so.$(PNGVER) libpng.so; \
ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.2; \
ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.2.$(PNGMIN); \
ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
(cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
install-man: libpng.3 libpngpf.3 png.5
-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
-@/bin/rm -f $(DM)/man3/libpng.3
-@/bin/rm -f $(DM)/man3/libpngpf.3
cp libpng.3 $(DM)/man3
cp libpngpf.3 $(DM)/man3
-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
-@/bin/rm -f $(DM)/man5/png.5
cp png.5 $(DM)/man5
install-config: libpng-config
-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
-@/bin/rm -f $(DB)/libpng-config
-@/bin/rm -f $(DB)/$(LIBNAME)-config
cp libpng-config $(DB)/$(LIBNAME)-config
chmod 755 $(DB)/$(LIBNAME)-config
(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
install: install-static install-shared install-man install-config
# If you installed in $(DESTDIR), test-installed won't work until you
# move the library to its final location.
test-installed:
$(CC) $(CFLAGS) \
`$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
-o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs`
./pngtesti pngtest.png
clean: clean:
/bin/rm -f *.o libpng.a libpng.so* pngtest pngout.png /bin/rm -f *.o libpng.a pngtest pngout.png libpng.pc libpng-config \
$(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtesti
# DO NOT DELETE THIS LINE -- make depend depends on it. # DO NOT DELETE THIS LINE -- make depend depends on it.

View File

@@ -1,24 +1,55 @@
# makefile for cygwin on x86 # makefile for cygwin on x86
# builds both dll (with import lib) and static lib versions # Builds both dll (with import lib) and static lib versions
# of the library, and builds two copies of pngtest: one # of the library, and builds two copies of pngtest: one
# statically linked and one dynamically linked. # statically linked and one dynamically linked.
# #
# Copyright (C) 2002 Soren Anderson, Charles Wilson, and Glenn Randers-Pehrson
# based on makefile for linux-elf w/mmx by: # based on makefile for linux-elf w/mmx by:
# Copyright (C) 1998-2000 Greg Roelofs # Copyright (C) 1998-2000 Greg Roelofs
# Copyright (C) 1996, 1997 Andreas Dilger # Copyright (C) 1996, 1997 Andreas Dilger
# For conditions of distribution and use, see copyright notice in png.h # For conditions of distribution and use, see copyright notice in png.h
# This makefile intends to support building outside the src directory
# if desired. When invoking it, specify an argument to SRCDIR on the
# command line that points to the top of the directory where your source
# is located.
ifdef SRCDIR
VPATH = $(SRCDIR)
else
SRCDIR = .
endif
# Override DESTDIR= on the make install command line to easily support
# installing into a temporary location. Example:
#
# make install DESTDIR=/tmp/build/libpng
#
# If you're going to install into a temporary location
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
# you execute make install.
DESTDIR=
# To enable assembler optimizations, add '-DPNG_USE_PNGGCCRD' to # To enable assembler optimizations, add '-DPNG_USE_PNGGCCRD' to
# $CFLAGS, and include pnggccrd.o in $OBJS, below. # $CFLAGS, and include pnggccrd.o in $OBJS, below, and in the dependency
# list at the bottom of this makefile.
CC=gcc CC=gcc
ifdef MINGW
MINGW_CCFLAGS=-mno-cygwin -I/usr/include/mingw
MINGW_LDFLAGS=-mno-cygwin -L/usr/lib/mingw
endif
# where "make install" puts libpng.a, libpng.so*, png.h, and pngconf.h # Where "make install" puts libpng*.a, *png*.dll, png.h, and pngconf.h
ifndef prefix
prefix=/usr prefix=/usr
$(warning You haven't specified a 'prefix=' location. Defaulting to "/usr")
endif
# Where the zlib library and include files are located # Where the zlib library and include files are located
ZLIBLIB=${prefix}/lib ZLIBLIB= /usr/lib
ZLIBINC=${prefix}/include ZLIBINC=
#ZLIBLIB=../zlib #ZLIBLIB=../zlib
#ZLIBINC=../zlib #ZLIBINC=../zlib
@@ -30,18 +61,25 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \ -Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
#CFLAGS=-DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 $(ALIGN) -funroll-loops \ ### if you use the asm, add pnggccrd.o to the OBJS list
# -fomit-frame-pointer # $(WARNMORE) -g -DPNG_DEBUG=5 ###
CFLAGS=-I$(ZLIBINC) -Wall -O3 $(ALIGN) -funroll-loops \ ### if you don't need thread safety, but want the asm accel
-fomit-frame-pointer #CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD \
# $(addprefix -I,$(ZLIBINC)) -Wall -O3 $(ALIGN) -funroll-loops \
# -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
### if you need thread safety and want (minimal) asm accel
#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_USE_PNGGCCRD $(addprefix -I,$(ZLIBINC)) \
# -Wall -O3 $(ALIGN) -funroll-loops \
# -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
### Normal (non-asm) compilation
CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \
-Wall -O3 $(ALIGN) -funroll-loops \
-fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not LIBNAME = libpng10
# have to change it. PNGMAJ = 0
PNGMAJ = 2 PNGDLL = 10
#PNGDLL = $%DLLNUM% # msvc PNGMIN = 1.0.14
PNGDLL = 2 # cygwin 1.0.9
PNGMIN = 1.0.9
PNGMIN_BASE = 1.0.9
PNGVER = $(PNGMAJ).$(PNGMIN) PNGVER = $(PNGMAJ).$(PNGMIN)
SHAREDLIB=cygpng$(PNGDLL).dll SHAREDLIB=cygpng$(PNGDLL).dll
@@ -51,19 +89,28 @@ SHAREDDEF=libpng.def
LIBS=$(SHAREDLIB) $(STATLIB) LIBS=$(SHAREDLIB) $(STATLIB)
EXE=.exe EXE=.exe
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz LDFLAGS=$(strip -L. $(MINGW_LDFLAGS) -lpng $(addprefix -L,$(ZLIBLIB)) -lz)
LDSHARED=gcc -shared -Wl,--enable-auto-image-base LDSFLAGS=$(strip -shared -L. $(MINGW_LDFLAGS) -Wl,--export-all)
LDEXTRA=-Wl,--out-implib=$(IMPLIB) $(SHAREDDEF) LDEXTRA=-Wl,--out-implib=$(IMPLIB) $(addprefix -L,$(ZLIBLIB)) -lz
MKDIR=/bin/mkdir -pv
RANLIB=ranlib RANLIB=ranlib
#RANLIB=echo #RANLIB=echo
INCPATH=$(prefix)/include INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib LIBPATH=$(prefix)/lib
BINPATH=$(prefix)/bin BINPATH=$(prefix)/bin
MANPATH=$(prefix)/man MANPATH=$(prefix)/man
MAN3PATH=$(MANPATH)/man3 MAN3PATH=$(MANPATH)/man3
DOCPATH=$(prefix)/doc/libpng-$(PNGMIN_BASE) MAN5PATH=$(MANPATH)/man5
# cosmetic: shortened strings:
S =$(SRCDIR)
D =$(DESTDIR)
DB =$(D)$(BINPATH)
DI =$(D)$(INCPATH)
DL =$(D)$(LIBPATH)
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -71,47 +118,71 @@ OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
OBJSDLL = $(OBJS:.o=.pic.o) OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o .SUFFIXES: .c .o .pic.o
%.o : %.c %.o : %.c
$(CC) -c $(CFLAGS) -DPNG_STATIC -DZLIB_STATIC -o $@ $< $(CC) -c $(CFLAGS) -o $@ $<
%.pic.o : CFLAGS += -DPNG_BUILD_DLL
%.pic.o : %.c %.pic.o : %.c
$(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $< $(CC) -c $(CFLAGS) -o $@ $<
all: all-static all-shared all: all-static all-shared libpng.pc libpng-config libpng.pc libpng-config
# Make this to verify that "make [...] install" will do what you want.
buildsetup-tell:
@echo VPATH is set to: \"$(VPATH)\"
@echo prefix is set to: \"$(prefix)\"
@echo -e INCPATH,LIBPATH, etc. are set to:'\n' \
$(addprefix $(D),$(INCPATH)'\n' $(LIBPATH)'\n' $(BINPATH)'\n' \
$(MANPATH)'\n' $(MAN3PATH)'\n' $(MAN5PATH)'\n')'\n'
libpng.pc: scripts/libpng.pc.in
@echo -e Making pkg-config file for this libpng installation..'\n' \
using PREFIX=\"$(prefix)\"'\n'
cat $(S)/scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \
sed -e s/-lm// > libpng.pc
libpng-config: scripts/libpng-config-head.in scripts/libpng-config-body.in
@echo -e Making $(LIBNAME) libpng-config file for this libpng \
installation..'\n' using PREFIX=\"$(prefix)\"'\n'
( cat $(S)/scripts/libpng-config-head.in; \
echo prefix=\"$(prefix)\"; \
echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo cflags=\"\"; \
echo ldflags=\"-L$(LIBPATH)\"; \
echo libs=\"-lpng$(PNGMAJ) -lz\"; \
cat $(S)/scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config
static: all-static static: all-static
shared: all-shared shared: all-shared
all-static: $(STATLIB) pngtest-stat$(EXE) all-static: $(STATLIB) pngtest-stat$(EXE)
all-shared: $(SHAREDLIB) pngtest$(EXE) all-shared: $(SHAREDLIB) pngtest$(EXE)
pnggccrd.o: png.h pngconf.h pnggccrd.o: pnggccrd.c png.h pngconf.h
@echo "" @echo ""
@echo ' You can ignore the single "control reaches end of non-void function"' @echo ' You can ignore the "control reaches end of non-void function"'
@echo ' warning and multiple "<variable> defined but not used" warnings:' @echo ' warning and "<variable> defined but not used" warnings:'
@echo "" @echo ""
$(CC) -c $(CFLAGS) -DPNG_STATIC -DZLIB_STATIC -o $@ $*.c $(CC) -c $(CFLAGS) -o $@ $<
pnggccrd.pic.o: png.h pngconf.h pnggccrd.pic.o: pnggccrd.c png.h pngconf.h
@echo "" @echo ""
@echo ' You can ignore the single "control reaches end of non-void function"' @echo ' You can ignore the "control reaches end of non-void function"'
@echo ' warning and multiple "<variable> defined but not used" warnings:' @echo ' warning and "<variable> defined but not used" warnings:'
@echo "" @echo ""
$(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ pnggccrd.c $(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
$(STATLIB): $(OBJS) $(STATLIB): $(OBJS)
ar rc $@ $(OBJS) ar rc $@ $(OBJS)
$(RANLIB) $@ $(RANLIB) $@
$(SHAREDDEF): projects/msvc/png32ms.def $(SHAREDDEF): projects/msvc/png32ms.def
cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' > $@ cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' | \
sed -e 's/\([^;]*\);/;/' > $@
$(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF) $(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF)
$(LDSHARED) -o $@ $(LDEXTRA) $(OBJSDLL) -L. -L$(ZLIBLIB) -lz $(CC) $(LDSFLAGS) -o $@ $(OBJSDLL) -L. $(LDEXTRA)
pngtest$(EXE): pngtest.pic.o $(SHAREDLIB) pngtest$(EXE): pngtest.pic.o $(SHAREDLIB)
$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@ $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
@@ -123,48 +194,93 @@ pngtest.pic.o: pngtest.c
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
pngtest.o: pngtest.c pngtest.o: pngtest.c
$(CC) $(CFLAGS) -DPNG_STATIC -DZLIB_STATIC -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
test: test-static test-shared test: test-static test-shared
test-static: pngtest-stat$(EXE) test-static: pngtest-stat$(EXE)
./pngtest-stat ./pngtest-stat $(S)/pngtest.png
test-shared: pngtest$(EXE) test-shared: pngtest$(EXE)
./pngtest ./pngtest $(S)/pngtest.png
install: install-static install-shared install-static: $(STATLIB) install-headers install-man
-@if [ ! -d $(DL) ]; then $(MKDIR) $(DL); fi
install -m 644 $(STATLIB) $(DL)/$(LIBNAME).a
-@rm -f $(DL)/$(STATLIB)
(cd $(DL); ln -sf $(LIBNAME).a $(STATLIB))
install-static: $(STATLIB) install-headers install-docs install-man install-shared: $(SHAREDLIB) libpng.pc libpng-config install-headers install-man
-@if [ ! -d $(LIBPATH) ]; then mkdir -p $(LIBPATH); fi -@if [ ! -d $(DL) ]; then $(MKDIR) $(DL); fi
install -m 755 $(STATLIB) $(LIBPATH) -@if [ ! -d $(DB) ]; then $(MKDIR) $(DB); fi
-@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR) $(DL)/pkgconfig; fi
install-shared: $(SHAREDLIB) install-headers install-docs install-man -@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
-@if [ ! -d $(LIBPATH) ]; then mkdir -p $(LIBPATH); fi -@/bin/rm -f $(DL)/pkgconfig/libpng.pc
-@if [ ! -d $(BINPATH) ]; then mkdir -p $(BINPATH); fi install -m 644 $(IMPLIB) $(DL)/$(LIBNAME).dll.a
install -m 755 $(IMPLIB) $(LIBPATH) -@rm -f $(DL)/$(IMPLIB)
install -s -m 755 $(SHAREDLIB) $(BINPATH) (cd $(DL); ln -sf $(LIBNAME).dll.a $(IMPLIB))
install -s -m 755 $(SHAREDLIB) $(DB)
install -m 644 libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
(cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
install-headers: install-headers:
-@if [ ! -d $(INCPATH) ]; then mkdir -p $(INCPATH); fi -@if [ ! -d $(DI) ]; then $(MKDIR) $(DI); fi
install -m 644 png.h pngconf.h $(INCPATH) -@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR) $(DI)/$(LIBNAME); fi
-@rm -f $(DI)/png.h
install-docs: -@rm -f $(DI)/pngconf.h
-@if [ ! -d $(DOCPATH) ]; then mkdir -p $(DOCPATH); fi install -m 644 $(S)/png.h $(S)/pngconf.h $(DI)/$(LIBNAME)
install -m 644 $(DOCS) $(DOCPATH) -@rm -f $(DI)/libpng
(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
install-man: install-man:
-@if [ ! -d $(MAN3PATH) ]; then mkdir -p $(MAN3PATH); fi -@if [ ! -d $(D)$(MAN3PATH) ]; then $(MKDIR) $(D)$(MAN3PATH); fi
install -m 644 libpngpf.3 libpng.3 $(MAN3PATH) -@if [ ! -d $(D)$(MAN5PATH) ]; then $(MKDIR) $(D)$(MAN5PATH); fi
install -m 644 $(S)/libpngpf.3 $(S)/libpng.3 $(D)$(MAN3PATH)
install -m 644 $(S)/png.5 $(D)$(MAN5PATH)
install-config: libpng-config
-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
-@/bin/rm -f $(DB)/libpng-config
-@/bin/rm -f $(DB)/$(LIBNAME)-config
cp libpng-config $(DB)/$(LIBNAME)-config
chmod 755 $(DB)/$(LIBNAME)-config
(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
# Run this to verify that a future `configure' run will pick up the settings
# you want.
test-config-install: SHELL=/bin/bash
test-config-install: $(DB)/libpng-config
@echo -e Testing libpng-config functions...'\n'
@ for TYRA in LDFLAGS CPPFLAGS CFLAGS LIBS VERSION; \
do \
printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \
"$$($(DB)/libpng-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'`)"; \
gytiu=$$(( $$gytiu + 1 )); \
done
install: install-static install-shared install-man install-config
# If you installed in $(DESTDIR), test-installed won't work until you
# move the library to its final location.
test-installed:
$(CC) $(CFLAGS) \
`$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
-L$(ZLIBLIB) \
-o pngtesti$(EXE) `$(BINPATH)/libpng10-config --ldflags --libs`
./pngtesti$(EXE) pngtest.png
clean: clean:
/bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \ /bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \
pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF) pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF) \
libpng-config libpng.pc pngtesti$(EXE)
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
writelock: writelock:
chmod a-w *.[ch35] $(DOCS) scripts/* chmod a-w *.[ch35] $(DOCS) scripts/*
.PHONY: buildsetup-tell libpng.pc libpng-config test-config-install clean
# DO NOT DELETE THIS LINE -- make depend depends on it. # DO NOT DELETE THIS LINE -- make depend depends on it.
png.o png.pic.o: png.h pngconf.h png.c png.o png.pic.o: png.h pngconf.h png.c
@@ -185,3 +301,6 @@ pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c
pngtest.o: png.h pngconf.h pngtest.c pngtest.o: png.h pngconf.h pngtest.c
pngtest-stat.o: png.h pngconf.h pngtest.c pngtest-stat.o: png.h pngconf.h pngtest.c

195
scripts/makefile.darwin Normal file
View File

@@ -0,0 +1,195 @@
# makefile for libpng on Darwin / Mac OS X
# Copyright (C) 2002 Glenn Randers-Pehrson
# Copyright (C) 2001 Christoph Pfisterer
# derived from makefile.linux:
# Copyright (C) 1998, 1999 Greg Roelofs
# Copyright (C) 1996, 1997 Andreas Dilger
# For conditions of distribution and use, see copyright notice in png.h
# where "make install" puts libpng.a, libpng10.dylib, png.h and pngconf.h
prefix=/usr/local
# Where the zlib library and include files are located
#ZLIBLIB=/usr/local/lib
#ZLIBINC=/usr/local/include
ZLIBLIB=../zlib
ZLIBINC=../zlib
CC=cc
CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops
LDFLAGS=-L. -L$(ZLIBLIB) -lpng10 -lz
#RANLIB=echo
RANLIB=ranlib
PNGMAJ = 0
PNGMIN = 1.0.14
PNGVER = $(PNGMAJ).$(PNGMIN)
LIBNAME = libpng10
INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib
MANPATH=$(prefix)/man
BINPATH=$(prefix)/bin
# override DESTDIR= on the make install command line to easily support
# installing into a temporary location. Example:
#
# make install DESTDIR=/tmp/build/libpng
#
# If you're going to install into a temporary location
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
# you execute make install.
DESTDIR=
DB=$(DESTDIR)$(BINPATH)
DI=$(DESTDIR)$(INCPATH)
DL=$(DESTDIR)$(LIBPATH)
DM=$(DESTDIR)$(MANPATH)
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o
OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o
.c.pic.o:
$(CC) -c $(CFLAGS) -fno-common -o $@ $*.c
all: libpng.a $(LIBNAME).dylib pngtest libpng.pc libpng-config
libpng.a: $(OBJS)
ar rc $@ $(OBJS)
$(RANLIB) $@
libpng.pc:
cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \
sed -e s/-lm// > libpng.pc
libpng-config:
( cat scripts/libpng-config-head.in; \
echo prefix=\"$(prefix)\"; \
echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo cflags=\"\"; \
echo ldflags=\"-L$(LIBPATH)\"; \
echo libs=\"-lpng10 -lz\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config
$(LIBNAME).dylib: $(LIBNAME).$(PNGMAJ).dylib
ln -sf $(LIBNAME).$(PNGMAJ).dylib $(LIBNAME).dylib
$(LIBNAME).$(PNGMAJ).dylib: $(LIBNAME).$(PNGVER).dylib
ln -sf $(LIBNAME).$(PNGVER).dylib $(LIBNAME).$(PNGMAJ).dylib
$(LIBNAME).$(PNGVER).dylib: $(OBJSDLL)
$(CC) -dynamiclib \
-install_name $(DL)/$(LIBNAME).$(PNGMAJ).dylib \
-current_version $(PNGMIN) -compatibility_version $(PNGMIN) \
-o $(LIBNAME).$(PNGVER).dylib \
$(OBJSDLL) -L$(ZLIBLIB) -lz
pngtest: pngtest.o $(LIBNAME).dylib
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
test: pngtest
./pngtest
install-headers: png.h pngconf.h
-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
cp png.h pngconf.h $(DI)/$(LIBNAME)
chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
-@/bin/rm -f $(DI)/libpng
(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
install-static: install-headers libpng.a
-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
cp libpng.a $(DL)/$(LIBNAME).a
chmod 644 $(DL)/$(LIBNAME).a
-@/bin/rm -f $(DL)/libpng.a
(cd $(DL); ln -sf $(LIBNAME).a libpng.a)
install-shared: install-headers $(LIBNAME).dylib libpng.pc
-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-@/bin/rm -f $(DL)/$(LIBNAME).$(PNGMAJ)*.dylib
-@/bin/rm -f $(DL)/$(LIBNAME).dylib
-@/bin/rm -f $(DL)/libpng.dylib
-@/bin/rm -f $(DL)/libpng.3.dylib
-@/bin/rm -f $(DL)/libpng.3.*.dylib
cp $(LIBNAME).$(PNGVER).dylib $(DL)
chmod 755 $(DL)/$(LIBNAME).$(PNGVER).dylib
(cd $(DL); \
ln -sf $(LIBNAME).$(PNGVER).dylib libpng.dylib; \
ln -sf $(LIBNAME).$(PNGVER).dylib libpng.3.dylib; \
ln -sf $(LIBNAME).$(PNGVER).dylib libpng.3.$(PNGMIN).dylib; \
ln -sf $(LIBNAME).$(PNGVER).dylib $(LIBNAME).$(PNGMAJ).dylib; \
ln -sf $(LIBNAME).$(PNGMAJ).dylib $(LIBNAME).dylib)
-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
(cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
install-man: libpng.3 libpngpf.3 png.5
-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
-@/bin/rm -f $(DM)/man3/libpng.3
-@/bin/rm -f $(DM)/man3/libpngpf.3
cp libpng.3 $(DM)/man3
cp libpngpf.3 $(DM)/man3
-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
-@/bin/rm -f $(DM)/man5/png.5
cp png.5 $(DM)/man5
install-config: libpng-config
-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
-@/bin/rm -f $(DB)/libpng-config
-@/bin/rm -f $(DB)/$(LIBNAME)-config
cp libpng-config $(DB)/$(LIBNAME)-config
chmod 755 $(DB)/$(LIBNAME)-config
(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
install: install-static install-shared install-man install-config
# If you installed in $(DESTDIR), test-installed won't work until you
# move the library to its final location.
test-installed:
$(CC) $(CFLAGS) \
`$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
-L$(ZLIBLIB) \
-o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs`
./pngtesti pngtest.png
clean:
rm -f *.o libpng.a pngtest pngout.png libpng.pc libpng-config \
$(LIBNAME).*dylib pngtesti
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
writelock:
chmod a-w *.[ch35] $(DOCS) scripts/*
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o png.pic.o: png.h pngconf.h
pngerror.o pngerror.pic.o: png.h pngconf.h
pngrio.o pngrio.pic.o: png.h pngconf.h
pngwio.o pngwio.pic.o: png.h pngconf.h
pngmem.o pngmem.pic.o: png.h pngconf.h
pngset.o pngset.pic.o: png.h pngconf.h
pngget.o pngget.pic.o: png.h pngconf.h
pngread.o pngread.pic.o: png.h pngconf.h
pngrtran.o pngrtran.pic.o: png.h pngconf.h
pngrutil.o pngrutil.pic.o: png.h pngconf.h
pngtrans.o pngtrans.pic.o: png.h pngconf.h
pngwrite.o pngwrite.pic.o: png.h pngconf.h
pngwtran.o pngwtran.pic.o: png.h pngconf.h
pngwutil.o pngwutil.pic.o: png.h pngconf.h
pngpread.o pngpread.pic.o: png.h pngconf.h
pngtest.o: png.h pngconf.h

View File

@@ -1,5 +1,5 @@
# makefile for libpng on DEC Alpha Unix # makefile for libpng on DEC Alpha Unix
# Copyright (C) 2000 Glenn Randers-Pehrson # Copyright (C) 2000-2002 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h # For conditions of distribution and use, see copyright notice in png.h
@@ -7,6 +7,23 @@
prefix=/usr/local prefix=/usr/local
INCPATH=$(prefix)/include INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib LIBPATH=$(prefix)/lib
MANPATH=$(prefix)/man
BINPATH=$(prefix)/bin
# override DESTDIR= on the make install command line to easily support
# installing into a temporary location. Example:
#
# make install DESTDIR=/tmp/build/libpng
#
# If you're going to install into a temporary location
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
# you execute make install.
DESTDIR=
DB=$(DESTDIR)$(BINPATH)
DI=$(DESTDIR)$(INCPATH)
DL=$(DESTDIR)$(LIBPATH)
DM=$(DESTDIR)$(MANPATH)
# Where the zlib library and include files are located # Where the zlib library and include files are located
#ZLIBLIB=/usr/local/lib #ZLIBLIB=/usr/local/lib
@@ -14,11 +31,10 @@ LIBPATH=$(prefix)/lib
ZLIBLIB=../zlib ZLIBLIB=../zlib
ZLIBINC=../zlib ZLIBINC=../zlib
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not PNGMAJ = 0
# have to change it. PNGMIN = 1.0.14
PNGMAJ = 2
PNGMIN = 1.0.9
PNGVER = $(PNGMAJ).$(PNGMIN) PNGVER = $(PNGMAJ).$(PNGMIN)
LIBNAME = libpng10
CC=cc CC=cc
CFLAGS=-std -w1 -I$(ZLIBINC) -O # -g -DPNG_DEBUG=1 CFLAGS=-std -w1 -I$(ZLIBINC) -O # -g -DPNG_DEBUG=1
@@ -31,20 +47,34 @@ OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o pngwtran.o pngmem.o pngerror.o pngpread.o
all: libpng.so libpng.a pngtest all: $(LIBNAME).so libpng.a pngtest libpng.pc libpng-config
libpng.a: $(OBJS) libpng.a: $(OBJS)
ar rc $@ $(OBJS) ar rc $@ $(OBJS)
$(RANLIB) $@ $(RANLIB) $@
libpng.so: libpng.so.$(PNGMAJ) libpng.pc:
ln -f -s libpng.so.$(PNGMAJ) libpng.so cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
libpng.so.$(PNGMAJ): libpng.so.$(PNGVER) libpng-config:
ln -f -s libpng.so.$(PNGVER) libpng.so.$(PNGMAJ) ( cat scripts/libpng-config-head.in; \
echo prefix=\"$(prefix)\"; \
echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo cflags=\"-std\"; \
echo ldflags=\"-L$(LIBPATH)\"; \
echo libs=\"-lpng10 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config
libpng.so.$(PNGVER): $(OBJS) $(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
$(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB) -lz -lm ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER)
ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
$(LIBNAME).so.$(PNGVER): $(OBJS)
$(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB)
-soname $(LIBNAME).so.$(PNGMAJ) -lz -lm
pngtest: pngtest.o libpng.a pngtest: pngtest.o libpng.a
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
@@ -52,23 +82,79 @@ pngtest: pngtest.o libpng.a
test: pngtest test: pngtest
./pngtest ./pngtest
install: libpng.a libpng.so.$(PNGVER) install-headers: png.h pngconf.h
-@mkdir $(INCPATH) -@if [ ! -d $(DI) ]; then mkdir $(DI); fi
-@mkdir $(LIBPATH) -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
cp png.h $(INCPATH) cp png.h pngconf.h $(DI)/$(LIBNAME)
cp pngconf.h $(INCPATH) chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
chmod 644 $(INCPATH)/png.h -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
chmod 644 $(INCPATH)/pngconf.h -@/bin/rm -f $(DI)/libpng
cp libpng.a $(LIBPATH) (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
cp libpng.so.$(PNGVER) $(LIBPATH)
chmod 644 $(LIBPATH)/libpng.a install-static: install-headers libpng.a
chmod 644 $(LIBPATH)/libpng.so.$(PNGVER) -@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-@/bin/rm -f $(LIBPATH)/libpng.so.$(PNGMAJ) $(LIBPATH)/libpng.so cp libpng.a $(DL)/$(LIBNAME).a
(cd $(LIBPATH)); ln -f -s libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \ chmod 644 $(DL)/$(LIBNAME).a
ln -f -s libpng.so.$(PNGMAJ) libpng.so) -@/bin/rm -f $(DL)/libpng.a
(cd $(DL); ln -sf $(LIBNAME).a libpng.a)
install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
-@/bin/rm -f $(DL)/libpng.so
-@/bin/rm -f $(DL)/libpng.so.2
-@/bin/rm -f $(DL)/libpng.so.2.*
cp $(LIBNAME).so.$(PNGVER) $(DL)
chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
(cd $(DL); \
ln -sf $(LIBNAME).so.$(PNGVER) libpng.so; \
ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.2; \
ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.2.$(PNGMIN); \
ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
(cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
install-man: libpng.3 libpngpf.3 png.5
-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
-@/bin/rm -f $(DM)/man3/libpng.3
-@/bin/rm -f $(DM)/man3/libpngpf.3
cp libpng.3 $(DM)/man3
cp libpngpf.3 $(DM)/man3
-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
-@/bin/rm -f $(DM)/man5/png.5
cp png.5 $(DM)/man5
install-config: libpng-config
-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
-@/bin/rm -f $(DB)/libpng-config
-@/bin/rm -f $(DB)/$(LIBNAME)-config
cp libpng-config $(DB)/$(LIBNAME)-config
chmod 755 $(DB)/$(LIBNAME)-config
(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
install: install-static install-shared install-man install-config
# If you installed in $(DESTDIR), test-installed won't work until you
# move the library to its final location.
test-installed:
echo
echo Testing installed dynamic shared library.
$(CC) -std -w1 -I$(ZLIBINC) \
`$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
-L$(ZLIBLIB) -R$(ZLIBLIB) \
-o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs`
./pngtesti pngtest.png
clean: clean:
rm -f *.o libpng.a pngtest pngout.png libpng.so* /bin/rm -f *.o libpng.a pngtest pngtesti pngout.png libpng.pc \
libpng-config $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)*
# DO NOT DELETE THIS LINE -- make depend depends on it. # DO NOT DELETE THIS LINE -- make depend depends on it.

View File

@@ -1,10 +1,13 @@
# DJGPP (DOS gcc) makefile for libpng # DJGPP (DOS gcc) makefile for libpng
# Copyright (C) 2002 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h # For conditions of distribution and use, see copyright notice in png.h
# where make install puts libpng.a and png.h # where make install will put libpng.a and png.h
#prefix=/usr/local #prefix=/usr/local
prefix=. prefix=.
INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib
CC=gcc CC=gcc
CFLAGS=-I../zlib -O CFLAGS=-I../zlib -O

48
scripts/makefile.freebsd Normal file
View File

@@ -0,0 +1,48 @@
# makefile for libpng under FreeBSD
# Copyright (C) 2002 Glenn Randers-Pehrson and Andrey A. Chernov
# For conditions of distribution and use, see copyright notice in png.h
PREFIX?= /usr/local
SHLIB_VER?= 5
LIB= png
SHLIB_MAJOR= ${SHLIB_VER}
SHLIB_MINOR= 0
NOPROFILE= YES
NOOBJ= YES
# where make install puts libpng.a and png.h
DESTDIR= ${PREFIX}
LIBDIR= /lib
INCS= png.h pngconf.h
INCSDIR= /include/libpng
INCDIR= ${INCSDIR} # for 4.x bsd.lib.mk
MAN= libpng.3 libpngpf.3 png.5
MANDIR= /man/man
SYMLINKS= libpng/png.h ${INCSDIR}/../png.h \
libpng/pngconf.h ${INCSDIR}/../pngconf.h
LDADD+= -lm -lz
DPADD+= ${LIBM} ${LIBZ}
CFLAGS+= -I. -DPNG_USE_PNGGCCRD
.if (${MACHINE_ARCH} != "i386")
CFLAGS+= -DPNG_NO_ASSEMBLER_CODE
.endif
SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
pngwtran.c pngmem.c pngerror.c pngpread.c pnggccrd.c
pngtest: pngtest.o libpng.a
${CC} ${CFLAGS} -L. -static -o pngtest pngtest.o -lpng -lz -lm
CLEANFILES= pngtest pngtest.o pngout.png
test: pngtest
./pngtest
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
writelock:
chmod a-w *.[ch35] $(DOCS) scripts/*
.include <bsd.lib.mk>

View File

@@ -1,20 +1,31 @@
# makefile for libpng on Linux ELF with gcc using MMX assembler code # makefile for libpng.a and libpng10.so on Linux ELF with gcc using MMX
# Copyright 1996-1997 Andreas Dilger # assembler code
# Copyright 2002 Greg Roelofs and Glenn Randers-Pehrson
# Copyright 1998-2001 Greg Roelofs # Copyright 1998-2001 Greg Roelofs
# Copyright 1996-1997 Andreas Dilger
# For conditions of distribution and use, see copyright notice in png.h # For conditions of distribution and use, see copyright notice in png.h
# CAUTION: Do not use this makefile with gcc versions 2.7.2.2 and earlier. # CAUTION: Do not use this makefile with gcc versions 2.7.2.2 and earlier.
# WARNING: The assembler code in pnggccrd.c may not be thread safe.
# NOTE: When testing MMX performance on a multitasking system, make sure # NOTE: When testing MMX performance on a multitasking system, make sure
# there are no floating-point programs (e.g., SETI@Home) running in # there are no floating-point programs (e.g., SETI@Home) running in
# the background! Context switches between MMX and FPU are expensive. # the background! Context switches between MMX and FPU are expensive.
LIBNAME = libpng10
PNGMAJ = 0
PNGMIN = 1.0.14
PNGVER = $(PNGMAJ).$(PNGMIN)
CC=gcc CC=gcc
# where "make install" puts libpng.a, libpng.so*, png.h, and pngconf.h # where "make install" puts libpng10.a, libpng10.so*,
# libpng10/png.h and libpng10/pngconf.h
# Prefix must be a full pathname.
prefix=/usr/local prefix=/usr/local
# Where the zlib library and include files are located # Where the zlib library and include files are located.
#ZLIBLIB=/usr/local/lib #ZLIBLIB=/usr/local/lib
#ZLIBINC=/usr/local/include #ZLIBINC=/usr/local/include
ZLIBLIB=../zlib ZLIBLIB=../zlib
@@ -30,32 +41,45 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
# for pgcc version 2.95.1, -O3 is buggy; don't use it. # for pgcc version 2.95.1, -O3 is buggy; don't use it.
# Remove -DPNG_THREAD_UNSAFE_OK if you need thread safety
### for generic gcc: ### for generic gcc:
CFLAGS=-DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 $(ALIGN) -funroll-loops \ CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall \
-O3 $(ALIGN) -funroll-loops \
-fomit-frame-pointer # $(WARNMORE) -g -DPNG_DEBUG=5 -fomit-frame-pointer # $(WARNMORE) -g -DPNG_DEBUG=5
### for gcc 2.95.2 on 686: ### for gcc 2.95.2 on 686:
#CFLAGS=-DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 \ #CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 \
# -mcpu=i686 -malign-double -ffast-math -fstrict-aliasing \ # -mcpu=i686 -malign-double -ffast-math -fstrict-aliasing \
# $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer # $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer
### for gcc 2.7.2.3 on 486 and up: ### for gcc 2.7.2.3 on 486 and up:
#CFLAGS=-DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 \ #CFLAGS=-DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 \
# -m486 -malign-double -ffast-math \ # -m486 -malign-double -ffast-math \
# $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer # $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer
LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz -lm LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng10 -lz -lm
LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm
RANLIB=ranlib RANLIB=ranlib
#RANLIB=echo #RANLIB=echo
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0.9
PNGVER = $(PNGMAJ).$(PNGMIN)
INCPATH=$(prefix)/include INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib LIBPATH=$(prefix)/lib
MANPATH=$(prefix)/man
BINPATH=$(prefix)/bin
# override DESTDIR= on the make install command line to easily support
# installing into a temporary location. Example:
#
# make install DESTDIR=/tmp/build/libpng
#
# If you're going to install into a temporary location
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
# you execute make install.
DESTDIR=
DB=$(DESTDIR)$(BINPATH)
DI=$(DESTDIR)$(INCPATH)
DL=$(DESTDIR)$(LIBPATH)
DM=$(DESTDIR)$(MANPATH)
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -68,39 +92,44 @@ OBJSDLL = $(OBJS:.o=.pic.o)
.c.pic.o: .c.pic.o:
$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
all: libpng.a libpng.so pngtest pngtest-static all: libpng.a $(LIBNAME).so pngtest pngtest-static libpng.pc libpng-config
pnggccrd.o: pnggccrd.c png.h pngconf.h
@echo ""
@echo ' You can ignore the single "control reaches end of non-void function"'
@echo ' warning and multiple "<variable> defined but not used" warnings:'
@echo ""
$(CC) -c $(CFLAGS) -o $@ $*.c
@echo ""
pnggccrd.pic.o: pnggccrd.c png.h pngconf.h
@echo ""
@echo ' You can ignore the single "control reaches end of non-void function"'
@echo ' warning and multiple "<variable> defined but not used" warnings:'
@echo ""
$(CC) -c $(CFLAGS) -fPIC -o $@ pnggccrd.c
@echo ""
libpng.a: $(OBJS) libpng.a: $(OBJS)
ar rc $@ $(OBJS) ar rc $@ $(OBJS)
$(RANLIB) $@ $(RANLIB) $@
libpng.so: libpng.so.$(PNGMAJ) libpng.pc:
ln -sf libpng.so.$(PNGMAJ) libpng.so cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
libpng.so.$(PNGMAJ): libpng.so.$(PNGVER) libpng-config:
ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ) ( cat scripts/libpng-config-head.in; \
echo prefix=\"$(prefix)\"; \
echo cppflags=\"-I$(INCPATH)/$(LIBNAME) -DPNG_THREAD_UNSAFE_OK \
-DPNG_USE_PNGGCCRD\"; \
echo cflags=\"\"; \
echo ldflags=\"-L$(LIBPATH) -Wl,-rpath,$(LIBPATH)\"; \
echo libs=\"-lpng10 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config
libpng.so.$(PNGVER): $(OBJSDLL) pnggccrd.o: pnggccrd.c png.h pngconf.h
$(CC) -shared -Wl,-soname,libpng.so.$(PNGMAJ) -o libpng.so.$(PNGVER) \ $(CC) -c $(CFLAGS) -o $@ $*.c
$(OBJSDLL) -L$(ZLIBLIB) -lz -lm -lc
pngtest: pngtest.o libpng.so pnggccrd.pic.o: pnggccrd.c png.h pngconf.h
$(CC) -c $(CFLAGS) -fPIC -o $@ pnggccrd.c
$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER)
ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
$(LIBNAME).so.$(PNGVER): $(OBJSDLL)
$(CC) -shared -Wl,-soname,$(LIBNAME).so.$(PNGMAJ) \
-o $(LIBNAME).so.$(PNGVER) \
$(OBJSDLL) -L$(ZLIBLIB) -lz -lm -lc
pngtest: pngtest.o $(LIBNAME).so
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
pngtest-static: pngtest.o libpng.a pngtest-static: pngtest.o libpng.a
@@ -108,27 +137,85 @@ pngtest-static: pngtest.o libpng.a
test: pngtest pngtest-static test: pngtest pngtest-static
@echo "" @echo ""
@echo " Testing dynamically linked version:" @echo " Running pngtest dynamically linked with $(LIBNAME).so:"
@echo "" @echo ""
./pngtest ./pngtest
@echo "" @echo ""
@echo " Testing statically linked version:" @echo " Running pngtest statically linked with libpng.a:"
@echo "" @echo ""
./pngtest-static ./pngtest-static
install: libpng.a libpng.so.$(PNGVER) install-headers: png.h pngconf.h
-@if [ ! -d $(INCPATH) ]; then mkdir $(INCPATH); fi -@if [ ! -d $(DI) ]; then mkdir $(DI); fi
-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
cp png.h pngconf.h $(INCPATH) cp png.h pngconf.h $(DI)/$(LIBNAME)
chmod 644 $(INCPATH)/png.h $(INCPATH)/pngconf.h chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
cp libpng.a libpng.so.$(PNGVER) $(LIBPATH) -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
chmod 755 $(LIBPATH)/libpng.so.$(PNGVER) -@/bin/rm -f $(DI)/libpng
-@/bin/rm -f $(LIBPATH)/libpng.so.$(PNGMAJ) $(LIBPATH)/libpng.so (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
(cd $(LIBPATH); ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
ln -sf libpng.so.$(PNGMAJ) libpng.so) install-static: install-headers libpng.a
-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
cp libpng.a $(DL)/$(LIBNAME).a
chmod 644 $(DL)/$(LIBNAME).a
-@/bin/rm -f $(DL)/libpng.a
(cd $(DL); ln -sf $(LIBNAME).a libpng.a)
install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
-@/bin/rm -f $(DL)/libpng.so
-@/bin/rm -f $(DL)/libpng.so.2
-@/bin/rm -f $(DL)/libpng.so.2.*
cp $(LIBNAME).so.$(PNGVER) $(DL)
chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
(cd $(DL); \
ln -sf $(LIBNAME).so.$(PNGVER) libpng.so; \
ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.2; \
ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.2.$(PNGMIN); \
ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
(cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
install-man: libpng.3 libpngpf.3 png.5
-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
-@/bin/rm -f $(DM)/man3/libpng.3
-@/bin/rm -f $(DM)/man3/libpngpf.3
cp libpng.3 $(DM)/man3
cp libpngpf.3 $(DM)/man3
-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
-@/bin/rm -f $(DM)/man5/png.5
cp png.5 $(DM)/man5
install-config: libpng-config
-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
-@/bin/rm -f $(DB)/libpng-config
-@/bin/rm -f $(DB)/$(LIBNAME)-config
cp libpng-config $(DB)/$(LIBNAME)-config
chmod 755 $(DB)/$(LIBNAME)-config
(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
install: install-static install-shared install-man install-config
# If you installed in $(DESTDIR), test-installed won't work until you
# move the library to its final location.
test-installed:
$(CC) -I$(ZLIBINC) \
`$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
-o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs`
./pngtesti pngtest.png
clean: clean:
/bin/rm -f *.o libpng.a libpng.so* pngtest pngout.png /bin/rm -f *.o libpng.a pngtest pngout.png libpng.pc libpng-config \
$(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest-static pngtesti
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
writelock: writelock:

208
scripts/makefile.hpgcc Normal file
View File

@@ -0,0 +1,208 @@
# makefile for libpng on HP-UX using GCC
# Copyright (C) 2002, Glenn Randers-Pehrson
# Copyright (C) 2001, Laurent faillie
# Copyright (C) 1998, 1999 Greg Roelofs
# Copyright (C) 1996, 1997 Andreas Dilger
# For conditions of distribution and use, see copyright notice in png.h
CC=gcc
# where "make install" puts libpng.a, libpng.so*, png.h and pngconf.h
prefix=/usr/local
# Where the zlib library and include files are located
ZLIBLIB=/opt/zlib/lib
ZLIBINC=/opt/zlib/include
ALIGN=
# for i386:
#ALIGN=-malign-loops=2 -malign-functions=2
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
# for pgcc version 2.95.1, -O3 is buggy; don't use it.
CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \
$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
#LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng10 -lz -lm
LDFLAGS=-L. -L$(ZLIBLIB) -lpng10 -lz -lm
RANLIB=ranlib
#RANLIB=echo
PNGMAJ = 0
PNGMIN = 1.0.14
PNGVER = $(PNGMAJ).$(PNGMIN)
LIBNAME = libpng10
INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib
MANPATH=$(prefix)/man
BINPATH=$(prefix)/bin
# override DESTDIR= on the make install command line to easily support
# installing into a temporary location. Example:
#
# make install DESTDIR=/tmp/build/libpng
#
# If you're going to install into a temporary location
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
# you execute make install.
DESTDIR=
DB=$(DESTDIR)$(BINPATH)
DI=$(DESTDIR)$(INCPATH)
DL=$(DESTDIR)$(LIBPATH)
DM=$(DESTDIR)$(MANPATH)
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o
OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o
.c.pic.o:
$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
all: libpng.a $(LIBNAME).sl pngtest libpng.pc libpng-config
libpng.a: $(OBJS)
ar rc $@ $(OBJS)
$(RANLIB) $@
libpng.pc:
cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
libpng-config:
( cat scripts/libpng-config-head.in; \
echo prefix=\"$(prefix)\"; \
echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo cflags=\"\"; \
echo ldflags=\"\"; \
echo libs=\"-lpng10 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config
$(LIBNAME).sl: $(LIBNAME).sl.$(PNGMAJ)
ln -f -s $(LIBNAME).sl.$(PNGMAJ) $(LIBNAME).sl
$(LIBNAME).sl.$(PNGMAJ): $(LIBNAME).sl.$(PNGVER)
ln -f -s $(LIBNAME).sl.$(PNGVER) $(LIBNAME).sl.$(PNGMAJ)
$(LIBNAME).sl.$(PNGVER): $(OBJSDLL)
$(LD) -b -L$(ZLIBLIB) +s +b $(ZLIBLIB) \
+h libpng.sl.$(PNGMAJ) -o libpng.sl.$(PNGVER) $(OBJSDLL) -lz
pngtest: pngtest.o $(LIBNAME).sl
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
test: pngtest
./pngtest
install-headers: png.h pngconf.h
-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
cp png.h pngconf.h $(DI)/$(LIBNAME)
chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
-@/bin/rm -f $(DI)/libpng
(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
install-static: install-headers libpng.a
-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
cp libpng.a $(DL)/$(LIBNAME).a
chmod 644 $(DL)/$(LIBNAME).a
-@/bin/rm -f $(DL)/libpng.a
(cd $(DL); ln -sf $(LIBNAME).a libpng.a)
install-shared: install-headers $(LIBNAME).sl.$(PNGVER) libpng.pc
-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-@/bin/rm -f $(DL)/$(LIBNAME).sl.$(PNGMAJ)* $(DL)/$(LIBNAME).sl
-@/bin/rm -f $(DL)/libpng.so
-@/bin/rm -f $(DL)/libpng.so.2
-@/bin/rm -f $(DL)/libpng.so.2.*
cp $(LIBNAME).sl.$(PNGVER) $(DL)
chmod 755 $(DL)/$(LIBNAME).sl.$(PNGVER)
(cd $(DL); \
ln -sf $(LIBNAME).so.$(PNGVER) libpng.so; \
ln -sf $(LIBNAME).sl.$(PNGVER) libpng.sl.3; \
ln -sf $(LIBNAME).sl.$(PNGVER) libpng.sl.3.$(PNGMIN); \
ln -sf $(LIBNAME).sl.$(PNGVER) $(LIBNAME).sl.$(PNGMAJ); \
ln -sf $(LIBNAME).sl.$(PNGMAJ) $(LIBNAME).sl)
-@if [ ! -d $(DL)/pkgconfig ]; then mkdir \
$(DL)/pkgconfig; fi
-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
(cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
install-man: libpng.3 libpngpf.3 png.5
-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
-@/bin/rm -f $(DM)/man3/libpng.3
-@/bin/rm -f $(DM)/man3/libpngpf.3
cp libpng.3 $(DM)/man3
cp libpngpf.3 $(DM)/man3
-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
-@/bin/rm -f $(DM)/man5/png.5
cp png.5 $(DM)/man5
install-config: libpng-config
-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
-@/bin/rm -f $(DB)/libpng-config
-@/bin/rm -f $(DB)/$(LIBNAME)-config
cp libpng-config $(DB)/$(LIBNAME)-config
chmod 755 $(DB)/$(LIBNAME)-config
(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
install: install-static install-shared install-man install-config
# If you installed in $(DESTDIR), test-installed won't work until you
# move the library to its final location.
test-installed:
echo
echo Testing installed dynamic shared library.
$(CC) -I$(ZLIBINC) \
`$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
-o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs`
./pngtesti pngtest.png
clean:
/bin/rm -f *.o libpng.a pngtest pngtesti pngout.png libpng.pc \
libpng-config $(LIBNAME).sl $(LIBNAME).sl.$(PNGMAJ)*
clean:
/bin/rm -f *.o libpng.a $(SHAREDLIB).sl $(SHAREDLIB).sl.$(PNGMAJ)* \
pngtest pngout.png
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
writelock:
chmod a-w *.[ch35] $(DOCS) scripts/*
# DO NOT DELETE THIS LINE -- make depend depends on it.
png.o png.pic.o: png.h pngconf.h
pngerror.o pngerror.pic.o: png.h pngconf.h
pngrio.o pngrio.pic.o: png.h pngconf.h
pngwio.o pngwio.pic.o: png.h pngconf.h
pngmem.o pngmem.pic.o: png.h pngconf.h
pngset.o pngset.pic.o: png.h pngconf.h
pngget.o pngget.pic.o: png.h pngconf.h
pngread.o pngread.pic.o: png.h pngconf.h
pngrtran.o pngrtran.pic.o: png.h pngconf.h
pngrutil.o pngrutil.pic.o: png.h pngconf.h
pngtrans.o pngtrans.pic.o: png.h pngconf.h
pngwrite.o pngwrite.pic.o: png.h pngconf.h
pngwtran.o pngwtran.pic.o: png.h pngconf.h
pngwutil.o pngwutil.pic.o: png.h pngconf.h
pngpread.o pngpread.pic.o: png.h pngconf.h
pngtest.o: png.h pngconf.h

View File

@@ -1,5 +1,5 @@
# makefile for libpng, HPUX (10.20 and 11.00) # makefile for libpng, HPUX (10.20 and 11.00)
# Copyright (C) 1999, 2000 Glenn Randers-Pehrson # Copyright (C) 1999-2002 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42 # Copyright (C) 1995 Guy Eric Schalnat, Group 42
# contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard # contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard
# For conditions of distribution and use, see copyright notice in png.h # For conditions of distribution and use, see copyright notice in png.h
@@ -10,19 +10,38 @@ ZLIBINC=/opt/zlib/include
CC=cc CC=cc
CFLAGS=-I$(ZLIBINC) -O -Ae +DA1.1 +DS2.0 CFLAGS=-I$(ZLIBINC) -O -Ae +DA1.1 +DS2.0
# Caution: be sure you have built zlib with the same CFLAGS.
CCFLAGS=-I$(ZLIBINC) -O -Ae +DA1.1 +DS2.0 CCFLAGS=-I$(ZLIBINC) -O -Ae +DA1.1 +DS2.0
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
RANLIB=ranlib RANLIB=ranlib
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not PNGMAJ = 0
# have to change it. PNGMIN = 1.0.14
PNGMAJ = 2
PNGMIN = 1.0.9
PNGVER = $(PNGMAJ).$(PNGMIN) PNGVER = $(PNGMAJ).$(PNGMIN)
LIBNAME = libpng10
# where make install puts libpng.a and png.h # where make install puts libpng.a, libpng10.sl, and png.h
prefix=/opt/libpng prefix=/opt/libpng
INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib
MANPATH=$(prefix)/man
BINPATH=$(prefix)/bin
# override DESTDIR= on the make install command line to easily support
# installing into a temporary location. Example:
#
# make install DESTDIR=/tmp/build/libpng
#
# If you're going to install into a temporary location
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
# you execute make install.
DESTDIR=
DB=$(DESTDIR)$(BINPATH)
DI=$(DESTDIR)$(INCPATH)
DL=$(DESTDIR)$(LIBPATH)
DM=$(DESTDIR)$(MANPATH)
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -35,21 +54,35 @@ OBJSDLL = $(OBJS:.o=.pic.o)
.c.pic.o: .c.pic.o:
$(CC) -c $(CFLAGS) +z -o $@ $*.c $(CC) -c $(CFLAGS) +z -o $@ $*.c
all: libpng.a libpng.sl pngtest all: libpng.a $(LIBNAME).sl pngtest libpng.pc libpng-config
libpng.a: $(OBJS) libpng.a: $(OBJS)
ar rc $@ $(OBJS) ar rc $@ $(OBJS)
$(RANLIB) $@ $(RANLIB) $@
libpng.sl: libpng.sl.$(PNGMAJ) libpng.pc:
ln -f -s libpng.sl.$(PNGMAJ) libpng.sl cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
libpng.sl.$(PNGMAJ): libpng.sl.$(PNGVER) libpng-config:
ln -f -s libpng.sl.$(PNGVER) libpng.sl.$(PNGMAJ) ( cat scripts/libpng-config-head.in; \
echo prefix=\"$(prefix)\"; \
echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo cflags=\"-Ae +DA1.1 +DS2.0"; \
echo ldflags=\"-L$(LIBPATH)\"; \
echo libs=\"-lpng10 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config
libpng.sl.$(PNGVER): $(OBJSDLL) $(LIBNAME).sl: $(LIBNAME).sl.$(PNGMAJ)
ln -sf $(LIBNAME).sl.$(PNGMAJ) $(LIBNAME).sl
$(LIBNAME).sl.$(PNGMAJ): $(LIBNAME).sl.$(PNGVER)
ln -sf $(LIBNAME).sl.$(PNGVER) $(LIBNAME).sl.$(PNGMAJ)
$(LIBNAME).sl.$(PNGVER): $(OBJSDLL)
$(LD) -b -L$(ZLIBLIB) +s +b $(ZLIBLIB) \ $(LD) -b -L$(ZLIBLIB) +s +b $(ZLIBLIB) \
+h libpng.sl.$(PNGMAJ) -o libpng.sl.$(PNGVER) $(OBJSDLL) -lz +h $(LIBNAME).sl.$(PNGMAJ) -o $(LIBNAME).sl.$(PNGVER) \
$(OBJSDLL) -lz
pngtest: pngtest.o libpng.a pngtest: pngtest.o libpng.a
$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS) $(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
@@ -57,21 +90,79 @@ pngtest: pngtest.o libpng.a
test: pngtest test: pngtest
./pngtest ./pngtest
install: libpng.a install-headers: png.h pngconf.h
-@mkdir $(prefix)/include -@if [ ! -d $(DI) ]; then mkdir $(DI); fi
-@mkdir $(prefix)/lib -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
cp png.h $(prefix)/include cp png.h pngconf.h $(DI)/$(LIBNAME)
cp pngconf.h $(prefix)/include chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
chmod 644 $(prefix)/include/png.h -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
chmod 644 $(prefix)/include/pngconf.h -@/bin/rm -f $(DI)/libpng
cp libpng.a libpng.sl.$(PNGVER) $(prefix)/lib (cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
chmod 644 $(prefix)/lib/libpng.a
chmod 755 $(prefix)/lib/libpng.sl.$(PNGVER) install-static: install-headers libpng.a
(cd $(prefix)/lib; ln -f -s libpng.sl.$(PNGVER) libpng.sl.$(PNGMAJ); \ -@if [ ! -d $(DL) ]; then mkdir $(DL); fi
ln -f -s libpng.sl.$(PNGMAJ) libpng.sl) cp libpng.a $(DL)/$(LIBNAME).a
chmod 644 $(DL)/$(LIBNAME).a
-@/bin/rm -f $(DL)/libpng.a
(cd $(DL); ln -sf $(LIBNAME).a libpng.a)
install-shared: install-headers $(LIBNAME).sl.$(PNGVER) libpng.pc
-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-@/bin/rm -f $(DL)/$(LIBNAME).sl.$(PNGMAJ)* $(DL)/$(LIBNAME).sl
-@/bin/rm -f $(DL)/libpng.sl
-@/bin/rm -f $(DL)/libpng.sl.3
-@/bin/rm -f $(DL)/libpng.sl.3.*
cp $(LIBNAME).sl.$(PNGVER) $(DL)
chmod 755 $(DL)/$(LIBNAME).sl.$(PNGVER)
(cd $(DL); \
ln -sf $(LIBNAME).sl.$(PNGVER) libpng.sl; \
ln -sf $(LIBNAME).sl.$(PNGVER) libpng.sl.3; \
ln -sf $(LIBNAME).sl.$(PNGVER) libpng.sl.3.$(PNGMIN); \
ln -sf $(LIBNAME).sl.$(PNGVER) $(LIBNAME).sl.$(PNGMAJ); \
ln -sf $(LIBNAME).sl.$(PNGMAJ) $(LIBNAME).sl)
-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
(cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
install-man: libpng.3 libpngpf.3 png.5
-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
-@/bin/rm -f $(DM)/man3/libpng.3
-@/bin/rm -f $(DM)/man3/libpngpf.3
cp libpng.3 $(DM)/man3
cp libpngpf.3 $(DM)/man3
-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
-@/bin/rm -f $(DM)/man5/png.5
cp png.5 $(DM)/man5
install-config: libpng-config
-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
-@/bin/rm -f $(DB)/libpng-config
-@/bin/rm -f $(DB)/$(LIBNAME)-config
cp libpng-config $(DB)/$(LIBNAME)-config
chmod 755 $(DB)/$(LIBNAME)-config
(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
install: install-static install-shared install-man install-config
# If you installed in $(DESTDIR), test-installed won't work until you
# move the library to its final location.
test-installed:
echo
echo Testing installed dynamic shared library.
$(CC) $(CCFLAGS) \
`$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
-L$(ZLIBLIB) \
-o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs`
./pngtesti pngtest.png
clean: clean:
rm -f *.o libpng.a libpng.sl* pngtest pngout.png /bin/rm -f *.o libpng.a pngtest pngtesti pngout.png libpng.pc \
libpng-config $(LIBNAME).sl $(LIBNAME).sl.$(PNGMAJ)*
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
writelock: writelock:

View File

@@ -5,7 +5,7 @@
# Notes: # Notes:
# Derived from makefile.std # Derived from makefile.std
# All modules are compiled in C mode # All modules are compiled in C mode
# Tested with IBM C 3.6.5 under Win32, expected to work under OS/2 too # Tested under Win32, expected to work under OS/2
# Can be easily adapted for IBM VisualAge/C++ for AIX # Can be easily adapted for IBM VisualAge/C++ for AIX
# Location of the zlib library and include files # Location of the zlib library and include files
@@ -18,7 +18,7 @@ LD = ilink
AR = ilib AR = ilib
RM = del RM = del
CFLAGS = -I$(ZLIBINC) -O2 -W3 CFLAGS = -I$(ZLIBINC) -Mc -O2 -W3
LDFLAGS = LDFLAGS =
# File extensions # File extensions

View File

@@ -1,4 +1,5 @@
# makefile for libpng # makefile for libpng
# Copyright (C) 2002 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h # For conditions of distribution and use, see copyright notice in png.h
@@ -9,6 +10,18 @@
# where make install puts libpng.a and png.h # where make install puts libpng.a and png.h
prefix=/usr/local prefix=/usr/local
INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib
# override DESTDIR= on the make install command line to easily support
# installing into a temporary location. Example:
#
# make install DESTDIR=/tmp/build/libpng
#
# If you're going to install into a temporary location
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
# you execute make install.
DESTDIR=
CC=cc CC=cc
CFLAGS=-I../zlib -O CFLAGS=-I../zlib -O
@@ -46,14 +59,18 @@ test: pngtest
./pngtest ./pngtest
install: libpng.a install: libpng.a
-@mkdir $(prefix)/include -@mkdir $(DESTDIR)$(INCPATH)
-@mkdir $(prefix)/lib -@mkdir $(DESTDIR)$(INCPATH)/libpng
cp png.h $(prefix)/include -@mkdir $(DESTDIR)$(LIBPATH)
cp pngconf.h $(prefix)/include -@rm -f $(DESTDIR)$(INCPATH)/png.h
chmod 644 $(prefix)/include/png.h -@rm -f $(DESTDIR)$(INCPATH)/pngconf.h
chmod 644 $(prefix)/include/pngconf.h cp png.h $(DESTDIR)$(INCPATH)/libpng
cp libpng.a $(prefix)/lib cp pngconf.h $(DESTDIR)$(INCPATH)/libpng
chmod 644 $(prefix)/lib/libpng.a chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h
chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h
(cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .)
cp libpng.a $(DESTDIR)$(LIBPATH)
chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a
clean: clean:
rm -f *.o libpng.a pngtest pngout.png ansi2knr rm -f *.o libpng.a pngtest pngout.png ansi2knr

View File

@@ -1,14 +1,21 @@
# makefile for libpng on Linux ELF with gcc # makefile for libpng.a and libpng10.so on Linux ELF with gcc
# Copyright (C) 1998, 1999 Greg Roelofs # Copyright (C) 1998, 1999, 2002 Greg Roelofs and Glenn Randers-Pehrson
# Copyright (C) 1996, 1997 Andreas Dilger # Copyright (C) 1996, 1997 Andreas Dilger
# For conditions of distribution and use, see copyright notice in png.h # For conditions of distribution and use, see copyright notice in png.h
LIBNAME = libpng10
PNGMAJ = 0
PNGMIN = 1.0.14
PNGVER = $(PNGMAJ).$(PNGMIN)
CC=gcc CC=gcc
# where "make install" puts libpng.a, libpng.so*, png.h and pngconf.h # where "make install" puts libpng10.a, libpng10.so*,
# libpng10/png.h and libpng10/pngconf.h
# Prefix must be a full pathname.
prefix=/usr/local prefix=/usr/local
# Where the zlib library and include files are located # Where the zlib library and include files are located.
#ZLIBLIB=/usr/local/lib #ZLIBLIB=/usr/local/lib
#ZLIBINC=/usr/local/include #ZLIBINC=/usr/local/include
ZLIBLIB=../zlib ZLIBLIB=../zlib
@@ -26,19 +33,32 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \ CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \
$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz -lm
LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng10 -lz -lm
LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm
RANLIB=ranlib RANLIB=ranlib
#RANLIB=echo #RANLIB=echo
# read libpng.txt or png.h to see why PNGMAJ is 2. You should not
# have to change it.
PNGMAJ = 2
PNGMIN = 1.0.9
PNGVER = $(PNGMAJ).$(PNGMIN)
INCPATH=$(prefix)/include INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib LIBPATH=$(prefix)/lib
MANPATH=$(prefix)/man
BINPATH=$(prefix)/bin
# override DESTDIR= on the make install command line to easily support
# installing into a temporary location. Example:
#
# make install DESTDIR=/tmp/build/libpng
#
# If you're going to install into a temporary location
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
# you execute make install.
DESTDIR=
DB=$(DESTDIR)$(BINPATH)
DI=$(DESTDIR)$(INCPATH)
DL=$(DESTDIR)$(LIBPATH)
DM=$(DESTDIR)$(MANPATH)
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -51,41 +71,123 @@ OBJSDLL = $(OBJS:.o=.pic.o)
.c.pic.o: .c.pic.o:
$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c $(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
all: libpng.a libpng.so pngtest all: libpng.a $(LIBNAME).so pngtest pngtest-static libpng.pc libpng-config
libpng.a: $(OBJS) libpng.a: $(OBJS)
ar rc $@ $(OBJS) ar rc $@ $(OBJS)
$(RANLIB) $@ $(RANLIB) $@
libpng.so: libpng.so.$(PNGMAJ) libpng.pc:
ln -sf libpng.so.$(PNGMAJ) libpng.so cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
libpng.so.$(PNGMAJ): libpng.so.$(PNGVER) libpng-config:
ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ) ( cat scripts/libpng-config-head.in; \
echo prefix=\"$(prefix)\"; \
echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo cflags=\"\"; \
echo ldflags=\"-L$(LIBPATH) -Wl,-rpath,$(LIBPATH)\"; \
echo libs=\"-lpng10 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config
libpng.so.$(PNGVER): $(OBJSDLL) $(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
$(CC) -shared -Wl,-soname,libpng.so.$(PNGMAJ) -o libpng.so.$(PNGVER) \ ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
$(OBJSDLL) -L$(ZLIBLIB) -lz -lm -lc
pngtest: pngtest.o libpng.so $(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER)
ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
$(LIBNAME).so.$(PNGVER): $(OBJSDLL)
$(CC) -shared -Wl,-soname,$(LIBNAME).so.$(PNGMAJ) \
-o $(LIBNAME).so.$(PNGVER) \
$(OBJSDLL) -L$(ZLIBLIB) -lz -lm -lc
pngtest: pngtest.o $(LIBNAME).so
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
test: pngtest pngtest-static: pngtest.o libpng.a
./pngtest $(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
install: libpng.a libpng.so.$(PNGVER) test: pngtest pngtest-static
-@if [ ! -d $(INCPATH) ]; then mkdir $(INCPATH); fi @echo ""
-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi @echo " Running pngtest dynamically linked with $(LIBNAME).so:"
cp png.h pngconf.h $(INCPATH) @echo ""
chmod 644 $(INCPATH)/png.h $(INCPATH)/pngconf.h ./pngtest
cp libpng.a libpng.so.$(PNGVER) $(LIBPATH) @echo ""
chmod 755 $(LIBPATH)/libpng.so.$(PNGVER) @echo " Running pngtest statically linked with libpng.a:"
-@/bin/rm -f $(LIBPATH)/libpng.so.$(PNGMAJ) $(LIBPATH)/libpng.so @echo ""
(cd $(LIBPATH); ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \ ./pngtest-static
ln -sf libpng.so.$(PNGMAJ) libpng.so)
install-headers: png.h pngconf.h
-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
cp png.h pngconf.h $(DI)/$(LIBNAME)
chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
-@/bin/rm -f $(DI)/libpng
(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
install-static: install-headers libpng.a
-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
cp libpng.a $(DL)/$(LIBNAME).a
chmod 644 $(DL)/$(LIBNAME).a
-@/bin/rm -f $(DL)/libpng.a
(cd $(DL); ln -sf $(LIBNAME).a libpng.a)
install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
-@/bin/rm -f $(DL)/libpng.so
-@/bin/rm -f $(DL)/libpng.so.2
-@/bin/rm -f $(DL)/libpng.so.2.*
cp $(LIBNAME).so.$(PNGVER) $(DL)
chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
(cd $(DL); \
ln -sf $(LIBNAME).so.$(PNGVER) libpng.so; \
ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.2; \
ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.2.$(PNGMIN); \
ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
(cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
install-man: libpng.3 libpngpf.3 png.5
-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
-@/bin/rm -f $(DM)/man3/libpng.3
-@/bin/rm -f $(DM)/man3/libpngpf.3
cp libpng.3 $(DM)/man3
cp libpngpf.3 $(DM)/man3
-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
-@/bin/rm -f $(DM)/man5/png.5
cp png.5 $(DM)/man5
install-config: libpng-config
-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
-@/bin/rm -f $(DB)/libpng-config
-@/bin/rm -f $(DB)/$(LIBNAME)-config
cp libpng-config $(DB)/$(LIBNAME)-config
chmod 755 $(DB)/$(LIBNAME)-config
(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
install: install-static install-shared install-man install-config
# If you installed in $(DESTDIR), test-installed won't work until you
# move the library to its final location.
test-installed:
$(CC) -I$(ZLIBINC) \
`$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
-o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs`
./pngtesti pngtest.png
clean: clean:
/bin/rm -f *.o libpng.a libpng.so* pngtest pngout.png /bin/rm -f *.o libpng.a pngtest pngout.png libpng.pc libpng-config \
$(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest-static pngtesti
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
writelock: writelock:

View File

@@ -1,5 +1,8 @@
# makefile for libpng, MACOS X # makefile for libpng, MACOS X
# Copyright (C) 2002 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# Modified by Karin Kosina <kyrah@sim.no> 20011010:
# build shared library (*.dylib)
# For conditions of distribution and use, see copyright notice in png.h # For conditions of distribution and use, see copyright notice in png.h
# where make install puts libpng.a and png.h # where make install puts libpng.a and png.h
@@ -12,8 +15,37 @@ ZLIBLIB=../zlib
ZLIBINC=../zlib ZLIBINC=../zlib
CC=cc CC=cc
CFLAGS=-I$(ZLIBINC) -O # -g -DPNG_DEBUG=5
PNGMAJ = 0
PNGMIN = 1.0.14
PNGVER = $(PNGMAJ).$(PNGMIN)
CFLAGS=-fno-common -I$(ZLIBINC) -O # -g -DPNG_DEBUG=5
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz
LDSHARED=cc -lz -dynamiclib -compatibility_version $(PNGVER) \
-current_version $(PNGVER)
LIBNAME=libpng10
SHAREDLIB_POSTFIX=dylib
INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib
MANPATH=$(prefix)/man
BINPATH=$(prefix)/bin
# override DESTDIR= on the make install command line to easily support
# installing into a temporary location. Example:
#
# make install DESTDIR=/tmp/build/libpng
#
# If you're going to install into a temporary location
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
# you execute make install.
DESTDIR=
DB=$(DESTDIR)$(BINPATH)
DI=$(DESTDIR)$(INCPATH)
DL=$(DESTDIR)$(LIBPATH)
DM=$(DESTDIR)$(MANPATH)
#RANLIB=echo #RANLIB=echo
RANLIB=ranlib RANLIB=ranlib
@@ -22,30 +54,116 @@ OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
pngwtran.o pngmem.o pngerror.o pngpread.o pngwtran.o pngmem.o pngerror.o pngpread.o
all: libpng.a pngtest all: libpng.a pngtest shared libpng.pc libpng-config
shared: $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX)
libpng.pc:
cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \
sed -e s/-lm// > libpng.pc
libpng-config:
( cat scripts/libpng-config-head.in; \
echo prefix=\"$(prefix)\"; \
echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo cflags=\"\"; \
echo ldflags=\"-L$(LIBPATH)\"; \
echo libs=\"-lpng10 -lz\"; \
cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config
libpng.a: $(OBJS) libpng.a: $(OBJS)
ar rc $@ $(OBJS) ar rc $@ $(OBJS)
$(RANLIB) $@ $(RANLIB) $@
$(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX): $(OBJS)
$(LDSHARED) -o $@ $(OBJS)
pngtest: pngtest.o libpng.a pngtest: pngtest.o libpng.a
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS) $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
test: pngtest test: pngtest
./pngtest ./pngtest
install: libpng.a install-headers: png.h pngconf.h
-@mkdir $(prefix)/include -@if [ ! -d $(DI) ]; then mkdir $(DI); fi
-@mkdir $(prefix)/lib -@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
cp png.h $(prefix)/include cp png.h pngconf.h $(DI)/$(LIBNAME)
cp pngconf.h $(prefix)/include chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
chmod 644 $(prefix)/include/png.h -@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
chmod 644 $(prefix)/include/pngconf.h -@/bin/rm -f $(DI)/libpng
cp libpng.a $(prefix)/lib (cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .)
chmod 644 $(prefix)/lib/libpng.a
install-static: install-headers libpng.a
-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
cp libpng.a $(DL)/$(LIBNAME).a
chmod 644 $(DL)/$(LIBNAME).a
-@/bin/rm -f $(DL)/libpng.a
(cd $(DL); ln -f -s $(LIBNAME).a libpng.a)
install-shared: install-headers $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) libpng.pc
-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
-@/bin/rm -f \
$(DL)/$(LIBNAME).$(PNGMAJ)*.$(SHAREDLIB_POSTFIX)
-@/bin/rm -f $(DL)/$(LIBNAME).$(SHAREDLIB_POSTFIX)
-@/bin/rm -f libpng.$(SHARED_POSTFIX)
-@/bin/rm -f libpng.3.$(SHARED_POSTFIX)
-@/bin/rm -f libpng.3.*.$(SHARED_POSTFIX)
cp $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) $(DL)
chmod 755 $(DL)/$(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX)
(cd $(DL); \
ln -f -s $(LIBNAME).$(PNGVER).$(SHARED_POSTFIX) \
libpng.$(SHARED_POSTFIX); \
ln -f -s $(LIBNAME).$(PNGVER).$(SHARED_POSTFIX) \
libpng.3.$(SHARED_POSTFIX); \
ln -f -s $(LIBNAME).$(PNGVER).$(SHARED_POSTFIX) \
libpng.3.$(PNGMIN).$(SHARED_POSTFIX); \
ln -f -s $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) \
$(LIBNAME).$(PNGMAJ).$(SHAREDLIB_POSTFIX); \
ln -f -s $(LIBNAME).$(PNGMAJ).$(SHAREDLIB_POSTFIX) \
$(LIBNAME).$(SHAREDLIB_POSTFIX))
-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
(cd $(DL)/pkgconfig; ln -f -s $(LIBNAME).pc libpng.pc)
install-man: libpng.3 libpngpf.3 png.5
-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
-@/bin/rm -f $(DM)/man3/libpng.3
-@/bin/rm -f $(DM)/man3/libpngpf.3
cp libpng.3 $(DM)/man3
cp libpngpf.3 $(DM)/man3
-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
-@/bin/rm -f $(DM)/man5/png.5
cp png.5 $(DM)/man5
install-config: libpng-config
-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
-@/bin/rm -f $(DB)/libpng-config
-@/bin/rm -f $(DB)/$(LIBNAME)-config
cp libpng-config $(DB)/$(LIBNAME)-config
chmod 755 $(DB)/$(LIBNAME)-config
(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
install: install-static install-shared install-man install-config
# If you installed in $(DESTDIR), test-installed won't work until you
# move the library to its final location.
test-installed:
$(CC) $(CFLAGS) \
`$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
-L$(ZLIBLIB) \
-o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs`
./pngtesti pngtest.png
clean: clean:
rm -f *.o libpng.a pngtest pngout.png rm -f *.o libpng.a pngtest pngout.png libpng.pc libpng-config \
$(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) \
$(LIBNAME).$(SHAREDLIB_POSTFIX)
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
writelock: writelock:

View File

@@ -1,9 +1,22 @@
# makefile for libpng # makefile for libpng
# Copyright (C) Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# For conditions of distribution and use, see copyright notice in png.h # For conditions of distribution and use, see copyright notice in png.h
# where make install puts libpng.a and png.h # where make install puts libpng.a and png.h
prefix=/usr/local prefix=/usr/local
INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib
# override DESTDIR= on the make install command line to easily support
# installing into a temporary location. Example:
#
# make install DESTDIR=/tmp/build/libpng
#
# If you're going to install into a temporary location
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
# you execute make install.
DESTDIR=
CC=cc CC=cc
CFLAGS=-I../zlib -O -systype sysv -DSYSV -w -Dmips CFLAGS=-I../zlib -O -systype sysv -DSYSV -w -Dmips
@@ -30,14 +43,18 @@ test: pngtest
./pngtest ./pngtest
install: libpng.a install: libpng.a
-@mkdir $(prefix)/include -@mkdir $(DESTDIR)$(INCPATH)
-@mkdir $(prefix)/lib -@mkdir $(DESTDIR)$(INCPATH)/libpng
cp png.h $(prefix)/include -@mkdir $(DESTDIR)$(LIBPATH)
cp pngconf.h $(prefix)/include -@rm -f $(DESTDIR)$(INCPATH)/png.h
chmod 644 $(prefix)/include/png.h -@rm -f $(DESTDIR)$(INCPATH)/pngconf.h
chmod 644 $(prefix)/include/pngconf.h cp png.h $(DESTDIR)$(INCPATH)/libpng
cp libpng.a $(prefix)/lib cp pngconf.h $(DESTDIR)$(INCPATH)/libpng
chmod 644 $(prefix)/lib/libpng.a chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h
chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h
(cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .)
cp libpng.a $(DESTDIR)$(LIBPATH)
chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a
clean: clean:
rm -f *.o libpng.a pngtest pngout.png rm -f *.o libpng.a pngtest pngout.png

44
scripts/makefile.ne10bsd Normal file
View File

@@ -0,0 +1,44 @@
# makefile for libpng for NetBSD for the standard
# make obj && make depend && make && make test
# make includes && make install
# Copyright (C) 2002 Patrick R.L. Welche
# For conditions of distribution and use, see copyright notice in png.h
# You should also run makefile.netbsd
LOCALBASE?=/usr/local
LIBDIR= ${LOCALBASE}/lib
MANDIR= ${LOCALBASE}/man
INCSDIR=${LOCALBASE}/include/libpng10
LIB= png10
SHLIB_MAJOR= 0
SHLIB_MINOR= 1.0.14
SRCS= pnggccrd.c png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
pngwtran.c pngmem.c pngerror.c pngpread.c
INCS= png.h pngconf.h
MAN= libpng.3 libpngpf.3 png.5
CPPFLAGS+=-I${.CURDIR} -DPNG_USE_PNGGCCRD
# something like this for mmx assembler, but it core dumps for me at the moment
# .if ${MACHINE_ARCH} == "i386"
# CPPFLAGS+=-DPNG_THREAD_UNSAFE_OK
# MKLINT= no
# .else
CPPFLAGS+=-DPNG_NO_ASSEMBLER_CODE
# .endif
CLEANFILES+=pngtest.o pngtest
pngtest.o: pngtest.c
${CC} -c ${CPPFLAGS} ${CFLAGS} ${.ALLSRC} -o ${.TARGET}
pngtest: pngtest.o libpng.a
${CC} ${LDFLAGS} ${.ALLSRC} -o${.TARGET} -lz -lm
test: pngtest
cd ${.CURDIR} && ${.OBJDIR}/pngtest
.include <bsd.lib.mk>

44
scripts/makefile.ne12bsd Normal file
View File

@@ -0,0 +1,44 @@
# makefile for libpng for NetBSD for the standard
# make obj && make depend && make && make test
# make includes && make install
# Copyright (C) 2002 Patrick R.L. Welche
# For conditions of distribution and use, see copyright notice in png.h
# You should also run makefile.netbsd
LOCALBASE?=/usr/local
LIBDIR= ${LOCALBASE}/lib
MANDIR= ${LOCALBASE}/man
INCSDIR=${LOCALBASE}/include/libpng10
LIB= png10
SHLIB_MAJOR= 0
SHLIB_MINOR= 1.0.14
SRCS= pnggccrd.c png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
pngwtran.c pngmem.c pngerror.c pngpread.c
INCS= png.h pngconf.h
MAN= libpng.3 libpngpf.3 png.5
CPPFLAGS+=-I${.CURDIR} -DPNG_USE_PNGGCCRD
# something like this for mmx assembler, but it core dumps for me at the moment
# .if ${MACHINE_ARCH} == "i386"
# CPPFLAGS+=-DPNG_THREAD_UNSAFE_OK
# MKLINT= no
# .else
CPPFLAGS+=-DPNG_NO_ASSEMBLER_CODE
# .endif
CLEANFILES+=pngtest.o pngtest
pngtest.o: pngtest.c
${CC} -c ${CPPFLAGS} ${CFLAGS} ${.ALLSRC} -o ${.TARGET}
pngtest: pngtest.o libpng.a
${CC} ${LDFLAGS} ${.ALLSRC} -o${.TARGET} -lz -lm
test: pngtest
cd ${.CURDIR} && ${.OBJDIR}/pngtest
.include <bsd.lib.mk>

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